diff options
author | marcel <marcel@FreeBSD.org> | 2014-08-03 02:24:52 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2014-08-03 02:24:52 +0000 |
commit | aef52ec818fb09d9eebb5e6e17f5af674ba9d90c (patch) | |
tree | dc07059f1788eb1e64f0ad741b5c228b8173b616 /lib/libc | |
parent | b37299ed785ac4eb45217050ecf4a151341f2b1b (diff) | |
download | FreeBSD-src-aef52ec818fb09d9eebb5e6e17f5af674ba9d90c.zip FreeBSD-src-aef52ec818fb09d9eebb5e6e17f5af674ba9d90c.tar.gz |
MFC 264162: Accept RFC 2292 option values so that RFC 2292 compliant
programs that are unaware of RFC 3542 can construct control messages.
Obtained from: Juniper Networks, Inc.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/net/ip6opt.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/libc/net/ip6opt.c b/lib/libc/net/ip6opt.c index 003c625..d7ea182 100644 --- a/lib/libc/net/ip6opt.c +++ b/lib/libc/net/ip6opt.c @@ -45,6 +45,18 @@ __FBSDID("$FreeBSD$"); static int ip6optlen(u_int8_t *opt, u_int8_t *lim); static void inet6_insert_padopt(u_char *p, int len); +#ifndef IPV6_2292HOPOPTS +#define IPV6_2292HOPOPTS 22 +#endif +#ifndef IPV6_2292DSTOPTS +#define IPV6_2292DSTOPTS 23 +#endif + +#define is_ipv6_hopopts(x) \ + ((x) == IPV6_HOPOPTS || (x) == IPV6_2292HOPOPTS) +#define is_ipv6_dstopts(x) \ + ((x) == IPV6_DSTOPTS || (x) == IPV6_2292DSTOPTS) + /* * This function returns the number of bytes required to hold an option * when it is stored as ancillary data, including the cmsghdr structure @@ -72,9 +84,9 @@ inet6_option_init(void *bp, struct cmsghdr **cmsgp, int type) struct cmsghdr *ch = (struct cmsghdr *)bp; /* argument validation */ - if (type != IPV6_HOPOPTS && type != IPV6_DSTOPTS) + if (!is_ipv6_hopopts(type) && !is_ipv6_dstopts(type)) return(-1); - + ch->cmsg_level = IPPROTO_IPV6; ch->cmsg_type = type; ch->cmsg_len = CMSG_LEN(0); @@ -234,8 +246,8 @@ inet6_option_next(const struct cmsghdr *cmsg, u_int8_t **tptrp) u_int8_t *lim; if (cmsg->cmsg_level != IPPROTO_IPV6 || - (cmsg->cmsg_type != IPV6_HOPOPTS && - cmsg->cmsg_type != IPV6_DSTOPTS)) + (!is_ipv6_hopopts(cmsg->cmsg_type) && + !is_ipv6_dstopts(cmsg->cmsg_type))) return(-1); /* message length validation */ @@ -290,8 +302,8 @@ inet6_option_find(const struct cmsghdr *cmsg, u_int8_t **tptrp, int type) u_int8_t *optp, *lim; if (cmsg->cmsg_level != IPPROTO_IPV6 || - (cmsg->cmsg_type != IPV6_HOPOPTS && - cmsg->cmsg_type != IPV6_DSTOPTS)) + (!is_ipv6_hopopts(cmsg->cmsg_type) && + !is_ipv6_dstopts(cmsg->cmsg_type))) return(-1); /* message length validation */ |