diff options
Diffstat (limited to 'ospf6d/ospf6_lsa.c')
-rw-r--r-- | ospf6d/ospf6_lsa.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c index e060879f4..8b720b6d8 100644 --- a/ospf6d/ospf6_lsa.c +++ b/ospf6d/ospf6_lsa.c @@ -47,11 +47,11 @@ vector ospf6_lsa_handler_vector; static int ospf6_unknown_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) { - u_char *start, *end, *current; + uint8_t *start, *end, *current; char byte[4]; - start = (u_char *)lsa->header + sizeof(struct ospf6_lsa_header); - end = (u_char *)lsa->header + ntohs(lsa->header->length); + start = (uint8_t *)lsa->header + sizeof(struct ospf6_lsa_header); + end = (uint8_t *)lsa->header + ntohs(lsa->header->length); vty_out(vty, " Unknown contents:\n"); for (current = start; current < end; current++) { @@ -84,7 +84,7 @@ void ospf6_install_lsa_handler(const struct ospf6_lsa_handler *handler) vector_set_index(ospf6_lsa_handler_vector, index, (void *)handler); } -const struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type) +const struct ospf6_lsa_handler *ospf6_get_lsa_handler(uint16_t type) { const struct ospf6_lsa_handler *handler = NULL; unsigned int index = ntohs(type) & OSPF6_LSTYPE_FCODE_MASK; @@ -100,7 +100,7 @@ const struct ospf6_lsa_handler *ospf6_get_lsa_handler(u_int16_t type) return handler; } -const char *ospf6_lstype_name(u_int16_t type) +const char *ospf6_lstype_name(uint16_t type) { static char buf[8]; const struct ospf6_lsa_handler *handler; @@ -113,7 +113,7 @@ const char *ospf6_lstype_name(u_int16_t type) return buf; } -const char *ospf6_lstype_short_name(u_int16_t type) +const char *ospf6_lstype_short_name(uint16_t type) { static char buf[8]; const struct ospf6_lsa_handler *handler; @@ -126,7 +126,7 @@ const char *ospf6_lstype_short_name(u_int16_t type) return buf; } -u_char ospf6_lstype_debug(u_int16_t type) +uint8_t ospf6_lstype_debug(uint16_t type) { const struct ospf6_lsa_handler *handler; handler = ospf6_get_lsa_handler(type); @@ -207,11 +207,11 @@ void ospf6_lsa_age_set(struct ospf6_lsa *lsa) /* this function calculates current age from its birth, then update age field of LSA header. return value is current age */ -u_int16_t ospf6_lsa_age_current(struct ospf6_lsa *lsa) +uint16_t ospf6_lsa_age_current(struct ospf6_lsa *lsa) { struct timeval now; - u_int32_t ulage; - u_int16_t age; + uint32_t ulage; + uint16_t age; assert(lsa); assert(lsa->header); @@ -237,7 +237,7 @@ u_int16_t ospf6_lsa_age_current(struct ospf6_lsa *lsa) } /* update age field of LSA header with adding InfTransDelay */ -void ospf6_lsa_age_update_to_send(struct ospf6_lsa *lsa, u_int32_t transdelay) +void ospf6_lsa_age_update_to_send(struct ospf6_lsa *lsa, uint32_t transdelay) { unsigned short age; @@ -292,8 +292,8 @@ void ospf6_lsa_premature_aging(struct ospf6_lsa *lsa) int ospf6_lsa_compare(struct ospf6_lsa *a, struct ospf6_lsa *b) { int32_t seqnuma, seqnumb; - u_int16_t cksuma, cksumb; - u_int16_t agea, ageb; + uint16_t cksuma, cksumb; + uint16_t agea, ageb; assert(a && a->header); assert(b && b->header); @@ -355,7 +355,7 @@ void ospf6_lsa_header_print_raw(struct ospf6_lsa_header *header) zlog_debug(" [%s Id:%s Adv:%s]", ospf6_lstype_name(header->type), id, adv_router); zlog_debug(" Age: %4hu SeqNum: %#08lx Cksum: %04hx Len: %d", - ntohs(header->age), (u_long)ntohl(header->seqnum), + ntohs(header->age), (unsigned long)ntohl(header->seqnum), ntohs(header->checksum), ntohs(header->length)); } @@ -394,13 +394,13 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa) vty_out(vty, "%-4s %-15s%-15s%4hu %8lx %30s\n", ospf6_lstype_short_name(lsa->header->type), id, adv_router, ospf6_lsa_age_current(lsa), - (u_long)ntohl(lsa->header->seqnum), + (unsigned long)ntohl(lsa->header->seqnum), handler->lh_get_prefix_str(lsa, buf, sizeof(buf), 0)); } else if (type != OSPF6_LSTYPE_UNKNOWN) { sprintf(tmpbuf, "%-4s %-15s%-15s%4hu %8lx", ospf6_lstype_short_name(lsa->header->type), id, adv_router, ospf6_lsa_age_current(lsa), - (u_long)ntohl(lsa->header->seqnum)); + (unsigned long)ntohl(lsa->header->seqnum)); while (handler->lh_get_prefix_str(lsa, buf, sizeof(buf), cnt) != NULL) { @@ -411,17 +411,17 @@ void ospf6_lsa_show_summary(struct vty *vty, struct ospf6_lsa *lsa) vty_out(vty, "%-4s %-15s%-15s%4hu %8lx\n", ospf6_lstype_short_name(lsa->header->type), id, adv_router, ospf6_lsa_age_current(lsa), - (u_long)ntohl(lsa->header->seqnum)); + (unsigned long)ntohl(lsa->header->seqnum)); } } void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa) { - u_char *start, *end, *current; + uint8_t *start, *end, *current; char byte[4]; - start = (u_char *)lsa->header; - end = (u_char *)lsa->header + ntohs(lsa->header->length); + start = (uint8_t *)lsa->header; + end = (uint8_t *)lsa->header + ntohs(lsa->header->length); vty_out(vty, "\n"); vty_out(vty, "%s:\n", lsa->name); @@ -456,7 +456,7 @@ void ospf6_lsa_show_internal(struct vty *vty, struct ospf6_lsa *lsa) vty_out(vty, "Link State ID: %s\n", id); vty_out(vty, "Advertising Router: %s\n", adv_router); vty_out(vty, "LS Sequence Number: %#010lx\n", - (u_long)ntohl(lsa->header->seqnum)); + (unsigned long)ntohl(lsa->header->seqnum)); vty_out(vty, "CheckSum: %#06hx Length: %hu\n", ntohs(lsa->header->checksum), ntohs(lsa->header->length)); vty_out(vty, "Flag: %x \n", lsa->flag); @@ -490,7 +490,7 @@ void ospf6_lsa_show(struct vty *vty, struct ospf6_lsa *lsa) vty_out(vty, "Link State ID: %s\n", id); vty_out(vty, "Advertising Router: %s\n", adv_router); vty_out(vty, "LS Sequence Number: %#010lx\n", - (u_long)ntohl(lsa->header->seqnum)); + (unsigned long)ntohl(lsa->header->seqnum)); vty_out(vty, "CheckSum: %#06hx Length: %hu\n", ntohs(lsa->header->checksum), ntohs(lsa->header->length)); vty_out(vty, "Duration: %s\n", duration); @@ -512,7 +512,7 @@ struct ospf6_lsa *ospf6_lsa_create(struct ospf6_lsa_header *header) { struct ospf6_lsa *lsa = NULL; struct ospf6_lsa_header *new_header = NULL; - u_int16_t lsa_size = 0; + uint16_t lsa_size = 0; /* size of the entire LSA */ lsa_size = ntohs(header->length); /* XXX vulnerable */ @@ -743,26 +743,28 @@ void ospf6_flush_self_originated_lsas_now(void) one-based. */ unsigned short ospf6_lsa_checksum(struct ospf6_lsa_header *lsa_header) { - u_char *buffer = (u_char *)&lsa_header->type; - int type_offset = buffer - (u_char *)&lsa_header->age; /* should be 2 */ + uint8_t *buffer = (uint8_t *)&lsa_header->type; + int type_offset = + buffer - (uint8_t *)&lsa_header->age; /* should be 2 */ /* Skip the AGE field */ - u_int16_t len = ntohs(lsa_header->length) - type_offset; + uint16_t len = ntohs(lsa_header->length) - type_offset; /* Checksum offset starts from "type" field, not the beginning of the lsa_header struct. The offset is 14, rather than 16. */ - int checksum_offset = (u_char *)&lsa_header->checksum - buffer; + int checksum_offset = (uint8_t *)&lsa_header->checksum - buffer; return (unsigned short)fletcher_checksum(buffer, len, checksum_offset); } int ospf6_lsa_checksum_valid(struct ospf6_lsa_header *lsa_header) { - u_char *buffer = (u_char *)&lsa_header->type; - int type_offset = buffer - (u_char *)&lsa_header->age; /* should be 2 */ + uint8_t *buffer = (uint8_t *)&lsa_header->type; + int type_offset = + buffer - (uint8_t *)&lsa_header->age; /* should be 2 */ /* Skip the AGE field */ - u_int16_t len = ntohs(lsa_header->length) - type_offset; + uint16_t len = ntohs(lsa_header->length) - type_offset; return (fletcher_checksum(buffer, len, FLETCHER_CHECKSUM_VALIDATE) == 0); @@ -874,7 +876,7 @@ DEFUN (no_debug_ospf6_lsa_type, { int idx_lsa = 4; int idx_type = 5; - u_int i; + unsigned int i; struct ospf6_lsa_handler *handler = NULL; for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) { @@ -915,7 +917,7 @@ void install_element_ospf6_debug_lsa(void) int config_write_ospf6_debug_lsa(struct vty *vty) { - u_int i; + unsigned int i; const struct ospf6_lsa_handler *handler; for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) { |