slirp: Drop dead code
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 24 Jun 2009 12:42:29 +0000 (14:42 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 29 Jun 2009 13:52:46 +0000 (08:52 -0500)
After all its years inside the qemu tree, there is no point in keeping
the dead code paths of slirp. This patch is a first round of removing
usually commented out code parts. More cleanups need to follow (and
maybe finally a proper reindention).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
26 files changed:
slirp/debug.c
slirp/debug.h
slirp/if.c
slirp/if.h
slirp/ip_icmp.c
slirp/ip_input.c
slirp/ip_output.c
slirp/libslirp.h
slirp/mbuf.c
slirp/mbuf.h
slirp/misc.c
slirp/misc.h
slirp/sbuf.c
slirp/slirp.c
slirp/slirp.h
slirp/socket.c
slirp/socket.h
slirp/tcp.h
slirp/tcp_input.c
slirp/tcp_output.c
slirp/tcp_subr.c
slirp/tcp_timer.c
slirp/tcp_timer.h
slirp/tcp_var.h
slirp/tftp.c
slirp/udp.c

index ac856ca19b42a022abb0f7bf211f96c8206f1642..6462c888f3a513d822c63bd459731d5eb2faf377 100644 (file)
@@ -9,127 +9,9 @@
 #include <slirp.h>
 
 FILE *dfd = NULL;
-#ifdef DEBUG
-int dostats = 1;
-#else
-int dostats = 0;
-#endif
 int slirp_debug = 0;
 
-/* Carry over one item from main.c so that the tty's restored.
- * Only done when the tty being used is /dev/tty --RedWolf */
-#ifndef CONFIG_QEMU
-extern struct termios slirp_tty_settings;
-extern int slirp_tty_restore;
-
-
-void
-debug_init(file, dbg)
-       char *file;
-       int dbg;
-{
-       /* Close the old debugging file */
-       if (dfd)
-          fclose(dfd);
-
-       dfd = fopen(file,"w");
-       if (dfd != NULL) {
-#if 0
-               fprintf(dfd,"Slirp %s - Debugging Started.\n", SLIRP_VERSION);
-#endif
-               fprintf(dfd,"Debugging Started level %i.\r\n",dbg);
-               fflush(dfd);
-               slirp_debug = dbg;
-       } else {
-               lprint("Error: Debugging file \"%s\" could not be opened: %s\r\n",
-                       file, strerror(errno));
-       }
-}
-
-/*
- * Dump a packet in the same format as tcpdump -x
- */
-#ifdef DEBUG
-void
-dump_packet(dat, n)
-       void *dat;
-       int n;
-{
-       u_char *pptr = (u_char *)dat;
-       int j,k;
-
-       n /= 16;
-       n++;
-       DEBUG_MISC((dfd, "PACKET DUMPED: \n"));
-       for(j = 0; j < n; j++) {
-               for(k = 0; k < 6; k++)
-                       DEBUG_MISC((dfd, "%02x ", *pptr++));
-               DEBUG_MISC((dfd, "\n"));
-               fflush(dfd);
-       }
-}
-#endif
-#endif
-
 #ifdef LOG_ENABLED
-#if 0
-/*
- * Statistic routines
- *
- * These will print statistics to the screen, the debug file (dfd), or
- * a buffer, depending on "type", so that the stats can be sent over
- * the link as well.
- */
-
-static void
-ttystats(ttyp)
-       struct ttys *ttyp;
-{
-       struct slirp_ifstats *is = &ttyp->ifstats;
-       char buff[512];
-
-       lprint(" \r\n");
-
-       if (IF_COMP & IF_COMPRESS)
-          strcpy(buff, "on");
-       else if (IF_COMP & IF_NOCOMPRESS)
-          strcpy(buff, "off");
-       else
-          strcpy(buff, "off (for now)");
-       lprint("Unit %d:\r\n", ttyp->unit);
-       lprint("  using %s encapsulation (VJ compression is %s)\r\n", (
-#ifdef USE_PPP
-              ttyp->proto==PROTO_PPP?"PPP":
-#endif
-              "SLIP"), buff);
-       lprint("  %d baudrate\r\n", ttyp->baud);
-       lprint("  interface is %s\r\n", ttyp->up?"up":"down");
-       lprint("  using fd %d, guardian pid is %d\r\n", ttyp->fd, ttyp->pid);
-#ifndef FULL_BOLT
-       lprint("  towrite is %d bytes\r\n", ttyp->towrite);
-#endif
-       if (ttyp->zeros)
-          lprint("  %d zeros have been typed\r\n", ttyp->zeros);
-       else if (ttyp->ones)
-          lprint("  %d ones have been typed\r\n", ttyp->ones);
-       lprint("Interface stats:\r\n");
-       lprint("  %6d output packets sent (%d bytes)\r\n", is->out_pkts, is->out_bytes);
-       lprint("  %6d output packets dropped (%d bytes)\r\n", is->out_errpkts, is->out_errbytes);
-       lprint("  %6d input packets received (%d bytes)\r\n", is->in_pkts, is->in_bytes);
-       lprint("  %6d input packets dropped (%d bytes)\r\n", is->in_errpkts, is->in_errbytes);
-       lprint("  %6d bad input packets\r\n", is->in_mbad);
-}
-
-static void
-allttystats(void)
-{
-       struct ttys *ttyp;
-
-       for (ttyp = ttys; ttyp; ttyp = ttyp->next)
-          ttystats(ttyp);
-}
-#endif
-
 static void
 ipstats(void)
 {
@@ -154,25 +36,6 @@ ipstats(void)
        lprint("  %6d total packets delivered\r\n", ipstat.ips_delivered);
 }
 
-#ifndef CONFIG_QEMU
-static void
-vjstats(void)
-{
-       lprint(" \r\n");
-
-       lprint("VJ compression stats:\r\n");
-
-       lprint("  %6d outbound packets (%d compressed)\r\n",
-              comp_s.sls_packets, comp_s.sls_compressed);
-       lprint("  %6d searches for connection stats (%d misses)\r\n",
-              comp_s.sls_searches, comp_s.sls_misses);
-       lprint("  %6d inbound uncompressed packets\r\n", comp_s.sls_uncompressedin);
-       lprint("  %6d inbound compressed packets\r\n", comp_s.sls_compressedin);
-       lprint("  %6d inbound unknown type packets\r\n", comp_s.sls_errorin);
-       lprint("  %6d inbound packets tossed due to error\r\n", comp_s.sls_tossed);
-}
-#endif
-
 static void
 tcpstats(void)
 {
@@ -234,11 +97,6 @@ tcpstats(void)
        lprint("  %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
        lprint("  %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
        lprint("  %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
-
-
-/*     lprint("    Packets received too short:         %d\r\n", tcpstat.tcps_rcvshort); */
-/*     lprint("    Segments dropped due to PAWS:       %d\r\n", tcpstat.tcps_pawsdrop); */
-
 }
 
 static void
@@ -293,49 +151,6 @@ mbufstats(void)
 }
 #endif
 
-#ifndef CONFIG_QEMU
-void
-slirp_exit(exit_status)
-       int exit_status;
-{
-       struct ttys *ttyp;
-
-       DEBUG_CALL("slirp_exit");
-       DEBUG_ARG("exit_status = %d", exit_status);
-
-       if (dostats) {
-               lprint_print = (int (*) _P((void *, const char *, va_list)))vfprintf;
-               if (!dfd)
-                  debug_init("slirp_stats", 0xf);
-               lprint_arg = (char **)&dfd;
-
-               ipstats();
-               tcpstats();
-               udpstats();
-               icmpstats();
-               mbufstats();
-               sockstats();
-               allttystats();
-               vjstats();
-       }
-
-       for (ttyp = ttys; ttyp; ttyp = ttyp->next)
-          tty_detached(ttyp, 1);
-
-       if (slirp_forked) {
-               /* Menendez time */
-               if (kill(getppid(), SIGQUIT) < 0)
-                       lprint("Couldn't kill parent process %ld!\n",
-                           (long) getppid());
-       }
-
-       /* Restore the terminal if we gotta */
-       if(slirp_tty_restore)
-         tcsetattr(0,TCSANOW, &slirp_tty_settings);  /* NOW DAMMIT! */
-       exit(exit_status);
-}
-#endif
-
 void
 slirp_stats(void)
 {
index c43eff73d396bc608ceedb5bcb15d11da6906c81..963ffda0728b83cd24a0413693c9977ff98ac0ce 100644 (file)
@@ -9,8 +9,6 @@
 #define PRN_SPRINTF    2
 
 extern FILE *dfd;
-extern FILE *lfd;
-extern int dostats;
 extern int slirp_debug;
 
 #define DBG_CALL 0x1
index 17f8a733781e795e40223278c0ad38711349fbfd..1ef4bf963a7722ee35aadf425adc790dc4d0f0cc 100644 (file)
@@ -36,89 +36,9 @@ if_init(void)
 {
        if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq;
        if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq;
-        //     sl_compress_init(&comp_s);
        next_m = &if_batchq;
 }
 
-#if 0
-/*
- * This shouldn't be needed since the modem is blocking and
- * we don't expect any signals, but what the hell..
- */
-inline int
-writen(fd, bptr, n)
-       int fd;
-       char *bptr;
-       int n;
-{
-       int ret;
-       int total;
-
-       /* This should succeed most of the time */
-       ret = send(fd, bptr, n,0);
-       if (ret == n || ret <= 0)
-          return ret;
-
-       /* Didn't write everything, go into the loop */
-       total = ret;
-       while (n > total) {
-               ret = send(fd, bptr+total, n-total,0);
-               if (ret <= 0)
-                  return ret;
-               total += ret;
-       }
-       return total;
-}
-
-/*
- * if_input - read() the tty, do "top level" processing (ie: check for any escapes),
- * and pass onto (*ttyp->if_input)
- *
- * XXXXX Any zeros arriving by themselves are NOT placed into the arriving packet.
- */
-#define INBUFF_SIZE 2048 /* XXX */
-void
-if_input(ttyp)
-       struct ttys *ttyp;
-{
-       u_char if_inbuff[INBUFF_SIZE];
-       int if_n;
-
-       DEBUG_CALL("if_input");
-       DEBUG_ARG("ttyp = %lx", (long)ttyp);
-
-       if_n = recv(ttyp->fd, (char *)if_inbuff, INBUFF_SIZE,0);
-
-       DEBUG_MISC((dfd, " read %d bytes\n", if_n));
-
-       if (if_n <= 0) {
-               if (if_n == 0 || (errno != EINTR && errno != EAGAIN)) {
-                       if (ttyp->up)
-                          link_up--;
-                       tty_detached(ttyp, 0);
-               }
-               return;
-       }
-       if (if_n == 1) {
-               if (*if_inbuff == '0') {
-                       ttyp->ones = 0;
-                       if (++ttyp->zeros >= 5)
-                          slirp_exit(0);
-                       return;
-               }
-               if (*if_inbuff == '1') {
-                       ttyp->zeros = 0;
-                       if (++ttyp->ones >= 5)
-                          tty_detached(ttyp, 0);
-                       return;
-               }
-       }
-       ttyp->ones = ttyp->zeros = 0;
-
-       (*ttyp->if_input)(ttyp, if_inbuff, if_n);
-}
-#endif
-
 /*
  * if_output: Queue packet into an output queue.
  * There are 2 output queue's, if_fastq and if_batchq.
index bed7152fe3e61a0cee309a72bd494dd537fa0c87..d49bcd599ddae652e3564f6bda3fb96bc8474e5c 100644 (file)
 #define IF_MRU 1500
 #define        IF_COMP IF_AUTOCOMP     /* Flags for compression */
 
-#if 0
-/*
- * Set if_maxlinkhdr to 48 because it's 40 bytes for TCP/IP,
- * and 8 bytes for PPP, but need to have it on an 8byte boundary
- */
-#ifdef USE_PPP
-#define IF_MAXLINKHDR 48
-#else
-#define IF_MAXLINKHDR 40
-#endif
-#else
-        /* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
+/* 2 for alignment, 14 for ethernet, 40 for TCP/IP */
 #define IF_MAXLINKHDR (2 + 14 + 40)
-#endif
 
 extern int     if_queued;      /* Number of packets queued so far */
 
index 6e93ee3eb42a081b07869bd1e442707ace8a48d9..c47ab1f38d24cbc46ce790678f73a1a330bc2246 100644 (file)
@@ -73,7 +73,6 @@ icmp_input(struct mbuf *m, int hlen)
   register struct icmp *icp;
   register struct ip *ip=mtod(m, struct ip *);
   int icmplen=ip->ip_len;
-  /* int code; */
 
   DEBUG_CALL("icmp_input");
   DEBUG_ARG("m = %lx", (long )m);
@@ -102,9 +101,6 @@ icmp_input(struct mbuf *m, int hlen)
   m->m_len += hlen;
   m->m_data -= hlen;
 
-  /*   icmpstat.icps_inhist[icp->icmp_type]++; */
-  /* code = icp->icmp_code; */
-
   DEBUG_ARG("icmp_type = %d", icp->icmp_type);
   switch (icp->icmp_type) {
   case ICMP_ECHO:
index 7a3c88b5497471f6ec7ce9ec67bb3b734df06846..1fdd8d6bdc8b0078dcda93ebce538bce258b65ff 100644 (file)
@@ -164,16 +164,6 @@ ip_input(struct mbuf *m)
          goto bad;
        }
 
-       /*
-        * Process options and, if not destined for us,
-        * ship it on.  ip_dooptions returns 1 when an
-        * error was detected (causing an icmp message
-        * to be sent and the original packet to be freed).
-        */
-/* We do no IP options */
-/*     if (hlen > sizeof (struct ip) && ip_dooptions(m))
- *             goto next;
- */
        /*
         * If offset or IP_MF are set, must reassemble.
         * Otherwise, nothing need be done.
@@ -396,9 +386,6 @@ insert:
          q = (struct ipasfrag *)(m->m_ext + delta);
        }
 
-       /* DEBUG_ARG("ip = %lx", (long)ip);
-        * ip=(struct ipasfrag *)m->m_data; */
-
     ip = fragtoip(q);
        ip->ip_len = next;
        ip->ip_tos &= ~1;
@@ -505,7 +492,6 @@ ip_dooptions(m)
        register u_char *cp;
        register struct ip_timestamp *ipt;
        register struct in_ifaddr *ia;
-/*     int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0; */
        int opt, optlen, cnt, off, code, type, forward = 0;
        struct in_addr *sin, dst;
 typedef u_int32_t n_time;
@@ -683,9 +669,6 @@ typedef u_int32_t n_time;
        }
        return (0);
 bad:
-       /* ip->ip_len -= ip->ip_hl << 2;   XXX icmp_error adds in hdr length */
-
-/* Not yet */
        icmp_error(m, type, code, 0, 0);
 
        STAT(ipstat.ips_badoptions++);
index 5bce520612897b5fea9a6903ce905e921221c107..94bb0f27eb1bd1c23b10852b04606a6f494b882d 100644 (file)
@@ -64,12 +64,6 @@ ip_output(struct socket *so, struct mbuf *m0)
        DEBUG_ARG("so = %lx", (long)so);
        DEBUG_ARG("m0 = %lx", (long)m0);
 
-       /* We do no options */
-/*     if (opt) {
- *             m = ip_insertoptions(m, opt, &len);
- *             hlen = len;
- *     }
- */
        ip = mtod(m, struct ip *);
        /*
         * Fill in IP header.
@@ -80,17 +74,6 @@ ip_output(struct socket *so, struct mbuf *m0)
        ip->ip_hl = hlen >> 2;
        STAT(ipstat.ips_localout++);
 
-       /*
-        * Verify that we have any chance at all of being able to queue
-        *      the packet or packet fragments
-        */
-       /* XXX Hmmm... */
-/*     if (if_queued > IF_THRESH && towrite <= 0) {
- *             error = ENOBUFS;
- *             goto bad;
- *     }
- */
-
        /*
         * If small enough for interface, can just send directly.
         */
@@ -142,12 +125,6 @@ ip_output(struct socket *so, struct mbuf *m0)
          mhip = mtod(m, struct ip *);
          *mhip = *ip;
 
-               /* No options */
-/*             if (hlen > sizeof (struct ip)) {
- *                     mhlen = ip_optcopy(ip, mhip) + sizeof (struct ip);
- *                     mhip->ip_hl = mhlen >> 2;
- *             }
- */
          m->m_len = mhlen;
          mhip->ip_off = ((off - hlen) >> 3) + (ip->ip_off & ~IP_MF);
          if (ip->ip_off & IP_MF)
index 5c7a8e91e859d54ff343b948a733f5a0fbfcdf86..c48837c0ebc8a48e5b80cc51fd64f932195a8005 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef _LIBSLIRP_H
 #define _LIBSLIRP_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <qemu-common.h>
 
 void slirp_init(int restricted, struct in_addr vnetwork,
@@ -37,8 +33,4 @@ void slirp_socket_recv(struct in_addr guest_addr, int guest_port,
                        const uint8_t *buf, int size);
 size_t slirp_socket_can_recv(struct in_addr guest_addr, int guest_port);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif
index 1d30a630c6a988b87c6ff2c0cffe78cec8598cd3..7963d346a0662919efa0f45bcffb4023df93479a 100644 (file)
@@ -141,17 +141,11 @@ m_inc(struct mbuf *m, int size)
         if (m->m_flags & M_EXT) {
          datasize = m->m_data - m->m_ext;
          m->m_ext = (char *)realloc(m->m_ext,size);
-/*             if (m->m_ext == NULL)
- *                     return (struct mbuf *)NULL;
- */
          m->m_data = m->m_ext + datasize;
         } else {
          char *dat;
          datasize = m->m_data - m->m_dat;
          dat = (char *)malloc(size);
-/*             if (dat == NULL)
- *                     return (struct mbuf *)NULL;
- */
          memcpy(dat, m->m_dat, m->m_size);
 
          m->m_ext = dat;
index 552737347e39e96856551bb10a6f60cc3a948c8a..e2594411a41a84c76daf63cf362da0c37692c4e1 100644 (file)
 /*
  * Macros for type conversion
  * mtod(m,t) - convert mbuf pointer to data pointer of correct type
- * dtom(x) -   convert data pointer within mbuf to mbuf pointer (XXX)
  */
 #define mtod(m,t)      ((t)(m)->m_data)
-/* #define     dtom(x)         ((struct mbuf *)((int)(x) & ~(M_SIZE-1))) */
 
 /* XXX About mbufs for slirp:
  * Only one mbuf is ever used in a chain, for each "cell" of data.
index 8d03f7955160a985bef50623b383b8d69b16ba23..958711298ebd351c11728221e03ae410c399ffe8 100644 (file)
 
 u_int curtime, time_fasttimo, last_slowtimo;
 
-#if 0
-int x_port = -1;
-int x_display = 0;
-int x_screen = 0;
-
-int
-show_x(buff, inso)
-       char *buff;
-       struct socket *inso;
-{
-       if (x_port < 0) {
-               lprint("X Redir: X not being redirected.\r\n");
-       } else {
-               lprint("X Redir: In sh/bash/zsh/etc. type: DISPLAY=%s:%d.%d; export DISPLAY\r\n",
-                     inet_ntoa(our_addr), x_port, x_screen);
-               lprint("X Redir: In csh/tcsh/etc. type:    setenv DISPLAY %s:%d.%d\r\n",
-                     inet_ntoa(our_addr), x_port, x_screen);
-               if (x_display)
-                  lprint("X Redir: Redirecting to display %d\r\n", x_display);
-       }
-
-       return CFG_OK;
-}
-
-
-/*
- * XXX Allow more than one X redirection?
- */
-void
-redir_x(inaddr, start_port, display, screen)
-       u_int32_t inaddr;
-       int start_port;
-       int display;
-       int screen;
-{
-       int i;
-
-       if (x_port >= 0) {
-               lprint("X Redir: X already being redirected.\r\n");
-               show_x(0, 0);
-       } else {
-               for (i = 6001 + (start_port-1); i <= 6100; i++) {
-                       if (solisten(htons(i), inaddr, htons(6000 + display), 0)) {
-                               /* Success */
-                               x_port = i - 6000;
-                               x_display = display;
-                               x_screen = screen;
-                               show_x(0, 0);
-                               return;
-                       }
-               }
-               lprint("X Redir: Error: Couldn't redirect a port for X. Weird.\r\n");
-       }
-}
-#endif
-
 /*
  * Get our IP address and put it in our_addr
  */
@@ -109,12 +53,8 @@ remque(void *a)
   ((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
   ((struct quehead *)(element->qh_rlink))->qh_link = element->qh_link;
   element->qh_rlink = NULL;
-  /*  element->qh_link = NULL;  TCP FIN1 crashes if you do this.  Why ? */
 }
 
-/* #endif */
-
-
 int add_exec(struct ex_list **ex_ptr, int do_pty, char *exec,
              struct in_addr addr, int port)
 {
@@ -170,73 +110,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
 
 #else
 
-#ifndef CONFIG_QEMU
-int
-slirp_openpty(amaster, aslave)
-     int *amaster, *aslave;
-{
-       register int master, slave;
-
-#ifdef HAVE_GRANTPT
-       char *ptr;
-
-       if ((master = open("/dev/ptmx", O_RDWR)) < 0 ||
-           grantpt(master) < 0 ||
-           unlockpt(master) < 0 ||
-           (ptr = ptsname(master)) == NULL)  {
-               close(master);
-               return -1;
-       }
-
-       if ((slave = open(ptr, O_RDWR)) < 0 ||
-           ioctl(slave, I_PUSH, "ptem") < 0 ||
-           ioctl(slave, I_PUSH, "ldterm") < 0 ||
-           ioctl(slave, I_PUSH, "ttcompat") < 0) {
-               close(master);
-               close(slave);
-               return -1;
-       }
-
-       *amaster = master;
-       *aslave = slave;
-       return 0;
-
-#else
-
-       static char line[] = "/dev/ptyXX";
-       register const char *cp1, *cp2;
-
-       for (cp1 = "pqrsPQRS"; *cp1; cp1++) {
-               line[8] = *cp1;
-               for (cp2 = "0123456789abcdefghijklmnopqrstuv"; *cp2; cp2++) {
-                       line[9] = *cp2;
-                       if ((master = open(line, O_RDWR, 0)) == -1) {
-                               if (errno == ENOENT)
-                                  return (-1);    /* out of ptys */
-                       } else {
-                               line[5] = 't';
-                               /* These will fail */
-                               (void) chown(line, getuid(), 0);
-                               (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
-#ifdef HAVE_REVOKE
-                               (void) revoke(line);
-#endif
-                               if ((slave = open(line, O_RDWR, 0)) != -1) {
-                                       *amaster = master;
-                                       *aslave = slave;
-                                       return 0;
-                               }
-                               (void) close(master);
-                               line[5] = 'p';
-                       }
-               }
-       }
-       errno = ENOENT; /* out of ptys */
-       return (-1);
-#endif
-}
-#endif
-
 /*
  * XXX This is ugly
  * We create and bind a socket, then fork off to another
@@ -257,9 +130,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
        int opt;
         int master = -1;
        const char *argv[256];
-#if 0
-       char buff[256];
-#endif
        /* don't want to clobber the original */
        char *bptr;
        const char *curarg;
@@ -271,14 +141,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
        DEBUG_ARG("do_pty = %lx", (long)do_pty);
 
        if (do_pty == 2) {
-#if 0
-               if (slirp_openpty(&master, &s) == -1) {
-                       lprint("Error: openpty failed: %s\n", strerror(errno));
-                       return 0;
-               }
-#else
                 return 0;
-#endif
        } else {
                addr.sin_family = AF_INET;
                addr.sin_port = 0;
@@ -324,17 +187,6 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
                         } while (ret < 0 && errno == EINTR);
                }
 
-#if 0
-               if (x_port >= 0) {
-#ifdef HAVE_SETENV
-                       sprintf(buff, "%s:%d.%d", inet_ntoa(our_addr), x_port, x_screen);
-                       setenv("DISPLAY", buff, 1);
-#else
-                       sprintf(buff, "DISPLAY=%s:%d.%d", inet_ntoa(our_addr), x_port, x_screen);
-                       putenv(buff);
-#endif
-               }
-#endif
                dup2(s, 0);
                dup2(s, 1);
                dup2(s, 2);
@@ -422,137 +274,6 @@ strdup(str)
 }
 #endif
 
-#if 0
-void
-snooze_hup(num)
-       int num;
-{
-       int s, ret;
-#ifndef NO_UNIX_SOCKETS
-       struct sockaddr_un sock_un;
-#endif
-       struct sockaddr_in sock_in;
-       char buff[256];
-
-       ret = -1;
-       if (slirp_socket_passwd) {
-               s = socket(AF_INET, SOCK_STREAM, 0);
-               if (s < 0)
-                  slirp_exit(1);
-               sock_in.sin_family = AF_INET;
-               sock_in.sin_addr.s_addr = slirp_socket_addr;
-               sock_in.sin_port = htons(slirp_socket_port);
-               if (connect(s, (struct sockaddr *)&sock_in, sizeof(sock_in)) != 0)
-                  slirp_exit(1); /* just exit...*/
-               sprintf(buff, "kill %s:%d", slirp_socket_passwd, slirp_socket_unit);
-               write(s, buff, strlen(buff)+1);
-       }
-#ifndef NO_UNIX_SOCKETS
-         else {
-               s = socket(AF_UNIX, SOCK_STREAM, 0);
-               if (s < 0)
-                  slirp_exit(1);
-               sock_un.sun_family = AF_UNIX;
-               strcpy(sock_un.sun_path, socket_path);
-               if (connect(s, (struct sockaddr *)&sock_un,
-                             sizeof(sock_un.sun_family) + sizeof(sock_un.sun_path)) != 0)
-                  slirp_exit(1);
-               sprintf(buff, "kill none:%d", slirp_socket_unit);
-               write(s, buff, strlen(buff)+1);
-       }
-#endif
-       slirp_exit(0);
-}
-
-
-void
-snooze()
-{
-       sigset_t s;
-       int i;
-
-       /* Don't need our data anymore */
-       /* XXX This makes SunOS barf */
-/*     brk(0); */
-
-       /* Close all fd's */
-       for (i = 255; i >= 0; i--)
-          close(i);
-
-       signal(SIGQUIT, slirp_exit);
-       signal(SIGHUP, snooze_hup);
-       sigemptyset(&s);
-
-       /* Wait for any signal */
-       sigsuspend(&s);
-
-       /* Just in case ... */
-       exit(255);
-}
-
-void
-relay(s)
-       int s;
-{
-       char buf[8192];
-       int n;
-       fd_set readfds;
-       struct ttys *ttyp;
-
-       /* Don't need our data anymore */
-       /* XXX This makes SunOS barf */
-/*     brk(0); */
-
-       signal(SIGQUIT, slirp_exit);
-       signal(SIGHUP, slirp_exit);
-        signal(SIGINT, slirp_exit);
-       signal(SIGTERM, slirp_exit);
-
-       /* Fudge to get term_raw and term_restore to work */
-       if (NULL == (ttyp = tty_attach (0, slirp_tty))) {
-         lprint ("Error: tty_attach failed in misc.c:relay()\r\n");
-         slirp_exit (1);
-    }
-       ttyp->fd = 0;
-       ttyp->flags |= TTY_CTTY;
-       term_raw(ttyp);
-
-       while (1) {
-               FD_ZERO(&readfds);
-
-               FD_SET(0, &readfds);
-               FD_SET(s, &readfds);
-
-               n = select(s+1, &readfds, (fd_set *)0, (fd_set *)0, (struct timeval *)0);
-
-               if (n <= 0)
-                  slirp_exit(0);
-
-               if (FD_ISSET(0, &readfds)) {
-                       n = read(0, buf, 8192);
-                       if (n <= 0)
-                          slirp_exit(0);
-                       n = writen(s, buf, n);
-                       if (n <= 0)
-                          slirp_exit(0);
-               }
-
-               if (FD_ISSET(s, &readfds)) {
-                       n = read(s, buf, 8192);
-                       if (n <= 0)
-                          slirp_exit(0);
-                       n = writen(0, buf, n);
-                       if (n <= 0)
-                          slirp_exit(0);
-               }
-       }
-
-       /* Just in case.... */
-       exit(1);
-}
-#endif
-
-#ifdef CONFIG_QEMU
 #include "monitor.h"
 
 void lprint(const char *format, ...)
@@ -563,159 +284,6 @@ void lprint(const char *format, ...)
     monitor_vprintf(cur_mon, format, args);
     va_end(args);
 }
-#else
-int (*lprint_print) _P((void *, const char *, va_list));
-char *lprint_ptr, *lprint_ptr2, **lprint_arg;
-
-void
-#ifdef __STDC__
-lprint(const char *format, ...)
-#else
-lprint(va_alist) va_dcl
-#endif
-{
-       va_list args;
-
-#ifdef __STDC__
-        va_start(args, format);
-#else
-        char *format;
-        va_start(args);
-        format = va_arg(args, char *);
-#endif
-#if 0
-       /* If we're printing to an sbuf, make sure there's enough room */
-       /* XXX +100? */
-       if (lprint_sb) {
-               if ((lprint_ptr - lprint_sb->sb_wptr) >=
-                   (lprint_sb->sb_datalen - (strlen(format) + 100))) {
-                       int deltaw = lprint_sb->sb_wptr - lprint_sb->sb_data;
-                       int deltar = lprint_sb->sb_rptr - lprint_sb->sb_data;
-                       int deltap = lprint_ptr -         lprint_sb->sb_data;
-
-                       lprint_sb->sb_data = (char *)realloc(lprint_sb->sb_data,
-                                                            lprint_sb->sb_datalen + TCP_SNDSPACE);
-
-                       /* Adjust all values */
-                       lprint_sb->sb_wptr = lprint_sb->sb_data + deltaw;
-                       lprint_sb->sb_rptr = lprint_sb->sb_data + deltar;
-                       lprint_ptr =         lprint_sb->sb_data + deltap;
-
-                       lprint_sb->sb_datalen += TCP_SNDSPACE;
-               }
-       }
-#endif
-       if (lprint_print)
-          lprint_ptr += (*lprint_print)(*lprint_arg, format, args);
-
-       /* Check if they want output to be logged to file as well */
-       if (lfd) {
-               /*
-                * Remove \r's
-                * otherwise you'll get ^M all over the file
-                */
-               int len = strlen(format);
-               char *bptr1, *bptr2;
-
-               bptr1 = bptr2 = strdup(format);
-
-               while (len--) {
-                       if (*bptr1 == '\r')
-                          memcpy(bptr1, bptr1+1, len+1);
-                       else
-                          bptr1++;
-               }
-               vfprintf(lfd, bptr2, args);
-               free(bptr2);
-       }
-       va_end(args);
-}
-
-void
-add_emu(buff)
-       char *buff;
-{
-       u_int lport, fport;
-       u_int8_t tos = 0, emu = 0;
-       char buff1[256], buff2[256], buff4[128];
-       char *buff3 = buff4;
-       struct emu_t *emup;
-       struct socket *so;
-
-       if (sscanf(buff, "%256s %256s", buff2, buff1) != 2) {
-               lprint("Error: Bad arguments\r\n");
-               return;
-       }
-
-       if (sscanf(buff1, "%d:%d", &lport, &fport) != 2) {
-               lport = 0;
-               if (sscanf(buff1, "%d", &fport) != 1) {
-                       lprint("Error: Bad first argument\r\n");
-                       return;
-               }
-       }
-
-       if (sscanf(buff2, "%128[^:]:%128s", buff1, buff3) != 2) {
-               buff3 = 0;
-               if (sscanf(buff2, "%256s", buff1) != 1) {
-                       lprint("Error: Bad second argument\r\n");
-                       return;
-               }
-       }
-
-       if (buff3) {
-               if (strcmp(buff3, "lowdelay") == 0)
-                  tos = IPTOS_LOWDELAY;
-               else if (strcmp(buff3, "throughput") == 0)
-                  tos = IPTOS_THROUGHPUT;
-               else {
-                       lprint("Error: Expecting \"lowdelay\"/\"throughput\"\r\n");
-                       return;
-               }
-       }
-
-       if (strcmp(buff1, "ftp") == 0)
-          emu = EMU_FTP;
-       else if (strcmp(buff1, "irc") == 0)
-          emu = EMU_IRC;
-       else if (strcmp(buff1, "none") == 0)
-          emu = EMU_NONE; /* ie: no emulation */
-       else {
-               lprint("Error: Unknown service\r\n");
-               return;
-       }
-
-       /* First, check that it isn't already emulated */
-       for (emup = tcpemu; emup; emup = emup->next) {
-               if (emup->lport == lport && emup->fport == fport) {
-                       lprint("Error: port already emulated\r\n");
-                       return;
-               }
-       }
-
-       /* link it */
-       emup = (struct emu_t *)malloc(sizeof (struct emu_t));
-       emup->lport = (u_int16_t)lport;
-       emup->fport = (u_int16_t)fport;
-       emup->tos = tos;
-       emup->emu = emu;
-       emup->next = tcpemu;
-       tcpemu = emup;
-
-       /* And finally, mark all current sessions, if any, as being emulated */
-       for (so = tcb.so_next; so != &tcb; so = so->so_next) {
-               if ((lport && lport == ntohs(so->so_lport)) ||
-                   (fport && fport == ntohs(so->so_fport))) {
-                       if (emu)
-                          so->so_emu = emu;
-                       if (tos)
-                          so->so_iptos = tos;
-               }
-       }
-
-       lprint("Adding emulation for %s to port %d/%d\r\n", buff1, emup->lport, emup->fport);
-}
-#endif
 
 #ifdef BAD_SPRINTF
 
@@ -817,99 +385,6 @@ fd_block(int fd)
 #endif
 }
 
-
-#if 0
-/*
- * invoke RSH
- */
-int
-rsh_exec(so,ns, user, host, args)
-       struct socket *so;
-       struct socket *ns;
-       char *user;
-       char *host;
-       char *args;
-{
-       int fd[2];
-       int fd0[2];
-       int s;
-       char buff[256];
-
-       DEBUG_CALL("rsh_exec");
-       DEBUG_ARG("so = %lx", (long)so);
-
-       if (pipe(fd)<0) {
-          lprint("Error: pipe failed: %s\n", strerror(errno));
-          return 0;
-       }
-/* #ifdef HAVE_SOCKETPAIR */
-#if 1
-        if (socketpair(PF_UNIX,SOCK_STREAM,0, fd0) == -1) {
-          close(fd[0]);
-          close(fd[1]);
-          lprint("Error: openpty failed: %s\n", strerror(errno));
-          return 0;
-        }
-#else
-        if (slirp_openpty(&fd0[0], &fd0[1]) == -1) {
-          close(fd[0]);
-          close(fd[1]);
-          lprint("Error: openpty failed: %s\n", strerror(errno));
-          return 0;
-        }
-#endif
-
-       switch(fork()) {
-        case -1:
-           lprint("Error: fork failed: %s\n", strerror(errno));
-           close(fd[0]);
-           close(fd[1]);
-           close(fd0[0]);
-           close(fd0[1]);
-           return 0;
-
-        case 0:
-           close(fd[0]);
-           close(fd0[0]);
-
-               /* Set the DISPLAY */
-           if (x_port >= 0) {
-#ifdef HAVE_SETENV
-             sprintf(buff, "%s:%d.%d", inet_ntoa(our_addr), x_port, x_screen);
-             setenv("DISPLAY", buff, 1);
-#else
-             sprintf(buff, "DISPLAY=%s:%d.%d", inet_ntoa(our_addr), x_port, x_screen);
-             putenv(buff);
-#endif
-           }
-
-           dup2(fd0[1], 0);
-           dup2(fd0[1], 1);
-           dup2(fd[1], 2);
-           for (s = 3; s <= 255; s++)
-             close(s);
-
-           execlp("rsh","rsh","-l", user, host, args, NULL);
-
-           /* Ooops, failed, let's tell the user why */
-
-           sprintf(buff, "Error: execlp of %s failed: %s\n",
-                   "rsh", strerror(errno));
-           write(2, buff, strlen(buff)+1);
-           close(0); close(1); close(2); /* XXX */
-           exit(1);
-
-        default:
-          close(fd[1]);
-          close(fd0[1]);
-          ns->s=fd[0];
-          so->s=fd0[0];
-
-          return 1;
-       }
-}
-#endif
-
 void slirp_connection_info(Monitor *mon)
 {
     const char * const tcpstates[] = {
index 29d574965ea400c7a48ca8497e534e8b571a433a..82dd5965c317a74effece6e12d809ac71b8d0853 100644 (file)
@@ -19,10 +19,6 @@ struct ex_list {
 extern struct ex_list *exec_list;
 extern u_int time_fasttimo, last_slowtimo;
 
-extern int (*lprint_print) _P((void *, const char *, va_list));
-extern char *lprint_ptr, *lprint_ptr2, **lprint_arg;
-extern struct sbuf *lprint_sb;
-
 #ifndef HAVE_STRDUP
 char *strdup _P((const char *));
 #endif
@@ -63,10 +59,6 @@ struct emu_t {
        struct emu_t *next;
 };
 
-#ifndef CONFIG_QEMU
-extern struct emu_t *tcpemu;
-#endif
-
 extern int x_port, x_server, x_display;
 
 int show_x _P((char *, struct socket *));
index 5375414f26d7d85f6aa0acde5bcb2120ce817f75..5a1ccbfadfe6bd35145cad6cb7c289d77dda0f35 100644 (file)
@@ -9,14 +9,6 @@
 
 static void sbappendsb(struct sbuf *sb, struct mbuf *m);
 
-/* Done as a macro in socket.h */
-/* int
- * sbspace(struct sockbuff *sb)
- * {
- *     return SB_DATALEN - sb->sb_cc;
- * }
- */
-
 void
 sbfree(struct sbuf *sb)
 {
index 35de4e380b7cee28947889b208780d03a5e2b2ed..44a53cdfe530c1f1acd7187c5bdd763341d96f70 100644 (file)
@@ -55,7 +55,6 @@ int slirp_restrict;
 static int do_slowtimo;
 int link_up;
 struct timeval tt;
-FILE *lfd;
 struct ex_list *exec_list;
 
 /* XXX: suppress those select globals */
@@ -96,16 +95,6 @@ static int get_dns_addr(struct in_addr *pdns_addr)
     pIPAddr = &(FixedInfo->DnsServerList);
     inet_aton(pIPAddr->IpAddress.String, &tmp_addr);
     *pdns_addr = tmp_addr;
-#if 0
-    printf( "DNS Servers:\n" );
-    printf( "DNS Addr:%s\n", pIPAddr->IpAddress.String );
-
-    pIPAddr = FixedInfo -> DnsServerList.Next;
-    while ( pIPAddr ) {
-            printf( "DNS Addr:%s\n", pIPAddr ->IpAddress.String );
-            pIPAddr = pIPAddr ->Next;
-    }
-#endif
     if (FixedInfo) {
         GlobalFree(FixedInfo);
         FixedInfo = NULL;
@@ -179,8 +168,6 @@ void slirp_init(int restricted, struct in_addr vnetwork,
                 const char *bootfile, struct in_addr vdhcp_start,
                 struct in_addr vnameserver)
 {
-    //    debug_init("/tmp/slirp.log", DEBUG_DEFAULT);
-
 #ifdef _WIN32
     WSADATA Data;
 
index 101d0943b75b03a0424511ac1f559b09aabd1f7e..0c62fd784bc362af19c3b7536d9dc55de8f9ee36 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef __COMMON_H__
 #define __COMMON_H__
 
-#define CONFIG_QEMU
-
 //#define DEBUG 1
 
 // Uncomment the following line to enable SLIRP statistics printing in Qemu
@@ -14,9 +12,6 @@
 #define STAT(expr) do { } while(0)
 #endif
 
-#ifndef CONFIG_QEMU
-#include "version.h"
-#endif
 #include "config-host.h"
 #include "slirp_config.h"
 
@@ -223,8 +218,6 @@ int inet_aton _P((const char *cp, struct in_addr *ia));
 #include "tftp.h"
 #include "libslirp.h"
 
-extern struct ttys *ttys_unit[MAX_INTERFACES];
-
 #ifndef NULL
 #define NULL (void *)0
 #endif
index 6b3da0a112f69745c8c95583071cd800b22de444..a911b29d901d9ed4a516969365a45dccec44a52d 100644 (file)
 static void sofcantrcvmore(struct socket *so);
 static void sofcantsendmore(struct socket *so);
 
-#if 0
-static void
-so_init()
-{
-       /* Nothing yet */
-}
-#endif
-
 struct socket *
 solookup(struct socket *head, struct in_addr laddr, u_int lport,
          struct in_addr faddr, u_int fport)
@@ -526,12 +518,6 @@ sorecvfrom(struct socket *so)
                so->so_expire = curtime + SO_EXPIRE;
            }
 
-           /*          if (m->m_len == len) {
-            *                  m_inc(m, MINCSIZE);
-            *                  m->m_len = 0;
-            *          }
-            */
-
            /*
             * If this packet was destined for CTL_ADDR,
             * make it look like that's where it came from, done by udp_output
@@ -604,7 +590,6 @@ tcp_listen(u_int32_t haddr, u_int hport, u_int32_t laddr, u_int lport, int flags
        DEBUG_ARG("flags = %x", flags);
 
        if ((so = socreate()) == NULL) {
-         /* free(so);      Not sofree() ??? free(NULL) == NOP */
          return NULL;
        }
 
@@ -659,33 +644,6 @@ tcp_listen(u_int32_t haddr, u_int hport, u_int32_t laddr, u_int lport, int flags
        return so;
 }
 
-#if 0
-/*
- * Data is available in so_rcv
- * Just write() the data to the socket
- * XXX not yet...
- */
-static void
-sorwakeup(so)
-       struct socket *so;
-{
-/*     sowrite(so); */
-/*     FD_CLR(so->s,&writefds); */
-}
-
-/*
- * Data has been freed in so_snd
- * We have room for a read() if we want to
- * For now, don't read, it'll be done in the main loop
- */
-static void
-sowwakeup(so)
-       struct socket *so;
-{
-       /* Nothing, yet */
-}
-#endif
-
 /*
  * Various session state calls
  * XXX Should be #define's
@@ -746,17 +704,6 @@ sofcantsendmore(struct socket *so)
        }
 }
 
-void
-soisfdisconnected(struct socket *so)
-{
-/*     so->so_state &= ~(SS_ISFCONNECTING|SS_ISFCONNECTED); */
-/*     close(so->s); */
-/*     so->so_state = SS_ISFDISCONNECTED; */
-       /*
-        * XXX Do nothing ... ?
-        */
-}
-
 /*
  * Set write drain mode
  * Set CANTSENDMORE once all data has been write()n
index d241a48ca2ebe9b673a11dd1953a91a12dba0be2..4db2147aa8ce678f85360f760796199b7b72ba12 100644 (file)
@@ -5,8 +5,6 @@
  * terms and conditions of the copyright.
  */
 
-/* MINE */
-
 #ifndef _SLIRP_SOCKET_H_
 #define _SLIRP_SOCKET_H_
 
@@ -64,7 +62,6 @@ struct socket {
 #define SS_ISFCONNECTED                0x004   /* Socket is connected to peer */
 #define SS_FCANTRCVMORE                0x008   /* Socket can't receive more from peer (for half-closes) */
 #define SS_FCANTSENDMORE       0x010   /* Socket can't send more to peer (for half-closes) */
-/* #define SS_ISFDISCONNECTED  0x020*/ /* Socket has disconnected from peer, in 2MSL state */
 #define SS_FWDRAIN             0x040   /* We received a FIN, drain data and set SS_FCANTSENDMORE */
 
 #define SS_CTL                 0x080
@@ -89,7 +86,6 @@ int sosendto _P((struct socket *, struct mbuf *));
 struct socket * tcp_listen _P((u_int32_t, u_int, u_int32_t, u_int, int));
 void soisfconnecting _P((register struct socket *));
 void soisfconnected _P((register struct socket *));
-void soisfdisconnected _P((struct socket *));
 void sofwdrain _P((struct socket *));
 struct iovec; /* For win32 */
 size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np);
index 33998575130026006495d63595deafb9912f3937..4a18ed88215618613e8a4dd50b280fe2bf11c4c5 100644 (file)
@@ -113,7 +113,6 @@ struct tcphdr {
 #undef TCP_NODELAY
 #define        TCP_NODELAY     0x01    /* don't delay send to coalesce packets */
 #undef TCP_MAXSEG
-/* #define     TCP_MAXSEG      0x02 */ /* set maximum segment size */
 
 /*
  * TCP FSM state definitions.
index 8789303c8b1dc4eeb4591e77aae1c9a39d904349..980ae06d34546e150ad0975459e66cb30aa29464 100644 (file)
@@ -81,7 +81,6 @@ tcp_seq tcp_iss;                /* tcp initial send seq # */
                       if (tcp_emu((so),(m))) sbappend((so), (m)); \
               } else \
                       sbappend((so), (m)); \
-/*               sorwakeup(so); */ \
        } else {\
                (flags) = tcp_reass((tp), (ti), (m)); \
                tp->t_flags |= TF_ACKNOW; \
@@ -101,7 +100,6 @@ tcp_seq tcp_iss;                /* tcp initial send seq # */
                        if (tcp_emu((so),(m))) sbappend(so, (m)); \
                } else \
                        sbappend((so), (m)); \
-/*             sorwakeup(so); */ \
        } else { \
                (flags) = tcp_reass((tp), (ti), (m)); \
                tp->t_flags |= TF_ACKNOW; \
@@ -211,7 +209,6 @@ present:
                remque(tcpiphdr2qlink(ti));
                m = ti->ti_mbuf;
                ti = tcpiphdr_next(ti);
-/*             if (so->so_state & SS_FCANTRCVMORE) */
                if (so->so_state & SS_FCANTSENDMORE)
                        m_freem(m);
                else {
@@ -221,7 +218,6 @@ present:
                                sbappend(so, m);
                }
        } while (ti != (struct tcpiphdr *)tp && ti->ti_seq == tp->rcv_nxt);
-/*     sorwakeup(so); */
        return (flags);
 }
 
@@ -241,11 +237,9 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
        register int tiflags;
         struct socket *so = NULL;
        int todrop, acked, ourfinisacked, needoutput = 0;
-/*     int dropsocket = 0; */
        int iss = 0;
        u_long tiwin;
        int ret;
-/*     int ts_present = 0; */
     struct ex_list *ex_ptr;
 
        DEBUG_CALL("tcp_input");
@@ -300,9 +294,6 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
        ti->ti_x1 = 0;
        ti->ti_len = htons((u_int16_t)tlen);
        len = sizeof(struct ip ) + tlen;
-       /* keep checksum for ICMP reply
-        * ti->ti_sum = cksum(m, len);
-        * if (ti->ti_sum) { */
        if(cksum(m, len)) {
          STAT(tcpstat.tcps_rcvbadsum++);
          goto drop;
@@ -322,25 +313,6 @@ tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
        if (off > sizeof (struct tcphdr)) {
          optlen = off - sizeof (struct tcphdr);
          optp = mtod(m, caddr_t) + sizeof (struct tcpiphdr);
-
-               /*
-                * Do quick retrieval of timestamp options ("options
-                * prediction?").  If timestamp is the only option and it's
-                * formatted as recommended in RFC 1323 appendix A, we
-                * quickly get the values now and not bother calling
-                * tcp_dooptions(), etc.
-                */
-/*             if ((optlen == TCPOLEN_TSTAMP_APPA ||
- *                  (optlen > TCPOLEN_TSTAMP_APPA &&
- *                     optp[TCPOLEN_TSTAMP_APPA] == TCPOPT_EOL)) &&
- *                  *(u_int32_t *)optp == htonl(TCPOPT_TSTAMP_HDR) &&
- *                  (ti->ti_flags & TH_SYN) == 0) {
- *                     ts_present = 1;
- *                     ts_val = ntohl(*(u_int32_t *)(optp + 4));
- *                     ts_ecr = ntohl(*(u_int32_t *)(optp + 8));
- *                     optp = NULL;   / * we've parsed the options * /
- *             }
- */
        }
        tiflags = ti->ti_flags;
 
@@ -411,9 +383,6 @@ findso:
          sbreserve(&so->so_snd, TCP_SNDSPACE);
          sbreserve(&so->so_rcv, TCP_RCVSPACE);
 
-         /*            tcp_last_so = so; */  /* XXX ? */
-         /*            tp = sototcpcb(so);    */
-
          so->so_laddr = ti->ti_src;
          so->so_lport = ti->ti_sport;
          so->so_faddr = ti->ti_dst;
@@ -442,12 +411,7 @@ findso:
        if (tp->t_state == TCPS_CLOSED)
                goto drop;
 
-       /* Unscale the window into a 32-bit value. */
-/*     if ((tiflags & TH_SYN) == 0)
- *             tiwin = ti->ti_win << tp->snd_scale;
- *     else
- */
-               tiwin = ti->ti_win;
+       tiwin = ti->ti_win;
 
        /*
         * Segment received on connection.
@@ -465,8 +429,6 @@ findso:
         */
        if (optp && tp->t_state != TCPS_LISTEN)
                tcp_dooptions(tp, (u_char *)optp, optlen, ti);
-/* , */
-/*                     &ts_present, &ts_val, &ts_ecr); */
 
        /*
         * Header prediction: check for the two common cases
@@ -488,20 +450,9 @@ findso:
         */
        if (tp->t_state == TCPS_ESTABLISHED &&
            (tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK &&
-/*         (!ts_present || TSTMP_GEQ(ts_val, tp->ts_recent)) && */
            ti->ti_seq == tp->rcv_nxt &&
            tiwin && tiwin == tp->snd_wnd &&
            tp->snd_nxt == tp->snd_max) {
-               /*
-                * If last ACK falls within this segment's sequence numbers,
-                *  record the timestamp.
-                */
-/*             if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
- *                SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len)) {
- *                     tp->ts_recent_age = tcp_now;
- *                     tp->ts_recent = ts_val;
- *             }
- */
                if (ti->ti_len == 0) {
                        if (SEQ_GT(ti->ti_ack, tp->snd_una) &&
                            SEQ_LEQ(ti->ti_ack, tp->snd_max) &&
@@ -510,11 +461,8 @@ findso:
                                 * this is a pure ack for outstanding data.
                                 */
                                STAT(tcpstat.tcps_predack++);
-/*                             if (ts_present)
- *                                     tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
- *                             else
- */                                 if (tp->t_rtt &&
-                                           SEQ_GT(ti->ti_ack, tp->t_rtseq))
+                               if (tp->t_rtt &&
+                                   SEQ_GT(ti->ti_ack, tp->t_rtseq))
                                        tcp_xmit_timer(tp, tp->t_rtt);
                                acked = ti->ti_ack - tp->snd_una;
                                STAT(tcpstat.tcps_rcvackpack++);
@@ -537,13 +485,6 @@ findso:
                                else if (tp->t_timer[TCPT_PERSIST] == 0)
                                        tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
 
-                               /*
-                                * There's room in so_snd, sowwakup will read()
-                                * from the socket if we can
-                                */
-/*                             if (so->so_snd.sb_flags & SB_NOTIFY)
- *                                     sowwakeup(so);
- */
                                /*
                                 * This is called because sowwakeup might have
                                 * put data into so_snd.  Since we don't so sowwakeup,
@@ -574,13 +515,6 @@ findso:
                        } else
                                sbappend(so, m);
 
-                       /*
-                        * XXX This is called when data arrives.  Later, check
-                        * if we can actually write() to the socket
-                        * XXX Need to check? It's be NON_BLOCKING
-                        */
-/*                     sorwakeup(so); */
-
                        /*
                         * If this is a short packet, then ACK now - with Nagel
                         *      congestion avoidance sender won't send more until
@@ -644,13 +578,6 @@ findso:
              vnetwork_addr.s_addr) {
            if (so->so_faddr.s_addr != vhost_addr.s_addr &&
                so->so_faddr.s_addr != vnameserver_addr.s_addr) {
-#if 0
-             if(lastbyte==CTL_CMD || lastbyte==CTL_EXEC) {
-               /* Command or exec adress */
-               so->so_state |= SS_CTL;
-             } else
-#endif
-              {
                /* May be an add exec */
                for(ex_ptr = exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) {
                  if(ex_ptr->ex_fport == so->so_fport &&
@@ -659,8 +586,9 @@ findso:
                    break;
                  }
                }
-             }
-             if(so->so_state & SS_CTL) goto cont_input;
+               if (so->so_state & SS_CTL) {
+                   goto cont_input;
+               }
            }
            /* CTL_ALIAS: Do nothing, tcp_fconnect will be called on it */
          }
@@ -718,8 +646,6 @@ findso:
 
          if (optp)
            tcp_dooptions(tp, (u_char *)optp, optlen, ti);
-         /* , */
-         /*                            &ts_present, &ts_val, &ts_ecr); */
 
          if (iss)
            tp->iss = iss;
@@ -777,13 +703,6 @@ findso:
                        soisfconnected(so);
                        tp->t_state = TCPS_ESTABLISHED;
 
-                       /* Do window scaling on this connection? */
-/*                     if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
- *                             (TF_RCVD_SCALE|TF_REQ_SCALE)) {
- *                             tp->snd_scale = tp->requested_s_scale;
- *                             tp->rcv_scale = tp->request_r_scale;
- *                     }
- */
                        (void) tcp_reass(tp, (struct tcpiphdr *)0,
                                (struct mbuf *)0);
                        /*
@@ -816,40 +735,10 @@ trimthenstep6:
        } /* switch tp->t_state */
        /*
         * States other than LISTEN or SYN_SENT.
-        * First check timestamp, if present.
-        * Then check that at least some bytes of segment are within
+        * Check that at least some bytes of segment are within
         * receive window.  If segment begins before rcv_nxt,
         * drop leading data (and SYN); if nothing left, just ack.
-        *
-        * RFC 1323 PAWS: If we have a timestamp reply on this segment
-        * and it's less than ts_recent, drop it.
         */
-/*     if (ts_present && (tiflags & TH_RST) == 0 && tp->ts_recent &&
- *         TSTMP_LT(ts_val, tp->ts_recent)) {
- *
- */            /* Check to see if ts_recent is over 24 days old.  */
-/*             if ((int)(tcp_now - tp->ts_recent_age) > TCP_PAWS_IDLE) {
- */                    /*
- *                      * Invalidate ts_recent.  If this segment updates
- *                      * ts_recent, the age will be reset later and ts_recent
- *                      * will get a valid value.  If it does not, setting
- *                      * ts_recent to zero will at least satisfy the
- *                      * requirement that zero be placed in the timestamp
- *                      * echo reply when ts_recent isn't valid.  The
- *                      * age isn't reset until we get a valid ts_recent
- *                      * because we don't want out-of-order segments to be
- *                      * dropped when ts_recent is old.
- *                      */
-/*                     tp->ts_recent = 0;
- *             } else {
- *                     tcpstat.tcps_rcvduppack++;
- *                     tcpstat.tcps_rcvdupbyte += ti->ti_len;
- *                     tcpstat.tcps_pawsdrop++;
- *                     goto dropafterack;
- *             }
- *     }
- */
-
        todrop = tp->rcv_nxt - ti->ti_seq;
        if (todrop > 0) {
                if (tiflags & TH_SYN) {
@@ -947,18 +836,6 @@ trimthenstep6:
                tiflags &= ~(TH_PUSH|TH_FIN);
        }
 
-       /*
-        * If last ACK falls within this segment's sequence numbers,
-        * record its timestamp.
-        */
-/*     if (ts_present && SEQ_LEQ(ti->ti_seq, tp->last_ack_sent) &&
- *         SEQ_LT(tp->last_ack_sent, ti->ti_seq + ti->ti_len +
- *                ((tiflags & (TH_SYN|TH_FIN)) != 0))) {
- *             tp->ts_recent_age = tcp_now;
- *             tp->ts_recent = ts_val;
- *     }
- */
-
        /*
         * If the RST bit is set examine the state:
         *    SYN_RECEIVED STATE:
@@ -972,15 +849,10 @@ trimthenstep6:
        if (tiflags&TH_RST) switch (tp->t_state) {
 
        case TCPS_SYN_RECEIVED:
-/*             so->so_error = ECONNREFUSED; */
-               goto close;
-
        case TCPS_ESTABLISHED:
        case TCPS_FIN_WAIT_1:
        case TCPS_FIN_WAIT_2:
        case TCPS_CLOSE_WAIT:
-/*             so->so_error = ECONNRESET; */
-       close:
                tp->t_state = TCPS_CLOSED;
                STAT(tcpstat.tcps_drops++);
                tp = tcp_close(tp);
@@ -1048,13 +920,6 @@ trimthenstep6:
                  soisfconnected(so);
                }
 
-               /* Do window scaling? */
-/*             if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
- *                     (TF_RCVD_SCALE|TF_REQ_SCALE)) {
- *                     tp->snd_scale = tp->requested_s_scale;
- *                     tp->rcv_scale = tp->request_r_scale;
- *             }
- */
                (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0);
                tp->snd_wl1 = ti->ti_seq - 1;
                /* Avoid ack processing; snd_una==ti_ack  =>  dup ack */
@@ -1155,19 +1020,13 @@ trimthenstep6:
                STAT(tcpstat.tcps_rcvackbyte += acked);
 
                /*
-                * If we have a timestamp reply, update smoothed
-                * round trip time.  If no timestamp is present but
-                * transmit timer is running and timed sequence
+                * If transmit timer is running and timed sequence
                 * number was acked, update smoothed round trip time.
                 * Since we now have an rtt measurement, cancel the
                 * timer backoff (cf., Phil Karn's retransmit alg.).
                 * Recompute the initial retransmit timer.
                 */
-/*             if (ts_present)
- *                     tcp_xmit_timer(tp, tcp_now-ts_ecr+1);
- *             else
- */
-                    if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
+               if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq))
                        tcp_xmit_timer(tp,tp->t_rtt);
 
                /*
@@ -1205,13 +1064,6 @@ trimthenstep6:
                        tp->snd_wnd -= acked;
                        ourfinisacked = 0;
                }
-               /*
-                * XXX sowwakup is called when data is acked and there's room for
-                * for more data... it should read() the socket
-                */
-/*             if (so->so_snd.sb_flags & SB_NOTIFY)
- *                     sowwakeup(so);
- */
                tp->snd_una = ti->ti_ack;
                if (SEQ_LT(tp->snd_nxt, tp->snd_una))
                        tp->snd_nxt = tp->snd_una;
@@ -1233,7 +1085,6 @@ trimthenstep6:
                                 * we'll hang forever.
                                 */
                                if (so->so_state & SS_FCANTRCVMORE) {
-                                       soisfdisconnected(so);
                                        tp->t_timer[TCPT_2MSL] = TCP_MAXIDLE;
                                }
                                tp->t_state = TCPS_FIN_WAIT_2;
@@ -1251,7 +1102,6 @@ trimthenstep6:
                                tp->t_state = TCPS_TIME_WAIT;
                                tcp_canceltimers(tp);
                                tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
-                               soisfdisconnected(so);
                        }
                        break;
 
@@ -1384,7 +1234,6 @@ dodata:
                         * will got to TCPS_LAST_ACK, and use tcp_output()
                         * to send the FIN.
                         */
-/*                     sofcantrcvmore(so); */
                        sofwdrain(so);
 
                        tp->t_flags |= TF_ACKNOW;
@@ -1421,7 +1270,6 @@ dodata:
                        tp->t_state = TCPS_TIME_WAIT;
                        tcp_canceltimers(tp);
                        tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
-                       soisfdisconnected(so);
                        break;
 
                /*
@@ -1440,13 +1288,6 @@ dodata:
         *
         * See above.
         */
-/*     if (ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg) {
- */
-/*     if ((ti->ti_len && (unsigned)ti->ti_len < tp->t_maxseg &&
- *             (so->so_iptos & IPTOS_LOWDELAY) == 0) ||
- *            ((so->so_iptos & IPTOS_LOWDELAY) &&
- *            ((struct tcpiphdr_2 *)ti)->first_char == (char)27)) {
- */
        if (ti->ti_len && (unsigned)ti->ti_len <= 5 &&
            ((struct tcpiphdr_2 *)ti)->first_char == (char)27) {
                tp->t_flags |= TF_ACKNOW;
@@ -1493,10 +1334,6 @@ drop:
        return;
 }
 
- /* , ts_present, ts_val, ts_ecr) */
-/*     int *ts_present;
- *     u_int32_t *ts_val, *ts_ecr;
- */
 static void
 tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
 {
@@ -1531,35 +1368,6 @@ tcp_dooptions(struct tcpcb *tp, u_char *cp, int cnt, struct tcpiphdr *ti)
                        NTOHS(mss);
                        (void) tcp_mss(tp, mss);        /* sets t_maxseg */
                        break;
-
-/*             case TCPOPT_WINDOW:
- *                     if (optlen != TCPOLEN_WINDOW)
- *                             continue;
- *                     if (!(ti->ti_flags & TH_SYN))
- *                             continue;
- *                     tp->t_flags |= TF_RCVD_SCALE;
- *                     tp->requested_s_scale = min(cp[2], TCP_MAX_WINSHIFT);
- *                     break;
- */
-/*             case TCPOPT_TIMESTAMP:
- *                     if (optlen != TCPOLEN_TIMESTAMP)
- *                             continue;
- *                     *ts_present = 1;
- *                     memcpy((char *) ts_val, (char *)cp + 2, sizeof(*ts_val));
- *                     NTOHL(*ts_val);
- *                     memcpy((char *) ts_ecr, (char *)cp + 6, sizeof(*ts_ecr));
- *                     NTOHL(*ts_ecr);
- *
- */                    /*
- *                      * A timestamp received in a SYN makes
- *                      * it ok to send timestamp requests and replies.
- *                      */
-/*                     if (ti->ti_flags & TH_SYN) {
- *                             tp->t_flags |= TF_RCVD_TSTMP;
- *                             tp->ts_recent = *ts_val;
- *                             tp->ts_recent_age = tcp_now;
- *                     }
- */                    break;
                }
        }
 }
index 5daf58e73a0b13a52f385106b533ac2bae0913be..a11f3da1a04977f872027158b2dd154e3722927c 100644 (file)
@@ -272,39 +272,9 @@ send:
                        mss = htons((u_int16_t) tcp_mss(tp, 0));
                        memcpy((caddr_t)(opt + 2), (caddr_t)&mss, sizeof(mss));
                        optlen = 4;
-
-/*                     if ((tp->t_flags & TF_REQ_SCALE) &&
- *                         ((flags & TH_ACK) == 0 ||
- *                         (tp->t_flags & TF_RCVD_SCALE))) {
- *                             *((u_int32_t *) (opt + optlen)) = htonl(
- *                                     TCPOPT_NOP << 24 |
- *                                     TCPOPT_WINDOW << 16 |
- *                                     TCPOLEN_WINDOW << 8 |
- *                                     tp->request_r_scale);
- *                             optlen += 4;
- *                     }
- */
                }
        }
 
