move include of kernel.h
[unix-history] / usr / src / sys / netinet / ip_input.c
index fc3efea..1f2cd30 100644 (file)
@@ -1,19 +1,23 @@
-/*     ip_input.c      1.46    82/07/24        */
+/*     ip_input.c      1.56    82/10/23        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
-#include "../h/clock.h"
 #include "../h/mbuf.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
 #include "../h/mbuf.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
-#include "../net/in.h"
-#include "../net/in_systm.h"
-#include "../net/if.h"
-#include "../net/ip.h"                 /* belongs before in.h */
-#include "../net/ip_var.h"
-#include "../net/ip_icmp.h"
-#include "../net/tcp.h"
 #include <errno.h>
 #include <errno.h>
+#include <time.h>
+#include "../h/kernel.h"
+
+#include "../net/if.h"
+#include "../net/route.h"
+#include "../netinet/in.h"
+#include "../netinet/in_pcb.h"
+#include "../netinet/in_systm.h"
+#include "../netinet/ip.h"
+#include "../netinet/ip_var.h"
+#include "../netinet/ip_icmp.h"
+#include "../netinet/tcp.h"
 
 u_char ip_protox[IPPROTO_MAX];
 int    ipqmaxlen = IFQ_MAXLEN;
 
 u_char ip_protox[IPPROTO_MAX];
 int    ipqmaxlen = IFQ_MAXLEN;
@@ -38,7 +42,7 @@ ip_init()
                    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
                        ip_protox[pr->pr_protocol] = pr - protosw;
        ipq.next = ipq.prev = &ipq;
                    pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
                        ip_protox[pr->pr_protocol] = pr - protosw;
        ipq.next = ipq.prev = &ipq;
-       ip_id = time & 0xffff;
+       ip_id = time.tv_sec & 0xffff;
        ipintrq.ifq_maxlen = ipqmaxlen;
        ifinet = if_ifwithaf(AF_INET);
 }
        ipintrq.ifq_maxlen = ipqmaxlen;
        ifinet = if_ifwithaf(AF_INET);
 }
@@ -56,7 +60,7 @@ ipintr()
 {
        register struct ip *ip;
        register struct mbuf *m;
 {
        register struct ip *ip;
        register struct mbuf *m;
-       struct mbuf *m0, *mopt;
+       struct mbuf *m0;
        register int i;
        register struct ipq *fp;
        int hlen, s;
        register int i;
        register struct ipq *fp;
        int hlen, s;
@@ -87,7 +91,7 @@ next:
                        goto bad;
                }
 
                        goto bad;
                }
 
-#if vax
+#if vax || pdp11 || ns16032
        /*
         * Convert fields to host representation.
         */
        /*
         * Convert fields to host representation.
         */
@@ -232,7 +236,6 @@ ip_reass(ip, fp)
        if (fp == 0) {
                if ((t = m_get(M_WAIT)) == NULL)
                        goto dropfrag;
        if (fp == 0) {
                if ((t = m_get(M_WAIT)) == NULL)
                        goto dropfrag;
-               t->m_off = MMINOFF;
                fp = mtod(t, struct ipq *);
                insque(fp, &ipq);
                fp->ipq_ttl = IPFRAGTTL;
                fp = mtod(t, struct ipq *);
                insque(fp, &ipq);
                fp->ipq_ttl = IPFRAGTTL;
@@ -563,7 +566,7 @@ ip_ctlinput(cmd, arg)
        int cmd;
        caddr_t arg;
 {
        int cmd;
        caddr_t arg;
 {
-       struct in_addr *sin;
+       struct in_addr *in;
        int tcp_abort(), udp_abort();
        extern struct inpcb tcb, udb;
 
        int tcp_abort(), udp_abort();
        extern struct inpcb tcb, udb;
 
@@ -572,13 +575,14 @@ ip_ctlinput(cmd, arg)
        if (inetctlerrmap[cmd] == 0)
                return;         /* XXX */
        if (cmd == PRC_IFDOWN)
        if (inetctlerrmap[cmd] == 0)
                return;         /* XXX */
        if (cmd == PRC_IFDOWN)
-               sin = &((struct sockaddr_in *)arg)->sin_addr;
+               in = &((struct sockaddr_in *)arg)->sin_addr;
        else if (cmd == PRC_HOSTDEAD || cmd == PRC_HOSTUNREACH)
        else if (cmd == PRC_HOSTDEAD || cmd == PRC_HOSTUNREACH)
-               sin = (struct in_addr *)arg;
+               in = (struct in_addr *)arg;
        else
        else
-               sin = &((struct icmp *)arg)->icmp_ip.ip_dst;
-       in_pcbnotify(&tcb, sin, inetctlerrmap[cmd], tcp_abort);
-       in_pcbnotify(&udb, sin, inetctlerrmap[cmd], udp_abort);
+               in = &((struct icmp *)arg)->icmp_ip.ip_dst;
+/* THIS IS VERY QUESTIONABLE, SHOULD HIT ALL PROTOCOLS */
+       in_pcbnotify(&tcb, in, (int)inetctlerrmap[cmd], tcp_abort);
+       in_pcbnotify(&udb, in, (int)inetctlerrmap[cmd], udp_abort);
 }
 
 int    ipprintfs = 0;
 }
 
 int    ipprintfs = 0;
@@ -618,11 +622,11 @@ ip_forward(ip)
         * Save at most 64 bytes of the packet in case
         * we need to generate an ICMP message to the src.
         */
         * Save at most 64 bytes of the packet in case
         * we need to generate an ICMP message to the src.
         */
-       mcopy = m_copy(dtom(ip), 0, min(ip->ip_len, 64));
+       mcopy = m_copy(dtom(ip), 0, imin(ip->ip_len, 64));
        ip_stripoptions(ip, mopt);
 
        /* last 0 here means no directed broadcast */
        ip_stripoptions(ip, mopt);
 
        /* last 0 here means no directed broadcast */
-       if ((error = ip_output(dtom(ip), mopt, 0, 0)) == 0) {
+       if ((error = ip_output(dtom(ip), mopt, (struct route *)0, 0)) == 0) {
                if (mcopy)
                        m_freem(mcopy);
                return;
                if (mcopy)
                        m_freem(mcopy);
                return;