irdp_interface.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. /*
  2. *
  3. * Copyright (C) 2000 Robert Olsson.
  4. * Swedish University of Agricultural Sciences
  5. *
  6. * This file is part of GNU Zebra.
  7. *
  8. * GNU Zebra is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2, or (at your option) any
  11. * later version.
  12. *
  13. * GNU Zebra is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  20. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  21. * 02111-1307, USA.
  22. */
  23. /*
  24. * This work includes work with the following copywrite:
  25. *
  26. * Copyright (C) 1997, 2000 Kunihiro Ishiguro
  27. *
  28. */
  29. /*
  30. * Thanks to Jens Låås at Swedish University of Agricultural Sciences
  31. * for reviewing and tests.
  32. */
  33. #include <zebra.h>
  34. #ifdef HAVE_IRDP
  35. #include "if.h"
  36. #include "vty.h"
  37. #include "sockunion.h"
  38. #include "prefix.h"
  39. #include "command.h"
  40. #include "memory.h"
  41. #include "stream.h"
  42. #include "ioctl.h"
  43. #include "connected.h"
  44. #include "log.h"
  45. #include "zclient.h"
  46. #include "thread.h"
  47. #include "zebra/interface.h"
  48. #include "zebra/rtadv.h"
  49. #include "zebra/rib.h"
  50. #include "zebra/zserv.h"
  51. #include "zebra/redistribute.h"
  52. #include "zebra/irdp.h"
  53. #include <netinet/ip_icmp.h>
  54. #include "if.h"
  55. #include "sockunion.h"
  56. #include "log.h"
  57. /* Master of threads. */
  58. extern struct zebra_t zebrad;
  59. extern int irdp_sock;
  60. static const char *
  61. inet_2a(u_int32_t a, char *b)
  62. {
  63. sprintf(b, "%u.%u.%u.%u",
  64. (a ) & 0xFF,
  65. (a>> 8) & 0xFF,
  66. (a>>16) & 0xFF,
  67. (a>>24) & 0xFF);
  68. return b;
  69. }
  70. static struct prefix *
  71. irdp_get_prefix(struct interface *ifp)
  72. {
  73. struct listnode *node;
  74. struct connected *ifc;
  75. if (ifp->connected)
  76. for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
  77. return ifc->address;
  78. return NULL;
  79. }
  80. /* Join to the add/leave multicast group. */
  81. static int
  82. if_group (struct interface *ifp,
  83. int sock,
  84. u_int32_t group,
  85. int add_leave)
  86. {
  87. struct ip_mreq m;
  88. struct prefix *p;
  89. int ret;
  90. char b1[INET_ADDRSTRLEN];
  91. memset (&m, 0, sizeof (m));
  92. m.imr_multiaddr.s_addr = htonl (group);
  93. p = irdp_get_prefix(ifp);
  94. if(!p) {
  95. zlog_warn ("IRDP: can't get address for %s", ifp->name);
  96. return 1;
  97. }
  98. m.imr_interface = p->u.prefix4;
  99. ret = setsockopt (sock, IPPROTO_IP, add_leave,
  100. (char *) &m, sizeof (struct ip_mreq));
  101. if (ret < 0)
  102. zlog_warn ("IRDP: %s can't setsockopt %s: %s",
  103. add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group",
  104. inet_2a(group, b1),
  105. safe_strerror (errno));
  106. return ret;
  107. }
  108. static int
  109. if_add_group (struct interface *ifp)
  110. {
  111. struct zebra_if *zi= ifp->info;
  112. struct irdp_interface *irdp = &zi->irdp;
  113. int ret;
  114. char b1[INET_ADDRSTRLEN];
  115. ret = if_group (ifp, irdp_sock, INADDR_ALLRTRS_GROUP, IP_ADD_MEMBERSHIP);
  116. if (ret < 0) {
  117. return ret;
  118. }
  119. if(irdp->flags & IF_DEBUG_MISC )
  120. zlog_debug("IRDP: Adding group %s for %s",
  121. inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1),
  122. ifp->name);
  123. return 0;
  124. }
  125. static int
  126. if_drop_group (struct interface *ifp)
  127. {
  128. struct zebra_if *zi= ifp->info;
  129. struct irdp_interface *irdp = &zi->irdp;
  130. int ret;
  131. char b1[INET_ADDRSTRLEN];
  132. ret = if_group (ifp, irdp_sock, INADDR_ALLRTRS_GROUP, IP_DROP_MEMBERSHIP);
  133. if (ret < 0)
  134. return ret;
  135. if(irdp->flags & IF_DEBUG_MISC)
  136. zlog_debug("IRDP: Leaving group %s for %s",
  137. inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1),
  138. ifp->name);
  139. return 0;
  140. }
  141. static void
  142. if_set_defaults(struct interface *ifp)
  143. {
  144. struct zebra_if *zi=ifp->info;
  145. struct irdp_interface *irdp=&zi->irdp;
  146. irdp->MaxAdvertInterval = IRDP_MAXADVERTINTERVAL;
  147. irdp->MinAdvertInterval = IRDP_MINADVERTINTERVAL;
  148. irdp->Preference = IRDP_PREFERENCE;
  149. irdp->Lifetime = IRDP_LIFETIME;
  150. }
  151. static struct Adv *Adv_new (void)
  152. {
  153. return XCALLOC (MTYPE_TMP, sizeof (struct Adv));
  154. }
  155. static void
  156. Adv_free (struct Adv *adv)
  157. {
  158. XFREE (MTYPE_TMP, adv);
  159. }
  160. static void
  161. irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
  162. {
  163. struct zebra_if *zi= ifp->info;
  164. struct irdp_interface *irdp = &zi->irdp;
  165. struct listnode *node;
  166. struct connected *ifc;
  167. u_int32_t timer, seed;
  168. if (irdp->flags & IF_ACTIVE ) {
  169. zlog_warn("IRDP: Interface is already active %s", ifp->name);
  170. return;
  171. }
  172. if ((irdp_sock < 0) && ((irdp_sock = irdp_sock_init()) < 0)) {
  173. zlog_warn("IRDP: Cannot activate interface %s (cannot create "
  174. "IRDP socket)", ifp->name);
  175. return;
  176. }
  177. irdp->flags |= IF_ACTIVE;
  178. if(!multicast)
  179. irdp->flags |= IF_BROADCAST;
  180. if_add_update(ifp);
  181. if (! (ifp->flags & IFF_UP)) {
  182. zlog_warn("IRDP: Interface is down %s", ifp->name);
  183. }
  184. /* Shall we cancel if_start if if_add_group fails? */
  185. if( multicast) {
  186. if_add_group(ifp);
  187. if (! (ifp->flags & (IFF_MULTICAST|IFF_ALLMULTI))) {
  188. zlog_warn("IRDP: Interface not multicast enabled %s", ifp->name);
  189. }
  190. }
  191. if(set_defaults)
  192. if_set_defaults(ifp);
  193. irdp->irdp_sent = 0;
  194. /* The spec suggests this for randomness */
  195. seed = 0;
  196. if( ifp->connected)
  197. for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
  198. {
  199. seed = ifc->address->u.prefix4.s_addr;
  200. break;
  201. }
  202. srandom(seed);
  203. timer = (random () % IRDP_DEFAULT_INTERVAL) + 1;
  204. irdp->AdvPrefList = list_new();
  205. irdp->AdvPrefList->del = (void (*)(void *)) Adv_free; /* Destructor */
  206. /* And this for startup. Speed limit from 1991 :-). But it's OK*/
  207. if(irdp->irdp_sent < MAX_INITIAL_ADVERTISEMENTS &&
  208. timer > MAX_INITIAL_ADVERT_INTERVAL )
  209. timer= MAX_INITIAL_ADVERT_INTERVAL;
  210. if(irdp->flags & IF_DEBUG_MISC)
  211. zlog_debug("IRDP: Init timer for %s set to %u",
  212. ifp->name,
  213. timer);
  214. irdp->t_advertise = thread_add_timer(zebrad.master,
  215. irdp_send_thread,
  216. ifp,
  217. timer);
  218. }
  219. static void
  220. irdp_if_stop(struct interface *ifp)
  221. {
  222. struct zebra_if *zi=ifp->info;
  223. struct irdp_interface *irdp=&zi->irdp;
  224. if (irdp == NULL) {
  225. zlog_warn ("Interface %s structure is NULL", ifp->name);
  226. return;
  227. }
  228. if (! (irdp->flags & IF_ACTIVE )) {
  229. zlog_warn("Interface is not active %s", ifp->name);
  230. return;
  231. }
  232. if(! (irdp->flags & IF_BROADCAST))
  233. if_drop_group(ifp);
  234. irdp_advert_off(ifp);
  235. list_delete(irdp->AdvPrefList);
  236. irdp->AdvPrefList=NULL;
  237. irdp->flags = 0;
  238. }
  239. static void
  240. irdp_if_shutdown(struct interface *ifp)
  241. {
  242. struct zebra_if *zi= ifp->info;
  243. struct irdp_interface *irdp = &zi->irdp;
  244. if (irdp->flags & IF_SHUTDOWN ) {
  245. zlog_warn("IRDP: Interface is already shutdown %s", ifp->name);
  246. return;
  247. }
  248. irdp->flags |= IF_SHUTDOWN;
  249. irdp->flags &= ~IF_ACTIVE;
  250. if(! (irdp->flags & IF_BROADCAST))
  251. if_drop_group(ifp);
  252. /* Tell the hosts we are out of service */
  253. irdp_advert_off(ifp);
  254. }
  255. static void
  256. irdp_if_no_shutdown(struct interface *ifp)
  257. {
  258. struct zebra_if *zi= ifp->info;
  259. struct irdp_interface *irdp = &zi->irdp;
  260. if (! (irdp->flags & IF_SHUTDOWN )) {
  261. zlog_warn("IRDP: Interface is not shutdown %s", ifp->name);
  262. return;
  263. }
  264. irdp->flags &= ~IF_SHUTDOWN;
  265. irdp_if_start(ifp, irdp->flags & IF_BROADCAST? FALSE : TRUE, FALSE);
  266. }
  267. /* Write configuration to user */
  268. void irdp_config_write (struct vty *vty, struct interface *ifp)
  269. {
  270. struct zebra_if *zi=ifp->info;
  271. struct irdp_interface *irdp=&zi->irdp;
  272. struct Adv *adv;
  273. struct listnode *node;
  274. char b1[INET_ADDRSTRLEN];
  275. if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) {
  276. if( irdp->flags & IF_SHUTDOWN)
  277. vty_out (vty, " ip irdp shutdown %s", VTY_NEWLINE);
  278. if( irdp->flags & IF_BROADCAST)
  279. vty_out (vty, " ip irdp broadcast%s", VTY_NEWLINE);
  280. else
  281. vty_out (vty, " ip irdp multicast%s", VTY_NEWLINE);
  282. vty_out (vty, " ip irdp preference %ld%s",
  283. irdp->Preference, VTY_NEWLINE);
  284. for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
  285. vty_out (vty, " ip irdp address %s preference %d%s",
  286. inet_2a(adv->ip.s_addr, b1),
  287. adv->pref,
  288. VTY_NEWLINE);
  289. vty_out (vty, " ip irdp holdtime %d%s",
  290. irdp->Lifetime, VTY_NEWLINE);
  291. vty_out (vty, " ip irdp minadvertinterval %ld%s",
  292. irdp->MinAdvertInterval, VTY_NEWLINE);
  293. vty_out (vty, " ip irdp maxadvertinterval %ld%s",
  294. irdp->MaxAdvertInterval, VTY_NEWLINE);
  295. }
  296. }
  297. DEFUN (ip_irdp_multicast,
  298. ip_irdp_multicast_cmd,
  299. "ip irdp multicast",
  300. IP_STR
  301. "ICMP Router discovery on this interface using multicast\n")
  302. {
  303. struct interface *ifp;
  304. ifp = (struct interface *) vty->index;
  305. if(!ifp) {
  306. return CMD_WARNING;
  307. }
  308. irdp_if_start(ifp, TRUE, TRUE);
  309. return CMD_SUCCESS;
  310. }
  311. DEFUN (ip_irdp_broadcast,
  312. ip_irdp_broadcast_cmd,
  313. "ip irdp broadcast",
  314. IP_STR
  315. "ICMP Router discovery on this interface using broadcast\n")
  316. {
  317. struct interface *ifp;
  318. ifp = (struct interface *) vty->index;
  319. if(!ifp) {
  320. return CMD_WARNING;
  321. }
  322. irdp_if_start(ifp, FALSE, TRUE);
  323. return CMD_SUCCESS;
  324. }
  325. DEFUN (no_ip_irdp,
  326. no_ip_irdp_cmd,
  327. "no ip irdp",
  328. NO_STR
  329. IP_STR
  330. "Disable ICMP Router discovery on this interface\n")
  331. {
  332. struct interface *ifp;
  333. ifp = (struct interface *) vty->index;
  334. if(!ifp) {
  335. return CMD_WARNING;
  336. }
  337. irdp_if_stop(ifp);
  338. return CMD_SUCCESS;
  339. }
  340. DEFUN (ip_irdp_shutdown,
  341. ip_irdp_shutdown_cmd,
  342. "ip irdp shutdown",
  343. IP_STR
  344. "ICMP Router discovery shutdown on this interface\n")
  345. {
  346. struct interface *ifp;
  347. ifp = (struct interface *) vty->index;
  348. if(!ifp) {
  349. return CMD_WARNING;
  350. }
  351. irdp_if_shutdown(ifp);
  352. return CMD_SUCCESS;
  353. }
  354. DEFUN (no_ip_irdp_shutdown,
  355. no_ip_irdp_shutdown_cmd,
  356. "no ip irdp shutdown",
  357. NO_STR
  358. IP_STR
  359. "ICMP Router discovery no shutdown on this interface\n")
  360. {
  361. struct interface *ifp;
  362. ifp = (struct interface *) vty->index;
  363. if(!ifp) {
  364. return CMD_WARNING;
  365. }
  366. irdp_if_no_shutdown(ifp);
  367. return CMD_SUCCESS;
  368. }
  369. DEFUN (ip_irdp_holdtime,
  370. ip_irdp_holdtime_cmd,
  371. "ip irdp holdtime <0-9000>",
  372. IP_STR
  373. "ICMP Router discovery on this interface\n"
  374. "Set holdtime value\n"
  375. "Holdtime value in seconds. Default is 1800 seconds\n")
  376. {
  377. struct interface *ifp;
  378. struct zebra_if *zi;
  379. struct irdp_interface *irdp;
  380. ifp = (struct interface *) vty->index;
  381. if(!ifp) {
  382. return CMD_WARNING;
  383. }
  384. zi=ifp->info;
  385. irdp=&zi->irdp;
  386. irdp->Lifetime = atoi(argv[0]);
  387. return CMD_SUCCESS;
  388. }
  389. DEFUN (ip_irdp_minadvertinterval,
  390. ip_irdp_minadvertinterval_cmd,
  391. "ip irdp minadvertinterval <3-1800>",
  392. IP_STR
  393. "ICMP Router discovery on this interface\n"
  394. "Set minimum time between advertisement\n"
  395. "Minimum advertisement interval in seconds\n")
  396. {
  397. struct interface *ifp;
  398. struct zebra_if *zi;
  399. struct irdp_interface *irdp;
  400. ifp = (struct interface *) vty->index;
  401. if(!ifp) {
  402. return CMD_WARNING;
  403. }
  404. zi=ifp->info;
  405. irdp=&zi->irdp;
  406. if( (unsigned) atoi(argv[0]) <= irdp->MaxAdvertInterval) {
  407. irdp->MinAdvertInterval = atoi(argv[0]);
  408. return CMD_SUCCESS;
  409. }
  410. vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
  411. VTY_NEWLINE);
  412. vty_out (vty, "Please correct!%s",
  413. VTY_NEWLINE);
  414. return CMD_WARNING;
  415. }
  416. DEFUN (ip_irdp_maxadvertinterval,
  417. ip_irdp_maxadvertinterval_cmd,
  418. "ip irdp maxadvertinterval <4-1800>",
  419. IP_STR
  420. "ICMP Router discovery on this interface\n"
  421. "Set maximum time between advertisement\n"
  422. "Maximum advertisement interval in seconds\n")
  423. {
  424. struct interface *ifp;
  425. struct zebra_if *zi;
  426. struct irdp_interface *irdp;
  427. ifp = (struct interface *) vty->index;
  428. if(!ifp) {
  429. return CMD_WARNING;
  430. }
  431. zi=ifp->info;
  432. irdp=&zi->irdp;
  433. if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[0]) ) {
  434. irdp->MaxAdvertInterval = atoi(argv[0]);
  435. return CMD_SUCCESS;
  436. }
  437. vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
  438. VTY_NEWLINE);
  439. vty_out (vty, "Please correct!%s",
  440. VTY_NEWLINE);
  441. return CMD_WARNING;
  442. }
  443. /* DEFUN needs to be fixed for negative ranages...
  444. * "ip irdp preference <-2147483648-2147483647>",
  445. * Be positive for now. :-)
  446. */
  447. DEFUN (ip_irdp_preference,
  448. ip_irdp_preference_cmd,
  449. "ip irdp preference <0-2147483647>",
  450. IP_STR
  451. "ICMP Router discovery on this interface\n"
  452. "Set default preference level for this interface\n"
  453. "Preference level\n")
  454. {
  455. struct interface *ifp;
  456. struct zebra_if *zi;
  457. struct irdp_interface *irdp;
  458. ifp = (struct interface *) vty->index;
  459. if(!ifp) {
  460. return CMD_WARNING;
  461. }
  462. zi=ifp->info;
  463. irdp=&zi->irdp;
  464. irdp->Preference = atoi(argv[0]);
  465. return CMD_SUCCESS;
  466. }
  467. DEFUN (ip_irdp_address_preference,
  468. ip_irdp_address_preference_cmd,
  469. "ip irdp address A.B.C.D preference <0-2147483647>",
  470. IP_STR
  471. "Alter ICMP Router discovery preference this interface\n"
  472. "Specify IRDP non-default preference to advertise\n"
  473. "Set IRDP address for advertise\n"
  474. "Preference level\n")
  475. {
  476. struct listnode *node;
  477. struct in_addr ip;
  478. int pref;
  479. int ret;
  480. struct interface *ifp;
  481. struct zebra_if *zi;
  482. struct irdp_interface *irdp;
  483. struct Adv *adv;
  484. ifp = (struct interface *) vty->index;
  485. if(!ifp) {
  486. return CMD_WARNING;
  487. }
  488. zi=ifp->info;
  489. irdp=&zi->irdp;
  490. ret = inet_aton(argv[0], &ip);
  491. if(!ret) return CMD_WARNING;
  492. pref = atoi(argv[1]);
  493. for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
  494. if(adv->ip.s_addr == ip.s_addr)
  495. return CMD_SUCCESS;
  496. adv = Adv_new();
  497. adv->ip = ip;
  498. adv->pref = pref;
  499. listnode_add(irdp->AdvPrefList, adv);
  500. return CMD_SUCCESS;
  501. }
  502. DEFUN (no_ip_irdp_address_preference,
  503. no_ip_irdp_address_preference_cmd,
  504. "no ip irdp address A.B.C.D preference <0-2147483647>",
  505. NO_STR
  506. IP_STR
  507. "Alter ICMP Router discovery preference this interface\n"
  508. "Removes IRDP non-default preference\n"
  509. "Select IRDP address\n"
  510. "Old preference level\n")
  511. {
  512. struct listnode *node, *nnode;
  513. struct in_addr ip;
  514. int ret;
  515. struct interface *ifp;
  516. struct zebra_if *zi;
  517. struct irdp_interface *irdp;
  518. struct Adv *adv;
  519. ifp = (struct interface *) vty->index;
  520. if(!ifp) {
  521. return CMD_WARNING;
  522. }
  523. zi=ifp->info;
  524. irdp=&zi->irdp;
  525. ret = inet_aton(argv[0], &ip);
  526. if (!ret)
  527. return CMD_WARNING;
  528. for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv))
  529. {
  530. if(adv->ip.s_addr == ip.s_addr )
  531. {
  532. listnode_delete(irdp->AdvPrefList, adv);
  533. break;
  534. }
  535. }
  536. return CMD_SUCCESS;
  537. }
  538. DEFUN (ip_irdp_debug_messages,
  539. ip_irdp_debug_messages_cmd,
  540. "ip irdp debug messages",
  541. IP_STR
  542. "ICMP Router discovery debug Averts. and Solicits (short)\n")
  543. {
  544. struct interface *ifp;
  545. struct zebra_if *zi;
  546. struct irdp_interface *irdp;
  547. ifp = (struct interface *) vty->index;
  548. if(!ifp) {
  549. return CMD_WARNING;
  550. }
  551. zi=ifp->info;
  552. irdp=&zi->irdp;
  553. irdp->flags |= IF_DEBUG_MESSAGES;
  554. return CMD_SUCCESS;
  555. }
  556. DEFUN (ip_irdp_debug_misc,
  557. ip_irdp_debug_misc_cmd,
  558. "ip irdp debug misc",
  559. IP_STR
  560. "ICMP Router discovery debug Averts. and Solicits (short)\n")
  561. {
  562. struct interface *ifp;
  563. struct zebra_if *zi;
  564. struct irdp_interface *irdp;
  565. ifp = (struct interface *) vty->index;
  566. if(!ifp) {
  567. return CMD_WARNING;
  568. }
  569. zi=ifp->info;
  570. irdp=&zi->irdp;
  571. irdp->flags |= IF_DEBUG_MISC;
  572. return CMD_SUCCESS;
  573. }
  574. DEFUN (ip_irdp_debug_packet,
  575. ip_irdp_debug_packet_cmd,
  576. "ip irdp debug packet",
  577. IP_STR
  578. "ICMP Router discovery debug Averts. and Solicits (short)\n")
  579. {
  580. struct interface *ifp;
  581. struct zebra_if *zi;
  582. struct irdp_interface *irdp;
  583. ifp = (struct interface *) vty->index;
  584. if(!ifp) {
  585. return CMD_WARNING;
  586. }
  587. zi=ifp->info;
  588. irdp=&zi->irdp;
  589. irdp->flags |= IF_DEBUG_PACKET;
  590. return CMD_SUCCESS;
  591. }
  592. DEFUN (ip_irdp_debug_disable,
  593. ip_irdp_debug_disable_cmd,
  594. "ip irdp debug disable",
  595. IP_STR
  596. "ICMP Router discovery debug Averts. and Solicits (short)\n")
  597. {
  598. struct interface *ifp;
  599. struct zebra_if *zi;
  600. struct irdp_interface *irdp;
  601. ifp = (struct interface *) vty->index;
  602. if(!ifp) {
  603. return CMD_WARNING;
  604. }
  605. zi=ifp->info;
  606. irdp=&zi->irdp;
  607. irdp->flags &= ~IF_DEBUG_PACKET;
  608. irdp->flags &= ~IF_DEBUG_MESSAGES;
  609. irdp->flags &= ~IF_DEBUG_MISC;
  610. return CMD_SUCCESS;
  611. }
  612. void
  613. irdp_init ()
  614. {
  615. install_element (INTERFACE_NODE, &ip_irdp_broadcast_cmd);
  616. install_element (INTERFACE_NODE, &ip_irdp_multicast_cmd);
  617. install_element (INTERFACE_NODE, &no_ip_irdp_cmd);
  618. install_element (INTERFACE_NODE, &ip_irdp_shutdown_cmd);
  619. install_element (INTERFACE_NODE, &no_ip_irdp_shutdown_cmd);
  620. install_element (INTERFACE_NODE, &ip_irdp_holdtime_cmd);
  621. install_element (INTERFACE_NODE, &ip_irdp_maxadvertinterval_cmd);
  622. install_element (INTERFACE_NODE, &ip_irdp_minadvertinterval_cmd);
  623. install_element (INTERFACE_NODE, &ip_irdp_preference_cmd);
  624. install_element (INTERFACE_NODE, &ip_irdp_address_preference_cmd);
  625. install_element (INTERFACE_NODE, &no_ip_irdp_address_preference_cmd);
  626. install_element (INTERFACE_NODE, &ip_irdp_debug_messages_cmd);
  627. install_element (INTERFACE_NODE, &ip_irdp_debug_misc_cmd);
  628. install_element (INTERFACE_NODE, &ip_irdp_debug_packet_cmd);
  629. install_element (INTERFACE_NODE, &ip_irdp_debug_disable_cmd);
  630. }
  631. #endif /* HAVE_IRDP */