The long-awaited mega-massive-network-code- cleanup. Part I.
This commit includes the following changes: 1) Old-style (pr_usrreq()) protocols are no longer supported, the compatibility glue for them is deleted, and the kernel will panic on boot if any are compiled in. 2) Certain protocol entry points are modified to take a process structure, so they they can easily tell whether or not it is possible to sleep, and also to access credentials. 3) SS_PRIV is no more, and with it goes the SO_PRIVSTATE setsockopt() call. Protocols should use the process pointer they are now passed. 4) The PF_LOCAL and PF_ROUTE families have been updated to use the new style, as has the `raw' skeleton family. 5) PF_LOCAL sockets now obey the process's umask when creating a socket in the filesystem. As a result, LINT is now broken. I'm hoping that some enterprising hacker with a bit more time will either make the broken bits work (should be easy for netipx) or dike them out.
This commit is contained in:
parent
ee7877dfec
commit
a29f300e80
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25201
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: sys_socket.c,v 1.11 1997/03/23 03:36:25 bde Exp $
|
||||
* $Id: sys_socket.c,v 1.12 1997/03/24 11:52:26 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -68,9 +68,8 @@ soo_read(fp, uio, cred)
|
||||
struct uio *uio;
|
||||
struct ucred *cred;
|
||||
{
|
||||
|
||||
return (soreceive((struct socket *)fp->f_data, (struct mbuf **)0,
|
||||
uio, (struct mbuf **)0, (struct mbuf **)0, (int *)0));
|
||||
struct socket *so = (struct socket *)fp->f_data;
|
||||
return so->so_proto->pr_usrreqs->pru_soreceive(so, 0, uio, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
@ -80,9 +79,8 @@ soo_write(fp, uio, cred)
|
||||
struct uio *uio;
|
||||
struct ucred *cred;
|
||||
{
|
||||
|
||||
return (sosend((struct socket *)fp->f_data, (struct mbuf *)0,
|
||||
uio, (struct mbuf *)0, (struct mbuf *)0, 0));
|
||||
struct socket *so = (struct socket *)fp->f_data;
|
||||
return so->so_proto->pr_usrreqs->pru_sosend(so, 0, uio, 0, 0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
@ -140,7 +138,7 @@ soo_ioctl(fp, cmd, data, p)
|
||||
return (ifioctl(so, cmd, data, p));
|
||||
if (IOCGROUP(cmd) == 'r')
|
||||
return (rtioctl(cmd, data, p));
|
||||
return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, 0));
|
||||
return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, 0, p));
|
||||
}
|
||||
|
||||
int
|
||||
@ -149,40 +147,8 @@ soo_select(fp, which, p)
|
||||
int which;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct socket *so = (struct socket *)fp->f_data;
|
||||
register int s = splnet();
|
||||
|
||||
switch (which) {
|
||||
|
||||
case FREAD:
|
||||
if (soreadable(so)) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
selrecord(p, &so->so_rcv.sb_sel);
|
||||
so->so_rcv.sb_flags |= SB_SEL;
|
||||
break;
|
||||
|
||||
case FWRITE:
|
||||
if (sowriteable(so)) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
selrecord(p, &so->so_snd.sb_sel);
|
||||
so->so_snd.sb_flags |= SB_SEL;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
if (so->so_oobmark || (so->so_state & SS_RCVATMARK)) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
selrecord(p, &so->so_rcv.sb_sel);
|
||||
so->so_rcv.sb_flags |= SB_SEL;
|
||||
break;
|
||||
}
|
||||
splx(s);
|
||||
return (0);
|
||||
struct socket *so = (struct socket *)fp->f_data;
|
||||
return so->so_proto->pr_usrreqs->pru_soselect(so, which, p);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_domain.c 8.2 (Berkeley) 10/18/93
|
||||
* $Id$
|
||||
* $Id: uipc_domain.c,v 1.16 1997/02/22 09:39:27 peter Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -108,6 +108,11 @@ domaininit(dummy)
|
||||
/* See comments in uipc_socket2.c. */
|
||||
if (pr->pr_usrreqs == 0 && pr->pr_ousrreq)
|
||||
pr->pr_usrreqs = &pru_oldstyle;
|
||||
#else
|
||||
if (pr->pr_usrreqs == 0)
|
||||
panic("domaininit: %ssw[%d] has no usrreqs!",
|
||||
dp->dom_name,
|
||||
(int)(pr - dp->dom_protosw));
|
||||
#endif
|
||||
if (pr->pr_init)
|
||||
(*pr->pr_init)();
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_proto.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: uipc_proto.c,v 1.10 1997/02/24 20:30:55 wollman Exp $
|
||||
* $Id: uipc_proto.c,v 1.11 1997/04/14 18:23:48 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -53,18 +53,21 @@
|
||||
static struct protosw localsw[] = {
|
||||
{ SOCK_STREAM, &localdomain, 0, PR_CONNREQUIRED|PR_WANTRCVD|PR_RIGHTS,
|
||||
0, 0, 0, 0,
|
||||
uipc_usrreq,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
&uipc_usrreqs
|
||||
},
|
||||
{ SOCK_DGRAM, &localdomain, 0, PR_ATOMIC|PR_ADDR|PR_RIGHTS,
|
||||
0, 0, 0, 0,
|
||||
uipc_usrreq,
|
||||
0,
|
||||
0, 0, 0, 0,
|
||||
&uipc_usrreqs
|
||||
},
|
||||
{ 0, 0, 0, 0,
|
||||
0, 0, raw_ctlinput, 0,
|
||||
raw_usrreq,
|
||||
0,
|
||||
raw_init, 0, 0, 0,
|
||||
&raw_usrreqs
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: uipc_socket2.c,v 1.22 1997/02/24 20:30:57 wollman Exp $
|
||||
* $Id: uipc_socket2.c,v 1.23 1997/03/31 12:29:59 davidg Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -220,7 +220,7 @@ sonewconn1(head, connstatus)
|
||||
so->so_pgid = head->so_pgid;
|
||||
(void) soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat);
|
||||
|
||||
if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0)) {
|
||||
if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0, curproc)) { /*XXX*/
|
||||
(void) free((caddr_t)so, M_SOCKET);
|
||||
return ((struct socket *)0);
|
||||
}
|
||||
@ -975,7 +975,14 @@ pru_connect2_notsupp(struct socket *so1, struct socket *so2)
|
||||
}
|
||||
|
||||
int
|
||||
pru_listen_notsupp(struct socket *so)
|
||||
pru_control_notsupp(struct socket *so, int cmd, caddr_t data,
|
||||
struct ifnet *ifp, struct proc *p)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int
|
||||
pru_listen_notsupp(struct socket *so, struct proc *p)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
|
||||
* $Id: uipc_socket.c,v 1.24 1997/02/24 20:30:56 wollman Exp $
|
||||
* $Id: uipc_socket.c,v 1.25 1997/03/23 03:36:31 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -78,7 +78,7 @@ socreate(dom, aso, type, proto, p)
|
||||
prp = pffindproto(dom, proto, type);
|
||||
else
|
||||
prp = pffindtype(dom, type);
|
||||
if (prp == 0 || prp->pr_usrreqs == 0)
|
||||
if (prp == 0 || prp->pr_usrreqs->pru_attach == 0)
|
||||
return (EPROTONOSUPPORT);
|
||||
if (prp->pr_type != type)
|
||||
return (EPROTOTYPE);
|
||||
@ -87,10 +87,8 @@ socreate(dom, aso, type, proto, p)
|
||||
TAILQ_INIT(&so->so_incomp);
|
||||
TAILQ_INIT(&so->so_comp);
|
||||
so->so_type = type;
|
||||
if (p->p_ucred->cr_uid == 0)
|
||||
so->so_state = SS_PRIV;
|
||||
so->so_proto = prp;
|
||||
error = (*prp->pr_usrreqs->pru_attach)(so, proto);
|
||||
error = (*prp->pr_usrreqs->pru_attach)(so, proto, p);
|
||||
if (error) {
|
||||
so->so_state |= SS_NOFDREF;
|
||||
sofree(so);
|
||||
@ -101,26 +99,28 @@ socreate(dom, aso, type, proto, p)
|
||||
}
|
||||
|
||||
int
|
||||
sobind(so, nam)
|
||||
sobind(so, nam, p)
|
||||
struct socket *so;
|
||||
struct mbuf *nam;
|
||||
struct proc *p;
|
||||
{
|
||||
int s = splnet();
|
||||
int error;
|
||||
|
||||
error = (*so->so_proto->pr_usrreqs->pru_bind)(so, nam);
|
||||
error = (*so->so_proto->pr_usrreqs->pru_bind)(so, nam, p);
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
solisten(so, backlog)
|
||||
solisten(so, backlog, p)
|
||||
register struct socket *so;
|
||||
int backlog;
|
||||
struct proc *p;
|
||||
{
|
||||
int s = splnet(), error;
|
||||
|
||||
error = (*so->so_proto->pr_usrreqs->pru_listen)(so);
|
||||
error = (*so->so_proto->pr_usrreqs->pru_listen)(so, p);
|
||||
if (error) {
|
||||
splx(s);
|
||||
return (error);
|
||||
@ -247,9 +247,10 @@ soaccept(so, nam)
|
||||
}
|
||||
|
||||
int
|
||||
soconnect(so, nam)
|
||||
soconnect(so, nam, p)
|
||||
register struct socket *so;
|
||||
struct mbuf *nam;
|
||||
struct proc *p;
|
||||
{
|
||||
int s;
|
||||
int error;
|
||||
@ -268,7 +269,7 @@ soconnect(so, nam)
|
||||
(error = sodisconnect(so))))
|
||||
error = EISCONN;
|
||||
else
|
||||
error = (*so->so_proto->pr_usrreqs->pru_connect)(so, nam);
|
||||
error = (*so->so_proto->pr_usrreqs->pru_connect)(so, nam, p);
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
@ -471,7 +472,7 @@ sosend(so, addr, uio, top, control, flags)
|
||||
(so->so_proto->pr_flags & PR_IMPLOPCL) &&
|
||||
(resid <= 0)) ?
|
||||
PRUS_EOF : 0,
|
||||
top, addr, control);
|
||||
top, addr, control, p);
|
||||
splx(s);
|
||||
if (dontroute)
|
||||
so->so_options &= ~SO_DONTROUTE;
|
||||
@ -847,10 +848,11 @@ sorflush(so)
|
||||
}
|
||||
|
||||
int
|
||||
sosetopt(so, level, optname, m0)
|
||||
sosetopt(so, level, optname, m0, p)
|
||||
register struct socket *so;
|
||||
int level, optname;
|
||||
struct mbuf *m0;
|
||||
struct proc *p;
|
||||
{
|
||||
int error = 0;
|
||||
register struct mbuf *m = m0;
|
||||
@ -858,7 +860,7 @@ sosetopt(so, level, optname, m0)
|
||||
if (level != SOL_SOCKET) {
|
||||
if (so->so_proto && so->so_proto->pr_ctloutput)
|
||||
return ((*so->so_proto->pr_ctloutput)
|
||||
(PRCO_SETOPT, so, level, optname, &m0));
|
||||
(PRCO_SETOPT, so, level, optname, &m0, p));
|
||||
error = ENOPROTOOPT;
|
||||
} else {
|
||||
switch (optname) {
|
||||
@ -948,18 +950,13 @@ sosetopt(so, level, optname, m0)
|
||||
break;
|
||||
}
|
||||
|
||||
case SO_PRIVSTATE:
|
||||
/* we don't care what the parameter is... */
|
||||
so->so_state &= ~SS_PRIV;
|
||||
break;
|
||||
|
||||
default:
|
||||
error = ENOPROTOOPT;
|
||||
break;
|
||||
}
|
||||
if (error == 0 && so->so_proto && so->so_proto->pr_ctloutput) {
|
||||
(void) ((*so->so_proto->pr_ctloutput)
|
||||
(PRCO_SETOPT, so, level, optname, &m0));
|
||||
(PRCO_SETOPT, so, level, optname, &m0, p));
|
||||
m = NULL; /* freed by protocol */
|
||||
}
|
||||
}
|
||||
@ -970,17 +967,18 @@ sosetopt(so, level, optname, m0)
|
||||
}
|
||||
|
||||
int
|
||||
sogetopt(so, level, optname, mp)
|
||||
sogetopt(so, level, optname, mp, p)
|
||||
register struct socket *so;
|
||||
int level, optname;
|
||||
struct mbuf **mp;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct mbuf *m;
|
||||
|
||||
if (level != SOL_SOCKET) {
|
||||
if (so->so_proto && so->so_proto->pr_ctloutput) {
|
||||
return ((*so->so_proto->pr_ctloutput)
|
||||
(PRCO_GETOPT, so, level, optname, mp));
|
||||
(PRCO_GETOPT, so, level, optname, mp, p));
|
||||
} else
|
||||
return (ENOPROTOOPT);
|
||||
} else {
|
||||
@ -1008,10 +1006,6 @@ sogetopt(so, level, optname, mp)
|
||||
*mtod(m, int *) = so->so_options & optname;
|
||||
break;
|
||||
|
||||
case SO_PRIVSTATE:
|
||||
*mtod(m, int *) = so->so_state & SS_PRIV;
|
||||
break;
|
||||
|
||||
case SO_TYPE:
|
||||
*mtod(m, int *) = so->so_type;
|
||||
break;
|
||||
@ -1071,3 +1065,40 @@ sohasoutofband(so)
|
||||
psignal(p, SIGURG);
|
||||
selwakeup(&so->so_rcv.sb_sel);
|
||||
}
|
||||
|
||||
int
|
||||
soselect(struct socket *so, int which, struct proc *p)
|
||||
{
|
||||
int s = splnet();
|
||||
switch (which) {
|
||||
|
||||
case FREAD:
|
||||
if (soreadable(so)) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
selrecord(p, &so->so_rcv.sb_sel);
|
||||
so->so_rcv.sb_flags |= SB_SEL;
|
||||
break;
|
||||
|
||||
case FWRITE:
|
||||
if (sowriteable(so)) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
selrecord(p, &so->so_snd.sb_sel);
|
||||
so->so_snd.sb_flags |= SB_SEL;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
if (so->so_oobmark || (so->so_state & SS_RCVATMARK)) {
|
||||
splx(s);
|
||||
return (1);
|
||||
}
|
||||
selrecord(p, &so->so_rcv.sb_sel);
|
||||
so->so_rcv.sb_flags |= SB_SEL;
|
||||
break;
|
||||
}
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: uipc_socket2.c,v 1.22 1997/02/24 20:30:57 wollman Exp $
|
||||
* $Id: uipc_socket2.c,v 1.23 1997/03/31 12:29:59 davidg Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -220,7 +220,7 @@ sonewconn1(head, connstatus)
|
||||
so->so_pgid = head->so_pgid;
|
||||
(void) soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat);
|
||||
|
||||
if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0)) {
|
||||
if ((*so->so_proto->pr_usrreqs->pru_attach)(so, 0, curproc)) { /*XXX*/
|
||||
(void) free((caddr_t)so, M_SOCKET);
|
||||
return ((struct socket *)0);
|
||||
}
|
||||
@ -975,7 +975,14 @@ pru_connect2_notsupp(struct socket *so1, struct socket *so2)
|
||||
}
|
||||
|
||||
int
|
||||
pru_listen_notsupp(struct socket *so)
|
||||
pru_control_notsupp(struct socket *so, int cmd, caddr_t data,
|
||||
struct ifnet *ifp, struct proc *p)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
int
|
||||
pru_listen_notsupp(struct socket *so, struct proc *p)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
|
||||
* $Id: uipc_syscalls.c,v 1.24 1997/03/31 12:30:01 davidg Exp $
|
||||
* $Id: uipc_syscalls.c,v 1.25 1997/04/09 16:53:40 bde Exp $
|
||||
*/
|
||||
|
||||
#include "opt_ktrace.h"
|
||||
@ -130,7 +130,7 @@ bind(p, uap, retval)
|
||||
error = sockargs(&nam, uap->name, uap->namelen, MT_SONAME);
|
||||
if (error)
|
||||
return (error);
|
||||
error = sobind((struct socket *)fp->f_data, nam);
|
||||
error = sobind((struct socket *)fp->f_data, nam, p);
|
||||
m_freem(nam);
|
||||
return (error);
|
||||
}
|
||||
@ -151,7 +151,7 @@ listen(p, uap, retval)
|
||||
error = getsock(p->p_fd, uap->s, &fp);
|
||||
if (error)
|
||||
return (error);
|
||||
return (solisten((struct socket *)fp->f_data, uap->backlog));
|
||||
return (solisten((struct socket *)fp->f_data, uap->backlog, p));
|
||||
}
|
||||
|
||||
static int
|
||||
@ -312,7 +312,7 @@ connect(p, uap, retval)
|
||||
error = sockargs(&nam, uap->name, uap->namelen, MT_SONAME);
|
||||
if (error)
|
||||
return (error);
|
||||
error = soconnect(so, nam);
|
||||
error = soconnect(so, nam, p);
|
||||
if (error)
|
||||
goto bad;
|
||||
if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
|
||||
@ -420,6 +420,7 @@ sendit(p, s, mp, flags, retsize)
|
||||
register int i;
|
||||
struct mbuf *to, *control;
|
||||
int len, error;
|
||||
struct socket *so;
|
||||
#ifdef KTRACE
|
||||
struct iovec *ktriov = NULL;
|
||||
#endif
|
||||
@ -485,8 +486,9 @@ sendit(p, s, mp, flags, retsize)
|
||||
}
|
||||
#endif
|
||||
len = auio.uio_resid;
|
||||
error = sosend((struct socket *)fp->f_data, to, &auio,
|
||||
(struct mbuf *)0, control, flags);
|
||||
so = (struct socket *)fp->f_data;
|
||||
error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control,
|
||||
flags);
|
||||
if (error) {
|
||||
if (auio.uio_resid != len && (error == ERESTART ||
|
||||
error == EINTR || error == EWOULDBLOCK))
|
||||
@ -659,6 +661,7 @@ recvit(p, s, mp, namelenp, retsize)
|
||||
int len, error;
|
||||
struct mbuf *m, *from = 0, *control = 0;
|
||||
caddr_t ctlbuf;
|
||||
struct socket *so;
|
||||
#ifdef KTRACE
|
||||
struct iovec *ktriov = NULL;
|
||||
#endif
|
||||
@ -687,7 +690,8 @@ recvit(p, s, mp, namelenp, retsize)
|
||||
}
|
||||
#endif
|
||||
len = auio.uio_resid;
|
||||
error = soreceive((struct socket *)fp->f_data, &from, &auio,
|
||||
so = (struct socket *)fp->f_data;
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive(so, &from, &auio,
|
||||
(struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
|
||||
&mp->msg_flags);
|
||||
if (error) {
|
||||
@ -1012,7 +1016,7 @@ setsockopt(p, uap, retval)
|
||||
m->m_len = uap->valsize;
|
||||
}
|
||||
return (sosetopt((struct socket *)fp->f_data, uap->level,
|
||||
uap->name, m));
|
||||
uap->name, m, p));
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
@ -1043,7 +1047,7 @@ getsockopt(p, uap, retval)
|
||||
} else
|
||||
valsize = 0;
|
||||
if ((error = sogetopt((struct socket *)fp->f_data, uap->level,
|
||||
uap->name, &m)) == 0 && uap->val && valsize && m != NULL) {
|
||||
uap->name, &m, p)) == 0 && uap->val && valsize && m != NULL) {
|
||||
op = 0;
|
||||
while (m && !error && op < valsize) {
|
||||
i = min(m->m_len, (valsize - op));
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
|
||||
* $Id: uipc_usrreq.c,v 1.21 1997/03/21 16:12:32 wpaul Exp $
|
||||
* $Id: uipc_usrreq.c,v 1.22 1997/03/23 03:36:33 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -78,270 +78,353 @@ static void unp_mark __P((struct file *));
|
||||
static void unp_discard __P((struct file *));
|
||||
static int unp_internalize __P((struct mbuf *, struct proc *));
|
||||
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
uipc_usrreq(so, req, m, nam, control)
|
||||
struct socket *so;
|
||||
int req;
|
||||
struct mbuf *m, *nam, *control;
|
||||
static int
|
||||
uipc_abort(struct socket *so)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
register struct socket *so2;
|
||||
register int error = 0;
|
||||
struct proc *p = curproc; /* XXX */
|
||||
|
||||
if (req == PRU_CONTROL)
|
||||
return (EOPNOTSUPP);
|
||||
if (req != PRU_SEND && control && control->m_len) {
|
||||
error = EOPNOTSUPP;
|
||||
goto release;
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
unp_drop(unp, ECONNABORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
uipc_accept(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
|
||||
/*
|
||||
* Pass back name of connected socket,
|
||||
* if it was bound and we are still connected
|
||||
* (our peer may have closed already!).
|
||||
*/
|
||||
if (unp->unp_conn && unp->unp_conn->unp_addr) {
|
||||
nam->m_len = unp->unp_conn->unp_addr->m_len;
|
||||
bcopy(mtod(unp->unp_conn->unp_addr, caddr_t),
|
||||
mtod(nam, caddr_t), (unsigned)nam->m_len);
|
||||
} else {
|
||||
nam->m_len = sizeof(sun_noname);
|
||||
*(mtod(nam, struct sockaddr *)) = sun_noname;
|
||||
}
|
||||
if (unp == 0 && req != PRU_ATTACH) {
|
||||
error = EINVAL;
|
||||
goto release;
|
||||
}
|
||||
switch (req) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
case PRU_ATTACH:
|
||||
if (unp) {
|
||||
error = EISCONN;
|
||||
break;
|
||||
}
|
||||
error = unp_attach(so);
|
||||
break;
|
||||
static int
|
||||
uipc_attach(struct socket *so, int proto, struct proc *p)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
case PRU_DETACH:
|
||||
unp_detach(unp);
|
||||
break;
|
||||
if (unp != 0)
|
||||
return EISCONN;
|
||||
return unp_attach(so);
|
||||
}
|
||||
|
||||
case PRU_BIND:
|
||||
error = unp_bind(unp, nam, p);
|
||||
break;
|
||||
static int
|
||||
uipc_bind(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
case PRU_LISTEN:
|
||||
if (unp->unp_vnode == 0)
|
||||
error = EINVAL;
|
||||
break;
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
|
||||
case PRU_CONNECT:
|
||||
error = unp_connect(so, nam, p);
|
||||
break;
|
||||
return unp_bind(unp, nam, p);
|
||||
}
|
||||
|
||||
case PRU_CONNECT2:
|
||||
error = unp_connect2(so, (struct socket *)nam);
|
||||
break;
|
||||
static int
|
||||
uipc_connect(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
case PRU_DISCONNECT:
|
||||
unp_disconnect(unp);
|
||||
break;
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
return unp_connect(so, nam, curproc);
|
||||
}
|
||||
|
||||
case PRU_ACCEPT:
|
||||
/*
|
||||
* Pass back name of connected socket,
|
||||
* if it was bound and we are still connected
|
||||
* (our peer may have closed already!).
|
||||
*/
|
||||
if (unp->unp_conn && unp->unp_conn->unp_addr) {
|
||||
nam->m_len = unp->unp_conn->unp_addr->m_len;
|
||||
bcopy(mtod(unp->unp_conn->unp_addr, caddr_t),
|
||||
mtod(nam, caddr_t), (unsigned)nam->m_len);
|
||||
} else {
|
||||
nam->m_len = sizeof(sun_noname);
|
||||
*(mtod(nam, struct sockaddr *)) = sun_noname;
|
||||
}
|
||||
break;
|
||||
static int
|
||||
uipc_connect2(struct socket *so1, struct socket *so2)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so1);
|
||||
|
||||
case PRU_SHUTDOWN:
|
||||
socantsendmore(so);
|
||||
unp_shutdown(unp);
|
||||
break;
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
|
||||
case PRU_RCVD:
|
||||
switch (so->so_type) {
|
||||
return unp_connect2(so1, so2);
|
||||
}
|
||||
|
||||
case SOCK_DGRAM:
|
||||
panic("uipc 1");
|
||||
/*NOTREACHED*/
|
||||
/* control is EOPNOTSUPP */
|
||||
|
||||
case SOCK_STREAM:
|
||||
static int
|
||||
uipc_detach(struct socket *so)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
|
||||
unp_detach(unp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
uipc_disconnect(struct socket *so)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
unp_disconnect(unp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
uipc_listen(struct socket *so, struct proc *p)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
if (unp == 0 || unp->unp_vnode == 0)
|
||||
return EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
uipc_peeraddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
if (unp->unp_conn && unp->unp_conn->unp_addr) {
|
||||
nam->m_len = unp->unp_conn->unp_addr->m_len;
|
||||
bcopy(mtod(unp->unp_conn->unp_addr, caddr_t),
|
||||
mtod(nam, caddr_t), (unsigned)nam->m_len);
|
||||
} else
|
||||
nam->m_len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
uipc_rcvd(struct socket *so, int flags)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
struct socket *so2;
|
||||
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
switch (so->so_type) {
|
||||
case SOCK_DGRAM:
|
||||
panic("uipc_rcvd DGRAM?");
|
||||
/*NOTREACHED*/
|
||||
|
||||
case SOCK_STREAM:
|
||||
#define rcv (&so->so_rcv)
|
||||
#define snd (&so2->so_snd)
|
||||
if (unp->unp_conn == 0)
|
||||
break;
|
||||
so2 = unp->unp_conn->unp_socket;
|
||||
/*
|
||||
* Adjust backpressure on sender
|
||||
* and wakeup any waiting to write.
|
||||
*/
|
||||
snd->sb_mbmax += unp->unp_mbcnt - rcv->sb_mbcnt;
|
||||
unp->unp_mbcnt = rcv->sb_mbcnt;
|
||||
snd->sb_hiwat += unp->unp_cc - rcv->sb_cc;
|
||||
unp->unp_cc = rcv->sb_cc;
|
||||
sowwakeup(so2);
|
||||
#undef snd
|
||||
#undef rcv
|
||||
if (unp->unp_conn == 0)
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("uipc 2");
|
||||
}
|
||||
break;
|
||||
|
||||
case PRU_SEND:
|
||||
case PRU_SEND_EOF:
|
||||
if (control && (error = unp_internalize(control, p)))
|
||||
break;
|
||||
switch (so->so_type) {
|
||||
|
||||
case SOCK_DGRAM: {
|
||||
struct sockaddr *from;
|
||||
|
||||
if (nam) {
|
||||
if (unp->unp_conn) {
|
||||
error = EISCONN;
|
||||
break;
|
||||
}
|
||||
error = unp_connect(so, nam, p);
|
||||
if (error)
|
||||
break;
|
||||
} else {
|
||||
if (unp->unp_conn == 0) {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
so2 = unp->unp_conn->unp_socket;
|
||||
if (unp->unp_addr)
|
||||
from = mtod(unp->unp_addr, struct sockaddr *);
|
||||
else
|
||||
from = &sun_noname;
|
||||
if (sbappendaddr(&so2->so_rcv, from, m, control)) {
|
||||
sorwakeup(so2);
|
||||
m = 0;
|
||||
control = 0;
|
||||
} else
|
||||
error = ENOBUFS;
|
||||
if (nam)
|
||||
unp_disconnect(unp);
|
||||
break;
|
||||
}
|
||||
|
||||
case SOCK_STREAM:
|
||||
#define rcv (&so2->so_rcv)
|
||||
#define snd (&so->so_snd)
|
||||
/* Connect if not connected yet. */
|
||||
/*
|
||||
* Note: A better implementation would complain
|
||||
* if not equal to the peer's address.
|
||||
*/
|
||||
if ((so->so_state & SS_ISCONNECTED) == 0) {
|
||||
if (nam) {
|
||||
error = unp_connect(so, nam, p);
|
||||
if (error)
|
||||
break; /* XXX */
|
||||
} else {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (so->so_state & SS_CANTSENDMORE) {
|
||||
error = EPIPE;
|
||||
break;
|
||||
}
|
||||
if (unp->unp_conn == 0)
|
||||
panic("uipc 3");
|
||||
so2 = unp->unp_conn->unp_socket;
|
||||
/*
|
||||
* Send to paired receive port, and then reduce
|
||||
* send buffer hiwater marks to maintain backpressure.
|
||||
* Wake up readers.
|
||||
*/
|
||||
if (control) {
|
||||
if (sbappendcontrol(rcv, m, control))
|
||||
control = 0;
|
||||
} else
|
||||
sbappend(rcv, m);
|
||||
snd->sb_mbmax -=
|
||||
rcv->sb_mbcnt - unp->unp_conn->unp_mbcnt;
|
||||
unp->unp_conn->unp_mbcnt = rcv->sb_mbcnt;
|
||||
snd->sb_hiwat -= rcv->sb_cc - unp->unp_conn->unp_cc;
|
||||
unp->unp_conn->unp_cc = rcv->sb_cc;
|
||||
sorwakeup(so2);
|
||||
m = 0;
|
||||
#undef snd
|
||||
#undef rcv
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("uipc 4");
|
||||
}
|
||||
so2 = unp->unp_conn->unp_socket;
|
||||
/*
|
||||
* SEND_EOF is equivalent to a SEND followed by
|
||||
* a SHUTDOWN.
|
||||
* Adjust backpressure on sender
|
||||
* and wakeup any waiting to write.
|
||||
*/
|
||||
if (req == PRU_SEND_EOF) {
|
||||
socantsendmore(so);
|
||||
unp_shutdown(unp);
|
||||
}
|
||||
break;
|
||||
|
||||
case PRU_ABORT:
|
||||
unp_drop(unp, ECONNABORTED);
|
||||
break;
|
||||
|
||||
case PRU_SENSE:
|
||||
((struct stat *) m)->st_blksize = so->so_snd.sb_hiwat;
|
||||
if (so->so_type == SOCK_STREAM && unp->unp_conn != 0) {
|
||||
so2 = unp->unp_conn->unp_socket;
|
||||
((struct stat *) m)->st_blksize += so2->so_rcv.sb_cc;
|
||||
}
|
||||
((struct stat *) m)->st_dev = NODEV;
|
||||
if (unp->unp_ino == 0)
|
||||
unp->unp_ino = unp_ino++;
|
||||
((struct stat *) m)->st_ino = unp->unp_ino;
|
||||
return (0);
|
||||
|
||||
case PRU_RCVOOB:
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
case PRU_SENDOOB:
|
||||
error = EOPNOTSUPP;
|
||||
break;
|
||||
|
||||
case PRU_SOCKADDR:
|
||||
if (unp->unp_addr) {
|
||||
nam->m_len = unp->unp_addr->m_len;
|
||||
bcopy(mtod(unp->unp_addr, caddr_t),
|
||||
mtod(nam, caddr_t), (unsigned)nam->m_len);
|
||||
} else
|
||||
nam->m_len = 0;
|
||||
break;
|
||||
|
||||
case PRU_PEERADDR:
|
||||
if (unp->unp_conn && unp->unp_conn->unp_addr) {
|
||||
nam->m_len = unp->unp_conn->unp_addr->m_len;
|
||||
bcopy(mtod(unp->unp_conn->unp_addr, caddr_t),
|
||||
mtod(nam, caddr_t), (unsigned)nam->m_len);
|
||||
} else
|
||||
nam->m_len = 0;
|
||||
break;
|
||||
|
||||
case PRU_SLOWTIMO:
|
||||
snd->sb_mbmax += unp->unp_mbcnt - rcv->sb_mbcnt;
|
||||
unp->unp_mbcnt = rcv->sb_mbcnt;
|
||||
snd->sb_hiwat += unp->unp_cc - rcv->sb_cc;
|
||||
unp->unp_cc = rcv->sb_cc;
|
||||
sowwakeup(so2);
|
||||
#undef snd
|
||||
#undef rcv
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("piusrreq");
|
||||
panic("uipc_rcvd unknown socktype");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* pru_rcvoob is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
uipc_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
|
||||
struct mbuf *control, struct proc *p)
|
||||
{
|
||||
int error = 0;
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
struct socket *so2;
|
||||
|
||||
if (unp == 0) {
|
||||
error = EINVAL;
|
||||
goto release;
|
||||
}
|
||||
if (flags & PRUS_OOB) {
|
||||
error = EOPNOTSUPP;
|
||||
goto release;
|
||||
}
|
||||
|
||||
if (control && (error = unp_internalize(control, p)))
|
||||
goto release;
|
||||
|
||||
switch (so->so_type) {
|
||||
case SOCK_DGRAM:
|
||||
{
|
||||
struct sockaddr *from;
|
||||
|
||||
if (nam) {
|
||||
if (unp->unp_conn) {
|
||||
error = EISCONN;
|
||||
break;
|
||||
}
|
||||
error = unp_connect(so, nam, p);
|
||||
if (error)
|
||||
break;
|
||||
} else {
|
||||
if (unp->unp_conn == 0) {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
so2 = unp->unp_conn->unp_socket;
|
||||
if (unp->unp_addr)
|
||||
from = mtod(unp->unp_addr, struct sockaddr *);
|
||||
else
|
||||
from = &sun_noname;
|
||||
if (sbappendaddr(&so2->so_rcv, from, m, control)) {
|
||||
sorwakeup(so2);
|
||||
m = 0;
|
||||
control = 0;
|
||||
} else
|
||||
error = ENOBUFS;
|
||||
if (nam)
|
||||
unp_disconnect(unp);
|
||||
break;
|
||||
}
|
||||
|
||||
case SOCK_STREAM:
|
||||
#define rcv (&so2->so_rcv)
|
||||
#define snd (&so->so_snd)
|
||||
/* Connect if not connected yet. */
|
||||
/*
|
||||
* Note: A better implementation would complain
|
||||
* if not equal to the peer's address.
|
||||
*/
|
||||
if ((so->so_state & SS_ISCONNECTED) == 0) {
|
||||
if (nam) {
|
||||
error = unp_connect(so, nam, p);
|
||||
if (error)
|
||||
break; /* XXX */
|
||||
} else {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (so->so_state & SS_CANTSENDMORE) {
|
||||
error = EPIPE;
|
||||
break;
|
||||
}
|
||||
if (unp->unp_conn == 0)
|
||||
panic("uipc_send connected but no connection?");
|
||||
so2 = unp->unp_conn->unp_socket;
|
||||
/*
|
||||
* Send to paired receive port, and then reduce
|
||||
* send buffer hiwater marks to maintain backpressure.
|
||||
* Wake up readers.
|
||||
*/
|
||||
if (control) {
|
||||
if (sbappendcontrol(rcv, m, control))
|
||||
control = 0;
|
||||
} else
|
||||
sbappend(rcv, m);
|
||||
snd->sb_mbmax -=
|
||||
rcv->sb_mbcnt - unp->unp_conn->unp_mbcnt;
|
||||
unp->unp_conn->unp_mbcnt = rcv->sb_mbcnt;
|
||||
snd->sb_hiwat -= rcv->sb_cc - unp->unp_conn->unp_cc;
|
||||
unp->unp_conn->unp_cc = rcv->sb_cc;
|
||||
sorwakeup(so2);
|
||||
m = 0;
|
||||
#undef snd
|
||||
#undef rcv
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("uipc_send unknown socktype");
|
||||
}
|
||||
|
||||
/*
|
||||
* SEND_EOF is equivalent to a SEND followed by
|
||||
* a SHUTDOWN.
|
||||
*/
|
||||
if (flags & PRUS_EOF) {
|
||||
socantsendmore(so);
|
||||
unp_shutdown(unp);
|
||||
}
|
||||
|
||||
release:
|
||||
if (control)
|
||||
m_freem(control);
|
||||
if (m)
|
||||
m_freem(m);
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
uipc_sense(struct socket *so, struct stat *sb)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
struct socket *so2;
|
||||
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
sb->st_blksize = so->so_snd.sb_hiwat;
|
||||
if (so->so_type == SOCK_STREAM && unp->unp_conn != 0) {
|
||||
so2 = unp->unp_conn->unp_socket;
|
||||
sb->st_blksize += so2->so_rcv.sb_cc;
|
||||
}
|
||||
sb->st_dev = NODEV;
|
||||
if (unp->unp_ino == 0)
|
||||
unp->unp_ino = unp_ino++;
|
||||
sb->st_ino = unp->unp_ino;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
uipc_shutdown(struct socket *so)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
socantsendmore(so);
|
||||
unp_shutdown(unp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
uipc_sockaddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct unpcb *unp = sotounpcb(so);
|
||||
|
||||
if (unp == 0)
|
||||
return EINVAL;
|
||||
if (unp->unp_addr) {
|
||||
nam->m_len = unp->unp_addr->m_len;
|
||||
bcopy(mtod(unp->unp_addr, caddr_t),
|
||||
mtod(nam, caddr_t), (unsigned)nam->m_len);
|
||||
} else
|
||||
nam->m_len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct pr_usrreqs uipc_usrreqs = {
|
||||
uipc_abort, uipc_accept, uipc_attach, uipc_bind, uipc_connect,
|
||||
uipc_connect2, pru_control_notsupp, uipc_detach, uipc_disconnect,
|
||||
uipc_listen, uipc_peeraddr, uipc_rcvd, pru_rcvoob_notsupp,
|
||||
uipc_send, uipc_sense, uipc_shutdown, uipc_sockaddr,
|
||||
sosend, soreceive, soselect
|
||||
};
|
||||
|
||||
/*
|
||||
* Both send and receive buffers are allocated PIPSIZ bytes of buffering
|
||||
* for stream sockets, although the total for sender and receiver is
|
||||
@ -472,7 +555,7 @@ unp_bind(unp, nam, p)
|
||||
}
|
||||
VATTR_NULL(&vattr);
|
||||
vattr.va_type = VSOCK;
|
||||
vattr.va_mode = ACCESSPERMS;
|
||||
vattr.va_mode = (ACCESSPERMS & ~p->p_fd->fd_cmask);
|
||||
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
|
||||
if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr))
|
||||
return (error);
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)if.c 8.3 (Berkeley) 1/4/94
|
||||
* $Id: if.c,v 1.45 1997/02/14 15:30:54 wollman Exp $
|
||||
* $Id: if.c,v 1.46 1997/03/24 11:33:08 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -640,7 +640,7 @@ ifioctl(so, cmd, data, p)
|
||||
error = ((*so->so_proto->pr_usrreqs->pru_control)(so,
|
||||
cmd,
|
||||
data,
|
||||
ifp));
|
||||
ifp, p));
|
||||
switch (ocmd) {
|
||||
|
||||
case OSIOCGIFADDR:
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)raw_cb.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: raw_cb.c,v 1.10 1997/02/22 09:41:13 peter Exp $
|
||||
* $Id: raw_cb.c,v 1.11 1997/04/14 18:23:22 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)raw_cb.h 8.1 (Berkeley) 6/10/93
|
||||
* $Id: raw_cb.h,v 1.7 1997/02/22 09:41:13 peter Exp $
|
||||
* $Id: raw_cb.h,v 1.8 1997/04/14 18:23:23 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NET_RAW_CB_H_
|
||||
@ -67,8 +67,8 @@ void raw_disconnect __P((struct rawcb *));
|
||||
void raw_init __P((void));
|
||||
void raw_input __P((struct mbuf *,
|
||||
struct sockproto *, struct sockaddr *, struct sockaddr *));
|
||||
int raw_usrreq __P((struct socket *,
|
||||
int, struct mbuf *, struct mbuf *, struct mbuf *));
|
||||
|
||||
extern struct pr_usrreqs raw_usrreqs;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)raw_usrreq.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: raw_usrreq.c,v 1.10 1997/02/22 09:41:14 peter Exp $
|
||||
* $Id: raw_usrreq.c,v 1.11 1997/04/14 18:23:25 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -39,6 +39,7 @@
|
||||
#include <sys/systm.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/domain.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
@ -140,175 +141,172 @@ raw_ctlinput(cmd, arg, dummy)
|
||||
/* INCOMPLETE */
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
raw_usrreq(so, req, m, nam, control)
|
||||
struct socket *so;
|
||||
int req;
|
||||
struct mbuf *m, *nam, *control;
|
||||
static int
|
||||
raw_uabort(struct socket *so)
|
||||
{
|
||||
register struct rawcb *rp = sotorawcb(so);
|
||||
register int error = 0;
|
||||
int len;
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
|
||||
if (req == PRU_CONTROL)
|
||||
return (EOPNOTSUPP);
|
||||
if (control && control->m_len) {
|
||||
error = EOPNOTSUPP;
|
||||
goto release;
|
||||
if (rp == 0)
|
||||
return EINVAL;
|
||||
raw_disconnect(rp);
|
||||
sofree(so);
|
||||
soisdisconnected(so);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* pru_accept is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
raw_uattach(struct socket *so, int proto, struct proc *p)
|
||||
{
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
int error;
|
||||
|
||||
if (rp == 0)
|
||||
return EINVAL;
|
||||
if (p && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return error;
|
||||
return raw_attach(so, proto);
|
||||
}
|
||||
|
||||
static int
|
||||
raw_ubind(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
raw_uconnect(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* pru_connect2 is EOPNOTSUPP */
|
||||
/* pru_control is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
raw_udetach(struct socket *so)
|
||||
{
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
|
||||
if (rp == 0)
|
||||
return EINVAL;
|
||||
|
||||
raw_detach(rp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
raw_udisconnect(struct socket *so)
|
||||
{
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
|
||||
if (rp == 0)
|
||||
return EINVAL;
|
||||
if (rp->rcb_faddr == 0) {
|
||||
return ENOTCONN;
|
||||
}
|
||||
raw_disconnect(rp);
|
||||
soisdisconnected(so);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* pru_listen is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
raw_upeeraddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
unsigned len;
|
||||
|
||||
if (rp == 0)
|
||||
return EINVAL;
|
||||
if (rp->rcb_faddr == 0) {
|
||||
return ENOTCONN;
|
||||
}
|
||||
len = rp->rcb_faddr->sa_len;
|
||||
bcopy((caddr_t)rp->rcb_faddr, mtod(nam, caddr_t), len);
|
||||
nam->m_len = len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* pru_rcvd is EOPNOTSUPP */
|
||||
/* pru_rcvoob is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
raw_usend(struct socket *so, int flags, struct mbuf *m,
|
||||
struct mbuf *nam, struct mbuf *control, struct proc *p)
|
||||
{
|
||||
int error;
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
|
||||
if (rp == 0) {
|
||||
error = EINVAL;
|
||||
goto release;
|
||||
}
|
||||
switch (req) {
|
||||
|
||||
/*
|
||||
* Allocate a raw control block and fill in the
|
||||
* necessary info to allow packets to be routed to
|
||||
* the appropriate raw interface routine.
|
||||
*/
|
||||
case PRU_ATTACH:
|
||||
if ((so->so_state & SS_PRIV) == 0) {
|
||||
error = EACCES;
|
||||
break;
|
||||
}
|
||||
error = raw_attach(so, (int)nam);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Destroy state just before socket deallocation.
|
||||
* Flush data or not depending on the options.
|
||||
*/
|
||||
case PRU_DETACH:
|
||||
if (rp == 0) {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
raw_detach(rp);
|
||||
break;
|
||||
|
||||
/*
|
||||
* If a socket isn't bound to a single address,
|
||||
* the raw input routine will hand it anything
|
||||
* within that protocol family (assuming there's
|
||||
* nothing else around it should go to).
|
||||
*/
|
||||
case PRU_CONNECT:
|
||||
error = EINVAL;
|
||||
#if 0
|
||||
if (rp->rcb_faddr) {
|
||||
error = EISCONN;
|
||||
break;
|
||||
}
|
||||
nam = m_copym(nam, 0, M_COPYALL, M_WAIT);
|
||||
rp->rcb_faddr = mtod(nam, struct sockaddr *);
|
||||
soisconnected(so);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case PRU_BIND:
|
||||
error = EINVAL;
|
||||
#if 0
|
||||
if (rp->rcb_laddr) {
|
||||
error = EINVAL; /* XXX */
|
||||
break;
|
||||
}
|
||||
error = raw_bind(so, nam);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case PRU_CONNECT2:
|
||||
if (flags & PRUS_OOB) {
|
||||
error = EOPNOTSUPP;
|
||||
goto release;
|
||||
|
||||
case PRU_DISCONNECT:
|
||||
if (rp->rcb_faddr == 0) {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
raw_disconnect(rp);
|
||||
soisdisconnected(so);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Mark the connection as being incapable of further input.
|
||||
*/
|
||||
case PRU_SHUTDOWN:
|
||||
socantsendmore(so);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Ship a packet out. The appropriate raw output
|
||||
* routine handles any massaging necessary.
|
||||
*/
|
||||
case PRU_SEND:
|
||||
if (nam) {
|
||||
if (rp->rcb_faddr) {
|
||||
error = EISCONN;
|
||||
break;
|
||||
}
|
||||
rp->rcb_faddr = mtod(nam, struct sockaddr *);
|
||||
} else if (rp->rcb_faddr == 0) {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
error = (*so->so_proto->pr_output)(m, so);
|
||||
m = NULL;
|
||||
if (nam)
|
||||
rp->rcb_faddr = 0;
|
||||
break;
|
||||
|
||||
case PRU_ABORT:
|
||||
raw_disconnect(rp);
|
||||
sofree(so);
|
||||
soisdisconnected(so);
|
||||
break;
|
||||
|
||||
case PRU_SENSE:
|
||||
/*
|
||||
* stat: don't bother with a blocksize.
|
||||
*/
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Not supported.
|
||||
*/
|
||||
case PRU_RCVOOB:
|
||||
case PRU_RCVD:
|
||||
return(EOPNOTSUPP);
|
||||
|
||||
case PRU_LISTEN:
|
||||
case PRU_ACCEPT:
|
||||
case PRU_SENDOOB:
|
||||
error = EOPNOTSUPP;
|
||||
break;
|
||||
|
||||
case PRU_SOCKADDR:
|
||||
if (rp->rcb_laddr == 0) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
len = rp->rcb_laddr->sa_len;
|
||||
bcopy((caddr_t)rp->rcb_laddr, mtod(nam, caddr_t), (unsigned)len);
|
||||
nam->m_len = len;
|
||||
break;
|
||||
|
||||
case PRU_PEERADDR:
|
||||
if (rp->rcb_faddr == 0) {
|
||||
error = ENOTCONN;
|
||||
break;
|
||||
}
|
||||
len = rp->rcb_faddr->sa_len;
|
||||
bcopy((caddr_t)rp->rcb_faddr, mtod(nam, caddr_t), (unsigned)len);
|
||||
nam->m_len = len;
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("raw_usrreq");
|
||||
}
|
||||
|
||||
if (control && control->m_len) {
|
||||
error = EOPNOTSUPP;
|
||||
goto release;
|
||||
}
|
||||
if (nam) {
|
||||
if (rp->rcb_faddr) {
|
||||
error = EISCONN;
|
||||
goto release;
|
||||
}
|
||||
rp->rcb_faddr = mtod(nam, struct sockaddr *);
|
||||
} else if (rp->rcb_faddr == 0) {
|
||||
error = ENOTCONN;
|
||||
goto release;
|
||||
}
|
||||
error = (*so->so_proto->pr_output)(m, so);
|
||||
m = NULL;
|
||||
if (nam)
|
||||
rp->rcb_faddr = 0;
|
||||
release:
|
||||
if (m != NULL)
|
||||
m_freem(m);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* pru_sense is null */
|
||||
|
||||
static int
|
||||
raw_ushutdown(struct socket *so)
|
||||
{
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
|
||||
if (rp == 0)
|
||||
return EINVAL;
|
||||
socantsendmore(so);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
raw_usockaddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
unsigned len;
|
||||
|
||||
if (rp == 0)
|
||||
return EINVAL;
|
||||
if (rp->rcb_laddr == 0)
|
||||
return EINVAL;
|
||||
len = rp->rcb_laddr->sa_len;
|
||||
bcopy((caddr_t)rp->rcb_laddr, mtod(nam, caddr_t), len);
|
||||
nam->m_len = len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct pr_usrreqs raw_usrreqs = {
|
||||
raw_uabort, pru_accept_notsupp, raw_uattach, raw_ubind, raw_uconnect,
|
||||
pru_connect2_notsupp, pru_control_notsupp, raw_udetach,
|
||||
raw_udisconnect, pru_listen_notsupp, raw_upeeraddr, pru_rcvd_notsupp,
|
||||
pru_rcvoob_notsupp, raw_usend, pru_sense_null, raw_ushutdown,
|
||||
raw_usockaddr, sosend, soreceive, soselect
|
||||
};
|
||||
|
227
sys/net/rtsock.c
227
sys/net/rtsock.c
@ -31,9 +31,10 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)rtsock.c 8.5 (Berkeley) 11/2/94
|
||||
* $Id$
|
||||
* $Id: rtsock.c,v 1.26 1997/02/22 09:41:15 peter Exp $
|
||||
*/
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/systm.h>
|
||||
@ -69,8 +70,6 @@ static void rt_xaddrs __P((caddr_t, caddr_t, struct rt_addrinfo *));
|
||||
static int sysctl_dumpentry __P((struct radix_node *rn, void *vw));
|
||||
static int sysctl_iflist __P((int af, struct walkarg *w));
|
||||
static int route_output __P((struct mbuf *, struct socket *));
|
||||
static int route_usrreq __P((struct socket *,
|
||||
int, struct mbuf *, struct mbuf *, struct mbuf *));
|
||||
static void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *));
|
||||
|
||||
/* Sleazy use of local variables throughout file, warning!!!! */
|
||||
@ -82,62 +81,191 @@ static void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *
|
||||
#define ifaaddr info.rti_info[RTAX_IFA]
|
||||
#define brdaddr info.rti_info[RTAX_BRD]
|
||||
|
||||
/*ARGSUSED*/
|
||||
/*
|
||||
* It really doesn't make any sense at all for this code to share much
|
||||
* with raw_usrreq.c, since its functionality is so restricted. XXX
|
||||
*/
|
||||
static int
|
||||
route_usrreq(so, req, m, nam, control)
|
||||
register struct socket *so;
|
||||
int req;
|
||||
struct mbuf *m, *nam, *control;
|
||||
rts_abort(struct socket *so)
|
||||
{
|
||||
register int error = 0;
|
||||
register struct rawcb *rp = sotorawcb(so);
|
||||
int s;
|
||||
int s, error;
|
||||
s = splnet();
|
||||
error = raw_usrreqs.pru_abort(so);
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (req == PRU_ATTACH) {
|
||||
MALLOC(rp, struct rawcb *, sizeof(*rp), M_PCB, M_WAITOK);
|
||||
so->so_pcb = (caddr_t)rp;
|
||||
if (so->so_pcb)
|
||||
bzero(so->so_pcb, sizeof(*rp));
|
||||
/* pru_accept is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
rts_attach(struct socket *so, int proto, struct proc *p)
|
||||
{
|
||||
struct rawcb *rp;
|
||||
int s, error;
|
||||
|
||||
if (sotorawcb(so) != 0)
|
||||
return EISCONN; /* XXX panic? */
|
||||
MALLOC(rp, struct rawcb *, sizeof *rp, M_PCB, M_WAITOK); /* XXX */
|
||||
if (rp == 0)
|
||||
return ENOBUFS;
|
||||
bzero(rp, sizeof *rp);
|
||||
|
||||
/*
|
||||
* The splnet() is necessary to block protocols from sending
|
||||
* error notifications (like RTM_REDIRECT or RTM_LOSING) while
|
||||
* this PCB is extant but incompletely initialized.
|
||||
* Probably we should try to do more of this work beforehand and
|
||||
* eliminate the spl.
|
||||
*/
|
||||
s = splnet();
|
||||
so->so_pcb = (caddr_t)rp;
|
||||
error = raw_usrreqs.pru_attach(so, proto, p);
|
||||
rp = sotorawcb(so);
|
||||
if (error) {
|
||||
splx(s);
|
||||
free(rp, M_PCB);
|
||||
return error;
|
||||
}
|
||||
if (req == PRU_DETACH && rp) {
|
||||
int af = rp->rcb_proto.sp_protocol;
|
||||
if (af == AF_INET)
|
||||
switch(rp->rcb_proto.sp_protocol) {
|
||||
case AF_INET:
|
||||
route_cb.ip_count++;
|
||||
break;
|
||||
case AF_IPX:
|
||||
route_cb.ipx_count++;
|
||||
break;
|
||||
case AF_NS:
|
||||
route_cb.ns_count++;
|
||||
break;
|
||||
case AF_ISO:
|
||||
route_cb.iso_count++;
|
||||
break;
|
||||
}
|
||||
rp->rcb_faddr = &route_src;
|
||||
route_cb.any_count++;
|
||||
soisconnected(so);
|
||||
so->so_options |= SO_USELOOPBACK;
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
rts_bind(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
int s, error;
|
||||
s = splnet();
|
||||
error = raw_usrreqs.pru_bind(so, nam, p); /* xxx just EINVAL */
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
rts_connect(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
int s, error;
|
||||
s = splnet();
|
||||
error = raw_usrreqs.pru_connect(so, nam, p); /* XXX just EINVAL */
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* pru_connect2 is EOPNOTSUPP */
|
||||
/* pru_control is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
rts_detach(struct socket *so)
|
||||
{
|
||||
struct rawcb *rp = sotorawcb(so);
|
||||
int s, error;
|
||||
|
||||
s = splnet();
|
||||
if (rp != 0) {
|
||||
switch(rp->rcb_proto.sp_protocol) {
|
||||
case AF_INET:
|
||||
route_cb.ip_count--;
|
||||
else if (af == AF_IPX)
|
||||
break;
|
||||
case AF_IPX:
|
||||
route_cb.ipx_count--;
|
||||
else if (af == AF_NS)
|
||||
break;
|
||||
case AF_NS:
|
||||
route_cb.ns_count--;
|
||||
else if (af == AF_ISO)
|
||||
break;
|
||||
case AF_ISO:
|
||||
route_cb.iso_count--;
|
||||
break;
|
||||
}
|
||||
route_cb.any_count--;
|
||||
}
|
||||
s = splnet();
|
||||
error = raw_usrreq(so, req, m, nam, control);
|
||||
rp = sotorawcb(so);
|
||||
if (req == PRU_ATTACH && rp) {
|
||||
int af = rp->rcb_proto.sp_protocol;
|
||||
if (error) {
|
||||
free((caddr_t)rp, M_PCB);
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
if (af == AF_INET)
|
||||
route_cb.ip_count++;
|
||||
else if (af == AF_IPX)
|
||||
route_cb.ipx_count++;
|
||||
else if (af == AF_NS)
|
||||
route_cb.ns_count++;
|
||||
else if (af == AF_ISO)
|
||||
route_cb.iso_count++;
|
||||
rp->rcb_faddr = &route_src;
|
||||
route_cb.any_count++;
|
||||
soisconnected(so);
|
||||
so->so_options |= SO_USELOOPBACK;
|
||||
}
|
||||
error = raw_usrreqs.pru_detach(so);
|
||||
splx(s);
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
rts_disconnect(struct socket *so)
|
||||
{
|
||||
int s, error;
|
||||
s = splnet();
|
||||
error = raw_usrreqs.pru_disconnect(so);
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* pru_listen is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
rts_peeraddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
int s, error;
|
||||
s = splnet();
|
||||
error = raw_usrreqs.pru_peeraddr(so, nam);
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* pru_rcvd is EOPNOTSUPP */
|
||||
/* pru_rcvoob is EOPNOTSUPP */
|
||||
|
||||
static int
|
||||
rts_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
|
||||
struct mbuf *control, struct proc *p)
|
||||
{
|
||||
int s, error;
|
||||
s = splnet();
|
||||
error = raw_usrreqs.pru_send(so, flags, m, nam, control, p);
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* pru_sense is null */
|
||||
|
||||
static int
|
||||
rts_shutdown(struct socket *so)
|
||||
{
|
||||
int s, error;
|
||||
s = splnet();
|
||||
error = raw_usrreqs.pru_shutdown(so);
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
rts_sockaddr(struct socket *so, struct mbuf *nam)
|
||||
{
|
||||
int s, error;
|
||||
s = splnet();
|
||||
error = raw_usrreqs.pru_sockaddr(so, nam);
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
static struct pr_usrreqs route_usrreqs = {
|
||||
rts_abort, pru_accept_notsupp, rts_attach, rts_bind, rts_connect,
|
||||
pru_connect2_notsupp, pru_control_notsupp, rts_detach, rts_disconnect,
|
||||
pru_listen_notsupp, rts_peeraddr, pru_rcvd_notsupp, pru_rcvoob_notsupp,
|
||||
rts_send, pru_sense_null, rts_shutdown, rts_sockaddr,
|
||||
sosend, soreceive, soselect
|
||||
};
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
route_output(m, so)
|
||||
@ -811,7 +939,7 @@ sysctl_rtsock SYSCTL_HANDLER_ARGS
|
||||
return (error);
|
||||
}
|
||||
|
||||
SYSCTL_NODE(_net, PF_ROUTE, routetable, CTLFLAG_RD, sysctl_rtsock,"");
|
||||
SYSCTL_NODE(_net, PF_ROUTE, routetable, CTLFLAG_RD, sysctl_rtsock, "");
|
||||
|
||||
/*
|
||||
* Definitions of protocols supported in the ROUTE domain.
|
||||
@ -822,8 +950,9 @@ extern struct domain routedomain; /* or at least forward */
|
||||
static struct protosw routesw[] = {
|
||||
{ SOCK_RAW, &routedomain, 0, PR_ATOMIC|PR_ADDR,
|
||||
0, route_output, raw_ctlinput, 0,
|
||||
route_usrreq,
|
||||
raw_init
|
||||
0,
|
||||
raw_init, 0, 0, 0,
|
||||
&route_usrreqs
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)in.c 8.4 (Berkeley) 1/9/95
|
||||
* $Id: in.c,v 1.32 1997/02/22 09:41:27 peter Exp $
|
||||
* $Id: in.c,v 1.33 1997/03/24 11:33:25 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,6 +40,7 @@
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -140,11 +141,12 @@ static int in_interfaces; /* number of external internet interfaces */
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
int
|
||||
in_control(so, cmd, data, ifp)
|
||||
in_control(so, cmd, data, ifp, p)
|
||||
struct socket *so;
|
||||
int cmd;
|
||||
caddr_t data;
|
||||
register struct ifnet *ifp;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct ifreq *ifr = (struct ifreq *)data;
|
||||
register struct in_ifaddr *ia = 0, *iap;
|
||||
@ -200,8 +202,8 @@ in_control(so, cmd, data, ifp)
|
||||
case SIOCSIFADDR:
|
||||
case SIOCSIFNETMASK:
|
||||
case SIOCSIFDSTADDR:
|
||||
if ((so->so_state & SS_PRIV) == 0)
|
||||
return (EPERM);
|
||||
if (p && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return error;
|
||||
|
||||
if (ifp == 0)
|
||||
panic("in_control");
|
||||
@ -237,8 +239,8 @@ in_control(so, cmd, data, ifp)
|
||||
break;
|
||||
|
||||
case SIOCSIFBRDADDR:
|
||||
if ((so->so_state & SS_PRIV) == 0)
|
||||
return (EPERM);
|
||||
if (p && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return error;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case SIOCGIFADDR:
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
|
||||
* $Id: in_pcb.c,v 1.29 1997/03/24 11:24:50 bde Exp $
|
||||
* $Id: in_pcb.c,v 1.30 1997/04/03 05:14:40 davidg Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -112,14 +112,16 @@ SYSCTL_PROC(_net_inet_ip_portrange, OID_AUTO, hilast, CTLTYPE_INT|CTLFLAG_RW,
|
||||
&ipport_hilastauto, 0, &sysctl_net_ipport_check, "I", "");
|
||||
|
||||
int
|
||||
in_pcballoc(so, pcbinfo)
|
||||
in_pcballoc(so, pcbinfo, p)
|
||||
struct socket *so;
|
||||
struct inpcbinfo *pcbinfo;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct inpcb *inp;
|
||||
int s;
|
||||
|
||||
MALLOC(inp, struct inpcb *, sizeof(*inp), M_PCB, M_NOWAIT);
|
||||
MALLOC(inp, struct inpcb *, sizeof(*inp), M_PCB,
|
||||
p ? M_WAITOK : M_NOWAIT);
|
||||
if (inp == NULL)
|
||||
return (ENOBUFS);
|
||||
bzero((caddr_t)inp, sizeof(*inp));
|
||||
@ -134,14 +136,14 @@ in_pcballoc(so, pcbinfo)
|
||||
}
|
||||
|
||||
int
|
||||
in_pcbbind(inp, nam)
|
||||
in_pcbbind(inp, nam, p)
|
||||
register struct inpcb *inp;
|
||||
struct mbuf *nam;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct socket *so = inp->inp_socket;
|
||||
unsigned short *lastport;
|
||||
struct sockaddr_in *sin;
|
||||
struct proc *p = curproc; /* XXX */
|
||||
u_short lport = 0;
|
||||
int wild = 0, reuseport = (so->so_options & SO_REUSEPORT);
|
||||
int error;
|
||||
@ -208,7 +210,7 @@ in_pcbbind(inp, nam)
|
||||
lastport = &inp->inp_pcbinfo->lasthi;
|
||||
} else if (inp->inp_flags & INP_LOWPORT) {
|
||||
if (error = suser(p->p_ucred, &p->p_acflag))
|
||||
return (EACCES);
|
||||
return error;
|
||||
first = ipport_lowfirstauto; /* 1023 */
|
||||
last = ipport_lowlastauto; /* 600 */
|
||||
lastport = &inp->inp_pcbinfo->lastlow;
|
||||
@ -391,9 +393,10 @@ in_pcbladdr(inp, nam, plocal_sin)
|
||||
* then pick one.
|
||||
*/
|
||||
int
|
||||
in_pcbconnect(inp, nam)
|
||||
in_pcbconnect(inp, nam, p)
|
||||
register struct inpcb *inp;
|
||||
struct mbuf *nam;
|
||||
struct proc *p;
|
||||
{
|
||||
struct sockaddr_in *ifaddr;
|
||||
register struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
|
||||
@ -411,7 +414,7 @@ in_pcbconnect(inp, nam)
|
||||
return (EADDRINUSE);
|
||||
if (inp->inp_laddr.s_addr == INADDR_ANY) {
|
||||
if (inp->inp_lport == 0)
|
||||
(void)in_pcbbind(inp, (struct mbuf *)0);
|
||||
(void)in_pcbbind(inp, (struct mbuf *)0, p);
|
||||
inp->inp_laddr = ifaddr->sin_addr;
|
||||
}
|
||||
inp->inp_faddr = sin->sin_addr;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
|
||||
* $Id: in_pcb.h,v 1.19 1997/03/03 09:23:34 davidg Exp $
|
||||
* $Id: in_pcb.h,v 1.20 1997/04/03 05:14:41 davidg Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETINET_IN_PCB_H_
|
||||
@ -101,9 +101,9 @@ struct inpcbinfo {
|
||||
|
||||
#ifdef KERNEL
|
||||
void in_losing __P((struct inpcb *));
|
||||
int in_pcballoc __P((struct socket *, struct inpcbinfo *));
|
||||
int in_pcbbind __P((struct inpcb *, struct mbuf *));
|
||||
int in_pcbconnect __P((struct inpcb *, struct mbuf *));
|
||||
int in_pcballoc __P((struct socket *, struct inpcbinfo *, struct proc *));
|
||||
int in_pcbbind __P((struct inpcb *, struct mbuf *, struct proc *));
|
||||
int in_pcbconnect __P((struct inpcb *, struct mbuf *, struct proc *));
|
||||
void in_pcbdetach __P((struct inpcb *));
|
||||
void in_pcbdisconnect __P((struct inpcb *));
|
||||
int in_pcbladdr __P((struct inpcb *, struct mbuf *,
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)in_proto.c 8.2 (Berkeley) 2/9/95
|
||||
* $Id$
|
||||
* $Id: in_proto.c,v 1.38 1997/02/18 20:46:22 wollman Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -96,12 +96,14 @@ void iplinit();
|
||||
|
||||
|
||||
extern struct domain inetdomain;
|
||||
static struct pr_usrreqs nousrreqs;
|
||||
|
||||
struct protosw inetsw[] = {
|
||||
{ 0, &inetdomain, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0,
|
||||
ip_init, 0, ip_slowtimo, ip_drain
|
||||
ip_init, 0, ip_slowtimo, ip_drain,
|
||||
&nousrreqs
|
||||
},
|
||||
{ SOCK_DGRAM, &inetdomain, IPPROTO_UDP, PR_ATOMIC|PR_ADDR,
|
||||
udp_input, 0, udp_ctlinput, ip_ctloutput,
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)in_var.h 8.2 (Berkeley) 1/9/95
|
||||
* $Id$
|
||||
* $Id: in_var.h,v 1.25 1997/02/22 09:41:30 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETINET_IN_VAR_H_
|
||||
@ -216,7 +216,8 @@ do { \
|
||||
|
||||
struct in_multi *in_addmulti __P((struct in_addr *, struct ifnet *));
|
||||
void in_delmulti __P((struct in_multi *));
|
||||
int in_control __P((struct socket *, int, caddr_t, struct ifnet *));
|
||||
int in_control __P((struct socket *, int, caddr_t, struct ifnet *,
|
||||
struct proc *));
|
||||
void in_rtqdrain __P((void));
|
||||
void ip_input __P((struct mbuf *));
|
||||
int in_ifadown __P((struct ifaddr *ifa));
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ip_output.c 8.3 (Berkeley) 1/21/94
|
||||
* $Id: ip_output.c,v 1.1.1.2 1997/04/03 10:39:32 darrenr Exp $
|
||||
* $Id: ip_output.c,v 1.54 1997/04/03 10:47:12 darrenr Exp $
|
||||
*/
|
||||
|
||||
#define _IP_VHL
|
||||
@ -623,11 +623,12 @@ ip_optcopy(ip, jp)
|
||||
* IP socket option processing.
|
||||
*/
|
||||
int
|
||||
ip_ctloutput(op, so, level, optname, mp)
|
||||
ip_ctloutput(op, so, level, optname, mp, p)
|
||||
int op;
|
||||
struct socket *so;
|
||||
int level, optname;
|
||||
struct mbuf **mp;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct inpcb *inp = sotoinpcb(so);
|
||||
register struct mbuf *m = *mp;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ip_var.h 8.2 (Berkeley) 1/9/95
|
||||
* $Id$
|
||||
* $Id: ip_var.h,v 1.31 1997/02/22 09:41:36 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETINET_IP_VAR_H_
|
||||
@ -172,7 +172,8 @@ extern u_long (*ip_mcast_src) __P((int));
|
||||
extern int rsvp_on;
|
||||
extern struct pr_usrreqs rip_usrreqs;
|
||||
|
||||
int ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
|
||||
int ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **,
|
||||
struct proc *));
|
||||
void ip_drain __P((void));
|
||||
void ip_freemoptions __P((struct ip_moptions *));
|
||||
void ip_init __P((void));
|
||||
@ -186,7 +187,8 @@ void ip_slowtimo __P((void));
|
||||
struct mbuf *
|
||||
ip_srcroute __P((void));
|
||||
void ip_stripoptions __P((struct mbuf *, struct mbuf *));
|
||||
int rip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
|
||||
int rip_ctloutput __P((int, struct socket *, int, int, struct mbuf **,
|
||||
struct proc *p));
|
||||
void rip_ctlinput __P((int, struct sockaddr *, void *));
|
||||
void rip_init __P((void));
|
||||
void rip_input __P((struct mbuf *, int));
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)raw_ip.c 8.7 (Berkeley) 5/15/95
|
||||
* $Id: raw_ip.c,v 1.43 1997/03/03 09:23:35 davidg Exp $
|
||||
* $Id: raw_ip.c,v 1.44 1997/04/03 05:14:43 davidg Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -40,6 +40,7 @@
|
||||
#include <sys/errno.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/socket.h>
|
||||
@ -220,11 +221,12 @@ rip_output(m, so, dst)
|
||||
* Raw IP socket option processing.
|
||||
*/
|
||||
int
|
||||
rip_ctloutput(op, so, level, optname, m)
|
||||
rip_ctloutput(op, so, level, optname, m, p)
|
||||
int op;
|
||||
struct socket *so;
|
||||
int level, optname;
|
||||
struct mbuf **m;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct inpcb *inp = sotoinpcb(so);
|
||||
register int error;
|
||||
@ -313,7 +315,7 @@ rip_ctloutput(op, so, level, optname, m)
|
||||
error = EINVAL;
|
||||
return (error);
|
||||
}
|
||||
return (ip_ctloutput(op, so, level, optname, m));
|
||||
return (ip_ctloutput(op, so, level, optname, m, p));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -387,7 +389,7 @@ SYSCTL_INT(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW, &rip_recvspace,
|
||||
0, "");
|
||||
|
||||
static int
|
||||
rip_attach(struct socket *so, int proto)
|
||||
rip_attach(struct socket *so, int proto, struct proc *p)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
int error;
|
||||
@ -395,11 +397,11 @@ rip_attach(struct socket *so, int proto)
|
||||
inp = sotoinpcb(so);
|
||||
if (inp)
|
||||
panic("rip_attach");
|
||||
if ((so->so_state & SS_PRIV) == 0)
|
||||
return EACCES;
|
||||
if (p && (error = suser(p->p_ucred, &p->p_acflag)) != 0)
|
||||
return error;
|
||||
|
||||
if ((error = soreserve(so, rip_sendspace, rip_recvspace)) ||
|
||||
(error = in_pcballoc(so, &ripcbinfo)))
|
||||
(error = in_pcballoc(so, &ripcbinfo, p)))
|
||||
return error;
|
||||
inp = (struct inpcb *)so->so_pcb;
|
||||
inp->inp_ip_p = proto;
|
||||
@ -439,7 +441,7 @@ rip_disconnect(struct socket *so)
|
||||
}
|
||||
|
||||
static int
|
||||
rip_bind(struct socket *so, struct mbuf *nam)
|
||||
rip_bind(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
|
||||
@ -457,7 +459,7 @@ rip_bind(struct socket *so, struct mbuf *nam)
|
||||
}
|
||||
|
||||
static int
|
||||
rip_connect(struct socket *so, struct mbuf *nam)
|
||||
rip_connect(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
struct sockaddr_in *addr = mtod(nam, struct sockaddr_in *);
|
||||
@ -483,7 +485,7 @@ rip_shutdown(struct socket *so)
|
||||
|
||||
static int
|
||||
rip_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
|
||||
struct mbuf *control)
|
||||
struct mbuf *control, struct proc *p)
|
||||
{
|
||||
struct inpcb *inp = sotoinpcb(so);
|
||||
register u_long dst;
|
||||
@ -509,5 +511,5 @@ struct pr_usrreqs rip_usrreqs = {
|
||||
pru_connect2_notsupp, in_control, rip_detach, rip_disconnect,
|
||||
pru_listen_notsupp, in_setpeeraddr, pru_rcvd_notsupp,
|
||||
pru_rcvoob_notsupp, rip_send, pru_sense_null, rip_shutdown,
|
||||
in_setsockaddr
|
||||
in_setsockaddr, sosend, soreceive, soselect
|
||||
};
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
|
||||
* $Id$
|
||||
* $Id: tcp_input.c,v 1.57 1997/02/22 09:41:40 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef TUBA_INCLUDE
|
||||
@ -42,6 +42,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/proc.h> /* for proc0 declaration */
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
@ -652,7 +653,7 @@ tcp_input(m, iphlen)
|
||||
laddr = inp->inp_laddr;
|
||||
if (inp->inp_laddr.s_addr == INADDR_ANY)
|
||||
inp->inp_laddr = ti->ti_dst;
|
||||
if (in_pcbconnect(inp, am)) {
|
||||
if (in_pcbconnect(inp, am, &proc0)) { /* XXX creds */
|
||||
inp->inp_laddr = laddr;
|
||||
(void) m_free(am);
|
||||
goto drop;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
|
||||
* $Id$
|
||||
* $Id: tcp_input.c,v 1.57 1997/02/22 09:41:40 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef TUBA_INCLUDE
|
||||
@ -42,6 +42,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/proc.h> /* for proc0 declaration */
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
@ -652,7 +653,7 @@ tcp_input(m, iphlen)
|
||||
laddr = inp->inp_laddr;
|
||||
if (inp->inp_laddr.s_addr == INADDR_ANY)
|
||||
inp->inp_laddr = ti->ti_dst;
|
||||
if (in_pcbconnect(inp, am)) {
|
||||
if (in_pcbconnect(inp, am, &proc0)) { /* XXX creds */
|
||||
inp->inp_laddr = laddr;
|
||||
(void) m_free(am);
|
||||
goto drop;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
|
||||
* $Id$
|
||||
* $Id: tcp_usrreq.c,v 1.30 1997/02/21 16:30:31 wollman Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -71,8 +71,9 @@
|
||||
*/
|
||||
extern char *tcpstates[]; /* XXX ??? */
|
||||
|
||||
static int tcp_attach __P((struct socket *));
|
||||
static int tcp_connect __P((struct tcpcb *, struct mbuf *));
|
||||
static int tcp_attach __P((struct socket *, struct proc *));
|
||||
static int tcp_connect __P((struct tcpcb *, struct mbuf *,
|
||||
struct proc *));
|
||||
static struct tcpcb *
|
||||
tcp_disconnect __P((struct tcpcb *));
|
||||
static struct tcpcb *
|
||||
@ -94,7 +95,7 @@ static struct tcpcb *
|
||||
* and an internet control block.
|
||||
*/
|
||||
static int
|
||||
tcp_usr_attach(struct socket *so, int proto)
|
||||
tcp_usr_attach(struct socket *so, int proto, struct proc *p)
|
||||
{
|
||||
int s = splnet();
|
||||
int error;
|
||||
@ -108,7 +109,7 @@ tcp_usr_attach(struct socket *so, int proto)
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = tcp_attach(so);
|
||||
error = tcp_attach(so, p);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
@ -170,7 +171,7 @@ tcp_usr_detach(struct socket *so)
|
||||
* Give the socket an address.
|
||||
*/
|
||||
static int
|
||||
tcp_usr_bind(struct socket *so, struct mbuf *nam)
|
||||
tcp_usr_bind(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
int s = splnet();
|
||||
int error = 0;
|
||||
@ -190,7 +191,7 @@ tcp_usr_bind(struct socket *so, struct mbuf *nam)
|
||||
error = EAFNOSUPPORT;
|
||||
goto out;
|
||||
}
|
||||
error = in_pcbbind(inp, nam);
|
||||
error = in_pcbbind(inp, nam, p);
|
||||
if (error)
|
||||
goto out;
|
||||
COMMON_END(PRU_BIND);
|
||||
@ -201,7 +202,7 @@ tcp_usr_bind(struct socket *so, struct mbuf *nam)
|
||||
* Prepare to accept connections.
|
||||
*/
|
||||
static int
|
||||
tcp_usr_listen(struct socket *so)
|
||||
tcp_usr_listen(struct socket *so, struct proc *p)
|
||||
{
|
||||
int s = splnet();
|
||||
int error = 0;
|
||||
@ -210,7 +211,7 @@ tcp_usr_listen(struct socket *so)
|
||||
|
||||
COMMON_START();
|
||||
if (inp->inp_lport == 0)
|
||||
error = in_pcbbind(inp, NULL);
|
||||
error = in_pcbbind(inp, (struct mbuf *)0, p);
|
||||
if (error == 0)
|
||||
tp->t_state = TCPS_LISTEN;
|
||||
COMMON_END(PRU_LISTEN);
|
||||
@ -224,7 +225,7 @@ tcp_usr_listen(struct socket *so)
|
||||
* Send initial segment on connection.
|
||||
*/
|
||||
static int
|
||||
tcp_usr_connect(struct socket *so, struct mbuf *nam)
|
||||
tcp_usr_connect(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
int s = splnet();
|
||||
int error = 0;
|
||||
@ -244,7 +245,7 @@ tcp_usr_connect(struct socket *so, struct mbuf *nam)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((error = tcp_connect(tp, nam)) != 0)
|
||||
if ((error = tcp_connect(tp, nam, p)) != 0)
|
||||
goto out;
|
||||
error = tcp_output(tp);
|
||||
COMMON_END(PRU_CONNECT);
|
||||
@ -333,7 +334,7 @@ tcp_usr_rcvd(struct socket *so, int flags)
|
||||
*/
|
||||
static int
|
||||
tcp_usr_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
|
||||
struct mbuf *control)
|
||||
struct mbuf *control, struct proc *p)
|
||||
{
|
||||
int s = splnet();
|
||||
int error = 0;
|
||||
@ -357,7 +358,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
|
||||
* initialize maxseg/maxopd using peer's cached
|
||||
* MSS.
|
||||
*/
|
||||
error = tcp_connect(tp, nam);
|
||||
error = tcp_connect(tp, nam, p);
|
||||
if (error)
|
||||
goto out;
|
||||
tp->snd_wnd = TTCP_CLIENT_SND_WND;
|
||||
@ -396,7 +397,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
|
||||
* initialize maxseg/maxopd using peer's cached
|
||||
* MSS.
|
||||
*/
|
||||
error = tcp_connect(tp, nam);
|
||||
error = tcp_connect(tp, nam, p);
|
||||
if (error)
|
||||
goto out;
|
||||
tp->snd_wnd = TTCP_CLIENT_SND_WND;
|
||||
@ -463,7 +464,7 @@ struct pr_usrreqs tcp_usrreqs = {
|
||||
tcp_usr_connect, pru_connect2_notsupp, in_control, tcp_usr_detach,
|
||||
tcp_usr_disconnect, tcp_usr_listen, in_setpeeraddr, tcp_usr_rcvd,
|
||||
tcp_usr_rcvoob, tcp_usr_send, pru_sense_null, tcp_usr_shutdown,
|
||||
in_setsockaddr
|
||||
in_setsockaddr, sosend, soreceive, soselect
|
||||
};
|
||||
|
||||
/*
|
||||
@ -477,9 +478,10 @@ struct pr_usrreqs tcp_usrreqs = {
|
||||
* Initialize connection parameters and enter SYN-SENT state.
|
||||
*/
|
||||
static int
|
||||
tcp_connect(tp, nam)
|
||||
tcp_connect(tp, nam, p)
|
||||
register struct tcpcb *tp;
|
||||
struct mbuf *nam;
|
||||
struct proc *p;
|
||||
{
|
||||
struct inpcb *inp = tp->t_inpcb, *oinp;
|
||||
struct socket *so = inp->inp_socket;
|
||||
@ -491,7 +493,7 @@ tcp_connect(tp, nam)
|
||||
struct rmxp_tao tao_noncached;
|
||||
|
||||
if (inp->inp_lport == 0) {
|
||||
error = in_pcbbind(inp, NULL);
|
||||
error = in_pcbbind(inp, (struct mbuf *)0, p);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
@ -564,11 +566,12 @@ tcp_connect(tp, nam)
|
||||
}
|
||||
|
||||
int
|
||||
tcp_ctloutput(op, so, level, optname, mp)
|
||||
tcp_ctloutput(op, so, level, optname, mp, p)
|
||||
int op;
|
||||
struct socket *so;
|
||||
int level, optname;
|
||||
struct mbuf **mp;
|
||||
struct proc *p;
|
||||
{
|
||||
int error = 0, s;
|
||||
struct inpcb *inp;
|
||||
@ -585,7 +588,7 @@ tcp_ctloutput(op, so, level, optname, mp)
|
||||
return (ECONNRESET);
|
||||
}
|
||||
if (level != IPPROTO_TCP) {
|
||||
error = ip_ctloutput(op, so, level, optname, mp);
|
||||
error = ip_ctloutput(op, so, level, optname, mp, p);
|
||||
splx(s);
|
||||
return (error);
|
||||
}
|
||||
@ -684,8 +687,9 @@ SYSCTL_INT(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace,
|
||||
* bufer space, and entering LISTEN state if to accept connections.
|
||||
*/
|
||||
static int
|
||||
tcp_attach(so)
|
||||
tcp_attach(so, p)
|
||||
struct socket *so;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct tcpcb *tp;
|
||||
struct inpcb *inp;
|
||||
@ -696,7 +700,7 @@ tcp_attach(so)
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
error = in_pcballoc(so, &tcbinfo);
|
||||
error = in_pcballoc(so, &tcbinfo, p);
|
||||
if (error)
|
||||
return (error);
|
||||
inp = sotoinpcb(so);
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)tcp_var.h 8.4 (Berkeley) 5/24/95
|
||||
* $Id$
|
||||
* $Id: tcp_var.h,v 1.38 1997/02/22 09:41:43 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NETINET_TCP_VAR_H_
|
||||
@ -337,7 +337,8 @@ void tcp_canceltimers __P((struct tcpcb *));
|
||||
struct tcpcb *
|
||||
tcp_close __P((struct tcpcb *));
|
||||
void tcp_ctlinput __P((int, struct sockaddr *, void *));
|
||||
int tcp_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
|
||||
int tcp_ctloutput __P((int, struct socket *, int, int, struct mbuf **,
|
||||
struct proc *));
|
||||
struct tcpcb *
|
||||
tcp_drop __P((struct tcpcb *, int));
|
||||
void tcp_drain __P((void));
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
|
||||
* $Id: udp_usrreq.c,v 1.36 1997/03/03 09:23:37 davidg Exp $
|
||||
* $Id: udp_usrreq.c,v 1.37 1997/04/03 05:14:45 davidg Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -91,7 +91,7 @@ SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RD,
|
||||
static struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
|
||||
|
||||
static int udp_output __P((struct inpcb *, struct mbuf *, struct mbuf *,
|
||||
struct mbuf *));
|
||||
struct mbuf *, struct proc *));
|
||||
static void udp_notify __P((struct inpcb *, int));
|
||||
|
||||
void
|
||||
@ -360,10 +360,11 @@ udp_ctlinput(cmd, sa, vip)
|
||||
}
|
||||
|
||||
static int
|
||||
udp_output(inp, m, addr, control)
|
||||
udp_output(inp, m, addr, control, p)
|
||||
register struct inpcb *inp;
|
||||
register struct mbuf *m;
|
||||
struct mbuf *addr, *control;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct udpiphdr *ui;
|
||||
register int len = m->m_pkthdr.len;
|
||||
@ -388,7 +389,7 @@ udp_output(inp, m, addr, control)
|
||||
* Must block input while temporarily connected.
|
||||
*/
|
||||
s = splnet();
|
||||
error = in_pcbconnect(inp, addr);
|
||||
error = in_pcbconnect(inp, addr, p);
|
||||
if (error) {
|
||||
splx(s);
|
||||
goto release;
|
||||
@ -480,7 +481,7 @@ udp_abort(struct socket *so)
|
||||
}
|
||||
|
||||
static int
|
||||
udp_attach(struct socket *so, int proto)
|
||||
udp_attach(struct socket *so, int proto, struct proc *p)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
int s, error;
|
||||
@ -490,7 +491,7 @@ udp_attach(struct socket *so, int proto)
|
||||
return EINVAL;
|
||||
|
||||
s = splnet();
|
||||
error = in_pcballoc(so, &udbinfo);
|
||||
error = in_pcballoc(so, &udbinfo, p);
|
||||
splx(s);
|
||||
if (error)
|
||||
return error;
|
||||
@ -502,7 +503,7 @@ udp_attach(struct socket *so, int proto)
|
||||
}
|
||||
|
||||
static int
|
||||
udp_bind(struct socket *so, struct mbuf *nam)
|
||||
udp_bind(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
int s, error;
|
||||
@ -511,13 +512,13 @@ udp_bind(struct socket *so, struct mbuf *nam)
|
||||
if (inp == 0)
|
||||
return EINVAL;
|
||||
s = splnet();
|
||||
error = in_pcbbind(inp, nam);
|
||||
error = in_pcbbind(inp, nam, p);
|
||||
splx(s);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
udp_connect(struct socket *so, struct mbuf *nam)
|
||||
udp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
int s, error;
|
||||
@ -528,7 +529,7 @@ udp_connect(struct socket *so, struct mbuf *nam)
|
||||
if (inp->inp_faddr.s_addr != INADDR_ANY)
|
||||
return EISCONN;
|
||||
s = splnet();
|
||||
error = in_pcbconnect(inp, nam);
|
||||
error = in_pcbconnect(inp, nam, p);
|
||||
splx(s);
|
||||
if (error == 0)
|
||||
soisconnected(so);
|
||||
@ -572,7 +573,7 @@ udp_disconnect(struct socket *so)
|
||||
|
||||
static int
|
||||
udp_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr,
|
||||
struct mbuf *control)
|
||||
struct mbuf *control, struct proc *p)
|
||||
{
|
||||
struct inpcb *inp;
|
||||
|
||||
@ -581,7 +582,7 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *addr,
|
||||
m_freem(m);
|
||||
return EINVAL;
|
||||
}
|
||||
return udp_output(inp, m, addr, control);
|
||||
return udp_output(inp, m, addr, control, p);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -601,5 +602,5 @@ struct pr_usrreqs udp_usrreqs = {
|
||||
pru_connect2_notsupp, in_control, udp_detach, udp_disconnect,
|
||||
pru_listen_notsupp, in_setpeeraddr, pru_rcvd_notsupp,
|
||||
pru_rcvoob_notsupp, udp_send, pru_sense_null, udp_shutdown,
|
||||
in_setsockaddr
|
||||
in_setsockaddr, sosend, soreceive, soselect
|
||||
};
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
|
||||
* $Id: nfs_socket.c,v 1.22 1997/03/22 06:53:08 bde Exp $
|
||||
* $Id: nfs_socket.c,v 1.23 1997/04/22 17:38:01 dfr Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -192,7 +192,7 @@ nfs_connect(nmp, rep)
|
||||
struct sockaddr_in *sin;
|
||||
struct mbuf *m;
|
||||
u_short tport;
|
||||
struct proc *p = &proc0; /* only used for socreate */
|
||||
struct proc *p = &proc0; /* only used for socreate and sobind */
|
||||
|
||||
nmp->nm_so = (struct socket *)0;
|
||||
saddr = mtod(nmp->nm_nam, struct sockaddr *);
|
||||
@ -201,7 +201,6 @@ nfs_connect(nmp, rep)
|
||||
if (error)
|
||||
goto bad;
|
||||
so = nmp->nm_so;
|
||||
so->so_state &= ~SS_PRIV; /* don't need it */
|
||||
nmp->nm_soflags = so->so_proto->pr_flags;
|
||||
|
||||
/*
|
||||
@ -215,7 +214,7 @@ nfs_connect(nmp, rep)
|
||||
sin->sin_addr.s_addr = INADDR_ANY;
|
||||
tport = IPPORT_RESERVED - 1;
|
||||
sin->sin_port = htons(tport);
|
||||
while ((error = sobind(so, m)) == EADDRINUSE &&
|
||||
while ((error = sobind(so, m, p)) == EADDRINUSE &&
|
||||
--tport > IPPORT_RESERVED / 2)
|
||||
sin->sin_port = htons(tport);
|
||||
m_freem(m);
|
||||
@ -233,7 +232,7 @@ nfs_connect(nmp, rep)
|
||||
goto bad;
|
||||
}
|
||||
} else {
|
||||
error = soconnect(so, nmp->nm_nam);
|
||||
error = soconnect(so, nmp->nm_nam, p);
|
||||
if (error)
|
||||
goto bad;
|
||||
|
||||
@ -282,13 +281,13 @@ nfs_connect(nmp, rep)
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m, p);
|
||||
}
|
||||
if (so->so_proto->pr_protocol == IPPROTO_TCP) {
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m, p);
|
||||
}
|
||||
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR + sizeof (u_long))
|
||||
* 2;
|
||||
@ -414,8 +413,8 @@ nfs_send(so, nam, top, rep)
|
||||
else
|
||||
flags = 0;
|
||||
|
||||
error = sosend(so, sendnam, (struct uio *)0, top,
|
||||
(struct mbuf *)0, flags);
|
||||
error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0,
|
||||
flags);
|
||||
if (error) {
|
||||
if (rep) {
|
||||
log(LOG_INFO, "nfs send error %d for server %s\n",error,
|
||||
@ -533,8 +532,10 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = MSG_WAITALL;
|
||||
error = soreceive(so, (struct mbuf **)0, &auio,
|
||||
(struct mbuf **)0, (struct mbuf **)0, &rcvflg);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0, &auio,
|
||||
(struct mbuf **)0, (struct mbuf **)0,
|
||||
&rcvflg);
|
||||
if (error == EWOULDBLOCK && rep) {
|
||||
if (rep->r_flags & R_SOFTTERM)
|
||||
return (EINTR);
|
||||
@ -566,8 +567,9 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_resid = len;
|
||||
do {
|
||||
rcvflg = MSG_WAITALL;
|
||||
error = soreceive(so, (struct mbuf **)0,
|
||||
&auio, mp, (struct mbuf **)0, &rcvflg);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0,
|
||||
&auio, mp, (struct mbuf **)0, &rcvflg);
|
||||
} while (error == EWOULDBLOCK || error == EINTR ||
|
||||
error == ERESTART);
|
||||
if (!error && auio.uio_resid > 0) {
|
||||
@ -590,7 +592,8 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = 0;
|
||||
error = soreceive(so, (struct mbuf **)0,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0,
|
||||
&auio, mp, &control, &rcvflg);
|
||||
if (control)
|
||||
m_freem(control);
|
||||
@ -632,7 +635,8 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = 0;
|
||||
error = soreceive(so, getnam, &auio, mp,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, getnam, &auio, mp,
|
||||
(struct mbuf **)0, &rcvflg);
|
||||
if (error == EWOULDBLOCK &&
|
||||
(rep->r_flags & R_SOFTTERM))
|
||||
@ -1291,6 +1295,7 @@ nfs_timer(arg)
|
||||
register struct nfssvc_sock *slp;
|
||||
u_quad_t cur_usec;
|
||||
#endif /* NFS_NOSERVER */
|
||||
struct proc *p = &proc0; /* XXX for credentials, will break if sleep */
|
||||
|
||||
s = splnet();
|
||||
for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) {
|
||||
@ -1351,10 +1356,11 @@ nfs_timer(arg)
|
||||
if ((nmp->nm_flag & NFSMNT_NOCONN) == 0)
|
||||
error = (*so->so_proto->pr_usrreqs->pru_send)
|
||||
(so, 0, m, (struct mbuf *)0,
|
||||
(struct mbuf *)0);
|
||||
(struct mbuf *)0, p);
|
||||
else
|
||||
error = (*so->so_proto->pr_usrreqs->pru_send)
|
||||
(so, 0, m, nmp->nm_nam, (struct mbuf *)0);
|
||||
(so, 0, m, nmp->nm_nam, (struct mbuf *)0,
|
||||
p);
|
||||
if (error) {
|
||||
if (NFSIGNORE_SOERROR(nmp->nm_soflags, error))
|
||||
so->so_error = 0;
|
||||
@ -1666,7 +1672,8 @@ nfsrv_rcv(so, arg, waitflag)
|
||||
*/
|
||||
auio.uio_resid = 1000000000;
|
||||
flags = MSG_DONTWAIT;
|
||||
error = soreceive(so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
|
||||
if (error || mp == (struct mbuf *)0) {
|
||||
if (error == EWOULDBLOCK)
|
||||
slp->ns_flag |= SLP_NEEDQ;
|
||||
@ -1700,7 +1707,8 @@ nfsrv_rcv(so, arg, waitflag)
|
||||
do {
|
||||
auio.uio_resid = 1000000000;
|
||||
flags = MSG_DONTWAIT;
|
||||
error = soreceive(so, &nam, &auio, &mp,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, &nam, &auio, &mp,
|
||||
(struct mbuf **)0, &flags);
|
||||
if (mp) {
|
||||
nfs_realign(mp, 10 * NFSX_UNSIGNED);
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
|
||||
* $Id: nfs_syscalls.c,v 1.19 1997/03/22 06:53:11 bde Exp $
|
||||
* $Id: nfs_syscalls.c,v 1.20 1997/03/27 20:01:07 guido Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -105,7 +105,8 @@ static int notstarted = 1;
|
||||
static int modify_flag = 0;
|
||||
static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd,
|
||||
int cacherep));
|
||||
static int nfssvc_addsock __P((struct file *,struct mbuf *));
|
||||
static int nfssvc_addsock __P((struct file *, struct mbuf *,
|
||||
struct proc *));
|
||||
static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *));
|
||||
|
||||
static int nfs_privport = 0;
|
||||
@ -246,7 +247,7 @@ nfssvc(p, uap, retval)
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
error = nfssvc_addsock(fp, nam);
|
||||
error = nfssvc_addsock(fp, nam, p);
|
||||
} else {
|
||||
error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd));
|
||||
if (error)
|
||||
@ -350,9 +351,10 @@ nfssvc(p, uap, retval)
|
||||
* Adds a socket to the list for servicing by nfsds.
|
||||
*/
|
||||
static int
|
||||
nfssvc_addsock(fp, mynam)
|
||||
nfssvc_addsock(fp, mynam, p)
|
||||
struct file *fp;
|
||||
struct mbuf *mynam;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct mbuf *m;
|
||||
register int siz;
|
||||
@ -400,14 +402,14 @@ nfssvc_addsock(fp, mynam)
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m, p);
|
||||
}
|
||||
if (so->so_proto->pr_domain->dom_family == AF_INET &&
|
||||
so->so_proto->pr_protocol == IPPROTO_TCP) {
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m, p);
|
||||
}
|
||||
so->so_rcv.sb_flags &= ~SB_NOINTR;
|
||||
so->so_rcv.sb_timeo = 0;
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
|
||||
* $Id: nfs_syscalls.c,v 1.19 1997/03/22 06:53:11 bde Exp $
|
||||
* $Id: nfs_syscalls.c,v 1.20 1997/03/27 20:01:07 guido Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -105,7 +105,8 @@ static int notstarted = 1;
|
||||
static int modify_flag = 0;
|
||||
static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd,
|
||||
int cacherep));
|
||||
static int nfssvc_addsock __P((struct file *,struct mbuf *));
|
||||
static int nfssvc_addsock __P((struct file *, struct mbuf *,
|
||||
struct proc *));
|
||||
static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *));
|
||||
|
||||
static int nfs_privport = 0;
|
||||
@ -246,7 +247,7 @@ nfssvc(p, uap, retval)
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
error = nfssvc_addsock(fp, nam);
|
||||
error = nfssvc_addsock(fp, nam, p);
|
||||
} else {
|
||||
error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd));
|
||||
if (error)
|
||||
@ -350,9 +351,10 @@ nfssvc(p, uap, retval)
|
||||
* Adds a socket to the list for servicing by nfsds.
|
||||
*/
|
||||
static int
|
||||
nfssvc_addsock(fp, mynam)
|
||||
nfssvc_addsock(fp, mynam, p)
|
||||
struct file *fp;
|
||||
struct mbuf *mynam;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct mbuf *m;
|
||||
register int siz;
|
||||
@ -400,14 +402,14 @@ nfssvc_addsock(fp, mynam)
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m, p);
|
||||
}
|
||||
if (so->so_proto->pr_domain->dom_family == AF_INET &&
|
||||
so->so_proto->pr_protocol == IPPROTO_TCP) {
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m, p);
|
||||
}
|
||||
so->so_rcv.sb_flags &= ~SB_NOINTR;
|
||||
so->so_rcv.sb_timeo = 0;
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
|
||||
* $Id: nfs_socket.c,v 1.22 1997/03/22 06:53:08 bde Exp $
|
||||
* $Id: nfs_socket.c,v 1.23 1997/04/22 17:38:01 dfr Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -192,7 +192,7 @@ nfs_connect(nmp, rep)
|
||||
struct sockaddr_in *sin;
|
||||
struct mbuf *m;
|
||||
u_short tport;
|
||||
struct proc *p = &proc0; /* only used for socreate */
|
||||
struct proc *p = &proc0; /* only used for socreate and sobind */
|
||||
|
||||
nmp->nm_so = (struct socket *)0;
|
||||
saddr = mtod(nmp->nm_nam, struct sockaddr *);
|
||||
@ -201,7 +201,6 @@ nfs_connect(nmp, rep)
|
||||
if (error)
|
||||
goto bad;
|
||||
so = nmp->nm_so;
|
||||
so->so_state &= ~SS_PRIV; /* don't need it */
|
||||
nmp->nm_soflags = so->so_proto->pr_flags;
|
||||
|
||||
/*
|
||||
@ -215,7 +214,7 @@ nfs_connect(nmp, rep)
|
||||
sin->sin_addr.s_addr = INADDR_ANY;
|
||||
tport = IPPORT_RESERVED - 1;
|
||||
sin->sin_port = htons(tport);
|
||||
while ((error = sobind(so, m)) == EADDRINUSE &&
|
||||
while ((error = sobind(so, m, p)) == EADDRINUSE &&
|
||||
--tport > IPPORT_RESERVED / 2)
|
||||
sin->sin_port = htons(tport);
|
||||
m_freem(m);
|
||||
@ -233,7 +232,7 @@ nfs_connect(nmp, rep)
|
||||
goto bad;
|
||||
}
|
||||
} else {
|
||||
error = soconnect(so, nmp->nm_nam);
|
||||
error = soconnect(so, nmp->nm_nam, p);
|
||||
if (error)
|
||||
goto bad;
|
||||
|
||||
@ -282,13 +281,13 @@ nfs_connect(nmp, rep)
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m, p);
|
||||
}
|
||||
if (so->so_proto->pr_protocol == IPPROTO_TCP) {
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m, p);
|
||||
}
|
||||
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR + sizeof (u_long))
|
||||
* 2;
|
||||
@ -414,8 +413,8 @@ nfs_send(so, nam, top, rep)
|
||||
else
|
||||
flags = 0;
|
||||
|
||||
error = sosend(so, sendnam, (struct uio *)0, top,
|
||||
(struct mbuf *)0, flags);
|
||||
error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0,
|
||||
flags);
|
||||
if (error) {
|
||||
if (rep) {
|
||||
log(LOG_INFO, "nfs send error %d for server %s\n",error,
|
||||
@ -533,8 +532,10 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = MSG_WAITALL;
|
||||
error = soreceive(so, (struct mbuf **)0, &auio,
|
||||
(struct mbuf **)0, (struct mbuf **)0, &rcvflg);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0, &auio,
|
||||
(struct mbuf **)0, (struct mbuf **)0,
|
||||
&rcvflg);
|
||||
if (error == EWOULDBLOCK && rep) {
|
||||
if (rep->r_flags & R_SOFTTERM)
|
||||
return (EINTR);
|
||||
@ -566,8 +567,9 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_resid = len;
|
||||
do {
|
||||
rcvflg = MSG_WAITALL;
|
||||
error = soreceive(so, (struct mbuf **)0,
|
||||
&auio, mp, (struct mbuf **)0, &rcvflg);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0,
|
||||
&auio, mp, (struct mbuf **)0, &rcvflg);
|
||||
} while (error == EWOULDBLOCK || error == EINTR ||
|
||||
error == ERESTART);
|
||||
if (!error && auio.uio_resid > 0) {
|
||||
@ -590,7 +592,8 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = 0;
|
||||
error = soreceive(so, (struct mbuf **)0,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0,
|
||||
&auio, mp, &control, &rcvflg);
|
||||
if (control)
|
||||
m_freem(control);
|
||||
@ -632,7 +635,8 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = 0;
|
||||
error = soreceive(so, getnam, &auio, mp,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, getnam, &auio, mp,
|
||||
(struct mbuf **)0, &rcvflg);
|
||||
if (error == EWOULDBLOCK &&
|
||||
(rep->r_flags & R_SOFTTERM))
|
||||
@ -1291,6 +1295,7 @@ nfs_timer(arg)
|
||||
register struct nfssvc_sock *slp;
|
||||
u_quad_t cur_usec;
|
||||
#endif /* NFS_NOSERVER */
|
||||
struct proc *p = &proc0; /* XXX for credentials, will break if sleep */
|
||||
|
||||
s = splnet();
|
||||
for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) {
|
||||
@ -1351,10 +1356,11 @@ nfs_timer(arg)
|
||||
if ((nmp->nm_flag & NFSMNT_NOCONN) == 0)
|
||||
error = (*so->so_proto->pr_usrreqs->pru_send)
|
||||
(so, 0, m, (struct mbuf *)0,
|
||||
(struct mbuf *)0);
|
||||
(struct mbuf *)0, p);
|
||||
else
|
||||
error = (*so->so_proto->pr_usrreqs->pru_send)
|
||||
(so, 0, m, nmp->nm_nam, (struct mbuf *)0);
|
||||
(so, 0, m, nmp->nm_nam, (struct mbuf *)0,
|
||||
p);
|
||||
if (error) {
|
||||
if (NFSIGNORE_SOERROR(nmp->nm_soflags, error))
|
||||
so->so_error = 0;
|
||||
@ -1666,7 +1672,8 @@ nfsrv_rcv(so, arg, waitflag)
|
||||
*/
|
||||
auio.uio_resid = 1000000000;
|
||||
flags = MSG_DONTWAIT;
|
||||
error = soreceive(so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
|
||||
if (error || mp == (struct mbuf *)0) {
|
||||
if (error == EWOULDBLOCK)
|
||||
slp->ns_flag |= SLP_NEEDQ;
|
||||
@ -1700,7 +1707,8 @@ nfsrv_rcv(so, arg, waitflag)
|
||||
do {
|
||||
auio.uio_resid = 1000000000;
|
||||
flags = MSG_DONTWAIT;
|
||||
error = soreceive(so, &nam, &auio, &mp,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, &nam, &auio, &mp,
|
||||
(struct mbuf **)0, &flags);
|
||||
if (mp) {
|
||||
nfs_realign(mp, 10 * NFSX_UNSIGNED);
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
|
||||
* $Id: nfs_socket.c,v 1.22 1997/03/22 06:53:08 bde Exp $
|
||||
* $Id: nfs_socket.c,v 1.23 1997/04/22 17:38:01 dfr Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -192,7 +192,7 @@ nfs_connect(nmp, rep)
|
||||
struct sockaddr_in *sin;
|
||||
struct mbuf *m;
|
||||
u_short tport;
|
||||
struct proc *p = &proc0; /* only used for socreate */
|
||||
struct proc *p = &proc0; /* only used for socreate and sobind */
|
||||
|
||||
nmp->nm_so = (struct socket *)0;
|
||||
saddr = mtod(nmp->nm_nam, struct sockaddr *);
|
||||
@ -201,7 +201,6 @@ nfs_connect(nmp, rep)
|
||||
if (error)
|
||||
goto bad;
|
||||
so = nmp->nm_so;
|
||||
so->so_state &= ~SS_PRIV; /* don't need it */
|
||||
nmp->nm_soflags = so->so_proto->pr_flags;
|
||||
|
||||
/*
|
||||
@ -215,7 +214,7 @@ nfs_connect(nmp, rep)
|
||||
sin->sin_addr.s_addr = INADDR_ANY;
|
||||
tport = IPPORT_RESERVED - 1;
|
||||
sin->sin_port = htons(tport);
|
||||
while ((error = sobind(so, m)) == EADDRINUSE &&
|
||||
while ((error = sobind(so, m, p)) == EADDRINUSE &&
|
||||
--tport > IPPORT_RESERVED / 2)
|
||||
sin->sin_port = htons(tport);
|
||||
m_freem(m);
|
||||
@ -233,7 +232,7 @@ nfs_connect(nmp, rep)
|
||||
goto bad;
|
||||
}
|
||||
} else {
|
||||
error = soconnect(so, nmp->nm_nam);
|
||||
error = soconnect(so, nmp->nm_nam, p);
|
||||
if (error)
|
||||
goto bad;
|
||||
|
||||
@ -282,13 +281,13 @@ nfs_connect(nmp, rep)
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m, p);
|
||||
}
|
||||
if (so->so_proto->pr_protocol == IPPROTO_TCP) {
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m, p);
|
||||
}
|
||||
sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR + sizeof (u_long))
|
||||
* 2;
|
||||
@ -414,8 +413,8 @@ nfs_send(so, nam, top, rep)
|
||||
else
|
||||
flags = 0;
|
||||
|
||||
error = sosend(so, sendnam, (struct uio *)0, top,
|
||||
(struct mbuf *)0, flags);
|
||||
error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0,
|
||||
flags);
|
||||
if (error) {
|
||||
if (rep) {
|
||||
log(LOG_INFO, "nfs send error %d for server %s\n",error,
|
||||
@ -533,8 +532,10 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = MSG_WAITALL;
|
||||
error = soreceive(so, (struct mbuf **)0, &auio,
|
||||
(struct mbuf **)0, (struct mbuf **)0, &rcvflg);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0, &auio,
|
||||
(struct mbuf **)0, (struct mbuf **)0,
|
||||
&rcvflg);
|
||||
if (error == EWOULDBLOCK && rep) {
|
||||
if (rep->r_flags & R_SOFTTERM)
|
||||
return (EINTR);
|
||||
@ -566,8 +567,9 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_resid = len;
|
||||
do {
|
||||
rcvflg = MSG_WAITALL;
|
||||
error = soreceive(so, (struct mbuf **)0,
|
||||
&auio, mp, (struct mbuf **)0, &rcvflg);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0,
|
||||
&auio, mp, (struct mbuf **)0, &rcvflg);
|
||||
} while (error == EWOULDBLOCK || error == EINTR ||
|
||||
error == ERESTART);
|
||||
if (!error && auio.uio_resid > 0) {
|
||||
@ -590,7 +592,8 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = 0;
|
||||
error = soreceive(so, (struct mbuf **)0,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, (struct mbuf **)0,
|
||||
&auio, mp, &control, &rcvflg);
|
||||
if (control)
|
||||
m_freem(control);
|
||||
@ -632,7 +635,8 @@ nfs_receive(rep, aname, mp)
|
||||
auio.uio_procp = p;
|
||||
do {
|
||||
rcvflg = 0;
|
||||
error = soreceive(so, getnam, &auio, mp,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, getnam, &auio, mp,
|
||||
(struct mbuf **)0, &rcvflg);
|
||||
if (error == EWOULDBLOCK &&
|
||||
(rep->r_flags & R_SOFTTERM))
|
||||
@ -1291,6 +1295,7 @@ nfs_timer(arg)
|
||||
register struct nfssvc_sock *slp;
|
||||
u_quad_t cur_usec;
|
||||
#endif /* NFS_NOSERVER */
|
||||
struct proc *p = &proc0; /* XXX for credentials, will break if sleep */
|
||||
|
||||
s = splnet();
|
||||
for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) {
|
||||
@ -1351,10 +1356,11 @@ nfs_timer(arg)
|
||||
if ((nmp->nm_flag & NFSMNT_NOCONN) == 0)
|
||||
error = (*so->so_proto->pr_usrreqs->pru_send)
|
||||
(so, 0, m, (struct mbuf *)0,
|
||||
(struct mbuf *)0);
|
||||
(struct mbuf *)0, p);
|
||||
else
|
||||
error = (*so->so_proto->pr_usrreqs->pru_send)
|
||||
(so, 0, m, nmp->nm_nam, (struct mbuf *)0);
|
||||
(so, 0, m, nmp->nm_nam, (struct mbuf *)0,
|
||||
p);
|
||||
if (error) {
|
||||
if (NFSIGNORE_SOERROR(nmp->nm_soflags, error))
|
||||
so->so_error = 0;
|
||||
@ -1666,7 +1672,8 @@ nfsrv_rcv(so, arg, waitflag)
|
||||
*/
|
||||
auio.uio_resid = 1000000000;
|
||||
flags = MSG_DONTWAIT;
|
||||
error = soreceive(so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
|
||||
if (error || mp == (struct mbuf *)0) {
|
||||
if (error == EWOULDBLOCK)
|
||||
slp->ns_flag |= SLP_NEEDQ;
|
||||
@ -1700,7 +1707,8 @@ nfsrv_rcv(so, arg, waitflag)
|
||||
do {
|
||||
auio.uio_resid = 1000000000;
|
||||
flags = MSG_DONTWAIT;
|
||||
error = soreceive(so, &nam, &auio, &mp,
|
||||
error = so->so_proto->pr_usrreqs->pru_soreceive
|
||||
(so, &nam, &auio, &mp,
|
||||
(struct mbuf **)0, &flags);
|
||||
if (mp) {
|
||||
nfs_realign(mp, 10 * NFSX_UNSIGNED);
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
|
||||
* $Id: nfs_syscalls.c,v 1.19 1997/03/22 06:53:11 bde Exp $
|
||||
* $Id: nfs_syscalls.c,v 1.20 1997/03/27 20:01:07 guido Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -105,7 +105,8 @@ static int notstarted = 1;
|
||||
static int modify_flag = 0;
|
||||
static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd,
|
||||
int cacherep));
|
||||
static int nfssvc_addsock __P((struct file *,struct mbuf *));
|
||||
static int nfssvc_addsock __P((struct file *, struct mbuf *,
|
||||
struct proc *));
|
||||
static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *));
|
||||
|
||||
static int nfs_privport = 0;
|
||||
@ -246,7 +247,7 @@ nfssvc(p, uap, retval)
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
error = nfssvc_addsock(fp, nam);
|
||||
error = nfssvc_addsock(fp, nam, p);
|
||||
} else {
|
||||
error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd));
|
||||
if (error)
|
||||
@ -350,9 +351,10 @@ nfssvc(p, uap, retval)
|
||||
* Adds a socket to the list for servicing by nfsds.
|
||||
*/
|
||||
static int
|
||||
nfssvc_addsock(fp, mynam)
|
||||
nfssvc_addsock(fp, mynam, p)
|
||||
struct file *fp;
|
||||
struct mbuf *mynam;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct mbuf *m;
|
||||
register int siz;
|
||||
@ -400,14 +402,14 @@ nfssvc_addsock(fp, mynam)
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m);
|
||||
sosetopt(so, SOL_SOCKET, SO_KEEPALIVE, m, p);
|
||||
}
|
||||
if (so->so_proto->pr_domain->dom_family == AF_INET &&
|
||||
so->so_proto->pr_protocol == IPPROTO_TCP) {
|
||||
MGET(m, M_WAIT, MT_SOOPTS);
|
||||
*mtod(m, int *) = 1;
|
||||
m->m_len = sizeof(int);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m);
|
||||
sosetopt(so, IPPROTO_TCP, TCP_NODELAY, m, p);
|
||||
}
|
||||
so->so_rcv.sb_flags &= ~SB_NOINTR;
|
||||
so->so_rcv.sb_timeo = 0;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)protosw.h 8.1 (Berkeley) 6/2/93
|
||||
* $Id: protosw.h,v 1.15 1997/02/22 09:45:42 peter Exp $
|
||||
* $Id: protosw.h,v 1.16 1997/03/14 16:51:28 wollman Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_PROTOSW_H_
|
||||
@ -81,12 +81,10 @@ struct protosw {
|
||||
void (*pr_ctlinput)__P((int, struct sockaddr *, void *));
|
||||
/* control input (from below) */
|
||||
int (*pr_ctloutput)__P((int, struct socket *, int, int,
|
||||
struct mbuf **));
|
||||
struct mbuf **, struct proc *));
|
||||
/* control output (from above) */
|
||||
/* user-protocol hook */
|
||||
int (*pr_ousrreq) __P((struct socket *, int, struct mbuf *,
|
||||
struct mbuf *, struct mbuf *));
|
||||
/* user request: see list below */
|
||||
void *pr_ousrreq;
|
||||
/* utility hooks */
|
||||
void (*pr_init) __P((void)); /* initialization hook */
|
||||
void (*pr_fasttimo) __P((void));
|
||||
@ -172,28 +170,32 @@ char *prurequests[] = {
|
||||
|
||||
/*
|
||||
* If the ordering here looks odd, that's because it's alphabetical.
|
||||
* Having this structure separated out from the main protoswitch is actually
|
||||
* Having this structure separated out from the main protoswitch is allegedly
|
||||
* a big (12 cycles per call) lose on high-end CPUs. We will eventually
|
||||
* migrate this stuff back into the main structure.
|
||||
*/
|
||||
struct pr_usrreqs {
|
||||
int (*pru_abort) __P((struct socket *so));
|
||||
int (*pru_accept) __P((struct socket *so, struct mbuf *nam));
|
||||
int (*pru_attach) __P((struct socket *so, int proto));
|
||||
int (*pru_bind) __P((struct socket *so, struct mbuf *nam));
|
||||
int (*pru_connect) __P((struct socket *so, struct mbuf *nam));
|
||||
int (*pru_attach) __P((struct socket *so, int proto,
|
||||
struct proc *p));
|
||||
int (*pru_bind) __P((struct socket *so, struct mbuf *nam,
|
||||
struct proc *p));
|
||||
int (*pru_connect) __P((struct socket *so, struct mbuf *nam,
|
||||
struct proc *p));
|
||||
int (*pru_connect2) __P((struct socket *so1, struct socket *so2));
|
||||
int (*pru_control) __P((struct socket *so, int cmd, caddr_t data,
|
||||
struct ifnet *ifp));
|
||||
struct ifnet *ifp, struct proc *p));
|
||||
int (*pru_detach) __P((struct socket *so));
|
||||
int (*pru_disconnect) __P((struct socket *so));
|
||||
int (*pru_listen) __P((struct socket *so));
|
||||
int (*pru_listen) __P((struct socket *so, struct proc *p));
|
||||
int (*pru_peeraddr) __P((struct socket *so, struct mbuf *nam));
|
||||
int (*pru_rcvd) __P((struct socket *so, int flags));
|
||||
int (*pru_rcvoob) __P((struct socket *so, struct mbuf *m,
|
||||
int flags));
|
||||
int (*pru_send) __P((struct socket *so, int flags, struct mbuf *m,
|
||||
struct mbuf *addr, struct mbuf *control));
|
||||
struct mbuf *addr, struct mbuf *control,
|
||||
struct proc *p));
|
||||
#define PRUS_OOB 0x1
|
||||
#define PRUS_EOF 0x2
|
||||
int (*pru_sense) __P((struct socket *so, struct stat *sb));
|
||||
@ -201,9 +203,12 @@ struct pr_usrreqs {
|
||||
int (*pru_sockaddr) __P((struct socket *so, struct mbuf *nam));
|
||||
|
||||
/*
|
||||
* These two added later, so they are out of order. They are used
|
||||
* These three added later, so they are out of order. They are used
|
||||
* for shortcutting (fast path input/output) in some protocols.
|
||||
* XXX - that's a lie, they are not implemented yet
|
||||
* Rather than calling sosend() etc. directly, calls are made
|
||||
* through these entry points. For protocols which still use
|
||||
* the generic code, these just point to those routines.
|
||||
*/
|
||||
int (*pru_sosend) __P((struct socket *so, struct mbuf *addr,
|
||||
struct uio *uio, struct mbuf *top,
|
||||
@ -211,26 +216,19 @@ struct pr_usrreqs {
|
||||
int (*pru_soreceive) __P((struct socket *so, struct mbuf **paddr,
|
||||
struct uio *uio, struct mbuf **mp0,
|
||||
struct mbuf **controlp, int *flagsp));
|
||||
int (*pru_soselect) __P((struct socket *so, int which,
|
||||
struct proc *p));
|
||||
};
|
||||
|
||||
int pru_accept_notsupp __P((struct socket *so, struct mbuf *nam));
|
||||
int pru_connect2_notsupp __P((struct socket *so1, struct socket *so2));
|
||||
int pru_listen_notsupp __P((struct socket *so));
|
||||
int pru_control_notsupp __P((struct socket *so, int cmd, caddr_t data,
|
||||
struct ifnet *ifp, struct proc *p));
|
||||
int pru_listen_notsupp __P((struct socket *so, struct proc *p));
|
||||
int pru_rcvd_notsupp __P((struct socket *so, int flags));
|
||||
int pru_rcvoob_notsupp __P((struct socket *so, struct mbuf *m, int flags));
|
||||
int pru_sense_null __P((struct socket *so, struct stat *sb));
|
||||
|
||||
#define PRU_OLDSTYLE
|
||||
|
||||
#ifdef PRU_OLDSTYLE
|
||||
/*
|
||||
* Protocols which don't yet implement pr_usrreqs can point it to this
|
||||
* structure, which will call the old pr_usrreq() entry point with the
|
||||
* appropriate arguments.
|
||||
*/
|
||||
extern struct pr_usrreqs pru_oldstyle;
|
||||
#endif /* PRU_OLDSTYLE */
|
||||
|
||||
#endif /* KERNEL */
|
||||
|
||||
/*
|
||||
@ -279,7 +277,7 @@ char *prcrequests[] = {
|
||||
|
||||
/*
|
||||
* The arguments to ctloutput are:
|
||||
* (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
|
||||
* (*protosw[].pr_ctloutput)(req, so, level, optname, optval, p);
|
||||
* req is one of the actions listed below, so is a (struct socket *),
|
||||
* level is an indication of which protocol layer the option is intended.
|
||||
* optname is a protocol dependent socket option request,
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)socketvar.h 8.3 (Berkeley) 2/19/95
|
||||
* $Id$
|
||||
* $Id: socketvar.h,v 1.18 1997/02/22 09:45:56 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SOCKETVAR_H_
|
||||
@ -115,7 +115,7 @@ struct socket {
|
||||
#define SS_CANTRCVMORE 0x0020 /* can't receive more data from peer */
|
||||
#define SS_RCVATMARK 0x0040 /* at mark on input */
|
||||
|
||||
#define SS_PRIV 0x0080 /* privileged for broadcast, raw... */
|
||||
/*efine SS_PRIV 0x0080 privileged for broadcast, raw... */
|
||||
#define SS_NBIO 0x0100 /* non-blocking ops */
|
||||
#define SS_ASYNC 0x0200 /* async i/o notify */
|
||||
#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */
|
||||
@ -241,24 +241,24 @@ int sbwait __P((struct sockbuf *sb));
|
||||
int sb_lock __P((struct sockbuf *sb));
|
||||
int soabort __P((struct socket *so));
|
||||
int soaccept __P((struct socket *so, struct mbuf *nam));
|
||||
int sobind __P((struct socket *so, struct mbuf *nam));
|
||||
int sobind __P((struct socket *so, struct mbuf *nam, struct proc *p));
|
||||
void socantrcvmore __P((struct socket *so));
|
||||
void socantsendmore __P((struct socket *so));
|
||||
int soclose __P((struct socket *so));
|
||||
int soconnect __P((struct socket *so, struct mbuf *nam));
|
||||
int soconnect __P((struct socket *so, struct mbuf *nam, struct proc *p));
|
||||
int soconnect2 __P((struct socket *so1, struct socket *so2));
|
||||
int socreate __P((int dom, struct socket **aso, int type, int proto,
|
||||
struct proc *p));
|
||||
int sodisconnect __P((struct socket *so));
|
||||
void sofree __P((struct socket *so));
|
||||
int sogetopt __P((struct socket *so, int level, int optname,
|
||||
struct mbuf **mp));
|
||||
struct mbuf **mp, struct proc *p));
|
||||
void sohasoutofband __P((struct socket *so));
|
||||
void soisconnected __P((struct socket *so));
|
||||
void soisconnecting __P((struct socket *so));
|
||||
void soisdisconnected __P((struct socket *so));
|
||||
void soisdisconnecting __P((struct socket *so));
|
||||
int solisten __P((struct socket *so, int backlog));
|
||||
int solisten __P((struct socket *so, int backlog, struct proc *p));
|
||||
struct socket *
|
||||
sodropablereq __P((struct socket *head));
|
||||
struct socket *
|
||||
@ -267,10 +267,11 @@ int soreceive __P((struct socket *so, struct mbuf **paddr, struct uio *uio,
|
||||
struct mbuf **mp0, struct mbuf **controlp, int *flagsp));
|
||||
int soreserve __P((struct socket *so, u_long sndcc, u_long rcvcc));
|
||||
void sorflush __P((struct socket *so));
|
||||
int soselect __P((struct socket *so, int which, struct proc *p));
|
||||
int sosend __P((struct socket *so, struct mbuf *addr, struct uio *uio,
|
||||
struct mbuf *top, struct mbuf *control, int flags));
|
||||
int sosetopt __P((struct socket *so, int level, int optname,
|
||||
struct mbuf *m0));
|
||||
struct mbuf *m0, struct proc *p));
|
||||
int soshutdown __P((struct socket *so, int how));
|
||||
void sowakeup __P((struct socket *so, struct sockbuf *sb));
|
||||
#endif /* KERNEL */
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)un.h 8.3 (Berkeley) 2/19/95
|
||||
* $Id$
|
||||
* $Id: un.h,v 1.11 1997/02/22 09:46:20 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_UN_H_
|
||||
@ -58,6 +58,7 @@ int uipc_usrreq __P((struct socket *so, int req, struct mbuf *m,
|
||||
int unp_connect2 __P((struct socket *so, struct socket *so2));
|
||||
void unp_dispose __P((struct mbuf *m));
|
||||
int unp_externalize __P((struct mbuf *rights));
|
||||
extern struct pr_usrreqs uipc_usrreqs;
|
||||
#else /* !KERNEL */
|
||||
|
||||
/* actual length of an initialized sockaddr_un */
|
||||
|
Loading…
Reference in New Issue
Block a user