mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-28 17:25:42 +00:00
ospf6d: replace OSPF6_LSA_END with ospf6_lsa_end
Replacing the macro with an inline function enables better type checking. No functional change. Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
This commit is contained in:
parent
4d06e27569
commit
954f2ac581
@ -705,7 +705,8 @@ static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
}
|
||||
|
||||
start = (char *)link_lsa + sizeof(struct ospf6_link_lsa);
|
||||
end = (char *)lsa->header + ntohs(lsa->header->length);
|
||||
end = ospf6_lsa_end(lsa->header);
|
||||
|
||||
for (current = start; current < end;
|
||||
current += OSPF6_PREFIX_SIZE(prefix)) {
|
||||
prefix = (struct ospf6_prefix *)current;
|
||||
@ -864,7 +865,7 @@ static char *ospf6_intra_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa,
|
||||
|
||||
start = (char *)intra_prefix_lsa
|
||||
+ sizeof(struct ospf6_intra_prefix_lsa);
|
||||
end = (char *)lsa->header + ntohs(lsa->header->length);
|
||||
end = ospf6_lsa_end(lsa->header);
|
||||
current = start;
|
||||
|
||||
while (current + sizeof(struct ospf6_prefix) <= end) {
|
||||
@ -935,7 +936,8 @@ static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
|
||||
start = (char *)intra_prefix_lsa
|
||||
+ sizeof(struct ospf6_intra_prefix_lsa);
|
||||
end = (char *)lsa->header + ntohs(lsa->header->length);
|
||||
end = ospf6_lsa_end(lsa->header);
|
||||
|
||||
for (current = start; current < end;
|
||||
current += OSPF6_PREFIX_SIZE(prefix)) {
|
||||
prefix = (struct ospf6_prefix *)current;
|
||||
@ -1315,7 +1317,8 @@ void ospf6_intra_prefix_lsa_originate_transit(struct event *thread)
|
||||
|
||||
prefix_num = (unsigned short)ntohl(link_lsa->prefix_num);
|
||||
start = (char *)link_lsa + sizeof(struct ospf6_link_lsa);
|
||||
end = (char *)lsa->header + ntohs(lsa->header->length);
|
||||
end = ospf6_lsa_end(lsa->header);
|
||||
|
||||
for (current = start; current < end && prefix_num;
|
||||
current += OSPF6_PREFIX_SIZE(op)) {
|
||||
op = (struct ospf6_prefix *)current;
|
||||
@ -1770,7 +1773,7 @@ void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa)
|
||||
prefix_num = ntohs(intra_prefix_lsa->prefix_num);
|
||||
start = (caddr_t)intra_prefix_lsa
|
||||
+ sizeof(struct ospf6_intra_prefix_lsa);
|
||||
end = OSPF6_LSA_END(lsa->header);
|
||||
end = ospf6_lsa_end(lsa->header);
|
||||
for (current = start; current < end; current += OSPF6_PREFIX_SIZE(op)) {
|
||||
op = (struct ospf6_prefix *)current;
|
||||
if (prefix_num == 0)
|
||||
@ -1974,7 +1977,7 @@ void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa)
|
||||
prefix_num = ntohs(intra_prefix_lsa->prefix_num);
|
||||
start = (caddr_t)intra_prefix_lsa
|
||||
+ sizeof(struct ospf6_intra_prefix_lsa);
|
||||
end = OSPF6_LSA_END(lsa->header);
|
||||
end = ospf6_lsa_end(lsa->header);
|
||||
for (current = start; current < end; current += OSPF6_PREFIX_SIZE(op)) {
|
||||
op = (struct ospf6_prefix *)current;
|
||||
if (prefix_num == 0)
|
||||
|
@ -66,7 +66,7 @@ static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
char *start, *end, *current;
|
||||
|
||||
start = ospf6_lsa_header_end(lsa->header);
|
||||
end = (char *)lsa->header + ntohs(lsa->header->length);
|
||||
end = ospf6_lsa_end(lsa->header);
|
||||
|
||||
if (use_json) {
|
||||
json_object_string_add(json_obj, "lsaType", "unknown");
|
||||
@ -548,7 +548,7 @@ void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa,
|
||||
json_object *json = NULL;
|
||||
|
||||
start = (uint8_t *)lsa->header;
|
||||
end = (uint8_t *)lsa->header + ntohs(lsa->header->length);
|
||||
end = (uint8_t *)ospf6_lsa_end(lsa->header);
|
||||
|
||||
if (use_json) {
|
||||
json = json_object_new_object();
|
||||
|
@ -88,14 +88,17 @@ struct ospf6_lsa_header {
|
||||
};
|
||||
|
||||
#define OSPF6_LSA_SIZE(h) (ntohs(((struct ospf6_lsa_header *)(h))->length))
|
||||
#define OSPF6_LSA_END(h) \
|
||||
((caddr_t)(h) + ntohs(((struct ospf6_lsa_header *)(h))->length))
|
||||
|
||||
static inline char *ospf6_lsa_header_end(struct ospf6_lsa_header *header)
|
||||
{
|
||||
return (char *)header + sizeof(struct ospf6_lsa_header);
|
||||
}
|
||||
|
||||
static inline char *ospf6_lsa_end(struct ospf6_lsa_header *header)
|
||||
{
|
||||
return (char *)header + ntohs(header->length);
|
||||
}
|
||||
|
||||
#define OSPF6_LSA_IS_TYPE(t, L) \
|
||||
((L)->header->type == htons(OSPF6_LSTYPE_##t) ? 1 : 0)
|
||||
#define OSPF6_LSA_IS_SAME(L1, L2) \
|
||||
|
@ -207,7 +207,7 @@ static char *ospf6_lsdesc_backlink(struct ospf6_lsa *lsa, caddr_t lsdesc,
|
||||
? sizeof(struct ospf6_router_lsdesc)
|
||||
: sizeof(struct ospf6_network_lsdesc));
|
||||
for (backlink = ospf6_lsa_header_end(lsa->header) + 4;
|
||||
backlink + size <= OSPF6_LSA_END(lsa->header); backlink += size) {
|
||||
backlink + size <= ospf6_lsa_end(lsa->header); backlink += size) {
|
||||
assert(!(OSPF6_LSA_IS_TYPE(NETWORK, lsa)
|
||||
&& VERTEX_IS_TYPE(NETWORK, v)));
|
||||
|
||||
@ -511,7 +511,7 @@ void ospf6_spf_calculation(uint32_t router_id,
|
||||
? sizeof(struct ospf6_router_lsdesc)
|
||||
: sizeof(struct ospf6_network_lsdesc));
|
||||
for (lsdesc = ospf6_lsa_header_end(v->lsa->header) + 4;
|
||||
lsdesc + size <= OSPF6_LSA_END(v->lsa->header);
|
||||
lsdesc + size <= ospf6_lsa_end(v->lsa->header);
|
||||
lsdesc += size) {
|
||||
lsa = ospf6_lsdesc_lsa(lsdesc, v);
|
||||
if (lsa == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user