-       /*
-        * Send a timestamp and echo-reply if this is a SYN and our side
-        * wants to use timestamps (TF_REQ_TSTMP is set) or both our side
-        * and our peer have sent timestamps in our SYN's.
-        */
-/*     if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
- *          (flags & TH_RST) == 0 &&
- *         ((flags & (TH_SYN|TH_ACK)) == TH_SYN ||
- *          (tp->t_flags & TF_RCVD_TSTMP))) {
- *             u_int32_t *lp = (u_int32_t *)(opt + optlen);
- *
- *             / * Form timestamp option as shown in appendix A of RFC 1323. *  /
- *             *lp++ = htonl(TCPOPT_TSTAMP_HDR);
- *             *lp++ = htonl(tcp_now);
- *             *lp   = htonl(tp->ts_recent);
- *             optlen += TCPOLEN_TSTAMP_APPA;
- *     }
- */
        hdrlen += optlen;
 
        /*
@@ -334,28 +304,15 @@ send:
 
                m = m_get();
                if (m == NULL) {
-/*                     error = ENOBUFS; */
                        error = 1;
                        goto out;
                }
                m->m_data += IF_MAXLINKHDR;
                m->m_len = hdrlen;
 
-               /*
-                * This will always succeed, since we make sure our mbufs
-                * are big enough to hold one MSS packet + header + ... etc.
-                */
-/*             if (len <= MHLEN - hdrlen - max_linkhdr) { */
-
-                       sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
-                       m->m_len += len;
+               sbcopy(&so->so_snd, off, (int) len, mtod(m, caddr_t) + hdrlen);
+               m->m_len += len;
 
