[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.2 and 1.8

version 1.2, 1993/05/04 05:41:18 version 1.8, 1994/01/09 01:06:13
Line 30 
Line 30 
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.   * SUCH DAMAGE.
  *   *
  *      @(#)ip_input.c  7.19 (Berkeley) 5/25/91   *      from: @(#)ip_input.c    7.19 (Berkeley) 5/25/91
    *      $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 "../net/if.h"  #include <net/if.h>
 #include "../net/route.h"  #include <net/route.h>
   
 #include "in.h"  #include <netinet/in.h>
 #include "in_systm.h"  #include <netinet/in_systm.h>
 #include "ip.h"  #include <netinet/ip.h>
 #include "in_pcb.h"  #include <netinet/in_pcb.h>
 #include "in_var.h"  #include <netinet/in_var.h>
 #include "ip_var.h"  #include <netinet/ip_var.h>
 #include "ip_icmp.h"  #include <netinet/ip_icmp.h>
   #include <netinet/ip_mroute.h>
   
 #ifndef IPFORWARDING  #ifndef IPFORWARDING
 #ifdef GATEWAY  #ifdef GATEWAY
Line 97  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 134  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 266  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 (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 497  dropfrag:
Line 551  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 515  ip_freef(fp)
Line 570  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 528  ip_enq(p, prev)
Line 584  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 541  ip_deq(p)
Line 598  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 565  ip_slowtimo()
Line 623  ip_slowtimo()
 /*  /*
  * Drain off all datagram fragments.   * Drain off all datagram fragments.
  */   */
   void
 ip_drain()  ip_drain()
 {  {
   
Line 584  struct in_ifaddr *ip_rtaddr();
Line 643  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 757  ip_dooptions(m)
Line 817  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 793  ip_rtaddr(dst)
Line 856  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 828  ip_srcroute()
Line 892  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 887  ip_srcroute()
Line 951  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 929  u_char inetctlerrmap[PRC_NCMDS] = {
Line 994  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;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.8

CVSweb <webmaster@jp.NetBSD.org>