+ fp = getf(uap->s);
+ if (fp == 0)
+ return;
+ if (fp->f_type != DTYPE_SOCKET) {
+ u.u_error = ENOTSOCK;
+ return;
+ }
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ aiov.iov_base = uap->buf;
+ aiov.iov_len = uap->len;
+ auio.uio_resid = uap->len;
+ auio.uio_segflg = 0;
+ auio.uio_offset = 0; /* XXX */
+ if (useracc(uap->buf, uap->len, B_READ) == 0) {
+ u.u_error = EFAULT;
+ return;
+ }
+ if (u.u_error)
+ return;
+ u.u_error = sosend(fp->f_socket, (struct mbuf *)0, &auio, uap->flags);
+}
+
+recvfrom()
+{
+ register struct a {
+ int s;
+ caddr_t buf;
+ int len;
+ int flags;
+ caddr_t from;
+ int *fromlenaddr;
+ } *uap = (struct a *)u.u_ap;
+ register struct file *fp;
+ struct uio auio;
+ struct iovec aiov;
+ struct mbuf *from;
+ int fromlen;
+
+ if (copyin((caddr_t)uap->fromlenaddr, (caddr_t)&fromlen, sizeof (fromlen))) {
+ u.u_error = EFAULT;
+ return;
+ }
+ fp = getf(uap->s);
+ if (fp == 0)
+ return;
+ if (fp->f_type != DTYPE_SOCKET) {
+ u.u_error = ENOTSOCK;
+ return;
+ }
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ aiov.iov_base = uap->buf;
+ aiov.iov_len = uap->len;
+ auio.uio_resid = uap->len;
+ auio.uio_segflg = 0;
+ auio.uio_offset = 0; /* XXX */
+ if (useracc(uap->buf, uap->len, B_WRITE) == 0) {
+ u.u_error = EFAULT;
+ return;
+ }
+ from = 0;
+ u.u_error = soreceive(fp->f_socket, &from, &auio, uap->flags);
+ if (u.u_error)
+ goto bad;
+ if (from == 0)
+ fromlen = 0;
+ else {
+ if (fromlen > from->m_len)
+ fromlen = from->m_len;
+ if (copyout(mtod(from, caddr_t), uap->from, fromlen)) {
+ u.u_error = EFAULT;
+ goto bad;
+ }
+ }
+ if (copyout((caddr_t)&fromlen, (caddr_t)uap->fromlenaddr,
+ sizeof (fromlen))) {
+ u.u_error = EFAULT;
+ goto bad;
+ }
+ u.u_r.r_val1 = uap->len - auio.uio_resid;
+bad:
+ if (from)
+ m_freem(from);
+ return;
+}
+
+recv()
+{
+ register struct a {
+ int s;
+ caddr_t buf;
+ int len;
+ int flags;
+ } *uap = (struct a *)u.u_ap;
+ register struct file *fp;
+ struct uio auio;
+ struct iovec aiov;
+
+ fp = getf(uap->s);