summaryrefslogtreecommitdiff
path: root/sys/netinet/raw_ip.c
diff options
context:
space:
mode:
authorChris Kuethe <ckuethe@cvs.openbsd.org>2008-05-02 06:49:33 +0000
committerChris Kuethe <ckuethe@cvs.openbsd.org>2008-05-02 06:49:33 +0000
commitac62022e3319b58cd03e552240772872ff219a70 (patch)
tree11d64a9c749b3f2f1d31c20967ddf7faef658b0f /sys/netinet/raw_ip.c
parent7f740532bb7e0e07efa3aea9fae9139a1f135642 (diff)
Make the SO_TIMESTAMP sockopt work. When set, this allows the user to
get a timestamp of when the datagram was accepted (by udp(4), for example) rather than having to take a timestamp with gettimeofday(2) when recv(2) returns - possibly several hundreds of microseconds later. May be of use to those interested in precision network timing schemes or QoS for media applications. Tested on alpha, amd64, i386 and sparc64. manpage suggestions from jmc, ok deraadt
Diffstat (limited to 'sys/netinet/raw_ip.c')
-rw-r--r--sys/netinet/raw_ip.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index c06aa1bc0ea..a92c9870bf3 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip.c,v 1.40 2006/11/25 18:04:44 claudio Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.41 2008/05/02 06:49:32 ckuethe Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@@ -141,7 +141,8 @@ rip_input(struct mbuf *m, ...)
struct mbuf *n;
if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
- if (last->inp_flags & INP_CONTROLOPTS)
+ if (last->inp_flags & INP_CONTROLOPTS ||
+ last->inp_socket->so_options & SO_TIMESTAMP)
ip_savecontrol(last, &opts, ip, n);
if (sbappendaddr(&last->inp_socket->so_rcv,
sintosa(&ripsrc), n, opts) == 0) {
@@ -157,7 +158,8 @@ rip_input(struct mbuf *m, ...)
last = inp;
}
if (last) {
- if (last->inp_flags & INP_CONTROLOPTS)
+ if (last->inp_flags & INP_CONTROLOPTS ||
+ last->inp_socket->so_options & SO_TIMESTAMP)
ip_savecontrol(last, &opts, ip, m);
if (sbappendaddr(&last->inp_socket->so_rcv, sintosa(&ripsrc), m,
opts) == 0) {