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.1.1.1 retrieving revision 1.12 diff -u -p -r1.1.1.1 -r1.12 --- src/sys/netinet/raw_ip.c 1993/03/21 09:45:37 1.1.1.1 +++ src/sys/netinet/raw_ip.c 1994/02/10 18:46:05 1.12 @@ -30,39 +30,42 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)raw_ip.c 7.8 (Berkeley) 7/25/90 + * from: @(#)raw_ip.c 7.8 (Berkeley) 7/25/90 + * $Id: raw_ip.c,v 1.12 1994/02/10 18:46:05 mycroft Exp $ */ -#include "param.h" -#include "malloc.h" -#include "mbuf.h" -#include "socket.h" -#include "protosw.h" -#include "socketvar.h" -#include "errno.h" - -#include "../net/if.h" -#include "../net/route.h" -#include "../net/raw_cb.h" - -#include "in.h" -#include "in_systm.h" -#include "ip.h" -#include "ip_var.h" -#include "in_pcb.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include /* * Raw interface to IP protocol. */ - struct sockaddr_in ripdst = { sizeof(ripdst), AF_INET }; struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET }; struct sockproto ripproto = { PF_INET }; + /* * Setup generic address and protocol structures * for raw_input routine, then pass them along with * mbuf chain. */ +void rip_input(m) struct mbuf *m; { @@ -83,6 +86,7 @@ rip_input(m) * Tack on options user may have setup with control call. */ #define satosin(sa) ((struct sockaddr_in *)(sa)) +int rip_output(m, so) register struct mbuf *m; struct socket *so; @@ -90,14 +94,19 @@ rip_output(m, so) register struct ip *ip; register struct raw_inpcb *rp = sotorawinpcb(so); register struct sockaddr_in *sin; + struct mbuf *opts; /* * If the user handed us a complete IP packet, use it. * Otherwise, allocate an mbuf for a header and fill it in. */ - if (rp->rinp_flags & RINPF_HDRINCL) + if (rp->rinp_flags & RINPF_HDRINCL) { ip = mtod(m, struct ip *); - else { + if (ip->ip_len > m->m_pkthdr.len) + return EMSGSIZE; + ip->ip_len = m->m_pkthdr.len; + opts = NULL; + } else { M_PREPEND(m, sizeof(struct ip), M_WAIT); ip = mtod(m, struct ip *); ip->ip_tos = 0; @@ -111,16 +120,17 @@ rip_output(m, so) if (sin = satosin(rp->rinp_rcb.rcb_faddr)) ip->ip_dst = sin->sin_addr; ip->ip_ttl = MAXTTL; + opts = rp->rinp_options; } - return (ip_output(m, - (rp->rinp_flags & RINPF_HDRINCL)? (struct mbuf *)0: rp->rinp_options, - &rp->rinp_route, - (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST)); + return (ip_output(m, opts, &rp->rinp_route, + (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST, + rp->rinp_rcb.rcb_moptions)); } /* * Raw IP socket option processing. */ +int rip_ctloutput(op, so, level, optname, m) int op; struct socket *so; @@ -150,9 +160,20 @@ rip_ctloutput(op, so, level, optname, m) else rp->rinp_flags &= ~RINPF_HDRINCL; break; - + case IP_MULTICAST_IF: + case IP_MULTICAST_TTL: + case IP_MULTICAST_LOOP: + case IP_ADD_MEMBERSHIP: + case IP_DROP_MEMBERSHIP: + error = ip_setmoptions(optname, + &rp->rinp_rcb.rcb_moptions, *m); + break; default: +#ifdef MROUTING + error = ip_mrouter_cmd(optname, so, *m); +#else error = EINVAL; +#endif break; } break; @@ -174,7 +195,14 @@ rip_ctloutput(op, so, level, optname, m) (*m)->m_len = sizeof (int); *mtod(*m, int *) = rp->rinp_flags & RINPF_HDRINCL; break; - + case IP_MULTICAST_IF: + case IP_MULTICAST_TTL: + case IP_MULTICAST_LOOP: + case IP_ADD_MEMBERSHIP: + case IP_DROP_MEMBERSHIP: + error = ip_getmoptions(optname, + rp->rinp_rcb.rcb_moptions, m); + break; default: error = EINVAL; m_freem(*m); @@ -189,14 +217,17 @@ rip_ctloutput(op, so, level, optname, m) } /*ARGSUSED*/ -rip_usrreq(so, req, m, nam, rights, control) +int +rip_usrreq(so, req, m, nam, control) register struct socket *so; int req; - struct mbuf *m, *nam, *rights, *control; + struct mbuf *m, *nam, *control; { register int error = 0; register struct raw_inpcb *rp = sotorawinpcb(so); - +#if defined(MROUTING) + extern struct socket *ip_mrouter; +#endif switch (req) { case PRU_ATTACH: @@ -212,8 +243,14 @@ rip_usrreq(so, req, m, nam, rights, cont case PRU_DETACH: if (rp == 0) panic("rip_detach"); +#if defined(MROUTING) + if (so == ip_mrouter) + ip_mrouter_done(); +#endif if (rp->rinp_options) m_freem(rp->rinp_options); + if (rp->rinp_rcb.rcb_moptions) + ip_freemoptions(rp->rinp_rcb.rcb_moptions); if (rp->rinp_route.ro_rt) RTFREE(rp->rinp_route.ro_rt); if (rp->rinp_rcb.rcb_laddr)