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];
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];
(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;
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,
+ 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;
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);
}
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);
}
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);
}
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);
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);
+ 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;
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);
}
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);
}
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);
}
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);
}
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);
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);
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);
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;
}
}
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);
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");
}
}
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;
}
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;
}
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;
/* 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;
+ 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;
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);
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;
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__);
- 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__);
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;
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;
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;
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);
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);
/* 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__,
* 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__,
}
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__,
}
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);
/* 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,
}
/* 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;
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,
== (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));
== (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));
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;
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;
}
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;
}
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;
}
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;
}
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;
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);
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);
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
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");
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;
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;
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]);
/* 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]);
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;
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));
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,
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]);
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,
/* Commands */
-DEFUN (debug_ospf6_message,
- debug_ospf6_message_cmd,
- "debug ospf6 message <unknown|hello|dbdesc|lsreq|lsupdate|lsack|all> [<send|recv>]",
- 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 <unknown|hello|dbdesc|lsreq|lsupdate|lsack|all> [<send|recv|send-hdr|recv-hdr>]",
+ 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;
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;
return CMD_SUCCESS;
}
-DEFUN (no_debug_ospf6_message,
- no_debug_ospf6_message_cmd,
- "no debug ospf6 message <unknown|hello|dbdesc|lsreq|lsupdate|lsack|all> [<send|recv>]",
- 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 <unknown|hello|dbdesc|lsreq|lsupdate|lsack|all> [<send|recv|send-hdr|recv-hdr>]",
+ 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;
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;
{
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;
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))
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;