ospf6_top.c 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463
  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_CMD_CHECK_RUNNING ();
  952. ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
  953. return CMD_SUCCESS;
  954. }
  955. ALIAS (show_ipv6_ospf6_route,
  956. show_ipv6_ospf6_route_detail_cmd,
  957. "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
  958. SHOW_STR
  959. IP6_STR
  960. OSPF6_STR
  961. ROUTE_STR
  962. "Specify IPv6 address\n"
  963. "Specify IPv6 prefix\n"
  964. "Detailed information\n"
  965. "Summary of route table\n"
  966. )
  967. DEFUN (show_ipv6_ospf6_route_match,
  968. show_ipv6_ospf6_route_match_cmd,
  969. "show ipv6 ospf6 route X:X::X:X/M match",
  970. SHOW_STR
  971. IP6_STR
  972. OSPF6_STR
  973. ROUTE_STR
  974. "Specify IPv6 prefix\n"
  975. "Display routes which match the specified route\n"
  976. )
  977. {
  978. const char *sargv[CMD_ARGC_MAX];
  979. int i, sargc;
  980. OSPF6_CMD_CHECK_RUNNING ();
  981. /* copy argv to sargv and then append "match" */
  982. for (i = 0; i < argc; i++)
  983. sargv[i] = argv[i];
  984. sargc = argc;
  985. sargv[sargc++] = "match";
  986. sargv[sargc] = NULL;
  987. ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
  988. return CMD_SUCCESS;
  989. }
  990. DEFUN (show_ipv6_ospf6_route_match_detail,
  991. show_ipv6_ospf6_route_match_detail_cmd,
  992. "show ipv6 ospf6 route X:X::X:X/M match detail",
  993. SHOW_STR
  994. IP6_STR
  995. OSPF6_STR
  996. ROUTE_STR
  997. "Specify IPv6 prefix\n"
  998. "Display routes which match the specified route\n"
  999. "Detailed information\n"
  1000. )
  1001. {
  1002. const char *sargv[CMD_ARGC_MAX];
  1003. int i, sargc;
  1004. /* copy argv to sargv and then append "match" and "detail" */
  1005. for (i = 0; i < argc; i++)
  1006. sargv[i] = argv[i];
  1007. sargc = argc;
  1008. sargv[sargc++] = "match";
  1009. sargv[sargc++] = "detail";
  1010. sargv[sargc] = NULL;
  1011. OSPF6_CMD_CHECK_RUNNING ();
  1012. ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
  1013. return CMD_SUCCESS;
  1014. }
  1015. ALIAS (show_ipv6_ospf6_route_match,
  1016. show_ipv6_ospf6_route_longer_cmd,
  1017. "show ipv6 ospf6 route X:X::X:X/M longer",
  1018. SHOW_STR
  1019. IP6_STR
  1020. OSPF6_STR
  1021. ROUTE_STR
  1022. "Specify IPv6 prefix\n"
  1023. "Display routes longer than the specified route\n"
  1024. )
  1025. DEFUN (show_ipv6_ospf6_route_match_detail,
  1026. show_ipv6_ospf6_route_longer_detail_cmd,
  1027. "show ipv6 ospf6 route X:X::X:X/M longer detail",
  1028. SHOW_STR
  1029. IP6_STR
  1030. OSPF6_STR
  1031. ROUTE_STR
  1032. "Specify IPv6 prefix\n"
  1033. "Display routes longer than the specified route\n"
  1034. "Detailed information\n"
  1035. );
  1036. ALIAS (show_ipv6_ospf6_route,
  1037. show_ipv6_ospf6_route_type_cmd,
  1038. "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
  1039. SHOW_STR
  1040. IP6_STR
  1041. OSPF6_STR
  1042. ROUTE_STR
  1043. "Display Intra-Area routes\n"
  1044. "Display Inter-Area routes\n"
  1045. "Display Type-1 External routes\n"
  1046. "Display Type-2 External routes\n"
  1047. )
  1048. DEFUN (show_ipv6_ospf6_route_type_detail,
  1049. show_ipv6_ospf6_route_type_detail_cmd,
  1050. "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
  1051. SHOW_STR
  1052. IP6_STR
  1053. OSPF6_STR
  1054. ROUTE_STR
  1055. "Display Intra-Area routes\n"
  1056. "Display Inter-Area routes\n"
  1057. "Display Type-1 External routes\n"
  1058. "Display Type-2 External routes\n"
  1059. "Detailed information\n"
  1060. )
  1061. {
  1062. const char *sargv[CMD_ARGC_MAX];
  1063. int i, sargc;
  1064. /* copy argv to sargv and then append "detail" */
  1065. for (i = 0; i < argc; i++)
  1066. sargv[i] = argv[i];
  1067. sargc = argc;
  1068. sargv[sargc++] = "detail";
  1069. sargv[sargc] = NULL;
  1070. OSPF6_CMD_CHECK_RUNNING ();
  1071. ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
  1072. return CMD_SUCCESS;
  1073. }
  1074. static void
  1075. ospf6_stub_router_config_write (struct vty *vty)
  1076. {
  1077. if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
  1078. {
  1079. vty_out (vty, " stub-router administrative%s", VNL);
  1080. }
  1081. return;
  1082. }
  1083. static int
  1084. ospf6_distance_config_write (struct vty *vty)
  1085. {
  1086. struct route_node *rn;
  1087. struct ospf6_distance *odistance;
  1088. if (ospf6->distance_all)
  1089. vty_out (vty, " distance %d%s", ospf6->distance_all, VTY_NEWLINE);
  1090. if (ospf6->distance_intra
  1091. || ospf6->distance_inter
  1092. || ospf6->distance_external)
  1093. {
  1094. vty_out (vty, " distance ospf6");
  1095. if (ospf6->distance_intra)
  1096. vty_out (vty, " intra-area %d", ospf6->distance_intra);
  1097. if (ospf6->distance_inter)
  1098. vty_out (vty, " inter-area %d", ospf6->distance_inter);
  1099. if (ospf6->distance_external)
  1100. vty_out (vty, " external %d", ospf6->distance_external);
  1101. vty_out (vty, "%s", VTY_NEWLINE);
  1102. }
  1103. for (rn = route_top (ospf6->distance_table); rn; rn = route_next (rn))
  1104. if ((odistance = rn->info) != NULL)
  1105. {
  1106. char pstr[128];
  1107. vty_out (vty, " distance %d %s %s%s", odistance->distance,
  1108. prefix2str (&rn->p, pstr, sizeof(pstr)),
  1109. odistance->access_list ? odistance->access_list : "",
  1110. VTY_NEWLINE);
  1111. }
  1112. return 0;
  1113. }
  1114. /* OSPF configuration write function. */
  1115. static int
  1116. config_write_ospf6 (struct vty *vty)
  1117. {
  1118. char router_id[16];
  1119. struct listnode *j, *k;
  1120. struct ospf6_area *oa;
  1121. struct ospf6_interface *oi;
  1122. /* OSPFv6 configuration. */
  1123. if (ospf6 == NULL)
  1124. return CMD_SUCCESS;
  1125. inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
  1126. vty_out (vty, "router ospf6%s", VNL);
  1127. if (ospf6->router_id_static != 0)
  1128. vty_out (vty, " router-id %s%s", router_id, VNL);
  1129. /* log-adjacency-changes flag print. */
  1130. if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
  1131. {
  1132. vty_out(vty, " log-adjacency-changes");
  1133. if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
  1134. vty_out(vty, " detail");
  1135. vty_out(vty, "%s", VTY_NEWLINE);
  1136. }
  1137. if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
  1138. vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth / 1000,
  1139. VNL);
  1140. ospf6_stub_router_config_write (vty);
  1141. ospf6_redistribute_config_write (vty);
  1142. ospf6_area_config_write (vty);
  1143. ospf6_spf_config_write (vty);
  1144. ospf6_distance_config_write (vty);
  1145. for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
  1146. {
  1147. for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
  1148. vty_out (vty, " interface %s area %s%s",
  1149. oi->interface->name, oa->name, VNL);
  1150. }
  1151. vty_out (vty, "!%s", VNL);
  1152. return 0;
  1153. }
  1154. /* OSPF6 node structure. */
  1155. static struct cmd_node ospf6_node =
  1156. {
  1157. OSPF6_NODE,
  1158. "%s(config-ospf6)# ",
  1159. 1 /* VTYSH */
  1160. };
  1161. /* Install ospf related commands. */
  1162. void
  1163. ospf6_top_init (void)
  1164. {
  1165. /* Install ospf6 top node. */
  1166. install_node (&ospf6_node, config_write_ospf6);
  1167. install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
  1168. install_element (CONFIG_NODE, &router_ospf6_cmd);
  1169. install_element (CONFIG_NODE, &no_router_ospf6_cmd);
  1170. install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
  1171. install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
  1172. install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
  1173. install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
  1174. install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
  1175. install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
  1176. install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
  1177. install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
  1178. install_default (OSPF6_NODE);
  1179. install_element (OSPF6_NODE, &ospf6_router_id_cmd);
  1180. install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_cmd);
  1181. install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd);
  1182. install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd);
  1183. install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd);
  1184. install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
  1185. install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
  1186. install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd);
  1187. install_element (OSPF6_NODE, &no_ospf6_stub_router_admin_cmd);
  1188. /* For a later time
  1189. install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd);
  1190. install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd);
  1191. install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd);
  1192. install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd);
  1193. */
  1194. install_element (OSPF6_NODE, &ospf6_distance_cmd);
  1195. install_element (OSPF6_NODE, &no_ospf6_distance_cmd);
  1196. install_element (OSPF6_NODE, &no_ospf6_distance_ospf6_cmd);
  1197. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_cmd);
  1198. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_cmd);
  1199. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_cmd);
  1200. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_external_cmd);
  1201. install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_inter_cmd);
  1202. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_cmd);
  1203. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_cmd);
  1204. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_cmd);
  1205. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_external_cmd);
  1206. install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_intra_cmd);
  1207. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_cmd);
  1208. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_cmd);
  1209. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_cmd);
  1210. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_inter_cmd);
  1211. install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_intra_cmd);
  1212. install_element (OSPF6_NODE, &ospf6_distance_source_cmd);
  1213. install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd);
  1214. install_element (OSPF6_NODE, &ospf6_distance_source_access_list_cmd);
  1215. install_element (OSPF6_NODE, &no_ospf6_distance_source_access_list_cmd);
  1216. }