ospf6_spf.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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. /* Shortest Path First calculation for OSPFv3 */
  22. #include <zebra.h>
  23. #include "log.h"
  24. #include "memory.h"
  25. #include "command.h"
  26. #include "vty.h"
  27. #include "prefix.h"
  28. #include "pqueue.h"
  29. #include "linklist.h"
  30. #include "thread.h"
  31. #include "ospf6_lsa.h"
  32. #include "ospf6_lsdb.h"
  33. #include "ospf6_route.h"
  34. #include "ospf6_area.h"
  35. #include "ospf6_spf.h"
  36. #include "ospf6_intra.h"
  37. #include "ospf6_interface.h"
  38. #include "ospf6d.h"
  39. unsigned char conf_debug_ospf6_spf = 0;
  40. int
  41. ospf6_vertex_cmp (void *a, void *b)
  42. {
  43. struct ospf6_vertex *va = (struct ospf6_vertex *) a;
  44. struct ospf6_vertex *vb = (struct ospf6_vertex *) b;
  45. /* ascending order */
  46. return (va->cost - vb->cost);
  47. }
  48. int
  49. ospf6_vertex_id_cmp (void *a, void *b)
  50. {
  51. struct ospf6_vertex *va = (struct ospf6_vertex *) a;
  52. struct ospf6_vertex *vb = (struct ospf6_vertex *) b;
  53. int ret = 0;
  54. ret = ntohl (ospf6_linkstate_prefix_adv_router (&va->vertex_id)) -
  55. ntohl (ospf6_linkstate_prefix_adv_router (&vb->vertex_id));
  56. if (ret)
  57. return ret;
  58. ret = ntohl (ospf6_linkstate_prefix_id (&va->vertex_id)) -
  59. ntohl (ospf6_linkstate_prefix_id (&vb->vertex_id));
  60. return ret;
  61. }
  62. struct ospf6_vertex *
  63. ospf6_vertex_create (struct ospf6_lsa *lsa)
  64. {
  65. struct ospf6_vertex *v;
  66. int i;
  67. v = (struct ospf6_vertex *)
  68. XMALLOC (MTYPE_OSPF6_VERTEX, sizeof (struct ospf6_vertex));
  69. /* type */
  70. if (ntohs (lsa->header->type) == OSPF6_LSTYPE_ROUTER)
  71. v->type = OSPF6_VERTEX_TYPE_ROUTER;
  72. else if (ntohs (lsa->header->type) == OSPF6_LSTYPE_NETWORK)
  73. v->type = OSPF6_VERTEX_TYPE_NETWORK;
  74. else
  75. assert (0);
  76. /* vertex_id */
  77. ospf6_linkstate_prefix (lsa->header->adv_router, lsa->header->id,
  78. &v->vertex_id);
  79. /* name */
  80. ospf6_linkstate_prefix2str (&v->vertex_id, v->name, sizeof (v->name));
  81. /* Associated LSA */
  82. v->lsa = lsa;
  83. /* capability bits + options */
  84. v->capability = *(u_char *)(OSPF6_LSA_HEADER_END (lsa->header));
  85. v->options[0] = *(u_char *)(OSPF6_LSA_HEADER_END (lsa->header) + 1);
  86. v->options[1] = *(u_char *)(OSPF6_LSA_HEADER_END (lsa->header) + 2);
  87. v->options[2] = *(u_char *)(OSPF6_LSA_HEADER_END (lsa->header) + 3);
  88. for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++)
  89. ospf6_nexthop_clear (&v->nexthop[i]);
  90. v->parent = NULL;
  91. v->child_list = list_new ();
  92. v->child_list->cmp = ospf6_vertex_id_cmp;
  93. return v;
  94. }
  95. void
  96. ospf6_vertex_delete (struct ospf6_vertex *v)
  97. {
  98. list_delete (v->child_list);
  99. XFREE (MTYPE_OSPF6_VERTEX, v);
  100. }
  101. struct ospf6_lsa *
  102. ospf6_lsdesc_lsa (caddr_t lsdesc, struct ospf6_vertex *v)
  103. {
  104. struct ospf6_lsa *lsa;
  105. u_int16_t type = 0;
  106. u_int32_t id = 0, adv_router = 0;
  107. if (VERTEX_IS_TYPE (NETWORK, v))
  108. {
  109. type = htons (OSPF6_LSTYPE_ROUTER);
  110. id = htonl (0);
  111. adv_router = NETWORK_LSDESC_GET_NBR_ROUTERID (lsdesc);
  112. }
  113. else
  114. {
  115. if (ROUTER_LSDESC_IS_TYPE (POINTTOPOINT, lsdesc))
  116. {
  117. type = htons (OSPF6_LSTYPE_ROUTER);
  118. id = htonl (0);
  119. adv_router = ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc);
  120. }
  121. else if (ROUTER_LSDESC_IS_TYPE (TRANSIT_NETWORK, lsdesc))
  122. {
  123. type = htons (OSPF6_LSTYPE_NETWORK);
  124. id = htonl (ROUTER_LSDESC_GET_NBR_IFID (lsdesc));
  125. adv_router = ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc);
  126. }
  127. }
  128. lsa = ospf6_lsdb_lookup (type, id, adv_router, v->area->lsdb);
  129. if (IS_OSPF6_DEBUG_SPF (DETAIL))
  130. {
  131. char ibuf[16], abuf[16];
  132. inet_ntop (AF_INET, &id, ibuf, sizeof (ibuf));
  133. inet_ntop (AF_INET, &adv_router, abuf, sizeof (abuf));
  134. if (lsa)
  135. zlog_info (" Link to: %s", lsa->name);
  136. else
  137. zlog_info (" Link to: [%s Id:%s Adv:%s] No LSA",
  138. OSPF6_LSTYPE_NAME (type), ibuf, abuf);
  139. }
  140. return lsa;
  141. }
  142. char *
  143. ospf6_lsdesc_backlink (struct ospf6_lsa *lsa,
  144. caddr_t lsdesc, struct ospf6_vertex *v)
  145. {
  146. caddr_t backlink, found = NULL;
  147. int size;
  148. size = (OSPF6_LSA_IS_TYPE (ROUTER, lsa) ?
  149. sizeof (struct ospf6_router_lsdesc) :
  150. sizeof (struct ospf6_network_lsdesc));
  151. for (backlink = OSPF6_LSA_HEADER_END (lsa->header) + 4;
  152. backlink + size <= OSPF6_LSA_END (lsa->header); backlink += size)
  153. {
  154. assert (! (OSPF6_LSA_IS_TYPE (NETWORK, lsa) &&
  155. VERTEX_IS_TYPE (NETWORK, v)));
  156. if (OSPF6_LSA_IS_TYPE (NETWORK, lsa) &&
  157. NETWORK_LSDESC_GET_NBR_ROUTERID (backlink)
  158. == v->lsa->header->adv_router)
  159. found = backlink;
  160. else if (VERTEX_IS_TYPE (NETWORK, v) &&
  161. ROUTER_LSDESC_IS_TYPE (TRANSIT_NETWORK, backlink) &&
  162. ROUTER_LSDESC_GET_NBR_ROUTERID (backlink)
  163. == v->lsa->header->adv_router &&
  164. ROUTER_LSDESC_GET_NBR_IFID (backlink)
  165. == ntohl (v->lsa->header->id))
  166. found = backlink;
  167. else
  168. {
  169. if (! ROUTER_LSDESC_IS_TYPE (POINTTOPOINT, backlink) ||
  170. ! ROUTER_LSDESC_IS_TYPE (POINTTOPOINT, lsdesc))
  171. continue;
  172. if (ROUTER_LSDESC_GET_NBR_IFID (backlink) !=
  173. ROUTER_LSDESC_GET_IFID (lsdesc) ||
  174. ROUTER_LSDESC_GET_NBR_IFID (lsdesc) !=
  175. ROUTER_LSDESC_GET_IFID (backlink))
  176. continue;
  177. if (ROUTER_LSDESC_GET_NBR_ROUTERID (backlink) !=
  178. v->lsa->header->adv_router ||
  179. ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc) !=
  180. lsa->header->adv_router)
  181. continue;
  182. found = backlink;
  183. }
  184. }
  185. if (IS_OSPF6_DEBUG_SPF (DETAIL))
  186. zlog_info (" Backlink %s", (found ? "OK" : "FAIL"));
  187. return found;
  188. }
  189. void
  190. ospf6_nexthop_calc (struct ospf6_vertex *w, struct ospf6_vertex *v,
  191. caddr_t lsdesc)
  192. {
  193. int i, ifindex;
  194. struct ospf6_interface *oi;
  195. u_int16_t type;
  196. u_int32_t adv_router;
  197. struct ospf6_lsa *lsa;
  198. struct ospf6_link_lsa *link_lsa;
  199. char buf[64];
  200. assert (VERTEX_IS_TYPE (ROUTER, w));
  201. ifindex = (VERTEX_IS_TYPE (NETWORK, v) ? v->nexthop[0].ifindex :
  202. ROUTER_LSDESC_GET_IFID (lsdesc));
  203. oi = ospf6_interface_lookup_by_ifindex (ifindex);
  204. if (oi == NULL)
  205. {
  206. if (IS_OSPF6_DEBUG_SPF (SUMMARY))
  207. zlog_warn ("Can't find interface in SPF: ifindex %d", ifindex);
  208. return;
  209. }
  210. type = htons (OSPF6_LSTYPE_LINK);
  211. adv_router = (VERTEX_IS_TYPE (NETWORK, v) ?
  212. NETWORK_LSDESC_GET_NBR_ROUTERID (lsdesc) :
  213. ROUTER_LSDESC_GET_NBR_ROUTERID (lsdesc));
  214. i = 0;
  215. for (lsa = ospf6_lsdb_type_router_head (type, adv_router, oi->lsdb); lsa;
  216. lsa = ospf6_lsdb_type_router_next (type, adv_router, lsa))
  217. {
  218. if (VERTEX_IS_TYPE (ROUTER, v) &&
  219. htonl (ROUTER_LSDESC_GET_NBR_IFID (lsdesc)) != lsa->header->id)
  220. continue;
  221. link_lsa = (struct ospf6_link_lsa *) OSPF6_LSA_HEADER_END (lsa->header);
  222. if (IS_OSPF6_DEBUG_SPF (DETAIL))
  223. {
  224. inet_ntop (AF_INET6, &link_lsa->linklocal_addr, buf, sizeof (buf));
  225. zlog_info (" nexthop %s from %s", buf, lsa->name);
  226. }
  227. if (i < OSPF6_MULTI_PATH_LIMIT)
  228. {
  229. memcpy (&w->nexthop[i].address, &link_lsa->linklocal_addr,
  230. sizeof (struct in6_addr));
  231. w->nexthop[i].ifindex = ifindex;
  232. i++;
  233. }
  234. }
  235. if (i == 0 && IS_OSPF6_DEBUG_SPF (SUMMARY))
  236. zlog_info ("No nexthop for %s found", w->name);
  237. }
  238. int
  239. ospf6_spf_install (struct ospf6_vertex *v,
  240. struct ospf6_route_table *result_table)
  241. {
  242. struct ospf6_route *route;
  243. int i, j;
  244. struct ospf6_vertex *prev, *w;
  245. listnode node;
  246. if (IS_OSPF6_DEBUG_SPF (SUMMARY))
  247. zlog_info ("SPF install %s hops %d cost %d",
  248. v->name, v->hops, v->cost);
  249. route = ospf6_route_lookup (&v->vertex_id, result_table);
  250. if (route && route->path.cost < v->cost)
  251. {
  252. if (IS_OSPF6_DEBUG_SPF (SUMMARY))
  253. zlog_info (" already installed with lower cost (%d), ignore",
  254. route->path.cost);
  255. ospf6_vertex_delete (v);
  256. return -1;
  257. }
  258. else if (route && route->path.cost == v->cost)
  259. {
  260. if (IS_OSPF6_DEBUG_SPF (SUMMARY))
  261. zlog_info (" another path found, merge");
  262. for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) &&
  263. i < OSPF6_MULTI_PATH_LIMIT; i++)
  264. {
  265. for (j = 0; j < OSPF6_MULTI_PATH_LIMIT; j++)
  266. {
  267. if (ospf6_nexthop_is_set (&route->nexthop[j]))
  268. {
  269. if (ospf6_nexthop_is_same (&route->nexthop[j],
  270. &v->nexthop[i]))
  271. break;
  272. else
  273. continue;
  274. }
  275. ospf6_nexthop_copy (&route->nexthop[j], &v->nexthop[i]);
  276. break;
  277. }
  278. }
  279. prev = (struct ospf6_vertex *) route->route_option;
  280. if (prev->hops > v->hops)
  281. {
  282. LIST_LOOP (prev->child_list, w, node)
  283. {
  284. assert (w->parent == prev);
  285. w->parent = v;
  286. listnode_add_sort (v->child_list, w);
  287. }
  288. listnode_delete (prev->parent->child_list, prev);
  289. listnode_add_sort (v->parent->child_list, v);
  290. ospf6_vertex_delete (prev);
  291. route->route_option = v;
  292. }
  293. else
  294. ospf6_vertex_delete (v);
  295. return -1;
  296. }
  297. /* There should be no case where candidate being installed (variable
  298. "v") is closer than the one in the SPF tree (variable "route").
  299. In the case something's gone wrong with the behavior of
  300. Priority-Queue. */
  301. assert (route == NULL);
  302. route = ospf6_route_create ();
  303. memcpy (&route->prefix, &v->vertex_id, sizeof (struct prefix));
  304. route->type = OSPF6_DEST_TYPE_LINKSTATE;
  305. route->path.type = OSPF6_PATH_TYPE_INTRA;
  306. route->path.origin.type = v->lsa->header->type;
  307. route->path.origin.id = v->lsa->header->id;
  308. route->path.origin.adv_router = v->lsa->header->adv_router;
  309. route->path.metric_type = 1;
  310. route->path.cost = v->cost;
  311. route->path.cost_e2 = v->hops;
  312. route->path.router_bits = v->capability;
  313. route->path.options[0] = v->options[0];
  314. route->path.options[1] = v->options[1];
  315. route->path.options[2] = v->options[2];
  316. for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) &&
  317. i < OSPF6_MULTI_PATH_LIMIT; i++)
  318. ospf6_nexthop_copy (&route->nexthop[i], &v->nexthop[i]);
  319. if (v->parent)
  320. listnode_add_sort (v->parent->child_list, v);
  321. route->route_option = v;
  322. ospf6_route_add (route, result_table);
  323. return 0;
  324. }
  325. void
  326. ospf6_spf_table_finish (struct ospf6_route_table *result_table)
  327. {
  328. struct ospf6_route *route;
  329. struct ospf6_vertex *v;
  330. for (route = ospf6_route_head (result_table); route;
  331. route = ospf6_route_next (route))
  332. {
  333. v = (struct ospf6_vertex *) route->route_option;
  334. ospf6_vertex_delete (v);
  335. ospf6_route_remove (route, result_table);
  336. }
  337. }
  338. void
  339. ospf6_spf_calculation (u_int32_t router_id,
  340. struct ospf6_route_table *result_table,
  341. struct ospf6_area *oa)
  342. {
  343. struct pqueue *candidate_list;
  344. struct ospf6_vertex *root, *v, *w;
  345. int i;
  346. int size;
  347. caddr_t lsdesc;
  348. struct ospf6_lsa *lsa;
  349. /* initialize */
  350. candidate_list = pqueue_create ();
  351. candidate_list->cmp = ospf6_vertex_cmp;
  352. ospf6_spf_table_finish (result_table);
  353. /* Install the calculating router itself as the root of the SPF tree */
  354. /* construct root vertex */
  355. lsa = ospf6_lsdb_lookup (htons (OSPF6_LSTYPE_ROUTER), htonl (0),
  356. router_id, oa->lsdb);
  357. if (lsa == NULL)
  358. return;
  359. root = ospf6_vertex_create (lsa);
  360. root->area = oa;
  361. root->cost = 0;
  362. root->hops = 0;
  363. root->nexthop[0].ifindex = 0; /* should have been loopbak I/F ... */
  364. inet_pton (AF_INET6, "::1", &root->nexthop[0].address);
  365. /* Actually insert root to the candidate-list as the only candidate */
  366. pqueue_enqueue (root, candidate_list);
  367. /* Iterate until candidate-list becomes empty */
  368. while (candidate_list->size)
  369. {
  370. /* get closest candidate from priority queue */
  371. v = pqueue_dequeue (candidate_list);
  372. /* install may result in merging and rejecting of the vertex */
  373. if (ospf6_spf_install (v, result_table) < 0)
  374. continue;
  375. /* For each LS description in the just-added vertex V's LSA */
  376. size = (VERTEX_IS_TYPE (ROUTER, v) ?
  377. sizeof (struct ospf6_router_lsdesc) :
  378. sizeof (struct ospf6_network_lsdesc));
  379. for (lsdesc = OSPF6_LSA_HEADER_END (v->lsa->header) + 4;
  380. lsdesc + size <= OSPF6_LSA_END (v->lsa->header); lsdesc += size)
  381. {
  382. lsa = ospf6_lsdesc_lsa (lsdesc, v);
  383. if (lsa == NULL)
  384. continue;
  385. if (! ospf6_lsdesc_backlink (lsa, lsdesc, v))
  386. continue;
  387. w = ospf6_vertex_create (lsa);
  388. w->area = oa;
  389. w->parent = v;
  390. if (VERTEX_IS_TYPE (ROUTER, v))
  391. {
  392. w->cost = v->cost + ROUTER_LSDESC_GET_METRIC (lsdesc);
  393. w->hops = v->hops + (VERTEX_IS_TYPE (NETWORK, w) ? 0 : 1);
  394. }
  395. else /* NETWORK */
  396. {
  397. w->cost = v->cost;
  398. w->hops = v->hops + 1;
  399. }
  400. /* nexthop calculation */
  401. if (w->hops == 0)
  402. w->nexthop[0].ifindex = ROUTER_LSDESC_GET_IFID (lsdesc);
  403. else if (w->hops == 1 && v->hops == 0)
  404. ospf6_nexthop_calc (w, v, lsdesc);
  405. else
  406. {
  407. for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) &&
  408. i < OSPF6_MULTI_PATH_LIMIT; i++)
  409. ospf6_nexthop_copy (&w->nexthop[i], &v->nexthop[i]);
  410. }
  411. /* add new candidate to the candidate_list */
  412. if (IS_OSPF6_DEBUG_SPF (SUMMARY))
  413. zlog_info (" New candidate: %s hops %d cost %d",
  414. w->name, w->hops, w->cost);
  415. pqueue_enqueue (w, candidate_list);
  416. }
  417. }
  418. pqueue_delete (candidate_list);
  419. }
  420. int
  421. ospf6_spf_calculation_thread (struct thread *t)
  422. {
  423. struct ospf6_area *oa;
  424. struct timeval start, end, runtime;
  425. oa = (struct ospf6_area *) THREAD_ARG (t);
  426. oa->thread_spf_calculation = NULL;
  427. if (IS_OSPF6_DEBUG_SPF (SUMMARY))
  428. zlog_info ("SPF calculation for area %s", oa->name);
  429. /* execute SPF calculation */
  430. gettimeofday (&start, (struct timezone *) NULL);
  431. ospf6_spf_calculation (oa->ospf6->router_id, oa->spf_table, oa);
  432. gettimeofday (&end, (struct timezone *) NULL);
  433. if (IS_OSPF6_DEBUG_SPF (SUMMARY))
  434. {
  435. timersub (&end, &start, &runtime);
  436. zlog_info ("SPF calculation for area %s: runtime %ld sec %ld usec",
  437. oa->name, runtime.tv_sec, runtime.tv_usec);
  438. }
  439. ospf6_intra_route_calculation (oa);
  440. ospf6_intra_asbr_calculation (oa);
  441. return 0;
  442. }
  443. void
  444. ospf6_spf_schedule (struct ospf6_area *oa)
  445. {
  446. if (oa->thread_spf_calculation)
  447. return;
  448. oa->thread_spf_calculation =
  449. thread_add_event (master, ospf6_spf_calculation_thread, oa, 0);
  450. }
  451. void
  452. ospf6_spf_display_subtree (struct vty *vty, char *prefix, int rest,
  453. struct ospf6_vertex *v)
  454. {
  455. listnode node;
  456. struct ospf6_vertex *c;
  457. char *next_prefix;
  458. int len;
  459. int restnum;
  460. /* "prefix" is the space prefix of the display line */
  461. vty_out (vty, "%s+-%s [%d]%s", prefix, v->name, v->cost, VNL);
  462. len = strlen (prefix) + 4;
  463. next_prefix = (char *) malloc (len);
  464. if (next_prefix == NULL)
  465. {
  466. vty_out (vty, "malloc failed%s", VNL);
  467. return;
  468. }
  469. snprintf (next_prefix, len, "%s%s", prefix, (rest ? "| " : " "));
  470. restnum = listcount (v->child_list);
  471. LIST_LOOP (v->child_list, c, node)
  472. {
  473. restnum--;
  474. ospf6_spf_display_subtree (vty, next_prefix, restnum, c);
  475. }
  476. free (next_prefix);
  477. }
  478. DEFUN (debug_ospf6_spf_detail,
  479. debug_ospf6_spf_detail_cmd,
  480. "debug ospf6 spf detail",
  481. DEBUG_STR
  482. OSPF6_STR
  483. "Debug SPF Calculation\n"
  484. "Debug Detailed SPF\n"
  485. )
  486. {
  487. unsigned char level = 0;
  488. level = OSPF6_DEBUG_SPF_SUMMARY | OSPF6_DEBUG_SPF_DETAIL;
  489. OSPF6_DEBUG_SPF_ON (level);
  490. return CMD_SUCCESS;
  491. }
  492. DEFUN (debug_ospf6_spf,
  493. debug_ospf6_spf_cmd,
  494. "debug ospf6 spf",
  495. DEBUG_STR
  496. OSPF6_STR
  497. "Debug SPF Calculation\n"
  498. )
  499. {
  500. unsigned char level = 0;
  501. level = OSPF6_DEBUG_SPF_SUMMARY;
  502. OSPF6_DEBUG_SPF_ON (level);
  503. return CMD_SUCCESS;
  504. }
  505. DEFUN (no_debug_ospf6_spf_detail,
  506. no_debug_ospf6_spf_detail_cmd,
  507. "no debug ospf6 spf detail",
  508. NO_STR
  509. DEBUG_STR
  510. OSPF6_STR
  511. "Quit Debugging SPF Calculation\n"
  512. "Quit Debugging Detailed SPF (change to debug summary)\n"
  513. )
  514. {
  515. unsigned char level = 0;
  516. level = OSPF6_DEBUG_SPF_DETAIL;
  517. OSPF6_DEBUG_SPF_OFF (level);
  518. return CMD_SUCCESS;
  519. }
  520. DEFUN (no_debug_ospf6_spf,
  521. no_debug_ospf6_spf_cmd,
  522. "no debug ospf6 spf",
  523. NO_STR
  524. DEBUG_STR
  525. OSPF6_STR
  526. "Quit Debugging SPF Calculation\n"
  527. )
  528. {
  529. unsigned char level = 0;
  530. level = OSPF6_DEBUG_SPF_SUMMARY | OSPF6_DEBUG_SPF_DETAIL;
  531. OSPF6_DEBUG_SPF_OFF (level);
  532. return CMD_SUCCESS;
  533. }
  534. int
  535. config_write_ospf6_debug_spf (struct vty *vty)
  536. {
  537. if (IS_OSPF6_DEBUG_SPF (DETAIL))
  538. vty_out (vty, "debug ospf6 spf detail%s", VNL);
  539. else if (IS_OSPF6_DEBUG_SPF (SUMMARY))
  540. vty_out (vty, "debug ospf6 spf%s", VNL);
  541. return 0;
  542. }
  543. void
  544. install_element_ospf6_debug_spf ()
  545. {
  546. install_element (ENABLE_NODE, &debug_ospf6_spf_cmd);
  547. install_element (ENABLE_NODE, &debug_ospf6_spf_detail_cmd);
  548. install_element (ENABLE_NODE, &no_debug_ospf6_spf_cmd);
  549. install_element (ENABLE_NODE, &no_debug_ospf6_spf_detail_cmd);
  550. install_element (CONFIG_NODE, &debug_ospf6_spf_cmd);
  551. install_element (CONFIG_NODE, &debug_ospf6_spf_detail_cmd);
  552. install_element (CONFIG_NODE, &no_debug_ospf6_spf_cmd);
  553. install_element (CONFIG_NODE, &no_debug_ospf6_spf_detail_cmd);
  554. }
  555. void
  556. ospf6_spf_init ()
  557. {
  558. }