[BACK]Return to ip_input.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / netinet

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/netinet/ip_input.c between version 1.3.4.2 and 1.10

version 1.3.4.2, 1993/11/14 17:54:46 version 1.10, 1994/01/29 11:58:01
Line 34 
Line 34 
  *      $Id$   *      $Id$
  */   */
   
 #include "param.h"  #include <sys/param.h>
 #include "systm.h"  #include <sys/systm.h>
 #include "malloc.h"  #include <sys/malloc.h>
 #include "mbuf.h"  #include <sys/mbuf.h>
 #include "domain.h"  #include <sys/domain.h>
 #include "protosw.h"  #include <sys/protosw.h>
 #include "socket.h"  #include <sys/socket.h>
 #include "errno.h"  #include <sys/errno.h>
 #include "time.h"  #include <sys/time.h>
 #include "kernel.h"  #include <sys/kernel.h>
   
 #include "machine/cpu.h"  #include <net/if.h>
   #include <net/route.h>
 #include "../net/if.h"  
 #include "../net/route.h"  #include <netinet/in.h>
   #include <netinet/in_systm.h>
 #include "in.h"  #include <netinet/ip.h>
 #include "in_systm.h"  #include <netinet/in_pcb.h>
 #include "ip.h"  #include <netinet/in_var.h>
 #include "in_pcb.h"  #include <netinet/ip_var.h>
 #include "in_var.h"  #include <netinet/ip_icmp.h>
 #include "ip_var.h"  #include <netinet/ip_mroute.h>
 #include "ip_icmp.h"  
   
 #ifndef IPFORWARDING  #ifndef IPFORWARDING
 #ifdef GATEWAY  #ifdef GATEWAY
