📄 ospf6_message.c
字号:
} return 0;}intospf6_lsupdate_send_interface (struct thread *thread){ struct ospf6_interface *oi; struct ospf6_header *oh; struct ospf6_lsupdate *lsupdate; char *p; int num; struct ospf6_lsa *lsa; oi = (struct ospf6_interface *) THREAD_ARG (thread); oi->thread_send_lsupdate = (struct thread *) NULL; if (oi->state <= OSPF6_INTERFACE_WAITING) { if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_LSUPDATE, SEND)) zlog_info ("Quit to send LSUpdate to interface %s state %s", oi->interface->name, ospf6_interface_state_str[oi->state]); return 0; } /* if we have nothing to send, return */ if (oi->lsupdate_list->count == 0) return 0; memset (sendbuf, 0, iobuflen); oh = (struct ospf6_header *) sendbuf; lsupdate = (struct ospf6_lsupdate *)((caddr_t) oh + sizeof (struct ospf6_header)); p = (char *)((caddr_t) lsupdate + sizeof (struct ospf6_lsupdate)); num = 0; for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; lsa = ospf6_lsdb_next (lsa)) { /* MTU check */ if (p - sendbuf + OSPF6_LSA_SIZE (lsa->header) > oi->ifmtu) { ospf6_lsa_unlock (lsa); break; } ospf6_lsa_age_update_to_send (lsa, oi->transdelay); memcpy (p, lsa->header, OSPF6_LSA_SIZE (lsa->header)); p += OSPF6_LSA_SIZE (lsa->header); num++; assert (lsa->lock == 2); ospf6_lsdb_remove (lsa, oi->lsupdate_list); } lsupdate->lsa_number = htonl (num); oh->type = OSPF6_MESSAGE_TYPE_LSUPDATE; oh->length = htons (p - sendbuf); if (oi->state == OSPF6_INTERFACE_DR || oi->state == OSPF6_INTERFACE_BDR) ospf6_send (oi->linklocal_addr, &allspfrouters6, oi, oh); else ospf6_send (oi->linklocal_addr, &alldrouters6, oi, oh); if (oi->lsupdate_list->count > 0) { oi->thread_send_lsupdate = thread_add_event (master, ospf6_lsupdate_send_interface, oi, 0); } return 0;}intospf6_lsack_send_neighbor (struct thread *thread){ struct ospf6_neighbor *on; struct ospf6_header *oh; char *p; struct ospf6_lsa *lsa; on = (struct ospf6_neighbor *) THREAD_ARG (thread); on->thread_send_lsack = (struct thread *) NULL; if (on->state < OSPF6_NEIGHBOR_EXCHANGE) { if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_LSACK, SEND)) zlog_info ("Quit to send LSAck to neighbor %s state %s", on->name, ospf6_neighbor_state_str[on->state]); return 0; } /* if we have nothing to send, return */ if (on->lsack_list->count == 0) return 0; memset (sendbuf, 0, iobuflen); oh = (struct ospf6_header *) sendbuf; p = (char *)((caddr_t) oh + sizeof (struct ospf6_header)); for (lsa = ospf6_lsdb_head (on->lsack_list); lsa; lsa = ospf6_lsdb_next (lsa)) { /* MTU check */ if (p - sendbuf + sizeof (struct ospf6_lsa_header) > on->ospf6_if->ifmtu) { /* if we run out of packet size/space here, better to try again soon. */ THREAD_OFF (on->thread_send_lsack); on->thread_send_lsack = thread_add_event (master, ospf6_lsack_send_neighbor, on, 0); ospf6_lsa_unlock (lsa); break; } ospf6_lsa_age_update_to_send (lsa, on->ospf6_if->transdelay); memcpy (p, lsa->header, sizeof (struct ospf6_lsa_header)); p += sizeof (struct ospf6_lsa_header); assert (lsa->lock == 2); ospf6_lsdb_remove (lsa, on->lsack_list); } oh->type = OSPF6_MESSAGE_TYPE_LSACK; oh->length = htons (p - sendbuf); ospf6_send (on->ospf6_if->linklocal_addr, &on->linklocal_addr, on->ospf6_if, oh); return 0;}intospf6_lsack_send_interface (struct thread *thread){ struct ospf6_interface *oi; struct ospf6_header *oh; char *p; struct ospf6_lsa *lsa; oi = (struct ospf6_interface *) THREAD_ARG (thread); oi->thread_send_lsack = (struct thread *) NULL; if (oi->state <= OSPF6_INTERFACE_WAITING) { if (IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_LSACK, SEND)) zlog_info ("Quit to send LSAck to interface %s state %s", oi->interface->name, ospf6_interface_state_str[oi->state]); return 0; } /* if we have nothing to send, return */ if (oi->lsack_list->count == 0) return 0; memset (sendbuf, 0, iobuflen); oh = (struct ospf6_header *) sendbuf; p = (char *)((caddr_t) oh + sizeof (struct ospf6_header)); for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; lsa = ospf6_lsdb_next (lsa)) { /* MTU check */ if (p - sendbuf + sizeof (struct ospf6_lsa_header) > oi->ifmtu) { /* if we run out of packet size/space here, better to try again soon. */ THREAD_OFF (oi->thread_send_lsack); oi->thread_send_lsack = thread_add_event (master, ospf6_lsack_send_interface, oi, 0); ospf6_lsa_unlock (lsa); break; } ospf6_lsa_age_update_to_send (lsa, oi->transdelay); memcpy (p, lsa->header, sizeof (struct ospf6_lsa_header)); p += sizeof (struct ospf6_lsa_header); assert (lsa->lock == 2); ospf6_lsdb_remove (lsa, oi->lsack_list); } oh->type = OSPF6_MESSAGE_TYPE_LSACK; oh->length = htons (p - sendbuf); if (oi->state == OSPF6_INTERFACE_DR || oi->state == OSPF6_INTERFACE_BDR) ospf6_send (oi->linklocal_addr, &allspfrouters6, oi, oh); else ospf6_send (oi->linklocal_addr, &alldrouters6, oi, oh); if (oi->thread_send_lsack == NULL && oi->lsack_list->count > 0) { oi->thread_send_lsack = thread_add_event (master, ospf6_lsack_send_interface, oi, 0); } return 0;}/* Commands */DEFUN (debug_ospf6_message, debug_ospf6_message_cmd, "debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all)", 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" ){ unsigned char level = 0; int type = 0; int i; assert (argc > 0); /* check type */ if (! strncmp (argv[0], "u", 1)) type = OSPF6_MESSAGE_TYPE_UNKNOWN; else if (! strncmp (argv[0], "h", 1)) type = OSPF6_MESSAGE_TYPE_HELLO; else if (! strncmp (argv[0], "d", 1)) type = OSPF6_MESSAGE_TYPE_DBDESC; else if (! strncmp (argv[0], "lsr", 3)) type = OSPF6_MESSAGE_TYPE_LSREQ; else if (! strncmp (argv[0], "lsu", 3)) type = OSPF6_MESSAGE_TYPE_LSUPDATE; else if (! strncmp (argv[0], "lsa", 3)) type = OSPF6_MESSAGE_TYPE_LSACK; else if (! strncmp (argv[0], "a", 1)) type = OSPF6_MESSAGE_TYPE_ALL; if (argc == 1) level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV; else if (! strncmp (argv[1], "s", 1)) level = OSPF6_DEBUG_MESSAGE_SEND; else if (! strncmp (argv[1], "r", 1)) level = OSPF6_DEBUG_MESSAGE_RECV; if (type == OSPF6_MESSAGE_TYPE_ALL) { for (i = 0; i < 6; i++) OSPF6_DEBUG_MESSAGE_ON (i, level); } else OSPF6_DEBUG_MESSAGE_ON (type, level); return CMD_SUCCESS;}ALIAS (debug_ospf6_message, debug_ospf6_message_sendrecv_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 (no_debug_ospf6_message, no_debug_ospf6_message_cmd, "no debug ospf6 message (unknown|hello|dbdesc|lsreq|lsupdate|lsack|all)", 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" ){ unsigned char level = 0; int type = 0; int i; assert (argc > 0); /* check type */ if (! strncmp (argv[0], "u", 1)) type = OSPF6_MESSAGE_TYPE_UNKNOWN; else if (! strncmp (argv[0], "h", 1)) type = OSPF6_MESSAGE_TYPE_HELLO; else if (! strncmp (argv[0], "d", 1)) type = OSPF6_MESSAGE_TYPE_DBDESC; else if (! strncmp (argv[0], "lsr", 3)) type = OSPF6_MESSAGE_TYPE_LSREQ; else if (! strncmp (argv[0], "lsu", 3)) type = OSPF6_MESSAGE_TYPE_LSUPDATE; else if (! strncmp (argv[0], "lsa", 3)) type = OSPF6_MESSAGE_TYPE_LSACK; else if (! strncmp (argv[0], "a", 1)) type = OSPF6_MESSAGE_TYPE_ALL; if (argc == 1) level = OSPF6_DEBUG_MESSAGE_SEND | OSPF6_DEBUG_MESSAGE_RECV; else if (! strncmp (argv[1], "s", 1)) level = OSPF6_DEBUG_MESSAGE_SEND; else if (! strncmp (argv[1], "r", 1)) level = OSPF6_DEBUG_MESSAGE_RECV; if (type == OSPF6_MESSAGE_TYPE_ALL) { for (i = 0; i < 6; i++) OSPF6_DEBUG_MESSAGE_OFF (i, level); } else OSPF6_DEBUG_MESSAGE_OFF (type, level); return CMD_SUCCESS;}ALIAS (no_debug_ospf6_message, no_debug_ospf6_message_sendrecv_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" );intconfig_write_ospf6_debug_message (struct vty *vty){ char *type_str[] = {"unknown", "hello", "dbdesc", "lsreq", "lsupdate", "lsack"}; unsigned char s = 0, r = 0; int i; for (i = 0; i < 6; i++) { if (IS_OSPF6_DEBUG_MESSAGE (i, SEND)) s |= 1 << i; if (IS_OSPF6_DEBUG_MESSAGE (i, RECV)) r |= 1 << i; } if (s == 0x3f && r == 0x3f) { vty_out (vty, "debug ospf6 message all%s", VNL); return 0; } if (s == 0x3f && r == 0) { vty_out (vty, "debug ospf6 message all send%s", VNL); return 0; } else if (s == 0 && r == 0x3f) { vty_out (vty, "debug ospf6 message all recv%s", VNL); 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%s", VNL); else if (! IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, SEND)) vty_out (vty, "no debug ospf6 message unknown send%s", VNL); else if (! IS_OSPF6_DEBUG_MESSAGE (OSPF6_MESSAGE_TYPE_UNKNOWN, RECV)) vty_out (vty, "no debug ospf6 message unknown recv%s", VNL); for (i = 1; i < 6; i++) { if (IS_OSPF6_DEBUG_MESSAGE (i, SEND) && IS_OSPF6_DEBUG_MESSAGE (i, RECV)) vty_out (vty, "debug ospf6 message %s%s", type_str[i], VNL); else if (IS_OSPF6_DEBUG_MESSAGE (i, SEND)) vty_out (vty, "debug ospf6 message %s send%s", type_str[i], VNL); else if (IS_OSPF6_DEBUG_MESSAGE (i, RECV)) vty_out (vty, "debug ospf6 message %s recv%s", type_str[i], VNL); } return 0;}voidinstall_element_ospf6_debug_message (){ install_element (ENABLE_NODE, &debug_ospf6_message_cmd); install_element (ENABLE_NODE, &no_debug_ospf6_message_cmd); install_element (ENABLE_NODE, &debug_ospf6_message_sendrecv_cmd); install_element (ENABLE_NODE, &no_debug_ospf6_message_sendrecv_cmd); install_element (CONFIG_NODE, &debug_ospf6_message_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_message_cmd); install_element (CONFIG_NODE, &debug_ospf6_message_sendrecv_cmd); install_element (CONFIG_NODE, &no_debug_ospf6_message_sendrecv_cmd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -