Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet/raw_ip.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/raw_ip.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.14 retrieving revision 1.20 diff -u -p -r1.14 -r1.20 --- src/sys/netinet/raw_ip.c 1994/06/29 06:38:31 1.14 +++ src/sys/netinet/raw_ip.c 1995/06/12 00:47:49 1.20 @@ -1,4 +1,4 @@ -/* $NetBSD: raw_ip.c,v 1.14 1994/06/29 06:38:31 cgd Exp $ */ +/* $NetBSD: raw_ip.c,v 1.20 1995/06/12 00:47:49 mycroft Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1993 @@ -54,7 +54,7 @@ #include #include -struct inpcb rawinpcb; +struct inpcbtable rawcbtable; /* * Nominal space allocated to a raw ip socket. @@ -73,7 +73,7 @@ void rip_init() { - rawinpcb.inp_next = rawinpcb.inp_prev = &rawinpcb; + in_pcbinit(&rawcbtable); } struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET }; @@ -91,21 +91,22 @@ rip_input(m) struct socket *last = 0; ripsrc.sin_addr = ip->ip_src; - for (inp = rawinpcb.inp_next; inp != &rawinpcb; inp = inp->inp_next) { + for (inp = rawcbtable.inpt_list.lh_first; inp != 0; + inp = inp->inp_list.le_next) { if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != ip->ip_p) continue; if (inp->inp_laddr.s_addr && - inp->inp_laddr.s_addr == ip->ip_dst.s_addr) + inp->inp_laddr.s_addr != ip->ip_dst.s_addr) continue; if (inp->inp_faddr.s_addr && - inp->inp_faddr.s_addr == ip->ip_src.s_addr) + inp->inp_faddr.s_addr != ip->ip_src.s_addr) continue; if (last) { struct mbuf *n; if (n = m_copy(m, 0, (int)M_COPYALL)) { if (sbappendaddr(&last->so_rcv, - (struct sockaddr *)&ripsrc, - n, (struct mbuf *)0) == 0) + sintosa(&ripsrc), n, + (struct mbuf *)0) == 0) /* should notify about lost packet */ m_freem(n); else @@ -115,8 +116,8 @@ rip_input(m) last = inp->inp_socket; } if (last) { - if (sbappendaddr(&last->so_rcv, (struct sockaddr *)&ripsrc, - m, (struct mbuf *)0) == 0) + if (sbappendaddr(&last->so_rcv, sintosa(&ripsrc), m, + (struct mbuf *)0) == 0) m_freem(m); else sorwakeup(last); @@ -182,8 +183,11 @@ rip_ctloutput(op, so, level, optname, m) register struct inpcb *inp = sotoinpcb(so); register int error; - if (level != IPPROTO_IP) + if (level != IPPROTO_IP) { + if (m != 0 && *m != 0) + (void)m_free(*m); return (EINVAL); + } switch (optname) { @@ -205,25 +209,30 @@ rip_ctloutput(op, so, level, optname, m) } break; - case DVMRP_INIT: - case DVMRP_DONE: - case DVMRP_ADD_VIF: - case DVMRP_DEL_VIF: - case DVMRP_ADD_LGRP: - case DVMRP_DEL_LGRP: - case DVMRP_ADD_MRT: - case DVMRP_DEL_MRT: + case MRT_INIT: + case MRT_DONE: + case MRT_ADD_VIF: + case MRT_DEL_VIF: + case MRT_ADD_MFC: + case MRT_DEL_MFC: + case MRT_VERSION: + case MRT_ASSERT: #ifdef MROUTING - if (op == PRCO_SETOPT) { - error = ip_mrouter_cmd(optname, so, *m); - if (*m) - (void)m_free(*m); - } else + switch (op) { + case PRCO_SETOPT: + error = ip_mrouter_set(optname, so, m); + break; + case PRCO_GETOPT: + error = ip_mrouter_get(optname, so, m); + break; + default: error = EINVAL; + break; + } return (error); #else if (op == PRCO_SETOPT && *m) - (void)m_free(*m); + m_free(*m); return (EOPNOTSUPP); #endif } @@ -255,10 +264,10 @@ rip_usrreq(so, req, m, nam, control) break; } if ((error = soreserve(so, rip_sendspace, rip_recvspace)) || - (error = in_pcballoc(so, &rawinpcb))) + (error = in_pcballoc(so, &rawcbtable))) break; inp = (struct inpcb *)so->so_pcb; - inp->inp_ip.ip_p = (int)nam; + inp->inp_ip.ip_p = (long)nam; break; case PRU_DISCONNECT: @@ -288,11 +297,11 @@ rip_usrreq(so, req, m, nam, control) error = EINVAL; break; } - if ((ifnet == 0) || + if ((ifnet.tqh_first == 0) || ((addr->sin_family != AF_INET) && (addr->sin_family != AF_IMPLINK)) || (addr->sin_addr.s_addr && - ifa_ifwithaddr((struct sockaddr *)addr) == 0)) { + ifa_ifwithaddr(sintosa(addr)) == 0)) { error = EADDRNOTAVAIL; break; } @@ -307,7 +316,7 @@ rip_usrreq(so, req, m, nam, control) error = EINVAL; break; } - if (ifnet == 0) { + if (ifnet.tqh_first == 0) { error = EADDRNOTAVAIL; break; } @@ -338,7 +347,7 @@ rip_usrreq(so, req, m, nam, control) */ case PRU_SEND: { - register u_long dst; + register u_int32_t dst; if (so->so_state & SS_ISCONNECTED) { if (nam) {