-/*             } else {
- *                     m->m_next = m_copy(so->so_snd.sb_mb, off, (int) len);
- *                     if (m->m_next == 0)
- *                             len = 0;
- *             }
- */
                /*
                 * If we're sending everything we've got, set PUSH.
                 * (This will keep happy those implementations which only
@@ -376,7 +333,6 @@ send:
 
                m = m_get();
                if (m == NULL) {
-/*                     error = ENOBUFS; */
                        error = 1;
                        goto out;
                }
@@ -433,10 +389,6 @@ send:
 
        if (SEQ_GT(tp->snd_up, tp->snd_una)) {
                ti->ti_urp = htons((u_int16_t)(tp->snd_up - ntohl(ti->ti_seq)));
-#ifdef notdef
-       if (SEQ_GT(tp->snd_up, tp->snd_nxt)) {
-               ti->ti_urp = htons((u_int16_t)(tp->snd_up - tp->snd_nxt));
-#endif
                ti->ti_flags |= TH_URG;
        } else
                /*
@@ -523,32 +475,10 @@ send:
        ((struct ip *)ti)->ip_ttl = IPDEFTTL;
        ((struct ip *)ti)->ip_tos = so->so_iptos;
 
-/* #if BSD >= 43 */
-       /* Don't do IP options... */
-/*     error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
- *         so->so_options & SO_DONTROUTE, 0);
- */
        error = ip_output(so, m);
-
-/* #else
- *     error = ip_output(m, (struct mbuf *)0, &tp->t_inpcb->inp_route,
- *         so->so_options & SO_DONTROUTE);
- * #endif
- */
     }
        if (error) {
 out:
-/*             if (error == ENOBUFS) {
- *                     tcp_quench(tp->t_inpcb, 0);
- *                     return (0);
- *             }
- */
-/*             if ((error == EHOSTUNREACH || error == ENETDOWN)
- *                 && TCPS_HAVERCVDSYN(tp->t_state)) {
- *                     tp->t_softerror = error;
- *                     return (0);
- *             }
- */
                return (error);
        }
        STAT(tcpstat.tcps_sndtotal++);
