diff options
author | wollman <wollman@FreeBSD.org> | 1996-05-09 20:15:26 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1996-05-09 20:15:26 +0000 |
commit | 9ea36adbecaec6093c2c6769fbc0e405e5618487 (patch) | |
tree | b2796b2139f8fbb109be2d52262cfb5aa78d7df7 /sys/kern | |
parent | 86058739b95ae00ed08a591f6e8001326915086f (diff) | |
download | FreeBSD-src-9ea36adbecaec6093c2c6769fbc0e405e5618487.zip FreeBSD-src-9ea36adbecaec6093c2c6769fbc0e405e5618487.tar.gz |
Make it possible to return more than one piece of control information
(PR #1178).
Define a new SO_TIMESTAMP socket option for datagram sockets to return
packet-arrival timestamps as control information (PR #1179).
Submitted by: Louis Mamakos <loiue@TransSys.com>
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_socket.c | 4 | ||||
-rw-r--r-- | sys/kern/uipc_syscalls.c | 35 |
2 files changed, 27 insertions, 12 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 72a4567..b58eb51 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94 - * $Id: uipc_socket.c,v 1.16 1996/03/11 15:37:31 davidg Exp $ + * $Id: uipc_socket.c,v 1.17 1996/04/16 03:50:08 davidg Exp $ */ #include <sys/param.h> @@ -893,6 +893,7 @@ sosetopt(so, level, optname, m0) case SO_REUSEADDR: case SO_REUSEPORT: case SO_OOBINLINE: + case SO_TIMESTAMP: if (m == NULL || m->m_len < sizeof (int)) { error = EINVAL; goto bad; @@ -1017,6 +1018,7 @@ sogetopt(so, level, optname, mp) case SO_REUSEPORT: case SO_BROADCAST: case SO_OOBINLINE: + case SO_TIMESTAMP: *mtod(m, int *) = so->so_options & optname; break; diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index b366e94..6e17484 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94 - * $Id: uipc_syscalls.c,v 1.15 1996/02/24 13:38:07 phk Exp $ + * $Id: uipc_syscalls.c,v 1.16 1996/03/11 15:37:33 davidg Exp $ */ #include "opt_ktrace.h" @@ -636,7 +636,8 @@ recvit(p, s, mp, namelenp, retsize) register struct iovec *iov; register int i; int len, error; - struct mbuf *from = 0, *control = 0; + struct mbuf *m, *from = 0, *control = 0; + caddr_t ctlbuf; #ifdef KTRACE struct iovec *ktriov = NULL; #endif @@ -735,17 +736,29 @@ recvit(p, s, mp, namelenp, retsize) } #endif len = mp->msg_controllen; - if (len <= 0 || control == 0) - len = 0; - else { - if (len >= control->m_len) - len = control->m_len; - else + m = control; + mp->msg_controllen = 0; + ctlbuf = (caddr_t) mp->msg_control; + + while (m && len > 0) { + unsigned int tocopy; + + if (len >= m->m_len) + tocopy = m->m_len; + else { mp->msg_flags |= MSG_CTRUNC; - error = copyout((caddr_t)mtod(control, caddr_t), - (caddr_t)mp->msg_control, (unsigned)len); + tocopy = len; + } + + if (error = copyout((caddr_t)mtod(m, caddr_t), + ctlbuf, tocopy)) + goto out; + + ctlbuf += tocopy; + len -= tocopy; + m = m->m_next; } - mp->msg_controllen = len; + mp->msg_controllen = ctlbuf - mp->msg_control; } out: if (from) |