more cleanup
[unix-history] / usr / src / sys / netinet / ip_input.c
index bac28f3..9808dc1 100644 (file)
@@ -1,12 +1,11 @@
-/* ip_input.c 1.13 81/11/15 */
+/* ip_input.c 1.15 81/11/18 */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/clock.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/clock.h"
 #include "../h/mbuf.h"
-#include "../h/protocol.h"
 #include "../h/protosw.h"
 #include "../h/protosw.h"
-#include "../net/inet_cksum.h"
+#include "../h/socket.h"
 #include "../net/inet.h"
 #include "../net/inet_systm.h"
 #include "../net/imp.h"
 #include "../net/inet.h"
 #include "../net/inet_systm.h"
 #include "../net/imp.h"
@@ -24,7 +23,6 @@ ip_init()
 {
        register struct protosw *pr;
        register int i;
 {
        register struct protosw *pr;
        register int i;
-       int raw;
 
        pr = pffindproto(PF_INET, IPPROTO_RAW);
        if (pr == 0)
 
        pr = pffindproto(PF_INET, IPPROTO_RAW);
        if (pr == 0)
@@ -54,10 +52,9 @@ struct       ip *ip_reass();
 ip_input(m0)
        struct mbuf *m0;
 {
 ip_input(m0)
        struct mbuf *m0;
 {
-       register struct ip *ip;         /* known to be r11 in CKSUM below */
+       register struct ip *ip;
        register struct mbuf *m = m0;
        register int i;
        register struct mbuf *m = m0;
        register int i;
-       register struct ipq *q;
        register struct ipq *fp;
        int hlen;
 
        register struct ipq *fp;
        int hlen;
 
@@ -71,16 +68,16 @@ COUNT(IP_INPUT);
                m_freem(m);
                return;
        }
                m_freem(m);
                return;
        }
-       CKSUM_IPCHK(m, ip, r11, hlen);
+       ip->ip_sum = inet_cksum(m, hlen);
        if (ip->ip_sum) {
                printf("ip_sum %x\n", ip->ip_sum);
        if (ip->ip_sum) {
                printf("ip_sum %x\n", ip->ip_sum);
-               netstat.ip_badsum++;
+               ipstat.ips_badsum++;
                if (ipcksum) {
                        m_freem(m);
                        return;
                }
        }
                if (ipcksum) {
                        m_freem(m);
                        return;
                }
        }
-       ip->ip_len = ntohs(ip->ip_len);
+       ip->ip_len = ntohs((u_short)ip->ip_len);
        ip->ip_id = ntohs(ip->ip_id);
        ip->ip_off = ntohs(ip->ip_off);
 
        ip->ip_id = ntohs(ip->ip_id);
        ip->ip_off = ntohs(ip->ip_off);
 
@@ -108,10 +105,10 @@ COUNT(IP_INPUT);
         * ship it on.
         */
        if (hlen > sizeof (struct ip))
         * ship it on.
         */
        if (hlen > sizeof (struct ip))
-               ip_dooptions(ip, hlen);
+               ip_dooptions(ip);
        if (ip->ip_dst.s_addr != n_lhost.s_addr) {
                if (--ip->ip_ttl == 0) {
        if (ip->ip_dst.s_addr != n_lhost.s_addr) {
                if (--ip->ip_ttl == 0) {
-                       icmp_error(ip, ICMP_TIMXCEED);
+                       icmp_error(ip, ICMP_TIMXCEED, 0);
                        return;
                }
                ip_output(dtom(ip));
                        return;
                }
                ip_output(dtom(ip));
@@ -275,7 +272,7 @@ ip_reass(ip, fp)
        ((struct ip *)ip)->ip_src = fp->ipq_src;
        ((struct ip *)ip)->ip_dst = fp->ipq_dst;
        remque(fp);
        ((struct ip *)ip)->ip_src = fp->ipq_src;
        ((struct ip *)ip)->ip_dst = fp->ipq_dst;
        remque(fp);
-       m_free(dtom(fp));
+       (void) m_free(dtom(fp));
        m = dtom(ip);
        m->m_len += sizeof (struct ipasfrag);
        m->m_off -= sizeof (struct ipasfrag);
        m = dtom(ip);
        m->m_len += sizeof (struct ipasfrag);
        m->m_off -= sizeof (struct ipasfrag);
@@ -302,7 +299,7 @@ ip_freef(fp)
        m = dtom(fp);
        fp = fp->next;
        remque(fp->prev);
        m = dtom(fp);
        fp = fp->next;
        remque(fp->prev);
-       m_free(m);
+       (void) m_free(m);
        return (fp);
 }
 
        return (fp);
 }
 
@@ -356,6 +353,7 @@ ip_drain()
 {
 
 }
 {
 
 }
+
 /*
  * Do option processing on a datagram,
  * possibly discarding it if bad options
 /*
  * Do option processing on a datagram,
  * possibly discarding it if bad options
@@ -365,10 +363,9 @@ ip_dooptions(ip)
        struct ip *ip;
 {
        register u_char *cp;
        struct ip *ip;
 {
        register u_char *cp;
-       int opt, optlen, cnt, s;
-       struct ip_addr *sp;
+       int opt, optlen, cnt;
+       struct in_addr *sin;
        register struct ip_timestamp *ipt;
        register struct ip_timestamp *ipt;
-       int x;
 
        cp = (u_char *)(ip + 1);
        cnt = (ip->ip_hl << 2) - sizeof (struct ip);
 
        cp = (u_char *)(ip + 1);
        cnt = (ip->ip_hl << 2) - sizeof (struct ip);
@@ -389,13 +386,13 @@ ip_dooptions(ip)
                case IPOPT_SSRR:
                        if (cp[2] < 4 || cp[2] > optlen - (sizeof (long) - 1))
                                break;
                case IPOPT_SSRR:
                        if (cp[2] < 4 || cp[2] > optlen - (sizeof (long) - 1))
                                break;
-                       sp = (struct ip_addr *)(cp + cp[2]);
-                       if (n_lhost.s_addr == *(u_long *)sp) {
+                       sin = (struct in_addr *)(cp + cp[2]);
+                       if (n_lhost.s_addr == *(u_long *)sin) {
                                if (opt == IPOPT_SSRR) {
                                        /* MAKE SURE *SP DIRECTLY ACCESSIBLE */
                                }
                                if (opt == IPOPT_SSRR) {
                                        /* MAKE SURE *SP DIRECTLY ACCESSIBLE */
                                }
-                               ip->ip_dst = *sp;
-                               *sp = n_lhost;
+                               ip->ip_dst = *sin;
+                               *sin = n_lhost;
                                cp[2] += 4;
                        }
                        break;
                                cp[2] += 4;
                        }
                        break;