@@ -574,9 +504,6 @@ tcp_setpersist(struct tcpcb *tp)
 {
     int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1;
 
-/*     if (tp->t_timer[TCPT_REXMT])
- *             panic("tcp_output REXMT");
- */
        /*
         * Start/restart persistence timer.
         */
index 219f1dd00557c3c0acf595ca446c0818d9cdef9a..892bd833257ce98587b4a8f5c6ed89f994d7cfbc 100644 (file)
@@ -60,7 +60,6 @@ tcp_init(void)
  * in a skeletal tcp/ip header, minimizing the amount of work
  * necessary when the connection is used.
  */
-/* struct tcpiphdr * */
 void
 tcp_template(struct tcpcb *tp)
 {
@@ -119,11 +118,7 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,
         if (m == NULL) {
                if ((m = m_get()) == NULL)
                        return;
-#ifdef TCP_COMPAT_42
-               tlen = 1;
-#else
                tlen = 0;
-#endif
                m->m_data += IF_MAXLINKHDR;
                *mtod(m, struct tcpiphdr *) = *ti;
                ti = mtod(m, struct tcpiphdr *);
@@ -220,12 +215,6 @@ tcp_newtcpcb(struct socket *so)
  */
 struct tcpcb *tcp_drop(struct tcpcb *tp, int err)
 {
-/* tcp_drop(tp, errno)
-       register struct tcpcb *tp;
-       int errno;
-{
-*/
-
        DEBUG_CALL("tcp_drop");
        DEBUG_ARG("tp = %lx", (long)tp);
        DEBUG_ARG("errno = %d", errno);
@@ -236,10 +225,6 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err)
                STAT(tcpstat.tcps_drops++);
        } else
                STAT(tcpstat.tcps_conndrops++);
-/*     if (errno == ETIMEDOUT && tp->t_softerror)
- *             errno = tp->t_softerror;
- */
-/*     so->so_error = errno; */
        return (tcp_close(tp));
 }
 
@@ -267,14 +252,8 @@ tcp_close(struct tcpcb *tp)
                remque(tcpiphdr2qlink(tcpiphdr_prev(t)));
                m_freem(m);
        }
