blob: e824abed75e3a4e7e619f3af5a636d28dbe8d39f [file] [log] [blame]
hassoca776982004-06-12 14:33:05 +00001/*
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/*
25 * This work includes work with the following copywrite:
26 *
27 * Copyright (C) 1997, 2000 Kunihiro Ishiguro
28 *
29 */
30
31/*
32 * Thanks to Jens Låås at Swedish University of Agricultural Sciences
33 * for reviewing and tests.
34 */
35
36
37#include <zebra.h>
38
39#ifdef HAVE_IRDP
40
41#include "if.h"
42#include "vty.h"
43#include "sockunion.h"
44#include "prefix.h"
45#include "command.h"
46#include "memory.h"
47#include "stream.h"
48#include "ioctl.h"
49#include "connected.h"
50#include "log.h"
51#include "zclient.h"
52#include "thread.h"
53#include "zebra/interface.h"
54#include "zebra/rtadv.h"
55#include "zebra/rib.h"
56#include "zebra/zserv.h"
57#include "zebra/redistribute.h"
58#include "zebra/irdp.h"
59#include <netinet/ip_icmp.h>
60#include "if.h"
61#include "sockunion.h"
62#include "log.h"
63
64
65/* Master of threads. */
66extern struct zebra_t zebrad;
67
68int in_cksum (void *ptr, int nbytes);
69extern int irdp_sock;
70int irdp_send_thread(struct thread *t_advert);
71char *inet_2a(u_int32_t a, char *b);
72void irdp_advert_off(struct interface *ifp);
73
74
75char b1[16], b2[16], b3[16], b4[16]; /* For inet_2a */
76
77struct prefix *irdp_get_prefix(struct interface *ifp)
78{
paul0c0f9112004-09-24 08:24:42 +000079 struct listnode *node;
hassoca776982004-06-12 14:33:05 +000080 struct connected *ifc;
81
paul0c0f9112004-09-24 08:24:42 +000082 if (ifp->connected)
83 LIST_LOOP (ifp->connected, ifc, node)
hassoca776982004-06-12 14:33:05 +000084 return ifc->address;
paul0c0f9112004-09-24 08:24:42 +000085
hassoca776982004-06-12 14:33:05 +000086 return NULL;
87}
88
89/* Join to the add/leave multicast group. */
90int if_group (struct interface *ifp,
91 int sock,
92 u_int32_t group,
93 int add_leave)
94{
95 struct zebra_if *zi;
96 struct ip_mreq m;
97 struct prefix *p;
98 int ret;
99
100 zi = ifp->info;
101
102 bzero (&m, sizeof (m));
103 m.imr_multiaddr.s_addr = htonl (group);
104 p = irdp_get_prefix(ifp);
105
106 if(!p) {
107 zlog_warn ("IRDP: can't get address for %s", ifp->name);
108 return 1;
109 }
110
111 m.imr_interface = p->u.prefix4;
112
113 ret = setsockopt (sock, IPPROTO_IP, add_leave,
114 (char *) &m, sizeof (struct ip_mreq));
115 if (ret < 0)
116 zlog_warn ("IRDP: %s can't setsockopt %s: %s",
117 add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group",
118 inet_2a(group, b1),
119 strerror (errno));
120
121 return ret;
122}
123
124int if_add_group (struct interface *ifp)
125{
126 struct zebra_if *zi= ifp->info;
127 struct irdp_interface *irdp = &zi->irdp;
128 int ret;
129
130 ret = if_group (ifp, irdp_sock, INADDR_ALLRTRS_GROUP, IP_ADD_MEMBERSHIP);
131 if (ret < 0) {
132 return ret;
133 }
134
135 if(irdp->flags & IF_DEBUG_MISC )
136 zlog_warn("IRDP: Adding group %s for %s\n",
137 inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1),
138 ifp->name);
139 return 0;
140}
141int if_drop_group (struct interface *ifp)
142{
143 struct zebra_if *zi= ifp->info;
144 struct irdp_interface *irdp = &zi->irdp;
145 int ret;
146
147 ret = if_group (ifp, irdp_sock, INADDR_ALLRTRS_GROUP, IP_DROP_MEMBERSHIP);
148 if (ret < 0)
149 return ret;
150
151 if(irdp->flags & IF_DEBUG_MISC)
152 zlog_warn("IRDP: Leaving group %s for %s\n",
153 inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1),
154 ifp->name);
155 return 0;
156}
157
hasso39db97e2004-10-12 20:50:58 +0000158struct interface *get_iflist_ifp(unsigned int idx)
hassoca776982004-06-12 14:33:05 +0000159{
paul0c0f9112004-09-24 08:24:42 +0000160 struct listnode *node;
hassoca776982004-06-12 14:33:05 +0000161 struct interface *ifp;
162
paul0c0f9112004-09-24 08:24:42 +0000163 LIST_LOOP (iflist, ifp, node)
164 if(ifp->ifindex == idx)
165 return ifp;
166
hassoca776982004-06-12 14:33:05 +0000167 return NULL;
168}
169
170void
171if_set_defaults(struct interface *ifp)
172{
173 struct zebra_if *zi=ifp->info;
174 struct irdp_interface *irdp=&zi->irdp;
175
176 irdp->MaxAdvertInterval = IRDP_MAXADVERTINTERVAL;
177 irdp->MinAdvertInterval = IRDP_MINADVERTINTERVAL;
178 irdp->Preference = IRDP_PREFERENCE;
179 irdp->Lifetime = IRDP_LIFETIME;
180}
181
182
183struct Adv *Adv_new ()
184{
185 struct Adv *new;
186 new = XMALLOC (MTYPE_TMP, sizeof (struct Adv));
187 memset (new, 0, sizeof (struct Adv));
188 return new;
189}
190
191void Adv_free (struct Adv *adv)
192{
193 XFREE (MTYPE_TMP, adv);
194}
195
196void irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
197{
198 struct zebra_if *zi= ifp->info;
199 struct irdp_interface *irdp = &zi->irdp;
paul0c0f9112004-09-24 08:24:42 +0000200 struct listnode *node;
201 struct connected *ifc;
hassoca776982004-06-12 14:33:05 +0000202 u_int32_t timer, seed;
203
204 if (irdp->flags & IF_ACTIVE ) {
205 zlog_warn("IRDP: Interface is already active %s\n", ifp->name);
206 return;
207 }
208 irdp->flags |= IF_ACTIVE;
209
210 if(!multicast)
211 irdp->flags |= IF_BROADCAST;
212
213 if_add_update(ifp);
214
215 if (! (ifp->flags & IFF_UP)) {
216 zlog_warn("IRDP: Interface is down %s\n", ifp->name);
217 }
218
219 /* Shall we cancel if_start if if_add_group fails? */
220
221 if( multicast) {
222 if_add_group(ifp);
223
224 if (! (ifp->flags & (IFF_MULTICAST|IFF_ALLMULTI))) {
225 zlog_warn("IRDP: Interface not multicast enabled %s\n", ifp->name);
226 }
227 }
228
229 if(set_defaults)
230 if_set_defaults(ifp);
231
232 irdp->irdp_sent = 0;
233
234 /* The spec suggests this for randomness */
235
236 seed = 0;
paul0c0f9112004-09-24 08:24:42 +0000237 if( ifp->connected)
238 LIST_LOOP (ifp->connected, ifc, node)
239 {
240 seed = ifc->address->u.prefix4.s_addr;
241 break;
242 }
hassoca776982004-06-12 14:33:05 +0000243
244 srandom(seed);
245 timer = (random () % IRDP_DEFAULT_INTERVAL) + 1;
246
247 irdp->AdvPrefList = list_new();
hassoc9e52be2004-09-26 16:09:34 +0000248 irdp->AdvPrefList->del = (void (*)(void *)) Adv_free; /* Destructor */
hassoca776982004-06-12 14:33:05 +0000249
250
251 /* And this for startup. Speed limit from 1991 :-). But it's OK*/
252
253 if(irdp->irdp_sent < MAX_INITIAL_ADVERTISEMENTS &&
254 timer > MAX_INITIAL_ADVERT_INTERVAL )
255 timer= MAX_INITIAL_ADVERT_INTERVAL;
256
257
258 if(irdp->flags & IF_DEBUG_MISC)
259 zlog_warn("IRDP: Init timer for %s set to %u\n",
260 ifp->name,
261 timer);
262
263 irdp->t_advertise = thread_add_timer(zebrad.master,
264 irdp_send_thread,
265 ifp,
266 timer);
267}
268
269void irdp_if_stop(struct interface *ifp)
270{
271 struct zebra_if *zi=ifp->info;
272 struct irdp_interface *irdp=&zi->irdp;
273
274 if (irdp == NULL) {
275 zlog_warn ("Interface %s structure is NULL", ifp->name);
276 return;
277 }
278
279 if (! (irdp->flags & IF_ACTIVE )) {
280 zlog_warn("Interface is not active %s\n", ifp->name);
281 return;
282 }
283
284 if(! (irdp->flags & IF_BROADCAST))
285 if_drop_group(ifp);
286
287 irdp_advert_off(ifp);
288
289 list_delete(irdp->AdvPrefList);
290 irdp->AdvPrefList=NULL;
291
292 irdp->flags = 0;
293}
294
295
296void irdp_if_shutdown(struct interface *ifp)
297{
298 struct zebra_if *zi= ifp->info;
299 struct irdp_interface *irdp = &zi->irdp;
300
301 if (irdp->flags & IF_SHUTDOWN ) {
302 zlog_warn("IRDP: Interface is already shutdown %s\n", ifp->name);
303 return;
304 }
305
306 irdp->flags |= IF_SHUTDOWN;
307 irdp->flags &= ~IF_ACTIVE;
308
309 if(! (irdp->flags & IF_BROADCAST))
310 if_drop_group(ifp);
311
312 /* Tell the hosts we are out of service */
313 irdp_advert_off(ifp);
314}
315
316void irdp_if_no_shutdown(struct interface *ifp)
317{
318 struct zebra_if *zi= ifp->info;
319 struct irdp_interface *irdp = &zi->irdp;
320
321 if (! (irdp->flags & IF_SHUTDOWN )) {
322 zlog_warn("IRDP: Interface is not shutdown %s\n", ifp->name);
323 return;
324 }
325
326 irdp->flags &= ~IF_SHUTDOWN;
327
328 irdp_if_start(ifp, irdp->flags & IF_BROADCAST? FALSE : TRUE, FALSE);
329
330}
331
332
333/* Write configuration to user */
334
335void irdp_config_write (struct vty *vty, struct interface *ifp)
336{
337 struct zebra_if *zi=ifp->info;
338 struct irdp_interface *irdp=&zi->irdp;
339 struct Adv *adv;
paul0c0f9112004-09-24 08:24:42 +0000340 struct listnode *node;
hassoca776982004-06-12 14:33:05 +0000341
342 if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) {
343
344 if( irdp->flags & IF_SHUTDOWN)
345 vty_out (vty, " ip irdp shutdown %s", VTY_NEWLINE);
346
347 if( irdp->flags & IF_BROADCAST)
348 vty_out (vty, " ip irdp broadcast%s", VTY_NEWLINE);
349 else
350 vty_out (vty, " ip irdp multicast%s", VTY_NEWLINE);
351
352 vty_out (vty, " ip irdp preference %ld%s",
353 irdp->Preference, VTY_NEWLINE);
354
paul0c0f9112004-09-24 08:24:42 +0000355 LIST_LOOP (irdp->AdvPrefList, adv, node)
356 vty_out (vty, " ip irdp address %s preference %d%s",
357 inet_2a(adv->ip.s_addr, b1),
358 adv->pref,
359 VTY_NEWLINE);
hassoca776982004-06-12 14:33:05 +0000360
361 vty_out (vty, " ip irdp holdtime %d%s",
362 irdp->Lifetime, VTY_NEWLINE);
363
364 vty_out (vty, " ip irdp minadvertinterval %ld%s",
365 irdp->MinAdvertInterval, VTY_NEWLINE);
366
367 vty_out (vty, " ip irdp maxadvertinterval %ld%s",
368 irdp->MaxAdvertInterval, VTY_NEWLINE);
369
370 }
371}
372
373
374DEFUN (ip_irdp_multicast,
375 ip_irdp_multicast_cmd,
376 "ip irdp multicast",
377 IP_STR
378 "ICMP Router discovery on this interface using multicast\n")
379{
380 struct interface *ifp;
381
382 ifp = (struct interface *) vty->index;
383 if(!ifp) {
384 return CMD_WARNING;
385 }
386
387 irdp_if_start(ifp, TRUE, TRUE);
388 return CMD_SUCCESS;
389}
390
391DEFUN (ip_irdp_broadcast,
392 ip_irdp_broadcast_cmd,
393 "ip irdp broadcast",
394 IP_STR
395 "ICMP Router discovery on this interface using broadcast\n")
396{
397 struct interface *ifp;
398
399 ifp = (struct interface *) vty->index;
400 if(!ifp) {
401 return CMD_WARNING;
402 }
403
404 irdp_if_start(ifp, FALSE, TRUE);
405 return CMD_SUCCESS;
406}
407
hasso996933f2004-07-12 16:32:56 +0000408DEFUN (no_ip_irdp,
409 no_ip_irdp_cmd,
hassoca776982004-06-12 14:33:05 +0000410 "no ip irdp",
hasso8d0f15f2004-09-11 16:33:28 +0000411 NO_STR
hassoca776982004-06-12 14:33:05 +0000412 IP_STR
413 "Disable ICMP Router discovery on this interface\n")
414{
415 struct interface *ifp;
416
417 ifp = (struct interface *) vty->index;
418 if(!ifp) {
419 return CMD_WARNING;
420 }
421
422 irdp_if_stop(ifp);
423 return CMD_SUCCESS;
424}
425
426DEFUN (ip_irdp_shutdown,
427 ip_irdp_shutdown_cmd,
428 "ip irdp shutdown",
429 IP_STR
430 "ICMP Router discovery shutdown on this interface\n")
431{
432 struct interface *ifp;
433
434 ifp = (struct interface *) vty->index;
435 if(!ifp) {
436 return CMD_WARNING;
437 }
438
439 irdp_if_shutdown(ifp);
440 return CMD_SUCCESS;
441}
442
hasso996933f2004-07-12 16:32:56 +0000443DEFUN (no_ip_irdp_shutdown,
444 no_ip_irdp_shutdown_cmd,
hassoca776982004-06-12 14:33:05 +0000445 "no ip irdp shutdown",
hasso8d0f15f2004-09-11 16:33:28 +0000446 NO_STR
hassoca776982004-06-12 14:33:05 +0000447 IP_STR
448 "ICMP Router discovery no shutdown on this interface\n")
449{
450 struct interface *ifp;
451
452 ifp = (struct interface *) vty->index;
453 if(!ifp) {
454 return CMD_WARNING;
455 }
456
457 irdp_if_no_shutdown(ifp);
458 return CMD_SUCCESS;
459}
460
461DEFUN (ip_irdp_holdtime,
462 ip_irdp_holdtime_cmd,
463 "ip irdp holdtime <0-9000>",
464 IP_STR
465 "ICMP Router discovery on this interface\n"
466 "Set holdtime value\n"
467 "Holdtime value in seconds. Default is 1800 seconds\n")
468{
469 struct interface *ifp;
470 struct zebra_if *zi;
471 struct irdp_interface *irdp;
472 ifp = (struct interface *) vty->index;
473 if(!ifp) {
474 return CMD_WARNING;
475 }
476
477 zi=ifp->info;
478 irdp=&zi->irdp;
479
480 irdp->Lifetime = atoi(argv[0]);
481 return CMD_SUCCESS;
482}
483
484DEFUN (ip_irdp_minadvertinterval,
485 ip_irdp_minadvertinterval_cmd,
486 "ip irdp minadvertinterval <3-1800>",
487 IP_STR
488 "ICMP Router discovery on this interface\n"
489 "Set minimum time between advertisement\n"
490 "Minimum advertisement interval in seconds\n")
491{
492 struct interface *ifp;
493 struct zebra_if *zi;
494 struct irdp_interface *irdp;
495 ifp = (struct interface *) vty->index;
496 if(!ifp) {
497 return CMD_WARNING;
498 }
499
500 zi=ifp->info;
501 irdp=&zi->irdp;
502
hasso39db97e2004-10-12 20:50:58 +0000503 if( (unsigned) atoi(argv[0]) <= irdp->MaxAdvertInterval) {
hassoca776982004-06-12 14:33:05 +0000504 irdp->MinAdvertInterval = atoi(argv[0]);
505
506 return CMD_SUCCESS;
507 }
508
509 vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
510 VTY_NEWLINE);
511
512 vty_out (vty, "Please correct!%s",
513 VTY_NEWLINE);
514 return CMD_WARNING;
515}
516
517DEFUN (ip_irdp_maxadvertinterval,
518 ip_irdp_maxadvertinterval_cmd,
519 "ip irdp maxadvertinterval <4-1800>",
520 IP_STR
521 "ICMP Router discovery on this interface\n"
522 "Set maximum time between advertisement\n"
523 "Maximum advertisement interval in seconds\n")
524{
525 struct interface *ifp;
526 struct zebra_if *zi;
527 struct irdp_interface *irdp;
528 ifp = (struct interface *) vty->index;
529 if(!ifp) {
530 return CMD_WARNING;
531 }
532
533 zi=ifp->info;
534 irdp=&zi->irdp;
535
536
hasso39db97e2004-10-12 20:50:58 +0000537 if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[0]) ) {
hassoca776982004-06-12 14:33:05 +0000538 irdp->MaxAdvertInterval = atoi(argv[0]);
539
540 return CMD_SUCCESS;
541 }
542
543 vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
544 VTY_NEWLINE);
545
546 vty_out (vty, "Please correct!%s",
547 VTY_NEWLINE);
548 return CMD_WARNING;
549}
550
551DEFUN (ip_irdp_preference,
552 ip_irdp_preference_cmd,
553
554 /* DEFUN needs to be fixed for negative ranages...
555 Be positive for now. :-)
556
557 "ip irdp preference <-2147483648-2147483647>",
558 */
559
560
561 "ip irdp preference <0-2147483647>",
562 IP_STR
563 "ICMP Router discovery on this interface\n"
564 "Set default preference level for this interface\n"
565 "Preference level\n")
566{
567 struct interface *ifp;
568 struct zebra_if *zi;
569 struct irdp_interface *irdp;
570 ifp = (struct interface *) vty->index;
571 if(!ifp) {
572 return CMD_WARNING;
573 }
574
575 zi=ifp->info;
576 irdp=&zi->irdp;
577
578 irdp->Preference = atoi(argv[0]);
579 return CMD_SUCCESS;
580}
581
582DEFUN (ip_irdp_address_preference,
583 ip_irdp_address_preference_cmd,
584 "ip irdp address A.B.C.D preference <0-2147483647>",
585 IP_STR
586 "Alter ICMP Router discovery preference this interface\n"
587 "Specify IRDP non-default preference to advertise\n"
588 "Set IRDP address for advertise\n"
589 "Preference level\n")
590{
paul0c0f9112004-09-24 08:24:42 +0000591 struct listnode *node;
hassoca776982004-06-12 14:33:05 +0000592 struct in_addr ip;
593 int pref;
594 int ret;
595 struct interface *ifp;
596 struct zebra_if *zi;
597 struct irdp_interface *irdp;
598 struct Adv *adv;
599
600 ifp = (struct interface *) vty->index;
601 if(!ifp) {
602 return CMD_WARNING;
603 }
604
605 zi=ifp->info;
606 irdp=&zi->irdp;
607
608 ret = inet_aton(argv[0], &ip);
609 if(!ret) return CMD_WARNING;
610
611 pref = atoi(argv[1]);
612
paul0c0f9112004-09-24 08:24:42 +0000613 LIST_LOOP (irdp->AdvPrefList, adv, node)
614 if(adv->ip.s_addr == ip.s_addr)
615 return CMD_SUCCESS;
hassoca776982004-06-12 14:33:05 +0000616
617 adv = Adv_new();
618 adv->ip = ip;
619 adv->pref = pref;
620 listnode_add(irdp->AdvPrefList, adv);
621
622 return CMD_SUCCESS;
623
624}
625
hasso996933f2004-07-12 16:32:56 +0000626DEFUN (no_ip_irdp_address_preference,
627 no_ip_irdp_address_preference_cmd,
hassoca776982004-06-12 14:33:05 +0000628 "no ip irdp address A.B.C.D preference <0-2147483647>",
hasso8d0f15f2004-09-11 16:33:28 +0000629 NO_STR
hassoca776982004-06-12 14:33:05 +0000630 IP_STR
631 "Alter ICMP Router discovery preference this interface\n"
632 "Removes IRDP non-default preference\n"
633 "Select IRDP address\n"
634 "Old preference level\n")
635{
paul26f7a242004-09-24 08:45:10 +0000636 struct listnode *node, *nnode;
hassoca776982004-06-12 14:33:05 +0000637 struct in_addr ip;
638 int pref;
639 int ret;
640 struct interface *ifp;
641 struct zebra_if *zi;
642 struct irdp_interface *irdp;
643 struct Adv *adv;
644
645 ifp = (struct interface *) vty->index;
646 if(!ifp) {
647 return CMD_WARNING;
648 }
649
650 zi=ifp->info;
651 irdp=&zi->irdp;
652
653 ret = inet_aton(argv[0], &ip);
paul0c0f9112004-09-24 08:24:42 +0000654 if (!ret)
655 return CMD_WARNING;
hassoca776982004-06-12 14:33:05 +0000656
657 pref = atoi(argv[1]);
658
paul0c0f9112004-09-24 08:24:42 +0000659 for (node = listhead (irdp->AdvPrefList); node; node = nnode)
660 {
661 nnode = node->next;
662 adv = getdata (node);
663
664 if(adv->ip.s_addr == ip.s_addr )
665 {
666 listnode_delete(irdp->AdvPrefList, adv);
667 break;
668 }
669 }
670
hassoca776982004-06-12 14:33:05 +0000671 return CMD_SUCCESS;
hassoca776982004-06-12 14:33:05 +0000672}
673
674DEFUN (ip_irdp_debug_messages,
675 ip_irdp_debug_messages_cmd,
676 "ip irdp debug messages",
677 IP_STR
678 "ICMP Router discovery debug Averts. and Solicits (short)\n")
679{
680 struct interface *ifp;
681 struct zebra_if *zi;
682 struct irdp_interface *irdp;
683 ifp = (struct interface *) vty->index;
684 if(!ifp) {
685 return CMD_WARNING;
686 }
687
688 zi=ifp->info;
689 irdp=&zi->irdp;
690
691 irdp->flags |= IF_DEBUG_MESSAGES;
692
693 return CMD_SUCCESS;
694}
695
696DEFUN (ip_irdp_debug_misc,
697 ip_irdp_debug_misc_cmd,
698 "ip irdp debug misc",
699 IP_STR
700 "ICMP Router discovery debug Averts. and Solicits (short)\n")
701{
702 struct interface *ifp;
703 struct zebra_if *zi;
704 struct irdp_interface *irdp;
705 ifp = (struct interface *) vty->index;
706 if(!ifp) {
707 return CMD_WARNING;
708 }
709
710 zi=ifp->info;
711 irdp=&zi->irdp;
712
713 irdp->flags |= IF_DEBUG_MISC;
714
715 return CMD_SUCCESS;
716}
717
718DEFUN (ip_irdp_debug_packet,
719 ip_irdp_debug_packet_cmd,
720 "ip irdp debug packet",
721 IP_STR
722 "ICMP Router discovery debug Averts. and Solicits (short)\n")
723{
724 struct interface *ifp;
725 struct zebra_if *zi;
726 struct irdp_interface *irdp;
727 ifp = (struct interface *) vty->index;
728 if(!ifp) {
729 return CMD_WARNING;
730 }
731
732 zi=ifp->info;
733 irdp=&zi->irdp;
734
735 irdp->flags |= IF_DEBUG_PACKET;
736
737 return CMD_SUCCESS;
738}
739
740
741DEFUN (ip_irdp_debug_disable,
742 ip_irdp_debug_disable_cmd,
743 "ip irdp debug disable",
744 IP_STR
745 "ICMP Router discovery debug Averts. and Solicits (short)\n")
746{
747 struct interface *ifp;
748 struct zebra_if *zi;
749 struct irdp_interface *irdp;
750 ifp = (struct interface *) vty->index;
751 if(!ifp) {
752 return CMD_WARNING;
753 }
754
755 zi=ifp->info;
756 irdp=&zi->irdp;
757
758 irdp->flags &= ~IF_DEBUG_PACKET;
759 irdp->flags &= ~IF_DEBUG_MESSAGES;
760 irdp->flags &= ~IF_DEBUG_MISC;
761
762 return CMD_SUCCESS;
763}
764
765void
766irdp_if_init ()
767{
768 install_element (INTERFACE_NODE, &ip_irdp_broadcast_cmd);
769 install_element (INTERFACE_NODE, &ip_irdp_multicast_cmd);
hasso996933f2004-07-12 16:32:56 +0000770 install_element (INTERFACE_NODE, &no_ip_irdp_cmd);
hassoca776982004-06-12 14:33:05 +0000771 install_element (INTERFACE_NODE, &ip_irdp_shutdown_cmd);
hasso996933f2004-07-12 16:32:56 +0000772 install_element (INTERFACE_NODE, &no_ip_irdp_shutdown_cmd);
hassoca776982004-06-12 14:33:05 +0000773 install_element (INTERFACE_NODE, &ip_irdp_holdtime_cmd);
774 install_element (INTERFACE_NODE, &ip_irdp_maxadvertinterval_cmd);
775 install_element (INTERFACE_NODE, &ip_irdp_minadvertinterval_cmd);
776 install_element (INTERFACE_NODE, &ip_irdp_preference_cmd);
777 install_element (INTERFACE_NODE, &ip_irdp_address_preference_cmd);
hasso996933f2004-07-12 16:32:56 +0000778 install_element (INTERFACE_NODE, &no_ip_irdp_address_preference_cmd);
hassoca776982004-06-12 14:33:05 +0000779
780 install_element (INTERFACE_NODE, &ip_irdp_debug_messages_cmd);
781 install_element (INTERFACE_NODE, &ip_irdp_debug_misc_cmd);
782 install_element (INTERFACE_NODE, &ip_irdp_debug_packet_cmd);
783 install_element (INTERFACE_NODE, &ip_irdp_debug_disable_cmd);
784}
785
786#endif /* HAVE_IRDP */