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

📄 ospf6d.c

📁 大名鼎鼎的路由器源码。程序分ZEBRA、OSPFRIP等3个包。程序框架采用一个路由协议一个进程的方式
💻 C
📖 第 1 页 / 共 2 页
字号:
       ){  if (IS_OSPF6_DUMP_CONFIG)    zlog_info ("CONFIG: interface %s area %s prefix-list %s",               argv[0], argv[1], argv[2]);  return ospf6_interface_bind_area (vty, argv[0], argv[1], argv[2], 0);}DEFUN (ospf6_interface_area_plist_passive,       ospf6_interface_area_plist_passive_cmd,       "interface IFNAME area A.B.C.D prefix-list WORD passive",       "Enable routing on an IPv6 interface\n"       IFNAME_STR       "Set the OSPF6 area ID\n"       "OSPF6 area ID in IPv4 address notation\n"       OSPF6_PREFIX_LIST_STR       "IPv6 prefix-list name\n"       "IPv6 prefix-list name\n"       OSPF6_PASSIVE_STR       ){  if (IS_OSPF6_DUMP_CONFIG)    zlog_info ("CONFIG: interface %s area %s prefix-list %s passive",               argv[0], argv[1], argv[2]);  return ospf6_interface_bind_area (vty, argv[0], argv[1], argv[2], 1);}DEFUN (ospf6_interface_area,       ospf6_interface_area_cmd,       "interface IFNAME area A.B.C.D",       "Enable routing on an IPv6 interface\n"       IFNAME_STR       "Set the OSPF6 area ID\n"       "OSPF6 area ID in IPv4 address notation\n"       ){  struct interface *ifp;  struct ospf6_interface *o6i;  int passive;  char *plist_name;  if (IS_OSPF6_DUMP_CONFIG)    zlog_info ("CONFIG: interface %s area %s",               argv[0], argv[1]);  ifp = if_get_by_name (argv[0]);  o6i = (struct ospf6_interface *) ifp->info;  if (o6i)    {      passive = CHECK_FLAG (o6i->flag, OSPF6_INTERFACE_FLAG_PASSIVE);      plist_name = o6i->plist_name;    }  else    {      passive = 0;      plist_name = NULL;    }  return ospf6_interface_bind_area (vty, argv[0], argv[1],                                    plist_name, passive);}DEFUN (ospf6_interface_area_passive,       ospf6_interface_area_passive_cmd,       "interface IFNAME area A.B.C.D passive",       "Enable routing on an IPv6 interface\n"       IFNAME_STR       "Set the OSPF6 area ID\n"       "OSPF6 area ID in IPv4 address notation\n"       OSPF6_PASSIVE_STR       ){  if (IS_OSPF6_DUMP_CONFIG)    zlog_info ("CONFIG: interface %s area %s passive",               argv[0], argv[1]);  return ospf6_interface_bind_area (vty, argv[0], argv[1], NULL, 1);}DEFUN (no_ospf6_interface_area,       no_ospf6_interface_area_cmd,       "no interface IFNAME area A.B.C.D",       NO_STR       "Disable routing on an IPv6 interface\n"       IFNAME_STR){  struct interface *ifp;  struct ospf6_interface *o6i;  struct ospf6 *o6;  u_int32_t area_id;  o6 = (struct ospf6 *) vty->index;  ifp = if_lookup_by_name (argv[0]);  if (!ifp)    return CMD_ERR_NO_MATCH;  o6i = (struct ospf6_interface *) ifp->info;  if (!o6i)    return CMD_SUCCESS;  /* parse Area-ID */  if (inet_pton (AF_INET, argv[1], &area_id) != 1)    {      vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VTY_NEWLINE);      return CMD_ERR_AMBIGUOUS;    }  if (o6i->area->area_id != area_id)    {      vty_out (vty, "Wrong Area-ID: %s aready attached to area %s%s",               o6i->interface->name, o6i->area->str, VTY_NEWLINE);      return CMD_ERR_NOTHING_TODO;    }  if (o6i->area)    thread_execute (master, interface_down, o6i, 0);  listnode_delete (o6i->area->if_list, o6i);  o6i->area = (struct ospf6_area *) NULL;  return CMD_SUCCESS;}DEFUN (ospf6_area_range,       ospf6_area_range_cmd,       "area A.B.C.D range X:X::X:X/M",       "OSPFv3 area parameters\n"       "OSPFv3 area ID in IPv4 address format\n"       "Summarize routes matching address/mask (border routers only)\n"       "IPv6 address range\n"){  struct ospf6 *o6;  struct ospf6_area *o6a;  u_int32_t area_id;  int ret;  o6 = (struct ospf6 *) vty->index;  inet_pton (AF_INET, argv[0], &area_id);  o6a = ospf6_area_lookup (area_id, o6);  if (! o6a)    {      vty_out (vty, "No such area%s", VTY_NEWLINE);      return CMD_ERR_NO_MATCH;    }  ret = str2prefix_ipv6 (argv[1], &o6a->area_range);  if (ret <= 0)    {      vty_out (vty, "Malformed IPv6 address%s", VTY_NEWLINE);      return CMD_WARNING;    }  return CMD_SUCCESS;}DEFUN (ospf6_passive_interface,       ospf6_passive_interface_cmd,       "passive-interface IFNAME",       OSPF6_PASSIVE_STR       IFNAME_STR){  struct interface *ifp;  struct ospf6_interface *o6i;  ifp = if_get_by_name (argv[0]);  if (ifp->info)    o6i = (struct ospf6_interface *) ifp->info;  else    o6i = ospf6_interface_create (ifp);  SET_FLAG (o6i->flag, OSPF6_INTERFACE_FLAG_PASSIVE);  if (o6i->thread_send_hello)    {      thread_cancel (o6i->thread_send_hello);      o6i->thread_send_hello = (struct thread *) NULL;    }  return CMD_SUCCESS;}DEFUN (no_ospf6_passive_interface,       no_ospf6_passive_interface_cmd,       "no passive-interface IFNAME",       NO_STR       OSPF6_PASSIVE_STR       IFNAME_STR){  struct interface *ifp;  struct ospf6_interface *o6i;  ifp = if_lookup_by_name (argv[0]);  if (! ifp)    return CMD_ERR_NO_MATCH;  o6i = (struct ospf6_interface *) ifp->info;  UNSET_FLAG (o6i->flag, OSPF6_INTERFACE_FLAG_PASSIVE);  if (o6i->thread_send_hello == NULL)    thread_add_event (master, ospf6_send_hello, o6i, 0);  return CMD_SUCCESS;}#ifdef HAVE_SETPROCTITLEextern int _argc;extern char **_argv;DEFUN (set_proctitle,       set_proctitle_cmd,       "set proctitle (version|normal|none)",       "Set command\n"       "Process title\n"       "Version information\n"       "Normal command-line options\n"       "Just program name\n"){  int i;  char buf[64], tmp[64];  if (strncmp (argv[0], "v", 1) == 0)    {      proctitle_mode = 1;      setproctitle ("%s Zebra: %s", OSPF6_DAEMON_VERSION, ZEBRA_VERSION);    }  else if (strncmp (argv[0], "nor", 3) == 0)    {      proctitle_mode = 0;      memset (tmp, 0, sizeof (tmp));      memset (buf, 0, sizeof (buf));      for (i = 0; i < _argc; i++)        {          snprintf (buf, sizeof (buf), "%s%s ", tmp, _argv[i]);          memcpy (&tmp, &buf, sizeof (tmp));        }      setproctitle (buf);    }  else if (strncmp (argv[0], "non", 3) == 0)    {      proctitle_mode = -1;      setproctitle (NULL);    }  else    return CMD_ERR_NO_MATCH;  return CMD_SUCCESS;}#endif /* HAVE_SETPROCTITLE *//* OSPF configuration write function. */intospf6_config_write (struct vty *vty){  listnode j, k;  char buf[64];  struct ospf6_area *area;  struct ospf6_interface *o6i;  if (proctitle_mode == 1)    vty_out (vty, "set proctitle version%s", VTY_NEWLINE);  else if (proctitle_mode == -1)    vty_out (vty, "set proctitle none%s", VTY_NEWLINE);  vty_out (vty, "!%s", VTY_NEWLINE);  if (! ospf6)    return 0;  /* OSPFv6 configuration. */  if (!ospf6)    return CMD_SUCCESS;  inet_ntop (AF_INET, &ospf6->router_id, buf, sizeof (buf));  vty_out (vty, "router ospf6%s", VTY_NEWLINE);  vty_out (vty, " router-id %s%s", buf, VTY_NEWLINE);  ospf6_redistribute_config_write (vty);  ospf6_damp_config_write (vty);  for (j = listhead (ospf6->area_list); j; nextnode (j))    {      area = (struct ospf6_area *)getdata (j);      for (k = listhead (area->if_list); k; nextnode (k))        {          o6i = (struct ospf6_interface *) getdata (k);          vty_out (vty, " interface %s area %s%s",                   o6i->interface->name, area->str, VTY_NEWLINE);        }    }  vty_out (vty, "!%s", VTY_NEWLINE);  return 0;}/* OSPF6 node structure. */struct cmd_node ospf6_node =  {    OSPF6_NODE,    "%s(config-ospf6)# ",    1  };/* Install ospf related commands. */voidospf6_init (){  /* Install ospf6 top node. */  install_node (&ospf6_node, ospf6_config_write);  install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);  install_element (VIEW_NODE, &show_version_ospf6_cmd);  install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);  install_element (ENABLE_NODE, &show_version_ospf6_cmd);  install_element (ENABLE_NODE, &reload_cmd);  install_element (CONFIG_NODE, &router_ospf6_cmd);  install_element (CONFIG_NODE, &interface_cmd);#ifdef OSPF6_STATISTICS  install_element (VIEW_NODE, &show_ipv6_ospf6_statistics_cmd);  install_element (ENABLE_NODE, &show_ipv6_ospf6_statistics_cmd);#endif /* OSPF6_STATISTICS */#ifdef OSPF6_GARBAGE_COLLECT  install_element (ENABLE_NODE, &garbage_collection_cmd);#endif /* OSPF6_GARBAGE_COLLECT */#ifdef HAVE_SETPROCTITLE  install_element (CONFIG_NODE, &set_proctitle_cmd);#endif /* HAVE_SETPROCTITLE */  install_default (OSPF6_NODE);  install_element (OSPF6_NODE, &ospf6_router_id_cmd);  install_element (OSPF6_NODE, &ospf6_interface_area_cmd);  install_element (OSPF6_NODE, &ospf6_interface_area_passive_cmd);  install_element (OSPF6_NODE, &ospf6_interface_area_plist_cmd);  install_element (OSPF6_NODE, &ospf6_interface_area_plist_passive_cmd);  install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);  install_element (OSPF6_NODE, &ospf6_passive_interface_cmd);  install_element (OSPF6_NODE, &no_ospf6_passive_interface_cmd);  install_element (OSPF6_NODE, &ospf6_area_range_cmd);  /* Make empty list of top list. */  if_init ();  /* Install access list */  access_list_init ();  /* Install prefix list */  prefix_list_init ();  ospf6_dump_init ();#ifdef HAVE_OSPF6_DAMP  ospf6_damp_init ();#endif /*HAVE_OSPF6_DAMP*/  ospf6_hook_init ();  ospf6_lsa_init ();  ospf6_top_init ();  ospf6_area_init ();  ospf6_interface_init ();  ospf6_neighbor_init ();  ospf6_zebra_init ();  ospf6_routemap_init ();  ospf6_lsdb_init ();  ospf6_spf_init ();  ospf6_intra_init ();  ospf6_abr_init ();  ospf6_asbr_init ();}voidospf6_terminate (){  /* stop ospf6 */  ospf6_stop ();  /* log */  zlog (NULL, LOG_INFO, "OSPF6d terminated");}voidospf6_maxage_remover (){#if 0  if (IS_OSPF6_DUMP_LSDB)    zlog_info ("MaxAge Remover");#endif  ospf6_top_schedule_maxage_remover (NULL, 0, ospf6);  (*ospf6->foreach_area) (ospf6, NULL, 0,                          ospf6_area_schedule_maxage_remover);  (*ospf6->foreach_if) (ospf6, NULL, 0,                        ospf6_interface_schedule_maxage_remover);}void *ospf6_lsa_get_scope (u_int16_t type, struct ospf6_interface *o6i){  if (OSPF6_LSA_IS_SCOPE_LINKLOCAL (ntohs (type)))    return o6i;  else if (OSPF6_LSA_IS_SCOPE_AREA (ntohs (type)))    return o6i->area;  else if (OSPF6_LSA_IS_SCOPE_AS (ntohs (type)))    return o6i->area->ospf6;  else    return NULL;}

⌨️ 快捷键说明

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