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

📄 ospf6_top.c

📁 linux 路由软件 可支持RIP OSPF BGP等
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (C) 2003 Yasuhiro Ohara * * This file is part of GNU Zebra. * * GNU Zebra is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * GNU Zebra is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Zebra; see the file COPYING.  If not, write to the  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,  * Boston, MA 02111-1307, USA.   */#include <zebra.h>#include "log.h"#include "memory.h"#include "vty.h"#include "linklist.h"#include "prefix.h"#include "table.h"#include "thread.h"#include "command.h"#include "ospf6_proto.h"#include "ospf6_message.h"#include "ospf6_lsa.h"#include "ospf6_lsdb.h"#include "ospf6_route.h"#include "ospf6_zebra.h"#include "ospf6_top.h"#include "ospf6_area.h"#include "ospf6_interface.h"#include "ospf6_neighbor.h"#include "ospf6_flood.h"#include "ospf6_asbr.h"#include "ospf6_abr.h"#include "ospf6_intra.h"#include "ospf6d.h"/* global ospf6d variable */struct ospf6 *ospf6;voidospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa){  switch (ntohs (lsa->header->type))    {      case OSPF6_LSTYPE_AS_EXTERNAL:        ospf6_asbr_lsa_add (lsa);        break;      default:        break;    }}voidospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa){  switch (ntohs (lsa->header->type))    {      case OSPF6_LSTYPE_AS_EXTERNAL:        ospf6_asbr_lsa_remove (lsa);        break;      default:        break;    }}voidospf6_top_route_hook_add (struct ospf6_route *route){  ospf6_abr_originate_summary (route);  ospf6_zebra_route_update_add (route);}voidospf6_top_route_hook_remove (struct ospf6_route *route){  ospf6_abr_originate_summary (route);  ospf6_zebra_route_update_remove (route);}voidospf6_top_brouter_hook_add (struct ospf6_route *route){  ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));  ospf6_asbr_lsentry_add (route);  ospf6_abr_originate_summary (route);}voidospf6_top_brouter_hook_remove (struct ospf6_route *route){  ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));  ospf6_asbr_lsentry_remove (route);  ospf6_abr_originate_summary (route);}struct ospf6 *ospf6_create (){  struct ospf6 *o;  o = XMALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));  memset (o, 0, sizeof (struct ospf6));  /* initialize */  gettimeofday (&o->starttime, (struct timezone *) NULL);  o->area_list = list_new ();  o->area_list->cmp = ospf6_area_cmp;  o->lsdb = ospf6_lsdb_create (o);  o->lsdb_self = ospf6_lsdb_create (o);  o->lsdb->hook_add = ospf6_top_lsdb_hook_add;  o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;  o->route_table = ospf6_route_table_create ();  o->route_table->hook_add = ospf6_top_route_hook_add;  o->route_table->hook_remove = ospf6_top_route_hook_remove;  o->brouter_table = ospf6_route_table_create ();  o->brouter_table->hook_add = ospf6_top_brouter_hook_add;  o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;  o->external_table = ospf6_route_table_create ();  o->external_id_table = route_table_init ();  return o;}voidospf6_delete (struct ospf6 *o){  listnode i;  struct ospf6_area *oa;  for (i = listhead (o->area_list); i; nextnode (i))    {      oa = (struct ospf6_area *) getdata (i);      ospf6_area_delete (oa);    }  ospf6_lsdb_delete (o->lsdb);  ospf6_lsdb_delete (o->lsdb_self);  ospf6_route_table_delete (o->route_table);  ospf6_route_table_delete (o->brouter_table);  ospf6_route_table_delete (o->external_table);  route_table_finish (o->external_id_table);  XFREE (MTYPE_OSPF6_TOP, o);}voidospf6_enable (struct ospf6 *o){  listnode i;  struct ospf6_area *oa;  if (CHECK_FLAG (o->flag, OSPF6_DISABLED))    {      UNSET_FLAG (o->flag, OSPF6_DISABLED);      for (i = listhead (o->area_list); i; nextnode (i))        {          oa = (struct ospf6_area *) getdata (i);          ospf6_area_enable (oa);        }    }}voidospf6_disable (struct ospf6 *o){  listnode i;  struct ospf6_area *oa;  if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))    {      SET_FLAG (o->flag, OSPF6_DISABLED);      for (i = listhead (o->area_list); i; nextnode (i))        {          oa = (struct ospf6_area *) getdata (i);          ospf6_area_disable (oa);        }      ospf6_lsdb_remove_all (o->lsdb);      ospf6_route_remove_all (o->route_table);      ospf6_route_remove_all (o->brouter_table);    }}intospf6_maxage_remover (struct thread *thread){  struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);  struct ospf6_area *oa;  struct ospf6_interface *oi;  struct ospf6_neighbor *on;  listnode i, j, k;  o->maxage_remover = (struct thread *) NULL;  for (i = listhead (o->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->state != OSPF6_NEIGHBOR_EXCHANGE &&                  on->state != OSPF6_NEIGHBOR_LOADING)                continue;              return 0;            }        }    }  for (i = listhead (o->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);          OSPF6_LSDB_MAXAGE_REMOVER (oi->lsdb);        }      OSPF6_LSDB_MAXAGE_REMOVER (oa->lsdb);    }  OSPF6_LSDB_MAXAGE_REMOVER (o->lsdb);  return 0;}voidospf6_maxage_remove (struct ospf6 *o){  if (o && ! o->maxage_remover)    o->maxage_remover = thread_add_event (master, ospf6_maxage_remover, o, 0);}/* start ospf6 */DEFUN (router_ospf6,       router_ospf6_cmd,       "router ospf6",       ROUTER_STR       OSPF6_STR){  if (ospf6 == NULL)    ospf6 = ospf6_create ();  if (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))    ospf6_enable (ospf6);  /* set current ospf point. */  vty->node = OSPF6_NODE;  vty->index = ospf6;  return CMD_SUCCESS;}/* stop ospf6 */DEFUN (no_router_ospf6,       no_router_ospf6_cmd,       "no router ospf6",       NO_STR       OSPF6_ROUTER_STR){  if (ospf6 == NULL || CHECK_FLAG (ospf6->flag, OSPF6_DISABLED))    vty_out (vty, "OSPFv3 is not running%s", VNL);  else    ospf6_disable (ospf6);  /* return to config node . */  vty->node = CONFIG_NODE;  vty->index = NULL;  return CMD_SUCCESS;}/* change Router_ID commands. */DEFUN (ospf6_router_id,       ospf6_router_id_cmd,       "router-id A.B.C.D",       "Configure OSPF Router-ID\n"       V4NOTATION_STR){  int ret;  u_int32_t router_id;  struct ospf6 *o;  o = (struct ospf6 *) vty->index;  ret = inet_pton (AF_INET, argv[0], &router_id);  if (ret == 0)    {      vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);      return CMD_SUCCESS;    }  o->router_id = router_id;  return CMD_SUCCESS;}DEFUN (ospf6_interface_area,       ospf6_interface_area_cmd,       "interface IFNAME area A.B.C.D",       "Enable routing on an IPv6 interface\n"       IFNAME_STR       "Specify the OSPF6 area ID\n"       "OSPF6 area ID in IPv4 address notation\n"      ){  struct ospf6 *o;  struct ospf6_area *oa;  struct ospf6_interface *oi;  struct interface *ifp;  u_int32_t area_id;  o = (struct ospf6 *) vty->index;  /* find/create ospf6 interface */  ifp = if_get_by_name (argv[0]);  oi = (struct ospf6_interface *) ifp->info;  if (oi == NULL)    oi = ospf6_interface_create (ifp);  if (oi->area)    {

⌨️ 快捷键说明

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