[BACK]Return to raw_ip.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/raw_ip.c between version 1.50 and 1.55.2.2

version 1.50, 2000/02/02 23:28:09 version 1.55.2.2, 2001/11/14 19:17:55
Line 64 
Line 64 
  *      @(#)raw_ip.c    8.7 (Berkeley) 5/15/95   *      @(#)raw_ip.c    8.7 (Berkeley) 5/15/95
  */   */
   
   #include <sys/cdefs.h>
   __KERNEL_RCSID(0, "$NetBSD$");
   
 #include "opt_ipsec.h"  #include "opt_ipsec.h"
 #include "opt_mrouting.h"  #include "opt_mrouting.h"
   
Line 95 
Line 98 
 #include <netinet6/ipsec.h>  #include <netinet6/ipsec.h>
 #endif /*IPSEC*/  #endif /*IPSEC*/
   
 extern u_char ip_protox[];  
 extern struct  protosw inetsw[];  
 struct inpcbtable rawcbtable;  struct inpcbtable rawcbtable;
   
 int      rip_bind __P((struct inpcb *, struct mbuf *));  int      rip_bind __P((struct inpcb *, struct mbuf *));
Line 140  rip_input(m, va_alist)
Line 141  rip_input(m, va_alist)
 #endif  #endif
 {  {
         int off, proto;          int off, proto;
         register struct ip *ip = mtod(m, struct ip *);          struct ip *ip = mtod(m, struct ip *);
         register struct inpcb *inp;          struct inpcb *inp;
         struct inpcb *last = 0;          struct inpcb *last = 0;
         struct mbuf *opts = 0;          struct mbuf *opts = 0;
         struct sockaddr_in ripsrc;          struct sockaddr_in ripsrc;
Line 164  rip_input(m, va_alist)
Line 165  rip_input(m, va_alist)
          */           */
         ip->ip_len -= ip->ip_hl << 2;          ip->ip_len -= ip->ip_hl << 2;
   
         for (inp = rawcbtable.inpt_queue.cqh_first;          CIRCLEQ_FOREACH(inp, &rawcbtable.inpt_queue, inp_queue) {
             inp != (struct inpcb *)&rawcbtable.inpt_queue;  
             inp = inp->inp_queue.cqe_next) {  
                 if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != proto)                  if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != proto)
                         continue;                          continue;
                 if (!in_nullhost(inp->inp_laddr) &&                  if (!in_nullhost(inp->inp_laddr) &&
Line 177  rip_input(m, va_alist)
Line 176  rip_input(m, va_alist)
                         continue;                          continue;
                 if (last) {                  if (last) {
                         struct mbuf *n;                          struct mbuf *n;
   
   #ifdef IPSEC
                           /* check AH/ESP integrity. */
                           if (ipsec4_in_reject_so(m, last->inp_socket)) {
                                   ipsecstat.in_polvio++;
                                   /* do not inject data to pcb */
                           } else
   #endif /*IPSEC*/
                         if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {                          if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
                                 if (last->inp_flags & INP_CONTROLOPTS ||                                  if (last->inp_flags & INP_CONTROLOPTS ||
                                     last->inp_socket->so_options & SO_TIMESTAMP)                                      last->inp_socket->so_options & SO_TIMESTAMP)
Line 194  rip_input(m, va_alist)
Line 201  rip_input(m, va_alist)
                 }                  }
                 last = inp;                  last = inp;
         }          }
   #ifdef IPSEC
           /* check AH/ESP integrity. */
           if (last && ipsec4_in_reject_so(m, last->inp_socket)) {
                   m_freem(m);
                   ipsecstat.in_polvio++;
                   ipstat.ips_delivered--;
                   /* do not inject data to pcb */
           } else
   #endif /*IPSEC*/
         if (last) {          if (last) {
                 if (last->inp_flags & INP_CONTROLOPTS ||                  if (last->inp_flags & INP_CONTROLOPTS ||
                     last->inp_socket->so_options & SO_TIMESTAMP)                      last->inp_socket->so_options & SO_TIMESTAMP)
Line 230  rip_output(m, va_alist)
Line 246  rip_output(m, va_alist)
         va_dcl          va_dcl
 #endif  #endif
 {  {
         register struct inpcb *inp;          struct inpcb *inp;
         register struct ip *ip;          struct ip *ip;
         struct mbuf *opts;          struct mbuf *opts;
         int flags;          int flags;
         va_list ap;          va_list ap;
Line 281  rip_output(m, va_alist)
Line 297  rip_output(m, va_alist)
                 ipstat.ips_rawout++;                  ipstat.ips_rawout++;
         }          }
 #ifdef IPSEC  #ifdef IPSEC
         m->m_pkthdr.rcvif = (struct ifnet *)inp->inp_socket;    /*XXX*/          if (ipsec_setsocket(m, inp->inp_socket) != 0) {
                   m_freem(m);
                   return ENOBUFS;
           }
 #endif /*IPSEC*/  #endif /*IPSEC*/
         return (ip_output(m, opts, &inp->inp_route, flags, inp->inp_moptions, &inp->inp_errormtu));          return (ip_output(m, opts, &inp->inp_route, flags, inp->inp_moptions, &inp->inp_errormtu));
 }  }
Line 296  rip_ctloutput(op, so, level, optname, m)
Line 315  rip_ctloutput(op, so, level, optname, m)
         int level, optname;          int level, optname;
         struct mbuf **m;          struct mbuf **m;
 {  {
         register struct inpcb *inp = sotoinpcb(so);          struct inpcb *inp = sotoinpcb(so);
         int error = 0;          int error = 0;
   
         if (level != IPPROTO_IP) {          if (level != IPPROTO_IP) {
Line 371  rip_bind(inp, nam)
Line 390  rip_bind(inp, nam)
   
         if (nam->m_len != sizeof(*addr))          if (nam->m_len != sizeof(*addr))
                 return (EINVAL);                  return (EINVAL);
         if (ifnet.tqh_first == 0)          if (TAILQ_FIRST(&ifnet) == 0)
                 return (EADDRNOTAVAIL);                  return (EADDRNOTAVAIL);
         if (addr->sin_family != AF_INET &&          if (addr->sin_family != AF_INET &&
             addr->sin_family != AF_IMPLINK)              addr->sin_family != AF_IMPLINK)
Line 392  rip_connect(inp, nam)
Line 411  rip_connect(inp, nam)
   
         if (nam->m_len != sizeof(*addr))          if (nam->m_len != sizeof(*addr))
                 return (EINVAL);                  return (EINVAL);
         if (ifnet.tqh_first == 0)          if (TAILQ_FIRST(&ifnet) == 0)
                 return (EADDRNOTAVAIL);                  return (EADDRNOTAVAIL);
         if (addr->sin_family != AF_INET &&          if (addr->sin_family != AF_INET &&
             addr->sin_family != AF_IMPLINK)              addr->sin_family != AF_IMPLINK)
Line 415  u_long rip_recvspace = RIPRCVQ;
Line 434  u_long rip_recvspace = RIPRCVQ;
 /*ARGSUSED*/  /*ARGSUSED*/
 int  int
 rip_usrreq(so, req, m, nam, control, p)  rip_usrreq(so, req, m, nam, control, p)
         register struct socket *so;          struct socket *so;
         int req;          int req;
         struct mbuf *m, *nam, *control;          struct mbuf *m, *nam, *control;
         struct proc *p;          struct proc *p;
 {  {
         register struct inpcb *inp;          struct inpcb *inp;
         int s;          int s;
         register int error = 0;          int error = 0;
 #ifdef MROUTING  #ifdef MROUTING
         extern struct socket *ip_mrouter;          extern struct socket *ip_mrouter;
 #endif  #endif
Line 432  rip_usrreq(so, req, m, nam, control, p)
Line 451  rip_usrreq(so, req, m, nam, control, p)
                     (struct ifnet *)control, p));                      (struct ifnet *)control, p));
   
         if (req == PRU_PURGEIF) {          if (req == PRU_PURGEIF) {
                   in_pcbpurgeif0(&rawcbtable, (struct ifnet *)control);
                 in_purgeif((struct ifnet *)control);                  in_purgeif((struct ifnet *)control);
                 in_pcbpurgeif(&rawcbtable, (struct ifnet *)control);                  in_pcbpurgeif(&rawcbtable, (struct ifnet *)control);
                 return (0);                  return (0);
Line 469  rip_usrreq(so, req, m, nam, control, p)
Line 489  rip_usrreq(so, req, m, nam, control, p)
                         break;                          break;
                 inp = sotoinpcb(so);                  inp = sotoinpcb(so);
                 inp->inp_ip.ip_p = (long)nam;                  inp->inp_ip.ip_p = (long)nam;
 #ifdef IPSEC  
                 error = ipsec_init_policy(so, &inp->inp_sp);  
                 if (error != 0) {  
                         in_pcbdetach(inp);  
                         break;  
                 }  
 #endif /*IPSEC*/  
                 break;                  break;
   
         case PRU_DETACH:          case PRU_DETACH:

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.55.2.2

CVSweb <webmaster@jp.NetBSD.org>