Skip to content

Commit

Permalink
Prefix field in RIO to variable length
Browse files Browse the repository at this point in the history
  • Loading branch information
y-kzm committed Nov 1, 2024
1 parent 3c9d491 commit a7231ff
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions send.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,16 @@ static struct safe_buffer_list *add_ra_options_route(struct safe_buffer_list *sb
memset(&rinfo, 0, sizeof(rinfo));

rinfo.nd_opt_ri_type = ND_OPT_ROUTE_INFORMATION;
/* XXX: the prefixes are allowed to be sent in smaller chunks as well */
rinfo.nd_opt_ri_len = 3;
if (route->PrefixLen == 0) {
rinfo.nd_opt_ri_len = 1;
} else if (route->PrefixLen > 0 && route->PrefixLen <= 64) {
rinfo.nd_opt_ri_len = 2;
} else if (route->PrefixLen > 64 && route->PrefixLen <= 128) {
rinfo.nd_opt_ri_len = 3;
} else {
route = route->next;
continue;
}
rinfo.nd_opt_ri_prefix_len = route->PrefixLen;

rinfo.nd_opt_ri_flags_reserved = (route->AdvRoutePreference << ND_OPT_RI_PRF_SHIFT) & ND_OPT_RI_PRF_MASK;
Expand All @@ -585,7 +593,7 @@ static struct safe_buffer_list *add_ra_options_route(struct safe_buffer_list *sb
memcpy(&rinfo.nd_opt_ri_prefix, &route->Prefix, sizeof(struct in6_addr));

sbl = safe_buffer_list_append(sbl);
safe_buffer_append(sbl->sb, &rinfo, sizeof(rinfo));
safe_buffer_append(sbl->sb, &rinfo, rinfo.nd_opt_ri_len * 8);

route = route->next;
}
Expand Down

0 comments on commit a7231ff

Please sign in to comment.