diff options
author | fenner <fenner@FreeBSD.org> | 1996-11-11 04:56:32 +0000 |
---|---|---|
committer | fenner <fenner@FreeBSD.org> | 1996-11-11 04:56:32 +0000 |
commit | 51fa6f0e6c383037d81db2731606bf56378e1128 (patch) | |
tree | a1e9ea181d1b4cfcc3feaf4440cf48d359494bea /sys/netinet/ip_input.c | |
parent | 3b0a2952693ec15704f4dc217c9363c79260c647 (diff) | |
download | FreeBSD-src-51fa6f0e6c383037d81db2731606bf56378e1128.zip FreeBSD-src-51fa6f0e6c383037d81db2731606bf56378e1128.tar.gz |
Add the IP_RECVIF socket option, which supplies a packet's incoming interface
using a sockaddr_dl.
Fix the other packet-information socket options (SO_TIMESTAMP, IP_RECVDSTADDR)
to work for multicast UDP and raw sockets as well. (They previously only
worked for unicast UDP).
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r-- | sys/netinet/ip_input.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index cfe1d4a..9c57dff 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 - * $Id: ip_input.c,v 1.49 1996/10/22 22:25:58 sos Exp $ + * $Id: ip_input.c,v 1.50 1996/10/25 17:57:45 fenner Exp $ * $ANA: ip_input.c,v 1.5 1996/09/18 14:34:59 wollman Exp $ */ @@ -39,6 +39,8 @@ #include "opt_ipfw.h" +#include <stddef.h> + #include <sys/param.h> #include <sys/systm.h> #include <sys/malloc.h> @@ -53,6 +55,7 @@ #include <sys/sysctl.h> #include <net/if.h> +#include <net/if_dl.h> #include <net/route.h> #include <net/netisr.h> @@ -1313,6 +1316,63 @@ ip_forward(m, srcrt) icmp_error(mcopy, type, code, dest, destifp); } +void +ip_savecontrol(inp, mp, ip, m) + register struct inpcb *inp; + register struct mbuf **mp; + register struct ip *ip; + register struct mbuf *m; +{ + if (inp->inp_socket->so_options & SO_TIMESTAMP) { + struct timeval tv; + + microtime(&tv); + *mp = sbcreatecontrol((caddr_t) &tv, sizeof(tv), + SCM_TIMESTAMP, SOL_SOCKET); + if (*mp) + mp = &(*mp)->m_next; + } + if (inp->inp_flags & INP_RECVDSTADDR) { + *mp = sbcreatecontrol((caddr_t) &ip->ip_dst, + sizeof(struct in_addr), IP_RECVDSTADDR, IPPROTO_IP); + if (*mp) + mp = &(*mp)->m_next; + } +#ifdef notyet + /* XXX + * Moving these out of udp_input() made them even more broken + * than they already were. + */ + /* options were tossed already */ + if (inp->inp_flags & INP_RECVOPTS) { + *mp = sbcreatecontrol((caddr_t) opts_deleted_above, + sizeof(struct in_addr), IP_RECVOPTS, IPPROTO_IP); + if (*mp) + mp = &(*mp)->m_next; + } + /* ip_srcroute doesn't do what we want here, need to fix */ + if (inp->inp_flags & INP_RECVRETOPTS) { + *mp = sbcreatecontrol((caddr_t) ip_srcroute(), + sizeof(struct in_addr), IP_RECVRETOPTS, IPPROTO_IP); + if (*mp) + mp = &(*mp)->m_next; + } +#endif + if (inp->inp_flags & INP_RECVIF) { + struct sockaddr_dl sdl; + + sdl.sdl_len = offsetof(struct sockaddr_dl, sdl_data[0]); + sdl.sdl_family = AF_LINK; + sdl.sdl_index = m->m_pkthdr.rcvif ? + m->m_pkthdr.rcvif->if_index : 0; + sdl.sdl_nlen = sdl.sdl_alen = sdl.sdl_slen = 0; + *mp = sbcreatecontrol((caddr_t) &sdl, sdl.sdl_len, + IP_RECVIF, IPPROTO_IP); + if (*mp) + mp = &(*mp)->m_next; + } +} + int ip_rsvp_init(struct socket *so) { |