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++) {
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;
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;
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;
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);
- return handler->debug;
+ return handler->lh_debug;
}
/* RFC2328: Section 13.2 */
/* 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);
}
/* 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;
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);
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));
}
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) {
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);
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);
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);
{
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 */
/* allocate memory for this LSA */
- new_header = (struct ospf6_lsa_header *)XMALLOC(MTYPE_OSPF6_LSA_HEADER,
- lsa_size);
+ new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER, lsa_size);
/* copy LSA from original header */
memcpy(new_header, header, lsa_size);
/* LSA information structure */
/* allocate memory */
- lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA,
- sizeof(struct ospf6_lsa));
+ lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa));
lsa->header = (struct ospf6_lsa_header *)new_header;
struct ospf6_lsa_header *new_header = NULL;
/* allocate memory for this LSA */
- new_header = (struct ospf6_lsa_header *)XMALLOC(
- MTYPE_OSPF6_LSA_HEADER, sizeof(struct ospf6_lsa_header));
+ new_header = XMALLOC(MTYPE_OSPF6_LSA_HEADER,
+ sizeof(struct ospf6_lsa_header));
/* copy LSA from original header */
memcpy(new_header, header, sizeof(struct ospf6_lsa_header));
/* LSA information structure */
/* allocate memory */
- lsa = (struct ospf6_lsa *)XCALLOC(MTYPE_OSPF6_LSA,
- sizeof(struct ospf6_lsa));
+ lsa = XCALLOC(MTYPE_OSPF6_LSA, sizeof(struct ospf6_lsa));
lsa->header = (struct ospf6_lsa_header *)new_header;
SET_FLAG(lsa->flag, OSPF6_LSA_HEADERONLY);
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);
if (argc == 5) {
if (strmatch(argv[idx_type]->text, "originate"))
- SET_FLAG(handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
+ SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ORIGINATE);
else if (strmatch(argv[idx_type]->text, "examine"))
- SET_FLAG(handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
+ SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_EXAMIN);
else if (strmatch(argv[idx_type]->text, "flooding"))
- SET_FLAG(handler->debug, OSPF6_LSA_DEBUG_FLOOD);
+ SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_FLOOD);
} else
- SET_FLAG(handler->debug, OSPF6_LSA_DEBUG);
+ SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG);
return CMD_SUCCESS;
}
{
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++) {
if (argc == 6) {
if (strmatch(argv[idx_type]->text, "originate"))
- UNSET_FLAG(handler->debug, OSPF6_LSA_DEBUG_ORIGINATE);
+ UNSET_FLAG(handler->lh_debug,
+ OSPF6_LSA_DEBUG_ORIGINATE);
if (strmatch(argv[idx_type]->text, "examine"))
- UNSET_FLAG(handler->debug, OSPF6_LSA_DEBUG_EXAMIN);
+ UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_EXAMIN);
if (strmatch(argv[idx_type]->text, "flooding"))
- UNSET_FLAG(handler->debug, OSPF6_LSA_DEBUG_FLOOD);
+ UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_FLOOD);
} else
- UNSET_FLAG(handler->debug, OSPF6_LSA_DEBUG);
+ UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG);
return CMD_SUCCESS;
}
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++) {
handler = vector_slot(ospf6_lsa_handler_vector, i);
if (handler == NULL)
continue;
- if (CHECK_FLAG(handler->debug, OSPF6_LSA_DEBUG))
+ if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG))
vty_out(vty, "debug ospf6 lsa %s\n",
ospf6_lsa_handler_name(handler));
- if (CHECK_FLAG(handler->debug, OSPF6_LSA_DEBUG_ORIGINATE))
+ if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ORIGINATE))
vty_out(vty, "debug ospf6 lsa %s originate\n",
ospf6_lsa_handler_name(handler));
- if (CHECK_FLAG(handler->debug, OSPF6_LSA_DEBUG_EXAMIN))
+ if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_EXAMIN))
vty_out(vty, "debug ospf6 lsa %s examine\n",
ospf6_lsa_handler_name(handler));
- if (CHECK_FLAG(handler->debug, OSPF6_LSA_DEBUG_FLOOD))
+ if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_FLOOD))
vty_out(vty, "debug ospf6 lsa %s flooding\n",
ospf6_lsa_handler_name(handler));
}