[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.42.6.3 and 1.57.4.1

version 1.42.6.3, 1999/11/30 13:35:34 version 1.57.4.1, 2001/11/12 21:19:26
Line 85 
Line 85 
 #include <netinet/ip.h>  #include <netinet/ip.h>
 #include <netinet/ip_var.h>  #include <netinet/ip_var.h>
 #include <netinet/ip_mroute.h>  #include <netinet/ip_mroute.h>
   #include <netinet/ip_icmp.h>
 #include <netinet/in_pcb.h>  #include <netinet/in_pcb.h>
 #include <netinet/in_var.h>  #include <netinet/in_var.h>
   
Line 137  rip_input(m, va_alist)
Line 138  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 161  rip_input(m, va_alist)
Line 162  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 174  rip_input(m, va_alist)
Line 173  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 191  rip_input(m, va_alist)
Line 198  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 203  rip_input(m, va_alist)
Line 219  rip_input(m, va_alist)
                 } else                  } else
                         sorwakeup(last->inp_socket);                          sorwakeup(last->inp_socket);
         } else {          } else {
                 m_freem(m);                  if (inetsw[ip_protox[ip->ip_p]].pr_input == rip_input) {
                 ipstat.ips_noproto++;                          icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PROTOCOL,
                 ipstat.ips_delivered--;                              0, 0);
                           ipstat.ips_noproto++;
                           ipstat.ips_delivered--;
                   } else
                           m_freem(m);
         }          }
         return;          return;
 }  }
Line 223  rip_output(m, va_alist)
Line 243  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 274  rip_output(m, va_alist)
Line 294  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 289  rip_ctloutput(op, so, level, optname, m)
Line 312  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 364  rip_bind(inp, nam)
Line 387  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 385  rip_connect(inp, nam)
Line 408  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 408  u_long rip_recvspace = RIPRCVQ;
Line 431  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 424  rip_usrreq(so, req, m, nam, control, p)
Line 447  rip_usrreq(so, req, m, nam, control, p)
                 return (in_control(so, (long)m, (caddr_t)nam,                  return (in_control(so, (long)m, (caddr_t)nam,
                     (struct ifnet *)control, p));                      (struct ifnet *)control, p));
   
           if (req == PRU_PURGEIF) {
                   in_pcbpurgeif0(&rawcbtable, (struct ifnet *)control);
                   in_purgeif((struct ifnet *)control);
                   in_pcbpurgeif(&rawcbtable, (struct ifnet *)control);
                   return (0);
           }
   
         s = splsoftnet();          s = splsoftnet();
         inp = sotoinpcb(so);          inp = sotoinpcb(so);
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
Line 456  rip_usrreq(so, req, m, nam, control, p)
Line 486  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.42.6.3  
changed lines
  Added in v.1.57.4.1

CVSweb <webmaster@jp.NetBSD.org>