diff options
author | peter <peter@FreeBSD.org> | 1997-05-24 17:23:11 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-05-24 17:23:11 +0000 |
commit | 16ff4223276d7d07622d8962c3924ef714ccff73 (patch) | |
tree | d21647876f340300d5615e2f3b02059f55d41046 | |
parent | 9b1a8266578a8978b99dae88495bc5205996d7aa (diff) | |
download | FreeBSD-src-16ff4223276d7d07622d8962c3924ef714ccff73.zip FreeBSD-src-16ff4223276d7d07622d8962c3924ef714ccff73.tar.gz |
Attempt to convert the ip_divert code to use the new-style protocol request
switch. I needed 'LINT' to compile for other reasons so I kinda got the
blood on my hands. Note: I don't know how to test this, I don't know if
it works correctly.
-rw-r--r-- | sys/kern/uipc_sockbuf.c | 8 | ||||
-rw-r--r-- | sys/kern/uipc_socket2.c | 8 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 188 | ||||
-rw-r--r-- | sys/sys/protosw.h | 4 |
4 files changed, 104 insertions, 104 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index f31cc98..4814a66 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 - * $Id: uipc_socket2.c,v 1.23 1997/03/31 12:29:59 davidg Exp $ + * $Id: uipc_socket2.c,v 1.24 1997/04/27 20:00:44 wollman Exp $ */ #include <sys/param.h> @@ -969,6 +969,12 @@ pru_accept_notsupp(struct socket *so, struct mbuf *nam) } int +pru_connect_notsupp(struct socket *so, struct mbuf *nam, struct proc *p) +{ + return EOPNOTSUPP; +} + +int pru_connect2_notsupp(struct socket *so1, struct socket *so2) { return EOPNOTSUPP; diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index f31cc98..4814a66 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 - * $Id: uipc_socket2.c,v 1.23 1997/03/31 12:29:59 davidg Exp $ + * $Id: uipc_socket2.c,v 1.24 1997/04/27 20:00:44 wollman Exp $ */ #include <sys/param.h> @@ -969,6 +969,12 @@ pru_accept_notsupp(struct socket *so, struct mbuf *nam) } int +pru_connect_notsupp(struct socket *so, struct mbuf *nam, struct proc *p) +{ + return EOPNOTSUPP; +} + +int pru_connect2_notsupp(struct socket *so1, struct socket *so2) { return EOPNOTSUPP; diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 335ed51..d64a4cb 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ip_divert.c,v 1.7 1997/03/03 09:23:34 davidg Exp $ + * $Id: ip_divert.c,v 1.8 1997/04/03 05:14:41 davidg Exp $ */ #include <sys/param.h> @@ -42,6 +42,7 @@ #include <sys/socketvar.h> #include <sys/errno.h> #include <sys/systm.h> +#include <sys/proc.h> #include <net/if.h> #include <net/route.h> @@ -252,113 +253,98 @@ cantsend: return error; } -/*ARGSUSED*/ -int -div_usrreq(so, req, m, nam, control) - register struct socket *so; - int req; - struct mbuf *m, *nam, *control; +static int +div_attach(struct socket *so, int proto, struct proc *p) { - register int error = 0; - register struct inpcb *inp = sotoinpcb(so); - int s = 0; + struct inpcb *inp; + int error; + + inp = sotoinpcb(so); + if (inp) + panic("div_attach"); + if (p && (error = suser(p->p_ucred, &p->p_acflag)) != 0) + return error; + + if ((error = soreserve(so, div_sendspace, div_recvspace)) || + (error = in_pcballoc(so, &divcbinfo, p))) + return error; + inp = (struct inpcb *)so->so_pcb; + inp->inp_ip_p = proto; + inp->inp_flags |= INP_HDRINCL; + /* The socket is always "connected" because + we always know "where" to send the packet */ + so->so_state |= SS_ISCONNECTED; + return 0; +} - if (inp == NULL && req != PRU_ATTACH) { - error = EINVAL; - goto release; - } - switch (req) { +static int +div_detach(struct socket *so) +{ + struct inpcb *inp; - case PRU_ATTACH: - if (inp) - panic("div_attach"); - if ((so->so_state & SS_PRIV) == 0) { - error = EACCES; - break; - } - if ((error = soreserve(so, div_sendspace, div_recvspace)) || - (error = in_pcballoc(so, &divcbinfo))) - break; - inp = (struct inpcb *)so->so_pcb; - inp->inp_ip_p = (int)nam; /* XXX */ - inp->inp_flags |= INP_HDRINCL; - /* The socket is always "connected" because - we always know "where" to send the packet */ - so->so_state |= SS_ISCONNECTED; - break; - - case PRU_DISCONNECT: - if ((so->so_state & SS_ISCONNECTED) == 0) { - error = ENOTCONN; - break; - } - /* FALLTHROUGH */ - case PRU_ABORT: - soisdisconnected(so); - /* FALLTHROUGH */ - case PRU_DETACH: - if (inp == 0) - panic("div_detach"); - in_pcbdetach(inp); - break; - - case PRU_BIND: - s = splnet(); - error = in_pcbbind(inp, nam); - splx(s); - break; + inp = sotoinpcb(so); + if (inp == 0) + panic("div_detach"); + in_pcbdetach(inp); + return 0; +} - /* - * Mark the connection as being incapable of further input. - */ - case PRU_SHUTDOWN: - socantsendmore(so); - break; - - case PRU_SEND: - /* Packet must have a header (but that's about it) */ - if (m->m_len < sizeof (struct ip) || - (m = m_pullup(m, sizeof (struct ip))) == 0) { - ipstat.ips_toosmall++; - error = EINVAL; - break; - } +static int +div_abort(struct socket *so) +{ + soisdisconnected(so); + return div_detach(so); +} - /* Send packet */ - error = div_output(so, m, nam, control); - m = NULL; - break; +static int +div_disconnect(struct socket *so) +{ + if ((so->so_state & SS_ISCONNECTED) == 0) + return ENOTCONN; + return div_abort(so); +} - case PRU_SOCKADDR: - in_setsockaddr(so, nam); - break; +static int +div_bind(struct socket *so, struct mbuf *nam, struct proc *p) +{ + struct inpcb *inp; + int s; + int error; + + s = splnet(); + error = in_pcbbind(inp, nam, p); + splx(s); + return 0; +} - case PRU_SENSE: - /* - * stat: don't bother with a blocksize. - */ - return (0); +static int +div_shutdown(struct socket *so) +{ + socantsendmore(so); + return 0; +} - /* - * Not supported. - */ - case PRU_CONNECT: - case PRU_CONNECT2: - case PRU_CONTROL: - case PRU_RCVOOB: - case PRU_RCVD: - case PRU_LISTEN: - case PRU_ACCEPT: - case PRU_SENDOOB: - case PRU_PEERADDR: - error = EOPNOTSUPP; - break; - - default: - panic("div_usrreq"); - } -release: - if (m) +static int +div_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam, + struct mbuf *control, struct proc *p) +{ + /* Packet must have a header (but that's about it) */ + if (m->m_len < sizeof (struct ip) || + (m = m_pullup(m, sizeof (struct ip))) == 0) { + ipstat.ips_toosmall++; m_freem(m); - return (error); + return EINVAL; + } + + /* Send packet */ + return div_output(so, m, nam, control); } + +struct pr_usrreqs div_usrreqs = { + div_abort, pru_accept_notsupp, div_attach, div_bind, + pru_connect_notsupp, pru_connect2_notsupp, in_control, div_detach, + div_disconnect, pru_listen_notsupp, in_setpeeraddr, pru_rcvd_notsupp, + pru_rcvoob_notsupp, div_send, pru_sense_null, div_shutdown, + in_setsockaddr, sosend, soreceive, soselect +}; + diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 39879e5..60330dd 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)protosw.h 8.1 (Berkeley) 6/2/93 - * $Id: protosw.h,v 1.16 1997/03/14 16:51:28 wollman Exp $ + * $Id: protosw.h,v 1.17 1997/04/27 20:01:27 wollman Exp $ */ #ifndef _SYS_PROTOSW_H_ @@ -221,6 +221,8 @@ struct pr_usrreqs { }; int pru_accept_notsupp __P((struct socket *so, struct mbuf *nam)); +int pru_connect_notsupp __P((struct socket *so, struct mbuf *nam, + struct proc *p)); int pru_connect2_notsupp __P((struct socket *so1, struct socket *so2)); int pru_control_notsupp __P((struct socket *so, int cmd, caddr_t data, struct ifnet *ifp, struct proc *p)); |