summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_abr.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_abr.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_abr.c')
-rw-r--r--ospf6d/ospf6_abr.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c
index d3ff759d33..aec947a698 100644
--- a/ospf6d/ospf6_abr.c
+++ b/ospf6d/ospf6_abr.c
@@ -553,9 +553,8 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
lsa_header = (struct ospf6_lsa_header *)buffer;
if (route->type == OSPF6_DEST_TYPE_ROUTER) {
- router_lsa = (struct ospf6_inter_router_lsa
- *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ router_lsa = (struct ospf6_inter_router_lsa *)
+ ospf6_lsa_header_end(lsa_header);
p = (caddr_t)router_lsa + sizeof(struct ospf6_inter_router_lsa);
/* Fill Inter-Area-Router-LSA */
@@ -566,9 +565,8 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
router_lsa->router_id = ADV_ROUTER_IN_PREFIX(&route->prefix);
type = htons(OSPF6_LSTYPE_INTER_ROUTER);
} else {
- prefix_lsa = (struct ospf6_inter_prefix_lsa
- *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ prefix_lsa = (struct ospf6_inter_prefix_lsa *)
+ ospf6_lsa_header_end(lsa_header);
p = (caddr_t)prefix_lsa + sizeof(struct ospf6_inter_prefix_lsa);
/* Fill Inter-Area-Prefix-LSA */
@@ -1018,9 +1016,8 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
oa->name);
}
- prefix_lsa =
- (struct ospf6_inter_prefix_lsa *)OSPF6_LSA_HEADER_END(
- lsa->header);
+ prefix_lsa = (struct ospf6_inter_prefix_lsa *)
+ ospf6_lsa_header_end(lsa->header);
prefix.family = AF_INET6;
prefix.prefixlen = prefix_lsa->prefix.prefix_length;
ospf6_prefix_in6_addr(&prefix.u.prefix6, prefix_lsa,
@@ -1039,11 +1036,9 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
oa->name);
}
- router_lsa =
- (struct ospf6_inter_router_lsa *)OSPF6_LSA_HEADER_END(
- lsa->header);
- ospf6_linkstate_prefix(router_lsa->router_id, htonl(0),
- &prefix);
+ router_lsa = (struct ospf6_inter_router_lsa *)
+ ospf6_lsa_header_end(lsa->header);
+ ospf6_linkstate_prefix(router_lsa->router_id, htonl(0), &prefix);
if (is_debug)
inet_ntop(AF_INET, &router_lsa->router_id, buf,
sizeof(buf));
@@ -1433,9 +1428,8 @@ static char *ospf6_inter_area_prefix_lsa_get_prefix_str(struct ospf6_lsa *lsa,
char tbuf[16];
if (lsa != NULL) {
- prefix_lsa =
- (struct ospf6_inter_prefix_lsa *)OSPF6_LSA_HEADER_END(
- lsa->header);
+ prefix_lsa = (struct ospf6_inter_prefix_lsa *)
+ ospf6_lsa_header_end(lsa->header);
ospf6_prefix_in6_addr(&in6, prefix_lsa, &prefix_lsa->prefix);
if (buf) {
@@ -1457,7 +1451,7 @@ static int ospf6_inter_area_prefix_lsa_show(struct vty *vty,
struct ospf6_inter_prefix_lsa *prefix_lsa;
char buf[INET6_ADDRSTRLEN];
- prefix_lsa = (struct ospf6_inter_prefix_lsa *)OSPF6_LSA_HEADER_END(
+ prefix_lsa = (struct ospf6_inter_prefix_lsa *)ospf6_lsa_header_end(
lsa->header);
if (use_json) {
@@ -1494,9 +1488,8 @@ static char *ospf6_inter_area_router_lsa_get_prefix_str(struct ospf6_lsa *lsa,
struct ospf6_inter_router_lsa *router_lsa;
if (lsa != NULL) {
- router_lsa =
- (struct ospf6_inter_router_lsa *)OSPF6_LSA_HEADER_END(
- lsa->header);
+ router_lsa = (struct ospf6_inter_router_lsa *)
+ ospf6_lsa_header_end(lsa->header);
if (buf)
@@ -1514,7 +1507,7 @@ static int ospf6_inter_area_router_lsa_show(struct vty *vty,
struct ospf6_inter_router_lsa *router_lsa;
char buf[64];
- router_lsa = (struct ospf6_inter_router_lsa *)OSPF6_LSA_HEADER_END(
+ router_lsa = (struct ospf6_inter_router_lsa *)ospf6_lsa_header_end(
lsa->header);
ospf6_options_printbuf(router_lsa->options, buf, sizeof(buf));