ospf6_zebra.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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 "vty.h"
  24. #include "command.h"
  25. #include "prefix.h"
  26. #include "stream.h"
  27. #include "zclient.h"
  28. #include "memory.h"
  29. #include "ospf6d.h"
  30. #include "ospf6_proto.h"
  31. #include "ospf6_top.h"
  32. #include "ospf6_interface.h"
  33. #include "ospf6_route.h"
  34. #include "ospf6_lsa.h"
  35. #include "ospf6_asbr.h"
  36. #include "ospf6_zebra.h"
  37. unsigned char conf_debug_ospf6_zebra = 0;
  38. /* information about zebra. */
  39. struct zclient *zclient = NULL;
  40. /* redistribute function */
  41. void
  42. ospf6_zebra_redistribute (int type)
  43. {
  44. if (zclient->redist[type])
  45. return;
  46. zclient->redist[type] = 1;
  47. if (zclient->sock > 0)
  48. zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient->sock, type);
  49. }
  50. void
  51. ospf6_zebra_no_redistribute (int type)
  52. {
  53. if (! zclient->redist[type])
  54. return;
  55. zclient->redist[type] = 0;
  56. if (zclient->sock > 0)
  57. zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient->sock, type);
  58. }
  59. /* Inteface addition message from zebra. */
  60. int
  61. ospf6_zebra_if_add (int command, struct zclient *zclient, zebra_size_t length)
  62. {
  63. struct interface *ifp;
  64. ifp = zebra_interface_add_read (zclient->ibuf);
  65. if (IS_OSPF6_DEBUG_ZEBRA (RECV))
  66. zlog_info ("Zebra Interface add: %s index %d mtu %d",
  67. ifp->name, ifp->ifindex, ifp->mtu6);
  68. ospf6_interface_if_add (ifp);
  69. return 0;
  70. }
  71. int
  72. ospf6_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length)
  73. {
  74. #if 0
  75. struct interface *ifp;
  76. ifp = zebra_interface_delete_read (zclient->ibuf);
  77. if (IS_OSPF6_DEBUG_ZEBRA (RECV))
  78. zlog_info ("Zebra Interface delete: %s index %d mtu %d",
  79. ifp->name, ifp->ifindex, ifp->mtu6);
  80. ospf6_interface_if_del (ifp);
  81. #endif /*0*/
  82. return 0;
  83. }
  84. int
  85. ospf6_zebra_if_state_update (int command, struct zclient *zclient,
  86. zebra_size_t length)
  87. {
  88. struct interface *ifp;
  89. ifp = zebra_interface_state_read (zclient->ibuf);
  90. if (IS_OSPF6_DEBUG_ZEBRA (RECV))
  91. zlog_info ("Zebra Interface state change: "
  92. "%s index %d flags %ld metric %d mtu %d",
  93. ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu6);
  94. ospf6_interface_state_update (ifp);
  95. return 0;
  96. }
  97. int
  98. ospf6_zebra_if_address_update_add (int command, struct zclient *zclient,
  99. zebra_size_t length)
  100. {
  101. struct connected *c;
  102. char buf[128];
  103. c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_ADD, zclient->ibuf);
  104. if (c == NULL)
  105. return 0;
  106. if (IS_OSPF6_DEBUG_ZEBRA (RECV))
  107. zlog_info ("Zebra Interface address add: %s %5s %s/%d",
  108. c->ifp->name, prefix_family_str (c->address),
  109. inet_ntop (c->address->family, &c->address->u.prefix,
  110. buf, sizeof (buf)), c->address->prefixlen);
  111. if (c->address->family == AF_INET6)
  112. ospf6_interface_connected_route_update (c->ifp);
  113. return 0;
  114. }
  115. int
  116. ospf6_zebra_if_address_update_delete (int command, struct zclient *zclient,
  117. zebra_size_t length)
  118. {
  119. struct connected *c;
  120. char buf[128];
  121. c = zebra_interface_address_read (ZEBRA_INTERFACE_ADDRESS_DELETE, zclient->ibuf);
  122. if (c == NULL)
  123. return 0;
  124. if (IS_OSPF6_DEBUG_ZEBRA (RECV))
  125. zlog_info ("Zebra Interface address delete: %s %5s %s/%d",
  126. c->ifp->name, prefix_family_str (c->address),
  127. inet_ntop (c->address->family, &c->address->u.prefix,
  128. buf, sizeof (buf)), c->address->prefixlen);
  129. if (c->address->family == AF_INET6)
  130. ospf6_interface_connected_route_update (c->ifp);
  131. return 0;
  132. }
  133. const char *zebra_route_name[ZEBRA_ROUTE_MAX] =
  134. { "System", "Kernel", "Connect", "Static", "RIP", "RIPng", "OSPF",
  135. "OSPF6", "BGP" };
  136. const char *zebra_route_abname[ZEBRA_ROUTE_MAX] =
  137. { "X", "K", "C", "S", "r", "R", "o", "O", "B" };
  138. int
  139. ospf6_zebra_read_ipv6 (int command, struct zclient *zclient,
  140. zebra_size_t length)
  141. {
  142. struct stream *s;
  143. struct zapi_ipv6 api;
  144. unsigned long ifindex;
  145. struct prefix_ipv6 p;
  146. struct in6_addr *nexthop;
  147. s = zclient->ibuf;
  148. ifindex = 0;
  149. nexthop = NULL;
  150. memset (&api, 0, sizeof (api));
  151. /* Type, flags, message. */
  152. api.type = stream_getc (s);
  153. api.flags = stream_getc (s);
  154. api.message = stream_getc (s);
  155. /* IPv6 prefix. */
  156. memset (&p, 0, sizeof (struct prefix_ipv6));
  157. p.family = AF_INET6;
  158. p.prefixlen = stream_getc (s);
  159. stream_get (&p.prefix, s, PSIZE (p.prefixlen));
  160. /* Nexthop, ifindex, distance, metric. */
  161. if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
  162. {
  163. api.nexthop_num = stream_getc (s);
  164. nexthop = (struct in6_addr *)
  165. malloc (api.nexthop_num * sizeof (struct in6_addr));
  166. stream_get (nexthop, s, api.nexthop_num * sizeof (struct in6_addr));
  167. }
  168. if (CHECK_FLAG (api.message, ZAPI_MESSAGE_IFINDEX))
  169. {
  170. api.ifindex_num = stream_getc (s);
  171. ifindex = stream_getl (s);
  172. }
  173. if (CHECK_FLAG (api.message, ZAPI_MESSAGE_DISTANCE))
  174. api.distance = stream_getc (s);
  175. else
  176. api.distance = 0;
  177. if (CHECK_FLAG (api.message, ZAPI_MESSAGE_METRIC))
  178. api.metric = stream_getl (s);
  179. else
  180. api.metric = 0;
  181. if (IS_OSPF6_DEBUG_ZEBRA (RECV))
  182. {
  183. char prefixstr[128], nexthopstr[128];
  184. prefix2str ((struct prefix *)&p, prefixstr, sizeof (prefixstr));
  185. if (nexthop)
  186. inet_ntop (AF_INET6, nexthop, nexthopstr, sizeof (nexthopstr));
  187. else
  188. snprintf (nexthopstr, sizeof (nexthopstr), "::");
  189. zlog_info ("Zebra Receive route %s: %s %s nexthop %s ifindex %ld",
  190. (command == ZEBRA_IPV6_ROUTE_ADD ? "add" : "delete"),
  191. zebra_route_name[api.type], prefixstr, nexthopstr, ifindex);
  192. }
  193. if (command == ZEBRA_IPV6_ROUTE_ADD)
  194. ospf6_asbr_redistribute_add (api.type, ifindex, (struct prefix *) &p,
  195. api.nexthop_num, nexthop);
  196. else
  197. ospf6_asbr_redistribute_remove (api.type, ifindex, (struct prefix *) &p);
  198. if (CHECK_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP))
  199. free (nexthop);
  200. return 0;
  201. }
  202. DEFUN (show_zebra,
  203. show_zebra_cmd,
  204. "show zebra",
  205. SHOW_STR
  206. "Zebra information\n")
  207. {
  208. int i;
  209. if (zclient == NULL)
  210. {
  211. vty_out (vty, "Not connected to zebra%s", VTY_NEWLINE);
  212. return CMD_SUCCESS;
  213. }
  214. vty_out (vty, "Zebra Infomation%s", VTY_NEWLINE);
  215. vty_out (vty, " enable: %d fail: %d%s",
  216. zclient->enable, zclient->fail, VTY_NEWLINE);
  217. vty_out (vty, " redistribute default: %d%s", zclient->redist_default,
  218. VTY_NEWLINE);
  219. vty_out (vty, " redistribute:");
  220. for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
  221. {
  222. if (zclient->redist[i])
  223. vty_out (vty, " %s", zebra_route_name[i]);
  224. }
  225. vty_out (vty, "%s", VTY_NEWLINE);
  226. return CMD_SUCCESS;
  227. }
  228. DEFUN (router_zebra,
  229. router_zebra_cmd,
  230. "router zebra",
  231. "Enable a routing process\n"
  232. "Make connection to zebra daemon\n")
  233. {
  234. vty->node = ZEBRA_NODE;
  235. zclient->enable = 1;
  236. zclient_start (zclient);
  237. return CMD_SUCCESS;
  238. }
  239. DEFUN (no_router_zebra,
  240. no_router_zebra_cmd,
  241. "no router zebra",
  242. NO_STR
  243. "Configure routing process\n"
  244. "Disable connection to zebra daemon\n")
  245. {
  246. zclient->enable = 0;
  247. zclient_stop (zclient);
  248. return CMD_SUCCESS;
  249. }
  250. /* Zebra configuration write function. */
  251. int
  252. config_write_ospf6_zebra (struct vty *vty)
  253. {
  254. if (! zclient->enable)
  255. {
  256. vty_out (vty, "no router zebra%s", VTY_NEWLINE);
  257. vty_out (vty, "!%s", VTY_NEWLINE);
  258. }
  259. else if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
  260. {
  261. vty_out (vty, "router zebra%s", VTY_NEWLINE);
  262. vty_out (vty, " no redistribute ospf6%s", VTY_NEWLINE);
  263. vty_out (vty, "!%s", VTY_NEWLINE);
  264. }
  265. return 0;
  266. }
  267. /* Zebra node structure. */
  268. struct cmd_node zebra_node =
  269. {
  270. ZEBRA_NODE,
  271. "%s(config-zebra)# ",
  272. };
  273. #define ADD 0
  274. #define REM 1
  275. static void
  276. ospf6_zebra_route_update (int type, struct ospf6_route *request)
  277. {
  278. struct zapi_ipv6 api;
  279. char buf[64], ifname[IFNAMSIZ];
  280. int nhcount;
  281. struct in6_addr **nexthops;
  282. unsigned int *ifindexes;
  283. int i, ret = 0;
  284. struct prefix_ipv6 *dest;
  285. if (IS_OSPF6_DEBUG_ZEBRA (SEND))
  286. {
  287. prefix2str (&request->prefix, buf, sizeof (buf));
  288. zlog_info ("Send %s route: %s",
  289. (type == REM ? "remove" : "add"), buf);
  290. }
  291. if (zclient->sock < 0)
  292. {
  293. if (IS_OSPF6_DEBUG_ZEBRA (SEND))
  294. zlog_info (" Not connected to Zebra");
  295. return;
  296. }
  297. if (request->path.origin.adv_router == ospf6->router_id &&
  298. (request->path.type == OSPF6_PATH_TYPE_EXTERNAL1 ||
  299. request->path.type == OSPF6_PATH_TYPE_EXTERNAL2))
  300. {
  301. if (IS_OSPF6_DEBUG_ZEBRA (SEND))
  302. zlog_info (" Ignore self-originated external route");
  303. return;
  304. }
  305. /* If removing is the best path and if there's another path,
  306. treat this request as add the secondary path */
  307. if (type == REM && ospf6_route_is_best (request) &&
  308. request->next && ospf6_route_is_same (request, request->next))
  309. {
  310. if (IS_OSPF6_DEBUG_ZEBRA (SEND))
  311. zlog_info (" Best-path removal resulted Sencondary addition");
  312. type = ADD;
  313. request = request->next;
  314. }
  315. /* Only the best path will be sent to zebra. */
  316. if (! ospf6_route_is_best (request))
  317. {
  318. /* this is not preferred best route, ignore */
  319. if (IS_OSPF6_DEBUG_ZEBRA (SEND))
  320. zlog_info (" Ignore non-best route");
  321. return;
  322. }
  323. nhcount = 0;
  324. for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++)
  325. if (ospf6_nexthop_is_set (&request->nexthop[i]))
  326. nhcount++;
  327. if (nhcount == 0)
  328. {
  329. if (IS_OSPF6_DEBUG_ZEBRA (SEND))
  330. zlog_info (" No nexthop, ignore");
  331. return;
  332. }
  333. /* allocate memory for nexthop_list */
  334. nexthops = XCALLOC (MTYPE_OSPF6_OTHER,
  335. nhcount * sizeof (struct in6_addr *));
  336. if (nexthops == NULL)
  337. {
  338. zlog_warn ("Can't send route to zebra: malloc failed");
  339. return;
  340. }
  341. /* allocate memory for ifindex_list */
  342. ifindexes = XCALLOC (MTYPE_OSPF6_OTHER,
  343. nhcount * sizeof (unsigned int));
  344. if (ifindexes == NULL)
  345. {
  346. zlog_warn ("Can't send route to zebra: malloc failed");
  347. XFREE (MTYPE_OSPF6_OTHER, nexthops);
  348. return;
  349. }
  350. for (i = 0; i < nhcount; i++)
  351. {
  352. if (IS_OSPF6_DEBUG_ZEBRA (SEND))
  353. {
  354. inet_ntop (AF_INET6, &request->nexthop[i].address,
  355. buf, sizeof (buf));
  356. if_indextoname (request->nexthop[i].ifindex, ifname);
  357. zlog_info (" nexthop: %s%%%s(%d)", buf, ifname,
  358. request->nexthop[i].ifindex);
  359. }
  360. nexthops[i] = &request->nexthop[i].address;
  361. ifindexes[i] = request->nexthop[i].ifindex;
  362. }
  363. api.type = ZEBRA_ROUTE_OSPF6;
  364. api.flags = 0;
  365. api.message = 0;
  366. SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
  367. api.nexthop_num = nhcount;
  368. api.nexthop = nexthops;
  369. SET_FLAG (api.message, ZAPI_MESSAGE_IFINDEX);
  370. api.ifindex_num = nhcount;
  371. api.ifindex = ifindexes;
  372. SET_FLAG (api.message, ZAPI_MESSAGE_METRIC);
  373. api.metric = (request->path.metric_type == 2 ?
  374. request->path.cost_e2 : request->path.cost);
  375. dest = (struct prefix_ipv6 *) &request->prefix;
  376. if (type == REM)
  377. ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, dest, &api);
  378. else
  379. ret = zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient, dest, &api);
  380. if (ret < 0)
  381. zlog_err ("zapi_ipv6_route() %s failed: %s",
  382. (type == REM ? "delete" : "add"), strerror (errno));
  383. XFREE (MTYPE_OSPF6_OTHER, nexthops);
  384. XFREE (MTYPE_OSPF6_OTHER, ifindexes);
  385. return;
  386. }
  387. void
  388. ospf6_zebra_route_update_add (struct ospf6_route *request)
  389. {
  390. if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
  391. {
  392. ospf6->route_table->hook_add = NULL;
  393. ospf6->route_table->hook_remove = NULL;
  394. return;
  395. }
  396. ospf6_zebra_route_update (ADD, request);
  397. }
  398. void
  399. ospf6_zebra_route_update_remove (struct ospf6_route *request)
  400. {
  401. if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
  402. {
  403. ospf6->route_table->hook_add = NULL;
  404. ospf6->route_table->hook_remove = NULL;
  405. return;
  406. }
  407. ospf6_zebra_route_update (REM, request);
  408. }
  409. DEFUN (redistribute_ospf6,
  410. redistribute_ospf6_cmd,
  411. "redistribute ospf6",
  412. "Redistribute control\n"
  413. "OSPF6 route\n")
  414. {
  415. struct ospf6_route *route;
  416. if (zclient->redist[ZEBRA_ROUTE_OSPF6])
  417. return CMD_SUCCESS;
  418. zclient->redist[ZEBRA_ROUTE_OSPF6] = 1;
  419. if (ospf6 == NULL)
  420. return CMD_SUCCESS;
  421. /* send ospf6 route to zebra route table */
  422. for (route = ospf6_route_head (ospf6->route_table); route;
  423. route = ospf6_route_next (route))
  424. ospf6_zebra_route_update_add (route);
  425. ospf6->route_table->hook_add = ospf6_zebra_route_update_add;
  426. ospf6->route_table->hook_remove = ospf6_zebra_route_update_remove;
  427. return CMD_SUCCESS;
  428. }
  429. DEFUN (no_redistribute_ospf6,
  430. no_redistribute_ospf6_cmd,
  431. "no redistribute ospf6",
  432. NO_STR
  433. "Redistribute control\n"
  434. "OSPF6 route\n")
  435. {
  436. struct ospf6_route *route;
  437. if (! zclient->redist[ZEBRA_ROUTE_OSPF6])
  438. return CMD_SUCCESS;
  439. zclient->redist[ZEBRA_ROUTE_OSPF6] = 0;
  440. if (ospf6 == NULL)
  441. return CMD_SUCCESS;
  442. ospf6->route_table->hook_add = NULL;
  443. ospf6->route_table->hook_remove = NULL;
  444. /* withdraw ospf6 route from zebra route table */
  445. for (route = ospf6_route_head (ospf6->route_table); route;
  446. route = ospf6_route_next (route))
  447. ospf6_zebra_route_update_remove (route);
  448. return CMD_SUCCESS;
  449. }
  450. void
  451. ospf6_zebra_init ()
  452. {
  453. /* Allocate zebra structure. */
  454. zclient = zclient_new ();
  455. zclient_init (zclient, ZEBRA_ROUTE_OSPF6);
  456. zclient->interface_add = ospf6_zebra_if_add;
  457. zclient->interface_delete = ospf6_zebra_if_del;
  458. zclient->interface_up = ospf6_zebra_if_state_update;
  459. zclient->interface_down = ospf6_zebra_if_state_update;
  460. zclient->interface_address_add = ospf6_zebra_if_address_update_add;
  461. zclient->interface_address_delete = ospf6_zebra_if_address_update_delete;
  462. zclient->ipv4_route_add = NULL;
  463. zclient->ipv4_route_delete = NULL;
  464. zclient->ipv6_route_add = ospf6_zebra_read_ipv6;
  465. zclient->ipv6_route_delete = ospf6_zebra_read_ipv6;
  466. /* redistribute connected route by default */
  467. /* ospf6_zebra_redistribute (ZEBRA_ROUTE_CONNECT); */
  468. /* Install zebra node. */
  469. install_node (&zebra_node, config_write_ospf6_zebra);
  470. /* Install command element for zebra node. */
  471. install_element (VIEW_NODE, &show_zebra_cmd);
  472. install_element (ENABLE_NODE, &show_zebra_cmd);
  473. install_element (CONFIG_NODE, &router_zebra_cmd);
  474. install_element (CONFIG_NODE, &no_router_zebra_cmd);
  475. install_default (ZEBRA_NODE);
  476. install_element (ZEBRA_NODE, &redistribute_ospf6_cmd);
  477. install_element (ZEBRA_NODE, &no_redistribute_ospf6_cmd);
  478. return;
  479. }
  480. /* Debug */
  481. DEFUN (debug_ospf6_zebra_sendrecv,
  482. debug_ospf6_zebra_sendrecv_cmd,
  483. "debug ospf6 zebra (send|recv)",
  484. DEBUG_STR
  485. OSPF6_STR
  486. "Debug connection between zebra\n"
  487. "Debug Sending zebra\n"
  488. "Debug Receiving zebra\n"
  489. )
  490. {
  491. unsigned char level = 0;
  492. if (argc)
  493. {
  494. if (! strncmp (argv[0], "s", 1))
  495. level = OSPF6_DEBUG_ZEBRA_SEND;
  496. else if (! strncmp (argv[0], "r", 1))
  497. level = OSPF6_DEBUG_ZEBRA_RECV;
  498. }
  499. else
  500. level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
  501. OSPF6_DEBUG_ZEBRA_ON (level);
  502. return CMD_SUCCESS;
  503. }
  504. ALIAS (debug_ospf6_zebra_sendrecv,
  505. debug_ospf6_zebra_cmd,
  506. "debug ospf6 zebra",
  507. DEBUG_STR
  508. OSPF6_STR
  509. "Debug connection between zebra\n"
  510. );
  511. DEFUN (no_debug_ospf6_zebra_sendrecv,
  512. no_debug_ospf6_zebra_sendrecv_cmd,
  513. "no debug ospf6 zebra (send|recv)",
  514. NO_STR
  515. DEBUG_STR
  516. OSPF6_STR
  517. "Debug connection between zebra\n"
  518. "Debug Sending zebra\n"
  519. "Debug Receiving zebra\n"
  520. )
  521. {
  522. unsigned char level = 0;
  523. if (argc)
  524. {
  525. if (! strncmp (argv[0], "s", 1))
  526. level = OSPF6_DEBUG_ZEBRA_SEND;
  527. else if (! strncmp (argv[0], "r", 1))
  528. level = OSPF6_DEBUG_ZEBRA_RECV;
  529. }
  530. else
  531. level = OSPF6_DEBUG_ZEBRA_SEND | OSPF6_DEBUG_ZEBRA_RECV;
  532. OSPF6_DEBUG_ZEBRA_OFF (level);
  533. return CMD_SUCCESS;
  534. }
  535. ALIAS (no_debug_ospf6_zebra_sendrecv,
  536. no_debug_ospf6_zebra_cmd,
  537. "no debug ospf6 zebra",
  538. NO_STR
  539. DEBUG_STR
  540. OSPF6_STR
  541. "Debug connection between zebra\n"
  542. );
  543. int
  544. config_write_ospf6_debug_zebra (struct vty *vty)
  545. {
  546. if (IS_OSPF6_DEBUG_ZEBRA (SEND) && IS_OSPF6_DEBUG_ZEBRA (RECV))
  547. vty_out (vty, "debug ospf6 zebra%s", VTY_NEWLINE);
  548. else
  549. {
  550. if (IS_OSPF6_DEBUG_ZEBRA (SEND))
  551. vty_out (vty, "debug ospf6 zebra send%s", VTY_NEWLINE);
  552. if (IS_OSPF6_DEBUG_ZEBRA (RECV))
  553. vty_out (vty, "debug ospf6 zebra recv%s", VTY_NEWLINE);
  554. }
  555. return 0;
  556. }
  557. void
  558. install_element_ospf6_debug_zebra ()
  559. {
  560. install_element (ENABLE_NODE, &debug_ospf6_zebra_cmd);
  561. install_element (ENABLE_NODE, &no_debug_ospf6_zebra_cmd);
  562. install_element (ENABLE_NODE, &debug_ospf6_zebra_sendrecv_cmd);
  563. install_element (ENABLE_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
  564. install_element (CONFIG_NODE, &debug_ospf6_zebra_cmd);
  565. install_element (CONFIG_NODE, &no_debug_ospf6_zebra_cmd);
  566. install_element (CONFIG_NODE, &debug_ospf6_zebra_sendrecv_cmd);
  567. install_element (CONFIG_NODE, &no_debug_ospf6_zebra_sendrecv_cmd);
  568. }