diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 7733a9dea3b7..14186bc8d450 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.53 2001/02/07 12:20:43 itojun Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.54 2001/02/27 05:19:13 lukem Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -52,13 +52,13 @@ #include #include -struct pool socket_pool; +struct pool socket_pool; -extern int somaxconn; /* patchable (XXX sysctl) */ -int somaxconn = SOMAXCONN; +extern int somaxconn; /* patchable (XXX sysctl) */ +int somaxconn = SOMAXCONN; void -soinit() +soinit(void) { pool_init(&socket_pool, sizeof(struct socket), 0, 0, 0, @@ -74,18 +74,14 @@ soinit() */ /*ARGSUSED*/ int -socreate(dom, aso, type, proto) - int dom; - struct socket **aso; - int type; - int proto; +socreate(int dom, struct socket **aso, int type, int proto) { - struct proc *p = curproc; /* XXX */ - struct protosw *prp; - struct socket *so; - int error; - int s; + struct proc *p; + struct protosw *prp; + struct socket *so; + int error, s; + p = curproc; /* XXX */ if (proto) prp = pffindproto(dom, proto, type); else @@ -126,14 +122,11 @@ socreate(dom, aso, type, proto) } int -sobind(so, nam, p) - struct socket *so; - struct mbuf *nam; - struct proc *p; +sobind(struct socket *so, struct mbuf *nam, struct proc *p) { - int s = splsoftnet(); - int error; + int s, error; + s = splsoftnet(); error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, (struct mbuf *)0, nam, (struct mbuf *)0, p); splx(s); @@ -141,12 +134,11 @@ sobind(so, nam, p) } int -solisten(so, backlog) - struct socket *so; - int backlog; +solisten(struct socket *so, int backlog) { - int s = splsoftnet(), error; + int s, error; + s = splsoftnet(); error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); if (error) { @@ -163,8 +155,7 @@ solisten(so, backlog) } void -sofree(so) - struct socket *so; +sofree(struct socket *so) { if (so->so_pcb || (so->so_state & SS_NOFDREF) == 0) @@ -189,13 +180,13 @@ sofree(so) * Free socket when disconnect complete. */ int -soclose(so) - struct socket *so; +soclose(struct socket *so) { - struct socket *so2; - int s = splsoftnet(); /* conservative */ - int error = 0; + struct socket *so2; + int s, error; + error = 0; + s = splsoftnet(); /* conservative */ if (so->so_options & SO_ACCEPTCONN) { while ((so2 = so->so_q0.tqh_first) != 0) { (void) soqremque(so2, 0); @@ -227,7 +218,7 @@ soclose(so) } } } -drop: + drop: if (so->so_pcb) { int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH, (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, @@ -235,7 +226,7 @@ drop: if (error == 0) error = error2; } -discard: + discard: if (so->so_state & SS_NOFDREF) panic("soclose: NOFDREF"); so->so_state |= SS_NOFDREF; @@ -248,8 +239,7 @@ discard: * Must be called at splsoftnet... */ int -soabort(so) - struct socket *so; +soabort(struct socket *so) { return (*so->so_proto->pr_usrreq)(so, PRU_ABORT, (struct mbuf *)0, @@ -257,13 +247,12 @@ soabort(so) } int -soaccept(so, nam) - struct socket *so; - struct mbuf *nam; +soaccept(struct socket *so, struct mbuf *nam) { - int s = splsoftnet(); - int error = 0; + int s, error; + error = 0; + s = splsoftnet(); if ((so->so_state & SS_NOFDREF) == 0) panic("soaccept: !NOFDREF"); so->so_state &= ~SS_NOFDREF; @@ -278,14 +267,12 @@ soaccept(so, nam) } int -soconnect(so, nam) - struct socket *so; - struct mbuf *nam; +soconnect(struct socket *so, struct mbuf *nam) { - struct proc *p = curproc; /* XXX */ - int s; - int error; + struct proc *p; + int s, error; + p = curproc; /* XXX */ if (so->so_options & SO_ACCEPTCONN) return (EOPNOTSUPP); s = splsoftnet(); @@ -307,13 +294,11 @@ soconnect(so, nam) } int -soconnect2(so1, so2) - struct socket *so1; - struct socket *so2; +soconnect2(struct socket *so1, struct socket *so2) { - int s = splsoftnet(); - int error; + int s, error; + s = splsoftnet(); error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2, (struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0, (struct proc *)0); @@ -322,12 +307,11 @@ soconnect2(so1, so2) } int -sodisconnect(so) - struct socket *so; +sodisconnect(struct socket *so) { - int s = splsoftnet(); - int error; + int s, error; + s = splsoftnet(); if ((so->so_state & SS_ISCONNECTED) == 0) { error = ENOTCONN; goto bad; @@ -339,7 +323,7 @@ sodisconnect(so) error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT, (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); -bad: + bad: splx(s); return (error); } @@ -363,21 +347,17 @@ bad: * Data and control buffers are freed on return. */ int -sosend(so, addr, uio, top, control, flags) - struct socket *so; - struct mbuf *addr; - struct uio *uio; - struct mbuf *top; - struct mbuf *control; - int flags; +sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top, + struct mbuf *control, int flags) { - struct proc *p = curproc; /* XXX */ - struct mbuf **mp; - struct mbuf *m; - long space, len, resid; - int clen = 0, error, s, dontroute, mlen; - int atomic = sosendallatonce(so) || top; + struct proc *p; + struct mbuf **mp, *m; + long space, len, resid; + int clen, error, s, dontroute, mlen, atomic; + p = curproc; /* XXX */ + clen = 0; + atomic = sosendallatonce(so) || top; if (uio) resid = uio->uio_resid; else @@ -401,7 +381,7 @@ sosend(so, addr, uio, top, control, flags) clen = control->m_len; #define snderr(errno) { error = errno; splx(s); goto release; } -restart: + restart: if ((error = sblock(&so->so_snd, SBLOCKWAIT(flags))) != 0) goto out; do { @@ -469,7 +449,8 @@ restart: len = min(MCLBYTES, resid); #else if (atomic && top == 0) { - len = min(MCLBYTES - max_hdr, resid); + len = min(MCLBYTES - max_hdr, + resid); m->m_data += max_hdr; } else len = min(MCLBYTES, resid); @@ -486,7 +467,8 @@ nopages: if (atomic && top == 0 && len < mlen) MH_ALIGN(m, len); } - error = uiomove(mtod(m, caddr_t), (int)len, uio); + error = uiomove(mtod(m, caddr_t), (int)len, + uio); resid = uio->uio_resid; m->m_len = len; *mp = m; @@ -528,9 +510,9 @@ nopages: } while (resid && space > 0); } while (resid); -release: + release: sbunlock(&so->so_snd); -out: + out: if (top) m_freem(top); if (control) @@ -555,22 +537,18 @@ out: * only for the count in uio_resid. */ int -soreceive(so, paddr, uio, mp0, controlp, flagsp) - struct socket *so; - struct mbuf **paddr; - struct uio *uio; - struct mbuf **mp0; - struct mbuf **controlp; - int *flagsp; +soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, + struct mbuf **mp0, struct mbuf **controlp, int *flagsp) { - struct mbuf *m, **mp; - int flags, len, error, s, offset; - struct protosw *pr = so->so_proto; - struct mbuf *nextrecord; - int moff, type = 0; - int orig_resid = uio->uio_resid; + struct mbuf *m, **mp; + int flags, len, error, s, offset, moff, type, orig_resid; + struct protosw *pr; + struct mbuf *nextrecord; + pr = so->so_proto; mp = mp0; + type = 0; + orig_resid = uio->uio_resid; if (paddr) *paddr = 0; if (controlp) @@ -591,7 +569,7 @@ soreceive(so, paddr, uio, mp0, controlp, flagsp) (int) min(uio->uio_resid, m->m_len), uio); m = m_free(m); } while (uio->uio_resid && error == 0 && m); -bad: + bad: if (m) m_freem(m); return (error); @@ -602,7 +580,7 @@ bad: (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0, (struct proc *)0); -restart: + restart: if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0) return (error); s = splsoftnet(); @@ -665,7 +643,7 @@ restart: return (error); goto restart; } -dontblock: + dontblock: #ifdef notyet /* XXXX */ if (uio->uio_procp) uio->uio_procp->p_stats->p_ru.ru_msgrcv++; @@ -850,19 +828,18 @@ dontblock: if (flagsp) *flagsp |= flags; -release: + release: sbunlock(&so->so_rcv); splx(s); return (error); } int -soshutdown(so, how) - struct socket *so; - int how; +soshutdown(struct socket *so, int how) { - struct protosw *pr = so->so_proto; + struct protosw *pr; + pr = so->so_proto; if (!(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR)) return (EINVAL); @@ -875,14 +852,14 @@ soshutdown(so, how) } void -sorflush(so) - struct socket *so; +sorflush(struct socket *so) { - struct sockbuf *sb = &so->so_rcv; - struct protosw *pr = so->so_proto; - int s; - struct sockbuf asb; + struct sockbuf *sb, asb; + struct protosw *pr; + int s; + sb = &so->so_rcv; + pr = so->so_proto; sb->sb_flags |= SB_NOINTR; (void) sblock(sb, M_WAITOK); s = splimp(); @@ -897,14 +874,13 @@ sorflush(so) } int -sosetopt(so, level, optname, m0) - struct socket *so; - int level, optname; - struct mbuf *m0; +sosetopt(struct socket *so, int level, int optname, struct mbuf *m0) { - int error = 0; - struct mbuf *m = m0; + int error; + struct mbuf *m; + error = 0; + m = m0; if (level != SOL_SOCKET) { if (so->so_proto && so->so_proto->pr_ctloutput) return ((*so->so_proto->pr_ctloutput) @@ -1031,19 +1007,16 @@ sosetopt(so, level, optname, m0) m = NULL; /* freed by protocol */ } } -bad: + bad: if (m) (void) m_free(m); return (error); } int -sogetopt(so, level, optname, mp) - struct socket *so; - int level, optname; - struct mbuf **mp; +sogetopt(struct socket *so, int level, int optname, struct mbuf **mp) { - struct mbuf *m; + struct mbuf *m; if (level != SOL_SOCKET) { if (so->so_proto && so->so_proto->pr_ctloutput) { @@ -1124,8 +1097,7 @@ sogetopt(so, level, optname, mp) } void -sohasoutofband(so) - struct socket *so; +sohasoutofband(struct socket *so) { struct proc *p; diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 329c2fbaf565..b99e7cf8848b 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket2.c,v 1.36 2000/03/30 09:27:14 augustss Exp $ */ +/* $NetBSD: uipc_socket2.c,v 1.37 2001/02/27 05:19:15 lukem Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -87,8 +87,7 @@ const char netcls[] = "netcls"; */ void -soisconnecting(so) - struct socket *so; +soisconnecting(struct socket *so) { so->so_state &= ~(SS_ISCONNECTED|SS_ISDISCONNECTING); @@ -96,11 +95,11 @@ soisconnecting(so) } void -soisconnected(so) - struct socket *so; +soisconnected(struct socket *so) { - struct socket *head = so->so_head; + struct socket *head; + head = so->so_head; so->so_state &= ~(SS_ISCONNECTING|SS_ISDISCONNECTING|SS_ISCONFIRMING); so->so_state |= SS_ISCONNECTED; if (head && soqremque(so, 0)) { @@ -115,8 +114,7 @@ soisconnected(so) } void -soisdisconnecting(so) - struct socket *so; +soisdisconnecting(struct socket *so) { so->so_state &= ~SS_ISCONNECTING; @@ -127,8 +125,7 @@ soisdisconnecting(so) } void -soisdisconnected(so) - struct socket *so; +soisdisconnected(struct socket *so) { so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING); @@ -150,13 +147,12 @@ soisdisconnected(so) * to catch calls that are missing the (new) second parameter. */ struct socket * -sonewconn1(head, connstatus) - struct socket *head; - int connstatus; +sonewconn1(struct socket *head, int connstatus) { - struct socket *so; - int soqueue = connstatus ? 1 : 0; + struct socket *so; + int soqueue; + soqueue = connstatus ? 1 : 0; if (head->so_qlen + head->so_q0len > 3 * head->so_qlimit / 2) return ((struct socket *)0); so = pool_get(&socket_pool, PR_NOWAIT); @@ -191,9 +187,7 @@ sonewconn1(head, connstatus) } void -soqinsque(head, so, q) - struct socket *head, *so; - int q; +soqinsque(struct socket *head, struct socket *so, int q) { #ifdef DIAGNOSTIC @@ -213,12 +207,11 @@ soqinsque(head, so, q) } int -soqremque(so, q) - struct socket *so; - int q; +soqremque(struct socket *so, int q) { - struct socket *head = so->so_head; + struct socket *head; + head = so->so_head; if (q == 0) { if (so->so_onq != &head->so_q0) return (0); @@ -245,8 +238,7 @@ soqremque(so, q) */ void -socantsendmore(so) - struct socket *so; +socantsendmore(struct socket *so) { so->so_state |= SS_CANTSENDMORE; @@ -254,8 +246,7 @@ socantsendmore(so) } void -socantrcvmore(so) - struct socket *so; +socantrcvmore(struct socket *so) { so->so_state |= SS_CANTRCVMORE; @@ -266,8 +257,7 @@ socantrcvmore(so) * Wait for data to arrive at/drain from a socket buffer. */ int -sbwait(sb) - struct sockbuf *sb; +sbwait(struct sockbuf *sb) { sb->sb_flags |= SB_WAIT; @@ -281,10 +271,9 @@ sbwait(sb) * return any error returned from sleep (EINTR). */ int -sb_lock(sb) - struct sockbuf *sb; +sb_lock(struct sockbuf *sb) { - int error; + int error; while (sb->sb_flags & SB_LOCK) { sb->sb_flags |= SB_WANT; @@ -304,11 +293,9 @@ sb_lock(sb) * if the socket has the SS_ASYNC flag set. */ void -sowakeup(so, sb) - struct socket *so; - struct sockbuf *sb; +sowakeup(struct socket *so, struct sockbuf *sb) { - struct proc *p; + struct proc *p; selwakeup(&sb->sb_sel); sb->sb_flags &= ~SB_SEL; @@ -359,9 +346,7 @@ sowakeup(so, sb) */ int -soreserve(so, sndcc, rcvcc) - struct socket *so; - u_long sndcc, rcvcc; +soreserve(struct socket *so, u_long sndcc, u_long rcvcc) { if (sbreserve(&so->so_snd, sndcc) == 0) @@ -375,9 +360,9 @@ soreserve(so, sndcc, rcvcc) if (so->so_snd.sb_lowat > so->so_snd.sb_hiwat) so->so_snd.sb_lowat = so->so_snd.sb_hiwat; return (0); -bad2: + bad2: sbrelease(&so->so_snd); -bad: + bad: return (ENOBUFS); } @@ -387,9 +372,7 @@ bad: * if buffering efficiency is near the normal case. */ int -sbreserve(sb, cc) - struct sockbuf *sb; - u_long cc; +sbreserve(struct sockbuf *sb, u_long cc) { if (cc == 0 || cc > sb_max * MCLBYTES / (MSIZE + MCLBYTES)) @@ -405,8 +388,7 @@ sbreserve(sb, cc) * Free mbufs held by a socket, and reserved mbuf space. */ void -sbrelease(sb) - struct sockbuf *sb; +sbrelease(struct sockbuf *sb) { sbflush(sb); @@ -445,11 +427,9 @@ sbrelease(sb) * discarded and mbufs are compacted where possible. */ void -sbappend(sb, m) - struct sockbuf *sb; - struct mbuf *m; +sbappend(struct sockbuf *sb, struct mbuf *m) { - struct mbuf *n; + struct mbuf *n; if (m == 0) return; @@ -468,12 +448,13 @@ sbappend(sb, m) #ifdef SOCKBUF_DEBUG void -sbcheck(sb) - struct sockbuf *sb; +sbcheck(struct sockbuf *sb) { - struct mbuf *m; - int len = 0, mbcnt = 0; + struct mbuf *m; + int len, mbcnt; + len = 0; + mbcnt = 0; for (m = sb->sb_mb; m; m = m->m_next) { len += m->m_len; mbcnt += MSIZE; @@ -495,11 +476,9 @@ sbcheck(sb) * begins a new record. */ void -sbappendrecord(sb, m0) - struct sockbuf *sb; - struct mbuf *m0; +sbappendrecord(struct sockbuf *sb, struct mbuf *m0) { - struct mbuf *m; + struct mbuf *m; if (m0 == 0) return; @@ -530,12 +509,9 @@ sbappendrecord(sb, m0) * but after any other OOB data. */ void -sbinsertoob(sb, m0) - struct sockbuf *sb; - struct mbuf *m0; +sbinsertoob(struct sockbuf *sb, struct mbuf *m0) { - struct mbuf *m; - struct mbuf **mp; + struct mbuf *m, **mp; if (m0 == 0) return; @@ -575,16 +551,16 @@ sbinsertoob(sb, m0) * Returns 0 if no space in sockbuf or insufficient mbufs. */ int -sbappendaddr(sb, asa, m0, control) - struct sockbuf *sb; - struct sockaddr *asa; - struct mbuf *m0, *control; +sbappendaddr(struct sockbuf *sb, struct sockaddr *asa, struct mbuf *m0, + struct mbuf *control) { - struct mbuf *m, *n; - int space = asa->sa_len; + struct mbuf *m, *n; + int space; -if (m0 && (m0->m_flags & M_PKTHDR) == 0) -panic("sbappendaddr"); + space = asa->sa_len; + + if (m0 && (m0->m_flags & M_PKTHDR) == 0) + panic("sbappendaddr"); if (m0) space += m0->m_pkthdr.len; for (n = control; n; n = n->m_next) { @@ -623,13 +599,12 @@ panic("sbappendaddr"); } int -sbappendcontrol(sb, m0, control) - struct sockbuf *sb; - struct mbuf *m0, *control; +sbappendcontrol(struct sockbuf *sb, struct mbuf *m0, struct mbuf *control) { - struct mbuf *m, *n; - int space = 0; + struct mbuf *m, *n; + int space; + space = 0; if (control == 0) panic("sbappendcontrol"); for (m = control; ; m = m->m_next) { @@ -660,13 +635,12 @@ sbappendcontrol(sb, m0, control) * is null, the buffer is presumed empty. */ void -sbcompress(sb, m, n) - struct sockbuf *sb; - struct mbuf *m, *n; +sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n) { - int eor = 0; - struct mbuf *o; + int eor; + struct mbuf *o; + eor = 0; while (m) { eor |= m->m_flags & M_EOR; if (m->m_len == 0 && @@ -681,7 +655,8 @@ sbcompress(sb, m, n) n->m_data + n->m_len + m->m_len <= &n->m_dat[MLEN]) || ((~n->m_flags & (M_EXT|M_CLUSTER)) == 0 && !MCLISREFERENCED(n) && - n->m_data + n->m_len + m->m_len <= &n->m_ext.ext_buf[MCLBYTES]))) { + n->m_data + n->m_len + m->m_len <= + &n->m_ext.ext_buf[MCLBYTES]))) { memcpy(mtod(n, caddr_t) + n->m_len, mtod(m, caddr_t), (unsigned)m->m_len); n->m_len += m->m_len; @@ -712,8 +687,7 @@ sbcompress(sb, m, n) * Check that all resources are reclaimed. */ void -sbflush(sb) - struct sockbuf *sb; +sbflush(struct sockbuf *sb) { if (sb->sb_flags & SB_LOCK) @@ -728,12 +702,9 @@ sbflush(sb) * Drop data from (the front of) a sockbuf. */ void -sbdrop(sb, len) - struct sockbuf *sb; - int len; +sbdrop(struct sockbuf *sb, int len) { - struct mbuf *m, *mn; - struct mbuf *next; + struct mbuf *m, *mn, *next; next = (m = sb->sb_mb) ? m->m_nextpkt : 0; while (len > 0) { @@ -772,10 +743,9 @@ sbdrop(sb, len) * and move the next record to the front. */ void -sbdroprecord(sb) - struct sockbuf *sb; +sbdroprecord(struct sockbuf *sb) { - struct mbuf *m, *mn; + struct mbuf *m, *mn; m = sb->sb_mb; if (m) { @@ -792,13 +762,10 @@ sbdroprecord(sb) * with the specified type for presentation on a socket buffer. */ struct mbuf * -sbcreatecontrol(p, size, type, level) - caddr_t p; - int size; - int type, level; +sbcreatecontrol(caddr_t p, int size, int type, int level) { - struct cmsghdr *cp; - struct mbuf *m; + struct cmsghdr *cp; + struct mbuf *m; if (CMSG_SPACE(size) > MCLBYTES) { printf("sbcreatecontrol: message too large %d\n", size); diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index c8a7eea049f0..72f8d3d7e166 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_syscalls.c,v 1.56 2000/12/10 23:16:28 fvdl Exp $ */ +/* $NetBSD: uipc_syscalls.c,v 1.57 2001/02/27 05:19:15 lukem Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1990, 1993 @@ -42,7 +42,7 @@ * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that * this would be LKM-safe. */ -#define COMPAT_OLDSOCK /* used by */ +#define COMPAT_OLDSOCK /* used by */ #include #include @@ -72,21 +72,19 @@ extern struct fileops socketops; int -sys_socket(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_socket(struct proc *p, void *v, register_t *retval) { struct sys_socket_args /* { - syscallarg(int) domain; - syscallarg(int) type; - syscallarg(int) protocol; + syscallarg(int) domain; + syscallarg(int) type; + syscallarg(int) protocol; } */ *uap = v; - struct filedesc *fdp = p->p_fd; - struct socket *so; - struct file *fp; - int fd, error; + struct filedesc *fdp; + struct socket *so; + struct file *fp; + int fd, error; + fdp = p->p_fd; /* falloc() will use the desciptor for us */ if ((error = falloc(p, &fp, &fd)) != 0) return (error); @@ -109,19 +107,16 @@ sys_socket(p, v, retval) /* ARGSUSED */ int -sys_bind(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_bind(struct proc *p, void *v, register_t *retval) { struct sys_bind_args /* { - syscallarg(int) s; - syscallarg(const struct sockaddr *) name; - syscallarg(unsigned int) namelen; + syscallarg(int) s; + syscallarg(const struct sockaddr *) name; + syscallarg(unsigned int) namelen; } */ *uap = v; - struct file *fp; - struct mbuf *nam; - int error; + struct file *fp; + struct mbuf *nam; + int error; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) @@ -140,17 +135,14 @@ sys_bind(p, v, retval) /* ARGSUSED */ int -sys_listen(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_listen(struct proc *p, void *v, register_t *retval) { struct sys_listen_args /* { - syscallarg(int) s; - syscallarg(int) backlog; + syscallarg(int) s; + syscallarg(int) backlog; } */ *uap = v; - struct file *fp; - int error; + struct file *fp; + int error; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) @@ -161,23 +153,21 @@ sys_listen(p, v, retval) } int -sys_accept(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_accept(struct proc *p, void *v, register_t *retval) { struct sys_accept_args /* { - syscallarg(int) s; - syscallarg(struct sockaddr *) name; - syscallarg(unsigned int *) anamelen; + syscallarg(int) s; + syscallarg(struct sockaddr *) name; + syscallarg(unsigned int *) anamelen; } */ *uap = v; - struct filedesc *fdp = p->p_fd; - struct file *fp; - struct mbuf *nam; - unsigned int namelen; - int error, s, fd; - struct socket *so; + struct filedesc *fdp; + struct file *fp; + struct mbuf *nam; + unsigned int namelen; + int error, s, fd; + struct socket *so; + fdp = p->p_fd; if (SCARG(uap, name) && (error = copyin((caddr_t)SCARG(uap, anamelen), (caddr_t)&namelen, sizeof(namelen)))) return (error); @@ -261,20 +251,17 @@ sys_accept(p, v, retval) /* ARGSUSED */ int -sys_connect(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_connect(struct proc *p, void *v, register_t *retval) { struct sys_connect_args /* { - syscallarg(int) s; - syscallarg(const struct sockaddr *) name; - syscallarg(unsigned int) namelen; + syscallarg(int) s; + syscallarg(const struct sockaddr *) name; + syscallarg(unsigned int) namelen; } */ *uap = v; - struct file *fp; - struct socket *so; - struct mbuf *nam; - int error, s; + struct file *fp; + struct socket *so; + struct mbuf *nam; + int error, s; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) @@ -306,7 +293,7 @@ sys_connect(p, v, retval) so->so_error = 0; } splx(s); -bad: + bad: so->so_state &= ~SS_ISCONNECTING; m_freem(nam); if (error == ERESTART) @@ -315,22 +302,20 @@ bad: } int -sys_socketpair(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_socketpair(struct proc *p, void *v, register_t *retval) { struct sys_socketpair_args /* { - syscallarg(int) domain; - syscallarg(int) type; - syscallarg(int) protocol; - syscallarg(int *) rsv; + syscallarg(int) domain; + syscallarg(int) type; + syscallarg(int) protocol; + syscallarg(int *) rsv; } */ *uap = v; - struct filedesc *fdp = p->p_fd; - struct file *fp1, *fp2; - struct socket *so1, *so2; - int fd, error, sv[2]; + struct filedesc *fdp; + struct file *fp1, *fp2; + struct socket *so1, *so2; + int fd, error, sv[2]; + fdp = p->p_fd; error = socreate(SCARG(uap, domain), &so1, SCARG(uap, type), SCARG(uap, protocol)); if (error) @@ -368,37 +353,34 @@ sys_socketpair(p, v, retval) FILE_UNUSE(fp1, p); FILE_UNUSE(fp2, p); return (error); -free4: + free4: FILE_UNUSE(fp2, p); ffree(fp2); fdremove(fdp, sv[1]); -free3: + free3: FILE_UNUSE(fp1, p); ffree(fp1); fdremove(fdp, sv[0]); -free2: + free2: (void)soclose(so2); -free1: + free1: (void)soclose(so1); return (error); } int -sys_sendto(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_sendto(struct proc *p, void *v, register_t *retval) { struct sys_sendto_args /* { - syscallarg(int) s; - syscallarg(const void *) buf; - syscallarg(size_t) len; - syscallarg(int) flags; - syscallarg(const struct sockaddr *) to; - syscallarg(unsigned int) tolen; + syscallarg(int) s; + syscallarg(const void *) buf; + syscallarg(size_t) len; + syscallarg(int) flags; + syscallarg(const struct sockaddr *) to; + syscallarg(unsigned int) tolen; } */ *uap = v; - struct msghdr msg; - struct iovec aiov; + struct msghdr msg; + struct iovec aiov; msg.msg_name = (caddr_t)SCARG(uap, to); /* XXX kills const */ msg.msg_namelen = SCARG(uap, tolen); @@ -414,19 +396,16 @@ sys_sendto(p, v, retval) } int -sys_sendmsg(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_sendmsg(struct proc *p, void *v, register_t *retval) { struct sys_sendmsg_args /* { - syscallarg(int) s; - syscallarg(const struct msghdr *) msg; - syscallarg(int) flags; + syscallarg(int) s; + syscallarg(const struct msghdr *) msg; + syscallarg(int) flags; } */ *uap = v; - struct msghdr msg; - struct iovec aiov[UIO_SMALLIOV], *iov; - int error; + struct msghdr msg; + struct iovec aiov[UIO_SMALLIOV], *iov; + int error; error = copyin(SCARG(uap, msg), (caddr_t)&msg, sizeof(msg)); if (error) @@ -456,24 +435,21 @@ done: } int -sendit(p, s, mp, flags, retsize) - struct proc *p; - int s; - struct msghdr *mp; - int flags; - register_t *retsize; +sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize) { - struct file *fp; - struct uio auio; - struct iovec *iov; - int i; - struct mbuf *to, *control; - int len, error; - struct socket *so; + struct file *fp; + struct uio auio; + struct iovec *iov; + int i, len, error; + struct mbuf *to, *control; + struct socket *so; #ifdef KTRACE - struct iovec *ktriov = NULL; + struct iovec *ktriov; #endif +#ifdef KTRACE + ktriov = NULL; +#endif /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, s, &fp)) != 0) return (error); @@ -578,22 +554,19 @@ sendit(p, s, mp, flags, retsize) } int -sys_recvfrom(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_recvfrom(struct proc *p, void *v, register_t *retval) { struct sys_recvfrom_args /* { - syscallarg(int) s; - syscallarg(void *) buf; - syscallarg(size_t) len; - syscallarg(int) flags; - syscallarg(struct sockaddr *) from; - syscallarg(unsigned int *) fromlenaddr; + syscallarg(int) s; + syscallarg(void *) buf; + syscallarg(size_t) len; + syscallarg(int) flags; + syscallarg(struct sockaddr *) from; + syscallarg(unsigned int *) fromlenaddr; } */ *uap = v; - struct msghdr msg; - struct iovec aiov; - int error; + struct msghdr msg; + struct iovec aiov; + int error; if (SCARG(uap, fromlenaddr)) { error = copyin((caddr_t)SCARG(uap, fromlenaddr), @@ -615,19 +588,16 @@ sys_recvfrom(p, v, retval) } int -sys_recvmsg(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_recvmsg(struct proc *p, void *v, register_t *retval) { struct sys_recvmsg_args /* { - syscallarg(int) s; - syscallarg(struct msghdr *) msg; - syscallarg(int) flags; + syscallarg(int) s; + syscallarg(struct msghdr *) msg; + syscallarg(int) flags; } */ *uap = v; - struct msghdr msg; - struct iovec aiov[UIO_SMALLIOV], *uiov, *iov; - int error; + struct msghdr msg; + struct iovec aiov[UIO_SMALLIOV], *uiov, *iov; + int error; error = copyin((caddr_t)SCARG(uap, msg), (caddr_t)&msg, sizeof(msg)); @@ -665,22 +635,23 @@ done: } int -recvit(p, s, mp, namelenp, retsize) - struct proc *p; - int s; - struct msghdr *mp; - caddr_t namelenp; - register_t *retsize; +recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp, + register_t *retsize) { - struct file *fp; - struct uio auio; - struct iovec *iov; - int i; - int len, error; - struct mbuf *from = 0, *control = 0; - struct socket *so; + struct file *fp; + struct uio auio; + struct iovec *iov; + int i, len, error; + struct mbuf *from, *control; + struct socket *so; #ifdef KTRACE - struct iovec *ktriov = NULL; + struct iovec *ktriov; +#endif + + from = 0; + control = 0; +#ifdef KTRACE + ktriov = NULL; #endif /* getsock() will use the descriptor for us */ @@ -829,17 +800,14 @@ recvit(p, s, mp, namelenp, retsize) /* ARGSUSED */ int -sys_shutdown(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_shutdown(struct proc *p, void *v, register_t *retval) { struct sys_shutdown_args /* { - syscallarg(int) s; - syscallarg(int) how; + syscallarg(int) s; + syscallarg(int) how; } */ *uap = v; - struct file *fp; - int error; + struct file *fp; + int error; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) @@ -851,22 +819,20 @@ sys_shutdown(p, v, retval) /* ARGSUSED */ int -sys_setsockopt(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_setsockopt(struct proc *p, void *v, register_t *retval) { struct sys_setsockopt_args /* { - syscallarg(int) s; - syscallarg(int) level; - syscallarg(int) name; - syscallarg(const void *) val; - syscallarg(unsigned int) valsize; + syscallarg(int) s; + syscallarg(int) level; + syscallarg(int) name; + syscallarg(const void *) val; + syscallarg(unsigned int) valsize; } */ *uap = v; - struct file *fp; - struct mbuf *m = NULL; - int error; + struct file *fp; + struct mbuf *m; + int error; + m = NULL; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); @@ -893,23 +859,21 @@ sys_setsockopt(p, v, retval) /* ARGSUSED */ int -sys_getsockopt(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_getsockopt(struct proc *p, void *v, register_t *retval) { struct sys_getsockopt_args /* { - syscallarg(int) s; - syscallarg(int) level; - syscallarg(int) name; - syscallarg(void *) val; - syscallarg(unsigned int *) avalsize; + syscallarg(int) s; + syscallarg(int) level; + syscallarg(int) name; + syscallarg(void *) val; + syscallarg(unsigned int *) avalsize; } */ *uap = v; - struct file *fp; - struct mbuf *m = NULL, *m0; - unsigned int op, i, valsize; - int error; + struct file *fp; + struct mbuf *m, *m0; + unsigned int op, i, valsize; + int error; + m = NULL; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); @@ -946,16 +910,14 @@ sys_getsockopt(p, v, retval) /* ARGSUSED */ int -sys_pipe(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_pipe(struct proc *p, void *v, register_t *retval) { - struct filedesc *fdp = p->p_fd; - struct file *rf, *wf; - struct socket *rso, *wso; - int fd, error; + struct filedesc *fdp; + struct file *rf, *wf; + struct socket *rso, *wso; + int fd, error; + fdp = p->p_fd; if ((error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0)) != 0) return (error); if ((error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0)) != 0) @@ -980,17 +942,17 @@ sys_pipe(p, v, retval) FILE_UNUSE(rf, p); FILE_UNUSE(wf, p); return (0); -free4: + free4: FILE_UNUSE(wf, p); ffree(wf); fdremove(fdp, retval[1]); -free3: + free3: FILE_UNUSE(rf, p); ffree(rf); fdremove(fdp, retval[0]); -free2: + free2: (void)soclose(wso); -free1: + free1: (void)soclose(rso); return (error); } @@ -1000,21 +962,18 @@ free1: */ /* ARGSUSED */ int -sys_getsockname(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_getsockname(struct proc *p, void *v, register_t *retval) { struct sys_getsockname_args /* { - syscallarg(int) fdes; - syscallarg(struct sockaddr *) asa; - syscallarg(unsigned int *) alen; + syscallarg(int) fdes; + syscallarg(struct sockaddr *) asa; + syscallarg(unsigned int *) alen; } */ *uap = v; - struct file *fp; - struct socket *so; - struct mbuf *m; - unsigned int len; - int error; + struct file *fp; + struct socket *so; + struct mbuf *m; + unsigned int len; + int error; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0) @@ -1046,21 +1005,18 @@ sys_getsockname(p, v, retval) */ /* ARGSUSED */ int -sys_getpeername(p, v, retval) - struct proc *p; - void *v; - register_t *retval; +sys_getpeername(struct proc *p, void *v, register_t *retval) { struct sys_getpeername_args /* { - syscallarg(int) fdes; - syscallarg(struct sockaddr *) asa; - syscallarg(unsigned int *) alen; + syscallarg(int) fdes; + syscallarg(struct sockaddr *) asa; + syscallarg(unsigned int *) alen; } */ *uap = v; - struct file *fp; - struct socket *so; - struct mbuf *m; - unsigned int len; - int error; + struct file *fp; + struct socket *so; + struct mbuf *m; + unsigned int len; + int error; /* getsock() will use the descriptor for us */ if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0) @@ -1096,14 +1052,11 @@ sys_getpeername(p, v, retval) * XXX arguments in mbufs, and this could go away. */ int -sockargs(mp, buf, buflen, type) - struct mbuf **mp; - const void *buf; - int buflen, type; +sockargs(struct mbuf **mp, const void *buf, int buflen, int type) { - struct sockaddr *sa; - struct mbuf *m; - int error; + struct sockaddr *sa; + struct mbuf *m; + int error; /* * We can't allow socket names > UCHAR_MAX in length, since that @@ -1141,12 +1094,9 @@ sockargs(mp, buf, buflen, type) } int -getsock(fdp, fdes, fpp) - struct filedesc *fdp; - int fdes; - struct file **fpp; +getsock(struct filedesc *fdp, int fdes, struct file **fpp) { - struct file *fp; + struct file *fp; if ((unsigned)fdes >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fdes]) == NULL ||