version 1.54.2.3, 2001/06/21 20:07:07 |
version 1.60, 2002/01/03 01:11:26 |
|
|
* @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95 |
* @(#)uipc_socket.c 8.6 (Berkeley) 5/2/95 |
*/ |
*/ |
|
|
|
#include <sys/cdefs.h> |
|
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
#include "opt_compat_sunos.h" |
#include "opt_compat_sunos.h" |
|
|
#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> |
Line 82 socreate(int dom, struct socket **aso, i |
|
Line 84 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 112 socreate(int dom, struct socket **aso, i |
|
splx(s); |
splx(s); |
return (error); |
return (error); |
} |
} |
#ifdef COMPAT_SUNOS |
#if defined(COMPAT_SUNOS) && 0 /* moved into compat/sunos */ |
{ |
{ |
extern struct emul emul_sunos; |
extern struct emul emul_sunos; |
if (p->p_emul == &emul_sunos && type == SOCK_DGRAM) |
if (p->p_emul == &emul_sunos && type == SOCK_DGRAM) |
Line 274 soconnect(struct socket *so, struct mbuf |
|
Line 276 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 356 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 450 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 739 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) { |