-       /* It's static */
-/*     if (tp->t_template)
- *             (void) m_free(dtom(tp->t_template));
- */
-/*     free(tp, M_PCB);  */
        free(tp);
         so->so_tcpcb = NULL;
-       soisfdisconnected(so);
        /* clobber input socket cache if we're closing the cached connection */
        if (so == tcp_last_so)
                tcp_last_so = &tcb;
@@ -286,30 +265,6 @@ tcp_close(struct tcpcb *tp)
        return ((struct tcpcb *)0);
 }
 
-#ifdef notdef
-void
-tcp_drain()
-{
-       /* XXX */
-}
-
-/*
- * When a source quench is received, close congestion window
- * to one segment.  We will gradually open it again as we proceed.
- */
-void
-tcp_quench(i, errno)
-
-       int errno;
-{
-       struct tcpcb *tp = intotcpcb(inp);
-
-       if (tp)
-               tp->snd_cwnd = tp->t_maxseg;
-}
-
-#endif /* notdef */
-
 /*
  * TCP protocol interface to socket abstraction.
  */
@@ -349,9 +304,6 @@ tcp_sockclosed(struct tcpcb *tp)
                tp->t_state = TCPS_LAST_ACK;
                break;
        }
-/*     soisfdisconnecting(tp->t_socket); */
-       if (tp && tp->t_state >= TCPS_FIN_WAIT_2)
-               soisfdisconnected(tp->t_socket);
        if (tp)
                tcp_output(tp);
 }
