ospf6_area.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  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 "linklist.h"
  25. #include "thread.h"
  26. #include "vty.h"
  27. #include "command.h"
  28. #include "if.h"
  29. #include "prefix.h"
  30. #include "table.h"
  31. #include "ospf6_proto.h"
  32. #include "ospf6_lsa.h"
  33. #include "ospf6_lsdb.h"
  34. #include "ospf6_route.h"
  35. #include "ospf6_spf.h"
  36. #include "ospf6_top.h"
  37. #include "ospf6_area.h"
  38. #include "ospf6_interface.h"
  39. #include "ospf6_intra.h"
  40. #include "ospf6_abr.h"
  41. #include "ospf6d.h"
  42. int
  43. ospf6_area_cmp (void *va, void *vb)
  44. {
  45. struct ospf6_area *oa = (struct ospf6_area *) va;
  46. struct ospf6_area *ob = (struct ospf6_area *) vb;
  47. return (ntohl (oa->area_id) - ntohl (ob->area_id));
  48. }
  49. int
  50. ospf6_area_is_stub (struct ospf6_area *o6a)
  51. {
  52. if (OSPF6_OPT_ISSET (o6a->options, OSPF6_OPT_E))
  53. return 0;
  54. return 1;
  55. }
  56. /* schedule routing table recalculation */
  57. void
  58. ospf6_area_lsdb_hook_add (struct ospf6_lsa *lsa)
  59. {
  60. struct ospf6_area *oa;
  61. oa = (struct ospf6_area *) lsa->scope;
  62. switch (ntohs (lsa->header->type))
  63. {
  64. case OSPF6_LSTYPE_ROUTER:
  65. case OSPF6_LSTYPE_NETWORK:
  66. ospf6_spf_schedule (oa);
  67. break;
  68. case OSPF6_LSTYPE_INTRA_PREFIX:
  69. ospf6_intra_prefix_lsa_add (lsa);
  70. break;
  71. case OSPF6_LSTYPE_INTER_PREFIX:
  72. case OSPF6_LSTYPE_INTER_ROUTER:
  73. break;
  74. default:
  75. if (IS_OSPF6_DEBUG_LSA (RECV))
  76. zlog_info ("Unknown LSA in Area %s's lsdb", oa->name);
  77. break;
  78. }
  79. }
  80. void
  81. ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa)
  82. {
  83. struct ospf6_area *oa;
  84. oa = (struct ospf6_area *) lsa->scope;
  85. switch (ntohs (lsa->header->type))
  86. {
  87. case OSPF6_LSTYPE_ROUTER:
  88. case OSPF6_LSTYPE_NETWORK:
  89. ospf6_spf_schedule (oa);
  90. break;
  91. case OSPF6_LSTYPE_INTRA_PREFIX:
  92. ospf6_intra_prefix_lsa_remove (lsa);
  93. break;
  94. case OSPF6_LSTYPE_INTER_PREFIX:
  95. case OSPF6_LSTYPE_INTER_ROUTER:
  96. break;
  97. default:
  98. if (IS_OSPF6_DEBUG_LSA (RECV))
  99. zlog_info ("Unknown LSA in Area %s's lsdb", oa->name);
  100. break;
  101. }
  102. }
  103. void
  104. ospf6_area_route_hook_add (struct ospf6_route *route)
  105. {
  106. struct ospf6_route *copy = ospf6_route_copy (route);
  107. ospf6_route_add (copy, ospf6->route_table);
  108. }
  109. void
  110. ospf6_area_route_hook_remove (struct ospf6_route *route)
  111. {
  112. struct ospf6_route *copy;
  113. copy = ospf6_route_lookup_identical (route, ospf6->route_table);
  114. if (copy)
  115. ospf6_route_remove (copy, ospf6->route_table);
  116. }
  117. /* Make new area structure */
  118. struct ospf6_area *
  119. ospf6_area_create (u_int32_t area_id, struct ospf6 *o)
  120. {
  121. struct ospf6_area *oa;
  122. struct ospf6_route *route;
  123. oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area));
  124. inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name));
  125. oa->area_id = area_id;
  126. oa->if_list = list_new ();
  127. oa->summary_table = ospf6_route_table_create ();
  128. oa->lsdb = ospf6_lsdb_create ();
  129. oa->lsdb->hook_add = ospf6_area_lsdb_hook_add;
  130. oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove;
  131. oa->spf_table = ospf6_route_table_create ();
  132. oa->route_table = ospf6_route_table_create ();
  133. oa->route_table->hook_add = ospf6_area_route_hook_add;
  134. oa->route_table->hook_remove = ospf6_area_route_hook_remove;
  135. /* set default options */
  136. OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
  137. OSPF6_OPT_SET (oa->options, OSPF6_OPT_E);
  138. OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
  139. oa->ospf6 = o;
  140. listnode_add_sort (o->area_list, oa);
  141. /* import athoer area's routes as inter-area routes */
  142. for (route = ospf6_route_head (o->route_table); route;
  143. route = ospf6_route_next (route))
  144. ospf6_abr_originate_prefix_to_area (route, oa);
  145. return oa;
  146. }
  147. void
  148. ospf6_area_delete (struct ospf6_area *oa)
  149. {
  150. listnode n;
  151. struct ospf6_interface *oi;
  152. ospf6_route_table_delete (oa->summary_table);
  153. /* ospf6 interface list */
  154. for (n = listhead (oa->if_list); n; nextnode (n))
  155. {
  156. oi = (struct ospf6_interface *) getdata (n);
  157. ospf6_interface_delete (oi);
  158. }
  159. list_delete (oa->if_list);
  160. ospf6_lsdb_delete (oa->lsdb);
  161. ospf6_route_table_delete (oa->spf_table);
  162. ospf6_route_table_delete (oa->route_table);
  163. #if 0
  164. ospf6_spftree_delete (oa->spf_tree);
  165. ospf6_route_table_delete (oa->topology_table);
  166. #endif /*0*/
  167. THREAD_OFF (oa->thread_spf_calculation);
  168. THREAD_OFF (oa->thread_route_calculation);
  169. listnode_delete (oa->ospf6->area_list, oa);
  170. oa->ospf6 = NULL;
  171. /* free area */
  172. XFREE (MTYPE_OSPF6_AREA, oa);
  173. }
  174. struct ospf6_area *
  175. ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
  176. {
  177. struct ospf6_area *oa;
  178. listnode n;
  179. for (n = listhead (ospf6->area_list); n; nextnode (n))
  180. {
  181. oa = (struct ospf6_area *) getdata (n);
  182. if (oa->area_id == area_id)
  183. return oa;
  184. }
  185. return (struct ospf6_area *) NULL;
  186. }
  187. void
  188. ospf6_area_enable (struct ospf6_area *oa)
  189. {
  190. listnode i;
  191. struct ospf6_interface *oi;
  192. UNSET_FLAG (oa->flag, OSPF6_AREA_DISABLE);
  193. for (i = listhead (oa->if_list); i; nextnode (i))
  194. {
  195. oi = (struct ospf6_interface *) getdata (i);
  196. ospf6_interface_enable (oi);
  197. }
  198. }
  199. void
  200. ospf6_area_disable (struct ospf6_area *oa)
  201. {
  202. listnode i;
  203. struct ospf6_interface *oi;
  204. SET_FLAG (oa->flag, OSPF6_AREA_DISABLE);
  205. for (i = listhead (oa->if_list); i; nextnode (i))
  206. {
  207. oi = (struct ospf6_interface *) getdata (i);
  208. ospf6_interface_disable (oi);
  209. }
  210. }
  211. void
  212. ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
  213. {
  214. listnode i;
  215. struct ospf6_interface *oi;
  216. vty_out (vty, " Area %s%s", oa->name, VNL);
  217. vty_out (vty, " Number of Area scoped LSAs is %u%s",
  218. oa->lsdb->count, VNL);
  219. vty_out (vty, " Interface attached to this area:");
  220. for (i = listhead (oa->if_list); i; nextnode (i))
  221. {
  222. oi = (struct ospf6_interface *) getdata (i);
  223. vty_out (vty, " %s", oi->interface->name);
  224. }
  225. vty_out (vty, "%s", VNL);
  226. }
  227. #define OSPF6_CMD_AREA_LOOKUP(str, oa) \
  228. { \
  229. u_int32_t area_id = 0; \
  230. if (inet_pton (AF_INET, str, &area_id) != 1) \
  231. { \
  232. vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
  233. return CMD_SUCCESS; \
  234. } \
  235. oa = ospf6_area_lookup (area_id, ospf6); \
  236. if (oa == NULL) \
  237. { \
  238. vty_out (vty, "No such Area: %s%s", str, VNL); \
  239. return CMD_SUCCESS; \
  240. } \
  241. }
  242. DEFUN (show_ipv6_ospf6_area_route_intra,
  243. show_ipv6_ospf6_area_route_intra_cmd,
  244. "show ipv6 ospf6 area A.B.C.D route intra-area",
  245. SHOW_STR
  246. IP6_STR
  247. OSPF6_STR
  248. OSPF6_AREA_STR
  249. OSPF6_AREA_ID_STR
  250. ROUTE_STR
  251. "Display Intra-Area routes\n"
  252. )
  253. {
  254. struct ospf6_area *oa;
  255. OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
  256. argc--;
  257. argv++;
  258. return ospf6_route_table_show (vty, argc, argv, oa->route_table);
  259. }
  260. ALIAS (show_ipv6_ospf6_area_route_intra,
  261. show_ipv6_ospf6_area_route_intra_detail_cmd,
  262. "show ipv6 ospf6 area A.B.C.D route intra-area (X::X|X::X/M|detail)",
  263. SHOW_STR
  264. IP6_STR
  265. OSPF6_STR
  266. OSPF6_AREA_STR
  267. OSPF6_AREA_ID_STR
  268. ROUTE_STR
  269. "Display Intra-Area routes\n"
  270. "Specify IPv6 address\n"
  271. "Specify IPv6 prefix\n"
  272. "Detailed information\n"
  273. );
  274. DEFUN (show_ipv6_ospf6_area_route_intra_match,
  275. show_ipv6_ospf6_area_route_intra_match_cmd,
  276. "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match",
  277. SHOW_STR
  278. IP6_STR
  279. OSPF6_STR
  280. ROUTE_STR
  281. "Display Intra-Area routes\n"
  282. OSPF6_AREA_STR
  283. OSPF6_AREA_ID_STR
  284. "Specify IPv6 prefix\n"
  285. "Display routes which match the specified route\n"
  286. )
  287. {
  288. char *sargv[CMD_ARGC_MAX];
  289. int i, sargc;
  290. struct ospf6_area *oa;
  291. OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
  292. argc--;
  293. argv++;
  294. /* copy argv to sargv and then append "match" */
  295. for (i = 0; i < argc; i++)
  296. sargv[i] = argv[i];
  297. sargc = argc;
  298. sargv[sargc++] = "match";
  299. sargv[sargc] = NULL;
  300. return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
  301. }
  302. DEFUN (show_ipv6_ospf6_area_route_intra_match_detail,
  303. show_ipv6_ospf6_area_route_intra_match_detail_cmd,
  304. "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match detail",
  305. SHOW_STR
  306. IP6_STR
  307. OSPF6_STR
  308. OSPF6_AREA_STR
  309. OSPF6_AREA_ID_STR
  310. ROUTE_STR
  311. "Display Intra-Area routes\n"
  312. "Specify IPv6 prefix\n"
  313. "Display routes which match the specified route\n"
  314. "Detailed information\n"
  315. )
  316. {
  317. char *sargv[CMD_ARGC_MAX];
  318. int i, sargc;
  319. struct ospf6_area *oa;
  320. OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
  321. argc--;
  322. argv++;
  323. /* copy argv to sargv and then append "match" and "detail" */
  324. for (i = 0; i < argc; i++)
  325. sargv[i] = argv[i];
  326. sargc = argc;
  327. sargv[sargc++] = "match";
  328. sargv[sargc++] = "detail";
  329. sargv[sargc] = NULL;
  330. return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
  331. }
  332. DEFUN (show_ipv6_ospf6_route_intra,
  333. show_ipv6_ospf6_route_intra_cmd,
  334. "show ipv6 ospf6 route intra-area",
  335. SHOW_STR
  336. IP6_STR
  337. OSPF6_STR
  338. ROUTE_STR
  339. "Display Intra-Area routes\n"
  340. )
  341. {
  342. listnode node;
  343. struct ospf6_area *oa;
  344. for (node = listhead (ospf6->area_list); node; nextnode (node))
  345. {
  346. oa = (struct ospf6_area *) getdata (node);
  347. vty_out (vty, "Area %s%s", oa->name, VNL);
  348. ospf6_route_table_show (vty, argc, argv, oa->route_table);
  349. }
  350. return CMD_SUCCESS;
  351. }
  352. ALIAS (show_ipv6_ospf6_route_intra,
  353. show_ipv6_ospf6_route_intra_detail_cmd,
  354. "show ipv6 ospf6 route intra-area (X::X|X::X/M|detail|summary)",
  355. SHOW_STR
  356. IP6_STR
  357. OSPF6_STR
  358. ROUTE_STR
  359. "Display Intra-Area routes\n"
  360. "Specify IPv6 address\n"
  361. "Specify IPv6 prefix\n"
  362. "Detailed information\n"
  363. "Summary of route table\n"
  364. );
  365. DEFUN (show_ipv6_ospf6_route_intra_match,
  366. show_ipv6_ospf6_route_intra_match_cmd,
  367. "show ipv6 ospf6 route intra-area X::X/M match",
  368. SHOW_STR
  369. IP6_STR
  370. OSPF6_STR
  371. ROUTE_STR
  372. "Display Intra-Area routes\n"
  373. "Specify IPv6 prefix\n"
  374. "Display routes which match the specified route\n"
  375. )
  376. {
  377. char *sargv[CMD_ARGC_MAX];
  378. int i, sargc;
  379. listnode node;
  380. struct ospf6_area *oa;
  381. /* copy argv to sargv and then append "match" */
  382. for (i = 0; i < argc; i++)
  383. sargv[i] = argv[i];
  384. sargc = argc;
  385. sargv[sargc++] = "match";
  386. sargv[sargc] = NULL;
  387. for (node = listhead (ospf6->area_list); node; nextnode (node))
  388. {
  389. oa = (struct ospf6_area *) getdata (node);
  390. ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
  391. }
  392. return CMD_SUCCESS;
  393. }
  394. DEFUN (show_ipv6_ospf6_route_intra_match_detail,
  395. show_ipv6_ospf6_route_intra_match_detail_cmd,
  396. "show ipv6 ospf6 route intra-area X::X/M match detail",
  397. SHOW_STR
  398. IP6_STR
  399. OSPF6_STR
  400. ROUTE_STR
  401. "Display Intra-Area routes\n"
  402. "Specify IPv6 prefix\n"
  403. "Display routes which match the specified route\n"
  404. "Detailed information\n"
  405. )
  406. {
  407. char *sargv[CMD_ARGC_MAX];
  408. int i, sargc;
  409. listnode node;
  410. struct ospf6_area *oa;
  411. /* copy argv to sargv and then append "match" and "detail" */
  412. for (i = 0; i < argc; i++)
  413. sargv[i] = argv[i];
  414. sargc = argc;
  415. sargv[sargc++] = "match";
  416. sargv[sargc++] = "detail";
  417. sargv[sargc] = NULL;
  418. for (node = listhead (ospf6->area_list); node; nextnode (node))
  419. {
  420. oa = (struct ospf6_area *) getdata (node);
  421. ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
  422. }
  423. return CMD_SUCCESS;
  424. }
  425. DEFUN (show_ipv6_ospf6_spf_tree,
  426. show_ipv6_ospf6_spf_tree_cmd,
  427. "show ipv6 ospf6 spf tree",
  428. SHOW_STR
  429. IP6_STR
  430. OSPF6_STR
  431. "Shortest Path First caculation\n"
  432. "Show SPF tree\n")
  433. {
  434. listnode node;
  435. struct ospf6_area *oa;
  436. struct ospf6_vertex *root;
  437. struct ospf6_route *route;
  438. struct prefix prefix;
  439. ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
  440. for (node = listhead (ospf6->area_list); node; nextnode (node))
  441. {
  442. oa = (struct ospf6_area *) getdata (node);
  443. route = ospf6_route_lookup (&prefix, oa->spf_table);
  444. if (route == NULL)
  445. {
  446. vty_out (vty, "LS entry for root not found in area %s%s",
  447. oa->name, VNL);
  448. continue;
  449. }
  450. root = (struct ospf6_vertex *) route->route_option;
  451. ospf6_spf_display_subtree (vty, "", 0, root);
  452. }
  453. return CMD_SUCCESS;
  454. }
  455. DEFUN (show_ipv6_ospf6_area_spf_tree,
  456. show_ipv6_ospf6_area_spf_tree_cmd,
  457. "show ipv6 ospf6 area A.B.C.D spf tree",
  458. SHOW_STR
  459. IP6_STR
  460. OSPF6_STR
  461. OSPF6_AREA_STR
  462. OSPF6_AREA_ID_STR
  463. "Shortest Path First caculation\n"
  464. "Show SPF tree\n")
  465. {
  466. u_int32_t area_id;
  467. struct ospf6_area *oa;
  468. struct ospf6_vertex *root;
  469. struct ospf6_route *route;
  470. struct prefix prefix;
  471. ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
  472. if (inet_pton (AF_INET, argv[0], &area_id) != 1)
  473. {
  474. vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
  475. return CMD_SUCCESS;
  476. }
  477. oa = ospf6_area_lookup (area_id, ospf6);
  478. if (oa == NULL)
  479. {
  480. vty_out (vty, "No such Area: %s%s", argv[0], VNL);
  481. return CMD_SUCCESS;
  482. }
  483. route = ospf6_route_lookup (&prefix, oa->spf_table);
  484. if (route == NULL)
  485. {
  486. vty_out (vty, "LS entry for root not found in area %s%s",
  487. oa->name, VNL);
  488. return CMD_SUCCESS;
  489. }
  490. root = (struct ospf6_vertex *) route->route_option;
  491. ospf6_spf_display_subtree (vty, "", 0, root);
  492. return CMD_SUCCESS;
  493. }
  494. DEFUN (show_ipv6_ospf6_area_spf_table,
  495. show_ipv6_ospf6_area_spf_table_cmd,
  496. "show ipv6 ospf6 area A.B.C.D spf table",
  497. SHOW_STR
  498. IP6_STR
  499. OSPF6_STR
  500. OSPF6_AREA_STR
  501. OSPF6_AREA_ID_STR
  502. "Shortest Path First caculation\n"
  503. "Show table contains SPF result\n"
  504. )
  505. {
  506. u_int32_t area_id;
  507. struct ospf6_area *oa;
  508. if (inet_pton (AF_INET, argv[0], &area_id) != 1)
  509. {
  510. vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
  511. return CMD_SUCCESS;
  512. }
  513. oa = ospf6_area_lookup (area_id, ospf6);
  514. if (oa == NULL)
  515. {
  516. vty_out (vty, "No such Area: %s%s", argv[0], VNL);
  517. return CMD_SUCCESS;
  518. }
  519. argc--;
  520. argv++;
  521. ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
  522. return CMD_SUCCESS;
  523. }
  524. ALIAS (show_ipv6_ospf6_area_spf_table,
  525. show_ipv6_ospf6_area_spf_table_1_cmd,
  526. "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|A.B.C.D/M|detail)",
  527. SHOW_STR
  528. IP6_STR
  529. OSPF6_STR
  530. OSPF6_AREA_STR
  531. OSPF6_AREA_ID_STR
  532. "Shortest Path First caculation\n"
  533. "Show table contains SPF result\n"
  534. "Specify Router-ID\n"
  535. "Display multiple entry by specifying match-prefix of Router-ID\n"
  536. "Display Detail\n"
  537. );
  538. ALIAS (show_ipv6_ospf6_area_spf_table,
  539. show_ipv6_ospf6_area_spf_table_2_cmd,
  540. "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) (A.B.C.D|A.B.C.D/M|detail)",
  541. SHOW_STR
  542. IP6_STR
  543. OSPF6_STR
  544. OSPF6_AREA_STR
  545. OSPF6_AREA_ID_STR
  546. "Shortest Path First caculation\n"
  547. "Show table contains SPF result\n"
  548. "Specify Router-ID\n"
  549. "Wildcard Router-ID\n"
  550. "Specify Link State ID\n"
  551. "Display multiple entry by specifying match-prefix of Link State ID\n"
  552. "Display Detail\n"
  553. );
  554. DEFUN (show_ipv6_ospf6_area_spf_table_3,
  555. show_ipv6_ospf6_area_spf_table_3_cmd,
  556. "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) A.B.C.D/M detail",
  557. SHOW_STR
  558. IP6_STR
  559. OSPF6_STR
  560. OSPF6_AREA_STR
  561. OSPF6_AREA_ID_STR
  562. "Shortest Path First caculation\n"
  563. "Show table contains SPF result\n"
  564. "Specify Router-ID\n"
  565. "Wildcard Router-ID\n"
  566. "Display multiple entry by specifying match-prefix of Link State ID\n"
  567. "Display Detail\n"
  568. )
  569. {
  570. u_int32_t area_id;
  571. struct ospf6_area *oa;
  572. char *sargv[CMD_ARGC_MAX];
  573. int i, sargc;
  574. if (inet_pton (AF_INET, argv[0], &area_id) != 1)
  575. {
  576. vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
  577. return CMD_SUCCESS;
  578. }
  579. oa = ospf6_area_lookup (area_id, ospf6);
  580. if (oa == NULL)
  581. {
  582. vty_out (vty, "No such Area: %s%s", argv[0], VNL);
  583. return CMD_SUCCESS;
  584. }
  585. argc--;
  586. argv++;
  587. /* copy argv to sargv and then append "detail" */
  588. for (i = 0; i < argc; i++)
  589. sargv[i] = argv[i];
  590. sargc = argc;
  591. sargv[sargc++] = "detail";
  592. sargv[sargc] = NULL;
  593. ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
  594. return CMD_SUCCESS;
  595. }
  596. DEFUN (show_ipv6_ospf6_spf_table,
  597. show_ipv6_ospf6_spf_table_cmd,
  598. "show ipv6 ospf6 spf table",
  599. SHOW_STR
  600. IP6_STR
  601. OSPF6_STR
  602. "Shortest Path First caculation\n"
  603. "Show table contains SPF result\n"
  604. )
  605. {
  606. listnode node;
  607. struct ospf6_area *oa;
  608. for (node = listhead (ospf6->area_list); node; nextnode (node))
  609. {
  610. oa = (struct ospf6_area *) getdata (node);
  611. ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
  612. }
  613. return CMD_SUCCESS;
  614. }
  615. ALIAS (show_ipv6_ospf6_spf_table,
  616. show_ipv6_ospf6_spf_table_1_cmd,
  617. "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|detail)",
  618. SHOW_STR
  619. IP6_STR
  620. OSPF6_STR
  621. "Shortest Path First caculation\n"
  622. "Show table contains SPF result\n"
  623. "Specify Router-ID\n"
  624. "Display multiple entry by specifying match-prefix of Router-ID\n"
  625. "Display Detail\n"
  626. );
  627. ALIAS (show_ipv6_ospf6_spf_table,
  628. show_ipv6_ospf6_spf_table_2_cmd,
  629. "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|*) (A.B.C.D|A.B.C.D/M|detail)",
  630. SHOW_STR
  631. IP6_STR
  632. OSPF6_STR
  633. "Shortest Path First caculation\n"
  634. "Show table contains SPF result\n"
  635. "Specify Router-ID\n"
  636. "Display multiple entry by specifying match-prefix of Router-ID\n"
  637. "Wildcard Router-ID\n"
  638. "Specify Link State ID\n"
  639. "Display multiple entry by specifying match-prefix of Link State ID\n"
  640. "Display Detail\n"
  641. );
  642. DEFUN (show_ipv6_ospf6_spf_table_3,
  643. show_ipv6_ospf6_spf_table_3_cmd,
  644. "show ipv6 ospf6 spf table (A.B.C.D|*) A.B.C.D/M detail",
  645. SHOW_STR
  646. IP6_STR
  647. OSPF6_STR
  648. "Shortest Path First caculation\n"
  649. "Show table contains SPF result\n"
  650. "Specify Router-ID\n"
  651. "Wildcard Router-ID\n"
  652. "Display multiple entry by specifying match-prefix of Link State ID\n"
  653. "Display Detail\n"
  654. )
  655. {
  656. listnode node;
  657. struct ospf6_area *oa;
  658. char *sargv[CMD_ARGC_MAX];
  659. int i, sargc;
  660. /* copy argv to sargv and then append "detail" */
  661. for (i = 0; i < argc; i++)
  662. sargv[i] = argv[i];
  663. sargc = argc;
  664. sargv[sargc++] = "detail";
  665. sargv[sargc] = NULL;
  666. for (node = listhead (ospf6->area_list); node; nextnode (node))
  667. {
  668. oa = (struct ospf6_area *) getdata (node);
  669. ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
  670. }
  671. return CMD_SUCCESS;
  672. }
  673. DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
  674. show_ipv6_ospf6_simulate_spf_tree_root_cmd,
  675. "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
  676. SHOW_STR
  677. IP6_STR
  678. OSPF6_STR
  679. "Shortest Path First caculation\n"
  680. "Show SPF tree\n"
  681. "Specify root's router-id to calculate another router's SPF tree\n")
  682. {
  683. u_int32_t area_id;
  684. struct ospf6_area *oa;
  685. struct ospf6_vertex *root;
  686. struct ospf6_route *route;
  687. struct prefix prefix;
  688. u_int32_t router_id;
  689. struct ospf6_route_table *spf_table;
  690. unsigned char tmp_debug_ospf6_spf = 0;
  691. inet_pton (AF_INET, argv[0], &router_id);
  692. ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
  693. if (inet_pton (AF_INET, argv[1], &area_id) != 1)
  694. {
  695. vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL);
  696. return CMD_SUCCESS;
  697. }
  698. oa = ospf6_area_lookup (area_id, ospf6);
  699. if (oa == NULL)
  700. {
  701. vty_out (vty, "No such Area: %s%s", argv[1], VNL);
  702. return CMD_SUCCESS;
  703. }
  704. tmp_debug_ospf6_spf = conf_debug_ospf6_spf;
  705. conf_debug_ospf6_spf = 0;
  706. spf_table = ospf6_route_table_create ();
  707. ospf6_spf_calculation (router_id, spf_table, oa);
  708. conf_debug_ospf6_spf = tmp_debug_ospf6_spf;
  709. route = ospf6_route_lookup (&prefix, spf_table);
  710. if (route == NULL)
  711. {
  712. ospf6_spf_table_finish (spf_table);
  713. ospf6_route_table_delete (spf_table);
  714. return CMD_SUCCESS;
  715. }
  716. root = (struct ospf6_vertex *) route->route_option;
  717. ospf6_spf_display_subtree (vty, "", 0, root);
  718. ospf6_spf_table_finish (spf_table);
  719. ospf6_route_table_delete (spf_table);
  720. return CMD_SUCCESS;
  721. }
  722. void
  723. ospf6_area_init ()
  724. {
  725. install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd);
  726. install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_cmd);
  727. install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
  728. install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
  729. install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
  730. install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
  731. install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
  732. install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
  733. install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
  734. install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
  735. install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_cmd);
  736. install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
  737. install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
  738. install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
  739. install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
  740. install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
  741. install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
  742. install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
  743. install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
  744. install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd);
  745. install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_cmd);
  746. install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
  747. install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
  748. install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
  749. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
  750. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
  751. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
  752. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
  753. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
  754. install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_cmd);
  755. install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
  756. install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
  757. install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
  758. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
  759. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
  760. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
  761. install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
  762. install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
  763. }