version 1.7, 1993/10/26 22:36:25 |
version 1.14, 1994/05/04 11:24:06 |
|
|
* $Id$ |
* $Id$ |
*/ |
*/ |
|
|
#include "param.h" |
#include <sys/param.h> |
#include "systm.h" |
#include <sys/systm.h> |
#include "proc.h" |
#include <sys/proc.h> |
#include "file.h" |
#include <sys/file.h> |
#include "malloc.h" |
#include <sys/malloc.h> |
#include "mbuf.h" |
#include <sys/mbuf.h> |
#include "domain.h" |
#include <sys/domain.h> |
#include "kernel.h" |
#include <sys/kernel.h> |
#include "select.h" |
#include <sys/protosw.h> |
#include "protosw.h" |
#include <sys/socket.h> |
#include "socket.h" |
#include <sys/socketvar.h> |
#include "socketvar.h" |
#include <sys/resourcevar.h> |
#include "resourcevar.h" |
|
|
|
/* |
/* |
* Socket operation routines. |
* Socket operation routines. |
|
|
/*ARGSUSED*/ |
/*ARGSUSED*/ |
int |
int |
socreate(dom, aso, type, proto) |
socreate(dom, aso, type, proto) |
|
int dom; |
struct socket **aso; |
struct socket **aso; |
register int type; |
register int type; |
int proto; |
int proto; |
Line 89 socreate(dom, aso, type, proto) |
|
Line 89 socreate(dom, aso, type, proto) |
|
sofree(so); |
sofree(so); |
return (error); |
return (error); |
} |
} |
|
#ifdef COMPAT_SUNOS |
|
if (p->p_emul == EMUL_SUNOS && type == SOCK_DGRAM) |
|
so->so_options |= SO_BROADCAST; |
|
#endif |
*aso = so; |
*aso = so; |
return (0); |
return (0); |
} |
} |
Line 321 sosend(so, addr, uio, top, control, flag |
|
Line 325 sosend(so, addr, uio, top, control, flag |
|
struct mbuf *control; |
struct mbuf *control; |
int flags; |
int flags; |
{ |
{ |
struct proc *p = curproc; /* XXX */ |
struct proc *p = curproc; /* XXX */ |
struct mbuf **mp; |
struct mbuf **mp; |
register struct mbuf *m; |
register struct mbuf *m; |
register long space, len, resid; |
register long space, len, resid; |
|
|
space = sbspace(&so->so_snd); |
space = sbspace(&so->so_snd); |
if (flags & MSG_OOB) |
if (flags & MSG_OOB) |
space += 1024; |
space += 1024; |
if (space < resid + clen && |
if (atomic && resid > so->so_snd.sb_hiwat || |
|
clen > so->so_snd.sb_hiwat) |
|
snderr(EMSGSIZE); |
|
if (space < resid + clen && uio && |
(atomic || space < so->so_snd.sb_lowat || space < clen)) { |
(atomic || space < so->so_snd.sb_lowat || space < clen)) { |
if (atomic && resid > so->so_snd.sb_hiwat || |
|
clen > so->so_snd.sb_hiwat) |
|
snderr(EMSGSIZE); |
|
if (so->so_state & SS_NBIO) |
if (so->so_state & SS_NBIO) |
snderr(EWOULDBLOCK); |
snderr(EWOULDBLOCK); |
sbunlock(&so->so_snd); |
sbunlock(&so->so_snd); |
|
|
if ((m->m_flags & M_EXT) == 0) |
if ((m->m_flags & M_EXT) == 0) |
goto nopages; |
goto nopages; |
mlen = MCLBYTES; |
mlen = MCLBYTES; |
#ifdef MAPPED_MBUFS |
len = min(min(mlen, resid), space); |
len = min(MCLBYTES, resid); |
|
#else |
|
if (atomic && top == 0) { |
|
len = min(MCLBYTES - max_hdr, resid); |
|
m->m_data += max_hdr; |
|
} else |
|
len = min(MCLBYTES, resid); |
|
#endif |
|
len = min(len, space); |
|
space -= len; |
|
} else { |
} else { |
nopages: |
nopages: |
len = min(min(mlen, resid), space); |
len = min(min(mlen, resid), space); |
space -= len; |
|
/* |
/* |
* For datagram protocols, leave room |
* For datagram protocols, leave room |
* for protocol headers in first mbuf. |
* for protocol headers in first mbuf. |
|
|
if (atomic && top == 0 && len < mlen) |
if (atomic && top == 0 && len < mlen) |
MH_ALIGN(m, len); |
MH_ALIGN(m, len); |
} |
} |
|
space -= len; |
error = uiomove(mtod(m, caddr_t), (int)len, uio); |
error = uiomove(mtod(m, caddr_t), (int)len, uio); |
resid = uio->uio_resid; |
resid = uio->uio_resid; |
m->m_len = len; |
m->m_len = len; |
Line 498 soreceive(so, paddr, uio, mp0, controlp, |
|
Line 492 soreceive(so, paddr, uio, mp0, controlp, |
|
struct mbuf **controlp; |
struct mbuf **controlp; |
int *flagsp; |
int *flagsp; |
{ |
{ |
struct proc *p = curproc; /* XXX */ |
struct proc *p = curproc; /* XXX */ |
register struct mbuf *m, **mp; |
register struct mbuf *m, **mp; |
register int flags, len, error, s, offset; |
register int flags, len, error, s, offset; |
struct protosw *pr = so->so_proto; |
struct protosw *pr = so->so_proto; |
|
|
return (error); |
return (error); |
} |
} |
|
|
|
int |
soshutdown(so, how) |
soshutdown(so, how) |
register struct socket *so; |
register struct socket *so; |
register int how; |
register int how; |
Line 801 soshutdown(so, how) |
|
Line 796 soshutdown(so, how) |
|
return (0); |
return (0); |
} |
} |
|
|
|
void |
sorflush(so) |
sorflush(so) |
register struct socket *so; |
register struct socket *so; |
{ |
{ |
|
|
sbrelease(&asb); |
sbrelease(&asb); |
} |
} |
|
|
|
int |
sosetopt(so, level, optname, m0) |
sosetopt(so, level, optname, m0) |
register struct socket *so; |
register struct socket *so; |
int level, optname; |
int level, optname; |
|
|
return (error); |
return (error); |
} |
} |
|
|
|
int |
sogetopt(so, level, optname, mp) |
sogetopt(so, level, optname, mp) |
register struct socket *so; |
register struct socket *so; |
int level, optname; |
int level, optname; |
Line 1015 sogetopt(so, level, optname, mp) |
|
Line 1013 sogetopt(so, level, optname, mp) |
|
} |
} |
} |
} |
|
|
|
void |
sohasoutofband(so) |
sohasoutofband(so) |
register struct socket *so; |
register struct socket *so; |
{ |
{ |