@@ -490,13 +442,6 @@ tcp_connect(struct socket *inso)
 
        tcp_template(tp);
 
-       /* Compute window scaling to request.  */
-/*     while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
- *             (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
- *             tp->request_r_scale++;
- */
-
-/*     soisconnecting(so); */ /* NOFDREF used instead */
        STAT(tcpstat.tcps_connattempt++);
 
        tp->t_state = TCPS_SYN_SENT;
@@ -540,10 +485,7 @@ static const struct tos_t tcptos[] = {
          {0, 0, 0, 0}
 };
 
-#ifdef CONFIG_QEMU
-static
-#endif
-struct emu_t *tcpemu = NULL;
+static struct emu_t *tcpemu = NULL;
 
 /*
  * Return TOS according to the above table
@@ -575,10 +517,6 @@ tcp_tos(struct socket *so)
        return 0;
 }
 
-#if 0
-int do_echo = -1;
-#endif
-
 /*
  * Emulate programs that try and connect to us
  * This includes ftp (the data connection is
@@ -661,302 +599,6 @@ tcp_emu(struct socket *so, struct mbuf *m)
                        return 0;
                }
 
-#if 0
-        case EMU_RLOGIN:
-               /*
-                * Rlogin emulation
-                * First we accumulate all the initial option negotiation,
-                * then fork_exec() rlogin according to the  options
-                */
-               {
-                       int i, i2, n;
-                       char *ptr;
-                       char args[100];
-                       char term[100];
-                       struct sbuf *so_snd = &so->so_snd;
-                       struct sbuf *so_rcv = &so->so_rcv;
-
-                       /* First check if they have a priveladged port, or too much data has arrived */
-                       if (ntohs(so->so_lport) > 1023 || ntohs(so->so_lport) < 512 ||
-                           (m->m_len + so_rcv->sb_wptr) > (so_rcv->sb_data + so_rcv->sb_datalen)) {
-                               memcpy(so_snd->sb_wptr, "Permission denied\n", 18);
-                               so_snd->sb_wptr += 18;
-                               so_snd->sb_cc += 18;
-                               tcp_sockclosed(sototcpcb(so));
-                               m_free(m);
-                               return 0;
-                       }
-
-                       /* Append the current data */
-                       memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
-                       so_rcv->sb_wptr += m->m_len;
-                       so_rcv->sb_rptr += m->m_len;
-                       m_free(m);
-
-                       /*
-                        * Check if we have all the initial options,
-                        * and build argument list to rlogin while we're here
-                        */
-                       n = 0;
-                       ptr = so_rcv->sb_data;
-                       args[0] = 0;
-                       term[0] = 0;
-                       while (ptr < so_rcv->sb_wptr) {
-                               if (*ptr++ == 0) {
-                                       n++;
-                                       if (n == 2) {
-                                               sprintf(args, "rlogin -l %s %s",
-                                                       ptr, inet_ntoa(so->so_faddr));
-                                       } else if (n == 3) {
-                                               i2 = so_rcv->sb_wptr - ptr;
-                                               for (i = 0; i < i2; i++) {
-                                                       if (ptr[i] == '/') {
-                                                               ptr[i] = 0;
-#ifdef HAVE_SETENV
-                                                               sprintf(term, "%s", ptr);
-#else
-                                                               sprintf(term, "TERM=%s", ptr);
-#endif
-                                                               ptr[i] = '/';
-                                                               break;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-
-                       if (n != 4)
-                          return 0;
-
-                       /* We have it, set our term variable and fork_exec() */
-#ifdef HAVE_SETENV
-                       setenv("TERM", term, 1);
-#else
-                       putenv(term);
-#endif
-                       fork_exec(so, args, 2);
-                       term[0] = 0;
-                       so->so_emu = 0;
-
-                       /* And finally, send the client a 0 character */
-                       so_snd->sb_wptr[0] = 0;
-                       so_snd->sb_wptr++;
-                       so_snd->sb_cc++;
-
-                       return 0;
-               }
-
-        case EMU_RSH:
-               /*
-                * rsh emulation
-                * First we accumulate all the initial option negotiation,
-                * then rsh_exec() rsh according to the  options
-                */
-               {
-                       int  n;
-                       char *ptr;
-                       char *user;
-                       char *args;
-                       struct sbuf *so_snd = &so->so_snd;
-                       struct sbuf *so_rcv = &so->so_rcv;
-
-                       /* First check if they have a priveladged port, or too much data has arrived */
-                       if (ntohs(so->so_lport) > 1023 || ntohs(so->so_lport) < 512 ||
-                           (m->m_len + so_rcv->sb_wptr) > (so_rcv->sb_data + so_rcv->sb_datalen)) {
-                               memcpy(so_snd->sb_wptr, "Permission denied\n", 18);
-                               so_snd->sb_wptr += 18;
-                               so_snd->sb_cc += 18;
-                               tcp_sockclosed(sototcpcb(so));
-                               m_free(m);
-                               return 0;
-                       }
-
-                       /* Append the current data */
-                       memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
-                       so_rcv->sb_wptr += m->m_len;
-                       so_rcv->sb_rptr += m->m_len;
-                       m_free(m);
-
-                       /*
-                        * Check if we have all the initial options,
-                        * and build argument list to rlogin while we're here
-                        */
-                       n = 0;
-                       ptr = so_rcv->sb_data;
-                       user="";
-                       args="";
-                       if (so->extra==NULL) {
-                               struct socket *ns;
-                               struct tcpcb* tp;
-                               int port=atoi(ptr);
-                               if (port <= 0) return 0;
-                if (port > 1023 || port < 512) {
-                  memcpy(so_snd->sb_wptr, "Permission denied\n", 18);
-                  so_snd->sb_wptr += 18;
-                  so_snd->sb_cc += 18;
-                  tcp_sockclosed(sototcpcb(so));
-                  return 0;
-                }
-                               if ((ns=socreate()) == NULL)
-                  return 0;
-                               if (tcp_attach(ns)<0) {
-                  free(ns);
-                  return 0;
-                               }
-
-                               ns->so_laddr=so->so_laddr;
-                               ns->so_lport=htons(port);
-
-                               (void) tcp_mss(sototcpcb(ns), 0);
-
-                               ns->so_faddr=so->so_faddr;
-                               ns->so_fport=htons(IPPORT_RESERVED-1); /* Use a fake port. */
-
-                               if (ns->so_faddr.s_addr == 0 ||
-                                       ns->so_faddr.s_addr == loopback_addr.s_addr)
-                  ns->so_faddr = alias_addr;
-
-                               ns->so_iptos = tcp_tos(ns);
-                               tp = sototcpcb(ns);
-
-                               tcp_template(tp);
-
-                               /* Compute window scaling to request.  */
-                               /*      while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
-                                *              (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
-                                *              tp->request_r_scale++;
-                                */
-
-                /*soisfconnecting(ns);*/
-
-                               STAT(tcpstat.tcps_connattempt++);
-
-                               tp->t_state = TCPS_SYN_SENT;
-                               tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
-                               tp->iss = tcp_iss;
-                               tcp_iss += TCP_ISSINCR/2;
-                               tcp_sendseqinit(tp);
-                               tcp_output(tp);
-                               so->extra=ns;
-                       }
-                       while (ptr < so_rcv->sb_wptr) {
-              if (*ptr++ == 0) {
-                n++;
-                if (n == 2) {
-                  user=ptr;
-                } else if (n == 3) {
-                  args=ptr;
-                }
-              }
-                       }
-
-                       if (n != 4)
-              return 0;
-
-                       rsh_exec(so,so->extra, user, inet_ntoa(so->so_faddr), args);
-                       so->so_emu = 0;
-                       so->extra=NULL;
-
-                       /* And finally, send the client a 0 character */
-                       so_snd->sb_wptr[0] = 0;
-                       so_snd->sb_wptr++;
-                       so_snd->sb_cc++;
-
-                       return 0;
-               }
-
-        case EMU_CTL:
-               {
-                       int num;
-                       struct sbuf *so_snd = &so->so_snd;
-                       struct sbuf *so_rcv = &so->so_rcv;
-
-                       /*
-                        * If there is binary data here, we save it in so->so_m
-                        */
-                       if (!so->so_m) {
-                         int rxlen;
-                         char *rxdata;
-                         rxdata=mtod(m, char *);
-                         for (rxlen=m->m_len; rxlen; rxlen--) {
-                           if (*rxdata++ & 0x80) {
-                             so->so_m = m;
-                             return 0;
-                           }
-                         }
-                       } /* if(so->so_m==NULL) */
-
-                       /*
-                        * Append the line
-                        */
-                       sbappendsb(so_rcv, m);
-
-                       /* To avoid going over the edge of the buffer, we reset it */
-                       if (so_snd->sb_cc == 0)
-                          so_snd->sb_wptr = so_snd->sb_rptr = so_snd->sb_data;
-
-                       /*
-                        * A bit of a hack:
-                        * If the first packet we get here is 1 byte long, then it
-                        * was done in telnet character mode, therefore we must echo
-                        * the characters as they come.  Otherwise, we echo nothing,
-                        * because in linemode, the line is already echoed
-                        * XXX two or more control connections won't work
-                        */
-                       if (do_echo == -1) {
-                               if (m->m_len == 1) do_echo = 1;
-                               else do_echo = 0;
-                       }
-                       if (do_echo) {
-                         sbappendsb(so_snd, m);
-                         m_free(m);
-                         tcp_output(sototcpcb(so)); /* XXX */
-                       } else
-                         m_free(m);
-
-                       num = 0;
-                       while (num < so->so_rcv.sb_cc) {
-                               if (*(so->so_rcv.sb_rptr + num) == '\n' ||
-                                   *(so->so_rcv.sb_rptr + num) == '\r') {
-                                       int n;
-
-                                       *(so_rcv->sb_rptr + num) = 0;
-                                       if (ctl_password && !ctl_password_ok) {
-                                               /* Need a password */
-                                               if (sscanf(so_rcv->sb_rptr, "pass %256s", buff) == 1) {
-                                                       if (strcmp(buff, ctl_password) == 0) {
-                                                               ctl_password_ok = 1;
-                                                               n = sprintf(so_snd->sb_wptr,
-                                                                           "Password OK.\r\n");
-                                                               goto do_prompt;
-                                                       }
-                                               }
-                                               n = sprintf(so_snd->sb_wptr,
-                                        "Error: Password required, log on with \"pass PASSWORD\"\r\n");
-                                               goto do_prompt;
-                                       }
-                                       cfg_quitting = 0;
-                                       n = do_config(so_rcv->sb_rptr, so, PRN_SPRINTF);
-                                       if (!cfg_quitting) {
-                                               /* Register the printed data */
-do_prompt:
-                                               so_snd->sb_cc += n;
-                                               so_snd->sb_wptr += n;
-                                               /* Add prompt */
-                                               n = sprintf(so_snd->sb_wptr, "Slirp> ");
-                                               so_snd->sb_cc += n;
-                                               so_snd->sb_wptr += n;
-                                       }
-                                       /* Drop so_rcv data */
-                                       so_rcv->sb_cc = 0;
-                                       so_rcv->sb_wptr = so_rcv->sb_rptr = so_rcv->sb_data;
-                                       tcp_output(sototcpcb(so)); /* Send the reply */
-                               }
-                               num++;
-                       }
-                       return 0;
-               }
-#endif
         case EMU_FTP: /* ftp */
                 *(m->m_data+m->m_len) = 0; /* NUL terminate for strstr */
                if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
@@ -1100,7 +742,7 @@ do_prompt:
                 * A typical packet for player version 1.0 (release version):
                 *
                 * 0000:50 4E 41 00 05
-                * 0000:00 01 00 02 1B D7 00 00 67 E6 6C DC 63 00 12 50 .....×..gælÜc..P
+                * 0000:00 01 00 02 1B D7 00 00 67 E6 6C DC 63 00 12 50 ........g.l.c..P
                 * 0010:4E 43 4C 49 45 4E 54 20 31 30 31 20 41 4C 50 48 NCLIENT 101 ALPH
                 * 0020:41 6C 00 00 52 00 17 72 61 66 69 6C 65 73 2F 76 Al..R..rafiles/v
                 * 0030:6F 61 2F 65 6E 67 6C 69 73 68 5F 2E 72 61 79 42 oa/english_.rayB
@@ -1112,8 +754,8 @@ do_prompt:
                 *
                 * A typical packet for player version 2.0 (beta):
                 *
-                * 0000:50 4E 41 00 06 00 02 00 00 00 01 00 02 1B C1 00 PNA...........Á.
-                * 0010:00 67 75 78 F5 63 00 0A 57 69 6E 32 2E 30 2E 30 .guxõc..Win2.0.0
+                * 0000:50 4E 41 00 06 00 02 00 00 00 01 00 02 1B C1 00 PNA.............
+                * 0010:00 67 75 78 F5 63 00 0A 57 69 6E 32 2E 30 2E 30 .gux.c..Win2.0.0
                 * 0020:2E 35 6C 00 00 52 00 1C 72 61 66 69 6C 65 73 2F .5l..R..rafiles/
                 * 0030:77 65 62 73 69 74 65 2F 32 30 72 65 6C 65 61 73 website/20releas
                 * 0040:65 2E 72 61 79 53 00 00 06 36 42                e.rayS...6B
index 9215eb2e6160a332577f93f89ad57cf6e5c374e9..9cacb0f0d452ab70ef3ec2d2ba5bf7b86b743f14 100644 (file)
@@ -102,10 +102,6 @@ tpgone:
                ;
        }
        tcp_iss += TCP_ISSINCR/PR_SLOWHZ;               /* increment iss */
-#ifdef TCP_COMPAT_42
-       if ((int)tcp_iss < 0)
-               tcp_iss = 0;                            /* XXX */
-#endif
        tcp_now++;                                      /* for timestamps */
 }
 
@@ -210,7 +206,6 @@ tcp_timers(register struct tcpcb *tp, int timer)
                 * retransmit times until then.
                 */
                if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) {
-/*                     in_losing(tp->t_inpcb); */
                        tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT);
                        tp->t_srtt = 0;
                }
@@ -275,7 +270,6 @@ tcp_timers(register struct tcpcb *tp, int timer)
                if (tp->t_state < TCPS_ESTABLISHED)
                        goto dropit;
 
-/*             if (tp->t_socket->so_options & SO_KEEPALIVE && */
                if ((SO_OPTIONS) && tp->t_state <= TCPS_CLOSE_WAIT) {
                        if (tp->t_idle >= TCPTV_KEEP_IDLE + TCP_MAXIDLE)
                                goto dropit;
@@ -292,17 +286,8 @@ tcp_timers(register struct tcpcb *tp, int timer)
                         * correspondent TCP to respond.
                         */
                        STAT(tcpstat.tcps_keepprobe++);
-#ifdef TCP_COMPAT_42
-                       /*
-                        * The keepalive packet must have nonzero length
-                        * to get a 4.2 host to respond.
-                        */
-                       tcp_respond(tp, &tp->t_template, (struct mbuf *)NULL,
-                           tp->rcv_nxt - 1, tp->snd_una - 1, 0);
-#else
                        tcp_respond(tp, &tp->t_template, (struct mbuf *)NULL,
                            tp->rcv_nxt, tp->snd_una - 1, 0);
-#endif
                        tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL;
                } else
                        tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE;
@@ -310,7 +295,7 @@ tcp_timers(register struct tcpcb *tp, int timer)
 
        dropit:
                STAT(tcpstat.tcps_keepdrops++);
-               tp = tcp_drop(tp, 0); /* ETIMEDOUT); */
+               tp = tcp_drop(tp, 0);
                break;
        }
 
