diff options
| author | 2006-05-29 20:42:27 +0000 | |
|---|---|---|
| committer | 2006-05-29 20:42:27 +0000 | |
| commit | cf2503d7b5e946bec1fa4ddbf4f93f672319af87 (patch) | |
| tree | e2c82afee3fffb547c29316fec1b3a71b80a812a /sys/netinet/udp_usrreq.c | |
| parent | No need for return; at end of functions returning void. (diff) | |
| download | wireguard-openbsd-cf2503d7b5e946bec1fa4ddbf4f93f672319af87.tar.xz wireguard-openbsd-cf2503d7b5e946bec1fa4ddbf4f93f672319af87.zip | |
Make savecontrol functions more generic and use them now for raw IP too.
Additionally add the IP_RECVIF option which returns the interface a packet
was received on. OK markus@ norby@
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
| -rw-r--r-- | sys/netinet/udp_usrreq.c | 57 |
1 files changed, 4 insertions, 53 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 2e1cdb35394..d29e3674852 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.107 2006/05/16 12:39:21 markus Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.108 2006/05/29 20:42:27 claudio Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -120,7 +120,6 @@ struct udpstat udpstat; static void udp_detach(struct inpcb *); static void udp_notify(struct inpcb *, int); -static struct mbuf *udp_saveopt(caddr_t, int, int); #ifndef UDBHASHSIZE #define UDBHASHSIZE 128 @@ -624,32 +623,9 @@ udp_input(struct mbuf *m, ...) if (ip6 && (inp->inp_flags & IN6P_CONTROLOPTS)) ip6_savecontrol(inp, &opts, ip6, m); #endif /* INET6 */ - if (ip && (inp->inp_flags & INP_CONTROLOPTS)) { - struct mbuf **mp = &opts; - - if (inp->inp_flags & INP_RECVDSTADDR) { - *mp = udp_saveopt((caddr_t) &ip->ip_dst, - sizeof(struct in_addr), IP_RECVDSTADDR); - if (*mp) - mp = &(*mp)->m_next; - } -#ifdef notyet - /* options were tossed above */ - if (inp->inp_flags & INP_RECVOPTS) { - *mp = udp_saveopt((caddr_t) opts_deleted_above, - sizeof(struct in_addr), IP_RECVOPTS); - 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 = udp_saveopt((caddr_t) ip_srcroute(), - sizeof(struct in_addr), IP_RECVRETOPTS); - if (*mp) - mp = &(*mp)->m_next; - } -#endif - } + if (ip && (inp->inp_flags & INP_CONTROLOPTS)) + ip_savecontrol(inp, &opts, ip, m); + iphlen += sizeof(struct udphdr); m_adj(m, iphlen); if (sbappendaddr(&inp->inp_socket->so_rcv, &srcsa.sa, m, opts) == 0) { @@ -665,31 +641,6 @@ bad: } /* - * Create a "control" mbuf containing the specified data - * with the specified type for presentation with a datagram. - */ -struct mbuf * -udp_saveopt(p, size, type) - caddr_t p; - int size; - int type; -{ - struct cmsghdr *cp; - struct mbuf *m; - - if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL) - return ((struct mbuf *) NULL); - cp = (struct cmsghdr *) mtod(m, struct cmsghdr *); - bcopy(p, CMSG_DATA(cp), size); - size = CMSG_LEN(size); - m->m_len = size; - cp->cmsg_len = size; - cp->cmsg_level = IPPROTO_IP; - cp->cmsg_type = type; - return (m); -} - -/* * Notify a udp user of an asynchronous error; * just wake up so that he can collect error status. */ |
