diff options
author | wollman <wollman@FreeBSD.org> | 1998-08-23 03:07:17 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1998-08-23 03:07:17 +0000 |
commit | a76fb5eefabdc9418c911bf0b61768d533c15cbd (patch) | |
tree | 02b1e59b8833c25c113cc2a72ebb74ec057423bb /sys/netipx | |
parent | 3846bf0ec8c81eca47577791dff72e8b96928749 (diff) | |
download | FreeBSD-src-a76fb5eefabdc9418c911bf0b61768d533c15cbd.zip FreeBSD-src-a76fb5eefabdc9418c911bf0b61768d533c15cbd.tar.gz |
Yow! Completely change the way socket options are handled, eliminating
another specialized mbuf type in the process. Also clean up some
of the cruft surrounding IPFW, multicast routing, RSVP, and other
ill-explored corners.
Diffstat (limited to 'sys/netipx')
-rw-r--r-- | sys/netipx/ipx_ip.c | 26 | ||||
-rw-r--r-- | sys/netipx/ipx_ip.h | 4 | ||||
-rw-r--r-- | sys/netipx/ipx_usrreq.c | 91 | ||||
-rw-r--r-- | sys/netipx/ipx_var.h | 6 | ||||
-rw-r--r-- | sys/netipx/spx.h | 5 | ||||
-rw-r--r-- | sys/netipx/spx_usrreq.c | 110 |
6 files changed, 118 insertions, 124 deletions
diff --git a/sys/netipx/ipx_ip.c b/sys/netipx/ipx_ip.c index 57e8b77..5b8b8aa 100644 --- a/sys/netipx/ipx_ip.c +++ b/sys/netipx/ipx_ip.c @@ -33,7 +33,7 @@ * * @(#)ipx_ip.c * - * $Id: ipx_ip.c,v 1.20 1998/02/09 06:10:20 eivind Exp $ + * $Id: ipx_ip.c,v 1.21 1998/06/07 17:12:19 dfr Exp $ */ /* @@ -316,17 +316,23 @@ struct ifnet *ifp; static struct ifreq ifr_ipxip = {"ipxip0"}; int -ipxip_route(so, m, p) +ipxip_route(so, sopt) struct socket *so; - register struct mbuf *m; - struct proc *p; + struct sockopt *sopt; { - register struct ipxip_req *rq = mtod(m, struct ipxip_req *); - struct sockaddr_ipx *ipx_dst = (struct sockaddr_ipx *)&rq->rq_ipx; - struct sockaddr_in *ip_dst = (struct sockaddr_in *)&rq->rq_ip; - struct route ro; + int error; struct ifnet_en *ifn; struct sockaddr_in *src; + struct ipxip_req rq; + struct sockaddr_ipx *ipx_dst; + struct sockaddr_in *ip_dst; + struct route ro; + + error = sooptcopyin(sopt, &rq, sizeof rq, sizeof rq); + if (error) + return (error); + ipx_dst = (struct sockaddr_ipx *)&rq.rq_ipx; + ip_dst = (struct sockaddr_in *)&rq.rq_ip; /* * First, make sure we already have an IPX address: @@ -387,14 +393,14 @@ ipxip_route(so, m, p) ifr_ipxip.ifr_name[4] = '0' + ipxipif.if_unit - 1; ifr_ipxip.ifr_dstaddr = *(struct sockaddr *)ipx_dst; ipx_control(so, (int)SIOCSIFDSTADDR, (caddr_t)&ifr_ipxip, - (struct ifnet *)ifn, p); + (struct ifnet *)ifn, sopt->sopt_p); /* use any of our addresses */ satoipx_addr(ifr_ipxip.ifr_addr).x_host = ipx_ifaddr->ia_addr.sipx_addr.x_host; return (ipx_control(so, (int)SIOCSIFADDR, (caddr_t)&ifr_ipxip, - (struct ifnet *)ifn, p)); + (struct ifnet *)ifn, sopt->sopt_p)); } static int diff --git a/sys/netipx/ipx_ip.h b/sys/netipx/ipx_ip.h index 1d22e63..e8bd9cf 100644 --- a/sys/netipx/ipx_ip.h +++ b/sys/netipx/ipx_ip.h @@ -33,7 +33,7 @@ * * @(#)ipxip.h * - * $Id: ipx_ip.h,v 1.10 1997/05/10 09:58:53 jhay Exp $ + * $Id: ipx_ip.h,v 1.11 1997/06/26 19:35:50 jhay Exp $ */ #ifndef _NETIPX_IPXIP_H_ @@ -53,7 +53,7 @@ struct ifnet_en { void ipxip_ctlinput __P((int cmd, struct sockaddr *sa, void *arg)); void ipxip_input __P((struct mbuf *m, int hlen)); -int ipxip_route __P((struct socket *so, struct mbuf *m, struct proc *p)); +int ipxip_route __P((struct socket *so, struct sockopt *sopt)); #endif /* KERNEL */ diff --git a/sys/netipx/ipx_usrreq.c b/sys/netipx/ipx_usrreq.c index 3c15319..58fb5e2 100644 --- a/sys/netipx/ipx_usrreq.c +++ b/sys/netipx/ipx_usrreq.c @@ -33,7 +33,7 @@ * * @(#)ipx_usrreq.c * - * $Id: ipx_usrreq.c,v 1.18 1997/12/15 20:31:15 eivind Exp $ + * $Id: ipx_usrreq.c,v 1.19 1998/02/09 06:10:25 eivind Exp $ */ #include "opt_ipx.h" @@ -310,30 +310,23 @@ ipx_output(ipxp, m0) } int -ipx_ctloutput(req, so, level, name, value, p) - int req, level; +ipx_ctloutput(so, sopt) struct socket *so; - int name; - struct mbuf **value; - struct proc *p; + struct sockopt *sopt; { register struct mbuf *m; struct ipxpcb *ipxp = sotoipxpcb(so); - int mask, error = 0; + int mask, error, optval; + short soptval; + struct ipx ioptval; + error = 0; if (ipxp == NULL) return (EINVAL); - switch (req) { - - case PRCO_GETOPT: - if (value == NULL) - return (EINVAL); - m = m_get(M_DONTWAIT, MT_DATA); - if (m == NULL) - return (ENOBUFS); - switch (name) { - + switch (sopt->sopt_dir) { + case SOPT_GET: + switch (sopt->sopt_name) { case SO_ALL_PACKETS: mask = IPXP_ALL_PACKETS; goto get_flags; @@ -345,38 +338,33 @@ ipx_ctloutput(req, so, level, name, value, p) case SO_HEADERS_ON_OUTPUT: mask = IPXP_RAWOUT; get_flags: - m->m_len = sizeof(short); - *mtod(m, short *) = ipxp->ipxp_flags & mask; + soptval = ipxp->ipxp_flags & mask; + error = sooptcopyout(sopt, &soptval, sizeof soptval); break; case SO_DEFAULT_HEADERS: - m->m_len = sizeof(struct ipx); - { - register struct ipx *ipx = mtod(m, struct ipx *); - ipx->ipx_len = 0; - ipx->ipx_sum = 0; - ipx->ipx_tc = 0; - ipx->ipx_pt = ipxp->ipxp_dpt; - ipx->ipx_dna = ipxp->ipxp_faddr; - ipx->ipx_sna = ipxp->ipxp_laddr; - } + ioptval.ipx_len = 0; + ioptval.ipx_sum = 0; + ioptval.ipx_tc = 0; + ioptval.ipx_pt = ipxp->ipxp_dpt; + ioptval.ipx_dna = ipxp->ipxp_faddr; + ioptval.ipx_sna = ipxp->ipxp_laddr; + error = sooptcopyout(sopt, &soptval, sizeof soptval); break; case SO_SEQNO: - m->m_len = sizeof(long); - *mtod(m, long *) = ipx_pexseq++; + error = sooptcopyout(sopt, &ipx_pexseq, + sizeof ipx_pexseq); + ipx_pexseq++; break; default: error = EINVAL; } - *value = m; break; - case PRCO_SETOPT: - switch (name) { - int *ok; - + case SOPT_SET: + switch (sopt->sopt_name) { case SO_ALL_PACKETS: mask = IPXP_ALL_PACKETS; goto set_head; @@ -388,39 +376,38 @@ ipx_ctloutput(req, so, level, name, value, p) case SO_HEADERS_ON_OUTPUT: mask = IPXP_RAWOUT; set_head: - if (value && *value) { - ok = mtod(*value, int *); - if (*ok) - ipxp->ipxp_flags |= mask; - else - ipxp->ipxp_flags &= ~mask; - } else error = EINVAL; + error = sooptcopyin(sopt, &optval, sizeof optval, + sizeof optval); + if (error) + break; + if (optval) + ipxp->ipxp_flags |= mask; + else + ipxp->ipxp_flags &= ~mask; break; case SO_DEFAULT_HEADERS: - { - register struct ipx *ipx - = mtod(*value, struct ipx *); - ipxp->ipxp_dpt = ipx->ipx_pt; - } + error = sooptcopyin(sopt, &ioptval, sizeof ioptval, + sizeof ioptval); + if (error) + break; + ipxp->ipxp_dpt = ioptval.ipx_pt; break; #ifdef IPXIP case SO_IPXIP_ROUTE: - error = ipxip_route(so, *value, p); + error = ipxip_route(so, sopt); break; #endif /* IPXIP */ #ifdef IPTUNNEL #if 0 case SO_IPXTUNNEL_ROUTE: - error = ipxtun_route(so, *value, p); + error = ipxtun_route(so, sopt); break; #endif #endif default: error = EINVAL; } - if (value && *value) - m_freem(*value); break; } return (error); diff --git a/sys/netipx/ipx_var.h b/sys/netipx/ipx_var.h index bd05bc9..bda0533 100644 --- a/sys/netipx/ipx_var.h +++ b/sys/netipx/ipx_var.h @@ -33,7 +33,7 @@ * * @(#)ipx_var.h * - * $Id: ipx_var.h,v 1.9 1998/02/01 20:08:34 bde Exp $ + * $Id: ipx_var.h,v 1.10 1998/06/07 17:12:20 dfr Exp $ */ #ifndef _NETIPX_IPX_VAR_H_ @@ -79,14 +79,14 @@ struct proc; struct route; struct sockaddr; struct socket; +struct sockopt; void ipx_abort __P((struct ipxpcb *ipxp)); u_short ipx_cksum __P((struct mbuf *m, int len)); int ipx_control __P((struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, struct proc *p)); void ipx_ctlinput __P((int cmd, struct sockaddr *arg_as_sa, void *dummy)); -int ipx_ctloutput __P((int req, struct socket *so, int level, int name, - struct mbuf **value, struct proc *p)); +int ipx_ctloutput __P((struct socket *so, struct sockopt *sopt)); void ipx_drop __P((struct ipxpcb *ipxp, int errno)); void ipx_init __P((void)); void ipx_input __P((struct mbuf *m, struct ipxpcb *ipxp)); diff --git a/sys/netipx/spx.h b/sys/netipx/spx.h index 2620e25..20a4116 100644 --- a/sys/netipx/spx.h +++ b/sys/netipx/spx.h @@ -33,7 +33,7 @@ * * @(#)spx.h * - * $Id: spx.h,v 1.12 1997/05/10 09:58:56 jhay Exp $ + * $Id: spx.h,v 1.13 1997/06/26 19:36:00 jhay Exp $ */ #ifndef _NETIPX_SPX_H_ @@ -173,8 +173,7 @@ extern struct pr_usrreqs spx_usrreqs; extern struct pr_usrreqs spx_usrreq_sps; void spx_ctlinput __P((int cmd, struct sockaddr *arg_as_sa, void *dummy)); -int spx_ctloutput __P((int req, struct socket *so, int level, int name, - struct mbuf **value, struct proc *p)); +int spx_ctloutput __P((struct socket *so, struct sockopt *sopt)); void spx_fasttimo __P((void)); void spx_init __P((void)); void spx_input __P((struct mbuf *m, struct ipxpcb *ipxp)); diff --git a/sys/netipx/spx_usrreq.c b/sys/netipx/spx_usrreq.c index 5fc8227..e37a2f8 100644 --- a/sys/netipx/spx_usrreq.c +++ b/sys/netipx/spx_usrreq.c @@ -33,7 +33,7 @@ * * @(#)spx_usrreq.h * - * $Id: spx_usrreq.c,v 1.18 1998/02/09 06:10:26 eivind Exp $ + * $Id: spx_usrreq.c,v 1.19 1998/05/01 18:30:02 bde Exp $ */ #include <sys/param.h> @@ -1154,39 +1154,33 @@ spx_setpersist(cb) } int -spx_ctloutput(req, so, level, name, value, p) - int req; +spx_ctloutput(so, sopt) struct socket *so; - int level, name; - struct mbuf **value; - struct proc *p; + struct sockopt *sopt; { register struct mbuf *m; struct ipxpcb *ipxp = sotoipxpcb(so); register struct spxpcb *cb; - int mask, error = 0; + int mask, error; + short soptval; + u_short usoptval; + int optval; + + error = 0; - if (level != IPXPROTO_SPX) { + if (sopt->sopt_level != IPXPROTO_SPX) { /* This will have to be changed when we do more general stacking of protocols */ - return (ipx_ctloutput(req, so, level, name, value, p)); + return (ipx_ctloutput(so, sopt)); } - if (ipxp == NULL) { - error = EINVAL; - goto release; - } else + if (ipxp == NULL) + return (EINVAL); + else cb = ipxtospxpcb(ipxp); - switch (req) { - - case PRCO_GETOPT: - if (value == NULL) - return (EINVAL); - m = m_get(M_DONTWAIT, MT_DATA); - if (m == NULL) - return (ENOBUFS); - switch (name) { - + switch (sopt->sopt_dir) { + case SOPT_GET: + switch (sopt->sopt_name) { case SO_HEADERS_ON_INPUT: mask = SF_HI; goto get_flags; @@ -1194,39 +1188,34 @@ spx_ctloutput(req, so, level, name, value, p) case SO_HEADERS_ON_OUTPUT: mask = SF_HO; get_flags: - m->m_len = sizeof(short); - *mtod(m, short *) = cb->s_flags & mask; + soptval = cb->s_flags & mask; + error = sooptcopyout(sopt, &soptval, sizeof soptval); break; case SO_MTU: - m->m_len = sizeof(u_short); - *mtod(m, short *) = cb->s_mtu; + usoptval = cb->s_mtu; + error = sooptcopyout(sopt, &usoptval, sizeof usoptval); break; case SO_LAST_HEADER: - m->m_len = sizeof(struct spxhdr); - *mtod(m, struct spxhdr *) = cb->s_rhdr; + error = sooptcopyout(sopt, &cb->s_rhdr, + sizeof cb->s_rhdr); break; case SO_DEFAULT_HEADERS: - m->m_len = sizeof(struct spx); - *mtod(m, struct spxhdr *) = cb->s_shdr; + error = sooptcopyout(sopt, &cb->s_shdr, + sizeof cb->s_shdr); break; default: - error = EINVAL; + error = ENOPROTOOPT; } - *value = m; break; - case PRCO_SETOPT: - if (value == 0 || *value == 0) { - error = EINVAL; - break; - } - switch (name) { - int *ok; - + case SOPT_SET: + switch (sopt->sopt_name) { + /* XXX why are these shorts on get and ints on set? + that doesn't make any sense... */ case SO_HEADERS_ON_INPUT: mask = SF_HI; goto set_head; @@ -1234,9 +1223,13 @@ spx_ctloutput(req, so, level, name, value, p) case SO_HEADERS_ON_OUTPUT: mask = SF_HO; set_head: + error = sooptcopyin(sopt, &optval, sizeof optval, + sizeof optval); + if (error) + break; + if (cb->s_flags & SF_PI) { - ok = mtod(*value, int *); - if (*ok) + if (optval) cb->s_flags |= mask; else cb->s_flags &= ~mask; @@ -1244,13 +1237,20 @@ spx_ctloutput(req, so, level, name, value, p) break; case SO_MTU: - cb->s_mtu = *(mtod(*value, u_short *)); + error = sooptcopyin(sopt, &usoptval, sizeof usoptval, + sizeof usoptval); + if (error) + break; + cb->s_mtu = usoptval; break; #ifdef SF_NEWCALL case SO_NEWCALL: - ok = mtod(*value, int *); - if (*ok) { + error = sooptcopyin(sopt, &optval, sizeof optval, + sizeof optval); + if (error) + break; + if (optval) { cb->s_flags2 |= SF_NEWCALL; spx_newchecks[5]++; } else { @@ -1262,21 +1262,23 @@ spx_ctloutput(req, so, level, name, value, p) case SO_DEFAULT_HEADERS: { - register struct spxhdr *sp - = mtod(*value, struct spxhdr *); - cb->s_dt = sp->spx_dt; - cb->s_cc = sp->spx_cc & SPX_EM; + struct spxhdr sp; + + error = sooptcopyin(sopt, &sp, sizeof sp, + sizeof sp); + if (error) + break; + cb->s_dt = sp.spx_dt; + cb->s_cc = sp.spx_cc & SPX_EM; } break; default: - error = EINVAL; + error = ENOPROTOOPT; } - m_freem(*value); break; } - release: - return (error); + return (error); } static int |