clean some stuff up and purge some crud
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Wed, 5 Jan 1983 15:18:45 +0000 (07:18 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Wed, 5 Jan 1983 15:18:45 +0000 (07:18 -0800)
SCCS-vsn: sys/netinet/in_pcb.c 4.38
SCCS-vsn: sys/netinet/ip_input.c 1.61
SCCS-vsn: sys/netinet/tcp_output.c 4.50
SCCS-vsn: sys/netinet/tcp_subr.c 4.38
SCCS-vsn: sys/netinet/tcp_timer.c 4.29
SCCS-vsn: sys/netinet/udp_usrreq.c 4.42

usr/src/sys/netinet/in_pcb.c
usr/src/sys/netinet/ip_input.c
usr/src/sys/netinet/tcp_output.c
usr/src/sys/netinet/tcp_subr.c
usr/src/sys/netinet/tcp_timer.c
usr/src/sys/netinet/udp_usrreq.c

index a52e99a..9b07f51 100644 (file)
@@ -1,4 +1,4 @@
-/*     in_pcb.c        4.37    82/12/14        */
+/*     in_pcb.c        4.38    83/01/04        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -24,7 +24,7 @@ in_pcballoc(so, head)
        register struct inpcb *inp;
 
        m = m_getclr(M_DONTWAIT, MT_PCB);
        register struct inpcb *inp;
 
        m = m_getclr(M_DONTWAIT, MT_PCB);
-       if (m == 0)
+       if (m == NULL)
                return (ENOBUFS);
        inp = mtod(m, struct inpcb *);
        inp->inp_head = head;
                return (ENOBUFS);
        inp = mtod(m, struct inpcb *);
        inp->inp_head = head;
@@ -45,14 +45,14 @@ in_pcbbind(inp, nam)
 
        if (ifnet == 0)
                return (EADDRNOTAVAIL);
 
        if (ifnet == 0)
                return (EADDRNOTAVAIL);
-       if (inp->inp_lport || inp->inp_laddr.s_addr)
+       if (inp->inp_lport || inp->inp_laddr.s_addr != INADDR_ANY)
                return (EINVAL);
        if (nam == 0)
                goto noname;
        sin = mtod(nam, struct sockaddr_in *);
        if (nam->m_len != sizeof (*sin))
                return (EINVAL);
                return (EINVAL);
        if (nam == 0)
                goto noname;
        sin = mtod(nam, struct sockaddr_in *);
        if (nam->m_len != sizeof (*sin))
                return (EINVAL);
-       if (sin->sin_addr.s_addr) {
+       if (sin->sin_addr.s_addr != INADDR_ANY) {
                int tport = sin->sin_port;
 
                sin->sin_port = 0;              /* yech... */
                int tport = sin->sin_port;
 
                sin->sin_port = 0;              /* yech... */
@@ -105,9 +105,9 @@ in_pcbconnect(inp, nam)
                return (EINVAL);
        if (sin->sin_family != AF_INET)
                return (EAFNOSUPPORT);
                return (EINVAL);
        if (sin->sin_family != AF_INET)
                return (EAFNOSUPPORT);
-       if (sin->sin_addr.s_addr == 0 || sin->sin_port == 0)
+       if (sin->sin_addr.s_addr == INADDR_ANY || sin->sin_port == 0)
                return (EADDRNOTAVAIL);
                return (EADDRNOTAVAIL);
-       if (inp->inp_laddr.s_addr == 0) {
+       if (inp->inp_laddr.s_addr == INADDR_ANY) {
                ifp = if_ifonnetof(in_netof(sin->sin_addr));
                if (ifp == 0) {
                        /*
                ifp = if_ifonnetof(in_netof(sin->sin_addr));
                if (ifp == 0) {
                        /*
@@ -129,7 +129,7 @@ in_pcbconnect(inp, nam)
            inp->inp_lport,
            0))
                return (EADDRINUSE);
            inp->inp_lport,
            0))
                return (EADDRINUSE);
-       if (inp->inp_laddr.s_addr == 0)
+       if (inp->inp_laddr.s_addr == INADDR_ANY)
                inp->inp_laddr = ifaddr->sin_addr;
        inp->inp_faddr = sin->sin_addr;
        inp->inp_fport = sin->sin_port;
                inp->inp_laddr = ifaddr->sin_addr;
        inp->inp_faddr = sin->sin_addr;
        inp->inp_fport = sin->sin_port;
@@ -140,7 +140,7 @@ in_pcbdisconnect(inp)
        struct inpcb *inp;
 {
 
        struct inpcb *inp;
 {
 
-       inp->inp_faddr.s_addr = 0;
+       inp->inp_faddr.s_addr = INADDR_ANY;
        inp->inp_fport = 0;
        if (inp->inp_socket->so_state & SS_NOFDREF)
                in_pcbdetach(inp);
        inp->inp_fport = 0;
        if (inp->inp_socket->so_state & SS_NOFDREF)
                in_pcbdetach(inp);
@@ -217,23 +217,23 @@ in_pcblookup(head, faddr, fport, laddr, lport, flags)
                if (inp->inp_lport != lport)
                        continue;
                wildcard = 0;
                if (inp->inp_lport != lport)
                        continue;
                wildcard = 0;
-               if (inp->inp_laddr.s_addr != 0) {
-                       if (laddr.s_addr == 0)
+               if (inp->inp_laddr.s_addr != INADDR_ANY) {
+                       if (laddr.s_addr == INADDR_ANY)
                                wildcard++;
                        else if (inp->inp_laddr.s_addr != laddr.s_addr)
                                continue;
                } else {
                                wildcard++;
                        else if (inp->inp_laddr.s_addr != laddr.s_addr)
                                continue;
                } else {
-                       if (laddr.s_addr != 0)
+                       if (laddr.s_addr != INADDR_ANY)
                                wildcard++;
                }
                                wildcard++;
                }
-               if (inp->inp_faddr.s_addr != 0) {
-                       if (faddr.s_addr == 0)
+               if (inp->inp_faddr.s_addr != INADDR_ANY) {
+                       if (faddr.s_addr == INADDR_ANY)
                                wildcard++;
                        else if (inp->inp_faddr.s_addr != faddr.s_addr ||
                            inp->inp_fport != fport)
                                continue;
                } else {
                                wildcard++;
                        else if (inp->inp_faddr.s_addr != faddr.s_addr ||
                            inp->inp_fport != fport)
                                continue;
                } else {
-                       if (faddr.s_addr != 0)
+                       if (faddr.s_addr != INADDR_ANY)
                                wildcard++;
                }
                if (wildcard && (flags & INPLOOKUP_WILDCARD) == 0)
                                wildcard++;
                }
                if (wildcard && (flags & INPLOOKUP_WILDCARD) == 0)
index fb06437..fe813c6 100644 (file)
@@ -1,4 +1,4 @@
-/*     ip_input.c      1.60    83/01/03        */
+/*     ip_input.c      1.61    83/01/04        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -506,7 +506,7 @@ ip_dooptions(ip)
 
                        case IPOPT_TS_PRESPEC:
                                ipaddr.sin_addr = *sin;
 
                        case IPOPT_TS_PRESPEC:
                                ipaddr.sin_addr = *sin;
-                               if (!if_ifwithaddr((struct sockaddr *)&ipaddr))
+                               if (if_ifwithaddr((struct sockaddr *)&ipaddr) == 0)
                                        continue;
                                if (ipt->ipt_ptr + 8 > ipt->ipt_len)
                                        goto bad;
                                        continue;
                                if (ipt->ipt_ptr + 8 > ipt->ipt_len)
                                        goto bad;
index 6dc94b5..52e19a6 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_output.c    4.49    82/12/14        */
+/*     tcp_output.c    4.50    83/01/04        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -22,8 +22,6 @@
 #include "../netinet/tcp_debug.h"
 #include <errno.h>
 
 #include "../netinet/tcp_debug.h"
 #include <errno.h>
 
-char *tcpstates[]; /* XXX */
-
 /*
  * Initial options.
  */
 /*
  * Initial options.
  */
@@ -142,7 +140,7 @@ send:
         * the template for sends on this connection.
         */
        MGET(m, M_DONTWAIT, MT_DATA);
         * the template for sends on this connection.
         */
        MGET(m, M_DONTWAIT, MT_DATA);
-       if (m == 0)
+       if (m == INADDR_ANY)
                return (ENOBUFS);
        m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
        m->m_len = sizeof (struct tcpiphdr);
                return (ENOBUFS);
        m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
        m->m_len = sizeof (struct tcpiphdr);
@@ -223,7 +221,7 @@ noopt:
        /*
         * If anything to send and we can send it all, set PUSH.
         * (This will keep happy those implementations which only
        /*
         * If anything to send and we can send it all, set PUSH.
         * (This will keep happy those implementations which only
-        * give data to the user when a buffer fills or a PUSH comes in.
+        * give data to the user when a buffer fills or a PUSH comes in.)
         */
        if (len && off+len == so->so_snd.sb_cc)
                ti->ti_flags |= TH_PUSH;
         */
        if (len && off+len == so->so_snd.sb_cc)
                ti->ti_flags |= TH_PUSH;
index 837736f..ed9e379 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_subr.c      4.37    82/12/16        */
+/*     tcp_subr.c      4.38    83/01/04        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -49,7 +49,7 @@ tcp_template(tp)
        register struct tcpiphdr *n;
 
        m = m_get(M_WAIT, MT_HEADER);
        register struct tcpiphdr *n;
 
        m = m_get(M_WAIT, MT_HEADER);
-       if (m == 0)
+       if (m == NULL)
                return (0);
        m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
        m->m_len = sizeof (struct tcpiphdr);
                return (0);
        m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
        m->m_len = sizeof (struct tcpiphdr);
@@ -102,7 +102,7 @@ tcp_respond(tp, ti, ack, seq, flags)
        }
        if (flags == 0) {
                m = m_get(M_DONTWAIT, MT_HEADER);
        }
        if (flags == 0) {
                m = m_get(M_DONTWAIT, MT_HEADER);
-               if (m == 0)
+               if (m == NULL)
                        return;
                m->m_len = sizeof (struct tcpiphdr) + 1;
                *mtod(m, struct tcpiphdr *) = *ti;
                        return;
                m->m_len = sizeof (struct tcpiphdr) + 1;
                *mtod(m, struct tcpiphdr *) = *ti;
@@ -149,8 +149,8 @@ tcp_newtcpcb(inp)
        struct mbuf *m = m_getclr(M_DONTWAIT, MT_PCB);
        register struct tcpcb *tp;
 
        struct mbuf *m = m_getclr(M_DONTWAIT, MT_PCB);
        register struct tcpcb *tp;
 
-       if (m == 0)
-               return (0);
+       if (m == NULL)
+               return ((struct tcpcb *)0);
        tp = mtod(m, struct tcpcb *);
        tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
        /*
        tp = mtod(m, struct tcpcb *);
        tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
        /*
index 725b668..564e50d 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_timer.c     4.28    82/10/20        */
+/*     tcp_timer.c     4.29    83/01/04        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -103,7 +103,6 @@ tcp_canceltimers(tp)
 
 float  tcp_backoff[TCP_MAXRXTSHIFT] =
     { 1.0, 1.2, 1.4, 1.7, 2.0, 3.0, 5.0, 8.0, 16.0, 32.0 };
 
 float  tcp_backoff[TCP_MAXRXTSHIFT] =
     { 1.0, 1.2, 1.4, 1.7, 2.0, 3.0, 5.0, 8.0, 16.0, 32.0 };
-int    tcprexmtprint = 0;
 int    tcpexprexmtbackoff = 0;
 /*
  * TCP timer processing.
 int    tcpexprexmtbackoff = 0;
 /*
  * TCP timer processing.
@@ -147,8 +146,6 @@ tcp_timers(tp, timer)
                                tcp_backoff[tp->t_rxtshift - 1],
                            TCPTV_MIN, TCPTV_MAX);
                }
                                tcp_backoff[tp->t_rxtshift - 1],
                            TCPTV_MIN, TCPTV_MAX);
                }
-if (tcprexmtprint)
-printf("rexmt set to %d\n", tp->t_timer[TCPT_REXMT]);
                tp->snd_nxt = tp->snd_una;
                /* this only transmits one segment! */
                (void) tcp_output(tp);
                tp->snd_nxt = tp->snd_una;
                /* this only transmits one segment! */
                (void) tcp_output(tp);
index cd4131f..e0aedcc 100644 (file)
@@ -1,4 +1,4 @@
-/*     udp_usrreq.c    4.41    82/12/14        */
+/*     udp_usrreq.c    4.42    83/01/04        */
 
 #include "../h/param.h"
 #include "../h/dir.h"
 
 #include "../h/param.h"
 #include "../h/dir.h"
@@ -89,11 +89,8 @@ udp_input(m0)
            ui->ui_src, ui->ui_sport, ui->ui_dst, ui->ui_dport,
                INPLOOKUP_WILDCARD);
        if (inp == 0) {
            ui->ui_src, ui->ui_sport, ui->ui_dst, ui->ui_dport,
                INPLOOKUP_WILDCARD);
        if (inp == 0) {
-               struct in_addr broadcastaddr;
-
-               broadcastaddr =
-                   if_makeaddr(in_netof(ui->ui_dst), INADDR_ANY);
-               if (ui->ui_dst.s_addr == broadcastaddr.s_addr)
+               /* don't send ICMP response for broadcast packet */
+               if (in_lnaof(ui->ui_dst) == INADDR_ANY)
                        goto bad;
                icmp_error((struct ip *)ui, ICMP_UNREACH, ICMP_UNREACH_PORT);
                return;
                        goto bad;
                icmp_error((struct ip *)ui, ICMP_UNREACH, ICMP_UNREACH_PORT);
                return;
@@ -107,10 +104,8 @@ udp_input(m0)
        udp_in.sin_addr = ui->ui_src;
        m->m_len -= sizeof (struct udpiphdr);
        m->m_off += sizeof (struct udpiphdr);
        udp_in.sin_addr = ui->ui_src;
        m->m_len -= sizeof (struct udpiphdr);
        m->m_off += sizeof (struct udpiphdr);
-SBCHECK(&inp->inp_socket->so_rcv, "udpinput before");
        if (sbappendaddr(&inp->inp_socket->so_rcv, (struct sockaddr *)&udp_in, m) == 0)
                goto bad;
        if (sbappendaddr(&inp->inp_socket->so_rcv, (struct sockaddr *)&udp_in, m) == 0)
                goto bad;
-SBCHECK(&inp->inp_socket->so_rcv, "udpinput after");
        sorwakeup(inp->inp_socket);
        return;
 bad:
        sorwakeup(inp->inp_socket);
        return;
 bad:
@@ -247,7 +242,7 @@ udp_usrreq(so, req, m, nam, opt)
                break;
 
        case PRU_CONNECT:
                break;
 
        case PRU_CONNECT:
-               if (inp->inp_faddr.s_addr)
+               if (inp->inp_faddr.s_addr != INADDR_ANY)
                        return (EISCONN);
                error = in_pcbconnect(inp, nam);
                if (error == 0)
                        return (EISCONN);
                error = in_pcbconnect(inp, nam);
                if (error == 0)
@@ -258,7 +253,7 @@ udp_usrreq(so, req, m, nam, opt)
                return (EOPNOTSUPP);
 
        case PRU_DISCONNECT:
                return (EOPNOTSUPP);
 
        case PRU_DISCONNECT:
-               if (inp->inp_faddr.s_addr == 0)
+               if (inp->inp_faddr.s_addr == INADDR_ANY)
                        return (ENOTCONN);
                in_pcbdisconnect(inp);
                soisdisconnected(so);
                        return (ENOTCONN);
                in_pcbdisconnect(inp);
                soisdisconnected(so);
@@ -273,13 +268,13 @@ udp_usrreq(so, req, m, nam, opt)
 
                if (nam) {
                        laddr = inp->inp_laddr;
 
                if (nam) {
                        laddr = inp->inp_laddr;
-                       if (inp->inp_faddr.s_addr)
+                       if (inp->inp_faddr.s_addr != INADDR_ANY)
                                return (EISCONN);
                        error = in_pcbconnect(inp, nam);
                        if (error)
                                break;
                } else {
                                return (EISCONN);
                        error = in_pcbconnect(inp, nam);
                        if (error)
                                break;
                } else {
-                       if (inp->inp_faddr.s_addr == 0)
+                       if (inp->inp_faddr.s_addr == INADDR_ANY)
                                return (ENOTCONN);
                }
                error = udp_output(inp, m);
                                return (ENOTCONN);
                }
                error = udp_output(inp, m);