summaryrefslogtreecommitdiffstats
path: root/ospf6d/ospf6_intra.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d/ospf6_intra.c')
-rw-r--r--ospf6d/ospf6_intra.c65
1 files changed, 28 insertions, 37 deletions
diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c
index cb036752e..b06796ada 100644
--- a/ospf6d/ospf6_intra.c
+++ b/ospf6d/ospf6_intra.c
@@ -242,9 +242,7 @@ void ospf6_router_lsa_originate(struct event *thread)
memset(buffer, 0, sizeof(buffer));
lsa_header = (struct ospf6_lsa_header *)buffer;
- router_lsa =
- (struct ospf6_router_lsa *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ router_lsa = (struct ospf6_router_lsa *)ospf6_lsa_header_end(lsa_header);
ospf6_router_lsa_options_set(oa, router_lsa);
@@ -305,10 +303,8 @@ void ospf6_router_lsa_originate(struct event *thread)
/* Reset Buffer to fill next Router LSA */
memset(buffer, 0, sizeof(buffer));
lsa_header = (struct ospf6_lsa_header *)buffer;
- router_lsa =
- (struct ospf6_router_lsa
- *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ router_lsa = (struct ospf6_router_lsa *)
+ ospf6_lsa_header_end(lsa_header);
ospf6_router_lsa_options_set(oa, router_lsa);
@@ -568,16 +564,14 @@ void ospf6_network_lsa_originate(struct event *thread)
memset(buffer, 0, sizeof(buffer));
lsa_header = (struct ospf6_lsa_header *)buffer;
network_lsa =
- (struct ospf6_network_lsa *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ (struct ospf6_network_lsa *)ospf6_lsa_header_end(lsa_header);
/* Collect the interface's Link-LSAs to describe
network's optional capabilities */
type = htons(OSPF6_LSTYPE_LINK);
for (ALL_LSDB_TYPED(oi->lsdb, type, lsa)) {
- link_lsa = (struct ospf6_link_lsa
- *)((caddr_t)lsa->header
- + sizeof(struct ospf6_lsa_header));
+ link_lsa = (struct ospf6_link_lsa *)ospf6_lsa_header_end(
+ lsa->header);
network_lsa->options[0] |= link_lsa->options[0];
network_lsa->options[1] |= link_lsa->options[1];
network_lsa->options[2] |= link_lsa->options[2];
@@ -711,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;
@@ -800,8 +795,7 @@ void ospf6_link_lsa_originate(struct event *thread)
/* prepare buffer */
memset(buffer, 0, sizeof(buffer));
lsa_header = (struct ospf6_lsa_header *)buffer;
- link_lsa = (struct ospf6_link_lsa *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ link_lsa = (struct ospf6_link_lsa *)ospf6_lsa_header_end(lsa_header);
/* Fill Link-LSA */
link_lsa->priority = oi->priority;
@@ -871,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) {
@@ -942,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;
@@ -1042,9 +1037,8 @@ void ospf6_intra_prefix_lsa_originate_stub(struct event *thread)
/* prepare buffer */
memset(buffer, 0, sizeof(buffer));
lsa_header = (struct ospf6_lsa_header *)buffer;
- intra_prefix_lsa = (struct ospf6_intra_prefix_lsa
- *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)ospf6_lsa_header_end(
+ lsa_header);
/* Fill Intra-Area-Prefix-LSA */
intra_prefix_lsa->ref_type = htons(OSPF6_LSTYPE_ROUTER);
@@ -1159,10 +1153,8 @@ void ospf6_intra_prefix_lsa_originate_stub(struct event *thread)
/* Prepare next buffer */
memset(buffer, 0, sizeof(buffer));
lsa_header = (struct ospf6_lsa_header *)buffer;
- intra_prefix_lsa =
- (struct ospf6_intra_prefix_lsa
- *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)
+ ospf6_lsa_header_end(lsa_header);
/* Fill Intra-Area-Prefix-LSA */
intra_prefix_lsa->ref_type = htons(OSPF6_LSTYPE_ROUTER);
@@ -1269,9 +1261,8 @@ void ospf6_intra_prefix_lsa_originate_transit(struct event *thread)
/* prepare buffer */
memset(buffer, 0, sizeof(buffer));
lsa_header = (struct ospf6_lsa_header *)buffer;
- intra_prefix_lsa = (struct ospf6_intra_prefix_lsa
- *)((caddr_t)lsa_header
- + sizeof(struct ospf6_lsa_header));
+ intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)ospf6_lsa_header_end(
+ lsa_header);
/* Fill Intra-Area-Prefix-LSA */
intra_prefix_lsa->ref_type = htons(OSPF6_LSTYPE_NETWORK);
@@ -1326,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;
@@ -1668,7 +1660,8 @@ void ospf6_intra_prefix_route_ecmp_path(struct ospf6_area *oa,
}
intra_prefix_lsa =
(struct ospf6_intra_prefix_lsa *)
- OSPF6_LSA_HEADER_END(lsa->header);
+ ospf6_lsa_header_end(
+ lsa->header);
if (intra_prefix_lsa->ref_adv_router
== oa->ospf6->router_id) {
@@ -1749,9 +1742,8 @@ void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa)
oa = OSPF6_AREA(lsa->lsdb->data);
- intra_prefix_lsa =
- (struct ospf6_intra_prefix_lsa *)OSPF6_LSA_HEADER_END(
- lsa->header);
+ intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)ospf6_lsa_header_end(
+ lsa->header);
if (intra_prefix_lsa->ref_type == htons(OSPF6_LSTYPE_ROUTER) ||
intra_prefix_lsa->ref_type == htons(OSPF6_LSTYPE_NETWORK))
ospf6_linkstate_prefix(intra_prefix_lsa->ref_adv_router,
@@ -1781,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)
@@ -1979,14 +1971,13 @@ void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa)
oa = OSPF6_AREA(lsa->lsdb->data);
- intra_prefix_lsa =
- (struct ospf6_intra_prefix_lsa *)OSPF6_LSA_HEADER_END(
- lsa->header);
+ intra_prefix_lsa = (struct ospf6_intra_prefix_lsa *)ospf6_lsa_header_end(
+ lsa->header);
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)