index 791ee49df2c3c7983e7b3fa38d332c7d38737f5d..f648ed0de7e397e02ec432595d8a3ce28ff21946 100644 (file)
@@ -98,7 +98,6 @@
 #define        TCPTV_KEEPCNT   8                       /* max probes before drop */
 
 #define        TCPTV_MIN       (  1*PR_SLOWHZ)         /* minimum allowable value */
-/* #define     TCPTV_REXMTMAX  ( 64*PR_SLOWHZ) */      /* max allowable REXMT value */
 #define TCPTV_REXMTMAX  ( 12*PR_SLOWHZ)                /* max allowable REXMT value */
 
 #define        TCP_LINGERTIME  120                     /* linger at most 2 minutes */
 #define TCP_MAXRXTSHIFT 12                      /* maximum retransmits */
 
 
-#ifdef TCPTIMERS
-char *tcptimers[] =
-    { "REXMT", "PERSIST", "KEEP", "2MSL" };
-#endif
-
 /*
  * Force a time value to be in a certain range.
  */
index d4af1c8d0becf876d15dcbfe7a14f7c86faebc15..be5741fb452d20ea9f81fe835d1ecd234c603e31 100644 (file)
@@ -61,9 +61,7 @@ struct tcpcb {
 #define        TF_RCVD_TSTMP   0x0100          /* a timestamp was received in SYN */
 #define        TF_SACK_PERMIT  0x0200          /* other side said I could SACK */
 
-       /* Make it static  for now */
-/*     struct  tcpiphdr *t_template;   / * skeletal packet for transmit */
-       struct  tcpiphdr t_template;
+       struct  tcpiphdr t_template;    /* static skeletal packet for xmit */
 
        struct  socket *t_socket;               /* back pointer to socket */
 /*
@@ -199,7 +197,6 @@ struct tcpstat {
        u_long  tcps_rcvbyte;           /* bytes received in sequence */
        u_long  tcps_rcvbadsum;         /* packets received with ccksum errs */
        u_long  tcps_rcvbadoff;         /* packets received with bad offset */
-/*     u_long  tcps_rcvshort;  */      /* packets received too short */
        u_long  tcps_rcvduppack;        /* duplicate-only packets received */
        u_long  tcps_rcvdupbyte;        /* duplicate-only bytes received */
        u_long  tcps_rcvpartduppack;    /* packets with some duplicate data */
@@ -215,7 +212,6 @@ struct tcpstat {
        u_long  tcps_rcvackpack;        /* rcvd ack packets */
        u_long  tcps_rcvackbyte;        /* bytes acked by rcvd acks */
        u_long  tcps_rcvwinupd;         /* rcvd window update packets */
-/*     u_long  tcps_pawsdrop;  */      /* segments dropped due to PAWS */
        u_long  tcps_predack;           /* times hdr predict ok for acks */
        u_long  tcps_preddat;           /* times hdr predict ok for data pkts */
        u_long  tcps_socachemiss;       /* tcp_last_so misses */
index 7cb095fb1d504f49247386e59569b1d5a3c54d0c..3358e2b2304736ae52390306acf362753b3a46dc 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 #include <slirp.h>
-#include "qemu-common.h" // for pstrcpy
+#include "qemu-common.h"
 
 struct tftp_session {
     int in_use;
index 60fe75461460daaab009d87adc0c195d3db18daa..3798e343dfa786930fa624b71a5669f96101fffc 100644 (file)
@@ -50,16 +50,6 @@ struct socket udb;
 static u_int8_t udp_tos(struct socket *so);
 static void udp_emu(struct socket *so, struct mbuf *m);
 
-/*
- * UDP protocol implementation.
- * Per RFC 768, August, 1980.
- */
-#ifndef        COMPAT_42
-#define UDPCKSUM 1
-#else
-#define UDPCKSUM 0 /* XXX */
-#endif
-
 struct socket *udp_last_so = &udb;
 
 void
@@ -76,7 +66,6 @@ udp_input(register struct mbuf *m, int iphlen)
 {
        register struct ip *ip;
        register struct udphdr *uh;
-/*     struct mbuf *opts = 0;*/
        int len;
        struct ip save_ip;
        struct socket *so;
@@ -129,14 +118,10 @@ udp_input(register struct mbuf *m, int iphlen)
        /*
         * Checksum extended UDP header and data.
         */
-       if (UDPCKSUM && uh->uh_sum) {
+       if (uh->uh_sum) {
       memset(&((struct ipovly *)ip)->ih_mbuf, 0, sizeof(struct mbuf_ptr));
          ((struct ipovly *)ip)->ih_x1 = 0;
          ((struct ipovly *)ip)->ih_len = uh->uh_ulen;
-         /* keep uh_sum for ICMP reply
-          * uh->uh_sum = cksum(m, len + sizeof (struct ip));
-          * if (uh->uh_sum) {
-          */
          if(cksum(m, len + sizeof(struct ip))) {
            STAT(udpstat.udps_badsum++);
            goto bad;
@@ -201,7 +186,6 @@ udp_input(register struct mbuf *m, int iphlen)
          /*
           * Setup fields
           */
-         /* udp_last_so = so; */
          so->so_laddr = ip->ip_src;
          so->so_lport = uh->uh_sport;
 
@@ -246,7 +230,6 @@ udp_input(register struct mbuf *m, int iphlen)
        return;
 bad:
        m_freem(m);
-       /* if (opts) m_freem(opts); */
        return;
 }
 
@@ -277,7 +260,7 @@ int udp_output2(struct socket *so, struct mbuf *m,
     memset(&ui->ui_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr));
        ui->ui_x1 = 0;
        ui->ui_pr = IPPROTO_UDP;
-       ui->ui_len = htons(m->m_len - sizeof(struct ip)); /* + sizeof (struct udphdr)); */
+       ui->ui_len = htons(m->m_len - sizeof(struct ip));
        /* XXXXX Check for from-one-location sockets, or from-any-location sockets */
         ui->ui_src = saddr->sin_addr;
        ui->ui_dst = daddr->sin_addr;
@@ -289,10 +272,8 @@ int udp_output2(struct socket *so, struct mbuf *m,
         * Stuff checksum and output datagram.
         */
        ui->ui_sum = 0;
-       if (UDPCKSUM) {
-           if ((ui->ui_sum = cksum(m, /* sizeof (struct udpiphdr) + */ m->m_len)) == 0)
+       if ((ui->ui_sum = cksum(m, m->m_len)) == 0)
                ui->ui_sum = 0xffff;
-       }
        ((struct ip *)ui)->ip_len = m->m_len;
 
        ((struct ip *)ui)->ip_ttl = IPDEFTTL;
@@ -363,8 +344,6 @@ void
 udp_detach(struct socket *so)
 {
        closesocket(so->s);
-       /* if (so->so_m) m_free(so->so_m);    done by sofree */
-
        sofree(so);
 }
 
@@ -651,7 +630,6 @@ udp_listen(u_int32_t haddr, u_int hport, u_int32_t laddr, u_int lport,
                return NULL;
        }
        setsockopt(so->s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
-/*     setsockopt(so->s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); */
 
        getsockname(so->s,(struct sockaddr *)&addr,&addrlen);
        so->so_fport = addr.sin_port;