diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c index 7aedd3df45a6..d2dcfd81d4e3 100644 --- a/ospf6d/ospf6_message.c +++ b/ospf6d/ospf6_message.c @@ -94,7 +94,7 @@ static void ospf6_header_print(struct ospf6_header *oh) ntohs(oh->checksum), oh->instance_id); } -void ospf6_hello_print(struct ospf6_header *oh) +void ospf6_hello_print(struct ospf6_header *oh, int action) { struct ospf6_hello *hello; char options[16]; @@ -115,15 +115,21 @@ void ospf6_hello_print(struct ospf6_header *oh) ntohs(hello->hello_interval), ntohs(hello->dead_interval)); zlog_debug(" DR:%pI4 BDR:%pI4", &hello->drouter, &hello->bdrouter); - for (p = (char *)((caddr_t)hello + sizeof(struct ospf6_hello)); - p + sizeof(uint32_t) <= OSPF6_MESSAGE_END(oh); - p += sizeof(uint32_t)) - zlog_debug(" Neighbor: %pI4", (in_addr_t *)p); + if ((IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV) + && action == OSPF6_ACTION_RECV) + || (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND) + && action == OSPF6_ACTION_SEND)) { - assert(p == OSPF6_MESSAGE_END(oh)); + for (p = (char *)((caddr_t)hello + sizeof(struct ospf6_hello)); + p + sizeof(uint32_t) <= OSPF6_MESSAGE_END(oh); + p += sizeof(uint32_t)) + zlog_debug(" Neighbor: %pI4", (in_addr_t *)p); + + assert(p == OSPF6_MESSAGE_END(oh)); + } } -void ospf6_dbdesc_print(struct ospf6_header *oh) +void ospf6_dbdesc_print(struct ospf6_header *oh, int action) { struct ospf6_dbdesc *dbdesc; char options[16]; @@ -145,34 +151,52 @@ void ospf6_dbdesc_print(struct ospf6_header *oh) (CHECK_FLAG(dbdesc->bits, OSPF6_DBDESC_MSBIT) ? "m" : "s"), (unsigned long)ntohl(dbdesc->seqnum)); - for (p = (char *)((caddr_t)dbdesc + sizeof(struct ospf6_dbdesc)); - p + sizeof(struct ospf6_lsa_header) <= OSPF6_MESSAGE_END(oh); - p += sizeof(struct ospf6_lsa_header)) - ospf6_lsa_header_print_raw((struct ospf6_lsa_header *)p); + if ((IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV) + && action == OSPF6_ACTION_RECV) + || (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND) + && action == OSPF6_ACTION_SEND)) { - assert(p == OSPF6_MESSAGE_END(oh)); + for (p = (char *)((caddr_t)dbdesc + + sizeof(struct ospf6_dbdesc)); + p + sizeof(struct ospf6_lsa_header) + <= OSPF6_MESSAGE_END(oh); + p += sizeof(struct ospf6_lsa_header)) + ospf6_lsa_header_print_raw( + (struct ospf6_lsa_header *)p); + + assert(p == OSPF6_MESSAGE_END(oh)); + } } -void ospf6_lsreq_print(struct ospf6_header *oh) +void ospf6_lsreq_print(struct ospf6_header *oh, int action) { char *p; ospf6_header_print(oh); assert(oh->type == OSPF6_MESSAGE_TYPE_LSREQ); - for (p = (char *)((caddr_t)oh + sizeof(struct ospf6_header)); - p + sizeof(struct ospf6_lsreq_entry) <= OSPF6_MESSAGE_END(oh); - p += sizeof(struct ospf6_lsreq_entry)) { - struct ospf6_lsreq_entry *e = (struct ospf6_lsreq_entry *)p; + if ((IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV) + && action == OSPF6_ACTION_RECV) + || (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND) + && action == OSPF6_ACTION_SEND)) { + + for (p = (char *)((caddr_t)oh + sizeof(struct ospf6_header)); + p + sizeof(struct ospf6_lsreq_entry) + <= OSPF6_MESSAGE_END(oh); + p += sizeof(struct ospf6_lsreq_entry)) { + struct ospf6_lsreq_entry *e = + (struct ospf6_lsreq_entry *)p; + + zlog_debug(" [%s Id:%pI4 Adv:%pI4]", + ospf6_lstype_name(e->type), &e->id, + &e->adv_router); + } - zlog_debug(" [%s Id:%pI4 Adv:%pI4]", - ospf6_lstype_name(e->type), &e->id, &e->adv_router); + assert(p == OSPF6_MESSAGE_END(oh)); } - - assert(p == OSPF6_MESSAGE_END(oh)); } -void ospf6_lsupdate_print(struct ospf6_header *oh) +void ospf6_lsupdate_print(struct ospf6_header *oh, int action) { struct ospf6_lsupdate *lsupdate; unsigned long num; @@ -187,29 +211,45 @@ void ospf6_lsupdate_print(struct ospf6_header *oh) num = ntohl(lsupdate->lsa_number); zlog_debug(" Number of LSA: %ld", num); - for (p = (char *)((caddr_t)lsupdate + sizeof(struct ospf6_lsupdate)); - p < OSPF6_MESSAGE_END(oh) - && p + OSPF6_LSA_SIZE(p) <= OSPF6_MESSAGE_END(oh); - p += OSPF6_LSA_SIZE(p)) { - ospf6_lsa_header_print_raw((struct ospf6_lsa_header *)p); - } + if ((IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV) + && action == OSPF6_ACTION_RECV) + || (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND) + && action == OSPF6_ACTION_SEND)) { + + for (p = (char *)((caddr_t)lsupdate + + sizeof(struct ospf6_lsupdate)); + p < OSPF6_MESSAGE_END(oh) + && p + OSPF6_LSA_SIZE(p) <= OSPF6_MESSAGE_END(oh); + p += OSPF6_LSA_SIZE(p)) { + ospf6_lsa_header_print_raw( + (struct ospf6_lsa_header *)p); + } - assert(p == OSPF6_MESSAGE_END(oh)); + assert(p == OSPF6_MESSAGE_END(oh)); + } } -void ospf6_lsack_print(struct ospf6_header *oh) +void ospf6_lsack_print(struct ospf6_header *oh, int action) { char *p; ospf6_header_print(oh); assert(oh->type == OSPF6_MESSAGE_TYPE_LSACK); - for (p = (char *)((caddr_t)oh + sizeof(struct ospf6_header)); - p + sizeof(struct ospf6_lsa_header) <= OSPF6_MESSAGE_END(oh); - p += sizeof(struct ospf6_lsa_header)) - ospf6_lsa_header_print_raw((struct ospf6_lsa_header *)p); + if ((IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV) + && action == OSPF6_ACTION_RECV) + || (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND) + && action == OSPF6_ACTION_SEND)) { - assert(p == OSPF6_MESSAGE_END(oh)); + for (p = (char *)((caddr_t)oh + sizeof(struct ospf6_header)); + p + sizeof(struct ospf6_lsa_header) + <= OSPF6_MESSAGE_END(oh); + p += sizeof(struct ospf6_lsa_header)) + ospf6_lsa_header_print_raw( + (struct ospf6_lsa_header *)p); + + assert(p == OSPF6_MESSAGE_END(oh)); + } } static void ospf6_hello_recv(struct in6_addr *src, struct in6_addr *dst, @@ -348,21 +388,21 @@ static void ospf6_dbdesc_recv_master(struct ospf6_header *oh, + sizeof(struct ospf6_header)); if (on->state < OSPF6_NEIGHBOR_INIT) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor state less than Init, ignore"); return; } switch (on->state) { case OSPF6_NEIGHBOR_TWOWAY: - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor state is 2-Way, ignore"); return; case OSPF6_NEIGHBOR_INIT: thread_execute(master, twoway_received, on, 0); if (on->state != OSPF6_NEIGHBOR_EXSTART) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Neighbor state is not ExStart, ignore"); return; @@ -395,14 +435,14 @@ static void ospf6_dbdesc_recv_master(struct ospf6_header *oh, sizeof(struct ospf6_dbdesc))) { /* Duplicated DatabaseDescription is dropped by master */ - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Duplicated dbdesc discarded by Master, ignore"); return; } if (CHECK_FLAG(dbdesc->bits, OSPF6_DBDESC_MSBIT)) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Master/Slave bit mismatch"); thread_add_event(master, seqnumber_mismatch, on, 0, NULL); @@ -410,7 +450,7 @@ static void ospf6_dbdesc_recv_master(struct ospf6_header *oh, } if (CHECK_FLAG(dbdesc->bits, OSPF6_DBDESC_IBIT)) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Initialize bit mismatch"); thread_add_event(master, seqnumber_mismatch, on, 0, NULL); @@ -418,7 +458,7 @@ static void ospf6_dbdesc_recv_master(struct ospf6_header *oh, } if (memcmp(on->options, dbdesc->options, sizeof(on->options))) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Option field mismatch"); thread_add_event(master, seqnumber_mismatch, on, 0, NULL); @@ -426,7 +466,7 @@ static void ospf6_dbdesc_recv_master(struct ospf6_header *oh, } if (ntohl(dbdesc->seqnum) != on->dbdesc_seqnum) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Sequence number mismatch (%#lx expected)", (unsigned long)on->dbdesc_seqnum); @@ -442,13 +482,13 @@ static void ospf6_dbdesc_recv_master(struct ospf6_header *oh, sizeof(struct ospf6_dbdesc))) { /* Duplicated DatabaseDescription is dropped by master */ - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Duplicated dbdesc discarded by Master, ignore"); return; } - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Not duplicate dbdesc in state %s", ospf6_neighbor_state_str[on->state]); thread_add_event(master, seqnumber_mismatch, on, 0, NULL); @@ -553,21 +593,21 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh, + sizeof(struct ospf6_header)); if (on->state < OSPF6_NEIGHBOR_INIT) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor state less than Init, ignore"); return; } switch (on->state) { case OSPF6_NEIGHBOR_TWOWAY: - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor state is 2-Way, ignore"); return; case OSPF6_NEIGHBOR_INIT: thread_execute(master, twoway_received, on, 0); if (on->state != OSPF6_NEIGHBOR_EXSTART) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Neighbor state is not ExStart, ignore"); return; @@ -611,7 +651,7 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh, sizeof(struct ospf6_dbdesc))) { /* Duplicated DatabaseDescription causes slave to * retransmit */ - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Duplicated dbdesc causes retransmit"); THREAD_OFF(on->thread_send_dbdesc); @@ -622,7 +662,7 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh, } if (!CHECK_FLAG(dbdesc->bits, OSPF6_DBDESC_MSBIT)) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Master/Slave bit mismatch"); thread_add_event(master, seqnumber_mismatch, on, 0, NULL); @@ -630,7 +670,7 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh, } if (CHECK_FLAG(dbdesc->bits, OSPF6_DBDESC_IBIT)) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Initialize bit mismatch"); thread_add_event(master, seqnumber_mismatch, on, 0, NULL); @@ -638,7 +678,7 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh, } if (memcmp(on->options, dbdesc->options, sizeof(on->options))) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Option field mismatch"); thread_add_event(master, seqnumber_mismatch, on, 0, NULL); @@ -646,7 +686,7 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh, } if (ntohl(dbdesc->seqnum) != on->dbdesc_seqnum + 1) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Sequence number mismatch (%#lx expected)", (unsigned long)on->dbdesc_seqnum + 1); @@ -662,7 +702,7 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh, sizeof(struct ospf6_dbdesc))) { /* Duplicated DatabaseDescription causes slave to * retransmit */ - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Duplicated dbdesc causes retransmit"); THREAD_OFF(on->thread_send_dbdesc); @@ -671,7 +711,7 @@ static void ospf6_dbdesc_recv_slave(struct ospf6_header *oh, return; } - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Not duplicate dbdesc in state %s", ospf6_neighbor_state_str[on->state]); thread_add_event(master, seqnumber_mismatch, on, 0, NULL); @@ -756,7 +796,7 @@ static void ospf6_dbdesc_recv(struct in6_addr *src, struct in6_addr *dst, on = ospf6_neighbor_lookup(oh->router_id, oi); if (on == NULL) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor not found, ignore"); return; } @@ -773,7 +813,7 @@ static void ospf6_dbdesc_recv(struct in6_addr *src, struct in6_addr *dst, } if (dbdesc->reserved1 || dbdesc->reserved2) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug( "Non-0 reserved field in %s's DbDesc, correct", on->name); @@ -788,7 +828,7 @@ static void ospf6_dbdesc_recv(struct in6_addr *src, struct in6_addr *dst, else if (ntohl(oi->area->ospf6->router_id) < ntohl(oh->router_id)) ospf6_dbdesc_recv_slave(oh, on); else { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Can't decide which is master, ignore"); } } @@ -805,7 +845,7 @@ static void ospf6_lsreq_recv(struct in6_addr *src, struct in6_addr *dst, on = ospf6_neighbor_lookup(oh->router_id, oi); if (on == NULL) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor not found, ignore"); return; } @@ -813,7 +853,7 @@ static void ospf6_lsreq_recv(struct in6_addr *src, struct in6_addr *dst, if (on->state != OSPF6_NEIGHBOR_EXCHANGE && on->state != OSPF6_NEIGHBOR_LOADING && on->state != OSPF6_NEIGHBOR_FULL) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor state less than Exchange, ignore"); return; } @@ -882,7 +922,7 @@ static unsigned ospf6_prefixes_examin( while (length) { if (length < OSPF6_PREFIX_MIN_SIZE) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug("%s: undersized IPv6 prefix header", __func__); return MSG_NG; @@ -890,7 +930,7 @@ static unsigned ospf6_prefixes_examin( /* safe to look deeper */ if (current->prefix_length > IPV6_MAX_BITLEN) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug("%s: invalid PrefixLength (%u bits)", __func__, current->prefix_length); return MSG_NG; @@ -901,7 +941,7 @@ static unsigned ospf6_prefixes_examin( + OSPF6_PREFIX_SPACE(current->prefix_length); if (requested_pfx_bytes > length) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug("%s: undersized IPv6 prefix", __func__); return MSG_NG; @@ -913,7 +953,8 @@ static unsigned ospf6_prefixes_examin( real_num_pfxs++; } if (real_num_pfxs != req_num_pfxs) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug( "%s: IPv6 prefix number mismatch (%u required, %u real)", __func__, req_num_pfxs, real_num_pfxs); @@ -945,7 +986,8 @@ static unsigned ospf6_lsa_examin(struct ospf6_lsa_header *lsah, ltindex = lsatype & OSPF6_LSTYPE_FCODE_MASK; if (ltindex < OSPF6_LSTYPE_SIZE && ospf6_lsa_minlen[ltindex] && lsalen < ospf6_lsa_minlen[ltindex] + OSPF6_LSA_HEADER_SIZE) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("%s: undersized (%u B) LSA", __func__, lsalen); return MSG_NG; @@ -958,7 +1000,7 @@ static unsigned ospf6_lsa_examin(struct ospf6_lsa_header *lsah, if ((lsalen - OSPF6_LSA_HEADER_SIZE - OSPF6_ROUTER_LSA_MIN_SIZE) % OSPF6_ROUTER_LSDESC_FIX_SIZE) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug( "%s: interface description alignment error", __func__); @@ -972,7 +1014,7 @@ static unsigned ospf6_lsa_examin(struct ospf6_lsa_header *lsah, - OSPF6_NETWORK_LSA_MIN_SIZE) % OSPF6_NETWORK_LSDESC_FIX_SIZE) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug( "%s: router description alignment error", __func__); @@ -997,7 +1039,7 @@ static unsigned ospf6_lsa_examin(struct ospf6_lsa_header *lsah, if (lsalen > OSPF6_LSA_HEADER_SIZE + OSPF6_INTER_ROUTER_LSA_FIX_SIZE) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug("%s: oversized (%u B) LSA", __func__, lsalen); return MSG_NG; @@ -1026,7 +1068,7 @@ static unsigned ospf6_lsa_examin(struct ospf6_lsa_header *lsah, prefix before ospf6_prefix_examin() confirms its sizing. */ if (exp_length + OSPF6_PREFIX_MIN_SIZE > lsalen) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug("%s: undersized (%u B) LSA header", __func__, lsalen); return MSG_NG; @@ -1045,7 +1087,7 @@ static unsigned ospf6_lsa_examin(struct ospf6_lsa_header *lsah, this check does not include any IPv6 prefix fields. */ if (exp_length > lsalen) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug("%s: undersized (%u B) LSA header", __func__, lsalen); return MSG_NG; @@ -1114,7 +1156,7 @@ ospf6_lsaseq_examin(struct ospf6_lsa_header *lsah, /* start of buffered data */ uint16_t lsalen; if (length < OSPF6_LSA_HEADER_SIZE) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug( "%s: undersized (%zu B) trailing (#%u) LSA header", __func__, length, counted_lsas); @@ -1124,7 +1166,7 @@ ospf6_lsaseq_examin(struct ospf6_lsa_header *lsah, /* start of buffered data */ lsalen = OSPF6_LSA_SIZE(lsah); if (lsalen < OSPF6_LSA_HEADER_SIZE) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, - RECV)) + RECV_HDR)) zlog_debug( "%s: malformed LSA header #%u, declared length is %u B", __func__, counted_lsas, lsalen); @@ -1134,7 +1176,8 @@ ospf6_lsaseq_examin(struct ospf6_lsa_header *lsah, /* start of buffered data */ /* less checks here and in ospf6_lsa_examin() */ if (MSG_OK != ospf6_lsa_examin(lsah, lsalen, 1)) { if (IS_OSPF6_DEBUG_MESSAGE( - OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug( "%s: anomaly in header-only %s LSA #%u", __func__, @@ -1151,7 +1194,8 @@ ospf6_lsaseq_examin(struct ospf6_lsa_header *lsah, /* start of buffered data */ * further checks */ if (lsalen > length) { if (IS_OSPF6_DEBUG_MESSAGE( - OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug( "%s: anomaly in %s LSA #%u: declared length is %u B, buffered length is %zu B", __func__, @@ -1161,7 +1205,8 @@ ospf6_lsaseq_examin(struct ospf6_lsa_header *lsah, /* start of buffered data */ } if (MSG_OK != ospf6_lsa_examin(lsah, lsalen, 0)) { if (IS_OSPF6_DEBUG_MESSAGE( - OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug( "%s: anomaly in %s LSA #%u", __func__, @@ -1177,7 +1222,8 @@ ospf6_lsaseq_examin(struct ospf6_lsa_header *lsah, /* start of buffered data */ } if (declared_num_lsas && counted_lsas != declared_num_lsas) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug( "%s: #LSAs declared (%u) does not match actual (%u)", __func__, declared_num_lsas, counted_lsas); @@ -1195,14 +1241,16 @@ static unsigned ospf6_packet_examin(struct ospf6_header *oh, /* length, 1st approximation */ if (bytesonwire < OSPF6_HEADER_SIZE) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("%s: undersized (%u B) packet", __func__, bytesonwire); return MSG_NG; } /* Now it is safe to access header fields. */ if (bytesonwire != ntohs(oh->length)) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug( "%s: %s packet length error (%u real, %u declared)", __func__, lookup_msg(ospf6_message_type_str, @@ -1212,7 +1260,8 @@ static unsigned ospf6_packet_examin(struct ospf6_header *oh, } /* version check */ if (oh->version != OSPFV3_VERSION) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("%s: invalid (%u) protocol version", __func__, oh->version); return MSG_NG; @@ -1221,7 +1270,8 @@ static unsigned ospf6_packet_examin(struct ospf6_header *oh, if (oh->type < OSPF6_MESSAGE_TYPE_ALL && ospf6_packet_minlen[oh->type] && bytesonwire < OSPF6_HEADER_SIZE + ospf6_packet_minlen[oh->type]) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("%s: undersized (%u B) %s packet", __func__, bytesonwire, lookup_msg(ospf6_message_type_str, oh->type, @@ -1238,7 +1288,8 @@ static unsigned ospf6_packet_examin(struct ospf6_header *oh, == (bytesonwire - OSPF6_HEADER_SIZE - OSPF6_HELLO_MIN_SIZE) % 4) return MSG_OK; - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("%s: alignment error in %s packet", __func__, lookup_msg(ospf6_message_type_str, oh->type, NULL)); @@ -1261,7 +1312,8 @@ static unsigned ospf6_packet_examin(struct ospf6_header *oh, == (bytesonwire - OSPF6_HEADER_SIZE - OSPF6_LS_REQ_MIN_SIZE) % OSPF6_LSREQ_LSDESC_FIX_SIZE) return MSG_OK; - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("%s: alignment error in %s packet", __func__, lookup_msg(ospf6_message_type_str, oh->type, NULL)); @@ -1289,13 +1341,14 @@ static unsigned ospf6_packet_examin(struct ospf6_header *oh, 1, 0); break; default: - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("%s: invalid (%u) message type", __func__, oh->type); return MSG_NG; } if (test != MSG_OK - && IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + && IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV_HDR)) zlog_debug("%s: anomaly in %s packet", __func__, lookup_msg(ospf6_message_type_str, oh->type, NULL)); return test; @@ -1356,7 +1409,7 @@ static void ospf6_lsupdate_recv(struct in6_addr *src, struct in6_addr *dst, on = ospf6_neighbor_lookup(oh->router_id, oi); if (on == NULL) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor not found, ignore"); return; } @@ -1364,7 +1417,7 @@ static void ospf6_lsupdate_recv(struct in6_addr *src, struct in6_addr *dst, if (on->state != OSPF6_NEIGHBOR_EXCHANGE && on->state != OSPF6_NEIGHBOR_LOADING && on->state != OSPF6_NEIGHBOR_FULL) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor state less than Exchange, ignore"); return; } @@ -1398,7 +1451,7 @@ static void ospf6_lsack_recv(struct in6_addr *src, struct in6_addr *dst, on = ospf6_neighbor_lookup(oh->router_id, oi); if (on == NULL) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor not found, ignore"); return; } @@ -1406,7 +1459,7 @@ static void ospf6_lsack_recv(struct in6_addr *src, struct in6_addr *dst, if (on->state != OSPF6_NEIGHBOR_EXCHANGE && on->state != OSPF6_NEIGHBOR_LOADING && on->state != OSPF6_NEIGHBOR_FULL) { - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) zlog_debug("Neighbor state less than Exchange, ignore"); return; } @@ -1555,12 +1608,14 @@ int ospf6_receive(struct thread *thread) oi = ospf6_interface_lookup_by_ifindex(ifindex, ospf6->vrf_id); if (oi == NULL || oi->area == NULL || CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("Message received on disabled interface"); return 0; } if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE)) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, + RECV_HDR)) zlog_debug("%s: Ignore message on passive interface %s", __func__, oi->interface->name); return 0; @@ -1576,7 +1631,7 @@ int ospf6_receive(struct thread *thread) which can be dismissed in a cleanup-focused review round later. */ /* Log */ - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV)) { + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, RECV_HDR)) { zlog_debug("%s received on %s", lookup_msg(ospf6_message_type_str, oh->type, NULL), oi->interface->name); @@ -1585,19 +1640,19 @@ int ospf6_receive(struct thread *thread) switch (oh->type) { case OSPF6_MESSAGE_TYPE_HELLO: - ospf6_hello_print(oh); + ospf6_hello_print(oh, OSPF6_ACTION_RECV); break; case OSPF6_MESSAGE_TYPE_DBDESC: - ospf6_dbdesc_print(oh); + ospf6_dbdesc_print(oh, OSPF6_ACTION_RECV); break; case OSPF6_MESSAGE_TYPE_LSREQ: - ospf6_lsreq_print(oh); + ospf6_lsreq_print(oh, OSPF6_ACTION_RECV); break; case OSPF6_MESSAGE_TYPE_LSUPDATE: - ospf6_lsupdate_print(oh); + ospf6_lsupdate_print(oh, OSPF6_ACTION_RECV); break; case OSPF6_MESSAGE_TYPE_LSACK: - ospf6_lsack_print(oh); + ospf6_lsack_print(oh, OSPF6_ACTION_RECV); break; default: assert(0); @@ -1656,7 +1711,7 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst, oh->reserved = 0; /* Log */ - if (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND)) { + if (IS_OSPF6_DEBUG_MESSAGE(oh->type, SEND_HDR)) { if (src) inet_ntop(AF_INET6, src, srcname, sizeof(srcname)); else @@ -1669,19 +1724,19 @@ static void ospf6_send(struct in6_addr *src, struct in6_addr *dst, switch (oh->type) { case OSPF6_MESSAGE_TYPE_HELLO: - ospf6_hello_print(oh); + ospf6_hello_print(oh, OSPF6_ACTION_RECV); break; case OSPF6_MESSAGE_TYPE_DBDESC: - ospf6_dbdesc_print(oh); + ospf6_dbdesc_print(oh, OSPF6_ACTION_RECV); break; case OSPF6_MESSAGE_TYPE_LSREQ: - ospf6_lsreq_print(oh); + ospf6_lsreq_print(oh, OSPF6_ACTION_RECV); break; case OSPF6_MESSAGE_TYPE_LSUPDATE: - ospf6_lsupdate_print(oh); + ospf6_lsupdate_print(oh, OSPF6_ACTION_RECV); break; case OSPF6_MESSAGE_TYPE_LSACK: - ospf6_lsack_print(oh); + ospf6_lsack_print(oh, OSPF6_ACTION_RECV); break; default: zlog_debug("Unknown message"); @@ -1719,7 +1774,7 @@ int ospf6_hello_send(struct thread *thread) oi->thread_send_hello = (struct thread *)NULL; if (oi->state <= OSPF6_INTERFACE_DOWN) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_HELLO, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_HELLO, SEND_HDR)) zlog_debug("Unable to send Hello on down interface %s", oi->interface->name); return 0; @@ -1758,7 +1813,7 @@ int ospf6_hello_send(struct thread *thread) if (p - sendbuf + sizeof(uint32_t) > ospf6_packet_max(oi)) { if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_HELLO, - SEND)) + SEND_HDR)) zlog_debug( "sending Hello message: exceeds I/F MTU"); break; @@ -1790,7 +1845,7 @@ int ospf6_dbdesc_send(struct thread *thread) on->thread_send_dbdesc = (struct thread *)NULL; if (on->state < OSPF6_NEIGHBOR_EXSTART) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_DBDESC, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_DBDESC, SEND_HDR)) zlog_debug( "Quit to send DbDesc to neighbor %s state %s", on->name, ospf6_neighbor_state_str[on->state]); @@ -1918,7 +1973,7 @@ int ospf6_lsreq_send(struct thread *thread) /* LSReq will be sent only in ExStart or Loading */ if (on->state != OSPF6_NEIGHBOR_EXCHANGE && on->state != OSPF6_NEIGHBOR_LOADING) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSREQ, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSREQ, SEND_HDR)) zlog_debug("Quit to send LSReq to neighbor %s state %s", on->name, ospf6_neighbor_state_str[on->state]); @@ -2029,11 +2084,12 @@ int ospf6_lsupdate_send_neighbor(struct thread *thread) on = (struct ospf6_neighbor *)THREAD_ARG(thread); on->thread_send_lsupdate = (struct thread *)NULL; - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND_HDR)) zlog_debug("LSUpdate to neighbor %s", on->name); if (on->state < OSPF6_NEIGHBOR_EXCHANGE) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, + SEND_HDR)) zlog_debug("Quit to send (neighbor state %s)", ospf6_neighbor_state_str[on->state]); return 0; @@ -2190,7 +2246,7 @@ int ospf6_lsupdate_send_neighbor_now(struct ospf6_neighbor *on, lsupdate->lsa_number = htonl(lsa_cnt); if (IS_OSPF6_DEBUG_FLOODING - || IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) + || IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND_HDR)) zlog_debug("%s: Send lsupdate with lsa %s (age %u)", __func__, lsa->name, ntohs(lsa->header->age)); @@ -2212,7 +2268,8 @@ int ospf6_lsupdate_send_interface(struct thread *thread) oi->thread_send_lsupdate = (struct thread *)NULL; if (oi->state <= OSPF6_INTERFACE_WAITING) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSUPDATE, + SEND_HDR)) zlog_debug( "Quit to send LSUpdate to interface %s state %s", oi->interface->name, @@ -2299,7 +2356,7 @@ int ospf6_lsack_send_neighbor(struct thread *thread) on->thread_send_lsack = (struct thread *)NULL; if (on->state < OSPF6_NEIGHBOR_EXCHANGE) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSACK, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSACK, SEND_HDR)) zlog_debug("Quit to send LSAck to neighbor %s state %s", on->name, ospf6_neighbor_state_str[on->state]); @@ -2377,7 +2434,7 @@ int ospf6_lsack_send_interface(struct thread *thread) oi->thread_send_lsack = (struct thread *)NULL; if (oi->state <= OSPF6_INTERFACE_WAITING) { - if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSACK, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_LSACK, SEND_HDR)) zlog_debug( "Quit to send LSAck to interface %s state %s", oi->interface->name, @@ -2440,21 +2497,21 @@ int ospf6_lsack_send_interface(struct thread *thread) /* Commands */ -DEFUN (debug_ospf6_message, - debug_ospf6_message_cmd, - "debug ospf6 message []", - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 message\n" - "Debug Unknown message\n" - "Debug Hello message\n" - "Debug Database Description message\n" - "Debug Link State Request message\n" - "Debug Link State Update message\n" - "Debug Link State Acknowledgement message\n" - "Debug All message\n" - "Debug only sending message\n" - "Debug only receiving message\n") +DEFUN(debug_ospf6_message, debug_ospf6_message_cmd, + "debug ospf6 message []", + DEBUG_STR OSPF6_STR + "Debug OSPFv3 message\n" + "Debug Unknown message\n" + "Debug Hello message\n" + "Debug Database Description message\n" + "Debug Link State Request message\n" + "Debug Link State Update message\n" + "Debug Link State Acknowledgement message\n" + "Debug All message\n" + "Debug only sending message, entire packet\n" + "Debug only receiving message, entire packet\n" + "Debug only sending message, header only\n" + "Debug only receiving message, header only\n") { int idx_packet = 3; int idx_send_recv = 4; @@ -2480,8 +2537,12 @@ DEFUN (debug_ospf6_message, if (argc == 4) level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV; + else if (!strncmp(argv[idx_send_recv]->arg, "send-h", 6)) + level = OSPF6_DEBUG_MESSAGE_SEND_HDR; else if (!strncmp(argv[idx_send_recv]->arg, "s", 1)) level = OSPF6_DEBUG_MESSAGE_SEND; + else if (!strncmp(argv[idx_send_recv]->arg, "recv-h", 6)) + level = OSPF6_DEBUG_MESSAGE_RECV_HDR; else if (!strncmp(argv[idx_send_recv]->arg, "r", 1)) level = OSPF6_DEBUG_MESSAGE_RECV; @@ -2494,22 +2555,21 @@ DEFUN (debug_ospf6_message, return CMD_SUCCESS; } -DEFUN (no_debug_ospf6_message, - no_debug_ospf6_message_cmd, - "no debug ospf6 message []", - NO_STR - DEBUG_STR - OSPF6_STR - "Debug OSPFv3 message\n" - "Debug Unknown message\n" - "Debug Hello message\n" - "Debug Database Description message\n" - "Debug Link State Request message\n" - "Debug Link State Update message\n" - "Debug Link State Acknowledgement message\n" - "Debug All message\n" - "Debug only sending message\n" - "Debug only receiving message\n") +DEFUN(no_debug_ospf6_message, no_debug_ospf6_message_cmd, + "no debug ospf6 message []", + NO_STR DEBUG_STR OSPF6_STR + "Debug OSPFv3 message\n" + "Debug Unknown message\n" + "Debug Hello message\n" + "Debug Database Description message\n" + "Debug Link State Request message\n" + "Debug Link State Update message\n" + "Debug Link State Acknowledgement message\n" + "Debug All message\n" + "Debug only sending message, entire pkt\n" + "Debug only receiving message, entire pkt\n" + "Debug only sending message, header only\n" + "Debug only receiving message, header only\n") { int idx_packet = 4; int idx_send_recv = 5; @@ -2534,9 +2594,15 @@ DEFUN (no_debug_ospf6_message, type = OSPF6_MESSAGE_TYPE_ALL; if (argc == 5) - level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV; + level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV + | OSPF6_DEBUG_MESSAGE_SEND_HDR + | OSPF6_DEBUG_MESSAGE_RECV_HDR; + else if (!strncmp(argv[idx_send_recv]->arg, "send-h", 6)) + level = OSPF6_DEBUG_MESSAGE_SEND_HDR; else if (!strncmp(argv[idx_send_recv]->arg, "s", 1)) level = OSPF6_DEBUG_MESSAGE_SEND; + else if (!strncmp(argv[idx_send_recv]->arg, "recv-h", 6)) + level = OSPF6_DEBUG_MESSAGE_RECV_HDR; else if (!strncmp(argv[idx_send_recv]->arg, "r", 1)) level = OSPF6_DEBUG_MESSAGE_RECV; @@ -2554,16 +2620,23 @@ int config_write_ospf6_debug_message(struct vty *vty) { const char *type_str[] = {"unknown", "hello", "dbdesc", "lsreq", "lsupdate", "lsack"}; - unsigned char s = 0, r = 0; + unsigned char s = 0, r = 0, sh = 0, rh = 0; int i; for (i = 0; i < 6; i++) { - if (IS_OSPF6_DEBUG_MESSAGE(i, SEND)) + if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, SEND)) s |= 1 << i; - if (IS_OSPF6_DEBUG_MESSAGE(i, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, RECV)) r |= 1 << i; } + for (i = 0; i < 6; i++) { + if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, SEND_HDR)) + sh |= 1 << i; + if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, RECV_HDR)) + rh |= 1 << i; + } + if (s == 0x3f && r == 0x3f) { vty_out(vty, "debug ospf6 message all\n"); return 0; @@ -2577,6 +2650,14 @@ int config_write_ospf6_debug_message(struct vty *vty) return 0; } + if (sh == 0x3f && rh == 0) { + vty_out(vty, "debug ospf6 message all send-hdr\n"); + return 0; + } else if (sh == 0 && rh == 0x3f) { + vty_out(vty, "debug ospf6 message all recv-hdr\n"); + return 0; + } + /* Unknown message is logged by default */ if (!IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, SEND) && !IS_OSPF6_DEBUG_MESSAGE(OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) @@ -2587,15 +2668,25 @@ int config_write_ospf6_debug_message(struct vty *vty) vty_out(vty, "no debug ospf6 message unknown recv\n"); for (i = 1; i < 6; i++) { - if (IS_OSPF6_DEBUG_MESSAGE(i, SEND) - && IS_OSPF6_DEBUG_MESSAGE(i, RECV)) + if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, SEND) + && IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, RECV)) vty_out(vty, "debug ospf6 message %s\n", type_str[i]); - else if (IS_OSPF6_DEBUG_MESSAGE(i, SEND)) + else if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, SEND)) vty_out(vty, "debug ospf6 message %s send\n", type_str[i]); - else if (IS_OSPF6_DEBUG_MESSAGE(i, RECV)) + else if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, RECV)) vty_out(vty, "debug ospf6 message %s recv\n", type_str[i]); + else if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, SEND_HDR) + && IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, RECV_HDR)) + vty_out(vty, "debug ospf6 message %s; header only\n", + type_str[i]); + else if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, RECV_HDR)) + vty_out(vty, "debug ospf6 message %s recv-hdr\n", + type_str[i]); + else if (IS_OSPF6_DEBUG_MESSAGE_ENABLED(i, SEND_HDR)) + vty_out(vty, "debug ospf6 message %s send-hdr\n", + type_str[i]); } return 0; diff --git a/ospf6d/ospf6_message.h b/ospf6d/ospf6_message.h index 7ec8cb785f87..c4cdbd52f4b1 100644 --- a/ospf6d/ospf6_message.h +++ b/ospf6d/ospf6_message.h @@ -25,14 +25,34 @@ /* Debug option */ extern unsigned char conf_debug_ospf6_message[]; +#define OSPF6_ACTION_SEND 0x01 +#define OSPF6_ACTION_RECV 0x02 #define OSPF6_DEBUG_MESSAGE_SEND 0x01 #define OSPF6_DEBUG_MESSAGE_RECV 0x02 +#define OSPF6_DEBUG_MESSAGE_SEND_HDR 0x04 +#define OSPF6_DEBUG_MESSAGE_RECV_HDR 0x08 +#define OSPF6_DEBUG_MESSAGE_SEND_BOTH \ + OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_SEND_HDR +#define OSPF6_DEBUG_MESSAGE_RECV_BOTH \ + OSPF6_DEBUG_MESSAGE_RECV | OSPF6_DEBUG_MESSAGE_RECV_HDR + #define OSPF6_DEBUG_MESSAGE_ON(type, level) \ (conf_debug_ospf6_message[type] |= (level)) #define OSPF6_DEBUG_MESSAGE_OFF(type, level) \ (conf_debug_ospf6_message[type] &= ~(level)) + #define IS_OSPF6_DEBUG_MESSAGE(t, e) \ - (conf_debug_ospf6_message[t] & OSPF6_DEBUG_MESSAGE_##e) + ((OSPF6_DEBUG_MESSAGE_##e) == OSPF6_DEBUG_MESSAGE_RECV_HDR) \ + ? (conf_debug_ospf6_message[t] \ + & (OSPF6_DEBUG_MESSAGE_RECV_BOTH)) \ + : (((OSPF6_DEBUG_MESSAGE_##e) == OSPF6_DEBUG_MESSAGE_SEND_HDR) \ + ? (conf_debug_ospf6_message[t] \ + & (OSPF6_DEBUG_MESSAGE_SEND_BOTH)) \ + : (conf_debug_ospf6_message[t] \ + & (OSPF6_DEBUG_MESSAGE_##e))) + +#define IS_OSPF6_DEBUG_MESSAGE_ENABLED(type, e) \ + (conf_debug_ospf6_message[type] & (OSPF6_DEBUG_MESSAGE_##e)) /* Type */ #define OSPF6_MESSAGE_TYPE_UNKNOWN 0x0 @@ -110,11 +130,11 @@ struct ospf6_lsupdate { /* It is just a sequence of LSA Headers */ /* Function definition */ -extern void ospf6_hello_print(struct ospf6_header *); -extern void ospf6_dbdesc_print(struct ospf6_header *); -extern void ospf6_lsreq_print(struct ospf6_header *); -extern void ospf6_lsupdate_print(struct ospf6_header *); -extern void ospf6_lsack_print(struct ospf6_header *); +extern void ospf6_hello_print(struct ospf6_header *, int action); +extern void ospf6_dbdesc_print(struct ospf6_header *, int action); +extern void ospf6_lsreq_print(struct ospf6_header *, int action); +extern void ospf6_lsupdate_print(struct ospf6_header *, int action); +extern void ospf6_lsack_print(struct ospf6_header *, int action); extern int ospf6_iobuf_size(unsigned int size); extern void ospf6_message_terminate(void);