ospf6_top.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455
  1. /*
  2. * Copyright (C) 2003 Yasuhiro Ohara
  3. *
  4. * This file is part of GNU Zebra.
  5. *
  6. * GNU Zebra is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * GNU Zebra is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GNU Zebra; see the file COPYING. If not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #include <zebra.h>
  22. #include "log.h"
  23. #include "memory.h"
  24. #include "vty.h"
  25. #include "linklist.h"
  26. #include "prefix.h"
  27. #include "table.h"
  28. #include "thread.h"
  29. #include "command.h"
  30. #include "ospf6_proto.h"
  31. #include "ospf6_message.h"
  32. #include "ospf6_lsa.h"
  33. #include "ospf6_lsdb.h"
  34. #include "ospf6_route.h"
  35. #include "ospf6_zebra.h"
  36. #include "ospf6_top.h"
  37. #include "ospf6_area.h"
  38. #include "ospf6_interface.h"
  39. #include "ospf6_neighbor.h"
  40. #include "ospf6_flood.h"
  41. #include "ospf6_asbr.h"
  42. #include "ospf6_abr.h"
  43. #include "ospf6_intra.h"
  44. #include "ospf6_spf.h"
  45. #include "ospf6d.h"
  46. /* global ospf6d variable */
  47. struct ospf6 *ospf6;
  48. static void ospf6_disable (struct ospf6 *o);
  49. static void
  50. ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
  51. {
  52. switch (ntohs (lsa->header->type))
  53. {
  54. case OSPF6_LSTYPE_AS_EXTERNAL:
  55. ospf6_asbr_lsa_add (lsa);
  56. break;
  57. default:
  58. break;
  59. }
  60. }
  61. static void
  62. ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
  63. {
  64. switch (ntohs (lsa->header->type))
  65. {
  66. case OSPF6_LSTYPE_AS_EXTERNAL:
  67. ospf6_asbr_lsa_remove (lsa);
  68. break;
  69. default:
  70. break;
  71. }
  72. }
  73. static void
  74. ospf6_top_route_hook_add (struct ospf6_route *route)
  75. {
  76. ospf6_abr_originate_summary (route);
  77. ospf6_zebra_route_update_add (route);
  78. }
  79. static void
  80. ospf6_top_route_hook_remove (struct ospf6_route *route)
  81. {
  82. ospf6_abr_originate_summary (route);
  83. ospf6_zebra_route_update_remove (route);
  84. }
  85. static void
  86. ospf6_top_brouter_hook_add (struct ospf6_route *route)
  87. {
  88. ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
  89. ospf6_asbr_lsentry_add (route);
  90. ospf6_abr_originate_summary (route);
  91. }
  92. static void
  93. ospf6_top_brouter_hook_remove (struct ospf6_route *route)
  94. {
  95. ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
  96. ospf6_asbr_lsentry_remove (route);
  97. ospf6_abr_originate_summary (route);
  98. }
  99. static struct ospf6 *
  100. ospf6_create (void)
  101. {
  102. struct ospf6 *o;
  103. o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
  104. /* initialize */
  105. quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
  106. o->area_list = list_new ();
  107. o->area_list->cmp = ospf6_area_cmp;
  108. o->lsdb = ospf6_lsdb_create (o);
  109. o->lsdb_self = ospf6_lsdb_create (o);
  110. o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
  111. o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
  112. o->spf_delay = OSPF_SPF_DELAY_DEFAULT;
  113. o->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
  114. o->spf_max_holdtime = OSPF_SPF_MAX_HOLDTIME_DEFAULT;
  115. o->spf_hold_multiplier = 1;
  116. o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
  117. o->route_table->scope = o;
  118. o->route_table->hook_add = ospf6_top_route_hook_add;
  119. o->route_table->hook_remove = ospf6_top_route_hook_remove;
  120. o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
  121. o->brouter_table->scope = o;
  122. o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
  123. o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
  124. o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
  125. o->external_table->scope = o;
  126. o->external_id_table = route_table_init ();
  127. o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
  128. o->distance_table = route_table_init ();
  129. return o;
  130. }
  131. void
  132. ospf6_delete (struct ospf6 *o)
  133. {
  134. struct listnode *node, *nnode;
  135. struct ospf6_area *oa;
  136. ospf6_disable (ospf6);
  137. for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
  138. ospf6_area_delete (oa);
  139. list_delete (o->area_list);
  140. ospf6_lsdb_delete (o->lsdb);
  141. ospf6_lsdb_delete (o->lsdb_self);
  142. ospf6_route_table_delete (o->route_table);
  143. ospf6_route_table_delete (o->brouter_table);
  144. ospf6_route_table_delete (o->external_table);
  145. route_table_finish (o->external_id_table);
  146. ospf6_distance_reset (o);
  147. route_table_finish (o->distance_table);
  148. XFREE (MTYPE_OSPF6_TOP, o);
  149. }
  150. static void
  151. __attribute__((unused))
  152. ospf6_enable (struct ospf6 *o)
  153. {
  154. struct listnode *node, *nnode;
  155. struct ospf6_area *oa;
  156. if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
  157. {
  158. UNSET_FLAG (o->flag, OSPF6_DISABLED);
  159. for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
  160. ospf6_area_enable (oa);
  161. }
  162. }
  163. static void
  164. ospf6_disable (struct ospf6 *o)
  165. {
  166. struct listnode *node, *nnode;
  167. struct ospf6_area *oa;
  168. if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
  169. {
  170. SET_FLAG (o->flag, OSPF6_DISABLED);
  171. for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
  172. ospf6_area_disable (oa);
  173. /* XXX: This also changes persistent settings */
  174. ospf6_asbr_redistribute_reset();
  175. ospf6_lsdb_remove_all (o->lsdb);
  176. ospf6_route_remove_all (o->route_table);
  177. ospf6_route_remove_all (o->brouter_table);
  178. THREAD_OFF(o->maxage_remover);
  179. THREAD_OFF(o->t_spf_calc);
  180. THREAD_OFF(o->t_ase_calc);
  181. }
  182. }
  183. static int
  184. ospf6_maxage_remover (struct thread *thread)
  185. {
  186. struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
  187. struct ospf6_area *oa;
  188. struct ospf6_interface *oi;
  189. struct ospf6_neighbor *on;
  190. struct listnode *i, *j, *k;
  191. int reschedule = 0;
  192. o->maxage_remover = (struct thread *) NULL;
  193. for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
  194. {
  195. for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
  196. {
  197. for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
  198. {
  199. if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
  200. on->state != OSPF6_NEIGHBOR_LOADING)
  201. continue;
  202. ospf6_maxage_remove (o);
  203. return 0;
  204. }
  205. }
  206. }
  207. for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
  208. {
  209. for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
  210. {
  211. if (ospf6_lsdb_maxage_remover (oi->lsdb))
  212. {
  213. reschedule = 1;
  214. }
  215. }
  216. if (ospf6_lsdb_maxage_remover (oa->lsdb))
  217. {
  218. reschedule = 1;
  219. }
  220. }
  221. if (ospf6_lsdb_maxage_remover (o->lsdb))
  222. {
  223. reschedule = 1;
  224. }
  225. if (reschedule)
  226. {
  227. ospf6_maxage_remove (o);
  228. }
  229. return 0;
  230. }
  231. void
  232. ospf6_maxage_remove (struct ospf6 *o)
  233. {
  234. if (o && ! o->maxage_remover)
  235. o->maxage_remover = thread_add_timer (master, ospf6_maxage_remover, o,
  236. OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT);
  237. }
  238. /* start ospf6 */
  239. DEFUN (router_ospf6,
  240. router_ospf6_cmd,
  241. "router ospf6",
  242. ROUTER_STR
  243. OSPF6_STR)
  244. {
  245. if (ospf6 == NULL)
  246. ospf6 = ospf6_create ();
  247. /* set current ospf point. */
  248. vty->node = OSPF6_NODE;
  249. vty->index = ospf6;
  250. return CMD_SUCCESS;
  251. }
  252. /* stop ospf6 */
  253. DEFUN (no_router_ospf6,
  254. no_router_ospf6_cmd,
  255. "no router ospf6",
  256. NO_STR
  257. OSPF6_ROUTER_STR)
  258. {
  259. if (ospf6 == NULL)
  260. vty_out (vty, "OSPFv3 is not configured%s", VNL);
  261. else
  262. {
  263. ospf6_delete (ospf6);
  264. ospf6 = NULL;
  265. }
  266. /* return to config node . */
  267. vty->node = CONFIG_NODE;
  268. vty->index = NULL;
  269. return CMD_SUCCESS;
  270. }
  271. /* change Router_ID commands. */
  272. DEFUN (ospf6_router_id,
  273. ospf6_router_id_cmd,
  274. "router-id A.B.C.D",
  275. "Configure OSPF Router-ID\n"
  276. V4NOTATION_STR)
  277. {
  278. int ret;
  279. u_int32_t router_id;
  280. struct ospf6 *o;
  281. o = (struct ospf6 *) vty->index;
  282. ret = inet_pton (AF_INET, argv[0], &router_id);
  283. if (ret == 0)
  284. {
  285. vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
  286. return CMD_SUCCESS;
  287. }
  288. o->router_id_static = router_id;
  289. if (o->router_id == 0)
  290. o->router_id = router_id;
  291. return CMD_SUCCESS;
  292. }
  293. DEFUN (ospf6_log_adjacency_changes,
  294. ospf6_log_adjacency_changes_cmd,
  295. "log-adjacency-changes",
  296. "Log changes in adjacency state\n")
  297. {
  298. struct ospf6 *ospf6 = vty->index;
  299. SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
  300. return CMD_SUCCESS;
  301. }
  302. DEFUN (ospf6_log_adjacency_changes_detail,
  303. ospf6_log_adjacency_changes_detail_cmd,
  304. "log-adjacency-changes detail",
  305. "Log changes in adjacency state\n"
  306. "Log all state changes\n")
  307. {
  308. struct ospf6 *ospf6 = vty->index;
  309. SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
  310. SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
  311. return CMD_SUCCESS;
  312. }
  313. DEFUN (no_ospf6_log_adjacency_changes,
  314. no_ospf6_log_adjacency_changes_cmd,
  315. "no log-adjacency-changes",
  316. NO_STR
  317. "Log changes in adjacency state\n")
  318. {
  319. struct ospf6 *ospf6 = vty->index;
  320. UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
  321. UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
  322. return CMD_SUCCESS;
  323. }
  324. DEFUN (no_ospf6_log_adjacency_changes_detail,
  325. no_ospf6_log_adjacency_changes_detail_cmd,
  326. "no log-adjacency-changes detail",
  327. NO_STR
  328. "Log changes in adjacency state\n"
  329. "Log all state changes\n")
  330. {
  331. struct ospf6 *ospf6 = vty->index;
  332. UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
  333. return CMD_SUCCESS;
  334. }
  335. DEFUN (ospf6_distance,
  336. ospf6_distance_cmd,
  337. "distance <1-255>",
  338. NO_STR
  339. "Define an administrative distance\n"
  340. "OSPF6 Administrative distance\n")
  341. {
  342. struct ospf6 *o;
  343. o = (struct ospf6 *) vty->index;
  344. o->distance_all = atoi (argv[0]);
  345. return CMD_SUCCESS;
  346. }
  347. DEFUN (no_ospf6_distance,
  348. no_ospf6_distance_cmd,
  349. "no distance <1-255>",
  350. NO_STR
  351. "Define an administrative distance\n"
  352. "OSPF6 Administrative distance\n")
  353. {
  354. struct ospf6 *o;
  355. o = (struct ospf6 *) vty->index;
  356. o->distance_all = 0;
  357. return CMD_SUCCESS;
  358. }
  359. DEFUN (no_ospf6_distance_ospf6,
  360. no_ospf6_distance_ospf6_cmd,
  361. "no distance ospf6",
  362. NO_STR
  363. "Define an administrative distance\n"
  364. "OSPF6 Administrative distance\n"
  365. "OSPF6 Distance\n")
  366. {
  367. struct ospf6 *o;
  368. o = (struct ospf6 *) vty->index;
  369. o->distance_intra = 0;
  370. o->distance_inter = 0;
  371. o->distance_external = 0;
  372. return CMD_SUCCESS;
  373. }
  374. DEFUN (ospf6_distance_ospf6_intra,
  375. ospf6_distance_ospf6_intra_cmd,
  376. "distance ospf6 intra-area <1-255>",
  377. "Define an administrative distance\n"
  378. "OSPF6 Administrative distance\n"
  379. "Intra-area routes\n"
  380. "Distance for intra-area routes\n")
  381. {
  382. struct ospf6 *o;
  383. o = (struct ospf6 *) vty->index;
  384. o->distance_intra = atoi (argv[0]);
  385. return CMD_SUCCESS;
  386. }
  387. DEFUN (ospf6_distance_ospf6_intra_inter,
  388. ospf6_distance_ospf6_intra_inter_cmd,
  389. "distance ospf6 intra-area <1-255> inter-area <1-255>",
  390. "Define an administrative distance\n"
  391. "OSPF6 Administrative distance\n"
  392. "Intra-area routes\n"
  393. "Distance for intra-area routes\n"
  394. "Inter-area routes\n"
  395. "Distance for inter-area routes\n")
  396. {
  397. struct ospf6 *o;
  398. o = (struct ospf6 *) vty->index;
  399. o->distance_intra = atoi (argv[0]);
  400. o->distance_inter = atoi (argv[1]);
  401. return CMD_SUCCESS;
  402. }
  403. DEFUN (ospf6_distance_ospf6_intra_external,
  404. ospf6_distance_ospf6_intra_external_cmd,
  405. "distance ospf6 intra-area <1-255> external <1-255>",
  406. "Define an administrative distance\n"
  407. "OSPF6 Administrative distance\n"
  408. "Intra-area routes\n"
  409. "Distance for intra-area routes\n"
  410. "External routes\n"
  411. "Distance for external routes\n")
  412. {
  413. struct ospf6 *o;
  414. o = (struct ospf6 *) vty->index;
  415. o->distance_intra = atoi (argv[0]);
  416. o->distance_external = atoi (argv[1]);
  417. return CMD_SUCCESS;
  418. }
  419. DEFUN (ospf6_distance_ospf6_intra_inter_external,
  420. ospf6_distance_ospf6_intra_inter_external_cmd,
  421. "distance ospf6 intra-area <1-255> inter-area <1-255> external <1-255>",
  422. "Define an administrative distance\n"
  423. "OSPF6 Administrative distance\n"
  424. "Intra-area routes\n"
  425. "Distance for intra-area routes\n"
  426. "Inter-area routes\n"
  427. "Distance for inter-area routes\n"
  428. "External routes\n"
  429. "Distance for external routes\n")
  430. {
  431. struct ospf6 *o;
  432. o = (struct ospf6 *) vty->index;
  433. o->distance_intra = atoi (argv[0]);
  434. o->distance_inter = atoi (argv[1]);
  435. o->distance_external = atoi (argv[2]);
  436. return CMD_SUCCESS;
  437. }
  438. DEFUN (ospf6_distance_ospf6_intra_external_inter,
  439. ospf6_distance_ospf6_intra_external_inter_cmd,
  440. "distance ospf6 intra-area <1-255> external <1-255> inter-area <1-255>",
  441. "Define an administrative distance\n"
  442. "OSPF6 Administrative distance\n"
  443. "Intra-area routes\n"
  444. "Distance for intra-area routes\n"
  445. "External routes\n"
  446. "Distance for external routes\n"
  447. "Inter-area routes\n"
  448. "Distance for inter-area routes\n")
  449. {
  450. struct ospf6 *o;
  451. o = (struct ospf6 *) vty->index;
  452. o->distance_intra = atoi (argv[0]);
  453. o->distance_external = atoi (argv[1]);
  454. o->distance_inter = atoi (argv[2]);
  455. return CMD_SUCCESS;
  456. }
  457. DEFUN (ospf6_distance_ospf6_inter,
  458. ospf6_distance_ospf6_inter_cmd,
  459. "distance ospf6 inter-area <1-255>",
  460. "Define an administrative distance\n"
  461. "OSPF6 Administrative distance\n"
  462. "Inter-area routes\n"
  463. "Distance for inter-area routes\n")
  464. {
  465. struct ospf6 *o;
  466. o = (struct ospf6 *) vty->index;
  467. o->distance_inter = atoi (argv[0]);
  468. return CMD_SUCCESS;
  469. }
  470. DEFUN (ospf6_distance_ospf6_inter_intra,
  471. ospf6_distance_ospf6_inter_intra_cmd,
  472. "distance ospf6 inter-area <1-255> intra-area <1-255>",
  473. "Define an administrative distance\n"
  474. "OSPF6 Administrative distance\n"
  475. "Inter-area routes\n"
  476. "Distance for inter-area routes\n"
  477. "Intra-area routes\n"
  478. "Distance for intra-area routes\n")
  479. {
  480. struct ospf6 *o;
  481. o = (struct ospf6 *) vty->index;
  482. o->distance_inter = atoi (argv[0]);
  483. o->distance_intra = atoi (argv[1]);
  484. return CMD_SUCCESS;
  485. }
  486. DEFUN (ospf6_distance_ospf6_inter_external,
  487. ospf6_distance_ospf6_inter_external_cmd,
  488. "distance ospf6 inter-area <1-255> external <1-255>",
  489. "Define an administrative distance\n"
  490. "OSPF6 Administrative distance\n"
  491. "Inter-area routes\n"
  492. "Distance for inter-area routes\n"
  493. "External routes\n"
  494. "Distance for external routes\n")
  495. {
  496. struct ospf6 *o;
  497. o = (struct ospf6 *) vty->index;
  498. o->distance_inter = atoi (argv[0]);
  499. o->distance_external = atoi (argv[1]);
  500. return CMD_SUCCESS;
  501. }
  502. DEFUN (ospf6_distance_ospf6_inter_intra_external,
  503. ospf6_distance_ospf6_inter_intra_external_cmd,
  504. "distance ospf6 inter-area <1-255> intra-area <1-255> external <1-255>",
  505. "Define an administrative distance\n"
  506. "OSPF6 Administrative distance\n"
  507. "Inter-area routes\n"
  508. "Distance for inter-area routes\n"
  509. "Intra-area routes\n"
  510. "Distance for intra-area routes\n"
  511. "External routes\n"
  512. "Distance for external routes\n")
  513. {
  514. struct ospf6 *o;
  515. o = (struct ospf6 *) vty->index;
  516. o->distance_inter = atoi (argv[0]);
  517. o->distance_intra = atoi (argv[1]);
  518. o->distance_external = atoi (argv[2]);
  519. return CMD_SUCCESS;
  520. }
  521. DEFUN (ospf6_distance_ospf6_inter_external_intra,
  522. ospf6_distance_ospf6_inter_external_intra_cmd,
  523. "distance ospf6 inter-area <1-255> external <1-255> intra-area <1-255>",
  524. "Define an administrative distance\n"
  525. "OSPF6 Administrative distance\n"
  526. "Inter-area routes\n"
  527. "Distance for inter-area routes\n"
  528. "External routes\n"
  529. "Distance for external routes\n"
  530. "Intra-area routes\n"
  531. "Distance for intra-area routes\n")
  532. {
  533. struct ospf6 *o;
  534. o = (struct ospf6 *) vty->index;
  535. o->distance_inter = atoi (argv[0]);
  536. o->distance_external = atoi (argv[1]);
  537. o->distance_intra = atoi (argv[2]);
  538. return CMD_SUCCESS;
  539. }
  540. DEFUN (ospf6_distance_ospf6_external,
  541. ospf6_distance_ospf6_external_cmd,
  542. "distance ospf6 external <1-255>",
  543. "Define an administrative distance\n"
  544. "OSPF6 Administrative distance\n"
  545. "External routes\n"
  546. "Distance for external routes\n")
  547. {
  548. struct ospf6 *o;
  549. o = (struct ospf6 *) vty->index;
  550. o->distance_external = atoi (argv[0]);
  551. return CMD_SUCCESS;
  552. }
  553. DEFUN (ospf6_distance_ospf6_external_intra,
  554. ospf6_distance_ospf6_external_intra_cmd,
  555. "distance ospf6 external <1-255> intra-area <1-255>",
  556. "Define an administrative distance\n"
  557. "OSPF6 Administrative distance\n"
  558. "External routes\n"
  559. "Distance for external routes\n"
  560. "Intra-area routes\n"
  561. "Distance for intra-area routes\n")
  562. {
  563. struct ospf6 *o;
  564. o = (struct ospf6 *) vty->index;
  565. o->distance_external = atoi (argv[0]);
  566. o->distance_intra = atoi (argv[1]);
  567. return CMD_SUCCESS;
  568. }
  569. DEFUN (ospf6_distance_ospf6_external_inter,
  570. ospf6_distance_ospf6_external_inter_cmd,
  571. "distance ospf6 external <1-255> inter-area <1-255>",
  572. "Define an administrative distance\n"
  573. "OSPF6 Administrative distance\n"
  574. "External routes\n"
  575. "Distance for external routes\n"
  576. "Inter-area routes\n"
  577. "Distance for inter-area routes\n")
  578. {
  579. struct ospf6 *o;
  580. o = (struct ospf6 *) vty->index;
  581. o->distance_external = atoi (argv[0]);
  582. o->distance_inter = atoi (argv[1]);
  583. return CMD_SUCCESS;
  584. }
  585. DEFUN (ospf6_distance_ospf6_external_intra_inter,
  586. ospf6_distance_ospf6_external_intra_inter_cmd,
  587. "distance ospf6 external <1-255> intra-area <1-255> inter-area <1-255>",
  588. "Define an administrative distance\n"
  589. "OSPF6 Administrative distance\n"
  590. "External routes\n"
  591. "Distance for external routes\n"
  592. "Intra-area routes\n"
  593. "Distance for intra-area routes\n"
  594. "Inter-area routes\n"
  595. "Distance for inter-area routes\n")
  596. {
  597. struct ospf6 *o;
  598. o = (struct ospf6 *) vty->index;
  599. o->distance_external = atoi (argv[0]);
  600. o->distance_intra = atoi (argv[1]);
  601. o->distance_inter = atoi (argv[2]);
  602. return CMD_SUCCESS;
  603. }
  604. DEFUN (ospf6_distance_ospf6_external_inter_intra,
  605. ospf6_distance_ospf6_external_inter_intra_cmd,
  606. "distance ospf6 external <1-255> inter-area <1-255> intra-area <1-255>",
  607. "Define an administrative distance\n"
  608. "OSPF6 Administrative distance\n"
  609. "External routes\n"
  610. "Distance for external routes\n"
  611. "Inter-area routes\n"
  612. "Distance for inter-area routes\n"
  613. "Intra-area routes\n"
  614. "Distance for intra-area routes\n")
  615. {
  616. struct ospf6 *o;
  617. o = (struct ospf6 *) vty->index;
  618. o->distance_external = atoi (argv[0]);
  619. o->distance_inter = atoi (argv[1]);
  620. o->distance_intra = atoi (argv[2]);
  621. return CMD_SUCCESS;
  622. }
  623. DEFUN (ospf6_distance_source,
  624. ospf6_distance_source_cmd,
  625. "distance <1-255> X:X::X:X/M",
  626. "Administrative distance\n"
  627. "Distance value\n"
  628. "IP source prefix\n")
  629. {
  630. struct ospf6 *o;
  631. o = (struct ospf6 *) vty->index;
  632. ospf6_distance_set (vty, o, argv[0], argv[1], NULL);
  633. return CMD_SUCCESS;
  634. }
  635. DEFUN (no_ospf6_distance_source,
  636. no_ospf6_distance_source_cmd,
  637. "no distance <1-255> X:X::X:X/M",
  638. NO_STR
  639. "Administrative distance\n"
  640. "Distance value\n"
  641. "IP source prefix\n")
  642. {
  643. struct ospf6 *o;
  644. o = (struct ospf6 *) vty->index;
  645. /* XXX: distance arg seems to be irrelevant */
  646. ospf6_distance_unset (vty, o, argv[1], NULL);
  647. return CMD_SUCCESS;
  648. }
  649. DEFUN (ospf6_distance_source_access_list,
  650. ospf6_distance_source_access_list_cmd,
  651. "distance <1-255> X:X::X:X/M WORD",
  652. "Administrative distance\n"
  653. "Distance value\n"
  654. "IP source prefix\n"
  655. "Access list name\n")
  656. {
  657. struct ospf6 *o;
  658. o = (struct ospf6 *) vty->index;
  659. ospf6_distance_set (vty, o, argv[0], argv[1], argv[2]);
  660. return CMD_SUCCESS;
  661. }
  662. DEFUN (no_ospf6_distance_source_access_list,
  663. no_ospf6_distance_source_access_list_cmd,
  664. "no distance <1-255> X:X::X:X/M WORD",
  665. NO_STR
  666. "Administrative distance\n"
  667. "Distance value\n"
  668. "IP source prefix\n"
  669. "Access list name\n")
  670. {
  671. struct ospf6 *o;
  672. o = (struct ospf6 *) vty->index;
  673. ospf6_distance_unset (vty, o, argv[1], argv[2]);
  674. return CMD_SUCCESS;
  675. }
  676. DEFUN (ospf6_interface_area,
  677. ospf6_interface_area_cmd,
  678. "interface IFNAME area A.B.C.D",
  679. "Enable routing on an IPv6 interface\n"
  680. IFNAME_STR
  681. "Specify the OSPF6 area ID\n"
  682. "OSPF6 area ID in IPv4 address notation\n"
  683. )
  684. {
  685. struct ospf6 *o;
  686. struct ospf6_area *oa;
  687. struct ospf6_interface *oi;
  688. struct interface *ifp;
  689. u_int32_t area_id;
  690. o = (struct ospf6 *) vty->index;
  691. /* find/create ospf6 interface */
  692. ifp = if_get_by_name (argv[0]);
  693. oi = (struct ospf6_interface *) ifp->info;
  694. if (oi == NULL)
  695. oi = ospf6_interface_create (ifp);
  696. if (oi->area)
  697. {
  698. vty_out (vty, "%s already attached to Area %s%s",
  699. oi->interface->name, oi->area->name, VNL);
  700. return CMD_SUCCESS;
  701. }
  702. /* parse Area-ID */
  703. if (inet_pton (AF_INET, argv[1], &area_id) != 1)
  704. {
  705. vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
  706. return CMD_SUCCESS;
  707. }
  708. /* find/create ospf6 area */
  709. oa = ospf6_area_lookup (area_id, o);
  710. if (oa == NULL)
  711. oa = ospf6_area_create (area_id, o);
  712. /* attach interface to area */
  713. listnode_add (oa->if_list, oi); /* sort ?? */
  714. oi->area = oa;
  715. SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
  716. /* ospf6 process is currently disabled, not much more to do */
  717. if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
  718. return CMD_SUCCESS;
  719. /* start up */
  720. ospf6_interface_enable (oi);
  721. /* If the router is ABR, originate summary routes */
  722. if (ospf6_is_router_abr (o))
  723. ospf6_abr_enable_area (oa);
  724. return CMD_SUCCESS;
  725. }
  726. DEFUN (no_ospf6_interface_area,
  727. no_ospf6_interface_area_cmd,
  728. "no interface IFNAME area A.B.C.D",
  729. NO_STR
  730. "Disable routing on an IPv6 interface\n"
  731. IFNAME_STR
  732. "Specify the OSPF6 area ID\n"
  733. "OSPF6 area ID in IPv4 address notation\n"
  734. )
  735. {
  736. struct ospf6_interface *oi;
  737. struct ospf6_area *oa;
  738. struct interface *ifp;
  739. u_int32_t area_id;
  740. ifp = if_lookup_by_name (argv[0]);
  741. if (ifp == NULL)
  742. {
  743. vty_out (vty, "No such interface %s%s", argv[0], VNL);
  744. return CMD_SUCCESS;
  745. }
  746. oi = (struct ospf6_interface *) ifp->info;
  747. if (oi == NULL)
  748. {
  749. vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
  750. return CMD_SUCCESS;
  751. }
  752. /* parse Area-ID */
  753. if (inet_pton (AF_INET, argv[1], &area_id) != 1)
  754. {
  755. vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
  756. return CMD_SUCCESS;
  757. }
  758. /* Verify Area */
  759. if (oi->area == NULL)
  760. {
  761. vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL);
  762. return CMD_SUCCESS;
  763. }
  764. if (oi->area->area_id != area_id)
  765. {
  766. vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
  767. oi->interface->name, oi->area->name, VNL);
  768. return CMD_SUCCESS;
  769. }
  770. thread_execute (master, interface_down, oi, 0);
  771. oa = oi->area;
  772. listnode_delete (oi->area->if_list, oi);
  773. oi->area = (struct ospf6_area *) NULL;
  774. /* Withdraw inter-area routes from this area, if necessary */
  775. if (oa->if_list->count == 0)
  776. {
  777. UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
  778. ospf6_abr_disable_area (oa);
  779. }
  780. return CMD_SUCCESS;
  781. }
  782. DEFUN (ospf6_stub_router_admin,
  783. ospf6_stub_router_admin_cmd,
  784. "stub-router administrative",
  785. "Make router a stub router\n"
  786. "Advertise inability to be a transit router\n"
  787. "Administratively applied, for an indefinite period\n")
  788. {
  789. struct listnode *node;
  790. struct ospf6_area *oa;
  791. if (!CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
  792. {
  793. for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
  794. {
  795. OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_V6);
  796. OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_R);
  797. OSPF6_ROUTER_LSA_SCHEDULE (oa);
  798. }
  799. SET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER);
  800. }
  801. return CMD_SUCCESS;
  802. }
  803. DEFUN (no_ospf6_stub_router_admin,
  804. no_ospf6_stub_router_admin_cmd,
  805. "no stub-router administrative",
  806. NO_STR
  807. "Make router a stub router\n"
  808. "Advertise ability to be a transit router\n"
  809. "Administratively applied, for an indefinite period\n")
  810. {
  811. struct listnode *node;
  812. struct ospf6_area *oa;
  813. if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
  814. {
  815. for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
  816. {
  817. OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
  818. OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
  819. OSPF6_ROUTER_LSA_SCHEDULE (oa);
  820. }
  821. UNSET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER);
  822. }
  823. return CMD_SUCCESS;
  824. }
  825. DEFUN (ospf6_stub_router_startup,
  826. ospf6_stub_router_startup_cmd,
  827. "stub-router on-startup <5-86400>",
  828. "Make router a stub router\n"
  829. "Advertise inability to be a transit router\n"
  830. "Automatically advertise as stub-router on startup of OSPF6\n"
  831. "Time (seconds) to advertise self as stub-router\n")
  832. {
  833. return CMD_SUCCESS;
  834. }
  835. DEFUN (no_ospf6_stub_router_startup,
  836. no_ospf6_stub_router_startup_cmd,
  837. "no stub-router on-startup",
  838. NO_STR
  839. "Make router a stub router\n"
  840. "Advertise inability to be a transit router\n"
  841. "Automatically advertise as stub-router on startup of OSPF6\n"
  842. "Time (seconds) to advertise self as stub-router\n")
  843. {
  844. return CMD_SUCCESS;
  845. }
  846. DEFUN (ospf6_stub_router_shutdown,
  847. ospf6_stub_router_shutdown_cmd,
  848. "stub-router on-shutdown <5-86400>",
  849. "Make router a stub router\n"
  850. "Advertise inability to be a transit router\n"
  851. "Automatically advertise as stub-router before shutdown\n"
  852. "Time (seconds) to advertise self as stub-router\n")
  853. {
  854. return CMD_SUCCESS;
  855. }
  856. DEFUN (no_ospf6_stub_router_shutdown,
  857. no_ospf6_stub_router_shutdown_cmd,
  858. "no stub-router on-shutdown",
  859. NO_STR
  860. "Make router a stub router\n"
  861. "Advertise inability to be a transit router\n"
  862. "Automatically advertise as stub-router before shutdown\n"
  863. "Time (seconds) to advertise self as stub-router\n")
  864. {
  865. return CMD_SUCCESS;
  866. }
  867. static void
  868. ospf6_show (struct vty *vty, struct ospf6 *o)
  869. {
  870. struct listnode *n;
  871. struct ospf6_area *oa;
  872. char router_id[16], duration[32];
  873. struct timeval now, running, result;
  874. char buf[32], rbuf[32];
  875. /* process id, router id */
  876. inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
  877. vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
  878. router_id, VNL);
  879. /* running time */
  880. quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
  881. timersub (&now, &o->starttime, &running);
  882. timerstring (&running, duration, sizeof (duration));
  883. vty_out (vty, " Running %s%s", duration, VNL);
  884. /* Redistribute configuration */
  885. /* XXX */
  886. /* Show SPF parameters */
  887. vty_out(vty, " Initial SPF scheduling delay %d millisec(s)%s"
  888. " Minimum hold time between consecutive SPFs %d millsecond(s)%s"
  889. " Maximum hold time between consecutive SPFs %d millsecond(s)%s"
  890. " Hold time multiplier is currently %d%s",
  891. o->spf_delay, VNL,
  892. o->spf_holdtime, VNL,
  893. o->spf_max_holdtime, VNL,
  894. o->spf_hold_multiplier, VNL);
  895. vty_out(vty, " SPF algorithm ");
  896. if (o->ts_spf.tv_sec || o->ts_spf.tv_usec)
  897. {
  898. timersub(&now, &o->ts_spf, &result);
  899. timerstring(&result, buf, sizeof(buf));
  900. ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf));
  901. vty_out(vty, "last executed %s ago, reason %s%s", buf, rbuf, VNL);
  902. vty_out (vty, " Last SPF duration %lld sec %lld usec%s",
  903. (long long)o->ts_spf_duration.tv_sec,
  904. (long long)o->ts_spf_duration.tv_usec, VNL);
  905. }
  906. else
  907. vty_out(vty, "has not been run$%s", VNL);
  908. threadtimer_string(now, o->t_spf_calc, buf, sizeof(buf));
  909. vty_out (vty, " SPF timer %s%s%s",
  910. (o->t_spf_calc ? "due in " : "is "), buf, VNL);
  911. if (CHECK_FLAG (o->flag, OSPF6_STUB_ROUTER))
  912. vty_out (vty, " Router Is Stub Router%s", VNL);
  913. /* LSAs */
  914. vty_out (vty, " Number of AS scoped LSAs is %u%s",
  915. o->lsdb->count, VNL);
  916. /* Areas */
  917. vty_out (vty, " Number of areas in this router is %u%s",
  918. listcount (o->area_list), VNL);
  919. if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
  920. {
  921. if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
  922. vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
  923. else
  924. vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
  925. }
  926. vty_out (vty, "%s",VTY_NEWLINE);
  927. for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
  928. ospf6_area_show (vty, oa);
  929. }
  930. /* show top level structures */
  931. DEFUN (show_ipv6_ospf6,
  932. show_ipv6_ospf6_cmd,
  933. "show ipv6 ospf6",
  934. SHOW_STR
  935. IP6_STR
  936. OSPF6_STR)
  937. {
  938. OSPF6_CMD_CHECK_RUNNING ();
  939. ospf6_show (vty, ospf6);
  940. return CMD_SUCCESS;
  941. }
  942. DEFUN (show_ipv6_ospf6_route,
  943. show_ipv6_ospf6_route_cmd,
  944. "show ipv6 ospf6 route",
  945. SHOW_STR
  946. IP6_STR
  947. OSPF6_STR
  948. ROUTE_STR
  949. )
  950. {
  951. ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
  952. return CMD_SUCCESS;
  953. }
  954. ALIAS (show_ipv6_ospf6_route,
  955. show_ipv6_ospf6_route_detail_cmd,
  956. "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
  957. SHOW_STR
  958. IP6_STR
  959. OSPF6_STR
  960. ROUTE_STR
  961. "Specify IPv6 address\n"
  962. "Specify IPv6 prefix\n"
  963. "Detailed information\n"
  964. "Summary of route table\n"
  965. )
  966. DEFUN (show_ipv6_ospf6_route_match,
  967. show_ipv6_ospf6_route_match_cmd,
  968. "show ipv6 ospf6 route X:X::X:X/M match",
  969. SHOW_STR
  970. IP6_STR
  971. OSPF6_STR
  972. ROUTE_STR
  973. "Specify IPv6 prefix\n"
  974. "Display routes which match the specified route\n"
  975. )
  976. {
  977. const char *sargv[CMD_ARGC_MAX];
  978. int i, sargc;
  979. /* copy argv to sargv and then append "match" */
  980. for (i = 0; i < argc; i++)
  981. sargv[i] = argv[i];
  982. sargc = argc;
  983. sargv[sargc++] = "match";
  984. sargv[sargc] = NULL;
  985. ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
  986. return CMD_SUCCESS;
  987. }
  988. DEFUN (show_ipv6_ospf6_route_match_detail,
  989. show_ipv6_ospf6_route_match_detail_cmd,
  990. "show ipv6 ospf6 route X:X::X:X/M match detail",
  991. SHOW_STR
  992. IP6_STR
  993. OSPF6_STR
  994. ROUTE_STR
  995. "Specify IPv6 prefix\n"
  996. "Display routes which match the specified route\n"
  997. "Detailed information\n"
  998. )
  999. {
  1000. const char *sargv[CMD_ARGC_MAX];
  1001. int i, sargc;
  1002. /* copy argv to sargv and then append "match" and "detail" */
  1003. for (i = 0; i < argc; i++)
  1004. sargv[i] = argv[i];
  1005. sargc = argc;
  1006. sargv[sargc++] = "match";
  1007. sargv[sargc++] = "detail";
  1008. sargv[sargc] = NULL;
  1009. ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
  1010. return CMD_SUCCESS;
  1011. }
  1012. ALIAS (show_ipv6_ospf6_route_match,
  1013. show_ipv6_ospf6_route_longer_cmd,
  1014. "show ipv6 ospf6 route X:X::X:X/M longer",
  1015. SHOW_STR
  1016. IP6_STR
  1017. OSPF6_STR
  1018. ROUTE_STR
  1019. "Specify IPv6 prefix\n"
  1020. "Display routes longer than the specified route\n"
  1021. )
  1022. DEFUN (show_ipv6_ospf6_route_match_detail,
  1023. show_ipv6_ospf6_route_longer_detail_cmd,
  1024. "show ipv6 ospf6 route X:X::X:X/M longer detail",
  1025. SHOW_STR
  1026. IP6_STR
  1027. OSPF6_STR
  1028. ROUTE_STR
  1029. "Specify IPv6 prefix\n"
  1030. "Display routes longer than the specified route\n"
  1031. "Detailed information\n"
  1032. );
  1033. ALIAS (show_ipv6_ospf6_route,
  1034. show_ipv6_ospf6_route_type_cmd,
  1035. "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
  1036. SHOW_STR
  1037. IP6_STR
  1038. OSPF6_STR
  1039. ROUTE_STR
  1040. "Display Intra-Area routes\n"
  1041. "Display Inter-Area routes\n"
  1042. "Display Type-1 External routes\n"
  1043. "Display Type-2 External routes\n"
  1044. )
  1045. DEFUN (show_ipv6_ospf6_route_type_detail,
  1046. show_ipv6_ospf6_route_type_detail_cmd,
  1047. "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
  1048. SHOW_STR
  1049. IP6_STR
  1050. OSPF6_STR
  1051. ROUTE_STR
  1052. "Display Intra-Area routes\n"
  1053. "Display Inter-Area routes\n"
  1054. "Display Type-1 External routes\n"
  1055. "Display Type-2 External routes\n"
  1056. "Detailed information\n"
  1057. )
  1058. {
  1059. const char *sargv[CMD_ARGC_MAX];
  1060. int i, sargc;
  1061. /* copy argv to sargv and then append "detail" */
  1062. for (i = 0; i < argc; i++)
  1063. sargv[i] = argv[i];
  1064. sargc = argc;
  1065. sargv[sargc++] = "detail";
  1066. sargv[sargc] = NULL;
  1067. ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
  1068. return CMD_SUCCESS;
  1069. }
  1070. static void
  1071. ospf6_stub_router_config_write (struct vty *vty)
  1072. {
  1073. if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
  1074. {
  1075. vty_out (vty, " stub-router administrative%s", VNL);
  1076. }
  1077. return;
  1078. }
  1079. static int
  1080. ospf6_distance_config_write (struct vty *vty)
  1081. {
  1082. struct route_node *rn;
  1083. struct ospf6_distance *odistance;
  1084. if (ospf6->distance_all)
  1085. vty_out (vty, " distance %d%s", ospf6->distance_all, VTY_NEWLINE);
  1086. if (ospf6->distance_intra
  1087. || ospf6->distance_inter
  1088. || ospf6->distance_external)
  1089. {
  1090. vty_out (vty, " distance ospf6");
  1091. if (ospf6->distance_intra)
  1092. vty_out (vty, " intra-area %d", ospf6->distance_intra);
  1093. if (ospf6->distance_inter)
  1094. vty_out (vty, " inter-area %d", ospf6->distance_inter);
  1095. if (ospf6->distance_external)
  1096. vty_out (vty, " external %d", ospf6->distance_external);
  1097. vty_out (vty, "%s", VTY_NEWLINE);
  1098. }
  1099. for (rn = route_top (ospf6->distance_table); rn; rn = route_next (rn))
  1100. if ((odistance = rn->info) != NULL)
  1101. {
  1102. char pstr[128];
  1103. vty_out (vty, " distance %d %s %s%s", odistance->distance,
  1104. prefix2str (&rn->p, pstr, sizeof(pstr)),
  1105. odistance->access_list ? odistance->access_list : "",
  1106. VTY_NEWLINE);
  1107. }
  1108. return 0;
  1109. }
  1110. /* OSPF configuration write function. */
  1111. static int
  1112. config_write_ospf6 (struct vty *vty)
  1113. {
  1114. char router_id[16];
  1115. struct listnode *j, *k;
  1116. struct ospf6_area *oa;
  1117. struct ospf6_interface *oi;
  1118. /* OSPFv6 configuration. */
  1119. if (ospf6 == NULL)
  1120. return CMD_SUCCESS;
  1121. inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
  1122. vty_out (vty, "router ospf6%s", VNL);
  1123. if (ospf6->router_id_static != 0)
  1124. vty_out (vty, " router-id %s%s", router_id, VNL);
  1125. /* log-adjacency-changes flag print. */
  1126. if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
  1127. {
  1128. vty_out(vty, " log-adjacency-changes");
  1129. if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
  1130. vty_out(vty, " detail");
  1131. vty_out(vty, "%s", VTY_NEWLINE);
  1132. }
  1133. if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
  1134. vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth / 1000,
  1135. VNL);
  1136. ospf6_stub_router_config_write (vty);
  1137. ospf6_redistribute_config_write (vty);
  1138. ospf6_area_config_write (vty);
  1139. ospf6_spf_config_write (vty);
  1140. ospf6_distance_config_write (vty);
  1141. for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
  1142. {
  1143. for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
  1144. vty_out (vty, " interface %s area %s%s",
  1145. oi->interface->name, oa->name, VNL);
  1146. }
  1147. vty_out (vty, "!%s", VNL);
  1148. return 0;
  1149. }
  1150. /* OSPF6 node structure. */
  1151. static struct cmd_node ospf6_node =
  1152. {
  1153. OSPF6_NODE,
  1154. "%s(config-ospf6)# ",
  1155. 1 /* VTYSH */
  1156. };
  1157. /* Install ospf related commands. */
  1158. void
  1159. ospf6_top_init (void)
  1160. {
  1161. /* Install ospf6 top node. */
  1162. install_node (&ospf6_node, config_write_ospf6);
  1163. install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
  1164. install_element (CONFIG_NODE, &router_ospf6_cmd);
  1165. install_element (CONFIG_NODE, &no_router_ospf6_cmd);
  1166. install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
  1167. install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
  1168. install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
  1169. install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
  1170. install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
  1171. install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
  1172. install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
  1173. install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
  1174. install_default (OSPF6_NODE);
  1175. install_element (OSPF6_NODE, &ospf6_router_id_cmd);
  1176. install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_cmd);
  1177. install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd);
  1178. install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd);
  1179. install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd);
  1180. install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
  1181. install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
  1182. install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd);
  1183. install_element (OSPF6_NODE, &no_ospf6_stub_router_admin_cmd);
  1184. /* For a later time
  1185. install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd);
  1186. install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd);
  1187. install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd);
  1188. install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd);
  1189. */
  1190. install_element (OSPF6_NODE, &ospf6_distance_cmd);
  1191. install_element (OSPF6_NODE, &no_ospf6_distance_cmd);
  1192. install_element (OSPF6_NODE, &no_ospf6_distance_ospf6_cmd);
  1193. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_cmd);
  1194. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_cmd);
  1195. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_cmd);
  1196. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_external_cmd);
  1197. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_inter_cmd);
  1198. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_cmd);
  1199. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_cmd);
  1200. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_cmd);
  1201. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_external_cmd);
  1202. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_intra_cmd);
  1203. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_cmd);
  1204. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_cmd);
  1205. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_cmd);
  1206. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_inter_cmd);
  1207. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_intra_cmd);
  1208. install_element (OSPF6_NODE, &ospf6_distance_source_cmd);
  1209. install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd);
  1210. install_element (OSPF6_NODE, &ospf6_distance_source_access_list_cmd);
  1211. install_element (OSPF6_NODE, &no_ospf6_distance_source_access_list_cmd);
  1212. }