Line 100  extern int if_index;
Line 99  extern int if_index;
 u_long  *ip_ifmatrix;  u_long  *ip_ifmatrix;
 #endif  #endif
   
   static void     ip_forward __P((struct mbuf *, int));
   static void     save_rte __P((u_char *, struct in_addr));
   
 /*  /*
  * IP initialization: fill in IP protocol switch table.   * IP initialization: fill in IP protocol switch table.
  * All protocols not implemented in kernel go to raw IP protocol handler.   * All protocols not implemented in kernel go to raw IP protocol handler.
  */   */
   void
 ip_init()  ip_init()
 {  {
         register struct protosw *pr;          register struct protosw *pr;
Line 137  struct route ipforward_rt;
Line 140  struct route ipforward_rt;
  * Ip input routine.  Checksum and byte swap header.  If fragmented   * Ip input routine.  Checksum and byte swap header.  If fragmented
  * try to reassemble.  Process options.  Pass to next level.   * try to reassemble.  Process options.  Pass to next level.
  */   */
   void
 ipintr()  ipintr()
 {  {
         register struct ip *ip;          register struct ip *ip;
Line 144  ipintr()
Line 148  ipintr()
         register struct ipq *fp;          register struct ipq *fp;
         register struct in_ifaddr *ia;          register struct in_ifaddr *ia;
         int hlen, s;          int hlen, s;
 #ifdef DIAGNOSTIC  #ifdef PARANOID
         static int busy = 0;          static int busy = 0;
   
         if (busy)          if (busy)
Line 160  next:
Line 164  next:
         IF_DEQUEUE(&ipintrq, m);          IF_DEQUEUE(&ipintrq, m);
         splx(s);          splx(s);
         if (m == 0) {          if (m == 0) {
 #ifdef DIAGNOSTIC  #ifdef PARANOID
                 --busy;                  --busy;
 #endif  #endif
                 return;                  return;
Line 269  next:
Line 273  next:
                                 goto ours;                                  goto ours;
                 }                  }
         }          }
   #ifdef MULTICAST
           if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) {
                   struct in_multi *inm;
   #ifdef MROUTING
                   extern struct socket *ip_mrouter;
   
                   if (m->m_flags & M_EXT) {
                           if ((m = m_pullup(m, hlen)) == 0) {
                                   ipstat.ips_toosmall++;
                                   goto next;
                           }
                           ip = mtod(m, struct ip *);
                   }
   
                   if (ip_mrouter) {
                           /*
                            * If we are acting as a multicast router, all
                            * incoming multicast packets are passed to the
                            * kernel-level multicast forwarding function.
                            * The packet is returned (relatively) intact; if
                            * ip_mforward() returns a non-zero value, the packet
                            * must be discarded, else it may be accepted below.
                            *
                            * (The IP ident field is put in the same byte order
                            * as expected when ip_mforward() is called from
                            * ip_output().)
                            */
                           ip->ip_id = htons(ip->ip_id);
                           if (ip_mforward(ip, m->m_pkthdr.rcvif, m) != 0) {
                                   m_freem(m);
                                   goto next;
                           }
                           ip->ip_id = ntohs(ip->ip_id);
   
                           /*
                            * The process-level routing demon needs to receive
                            * all multicast IGMP packets, whether or not this
                            * host belongs to their destination groups.
                            */
                           if (ip->ip_p == IPPROTO_IGMP)
                                   goto ours;
                   }
   #endif
                   /*
                    * See if we belong to the destination multicast group on the
                    * arrival interface.
                    */
                   IN_LOOKUP_MULTI(ip->ip_dst, m->m_pkthdr.rcvif, inm);
                   if (inm == NULL) {
                           m_freem(m);
                           goto next;
                   }
                   goto ours;
           }
   #endif
         if (ip->ip_dst.s_addr == (u_long)INADDR_BROADCAST)          if (ip->ip_dst.s_addr == (u_long)INADDR_BROADCAST)
                 goto ours;                  goto ours;
         if (ip->ip_dst.s_addr == INADDR_ANY)          if (ip->ip_dst.s_addr == INADDR_ANY)
Line 500  dropfrag:
Line 559  dropfrag:
  * Free a fragment reassembly header and all   * Free a fragment reassembly header and all
  * associated datagrams.   * associated datagrams.
  */   */
   void
 ip_freef(fp)  ip_freef(fp)
         struct ipq *fp;          struct ipq *fp;
 {  {
Line 518  ip_freef(fp)
Line 578  ip_freef(fp)
  * Put an ip fragment on a reassembly chain.   * Put an ip fragment on a reassembly chain.
  * Like insque, but pointers in middle of structure.   * Like insque, but pointers in middle of structure.
  */   */
   void
 ip_enq(p, prev)  ip_enq(p, prev)
         register struct ipasfrag *p, *prev;          register struct ipasfrag *p, *prev;
 {  {
Line 531  ip_enq(p, prev)
Line 592  ip_enq(p, prev)
 /*  /*
  * To ip_enq as remque is to insque.   * To ip_enq as remque is to insque.
  */   */
   void
 ip_deq(p)  ip_deq(p)
         register struct ipasfrag *p;          register struct ipasfrag *p;
 {  {
Line 544  ip_deq(p)
Line 606  ip_deq(p)
  * if a timer expires on a reassembly   * if a timer expires on a reassembly
  * queue, discard it.   * queue, discard it.
  */   */
   void
 ip_slowtimo()  ip_slowtimo()
 {  {
         register struct ipq *fp;          register struct ipq *fp;
Line 568  ip_slowtimo()
Line 631  ip_slowtimo()
 /*  /*
  * Drain off all datagram fragments.   * Drain off all datagram fragments.
  */   */
   void
 ip_drain()  ip_drain()
 {  {
   
Line 587  struct in_ifaddr *ip_rtaddr();
Line 651  struct in_ifaddr *ip_rtaddr();
  * Returns 1 if packet has been forwarded/freed,   * Returns 1 if packet has been forwarded/freed,
  * 0 if the packet should be processed further.   * 0 if the packet should be processed further.
  */   */
   int
 ip_dooptions(m)  ip_dooptions(m)
         struct mbuf *m;          struct mbuf *m;
 {  {
Line 760  ip_dooptions(m)
Line 825  ip_dooptions(m)
         } else          } else
                 return (0);                  return (0);
 bad:  bad:
         icmp_error(m, type, code);      {
           register struct in_addr foo = {};
           icmp_error(m, type, code, foo);
       }
         return (1);          return (1);
 }  }
   
Line 796  ip_rtaddr(dst)
Line 864  ip_rtaddr(dst)
  * Save incoming source route for use in replies,   * Save incoming source route for use in replies,
  * to be picked up later by ip_srcroute if the receiver is interested.   * to be picked up later by ip_srcroute if the receiver is interested.
  */   */
   static void
 save_rte(option, dst)  save_rte(option, dst)
         u_char *option;          u_char *option;
         struct in_addr dst;          struct in_addr dst;
Line 831  ip_srcroute()
Line 900  ip_srcroute()
         if (m == 0)          if (m == 0)
                 return ((struct mbuf *)0);                  return ((struct mbuf *)0);
   
 #define OPTSIZ  (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt))  #define OPTSIZ  (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt))
   
         /* length is (nhops+1)*sizeof(addr) + sizeof(nop + srcrt header) */          /* length is (nhops+1)*sizeof(addr) + sizeof(nop + srcrt header) */
         m->m_len = ip_nhops * sizeof(struct in_addr) + sizeof(struct in_addr) +          m->m_len = ip_nhops * sizeof(struct in_addr) + sizeof(struct in_addr) +
Line 890  ip_srcroute()
Line 959  ip_srcroute()
  * will be moved, and return value is their length.   * will be moved, and return value is their length.
  * XXX should be deleted; last arg currently ignored.   * XXX should be deleted; last arg currently ignored.
  */   */
   void
 ip_stripoptions(m, mopt)  ip_stripoptions(m, mopt)
         register struct mbuf *m;          register struct mbuf *m;
         struct mbuf *mopt;          struct mbuf *mopt;
Line 932  u_char inetctlerrmap[PRC_NCMDS] = {
Line 1002  u_char inetctlerrmap[PRC_NCMDS] = {
  * The srcrt parameter indicates whether the packet is being forwarded   * The srcrt parameter indicates whether the packet is being forwarded
  * via a source route.   * via a source route.
  */   */
   static void
 ip_forward(m, srcrt)  ip_forward(m, srcrt)
         struct mbuf *m;          struct mbuf *m;
         int srcrt;          int srcrt;
Line 1036  ip_forward(m, srcrt)
Line 1107  ip_forward(m, srcrt)
                 }                  }
         }          }
   
         error = ip_output(m, (struct mbuf *)0, &ipforward_rt, IP_FORWARDING);          error = ip_output(m, NULL, &ipforward_rt, IP_FORWARDING
   #ifdef DIRECTED_BROADCAST
               | IP_ALLOWBROADCAST
   #endif
               , NULL);
         if (error)          if (error)
                 ipstat.ips_cantforward++;                  ipstat.ips_cantforward++;
         else {          else {

Legend:
Removed from v.1.3.4.2  
changed lines
  Added in v.1.10

CVSweb <webmaster@jp.NetBSD.org>