diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-10-11 09:29:21 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-10-11 09:29:21 +0000 |
commit | 38d0057501a91a9d902cdb4a7ed20385b9613034 (patch) | |
tree | b970c268320ff7656c424ff27cfb61d1e92f497d /sys/netinet/ip_output.c | |
parent | 99c080a083c1cc366cfc123fed9104129efbd87f (diff) |
implement IP_RECVTTL socket option.
when set on raw or udp sockets, userland receives the incoming packet's TTL
as ancillary data (cmsg shitz). modeled after the FreeBSD implementation.
ok claudio djm deraadt
Diffstat (limited to 'sys/netinet/ip_output.c')
-rw-r--r-- | sys/netinet/ip_output.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 65e8698445f..3a42e2f72b0 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.180 2006/06/18 11:47:45 pascoe Exp $ */ +/* $OpenBSD: ip_output.c,v 1.181 2006/10/11 09:29:20 henning Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -1048,6 +1048,7 @@ ip_ctloutput(op, so, level, optname, mp) case IP_RECVRETOPTS: case IP_RECVDSTADDR: case IP_RECVIF: + case IP_RECVTTL: if (m == NULL || m->m_len != sizeof(int)) error = EINVAL; else { @@ -1061,6 +1062,7 @@ ip_ctloutput(op, so, level, optname, mp) case IP_TTL: inp->inp_ip.ip_ttl = optval; break; + #define OPTSET(bit) \ if (optval) \ inp->inp_flags |= bit; \ @@ -1081,6 +1083,9 @@ ip_ctloutput(op, so, level, optname, mp) case IP_RECVIF: OPTSET(INP_RECVIF); break; + case IP_RECVTTL: + OPTSET(INP_RECVTTL); + break; } } break; @@ -1383,6 +1388,7 @@ ip_ctloutput(op, so, level, optname, mp) case IP_RECVRETOPTS: case IP_RECVDSTADDR: case IP_RECVIF: + case IP_RECVTTL: *mp = m = m_get(M_WAIT, MT_SOOPTS); m->m_len = sizeof(int); switch (optname) { @@ -1411,6 +1417,9 @@ ip_ctloutput(op, so, level, optname, mp) case IP_RECVIF: optval = OPTBIT(INP_RECVIF); break; + case IP_RECVTTL: + optval = OPTBIT(INP_RECVTTL); + break; } *mtod(m, int *) = optval; break; |