diff options
author | Steven Barth <steven@midlink.org> | 2014-02-17 21:08:29 +0100 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2014-02-17 21:08:29 +0100 |
commit | e9a21fdb43c9f94762a724db1a043b376f745ae3 (patch) | |
tree | 46704261aec9ca25023541c0d7275db2ebaf71be /src/router.c | |
parent | 6d644f0991c51fffcc5312e73b42126b7c6559bf (diff) |
Add support for (managed) prefixes of length 65-96
Diffstat (limited to 'src/router.c')
-rw-r--r-- | src/router.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/router.c b/src/router.c index 372c400..907011a 100644 --- a/src/router.c +++ b/src/router.c @@ -296,7 +296,7 @@ static void send_router_advert(struct uloop_timeout *event) for (ssize_t i = 0; i < ipcnt; ++i) { struct odhcpd_ipaddr *addr = &addrs[i]; - if (addr->prefix > 64 || addr->has_class) + if (addr->prefix > 96 || addr->has_class) continue; // Address not suitable if (addr->preferred > MaxPreferredTime) @@ -307,8 +307,9 @@ static void send_router_advert(struct uloop_timeout *event) struct nd_opt_prefix_info *p = NULL; for (size_t i = 0; i < cnt; ++i) { - if (!memcmp(&adv.prefix[i].nd_opt_pi_prefix, - &addr->addr, 8)) + if (addr->prefix == adv.prefix[i].nd_opt_pi_prefix_len && + !odhcpd_bmemcmp(&adv.prefix[i].nd_opt_pi_prefix, + &addr->addr, addr->prefix)) p = &adv.prefix[i]; } @@ -326,14 +327,14 @@ static void send_router_advert(struct uloop_timeout *event) maxpreferred = 1000 * addr->preferred; } - memcpy(&p->nd_opt_pi_prefix, &addr->addr, 8); + odhcpd_bmemcpy(&p->nd_opt_pi_prefix, &addr->addr, addr->prefix); p->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION; p->nd_opt_pi_len = 4; - p->nd_opt_pi_prefix_len = 64; + p->nd_opt_pi_prefix_len = (addr->prefix < 64) ? 64 : addr->prefix; p->nd_opt_pi_flags_reserved = 0; if (!iface->ra_not_onlink) p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_ONLINK; - if (iface->managed < RELAYD_MANAGED_NO_AFLAG) + if (iface->managed < RELAYD_MANAGED_NO_AFLAG && addr->prefix <= 64) p->nd_opt_pi_flags_reserved |= ND_OPT_PI_FLAG_AUTO; p->nd_opt_pi_valid_time = htonl(addr->valid); p->nd_opt_pi_preferred_time = htonl(addr->preferred); |