irdp_interface.c 17 KB

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