version 1.54.2.3, 2001/06/21 20:07:07 |
version 1.63, 2002/04/06 08:04:17 |
|
|
* @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95 |
* @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95 |
*/ |
*/ |
|
|
#include "opt_compat_sunos.h" |
#include <sys/cdefs.h> |
|
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/systm.h> |
#include <sys/systm.h> |
#include <sys/lwp.h> |
|
#include <sys/proc.h> |
#include <sys/proc.h> |
#include <sys/file.h> |
#include <sys/file.h> |
#include <sys/malloc.h> |
#include <sys/malloc.h> |
|
|
{ |
{ |
|
|
pool_init(&socket_pool, sizeof(struct socket), 0, 0, 0, |
pool_init(&socket_pool, sizeof(struct socket), 0, 0, 0, |
"sockpl", 0, NULL, NULL, M_SOCKET); |
"sockpl", NULL); |
} |
} |
|
|
/* |
/* |
Line 82 socreate(int dom, struct socket **aso, i |
|
Line 82 socreate(int dom, struct socket **aso, i |
|
struct socket *so; |
struct socket *so; |
int error, s; |
int error, s; |
|
|
p = curproc->l_proc; /* XXX */ |
p = curproc; /* XXX */ |
if (proto) |
if (proto) |
prp = pffindproto(dom, proto, type); |
prp = pffindproto(dom, proto, type); |
else |
else |
Line 110 socreate(int dom, struct socket **aso, i |
|
Line 110 socreate(int dom, struct socket **aso, i |
|
splx(s); |
splx(s); |
return (error); |
return (error); |
} |
} |
#ifdef COMPAT_SUNOS |
|
{ |
|
extern struct emul emul_sunos; |
|
if (p->p_emul == &emul_sunos && type == SOCK_DGRAM) |
|
so->so_options |= SO_BROADCAST; |
|
} |
|
#endif |
|
splx(s); |
splx(s); |
*aso = so; |
*aso = so; |
return (0); |
return (0); |
Line 146 solisten(struct socket *so, int backlog) |
|
Line 139 solisten(struct socket *so, int backlog) |
|
splx(s); |
splx(s); |
return (error); |
return (error); |
} |
} |
if (so->so_q.tqh_first == NULL) |
if (TAILQ_EMPTY(&so->so_q)) |
so->so_options |= SO_ACCEPTCONN; |
so->so_options |= SO_ACCEPTCONN; |
if (backlog < 0) |
if (backlog < 0) |
backlog = 0; |
backlog = 0; |
Line 189 soclose(struct socket *so) |
|
Line 182 soclose(struct socket *so) |
|
error = 0; |
error = 0; |
s = splsoftnet(); /* conservative */ |
s = splsoftnet(); /* conservative */ |
if (so->so_options & SO_ACCEPTCONN) { |
if (so->so_options & SO_ACCEPTCONN) { |
while ((so2 = so->so_q0.tqh_first) != 0) { |
while ((so2 = TAILQ_FIRST(&so->so_q0)) != 0) { |
(void) soqremque(so2, 0); |
(void) soqremque(so2, 0); |
(void) soabort(so2); |
(void) soabort(so2); |
} |
} |
while ((so2 = so->so_q.tqh_first) != 0) { |
while ((so2 = TAILQ_FIRST(&so->so_q)) != 0) { |
(void) soqremque(so2, 1); |
(void) soqremque(so2, 1); |
(void) soabort(so2); |
(void) soabort(so2); |
} |
} |
Line 274 soconnect(struct socket *so, struct mbuf |
|
Line 267 soconnect(struct socket *so, struct mbuf |
|
struct proc *p; |
struct proc *p; |
int s, error; |
int s, error; |
|
|
p = curproc->l_proc; /* XXX */ |
p = curproc; /* XXX */ |
if (so->so_options & SO_ACCEPTCONN) |
if (so->so_options & SO_ACCEPTCONN) |
return (EOPNOTSUPP); |
return (EOPNOTSUPP); |
s = splsoftnet(); |
s = splsoftnet(); |
Line 354 sosend(struct socket *so, struct mbuf *a |
|
Line 347 sosend(struct socket *so, struct mbuf *a |
|
{ |
{ |
struct proc *p; |
struct proc *p; |
struct mbuf **mp, *m; |
struct mbuf **mp, *m; |
long space, len, resid; |
long space, len, resid, clen, mlen; |
int clen, error, s, dontroute, mlen, atomic; |
int error, s, dontroute, atomic; |
|
|
p = curproc->l_proc; /* XXX */ |
p = curproc; /* XXX */ |
clen = 0; |
clen = 0; |
atomic = sosendallatonce(so) || top; |
atomic = sosendallatonce(so) || top; |
if (uio) |
if (uio) |
Line 448 sosend(struct socket *so, struct mbuf *a |
|
Line 441 sosend(struct socket *so, struct mbuf *a |
|
goto nopages; |
goto nopages; |
mlen = MCLBYTES; |
mlen = MCLBYTES; |
#ifdef MAPPED_MBUFS |
#ifdef MAPPED_MBUFS |
len = min(MCLBYTES, resid); |
len = lmin(MCLBYTES, resid); |
#else |
#else |
if (atomic && top == 0) { |
if (atomic && top == 0) { |
len = min(MCLBYTES - max_hdr, |
len = lmin(MCLBYTES - max_hdr, |
resid); |
resid); |
m->m_data += max_hdr; |
m->m_data += max_hdr; |
} else |
} else |
len = min(MCLBYTES, resid); |
len = lmin(MCLBYTES, resid); |
#endif |
#endif |
space -= len; |
space -= len; |
} else { |
} else { |
nopages: |
nopages: |
len = min(min(mlen, resid), space); |
len = lmin(lmin(mlen, resid), space); |
space -= len; |
space -= len; |
/* |
/* |
* For datagram protocols, leave room |
* For datagram protocols, leave room |
Line 737 soreceive(struct socket *so, struct mbuf |
|
Line 730 soreceive(struct socket *so, struct mbuf |
|
splx(s); |
splx(s); |
error = uiomove(mtod(m, caddr_t) + moff, (int)len, uio); |
error = uiomove(mtod(m, caddr_t) + moff, (int)len, uio); |
s = splsoftnet(); |
s = splsoftnet(); |
|
if (error) |
|
goto release; |
} else |
} else |
uio->uio_resid -= len; |
uio->uio_resid -= len; |
if (len == m->m_len - moff) { |
if (len == m->m_len - moff) { |