summaryrefslogtreecommitdiffstats
path: root/ospf6d/ospf6_lsa.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:56:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:56:23 +0000
commitc15d6efd40655f717841d00839a43df1ead5cb26 (patch)
tree35d579f9a19170e2b39085669ca92533c2d161b4 /ospf6d/ospf6_lsa.c
parentAdding upstream version 10.0.1. (diff)
downloadfrr-upstream.tar.xz
frr-upstream.zip
Adding upstream version 10.1.upstream/10.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--ospf6d/ospf6_lsa.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c
index bc39579..0177518 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -63,10 +63,10 @@ struct ospf6 *ospf6_get_by_lsdb(struct ospf6_lsa *lsa)
static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
json_object *json_obj, bool use_json)
{
- uint8_t *start, *end, *current;
+ char *start, *end, *current;
- start = (uint8_t *)lsa->header + sizeof(struct ospf6_lsa_header);
- end = (uint8_t *)lsa->header + ntohs(lsa->header->length);
+ start = ospf6_lsa_header_end(lsa->header);
+ end = ospf6_lsa_end(lsa->header);
if (use_json) {
json_object_string_add(json_obj, "lsaType", "unknown");
@@ -201,10 +201,10 @@ int ospf6_lsa_is_differ(struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2)
return 1;
/* compare body */
- if (ntohs(lsa1->header->length) != ntohs(lsa2->header->length))
+ if (ospf6_lsa_size(lsa1->header) != ospf6_lsa_size(lsa2->header))
return 1;
- len = ntohs(lsa1->header->length) - sizeof(struct ospf6_lsa_header);
+ len = ospf6_lsa_size(lsa1->header) - sizeof(struct ospf6_lsa_header);
return memcmp(lsa1->header + 1, lsa2->header + 1, len);
}
@@ -214,7 +214,7 @@ int ospf6_lsa_is_changed(struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2)
if (OSPF6_LSA_IS_MAXAGE(lsa1) ^ OSPF6_LSA_IS_MAXAGE(lsa2))
return 1;
- if (ntohs(lsa1->header->length) != ntohs(lsa2->header->length))
+ if (ospf6_lsa_size(lsa1->header) != ospf6_lsa_size(lsa2->header))
return 1;
/* Going beyond LSA headers to compare the payload only makes sense,
* when both LSAs aren't header-only. */
@@ -228,14 +228,14 @@ int ospf6_lsa_is_changed(struct ospf6_lsa *lsa1, struct ospf6_lsa *lsa2)
if (CHECK_FLAG(lsa1->flag, OSPF6_LSA_HEADERONLY))
return 0;
- length = OSPF6_LSA_SIZE(lsa1->header) - sizeof(struct ospf6_lsa_header);
+ length = ospf6_lsa_size(lsa1->header) - sizeof(struct ospf6_lsa_header);
/* Once upper layer verifies LSAs received, length underrun should
* become a warning. */
if (length <= 0)
return 0;
- return memcmp(OSPF6_LSA_HEADER_END(lsa1->header),
- OSPF6_LSA_HEADER_END(lsa2->header), length);
+ return memcmp(ospf6_lsa_header_end(lsa1->header),
+ ospf6_lsa_header_end(lsa2->header), length);
}
/* ospf6 age functions */
@@ -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();
@@ -613,7 +613,7 @@ void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa,
json_object_int_add(json_obj, "checksum",
ntohs(lsa->header->checksum));
json_object_int_add(json_obj, "length",
- ntohs(lsa->header->length));
+ ospf6_lsa_size(lsa->header));
json_object_int_add(json_obj, "flag", lsa->flag);
json_object_int_add(json_obj, "lock", lsa->lock);
json_object_int_add(json_obj, "reTxCount", lsa->retrans_count);
@@ -630,7 +630,7 @@ void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa,
(unsigned long)ntohl(lsa->header->seqnum));
vty_out(vty, "CheckSum: %#06hx Length: %hu\n",
ntohs(lsa->header->checksum),
- ntohs(lsa->header->length));
+ ospf6_lsa_size(lsa->header));
vty_out(vty, "Flag: %x \n", lsa->flag);
vty_out(vty, "Lock: %d \n", lsa->lock);
vty_out(vty, "ReTx Count: %d\n", lsa->retrans_count);
@@ -720,7 +720,7 @@ struct ospf6_lsa *ospf6_lsa_create(struct ospf6_lsa_header *header)
uint16_t lsa_size = 0;
/* size of the entire LSA */
- lsa_size = ntohs(header->length); /* XXX vulnerable */
+ lsa_size = ospf6_lsa_size(header); /* XXX vulnerable */
lsa = ospf6_lsa_alloc(lsa_size);
@@ -947,7 +947,7 @@ unsigned short ospf6_lsa_checksum(struct ospf6_lsa_header *lsa_header)
buffer - (uint8_t *)&lsa_header->age; /* should be 2 */
/* Skip the AGE field */
- uint16_t len = ntohs(lsa_header->length) - type_offset;
+ uint16_t len = ospf6_lsa_size(lsa_header) - type_offset;
/* Checksum offset starts from "type" field, not the beginning of the
lsa_header struct. The offset is 14, rather than 16. */
@@ -963,7 +963,7 @@ int ospf6_lsa_checksum_valid(struct ospf6_lsa_header *lsa_header)
buffer - (uint8_t *)&lsa_header->age; /* should be 2 */
/* Skip the AGE field */
- uint16_t len = ntohs(lsa_header->length) - type_offset;
+ uint16_t len = ospf6_lsa_size(lsa_header) - type_offset;
return (fletcher_checksum(buffer, len, FLETCHER_CHECKSUM_VALIDATE)
== 0);