@@ -409,7 +406,7 @@ ip_dooptions(ip)
                                        goto bad;
                                break;
                        }
                                        goto bad;
                                break;
                        }
-                       sp = (struct ip_addr *)(cp+cp[2]);
+                       sin = (struct in_addr *)(cp+cp[2]);
                        switch (ipt->ipt_flg) {
 
                        case IPOPT_TS_TSONLY:
                        switch (ipt->ipt_flg) {
 
                        case IPOPT_TS_TSONLY:
@@ -418,11 +415,11 @@ ip_dooptions(ip)
                        case IPOPT_TS_TSANDADDR:
                                if (ipt->ipt_ptr + 8 > ipt->ipt_len)
                                        goto bad;
                        case IPOPT_TS_TSANDADDR:
                                if (ipt->ipt_ptr + 8 > ipt->ipt_len)
                                        goto bad;
-                               *(struct ip_addr *)sp++ = n_lhost;
+                               *(struct in_addr *)sin++ = n_lhost;
                                break;
 
                        case IPOPT_TS_PRESPEC:
                                break;
 
                        case IPOPT_TS_PRESPEC:
-                               if (*(u_long *)sp != n_lhost.s_addr)
+                               if (*(u_long *)sin != n_lhost.s_addr)
                                        break;
                                if (ipt->ipt_ptr + 8 > ipt->ipt_len)
                                        goto bad;
                                        break;
                                if (ipt->ipt_ptr + 8 > ipt->ipt_len)
                                        goto bad;
@@ -432,14 +429,14 @@ ip_dooptions(ip)
                        default:
                                goto bad;
                        }
                        default:
                                goto bad;
                        }
-                       *(n_time *)sp = ip_time();
+                       *(n_time *)sin = iptime();
                        ipt->ipt_ptr += 4;
                }
        }
                        ipt->ipt_ptr += 4;
                }
        }
-       return (0);
+       return;
 bad:
        /* SHOULD FORCE ICMP MESSAGE */
 bad:
        /* SHOULD FORCE ICMP MESSAGE */
-       return (-1);
+       return;
 }
 
 /*
 }
 
 /*
@@ -451,14 +448,12 @@ ip_stripoptions(ip)
 {
        register int i;
        register struct mbuf *m;
 {
        register int i;
        register struct mbuf *m;
-       char *op;
        int olen;
 COUNT(IP_OPT);
 
        olen = (ip->ip_hl<<2) - sizeof (struct ip);
        int olen;
 COUNT(IP_OPT);
 
        olen = (ip->ip_hl<<2) - sizeof (struct ip);
-       op = (caddr_t)ip + olen;
        m = dtom(++ip);
        i = m->m_len - (sizeof (struct ip) + olen);
        m = dtom(++ip);
        i = m->m_len - (sizeof (struct ip) + olen);
-       bcopy((caddr_t)ip+olen, (caddr_t)ip, i);
+       bcopy((caddr_t)ip+olen, (caddr_t)ip, (unsigned)i);
        m->m_len -= i;
 }
        m->m_len -= i;
 }