summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_spf.c
diff options
context:
space:
mode:
authorAndrew Cooks <acooks.at.bda@gmail.com>2024-05-21 09:47:20 +1000
committerAndrew Cooks <acooks.at.bda@gmail.com>2024-05-28 14:05:56 +1000
commit4d06e27569ae09cfb44cfa07b2c8d027ecf0fd72 (patch)
treed2c5f0aeb60b0d7f8285fffabe5712c0ab5f0eac /ospf6d/ospf6_spf.c
parentf7712516d8ea19629d346eca1d5ad71831ec1f22 (diff)
ospf6d: replace OSPF6_LSA_HEADER_END macro
Replacing the macro with an inline function allows the compiler to check the parameter type. Use the replacement function consistently to reduce the number of open coded pointer cast plus offset calculations. use tools/indent.py to reformat all occurences of its use. Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
Diffstat (limited to 'ospf6d/ospf6_spf.c')
-rw-r--r--ospf6d/ospf6_spf.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c
index e39ae504a2..93120df999 100644
--- a/ospf6d/ospf6_spf.c
+++ b/ospf6d/ospf6_spf.c
@@ -130,10 +130,10 @@ static struct ospf6_vertex *ospf6_vertex_create(struct ospf6_lsa *lsa)
v->lsa = lsa;
/* capability bits + options */
- v->capability = *(uint8_t *)(OSPF6_LSA_HEADER_END(lsa->header));
- v->options[0] = *(uint8_t *)(OSPF6_LSA_HEADER_END(lsa->header) + 1);
- v->options[1] = *(uint8_t *)(OSPF6_LSA_HEADER_END(lsa->header) + 2);
- v->options[2] = *(uint8_t *)(OSPF6_LSA_HEADER_END(lsa->header) + 3);
+ v->capability = *(uint8_t *)(ospf6_lsa_header_end(lsa->header));
+ v->options[0] = *(uint8_t *)(ospf6_lsa_header_end(lsa->header) + 1);
+ v->options[1] = *(uint8_t *)(ospf6_lsa_header_end(lsa->header) + 2);
+ v->options[2] = *(uint8_t *)(ospf6_lsa_header_end(lsa->header) + 3);
v->nh_list = list_new();
v->nh_list->cmp = (int (*)(void *, void *))ospf6_nexthop_cmp;
@@ -206,7 +206,7 @@ static char *ospf6_lsdesc_backlink(struct ospf6_lsa *lsa, caddr_t lsdesc,
size = (OSPF6_LSA_IS_TYPE(ROUTER, lsa)
? sizeof(struct ospf6_router_lsdesc)
: sizeof(struct ospf6_network_lsdesc));
- for (backlink = OSPF6_LSA_HEADER_END(lsa->header) + 4;
+ for (backlink = ospf6_lsa_header_end(lsa->header) + 4;
backlink + size <= OSPF6_LSA_END(lsa->header); backlink += size) {
assert(!(OSPF6_LSA_IS_TYPE(NETWORK, lsa)
&& VERTEX_IS_TYPE(NETWORK, v)));
@@ -290,7 +290,7 @@ static void ospf6_nexthop_calc(struct ospf6_vertex *w, struct ospf6_vertex *v,
!= lsa->header->id)
continue;
- link_lsa = (struct ospf6_link_lsa *)OSPF6_LSA_HEADER_END(
+ link_lsa = (struct ospf6_link_lsa *)ospf6_lsa_header_end(
lsa->header);
if (IS_OSPF6_DEBUG_SPF(PROCESS)) {
inet_ntop(AF_INET6, &link_lsa->linklocal_addr, buf,
@@ -510,7 +510,7 @@ void ospf6_spf_calculation(uint32_t router_id,
size = (VERTEX_IS_TYPE(ROUTER, v)
? sizeof(struct ospf6_router_lsdesc)
: sizeof(struct ospf6_network_lsdesc));
- for (lsdesc = OSPF6_LSA_HEADER_END(v->lsa->header) + 4;
+ for (lsdesc = ospf6_lsa_header_end(v->lsa->header) + 4;
lsdesc + size <= OSPF6_LSA_END(v->lsa->header);
lsdesc += size) {
lsa = ospf6_lsdesc_lsa(lsdesc, v);
@@ -1063,7 +1063,7 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,
}
if (IS_OSPF6_DEBUG_SPF(PROCESS)) {
- lsd = OSPF6_LSA_HEADER_END(rtr_lsa->header) + 4;
+ lsd = ospf6_lsa_header_end(rtr_lsa->header) + 4;
interface_id = ROUTER_LSDESC_GET_IFID(lsd);
inet_ntop(AF_INET, &interface_id, ifbuf, sizeof(ifbuf));
zlog_debug(
@@ -1074,7 +1074,7 @@ struct ospf6_lsa *ospf6_create_single_router_lsa(struct ospf6_area *area,
/* Append Next Link State ID LSA */
lsa_header = rtr_lsa->header;
- memcpy(new_header, (OSPF6_LSA_HEADER_END(rtr_lsa->header) + 4),
+ memcpy(new_header, (ospf6_lsa_header_end(rtr_lsa->header) + 4),
(ntohs(lsa_header->length) - lsa_length));
new_header += (ntohs(lsa_header->length) - lsa_length);
num_lsa--;
@@ -1137,7 +1137,7 @@ int ospf6_ase_calculate_route(struct ospf6 *ospf6, struct ospf6_lsa *lsa,
return 0;
}
- external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END(
+ external = (struct ospf6_as_external_lsa *)ospf6_lsa_header_end(
lsa->header);
prefix.family = AF_INET6;
prefix.prefixlen = external->prefix.prefix_length;