version 1.40, 1998/12/16 00:26:10 |
version 1.44.6.1, 1999/06/28 06:36:53 |
|
|
"sockpl", 0, NULL, NULL, M_SOCKET); |
"sockpl", 0, NULL, NULL, M_SOCKET); |
} |
} |
|
|
|
#ifdef KEY |
|
#include <netkey/key.h> |
|
#endif |
|
|
/* |
/* |
* Socket operation routines. |
* Socket operation routines. |
* These routines are called by the routines in |
* These routines are called by the routines in |
Line 100 socreate(dom, aso, type, proto) |
|
Line 104 socreate(dom, aso, type, proto) |
|
so->so_proto = prp; |
so->so_proto = prp; |
so->so_send = sosend; |
so->so_send = sosend; |
so->so_receive = soreceive; |
so->so_receive = soreceive; |
|
if (p != 0) |
|
so->so_uid = p->p_ucred->cr_uid; |
error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0, |
error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0, |
(struct mbuf *)(long)proto, (struct mbuf *)0, p); |
(struct mbuf *)(long)proto, (struct mbuf *)0, p); |
if (error) { |
if (error) { |
|
|
register struct socket *so; |
register struct socket *so; |
{ |
{ |
|
|
if (so->so_pcb || (so->so_state & SS_NOFDREF) == 0) |
if (so->so_pcb |
|
#ifdef MAPPED_ADDR_ENABLED |
|
/* |
|
* MAPPED_ADDR implementation spec: |
|
* Check so_pcb2 despite the ip6_mapped_addr value. |
|
* Because the sysctl value may be changed to 0 |
|
* after connection establishment. |
|
*/ |
|
|| so->so_pcb2 |
|
#endif /* MAPPED_ADDR_ENABLED */ |
|
|| (so->so_state & SS_NOFDREF) == 0) |
return; |
return; |
if (so->so_head) { |
if (so->so_head) { |
if (!soqremque(so, 0) && !soqremque(so, 1)) |
/* |
panic("sofree dq"); |
* We must not decommission a socket that's on the accept(2) |
so->so_head = 0; |
* queue. If we do, then accept(2) may hang after select(2) |
|
* indicated that the listening socket was ready. |
|
*/ |
|
if (!soqremque(so, 0)) |
|
return; |
} |
} |
sbrelease(&so->so_snd); |
sbrelease(&so->so_snd); |
sorflush(so); |
sorflush(so); |
|
|
soclose(so) |
soclose(so) |
register struct socket *so; |
register struct socket *so; |
{ |
{ |
|
struct socket *so2; |
int s = splsoftnet(); /* conservative */ |
int s = splsoftnet(); /* conservative */ |
int error = 0; |
int error = 0; |
|
|
if (so->so_options & SO_ACCEPTCONN) { |
if (so->so_options & SO_ACCEPTCONN) { |
while (so->so_q0.tqh_first) |
while ((so2 = so->so_q0.tqh_first) != 0) { |
(void) soabort(so->so_q0.tqh_first); |
(void) soqremque(so2, 0); |
while (so->so_q.tqh_first) |
(void) soabort(so2); |
(void) soabort(so->so_q.tqh_first); |
} |
|
while ((so2 = so->so_q.tqh_first) != 0) { |
|
(void) soqremque(so2, 1); |
|
(void) soabort(so2); |
|
} |
} |
} |
if (so->so_pcb == 0) |
if (so->so_pcb == 0 |
|
#ifdef MAPPED_ADDR_ENABLED |
|
&& so->so_pcb2 == 0 |
|
#endif /* MAPPED_ADDR_ENABLED */ |
|
) |
goto discard; |
goto discard; |
if (so->so_state & SS_ISCONNECTED) { |
if (so->so_state & SS_ISCONNECTED) { |
if ((so->so_state & SS_ISDISCONNECTING) == 0) { |
if ((so->so_state & SS_ISDISCONNECTING) == 0) { |
|
|
} |
} |
} |
} |
drop: |
drop: |
if (so->so_pcb) { |
if (so->so_pcb |
|
#ifdef MAPPED_ADDR_ENABLED |
|
|| so->so_pcb2 |
|
#endif /* MAPPED_ADDR_ENABLED */ |
|
) { |
int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, |
int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, |
(struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, |
(struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, |
(struct proc *)0); |
(struct proc *)0); |
Line 253 soaccept(so, nam) |
|
Line 286 soaccept(so, nam) |
|
if ((so->so_state & SS_NOFDREF) == 0) |
if ((so->so_state & SS_NOFDREF) == 0) |
panic("soaccept: !NOFDREF"); |
panic("soaccept: !NOFDREF"); |
so->so_state &= ~SS_NOFDREF; |
so->so_state &= ~SS_NOFDREF; |
error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT, (struct mbuf *)0, |
if ((so->so_state & SS_ISDISCONNECTED) == 0) |
nam, (struct mbuf *)0, (struct proc *)0); |
error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT, |
|
(struct mbuf *)0, nam, (struct mbuf *)0, (struct proc *)0); |
|
else |
|
error = 0; |
splx(s); |
splx(s); |
return (error); |
return (error); |
} |
} |
|
|
if ((flags & MSG_PEEK) == 0) { |
if ((flags & MSG_PEEK) == 0) { |
if (m == 0) |
if (m == 0) |
so->so_rcv.sb_mb = nextrecord; |
so->so_rcv.sb_mb = nextrecord; |
if (pr->pr_flags & PR_WANTRCVD && so->so_pcb) |
if (pr->pr_flags & PR_WANTRCVD && |
|
(so->so_pcb |
|
#ifdef MAPPED_ADDR_ENABLED |
|
|| so->so_pcb2 |
|
#endif /* MAPPED_ADDR_ENABLED */ |
|
) |
|
) |
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, |
(*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, |
(struct mbuf *)(long)flags, (struct mbuf *)0, |
(struct mbuf *)(long)flags, (struct mbuf *)0, |
(struct proc *)0); |
(struct proc *)0); |