some more clean up and renaming
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1794 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -136,7 +136,7 @@ struct socket {
|
||||
* Returns error without lock if sleep is interrupted.
|
||||
*/
|
||||
#define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \
|
||||
(((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
|
||||
(((wf) == M_WAITOK) ? sockbuf_lock(sb) : EWOULDBLOCK) : \
|
||||
((sb)->sb_flags |= SB_LOCK), 0)
|
||||
|
||||
/* release lock on sockbuf sb */
|
||||
|
||||
@@ -67,22 +67,23 @@
|
||||
# define ifaof_ifpforaddr core->ifaof_ifpforaddr
|
||||
# define ifafree core->ifafree
|
||||
|
||||
# define sbappend core->sbappend
|
||||
# define sbappendaddr core->sbappendaddr
|
||||
# define sbdrop core->sbdrop
|
||||
# define sbflush core->sbflush
|
||||
# define sbreserve core->sbreserve
|
||||
# define sockbuf_append core->sockbuf_append
|
||||
# define sockbuf_appendaddr core->sockbuf_appendaddr
|
||||
# define sockbuf_drop core->sockbuf_drop
|
||||
# define sockbuf_flush core->sockbuf_flush
|
||||
# define sockbuf_reserve core->sockbuf_reserve
|
||||
|
||||
# define soreserve core->soreserve
|
||||
# define sowakeup core->sowakeup
|
||||
# define sonewconn core->sonewconn
|
||||
# define soisconnected core->soisconnected
|
||||
# define soisconnecting core->soisconnecting
|
||||
# define soisdisconnected core->soisdisconnected
|
||||
# define soisdisconnecting core->soisdisconnecting
|
||||
# define sohasoutofband core->sohasoutofband
|
||||
# define socantsendmore core->socantsendmore
|
||||
# define socantrcvmore core->socantrcvmore
|
||||
|
||||
# define socket_set_connected core->socket_set_connected
|
||||
# define socket_set_connecting core->socket_set_connecting
|
||||
# define socket_set_disconnected core->socket_set_disconnected
|
||||
# define socket_set_disconnecting core->socket_set_disconnecting
|
||||
# define socket_set_hasoutofband core->socket_set_hasoutofband
|
||||
# define socket_set_cantsendmore core->socket_set_cantsendmore
|
||||
# define socket_set_cantrcvmore core->socket_set_cantrcvmore
|
||||
|
||||
# define rtfree core->rtfree
|
||||
# define rtalloc core->rtalloc
|
||||
|
||||
@@ -44,20 +44,20 @@ struct core_module_info {
|
||||
/* socket functions - called "internally" */
|
||||
struct socket *(*sonewconn)(struct socket *, int);
|
||||
int (*soreserve)(struct socket *, uint32, uint32);
|
||||
int (*sbreserve)(struct sockbuf *, uint32);
|
||||
void (*sbappend)(struct sockbuf *, struct mbuf *);
|
||||
int (*sbappendaddr)(struct sockbuf *, struct sockaddr *,
|
||||
int (*sockbuf_reserve)(struct sockbuf *, uint32);
|
||||
void (*sockbuf_append)(struct sockbuf *, struct mbuf *);
|
||||
int (*sockbuf_appendaddr)(struct sockbuf *, struct sockaddr *,
|
||||
struct mbuf *, struct mbuf *);
|
||||
void (*sbdrop)(struct sockbuf *, int);
|
||||
void (*sbflush)(struct sockbuf *sb);
|
||||
void (*sockbuf_drop)(struct sockbuf *, int);
|
||||
void (*sockbuf_flush)(struct sockbuf *sb);
|
||||
void (*sowakeup)(struct socket *, struct sockbuf *);
|
||||
void (*soisconnected)(struct socket *);
|
||||
void (*soisconnecting)(struct socket*);
|
||||
void (*soisdisconnected)(struct socket *);
|
||||
void (*soisdisconnecting)(struct socket *);
|
||||
void (*sohasoutofband)(struct socket *so);
|
||||
void (*socantrcvmore)(struct socket*);
|
||||
void (*socantsendmore)(struct socket *);
|
||||
void (*socket_set_connected)(struct socket *so);
|
||||
void (*socket_set_connecting)(struct socket *so);
|
||||
void (*socket_set_disconnected)(struct socket *so);
|
||||
void (*socket_set_disconnecting)(struct socket *so);
|
||||
void (*socket_set_hasoutofband)(struct socket *so);
|
||||
void (*socket_set_cantrcvmore)(struct socket *so);
|
||||
void (*socket_set_cantsendmore)(struct socket *so);
|
||||
|
||||
/* pcb options */
|
||||
int (*in_pcballoc)(struct socket *, struct inpcb *);
|
||||
|
||||
@@ -37,48 +37,40 @@ int socket_set_event_callback(struct socket *so, socket_event_callback, void *,
|
||||
* other network modules.
|
||||
*/
|
||||
|
||||
int sosend(struct socket *so, struct mbuf *addr, struct uio *uio,
|
||||
struct mbuf *top, struct mbuf *control, int flags);
|
||||
|
||||
struct socket *sonewconn(struct socket *head, int connstatus);
|
||||
int soreserve (struct socket *so, uint32 sndcc, uint32 rcvcc);
|
||||
|
||||
void sbrelease (struct sockbuf *sb);
|
||||
int sbreserve (struct sockbuf *sb, uint32 cc);
|
||||
void sbdrop (struct sockbuf *sb, int len);
|
||||
void sbdroprecord (struct sockbuf *sb);
|
||||
void sbflush (struct sockbuf *sb);
|
||||
int sbwait (struct sockbuf *sb);
|
||||
void sbappend (struct sockbuf *sb, struct mbuf *m);
|
||||
int sbappendaddr (struct sockbuf *sb, struct sockaddr *asa,
|
||||
void sockbuf_release(struct sockbuf *sb);
|
||||
int sockbuf_reserve(struct sockbuf *sb, uint32 cc);
|
||||
void sockbuf_drop(struct sockbuf *sb, int len);
|
||||
void sockbuf_droprecord(struct sockbuf *sb);
|
||||
void sockbuf_flush(struct sockbuf *sb);
|
||||
int sockbuf_wait(struct sockbuf *sb);
|
||||
void sockbuf_append(struct sockbuf *sb, struct mbuf *m);
|
||||
int sockbuf_appendaddr(struct sockbuf *sb, struct sockaddr *asa,
|
||||
struct mbuf *m0, struct mbuf *control);
|
||||
int sbappendcontrol (struct sockbuf *sb, struct mbuf *m0,
|
||||
int sockbuf_appendcontrol(struct sockbuf *sb, struct mbuf *m0,
|
||||
struct mbuf *control);
|
||||
void sbappendrecord (struct sockbuf *sb, struct mbuf *m0);
|
||||
void sbcheck (struct sockbuf *sb);
|
||||
void sbcompress (struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
|
||||
void sbinsertoob(struct sockbuf *, struct mbuf *);
|
||||
void sockbuf_appendrecord(struct sockbuf *sb, struct mbuf *m0);
|
||||
void sockbuf_compress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
|
||||
void sockbuf_insertoob(struct sockbuf *, struct mbuf *);
|
||||
|
||||
int soreceive (struct socket *so, struct mbuf **paddr, struct uio *uio,
|
||||
struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
|
||||
void sowakeup(struct socket *so, struct sockbuf *sb);
|
||||
int sbwait(struct sockbuf *sb);
|
||||
|
||||
int sodisconnect(struct socket *);
|
||||
void sofree(struct socket *);
|
||||
|
||||
void sohasoutofband(struct socket *so);
|
||||
void socantsendmore(struct socket *so);
|
||||
void socantrcvmore(struct socket *so);
|
||||
void soisconnected (struct socket *so);
|
||||
void soisconnecting (struct socket *so);
|
||||
void soisdisconnected (struct socket *so);
|
||||
void soisdisconnecting (struct socket *so);
|
||||
void soqinsque (struct socket *head, struct socket *so, int q);
|
||||
int soqremque (struct socket *so, int q);
|
||||
void socket_set_hasoutofband(struct socket *so);
|
||||
void socket_set_cantsendmore(struct socket *so);
|
||||
void socket_set_cantrcvmore(struct socket *so);
|
||||
void socket_set_connected(struct socket *so);
|
||||
void socket_set_connecting(struct socket *so);
|
||||
void socket_set_disconnected(struct socket *so);
|
||||
void socket_set_disconnecting(struct socket *so);
|
||||
|
||||
int sorflush(struct socket *so);
|
||||
|
||||
int sb_lock(struct sockbuf *sb);
|
||||
int sockbuf_lock(struct sockbuf *sb);
|
||||
int nsleep(sem_id chan, char *msg, int timeo);
|
||||
void wakeup(sem_id chan);
|
||||
|
||||
|
||||
@@ -103,19 +103,19 @@ _EXPORT struct core_module_info core_info = {
|
||||
|
||||
sonewconn,
|
||||
soreserve,
|
||||
sbreserve,
|
||||
sbappend,
|
||||
sbappendaddr,
|
||||
sbdrop,
|
||||
sbflush,
|
||||
sockbuf_reserve,
|
||||
sockbuf_append,
|
||||
sockbuf_appendaddr,
|
||||
sockbuf_drop,
|
||||
sockbuf_flush,
|
||||
sowakeup,
|
||||
soisconnected,
|
||||
soisconnecting,
|
||||
soisdisconnected,
|
||||
soisdisconnecting,
|
||||
sohasoutofband,
|
||||
socantrcvmore,
|
||||
socantsendmore,
|
||||
socket_set_connected,
|
||||
socket_set_connecting,
|
||||
socket_set_disconnected,
|
||||
socket_set_disconnecting,
|
||||
socket_set_hasoutofband,
|
||||
socket_set_cantrcvmore,
|
||||
socket_set_cantsendmore,
|
||||
|
||||
in_pcballoc,
|
||||
in_pcbdetach,
|
||||
|
||||
@@ -21,7 +21,7 @@ uint32 sb_max = SB_MAX; /* hard value, recompile needed to alter :( */
|
||||
* Attempt to scale mbmax so that mbcnt doesn't become limiting
|
||||
* if buffering efficiency is near the normal case.
|
||||
*/
|
||||
int sbreserve(struct sockbuf *sb, uint32 cc)
|
||||
int sockbuf_reserve(struct sockbuf *sb, uint32 cc)
|
||||
{
|
||||
uint64 dd = (uint64)cc;
|
||||
uint64 ee = (sb_max * MCLBYTES) / ((MSIZE) + (MCLBYTES));
|
||||
@@ -38,7 +38,7 @@ int sbreserve(struct sockbuf *sb, uint32 cc)
|
||||
return (1);
|
||||
}
|
||||
|
||||
void sbdrop(struct sockbuf *sb, int len)
|
||||
void sockbuf_drop(struct sockbuf *sb, int len)
|
||||
{
|
||||
struct mbuf *m, *mn;
|
||||
struct mbuf *next;
|
||||
@@ -80,13 +80,13 @@ void sbdrop(struct sockbuf *sb, int len)
|
||||
* Free all mbufs in a sockbuf.
|
||||
* Check that all resources are reclaimed.
|
||||
*/
|
||||
void sbflush(struct sockbuf *sb)
|
||||
void sockbuf_flush(struct sockbuf *sb)
|
||||
{
|
||||
if (sb->sb_flags & SB_LOCK) {
|
||||
return;
|
||||
}
|
||||
while (sb->sb_mbcnt)
|
||||
sbdrop(sb, (int)sb->sb_cc);
|
||||
sockbuf_drop(sb, (int)sb->sb_cc);
|
||||
if (sb->sb_cc || sb->sb_mb)
|
||||
return;
|
||||
}
|
||||
@@ -94,13 +94,13 @@ void sbflush(struct sockbuf *sb)
|
||||
/*
|
||||
* Free mbufs held by a socket, and reserved mbuf space.
|
||||
*/
|
||||
void sbrelease(struct sockbuf *sb)
|
||||
void sockbuf_release(struct sockbuf *sb)
|
||||
{
|
||||
sbflush(sb);
|
||||
sockbuf_flush(sb);
|
||||
sb->sb_hiwat = sb->sb_mbmax = 0;
|
||||
}
|
||||
|
||||
void sbappend(struct sockbuf *sb, struct mbuf *m)
|
||||
void sockbuf_append(struct sockbuf *sb, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *n;
|
||||
|
||||
@@ -111,15 +111,15 @@ void sbappend(struct sockbuf *sb, struct mbuf *m)
|
||||
n = n->m_nextpkt;
|
||||
do {
|
||||
if (n->m_flags & M_EOR) {
|
||||
sbappendrecord(sb, m); /* XXXXXX!!!! */
|
||||
sockbuf_appendrecord(sb, m); /* XXXXXX!!!! */
|
||||
return;
|
||||
}
|
||||
} while (n->m_next && (n = n->m_next));
|
||||
}
|
||||
sbcompress(sb, m, n);
|
||||
sockbuf_compress(sb, m, n);
|
||||
}
|
||||
|
||||
void sbappendrecord(struct sockbuf *sb, struct mbuf *m0)
|
||||
void sockbuf_appendrecord(struct sockbuf *sb, struct mbuf *m0)
|
||||
{
|
||||
struct mbuf *m;
|
||||
|
||||
@@ -143,10 +143,10 @@ void sbappendrecord(struct sockbuf *sb, struct mbuf *m0)
|
||||
m0->m_flags &= ~M_EOR;
|
||||
m->m_flags |= M_EOR;
|
||||
}
|
||||
sbcompress(sb, m, m0);
|
||||
sockbuf_compress(sb, m, m0);
|
||||
}
|
||||
|
||||
int sbappendaddr(struct sockbuf *sb, struct sockaddr *asa,
|
||||
int sockbuf_appendaddr(struct sockbuf *sb, struct sockaddr *asa,
|
||||
struct mbuf *m0, struct mbuf *control)
|
||||
{
|
||||
struct mbuf *m, *n;
|
||||
@@ -188,7 +188,7 @@ int sbappendaddr(struct sockbuf *sb, struct sockaddr *asa,
|
||||
return (1);
|
||||
}
|
||||
|
||||
void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
|
||||
void sockbuf_compress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
|
||||
{
|
||||
int eor = 0;
|
||||
struct mbuf *o;
|
||||
@@ -226,11 +226,11 @@ void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
|
||||
if (n)
|
||||
n->m_flags |= eor;
|
||||
else
|
||||
printf("semi-panic: sbcompress\n");
|
||||
printf("semi-panic: sockbuf_compress\n");
|
||||
}
|
||||
}
|
||||
|
||||
void sbdroprecord(struct sockbuf *sb)
|
||||
void sockbuf_droprecord(struct sockbuf *sb)
|
||||
{
|
||||
struct mbuf *m, *mn;
|
||||
|
||||
@@ -244,15 +244,15 @@ void sbdroprecord(struct sockbuf *sb)
|
||||
}
|
||||
}
|
||||
|
||||
int sbwait(struct sockbuf *sb)
|
||||
int sockbuf_wait(struct sockbuf *sb)
|
||||
{
|
||||
if (sb->sb_cc > 0)
|
||||
return 0;
|
||||
sb->sb_flags |= SB_WAIT;
|
||||
return nsleep(sb->sb_pop, "sbwait", sb->sb_timeo);
|
||||
return nsleep(sb->sb_pop, "sockbuf_wait", sb->sb_timeo);
|
||||
}
|
||||
|
||||
void sbinsertoob(struct sockbuf *sb, struct mbuf *m0)
|
||||
void sockbuf_insertoob(struct sockbuf *sb, struct mbuf *m0)
|
||||
{
|
||||
struct mbuf *m;
|
||||
struct mbuf **mp;
|
||||
@@ -284,20 +284,20 @@ again:
|
||||
m0->m_flags &= ~M_EOR;
|
||||
m->m_flags |= M_EOR;
|
||||
}
|
||||
sbcompress(sb, m, m0);
|
||||
sockbuf_compress(sb, m, m0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lock a sockbuf already known to be locked;
|
||||
* return any error returned from sleep (EINTR).
|
||||
*/
|
||||
int sb_lock(struct sockbuf *sb)
|
||||
int sockbuf_lock(struct sockbuf *sb) // XXX never called at all
|
||||
{
|
||||
int error;
|
||||
|
||||
while (sb->sb_flags & SB_LOCK) {
|
||||
sb->sb_flags |= SB_WANT;
|
||||
error = nsleep(sb->sb_sleep, "sb_lock", 0);
|
||||
error = nsleep(sb->sb_sleep, "sockbuf_lock", 0);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,15 @@
|
||||
#define SBLOCKWAIT(f) (((f) & MSG_DONTWAIT) ? M_NOWAIT : M_WAITOK)
|
||||
|
||||
/* Private prototypes */
|
||||
static int checkevent(struct socket *so);
|
||||
static int checkevent(struct socket *so);
|
||||
static void sofree(struct socket *);
|
||||
static void soqinsque (struct socket *head, struct socket *so, int q);
|
||||
static int soqremque (struct socket *so, int q);
|
||||
static int sosend(struct socket *so, struct mbuf *addr, struct uio *uio,
|
||||
struct mbuf *top, struct mbuf *control, int flags);
|
||||
static int soreceive (struct socket *so, struct mbuf **paddr, struct uio *uio,
|
||||
struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
|
||||
|
||||
|
||||
/* Static global objects... */
|
||||
static pool_ctl *spool;
|
||||
@@ -162,8 +170,15 @@ int socket_create(struct socket *so, int dom, int type, int proto)
|
||||
so->so_rcv.sb_sleep < 0 ||
|
||||
so->so_snd.sb_pop < 0 ||
|
||||
so->so_snd.sb_sleep < 0 ||
|
||||
so->so_timeo < 0)
|
||||
so->so_timeo < 0) {
|
||||
printf("socket_create: ENOMEM\n");
|
||||
delete_sem(so->so_rcv.sb_pop);
|
||||
delete_sem(so->so_rcv.sb_sleep);
|
||||
delete_sem(so->so_snd.sb_pop);
|
||||
delete_sem(so->so_snd.sb_sleep);
|
||||
delete_sem(so->so_timeo);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef _KERNEL_MODE
|
||||
set_sem_owner(so->so_rcv.sb_pop, B_SYSTEM_TEAM);
|
||||
@@ -186,9 +201,9 @@ int socket_create(struct socket *so, int dom, int type, int proto)
|
||||
|
||||
int soreserve(struct socket *so, uint32 sndcc, uint32 rcvcc)
|
||||
{
|
||||
if (sbreserve(&so->so_snd, sndcc) == 0)
|
||||
if (sockbuf_reserve(&so->so_snd, sndcc) == 0)
|
||||
goto bad;
|
||||
if (sbreserve(&so->so_rcv, rcvcc) == 0)
|
||||
if (sockbuf_reserve(&so->so_rcv, rcvcc) == 0)
|
||||
goto bad2;
|
||||
|
||||
if (so->so_rcv.sb_lowat == 0)
|
||||
@@ -201,7 +216,7 @@ int soreserve(struct socket *so, uint32 sndcc, uint32 rcvcc)
|
||||
return (0);
|
||||
|
||||
bad2:
|
||||
sbrelease(&so->so_snd);
|
||||
sockbuf_release(&so->so_snd);
|
||||
bad:
|
||||
printf("soreserve: ENOBUFS\n");
|
||||
return (ENOBUFS);
|
||||
@@ -432,7 +447,7 @@ int socket_writev(struct socket *so, struct iovec *iov, int flags)
|
||||
return (len - auio.uio_resid);
|
||||
}
|
||||
|
||||
int sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top,
|
||||
static int sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top,
|
||||
struct mbuf *control, int flags)
|
||||
{
|
||||
struct mbuf **mp;
|
||||
@@ -508,7 +523,7 @@ restart:
|
||||
}
|
||||
/* free lock - we're waiting on send buffer space */
|
||||
sbunlock(&so->so_snd);
|
||||
error = sbwait(&so->so_snd);
|
||||
error = sockbuf_wait(&so->so_snd);
|
||||
if (error)
|
||||
goto out;
|
||||
goto restart;
|
||||
@@ -680,7 +695,7 @@ out:
|
||||
}
|
||||
|
||||
|
||||
int soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, struct mbuf**mp0,
|
||||
static int soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, struct mbuf**mp0,
|
||||
struct mbuf **controlp, int *flagsp)
|
||||
{
|
||||
struct mbuf *m, **mp;
|
||||
@@ -772,7 +787,7 @@ restart:
|
||||
goto release;
|
||||
}
|
||||
sbunlock(&so->so_rcv);
|
||||
error = sbwait(&so->so_rcv);
|
||||
error = sockbuf_wait(&so->so_rcv);
|
||||
if (error)
|
||||
return error;
|
||||
goto restart;
|
||||
@@ -901,7 +916,7 @@ dontblock:
|
||||
!sosendallatonce(so) && !nextrecord) {
|
||||
if (so->so_error || so->so_state & SS_CANTRCVMORE)
|
||||
break;
|
||||
error = sbwait(&so->so_rcv);
|
||||
error = sockbuf_wait(&so->so_rcv);
|
||||
if (error) {
|
||||
sbunlock(&so->so_rcv);
|
||||
return 0;
|
||||
@@ -914,7 +929,7 @@ dontblock:
|
||||
if (m && pr->pr_flags & PR_ATOMIC) {
|
||||
flags |= MSG_TRUNC;
|
||||
if ((flags & MSG_PEEK) == 0)
|
||||
sbdroprecord(&so->so_rcv);
|
||||
sockbuf_droprecord(&so->so_rcv);
|
||||
}
|
||||
if ((flags & MSG_PEEK) == 0) {
|
||||
if (!m)
|
||||
@@ -1020,12 +1035,12 @@ int sorflush(struct socket *so)
|
||||
|
||||
sb->sb_flags |= SB_NOINTR;
|
||||
sblock(sb, M_WAITOK);
|
||||
socantrcvmore(so);
|
||||
socket_set_cantrcvmore(so);
|
||||
sbunlock(sb);
|
||||
asb = *sb;
|
||||
memset(sb, 0, sizeof(*sb));
|
||||
|
||||
sbrelease(&asb);
|
||||
sockbuf_release(&asb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1048,7 +1063,7 @@ bad:
|
||||
return error;
|
||||
}
|
||||
|
||||
void sofree(struct socket *so)
|
||||
static void sofree(struct socket *so)
|
||||
{
|
||||
if (so->so_pcb || (so->so_state & SS_NOFDREF) == 0)
|
||||
return;
|
||||
@@ -1060,7 +1075,7 @@ void sofree(struct socket *so)
|
||||
}
|
||||
so->so_head = NULL;
|
||||
}
|
||||
sbrelease(&so->so_snd);
|
||||
sockbuf_release(&so->so_snd);
|
||||
sorflush(so);
|
||||
|
||||
delete_sem(so->so_rcv.sb_pop);
|
||||
@@ -1128,7 +1143,7 @@ int socket_setsockopt(struct socket *so, int level, int optnum, const void *data
|
||||
switch (optnum) {
|
||||
case SO_SNDBUF:
|
||||
case SO_RCVBUF:
|
||||
if (sbreserve(optnum == SO_SNDBUF ? &so->so_snd : &so->so_rcv,
|
||||
if (sockbuf_reserve(optnum == SO_SNDBUF ? &so->so_snd : &so->so_rcv,
|
||||
(uint32)*mtod(m, int32*)) == 0) {
|
||||
error = ENOBUFS;
|
||||
goto bad;
|
||||
@@ -1320,9 +1335,9 @@ void sowakeup(struct socket *so, struct sockbuf *sb)
|
||||
release_sem_etc(sb->sb_pop, 1, B_CAN_INTERRUPT);
|
||||
}
|
||||
checkevent(so);
|
||||
}
|
||||
}
|
||||
|
||||
void soqinsque(struct socket *head, struct socket *so, int q)
|
||||
static void soqinsque(struct socket *head, struct socket *so, int q)
|
||||
{
|
||||
struct socket **prev;
|
||||
so->so_head = head;
|
||||
@@ -1340,7 +1355,7 @@ void soqinsque(struct socket *head, struct socket *so, int q)
|
||||
*prev = so;
|
||||
}
|
||||
|
||||
int soqremque(struct socket *so, int q)
|
||||
static int soqremque(struct socket *so, int q)
|
||||
{
|
||||
struct socket *head, *prev, *next;
|
||||
|
||||
@@ -1366,31 +1381,31 @@ int soqremque(struct socket *so, int q)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void sohasoutofband(struct socket *so)
|
||||
void socket_set_hasoutofband(struct socket *so)
|
||||
{
|
||||
/* Should we signal the process with SIGURG??? */
|
||||
checkevent(so);
|
||||
}
|
||||
|
||||
void socantsendmore(struct socket *so)
|
||||
void socket_set_cantsendmore(struct socket *so)
|
||||
{
|
||||
so->so_state |= SS_CANTSENDMORE;
|
||||
sowwakeup(so);
|
||||
}
|
||||
|
||||
void socantrcvmore(struct socket *so)
|
||||
void socket_set_cantrcvmore(struct socket *so)
|
||||
{
|
||||
so->so_state |= SS_CANTRCVMORE;
|
||||
sorwakeup(so);
|
||||
}
|
||||
|
||||
void soisconnecting(struct socket *so)
|
||||
void socket_set_connecting(struct socket *so)
|
||||
{
|
||||
so->so_state &= ~(SS_ISCONNECTED|SS_ISDISCONNECTING);
|
||||
so->so_state |= SS_ISCONNECTING;
|
||||
}
|
||||
|
||||
void soisconnected(struct socket *so)
|
||||
void socket_set_connected(struct socket *so)
|
||||
{
|
||||
struct socket *head = so->so_head;
|
||||
|
||||
@@ -1407,7 +1422,7 @@ void soisconnected(struct socket *so)
|
||||
}
|
||||
}
|
||||
|
||||
void soisdisconnecting(struct socket *so)
|
||||
void socket_set_disconnecting(struct socket *so)
|
||||
{
|
||||
so->so_state &= ~SS_ISCONNECTING;
|
||||
so->so_state |= (SS_ISDISCONNECTING|SS_CANTRCVMORE|SS_CANTSENDMORE);
|
||||
@@ -1416,7 +1431,7 @@ void soisdisconnecting(struct socket *so)
|
||||
sorwakeup(so);
|
||||
}
|
||||
|
||||
void soisdisconnected(struct socket *so)
|
||||
void socket_set_disconnected(struct socket *so)
|
||||
{
|
||||
so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING);
|
||||
so->so_state |= (SS_CANTRCVMORE|SS_CANTSENDMORE|SS_ISDISCONNECTED);
|
||||
|
||||
@@ -62,7 +62,7 @@ void rip_input(struct mbuf *m, int hdrlen)
|
||||
if (last) {
|
||||
struct mbuf *n;
|
||||
if ((n = m_copym(m, 0, (int)M_COPYALL))) {
|
||||
if (sbappendaddr(&last->so_rcv, (struct sockaddr*)&ripsrc,
|
||||
if (sockbuf_appendaddr(&last->so_rcv, (struct sockaddr*)&ripsrc,
|
||||
n, NULL) == 0)
|
||||
m_freem(n);
|
||||
else
|
||||
@@ -72,7 +72,7 @@ void rip_input(struct mbuf *m, int hdrlen)
|
||||
last = inp->inp_socket;
|
||||
}
|
||||
if (last) {
|
||||
if (sbappendaddr(&last->so_rcv, (struct sockaddr*)&ripsrc,
|
||||
if (sockbuf_appendaddr(&last->so_rcv, (struct sockaddr*)&ripsrc,
|
||||
m, NULL) == 0)
|
||||
m_freem(m);
|
||||
else
|
||||
@@ -150,7 +150,7 @@ int rip_userreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
|
||||
break;
|
||||
}
|
||||
case PRU_ABORT:
|
||||
soisdisconnected(so);
|
||||
socket_set_disconnected(so);
|
||||
case PRU_DETACH:
|
||||
if (inp == NULL) {
|
||||
printf("Can't detach from NULL protocol block!\n");
|
||||
@@ -212,14 +212,14 @@ int rip_userreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
|
||||
break;
|
||||
}
|
||||
inp->faddr = addr->sin_addr;
|
||||
soisconnected(so);
|
||||
socket_set_connected(so);
|
||||
break;
|
||||
}
|
||||
case PRU_CONNECT2:
|
||||
error = EOPNOTSUPP;
|
||||
break;
|
||||
case PRU_SHUTDOWN:
|
||||
socantsendmore(so);
|
||||
socket_set_cantsendmore(so);
|
||||
break;
|
||||
case PRU_RCVOOB:
|
||||
case PRU_RCVD:
|
||||
|
||||
@@ -202,7 +202,7 @@ struct tcpcb *tcp_close(struct tcpcb *tp)
|
||||
|
||||
pool_put(tcppool, tp);
|
||||
inp->inp_ppcb = NULL;
|
||||
soisdisconnected(so);
|
||||
socket_set_disconnected(so);
|
||||
if (inp == tcp_last_inpcb)
|
||||
tcp_last_inpcb = &tcb;
|
||||
in_pcbdetach(inp);
|
||||
@@ -301,7 +301,7 @@ struct tcpcb *tcp_usrclosed(struct tcpcb *tp)
|
||||
break;
|
||||
}
|
||||
if (tp && tp->t_state >= TCPS_FIN_WAIT_2)
|
||||
soisdisconnected(tp->t_inpcb->inp_socket);
|
||||
socket_set_disconnected(tp->t_inpcb->inp_socket);
|
||||
return tp;
|
||||
}
|
||||
|
||||
@@ -314,8 +314,8 @@ static struct tcpcb *tcp_disconnect(struct tcpcb *tp)
|
||||
else if ((so->so_options & SO_LINGER) && so->so_linger == 0)
|
||||
tp = tcp_drop(tp, 0);
|
||||
else {
|
||||
soisdisconnecting(so);
|
||||
sbflush(&so->so_rcv);
|
||||
socket_set_disconnecting(so);
|
||||
sockbuf_flush(&so->so_rcv);
|
||||
tp = tcp_usrclosed(tp);
|
||||
if (tp)
|
||||
tcp_output(tp);
|
||||
@@ -455,7 +455,7 @@ int tcp_userreq(struct socket *so, int req, struct mbuf *m,
|
||||
while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
|
||||
(TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
|
||||
tp->request_r_scale++;
|
||||
soisconnecting(so);
|
||||
socket_set_connecting(so);
|
||||
tcpstat.tcps_connattempt++;
|
||||
tp->t_state = TCPS_SYN_SENT;
|
||||
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
|
||||
@@ -479,14 +479,14 @@ int tcp_userreq(struct socket *so, int req, struct mbuf *m,
|
||||
req |= (int)nam << 8;
|
||||
break;
|
||||
case PRU_SEND:
|
||||
sbappend(&so->so_snd, m);
|
||||
sockbuf_append(&so->so_snd, m);
|
||||
error = tcp_output(tp);
|
||||
break;
|
||||
case PRU_RCVD:
|
||||
(void) tcp_output(tp);
|
||||
break;
|
||||
case PRU_SHUTDOWN:
|
||||
socantsendmore(so);
|
||||
socket_set_cantsendmore(so);
|
||||
tp = tcp_usrclosed(tp);
|
||||
if (tp)
|
||||
error = tcp_output(tp);
|
||||
|
||||
@@ -131,7 +131,7 @@ extern uint32 sb_max;
|
||||
(flags) = (ti)->ti_flags & TH_FIN; \
|
||||
tcpstat.tcps_rcvpack++; \
|
||||
tcpstat.tcps_rcvbyte += (ti)->ti_len; \
|
||||
sbappend(&(so)->so_rcv, (m)); \
|
||||
sockbuf_append(&(so)->so_rcv, (m)); \
|
||||
sorwakeup(so); \
|
||||
} else { \
|
||||
(flags) = tcp_reass((tp), (ti), (m)); \
|
||||
@@ -247,7 +247,7 @@ present:
|
||||
* So, reverse the logic and only append data if we can.
|
||||
*/
|
||||
if ((so->so_state & SS_CANTRCVMORE) == 0)
|
||||
sbappend(&so->so_rcv, m);
|
||||
sockbuf_append(&so->so_rcv, m);
|
||||
} while (ti != (struct tcpiphdr*)tp && ti->ti_seq == tp->rcv_nxt);
|
||||
sorwakeup(so);
|
||||
return (flags);
|
||||
@@ -554,7 +554,7 @@ findpcb:
|
||||
acked = ti->ti_ack - tp->snd_una;
|
||||
tcpstat.tcps_rcvackpack++;
|
||||
tcpstat.tcps_rcvackbyte += acked;
|
||||
sbdrop(&so->so_snd, acked);
|
||||
sockbuf_drop(&so->so_snd, acked);
|
||||
tp->snd_una = ti->ti_ack;
|
||||
m_freem(m);
|
||||
|
||||
@@ -597,7 +597,7 @@ findpcb:
|
||||
*/
|
||||
m->m_data += sizeof(struct tcpiphdr) + off - sizeof(struct tcphdr);
|
||||
m->m_len -= sizeof(struct tcpiphdr) + off - sizeof(struct tcphdr);
|
||||
sbappend(&so->so_rcv, m);
|
||||
sockbuf_append(&so->so_rcv, m);
|
||||
sorwakeup(so);
|
||||
tp->t_flags |= TF_DELACK;
|
||||
return;
|
||||
@@ -777,7 +777,7 @@ findpcb:
|
||||
tp->t_flags |= TF_ACKNOW;
|
||||
if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) {
|
||||
tcpstat.tcps_connects++;
|
||||
soisconnected(so);
|
||||
socket_set_connected(so);
|
||||
tp->t_state = TCPS_ESTABLISHED;
|
||||
/* Do window scaling on this connection? */
|
||||
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
|
||||
@@ -1028,7 +1028,7 @@ close:
|
||||
goto dropwithreset;
|
||||
}
|
||||
tcpstat.tcps_connects++;
|
||||
soisconnected(so);
|
||||
socket_set_connected(so);
|
||||
tp->t_state = TCPS_ESTABLISHED;
|
||||
/* Do window scaling? */
|
||||
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
|
||||
@@ -1168,10 +1168,10 @@ close:
|
||||
}
|
||||
if (acked > so->so_snd.sb_cc) {
|
||||
tp->snd_wnd -= so->so_snd.sb_cc;
|
||||
sbdrop(&so->so_snd, (int)so->so_snd.sb_cc);
|
||||
sockbuf_drop(&so->so_snd, (int)so->so_snd.sb_cc);
|
||||
ourfinisacked = 1;
|
||||
} else {
|
||||
sbdrop(&so->so_snd, acked);
|
||||
sockbuf_drop(&so->so_snd, acked);
|
||||
tp->snd_wnd -= acked;
|
||||
ourfinisacked = 0;
|
||||
}
|
||||
@@ -1198,7 +1198,7 @@ close:
|
||||
* we'll hang forever.
|
||||
*/
|
||||
if (so->so_state & SS_CANTRCVMORE) {
|
||||
soisdisconnected(so);
|
||||
socket_set_disconnected(so);
|
||||
tp->t_timer[TCPT_2MSL] = tcp_maxidle;
|
||||
}
|
||||
tp->t_state = TCPS_FIN_WAIT_2;
|
||||
@@ -1216,7 +1216,7 @@ close:
|
||||
tp->t_state = TCPS_TIME_WAIT;
|
||||
tcp_canceltimers(tp);
|
||||
tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
|
||||
soisdisconnected(so);
|
||||
socket_set_disconnected(so);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1300,7 +1300,7 @@ step6:
|
||||
(tp->rcv_up - tp->rcv_nxt) - 1;
|
||||
if (so->so_oobmark == 0)
|
||||
so->so_state |= SS_RCVATMARK;
|
||||
sohasoutofband(so);
|
||||
socket_set_hasoutofband(so);
|
||||
tp->t_oobflags &= ~(TCPOOB_HAVEDATA | TCPOOB_HADDATA);
|
||||
}
|
||||
/*
|
||||
@@ -1351,7 +1351,7 @@ dodata: /* XXX */
|
||||
*/
|
||||
if ((tiflags & TH_FIN)) {
|
||||
if (TCPS_HAVERCVDFIN(tp->t_state) == 0) {
|
||||
socantrcvmore(so);
|
||||
socket_set_cantrcvmore(so);
|
||||
tp->t_flags |= TF_ACKNOW;
|
||||
tp->rcv_nxt++;
|
||||
}
|
||||
@@ -1381,7 +1381,7 @@ dodata: /* XXX */
|
||||
tp->t_state = TCPS_TIME_WAIT;
|
||||
tcp_canceltimers(tp);
|
||||
tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL;
|
||||
soisdisconnected(so);
|
||||
socket_set_disconnected(so);
|
||||
break;
|
||||
|
||||
/*
|
||||
@@ -1691,7 +1691,7 @@ void tcp_mss_update(struct tcpcb *tp)
|
||||
bufsize = roundup(bufsize, mss);
|
||||
if (bufsize > sb_max)
|
||||
bufsize = sb_max;
|
||||
(void)sbreserve(&so->so_snd, bufsize);
|
||||
(void)sockbuf_reserve(&so->so_snd, bufsize);
|
||||
}
|
||||
|
||||
#ifdef RTV_RPIPE
|
||||
@@ -1702,7 +1702,7 @@ void tcp_mss_update(struct tcpcb *tp)
|
||||
bufsize = roundup(bufsize, mss);
|
||||
if (bufsize > sb_max)
|
||||
bufsize = sb_max;
|
||||
(void)sbreserve(&so->so_rcv, bufsize);
|
||||
(void)sockbuf_reserve(&so->so_rcv, bufsize);
|
||||
#ifdef RTV_RPIPE
|
||||
if (rt->rt_rmx.rmx_recvpipe > 0) {
|
||||
tp->request_r_scale = 0;
|
||||
|
||||
@@ -122,7 +122,7 @@ else
|
||||
bufsize = roundup(bufsize, mss);
|
||||
if (bufsize > sb_max)
|
||||
bufsize = sb_max;
|
||||
sbreserve(&so->so_snd, bufsize);
|
||||
sockbuf_reserve(&so->so_snd, bufsize);
|
||||
}
|
||||
tp->t_maxseg = mss;
|
||||
|
||||
@@ -132,7 +132,7 @@ else
|
||||
bufsize = roundup(bufsize, mss);
|
||||
if (bufsize > sb_max)
|
||||
bufsize = sb_max;
|
||||
sbreserve(&so->so_rcv, bufsize);
|
||||
sockbuf_reserve(&so->so_rcv, bufsize);
|
||||
}
|
||||
}
|
||||
tp->snd_cwnd = mss;
|
||||
|
||||
@@ -193,7 +193,7 @@ int udp_userreq(struct socket *so, int req,
|
||||
}
|
||||
error = in_pcbconnect(inp, addr);
|
||||
if (error == 0)
|
||||
soisconnected(so);
|
||||
socket_set_connected(so);
|
||||
break;
|
||||
case PRU_CONNECT2:
|
||||
error = EINVAL;//EOPNOTSUPP;
|
||||
@@ -304,7 +304,7 @@ void udp_input(struct mbuf *buf, int hdrlen)
|
||||
buf->m_pkthdr.len -= hdrlen;
|
||||
buf->m_data += hdrlen;
|
||||
|
||||
if (sbappendaddr(&inp->inp_socket->so_rcv, (struct sockaddr*)&udp_in,
|
||||
if (sockbuf_appendaddr(&inp->inp_socket->so_rcv, (struct sockaddr*)&udp_in,
|
||||
buf, opts) == 0) {
|
||||
goto bad;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user