[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.41 and 1.46

version 1.41, 1996/10/25 06:30:32 version 1.46, 1997/02/19 08:30:04
Line 42 
Line 42 
 #include <sys/domain.h>  #include <sys/domain.h>
 #include <sys/protosw.h>  #include <sys/protosw.h>
 #include <sys/socket.h>  #include <sys/socket.h>
   #include <sys/socketvar.h>
 #include <sys/errno.h>  #include <sys/errno.h>
 #include <sys/time.h>  #include <sys/time.h>
 #include <sys/kernel.h>  #include <sys/kernel.h>
Line 51 
Line 52 
 #include <sys/sysctl.h>  #include <sys/sysctl.h>
   
 #include <net/if.h>  #include <net/if.h>
   #include <net/if_dl.h>
 #include <net/route.h>  #include <net/route.h>
   #include <net/pfil.h>
   
 #include <netinet/in.h>  #include <netinet/in.h>
 #include <netinet/in_systm.h>  #include <netinet/in_systm.h>
Line 61 
Line 64 
 #include <netinet/ip_var.h>  #include <netinet/ip_var.h>
 #include <netinet/ip_icmp.h>  #include <netinet/ip_icmp.h>
   
 #ifdef PFIL_HOOKS  /* XXX should really put this in libkern.h */
 #include <net/pfil.h>  #define offsetof(type, member)  ((size_t)(&((type *)0)->member))
 #endif /* PFIL_HOOKS */  
   
 #ifndef IPFORWARDING  #ifndef IPFORWARDING
 #ifdef GATEWAY  #ifdef GATEWAY
Line 167  ipintr()
Line 169  ipintr()
 #ifdef PFIL_HOOKS  #ifdef PFIL_HOOKS
         struct packet_filter_hook *pfh;          struct packet_filter_hook *pfh;
         struct mbuf *m0;          struct mbuf *m0;
           int rv;
 #endif /* PFIL_HOOKS */  #endif /* PFIL_HOOKS */
   
 next:  next:
Line 250  next:
Line 253  next:
         m0 = m;          m0 = m;
         for (pfh = pfil_hook_get(PFIL_IN); pfh; pfh = pfh->pfil_link.le_next)          for (pfh = pfil_hook_get(PFIL_IN); pfh; pfh = pfh->pfil_link.le_next)
                 if (pfh->pfil_func) {                  if (pfh->pfil_func) {
                         if (pfh->pfil_func(ip, hlen, m->m_pkthdr.rcvif, 0, &m0))                          rv = pfh->pfil_func(ip, hlen, m->m_pkthdr.rcvif, 0, &m0);
                           ip = mtod(m = m0, struct ip *);
                           if (rv)
                                 goto next;                                  goto next;
                         else  
                                 ip = mtod(m = m0, struct ip *);  
                 }                  }
 #endif /* PFIL_HOOKS */  #endif /* PFIL_HOOKS */
   
Line 438  found:
Line 441  found:
         (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen);          (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen);
         goto next;          goto next;
 bad:  bad:
 #ifdef PFIL_HOOKS  
         m0 = m;  
         for (pfh = pfil_hook_get(PFIL_BAD); pfh; pfh = pfh->pfil_link.le_next)  
                 if (pfh->pfil_func) {  
                         (void)pfh->pfil_func(ip, hlen, m->m_pkthdr.rcvif, 2, &m0);  
                         ip = mtod(m = m0, struct ip *);  
                 }  
 #endif /* PFIL_HOOKS */  
         m_freem(m);          m_freem(m);
         goto next;          goto next;
 }  }
Line 1167  ip_forward(m, srcrt)
Line 1162  ip_forward(m, srcrt)
         icmp_error(mcopy, type, code, dest, destifp);          icmp_error(mcopy, type, code, dest, destifp);
 }  }
   
   void
   ip_savecontrol(inp, mp, ip, m)
           register struct inpcb *inp;
           register struct mbuf **mp;
           register struct ip *ip;
           register struct mbuf *m;
   {
   
           if (inp->inp_socket->so_options & SO_TIMESTAMP) {
                   struct timeval tv;
   
                   microtime(&tv);
                   *mp = sbcreatecontrol((caddr_t) &tv, sizeof(tv),
                       SCM_TIMESTAMP, SOL_SOCKET);
                   if (*mp)
                           mp = &(*mp)->m_next;
           }
           if (inp->inp_flags & INP_RECVDSTADDR) {
                   *mp = sbcreatecontrol((caddr_t) &ip->ip_dst,
                       sizeof(struct in_addr), IP_RECVDSTADDR, IPPROTO_IP);
                   if (*mp)
                           mp = &(*mp)->m_next;
           }
   #ifdef notyet
           /*
            * XXX
            * Moving these out of udp_input() made them even more broken
            * than they already were.
            *      - fenner@parc.xerox.com
            */
           /* options were tossed already */
           if (inp->inp_flags & INP_RECVOPTS) {
                   *mp = sbcreatecontrol((caddr_t) opts_deleted_above,
                       sizeof(struct in_addr), IP_RECVOPTS, IPPROTO_IP);
                   if (*mp)
                           mp = &(*mp)->m_next;
           }
           /* ip_srcroute doesn't do what we want here, need to fix */
           if (inp->inp_flags & INP_RECVRETOPTS) {
                   *mp = sbcreatecontrol((caddr_t) ip_srcroute(),
                       sizeof(struct in_addr), IP_RECVRETOPTS, IPPROTO_IP);
                   if (*mp)
                           mp = &(*mp)->m_next;
           }
   #endif
           if (inp->inp_flags & INP_RECVIF) {
                   struct sockaddr_dl sdl;
   
                   sdl.sdl_len = offsetof(struct sockaddr_dl, sdl_data[0]);
                   sdl.sdl_family = AF_LINK;
                   sdl.sdl_index = m->m_pkthdr.rcvif ?
                       m->m_pkthdr.rcvif->if_index : 0;
                   sdl.sdl_nlen = sdl.sdl_alen = sdl.sdl_slen = 0;
                   *mp = sbcreatecontrol((caddr_t) &sdl, sdl.sdl_len,
                       IP_RECVIF, IPPROTO_IP);
                   if (*mp)
                           mp = &(*mp)->m_next;
           }
   }
   
 int  int
 ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen)  ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
         int *name;          int *name;
Line 1197  ip_sysctl(name, namelen, oldp, oldlenp, 
Line 1252  ip_sysctl(name, namelen, oldp, oldlenp, 
                  * Don't allow this to change in a secure environment.                   * Don't allow this to change in a secure environment.
                  */                   */
                 if (securelevel > 0)                  if (securelevel > 0)
                         return (EPERM);                          return (sysctl_rdint(oldp, oldlenp, newp,
                 return (sysctl_int(oldp, oldlenp, newp, newlen,                              ip_forwsrcrt));
                     &ip_forwsrcrt));                  else
                           return (sysctl_int(oldp, oldlenp, newp, newlen,
                               &ip_forwsrcrt));
         case IPCTL_DIRECTEDBCAST:          case IPCTL_DIRECTEDBCAST:
                 return (sysctl_int(oldp, oldlenp, newp, newlen,                  return (sysctl_int(oldp, oldlenp, newp, newlen,
                     &ip_directedbcast));                      &ip_directedbcast));

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.46

CVSweb <webmaster@jp.NetBSD.org>