diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_domain.c | 12 | ||||
-rw-r--r-- | sys/kern/uipc_sockbuf.c | 220 | ||||
-rw-r--r-- | sys/kern/uipc_socket2.c | 220 |
3 files changed, 448 insertions, 4 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index b64a44b..c989f94 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_domain.c 8.2 (Berkeley) 10/18/93 - * $Id: uipc_domain.c,v 1.11 1995/12/02 17:10:38 bde Exp $ + * $Id: uipc_domain.c,v 1.12 1995/12/16 02:13:50 bde Exp $ */ #include <sys/param.h> @@ -103,9 +103,17 @@ domaininit(dummy) for (dp = domains; dp; dp = dp->dom_next) { if (dp->dom_init) (*dp->dom_init)(); - for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) + for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++){ +#ifdef PRU_OLDSTYLE + /* See comments in uipc_socket2.c. */ + if (pr->pr_usrreqs == 0) + pr->pr_usrreqs = &pru_oldstyle; + else if(pr->pr_usrreq == 0) + pr->pr_usrreq = pr_newstyle_usrreq; +#endif if (pr->pr_init) (*pr->pr_init)(); + } } if (max_linkhdr < 16) /* XXX */ diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index b3bdc44..4a8227d 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.9 1996/03/11 15:37:32 davidg Exp $ + * $Id: uipc_socket2.c,v 1.10 1996/06/12 05:07:35 gpalmer Exp $ */ #include <sys/param.h> @@ -754,3 +754,221 @@ sbdroprecord(sb) } while (m); } } + +#ifdef PRU_OLDSTYLE +/* + * The following routines mediate between the old-style `pr_usrreq' + * protocol implementations and the new-style `struct pr_usrreqs' + * calling convention. + */ + +/* syntactic sugar */ +#define nomb (struct mbuf *)0 + +static int +old_abort(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_ABORT, nomb, nomb, nomb); +} + +static int +old_accept(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_ACCEPT, nomb, nam, nomb); +} + +static int +old_attach(struct socket *so, int proto) +{ + return so->so_proto->pr_usrreq(so, PRU_ATTACH, nomb, + (struct mbuf *)proto, /* XXX */ + nomb); +} + +static int +old_bind(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_BIND, nomb, nam, nomb); +} + +static int +old_connect(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_CONNECT, nomb, nam, nomb); +} + +static int +old_connect2(struct socket *so1, struct socket *so2) +{ + return so1->so_proto->pr_usrreq(so1, PRU_CONNECT2, nomb, + (struct mbuf *)so2, nomb); +} + +static int +old_control(struct socket *so, int cmd, caddr_t data) +{ + return so->so_proto->pr_usrreq(so, PRU_CONTROL, (struct mbuf *)cmd, + (struct mbuf *)data, nomb); +} + +static int +old_detach(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_DETACH, nomb, nomb, nomb); +} + +static int +old_disconnect(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_DISCONNECT, nomb, nomb, nomb); +} + +static int +old_listen(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_LISTEN, nomb, nomb, nomb); +} + +static int +old_peeraddr(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_PEERADDR, nomb, nam, nomb); +} + +static int +old_rcvd(struct socket *so, int flags) +{ + return so->so_proto->pr_usrreq(so, PRU_RCVD, nomb, + (struct mbuf *)flags, /* XXX */ + nomb); +} + +static int +old_rcvoob(struct socket *so, struct mbuf *m, int flags) +{ + return so->so_proto->pr_usrreq(so, PRU_RCVOOB, m, + (struct mbuf *)flags, /* XXX */ + nomb); +} + +static int +old_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr, + struct mbuf *control) +{ + int req; + + if (flags & PRUS_OOB) { + req = PRU_SENDOOB; + } else if(flags & PRUS_EOF) { + req = PRU_SEND_EOF; + } else { + req = PRU_SEND; + } + return so->so_proto->pr_usrreq(so, req, m, addr, control); +} + +static int +old_sense(struct socket *so, struct stat *sb) +{ + return so->so_proto->pr_usrreq(so, PRU_SENSE, (struct mbuf *)sb, + nomb, nomb); +} + +static int +old_shutdown(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_SHUTDOWN, nomb, nomb, nomb); +} + +static int +old_sockaddr(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_SOCKADDR, nomb, nam, nomb); +} + +struct pr_usrreqs pru_oldstyle = { + old_abort, old_accept, old_attach, old_bind, old_connect, + old_connect2, old_control, old_detach, old_disconnect, + old_listen, old_peeraddr, old_rcvd, old_rcvoob, old_send, + old_sense, old_shutdown, old_sockaddr +}; + +/* + * This function is glue going the other way. It is present to allow + * for this interface to be actively developed from both directions + * (i.e., work on the kernel and protocol stacks proceeds simultaneously). + * It is expected that this function will probably cease to exist much + * sooner than the pru_oldstyle interface, above, will, because once the + * all of the high-kernel use of pr_usrreq() is removed the function is + * no longer needed. + */ +int +pr_newstyle_usrreq(struct socket *so, int req, struct mbuf *m, + struct mbuf *nam, struct mbuf *control) +{ + struct pr_usrreqs *pru = so->so_proto->pr_usrreqs; + + switch(req) { + case PRU_ABORT: + return pru->pru_abort(so); + + case PRU_ACCEPT: + return pru->pru_accept(so, nam); + + case PRU_ATTACH: + return pru->pru_attach(so, (int)nam); + + case PRU_BIND: + return pru->pru_bind(so, nam); + + case PRU_CONNECT: + return pru->pru_connect(so, nam); + + case PRU_CONNECT2: + return pru->pru_connect2(so, (struct socket *)nam); + + case PRU_CONTROL: + return pru->pru_control(so, (int)m, (caddr_t)nam); + + case PRU_DETACH: + return pru->pru_detach(so); + + case PRU_DISCONNECT: + return pru->pru_disconnect(so); + + case PRU_LISTEN: + return pru->pru_listen(so); + + case PRU_PEERADDR: + return pru->pru_peeraddr(so, nam); + + case PRU_RCVD: + return pru->pru_rcvd(so, (int)nam); + + case PRU_RCVOOB: + return pru->pru_rcvoob(so, m, (int)nam); + + case PRU_SEND: + return pru->pru_send(so, 0, m, nam, control); + + case PRU_SENDOOB: + return pru->pru_send(so, PRUS_OOB, m, nam, control); + + case PRU_SEND_EOF: + return pru->pru_send(so, PRUS_EOF, m, nam, control); + + case PRU_SENSE: + return pru->pru_sense(so, (struct stat *)m); + + case PRU_SHUTDOWN: + return pru->pru_shutdown(so); + + case PRU_SOCKADDR: + return pru->pru_sockaddr(so, nam); + + } + + panic("pru_newstyle_usrreq: unhandled request %d", req); +} + +#endif /* PRU_OLDSTYLE */ diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index b3bdc44..4a8227d 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.9 1996/03/11 15:37:32 davidg Exp $ + * $Id: uipc_socket2.c,v 1.10 1996/06/12 05:07:35 gpalmer Exp $ */ #include <sys/param.h> @@ -754,3 +754,221 @@ sbdroprecord(sb) } while (m); } } + +#ifdef PRU_OLDSTYLE +/* + * The following routines mediate between the old-style `pr_usrreq' + * protocol implementations and the new-style `struct pr_usrreqs' + * calling convention. + */ + +/* syntactic sugar */ +#define nomb (struct mbuf *)0 + +static int +old_abort(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_ABORT, nomb, nomb, nomb); +} + +static int +old_accept(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_ACCEPT, nomb, nam, nomb); +} + +static int +old_attach(struct socket *so, int proto) +{ + return so->so_proto->pr_usrreq(so, PRU_ATTACH, nomb, + (struct mbuf *)proto, /* XXX */ + nomb); +} + +static int +old_bind(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_BIND, nomb, nam, nomb); +} + +static int +old_connect(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_CONNECT, nomb, nam, nomb); +} + +static int +old_connect2(struct socket *so1, struct socket *so2) +{ + return so1->so_proto->pr_usrreq(so1, PRU_CONNECT2, nomb, + (struct mbuf *)so2, nomb); +} + +static int +old_control(struct socket *so, int cmd, caddr_t data) +{ + return so->so_proto->pr_usrreq(so, PRU_CONTROL, (struct mbuf *)cmd, + (struct mbuf *)data, nomb); +} + +static int +old_detach(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_DETACH, nomb, nomb, nomb); +} + +static int +old_disconnect(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_DISCONNECT, nomb, nomb, nomb); +} + +static int +old_listen(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_LISTEN, nomb, nomb, nomb); +} + +static int +old_peeraddr(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_PEERADDR, nomb, nam, nomb); +} + +static int +old_rcvd(struct socket *so, int flags) +{ + return so->so_proto->pr_usrreq(so, PRU_RCVD, nomb, + (struct mbuf *)flags, /* XXX */ + nomb); +} + +static int +old_rcvoob(struct socket *so, struct mbuf *m, int flags) +{ + return so->so_proto->pr_usrreq(so, PRU_RCVOOB, m, + (struct mbuf *)flags, /* XXX */ + nomb); +} + +static int +old_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr, + struct mbuf *control) +{ + int req; + + if (flags & PRUS_OOB) { + req = PRU_SENDOOB; + } else if(flags & PRUS_EOF) { + req = PRU_SEND_EOF; + } else { + req = PRU_SEND; + } + return so->so_proto->pr_usrreq(so, req, m, addr, control); +} + +static int +old_sense(struct socket *so, struct stat *sb) +{ + return so->so_proto->pr_usrreq(so, PRU_SENSE, (struct mbuf *)sb, + nomb, nomb); +} + +static int +old_shutdown(struct socket *so) +{ + return so->so_proto->pr_usrreq(so, PRU_SHUTDOWN, nomb, nomb, nomb); +} + +static int +old_sockaddr(struct socket *so, struct mbuf *nam) +{ + return so->so_proto->pr_usrreq(so, PRU_SOCKADDR, nomb, nam, nomb); +} + +struct pr_usrreqs pru_oldstyle = { + old_abort, old_accept, old_attach, old_bind, old_connect, + old_connect2, old_control, old_detach, old_disconnect, + old_listen, old_peeraddr, old_rcvd, old_rcvoob, old_send, + old_sense, old_shutdown, old_sockaddr +}; + +/* + * This function is glue going the other way. It is present to allow + * for this interface to be actively developed from both directions + * (i.e., work on the kernel and protocol stacks proceeds simultaneously). + * It is expected that this function will probably cease to exist much + * sooner than the pru_oldstyle interface, above, will, because once the + * all of the high-kernel use of pr_usrreq() is removed the function is + * no longer needed. + */ +int +pr_newstyle_usrreq(struct socket *so, int req, struct mbuf *m, + struct mbuf *nam, struct mbuf *control) +{ + struct pr_usrreqs *pru = so->so_proto->pr_usrreqs; + + switch(req) { + case PRU_ABORT: + return pru->pru_abort(so); + + case PRU_ACCEPT: + return pru->pru_accept(so, nam); + + case PRU_ATTACH: + return pru->pru_attach(so, (int)nam); + + case PRU_BIND: + return pru->pru_bind(so, nam); + + case PRU_CONNECT: + return pru->pru_connect(so, nam); + + case PRU_CONNECT2: + return pru->pru_connect2(so, (struct socket *)nam); + + case PRU_CONTROL: + return pru->pru_control(so, (int)m, (caddr_t)nam); + + case PRU_DETACH: + return pru->pru_detach(so); + + case PRU_DISCONNECT: + return pru->pru_disconnect(so); + + case PRU_LISTEN: + return pru->pru_listen(so); + + case PRU_PEERADDR: + return pru->pru_peeraddr(so, nam); + + case PRU_RCVD: + return pru->pru_rcvd(so, (int)nam); + + case PRU_RCVOOB: + return pru->pru_rcvoob(so, m, (int)nam); + + case PRU_SEND: + return pru->pru_send(so, 0, m, nam, control); + + case PRU_SENDOOB: + return pru->pru_send(so, PRUS_OOB, m, nam, control); + + case PRU_SEND_EOF: + return pru->pru_send(so, PRUS_EOF, m, nam, control); + + case PRU_SENSE: + return pru->pru_sense(so, (struct stat *)m); + + case PRU_SHUTDOWN: + return pru->pru_shutdown(so); + + case PRU_SOCKADDR: + return pru->pru_sockaddr(so, nam); + + } + + panic("pru_newstyle_usrreq: unhandled request %d", req); +} + +#endif /* PRU_OLDSTYLE */ |