⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ospf6_neighbor.c

📁 linux 路由软件 可支持RIP OSPF BGP等
💻 C
📖 第 1 页 / 共 2 页
字号:
  for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;       lsa = ospf6_lsdb_next (lsa))    {      ospf6_decrement_retrans_count (lsa);      ospf6_lsdb_remove (lsa, on->retrans_list);    }  THREAD_OFF (on->thread_send_dbdesc);  on->thread_send_dbdesc =    thread_add_event (master, ospf6_dbdesc_send, on, 0);  return 0;}intoneway_received (struct thread *thread){  struct ospf6_neighbor *on;  struct ospf6_lsa *lsa;  on = (struct ospf6_neighbor *) THREAD_ARG (thread);  assert (on);  if (on->state < OSPF6_NEIGHBOR_TWOWAY)    return 0;  if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))    zlog_info ("Neighbor Event %s: *1Way-Received*", on->name);  ospf6_neighbor_state_change (OSPF6_NEIGHBOR_INIT, on);  thread_add_event (master, neighbor_change, on->ospf6_if, 0);  ospf6_lsdb_remove_all (on->summary_list);  ospf6_lsdb_remove_all (on->request_list);  for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;       lsa = ospf6_lsdb_next (lsa))    {      ospf6_decrement_retrans_count (lsa);      ospf6_lsdb_remove (lsa, on->retrans_list);    }  THREAD_OFF (on->thread_send_dbdesc);  THREAD_OFF (on->thread_send_lsreq);  THREAD_OFF (on->thread_send_lsupdate);  THREAD_OFF (on->thread_send_lsack);  return 0;}intinactivity_timer (struct thread *thread){  struct ospf6_neighbor *on;  on = (struct ospf6_neighbor *) THREAD_ARG (thread);  assert (on);  if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))    zlog_info ("Neighbor Event %s: *InactivityTimer*", on->name);  on->inactivity_timer = NULL;  on->drouter = on->prev_drouter = 0;  on->bdrouter = on->prev_bdrouter = 0;  ospf6_neighbor_state_change (OSPF6_NEIGHBOR_DOWN, on);  thread_add_event (master, neighbor_change, on->ospf6_if, 0);  listnode_delete (on->ospf6_if->neighbor_list, on);  ospf6_neighbor_delete (on);  return 0;}/* vty functions *//* show neighbor structure */voidospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on){  char router_id[16];  char duration[16];  struct timeval now, res;  char nstate[16];  char deadtime[16];  long h, m, s;  /* Router-ID (Name) */  inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));#ifdef HAVE_GETNAMEINFO  {  }#endif /*HAVE_GETNAMEINFO*/  gettimeofday (&now, NULL);  /* Dead time */  h = m = s = 0;  if (on->inactivity_timer)    {      s = on->inactivity_timer->u.sands.tv_sec - now.tv_sec;      h = s / 3600;      s -= h * 3600;      m = s / 60;      s -= m * 60;    }  snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s);  /* Neighbor State */  if (if_is_pointopoint (on->ospf6_if->interface))    snprintf (nstate, sizeof (nstate), "PointToPoint");  else    {      if (on->router_id == on->drouter)        snprintf (nstate, sizeof (nstate), "DR");      else if (on->router_id == on->bdrouter)        snprintf (nstate, sizeof (nstate), "BDR");      else        snprintf (nstate, sizeof (nstate), "DROther");    }  /* Duration */  timersub (&now, &on->last_changed, &res);  timerstring (&res, duration, sizeof (duration));  /*  vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",           "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration",           "I/F", "State", VNL);  */  vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s",           router_id, on->priority, deadtime,           ospf6_neighbor_state_str[on->state], nstate, duration,           on->ospf6_if->interface->name,           ospf6_interface_state_str[on->ospf6_if->state], VNL);}voidospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on){  char router_id[16];  char drouter[16], bdrouter[16];  char duration[16];  struct timeval now, res;/*    vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",             "RouterID", "State", "Duration", "DR", "BDR", "I/F",             "State", VNL);*/  inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id));  inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));  inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));  gettimeofday (&now, NULL);  timersub (&now, &on->last_changed, &res);  timerstring (&res, duration, sizeof (duration));  vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",           router_id, ospf6_neighbor_state_str[on->state],           duration, drouter, bdrouter, on->ospf6_if->interface->name,           ospf6_interface_state_str[on->ospf6_if->state],           VNL);}voidospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on){  char drouter[16], bdrouter[16];  char linklocal_addr[64], duration[32];  struct timeval now, res;  struct ospf6_lsa *lsa;  inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr,             sizeof (linklocal_addr));  inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter));  inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter));  gettimeofday (&now, NULL);  timersub (&now, &on->last_changed, &res);  timerstring (&res, duration, sizeof (duration));  vty_out (vty, " Neighbor %s%s", on->name,           VNL);  vty_out (vty, "    Area %s via interface %s (ifindex %d)%s",           on->ospf6_if->area->name,           on->ospf6_if->interface->name,           on->ospf6_if->interface->ifindex,           VNL);  vty_out (vty, "    His IfIndex: %d Link-local address: %s%s",           on->ifindex, linklocal_addr,           VNL);  vty_out (vty, "    State %s for a duration of %s%s",           ospf6_neighbor_state_str[on->state], duration,           VNL);  vty_out (vty, "    His choice of DR/BDR %s/%s, Priority %d%s",           drouter, bdrouter, on->priority,           VNL);  vty_out (vty, "    DbDesc status: %s%s%s SeqNum: %#lx%s",           (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""),           (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""),           (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ?            "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum),           VNL);  vty_out (vty, "    Summary-List: %d LSAs%s", on->summary_list->count,           VNL);  for (lsa = ospf6_lsdb_head (on->summary_list); lsa;       lsa = ospf6_lsdb_next (lsa))    vty_out (vty, "      %s%s", lsa->name, VNL);  vty_out (vty, "    Request-List: %d LSAs%s", on->request_list->count,           VNL);  for (lsa = ospf6_lsdb_head (on->request_list); lsa;       lsa = ospf6_lsdb_next (lsa))    vty_out (vty, "      %s%s", lsa->name, VNL);  vty_out (vty, "    Retrans-List: %d LSAs%s", on->retrans_list->count,           VNL);  for (lsa = ospf6_lsdb_head (on->retrans_list); lsa;       lsa = ospf6_lsdb_next (lsa))    vty_out (vty, "      %s%s", lsa->name, VNL);  timerclear (&res);  if (on->thread_send_dbdesc)    timersub (&on->thread_send_dbdesc->u.sands, &now, &res);  timerstring (&res, duration, sizeof (duration));  vty_out (vty, "    %d Pending LSAs for DbDesc in Time %s [thread %s]%s",           on->dbdesc_list->count, duration,           (on->thread_send_dbdesc ? "on" : "off"),           VNL);  for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa;       lsa = ospf6_lsdb_next (lsa))    vty_out (vty, "      %s%s", lsa->name, VNL);  timerclear (&res);  if (on->thread_send_lsreq)    timersub (&on->thread_send_lsreq->u.sands, &now, &res);  timerstring (&res, duration, sizeof (duration));  vty_out (vty, "    %d Pending LSAs for LSReq in Time %s [thread %s]%s",           on->lsreq_list->count, duration,           (on->thread_send_lsreq ? "on" : "off"),           VNL);  for (lsa = ospf6_lsdb_head (on->lsreq_list); lsa;       lsa = ospf6_lsdb_next (lsa))    vty_out (vty, "      %s%s", lsa->name, VNL);  timerclear (&res);  if (on->thread_send_lsupdate)    timersub (&on->thread_send_lsupdate->u.sands, &now, &res);  timerstring (&res, duration, sizeof (duration));  vty_out (vty, "    %d Pending LSAs for LSUpdate in Time %s [thread %s]%s",           on->lsupdate_list->count, duration,           (on->thread_send_lsupdate ? "on" : "off"),           VNL);  for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa;       lsa = ospf6_lsdb_next (lsa))    vty_out (vty, "      %s%s", lsa->name, VNL);  timerclear (&res);  if (on->thread_send_lsack)    timersub (&on->thread_send_lsack->u.sands, &now, &res);  timerstring (&res, duration, sizeof (duration));  vty_out (vty, "    %d Pending LSAs for LSAck in Time %s [thread %s]%s",           on->lsack_list->count, duration,           (on->thread_send_lsack ? "on" : "off"),           VNL);  for (lsa = ospf6_lsdb_head (on->lsack_list); lsa;       lsa = ospf6_lsdb_next (lsa))    vty_out (vty, "      %s%s", lsa->name, VNL);}DEFUN (show_ipv6_ospf6_neighbor,       show_ipv6_ospf6_neighbor_cmd,       "show ipv6 ospf6 neighbor",       SHOW_STR       IP6_STR       OSPF6_STR       "Neighbor list\n"      ){  struct ospf6_neighbor *on;  struct ospf6_interface *oi;  struct ospf6_area *oa;  listnode i, j, k;  void (*showfunc) (struct vty *, struct ospf6_neighbor *);  OSPF6_CMD_CHECK_RUNNING ();  showfunc = ospf6_neighbor_show;  if (argc)    {      if (! strncmp (argv[0], "de", 2))        showfunc = ospf6_neighbor_show_detail;      else if (! strncmp (argv[0], "dr", 2))        showfunc = ospf6_neighbor_show_drchoice;    }  if (showfunc == ospf6_neighbor_show)    vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s",             "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration",             "I/F", "State", VNL);  else if (showfunc == ospf6_neighbor_show_drchoice)    vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s",             "RouterID", "State", "Duration", "DR", "BDR", "I/F",             "State", VNL);  for (i = listhead (ospf6->area_list); i; nextnode (i))    {      oa = (struct ospf6_area *) getdata (i);      for (j = listhead (oa->if_list); j; nextnode (j))        {          oi = (struct ospf6_interface *) getdata (j);          for (k = listhead (oi->neighbor_list); k; nextnode (k))            {              on = (struct ospf6_neighbor *) getdata (k);              (*showfunc) (vty, on);            }        }    }  return CMD_SUCCESS;}ALIAS (show_ipv6_ospf6_neighbor,       show_ipv6_ospf6_neighbor_detail_cmd,       "show ipv6 ospf6 neighbor (detail|drchoice)",       SHOW_STR       IP6_STR       OSPF6_STR       "Neighbor list\n"       "Display details\n"       "Display DR choices\n"      );DEFUN (show_ipv6_ospf6_neighbor_one,       show_ipv6_ospf6_neighbor_one_cmd,       "show ipv6 ospf6 neighbor A.B.C.D",       SHOW_STR       IP6_STR       OSPF6_STR       "Neighbor list\n"       "Specify Router-ID as IPv4 address notation\n"      ){  struct ospf6_neighbor *on;  struct ospf6_interface *oi;  struct ospf6_area *oa;  listnode i, j, k;  void (*showfunc) (struct vty *, struct ospf6_neighbor *);  u_int32_t router_id;  OSPF6_CMD_CHECK_RUNNING ();  showfunc = ospf6_neighbor_show_detail;  if ((inet_pton (AF_INET, argv[0], &router_id)) != 1)    {      vty_out (vty, "Router-ID is not parsable: %s%s", argv[0],               VNL);      return CMD_SUCCESS;    }  for (i = listhead (ospf6->area_list); i; nextnode (i))    {      oa = (struct ospf6_area *) getdata (i);      for (j = listhead (oa->if_list); j; nextnode (j))        {          oi = (struct ospf6_interface *) getdata (j);          for (k = listhead (oi->neighbor_list); k; nextnode (k))            {              on = (struct ospf6_neighbor *) getdata (k);              if (on->router_id == router_id)                (*showfunc) (vty, on);            }        }    }  return CMD_SUCCESS;}voidospf6_neighbor_init (){  install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_cmd);  install_element (VIEW_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);  install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_cmd);  install_element (ENABLE_NODE, &show_ipv6_ospf6_neighbor_detail_cmd);}DEFUN (debug_ospf6_neighbor,       debug_ospf6_neighbor_cmd,       "debug ospf6 neighbor",       DEBUG_STR       OSPF6_STR       "Debug OSPFv3 Neighbor\n"      ){  unsigned char level = 0;  if (argc)    {      if (! strncmp (argv[0], "s", 1))        level = OSPF6_DEBUG_NEIGHBOR_STATE;      if (! strncmp (argv[0], "e", 1))        level = OSPF6_DEBUG_NEIGHBOR_EVENT;    }  else    level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;  OSPF6_DEBUG_NEIGHBOR_ON (level);  return CMD_SUCCESS;}ALIAS (debug_ospf6_neighbor,       debug_ospf6_neighbor_detail_cmd,       "debug ospf6 neighbor (state|event)",       DEBUG_STR       OSPF6_STR       "Debug OSPFv3 Neighbor\n"       "Debug OSPFv3 Neighbor State Change\n"       "Debug OSPFv3 Neighbor Event\n"      );DEFUN (no_debug_ospf6_neighbor,       no_debug_ospf6_neighbor_cmd,       "no debug ospf6 neighbor",       NO_STR       DEBUG_STR       OSPF6_STR       "Debug OSPFv3 Neighbor\n"      ){  unsigned char level = 0;  if (argc)    {      if (! strncmp (argv[0], "s", 1))        level = OSPF6_DEBUG_NEIGHBOR_STATE;      if (! strncmp (argv[0], "e", 1))        level = OSPF6_DEBUG_NEIGHBOR_EVENT;    }  else    level = OSPF6_DEBUG_NEIGHBOR_STATE | OSPF6_DEBUG_NEIGHBOR_EVENT;  OSPF6_DEBUG_NEIGHBOR_OFF (level);  return CMD_SUCCESS;}ALIAS (no_debug_ospf6_neighbor,       no_debug_ospf6_neighbor_detail_cmd,       "no debug ospf6 neighbor (state|event)",       NO_STR       DEBUG_STR       OSPF6_STR       "Debug OSPFv3 Neighbor\n"       "Debug OSPFv3 Neighbor State Change\n"       "Debug OSPFv3 Neighbor Event\n"      );intconfig_write_ospf6_debug_neighbor (struct vty *vty){  if (IS_OSPF6_DEBUG_NEIGHBOR (STATE) &&      IS_OSPF6_DEBUG_NEIGHBOR (EVENT))    vty_out (vty, "debug ospf6 neighbor%s", VNL);  else if (IS_OSPF6_DEBUG_NEIGHBOR (STATE))    vty_out (vty, "debug ospf6 neighbor state%s", VNL);  else if (IS_OSPF6_DEBUG_NEIGHBOR (EVENT))    vty_out (vty, "debug ospf6 neighbor event%s", VNL);  return 0;}voidinstall_element_ospf6_debug_neighbor (){  install_element (ENABLE_NODE, &debug_ospf6_neighbor_cmd);  install_element (ENABLE_NODE, &debug_ospf6_neighbor_detail_cmd);  install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_cmd);  install_element (ENABLE_NODE, &no_debug_ospf6_neighbor_detail_cmd);  install_element (CONFIG_NODE, &debug_ospf6_neighbor_cmd);  install_element (CONFIG_NODE, &debug_ospf6_neighbor_detail_cmd);  install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_cmd);  install_element (CONFIG_NODE, &no_debug_ospf6_neighbor_detail_cmd);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -