version 1.5, 1993/05/22 11:42:37 |
version 1.9, 1994/01/09 01:06:21 |
|
|
* $Id$ |
* $Id$ |
*/ |
*/ |
|
|
#include "param.h" |
#include <sys/param.h> |
#include "malloc.h" |
#include <sys/malloc.h> |
#include "mbuf.h" |
#include <sys/mbuf.h> |
#include "socket.h" |
#include <sys/socket.h> |
#include "protosw.h" |
#include <sys/protosw.h> |
#include "socketvar.h" |
#include <sys/socketvar.h> |
#include "errno.h" |
#include <sys/errno.h> |
|
|
#include "../net/if.h" |
#include <net/if.h> |
#include "../net/route.h" |
#include <net/route.h> |
#include "../net/raw_cb.h" |
#include <net/raw_cb.h> |
|
|
#include "in.h" |
#include <netinet/in.h> |
#include "in_systm.h" |
#include <netinet/in_systm.h> |
#include "ip.h" |
#include <netinet/ip.h> |
#include "ip_var.h" |
#include <netinet/ip_var.h> |
#include "in_pcb.h" |
#include <netinet/in_pcb.h> |
|
#include <netinet/ip_mroute.h> |
|
|
/* |
/* |
* Raw interface to IP protocol. |
* Raw interface to IP protocol. |
*/ |
*/ |
|
|
struct sockaddr_in ripdst = { sizeof(ripdst), AF_INET }; |
struct sockaddr_in ripdst = { sizeof(ripdst), AF_INET }; |
struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET }; |
struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET }; |
struct sockproto ripproto = { PF_INET }; |
struct sockproto ripproto = { PF_INET }; |
|
|
/* |
/* |
* Setup generic address and protocol structures |
* Setup generic address and protocol structures |
* for raw_input routine, then pass them along with |
* for raw_input routine, then pass them along with |
* mbuf chain. |
* mbuf chain. |
*/ |
*/ |
|
void |
rip_input(m) |
rip_input(m) |
struct mbuf *m; |
struct mbuf *m; |
{ |
{ |
|
|
* Tack on options user may have setup with control call. |
* Tack on options user may have setup with control call. |
*/ |
*/ |
#define satosin(sa) ((struct sockaddr_in *)(sa)) |
#define satosin(sa) ((struct sockaddr_in *)(sa)) |
|
int |
rip_output(m, so) |
rip_output(m, so) |
register struct mbuf *m; |
register struct mbuf *m; |
struct socket *so; |
struct socket *so; |
Line 118 rip_output(m, so) |
|
Line 121 rip_output(m, so) |
|
} |
} |
return (ip_output(m, |
return (ip_output(m, |
(rp->rinp_flags & RINPF_HDRINCL)? (struct mbuf *)0: rp->rinp_options, |
(rp->rinp_flags & RINPF_HDRINCL)? (struct mbuf *)0: rp->rinp_options, |
&rp->rinp_route, |
&rp->rinp_route, |
(so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST)); |
(so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST |
|
#ifdef MULTICAST |
|
| IP_MULTICASTOPTS, rp->rinp_rcb.rcb_moptions |
|
#endif |
|
)); |
} |
} |
|
|
/* |
/* |
* Raw IP socket option processing. |
* Raw IP socket option processing. |
*/ |
*/ |
|
int |
rip_ctloutput(op, so, level, optname, m) |
rip_ctloutput(op, so, level, optname, m) |
int op; |
int op; |
struct socket *so; |
struct socket *so; |
Line 154 rip_ctloutput(op, so, level, optname, m) |
|
Line 162 rip_ctloutput(op, so, level, optname, m) |
|
else |
else |
rp->rinp_flags &= ~RINPF_HDRINCL; |
rp->rinp_flags &= ~RINPF_HDRINCL; |
break; |
break; |
|
#ifdef MULTICAST |
|
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; |
|
#else |
default: |
default: |
error = EINVAL; |
error = EINVAL; |
break; |
break; |
|
#endif |
} |
} |
break; |
break; |
|
|
Line 178 rip_ctloutput(op, so, level, optname, m) |
|
Line 203 rip_ctloutput(op, so, level, optname, m) |
|
(*m)->m_len = sizeof (int); |
(*m)->m_len = sizeof (int); |
*mtod(*m, int *) = rp->rinp_flags & RINPF_HDRINCL; |
*mtod(*m, int *) = rp->rinp_flags & RINPF_HDRINCL; |
break; |
break; |
|
#ifdef MULTICAST |
|
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; |
|
#endif |
default: |
default: |
error = EINVAL; |
error = EINVAL; |
m_freem(*m); |
m_freem(*m); |
Line 193 rip_ctloutput(op, so, level, optname, m) |
|
Line 227 rip_ctloutput(op, so, level, optname, m) |
|
} |
} |
|
|
/*ARGSUSED*/ |
/*ARGSUSED*/ |
|
int |
rip_usrreq(so, req, m, nam, control) |
rip_usrreq(so, req, m, nam, control) |
register struct socket *so; |
register struct socket *so; |
int req; |
int req; |
Line 200 rip_usrreq(so, req, m, nam, control) |
|
Line 235 rip_usrreq(so, req, m, nam, control) |
|
{ |
{ |
register int error = 0; |
register int error = 0; |
register struct raw_inpcb *rp = sotorawinpcb(so); |
register struct raw_inpcb *rp = sotorawinpcb(so); |
|
#if defined(MULTICAST) && defined(MROUTING) |
|
extern struct socket *ip_mrouter; |
|
#endif |
switch (req) { |
switch (req) { |
|
|
case PRU_ATTACH: |
case PRU_ATTACH: |
Line 216 rip_usrreq(so, req, m, nam, control) |
|
Line 253 rip_usrreq(so, req, m, nam, control) |
|
case PRU_DETACH: |
case PRU_DETACH: |
if (rp == 0) |
if (rp == 0) |
panic("rip_detach"); |
panic("rip_detach"); |
|
#if defined(MULTICAST) && defined(MROUTING) |
|
if (so == ip_mrouter) |
|
ip_mrouter_done(); |
|
#endif |
if (rp->rinp_options) |
if (rp->rinp_options) |
m_freem(rp->rinp_options); |
m_freem(rp->rinp_options); |
|
#ifdef MULTICAST |
|
if (rp->rinp_rcb.rcb_moptions) |
|
ip_freemoptions(rp->rinp_rcb.rcb_moptions); |
|
#endif |
if (rp->rinp_route.ro_rt) |
if (rp->rinp_route.ro_rt) |
RTFREE(rp->rinp_route.ro_rt); |
RTFREE(rp->rinp_route.ro_rt); |
if (rp->rinp_rcb.rcb_laddr) |
if (rp->rinp_rcb.rcb_laddr) |