Annotation of embedaddon/quagga/zebra/irdp_interface.c, revision 1.1
1.1 ! misho 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: /*
! 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. */
! 66: extern struct zebra_t zebrad;
! 67:
! 68: extern int irdp_sock;
! 69:
! 70: static const char *
! 71: inet_2a(u_int32_t a, char *b)
! 72: {
! 73: sprintf(b, "%u.%u.%u.%u",
! 74: (a ) & 0xFF,
! 75: (a>> 8) & 0xFF,
! 76: (a>>16) & 0xFF,
! 77: (a>>24) & 0xFF);
! 78: return b;
! 79: }
! 80:
! 81:
! 82: static struct prefix *
! 83: irdp_get_prefix(struct interface *ifp)
! 84: {
! 85: struct listnode *node;
! 86: struct connected *ifc;
! 87:
! 88: if (ifp->connected)
! 89: for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
! 90: return ifc->address;
! 91:
! 92: return NULL;
! 93: }
! 94:
! 95: /* Join to the add/leave multicast group. */
! 96: static int
! 97: if_group (struct interface *ifp,
! 98: int sock,
! 99: u_int32_t group,
! 100: int add_leave)
! 101: {
! 102: struct zebra_if *zi;
! 103: struct ip_mreq m;
! 104: struct prefix *p;
! 105: int ret;
! 106: char b1[INET_ADDRSTRLEN];
! 107:
! 108: zi = ifp->info;
! 109:
! 110: memset (&m, 0, sizeof (m));
! 111: m.imr_multiaddr.s_addr = htonl (group);
! 112: p = irdp_get_prefix(ifp);
! 113:
! 114: if(!p) {
! 115: zlog_warn ("IRDP: can't get address for %s", ifp->name);
! 116: return 1;
! 117: }
! 118:
! 119: m.imr_interface = p->u.prefix4;
! 120:
! 121: ret = setsockopt (sock, IPPROTO_IP, add_leave,
! 122: (char *) &m, sizeof (struct ip_mreq));
! 123: if (ret < 0)
! 124: zlog_warn ("IRDP: %s can't setsockopt %s: %s",
! 125: add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group",
! 126: inet_2a(group, b1),
! 127: safe_strerror (errno));
! 128:
! 129: return ret;
! 130: }
! 131:
! 132: static int
! 133: if_add_group (struct interface *ifp)
! 134: {
! 135: struct zebra_if *zi= ifp->info;
! 136: struct irdp_interface *irdp = &zi->irdp;
! 137: int ret;
! 138: char b1[INET_ADDRSTRLEN];
! 139:
! 140: ret = if_group (ifp, irdp_sock, INADDR_ALLRTRS_GROUP, IP_ADD_MEMBERSHIP);
! 141: if (ret < 0) {
! 142: return ret;
! 143: }
! 144:
! 145: if(irdp->flags & IF_DEBUG_MISC )
! 146: zlog_debug("IRDP: Adding group %s for %s",
! 147: inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1),
! 148: ifp->name);
! 149: return 0;
! 150: }
! 151:
! 152: static int
! 153: if_drop_group (struct interface *ifp)
! 154: {
! 155: struct zebra_if *zi= ifp->info;
! 156: struct irdp_interface *irdp = &zi->irdp;
! 157: int ret;
! 158: char b1[INET_ADDRSTRLEN];
! 159:
! 160: ret = if_group (ifp, irdp_sock, INADDR_ALLRTRS_GROUP, IP_DROP_MEMBERSHIP);
! 161: if (ret < 0)
! 162: return ret;
! 163:
! 164: if(irdp->flags & IF_DEBUG_MISC)
! 165: zlog_debug("IRDP: Leaving group %s for %s",
! 166: inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1),
! 167: ifp->name);
! 168: return 0;
! 169: }
! 170:
! 171: static void
! 172: if_set_defaults(struct interface *ifp)
! 173: {
! 174: struct zebra_if *zi=ifp->info;
! 175: struct irdp_interface *irdp=&zi->irdp;
! 176:
! 177: irdp->MaxAdvertInterval = IRDP_MAXADVERTINTERVAL;
! 178: irdp->MinAdvertInterval = IRDP_MINADVERTINTERVAL;
! 179: irdp->Preference = IRDP_PREFERENCE;
! 180: irdp->Lifetime = IRDP_LIFETIME;
! 181: }
! 182:
! 183:
! 184: static struct Adv *Adv_new (void)
! 185: {
! 186: return XCALLOC (MTYPE_TMP, sizeof (struct Adv));
! 187: }
! 188:
! 189: static void
! 190: Adv_free (struct Adv *adv)
! 191: {
! 192: XFREE (MTYPE_TMP, adv);
! 193: }
! 194:
! 195: static void
! 196: 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;
! 200: struct listnode *node;
! 201: struct connected *ifc;
! 202: u_int32_t timer, seed;
! 203:
! 204: if (irdp->flags & IF_ACTIVE ) {
! 205: zlog_warn("IRDP: Interface is already active %s", ifp->name);
! 206: return;
! 207: }
! 208: if ((irdp_sock < 0) && ((irdp_sock = irdp_sock_init()) < 0)) {
! 209: zlog_warn("IRDP: Cannot activate interface %s (cannot create "
! 210: "IRDP socket)", ifp->name);
! 211: return;
! 212: }
! 213: irdp->flags |= IF_ACTIVE;
! 214:
! 215: if(!multicast)
! 216: irdp->flags |= IF_BROADCAST;
! 217:
! 218: if_add_update(ifp);
! 219:
! 220: if (! (ifp->flags & IFF_UP)) {
! 221: zlog_warn("IRDP: Interface is down %s", ifp->name);
! 222: }
! 223:
! 224: /* Shall we cancel if_start if if_add_group fails? */
! 225:
! 226: if( multicast) {
! 227: if_add_group(ifp);
! 228:
! 229: if (! (ifp->flags & (IFF_MULTICAST|IFF_ALLMULTI))) {
! 230: zlog_warn("IRDP: Interface not multicast enabled %s", ifp->name);
! 231: }
! 232: }
! 233:
! 234: if(set_defaults)
! 235: if_set_defaults(ifp);
! 236:
! 237: irdp->irdp_sent = 0;
! 238:
! 239: /* The spec suggests this for randomness */
! 240:
! 241: seed = 0;
! 242: if( ifp->connected)
! 243: for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
! 244: {
! 245: seed = ifc->address->u.prefix4.s_addr;
! 246: break;
! 247: }
! 248:
! 249: srandom(seed);
! 250: timer = (random () % IRDP_DEFAULT_INTERVAL) + 1;
! 251:
! 252: irdp->AdvPrefList = list_new();
! 253: irdp->AdvPrefList->del = (void (*)(void *)) Adv_free; /* Destructor */
! 254:
! 255:
! 256: /* And this for startup. Speed limit from 1991 :-). But it's OK*/
! 257:
! 258: if(irdp->irdp_sent < MAX_INITIAL_ADVERTISEMENTS &&
! 259: timer > MAX_INITIAL_ADVERT_INTERVAL )
! 260: timer= MAX_INITIAL_ADVERT_INTERVAL;
! 261:
! 262:
! 263: if(irdp->flags & IF_DEBUG_MISC)
! 264: zlog_debug("IRDP: Init timer for %s set to %u",
! 265: ifp->name,
! 266: timer);
! 267:
! 268: irdp->t_advertise = thread_add_timer(zebrad.master,
! 269: irdp_send_thread,
! 270: ifp,
! 271: timer);
! 272: }
! 273:
! 274: static void
! 275: irdp_if_stop(struct interface *ifp)
! 276: {
! 277: struct zebra_if *zi=ifp->info;
! 278: struct irdp_interface *irdp=&zi->irdp;
! 279:
! 280: if (irdp == NULL) {
! 281: zlog_warn ("Interface %s structure is NULL", ifp->name);
! 282: return;
! 283: }
! 284:
! 285: if (! (irdp->flags & IF_ACTIVE )) {
! 286: zlog_warn("Interface is not active %s", ifp->name);
! 287: return;
! 288: }
! 289:
! 290: if(! (irdp->flags & IF_BROADCAST))
! 291: if_drop_group(ifp);
! 292:
! 293: irdp_advert_off(ifp);
! 294:
! 295: list_delete(irdp->AdvPrefList);
! 296: irdp->AdvPrefList=NULL;
! 297:
! 298: irdp->flags = 0;
! 299: }
! 300:
! 301:
! 302: static void
! 303: irdp_if_shutdown(struct interface *ifp)
! 304: {
! 305: struct zebra_if *zi= ifp->info;
! 306: struct irdp_interface *irdp = &zi->irdp;
! 307:
! 308: if (irdp->flags & IF_SHUTDOWN ) {
! 309: zlog_warn("IRDP: Interface is already shutdown %s", ifp->name);
! 310: return;
! 311: }
! 312:
! 313: irdp->flags |= IF_SHUTDOWN;
! 314: irdp->flags &= ~IF_ACTIVE;
! 315:
! 316: if(! (irdp->flags & IF_BROADCAST))
! 317: if_drop_group(ifp);
! 318:
! 319: /* Tell the hosts we are out of service */
! 320: irdp_advert_off(ifp);
! 321: }
! 322:
! 323: static void
! 324: irdp_if_no_shutdown(struct interface *ifp)
! 325: {
! 326: struct zebra_if *zi= ifp->info;
! 327: struct irdp_interface *irdp = &zi->irdp;
! 328:
! 329: if (! (irdp->flags & IF_SHUTDOWN )) {
! 330: zlog_warn("IRDP: Interface is not shutdown %s", ifp->name);
! 331: return;
! 332: }
! 333:
! 334: irdp->flags &= ~IF_SHUTDOWN;
! 335:
! 336: irdp_if_start(ifp, irdp->flags & IF_BROADCAST? FALSE : TRUE, FALSE);
! 337:
! 338: }
! 339:
! 340:
! 341: /* Write configuration to user */
! 342:
! 343: void irdp_config_write (struct vty *vty, struct interface *ifp)
! 344: {
! 345: struct zebra_if *zi=ifp->info;
! 346: struct irdp_interface *irdp=&zi->irdp;
! 347: struct Adv *adv;
! 348: struct listnode *node;
! 349: char b1[INET_ADDRSTRLEN];
! 350:
! 351: if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) {
! 352:
! 353: if( irdp->flags & IF_SHUTDOWN)
! 354: vty_out (vty, " ip irdp shutdown %s", VTY_NEWLINE);
! 355:
! 356: if( irdp->flags & IF_BROADCAST)
! 357: vty_out (vty, " ip irdp broadcast%s", VTY_NEWLINE);
! 358: else
! 359: vty_out (vty, " ip irdp multicast%s", VTY_NEWLINE);
! 360:
! 361: vty_out (vty, " ip irdp preference %ld%s",
! 362: irdp->Preference, VTY_NEWLINE);
! 363:
! 364: for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
! 365: vty_out (vty, " ip irdp address %s preference %d%s",
! 366: inet_2a(adv->ip.s_addr, b1),
! 367: adv->pref,
! 368: VTY_NEWLINE);
! 369:
! 370: vty_out (vty, " ip irdp holdtime %d%s",
! 371: irdp->Lifetime, VTY_NEWLINE);
! 372:
! 373: vty_out (vty, " ip irdp minadvertinterval %ld%s",
! 374: irdp->MinAdvertInterval, VTY_NEWLINE);
! 375:
! 376: vty_out (vty, " ip irdp maxadvertinterval %ld%s",
! 377: irdp->MaxAdvertInterval, VTY_NEWLINE);
! 378:
! 379: }
! 380: }
! 381:
! 382:
! 383: DEFUN (ip_irdp_multicast,
! 384: ip_irdp_multicast_cmd,
! 385: "ip irdp multicast",
! 386: IP_STR
! 387: "ICMP Router discovery on this interface using multicast\n")
! 388: {
! 389: struct interface *ifp;
! 390:
! 391: ifp = (struct interface *) vty->index;
! 392: if(!ifp) {
! 393: return CMD_WARNING;
! 394: }
! 395:
! 396: irdp_if_start(ifp, TRUE, TRUE);
! 397: return CMD_SUCCESS;
! 398: }
! 399:
! 400: DEFUN (ip_irdp_broadcast,
! 401: ip_irdp_broadcast_cmd,
! 402: "ip irdp broadcast",
! 403: IP_STR
! 404: "ICMP Router discovery on this interface using broadcast\n")
! 405: {
! 406: struct interface *ifp;
! 407:
! 408: ifp = (struct interface *) vty->index;
! 409: if(!ifp) {
! 410: return CMD_WARNING;
! 411: }
! 412:
! 413: irdp_if_start(ifp, FALSE, TRUE);
! 414: return CMD_SUCCESS;
! 415: }
! 416:
! 417: DEFUN (no_ip_irdp,
! 418: no_ip_irdp_cmd,
! 419: "no ip irdp",
! 420: NO_STR
! 421: IP_STR
! 422: "Disable ICMP Router discovery on this interface\n")
! 423: {
! 424: struct interface *ifp;
! 425:
! 426: ifp = (struct interface *) vty->index;
! 427: if(!ifp) {
! 428: return CMD_WARNING;
! 429: }
! 430:
! 431: irdp_if_stop(ifp);
! 432: return CMD_SUCCESS;
! 433: }
! 434:
! 435: DEFUN (ip_irdp_shutdown,
! 436: ip_irdp_shutdown_cmd,
! 437: "ip irdp shutdown",
! 438: IP_STR
! 439: "ICMP Router discovery shutdown on this interface\n")
! 440: {
! 441: struct interface *ifp;
! 442:
! 443: ifp = (struct interface *) vty->index;
! 444: if(!ifp) {
! 445: return CMD_WARNING;
! 446: }
! 447:
! 448: irdp_if_shutdown(ifp);
! 449: return CMD_SUCCESS;
! 450: }
! 451:
! 452: DEFUN (no_ip_irdp_shutdown,
! 453: no_ip_irdp_shutdown_cmd,
! 454: "no ip irdp shutdown",
! 455: NO_STR
! 456: IP_STR
! 457: "ICMP Router discovery no shutdown on this interface\n")
! 458: {
! 459: struct interface *ifp;
! 460:
! 461: ifp = (struct interface *) vty->index;
! 462: if(!ifp) {
! 463: return CMD_WARNING;
! 464: }
! 465:
! 466: irdp_if_no_shutdown(ifp);
! 467: return CMD_SUCCESS;
! 468: }
! 469:
! 470: DEFUN (ip_irdp_holdtime,
! 471: ip_irdp_holdtime_cmd,
! 472: "ip irdp holdtime <0-9000>",
! 473: IP_STR
! 474: "ICMP Router discovery on this interface\n"
! 475: "Set holdtime value\n"
! 476: "Holdtime value in seconds. Default is 1800 seconds\n")
! 477: {
! 478: struct interface *ifp;
! 479: struct zebra_if *zi;
! 480: struct irdp_interface *irdp;
! 481: ifp = (struct interface *) vty->index;
! 482: if(!ifp) {
! 483: return CMD_WARNING;
! 484: }
! 485:
! 486: zi=ifp->info;
! 487: irdp=&zi->irdp;
! 488:
! 489: irdp->Lifetime = atoi(argv[0]);
! 490: return CMD_SUCCESS;
! 491: }
! 492:
! 493: DEFUN (ip_irdp_minadvertinterval,
! 494: ip_irdp_minadvertinterval_cmd,
! 495: "ip irdp minadvertinterval <3-1800>",
! 496: IP_STR
! 497: "ICMP Router discovery on this interface\n"
! 498: "Set minimum time between advertisement\n"
! 499: "Minimum advertisement interval in seconds\n")
! 500: {
! 501: struct interface *ifp;
! 502: struct zebra_if *zi;
! 503: struct irdp_interface *irdp;
! 504: ifp = (struct interface *) vty->index;
! 505: if(!ifp) {
! 506: return CMD_WARNING;
! 507: }
! 508:
! 509: zi=ifp->info;
! 510: irdp=&zi->irdp;
! 511:
! 512: if( (unsigned) atoi(argv[0]) <= irdp->MaxAdvertInterval) {
! 513: irdp->MinAdvertInterval = atoi(argv[0]);
! 514:
! 515: return CMD_SUCCESS;
! 516: }
! 517:
! 518: vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
! 519: VTY_NEWLINE);
! 520:
! 521: vty_out (vty, "Please correct!%s",
! 522: VTY_NEWLINE);
! 523: return CMD_WARNING;
! 524: }
! 525:
! 526: DEFUN (ip_irdp_maxadvertinterval,
! 527: ip_irdp_maxadvertinterval_cmd,
! 528: "ip irdp maxadvertinterval <4-1800>",
! 529: IP_STR
! 530: "ICMP Router discovery on this interface\n"
! 531: "Set maximum time between advertisement\n"
! 532: "Maximum advertisement interval in seconds\n")
! 533: {
! 534: struct interface *ifp;
! 535: struct zebra_if *zi;
! 536: struct irdp_interface *irdp;
! 537: ifp = (struct interface *) vty->index;
! 538: if(!ifp) {
! 539: return CMD_WARNING;
! 540: }
! 541:
! 542: zi=ifp->info;
! 543: irdp=&zi->irdp;
! 544:
! 545:
! 546: if( irdp->MinAdvertInterval <= (unsigned) atoi(argv[0]) ) {
! 547: irdp->MaxAdvertInterval = atoi(argv[0]);
! 548:
! 549: return CMD_SUCCESS;
! 550: }
! 551:
! 552: vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
! 553: VTY_NEWLINE);
! 554:
! 555: vty_out (vty, "Please correct!%s",
! 556: VTY_NEWLINE);
! 557: return CMD_WARNING;
! 558: }
! 559:
! 560: /* DEFUN needs to be fixed for negative ranages...
! 561: * "ip irdp preference <-2147483648-2147483647>",
! 562: * Be positive for now. :-)
! 563: */
! 564:
! 565: DEFUN (ip_irdp_preference,
! 566: ip_irdp_preference_cmd,
! 567: "ip irdp preference <0-2147483647>",
! 568: IP_STR
! 569: "ICMP Router discovery on this interface\n"
! 570: "Set default preference level for this interface\n"
! 571: "Preference level\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:
! 581: zi=ifp->info;
! 582: irdp=&zi->irdp;
! 583:
! 584: irdp->Preference = atoi(argv[0]);
! 585: return CMD_SUCCESS;
! 586: }
! 587:
! 588: DEFUN (ip_irdp_address_preference,
! 589: ip_irdp_address_preference_cmd,
! 590: "ip irdp address A.B.C.D preference <0-2147483647>",
! 591: IP_STR
! 592: "Alter ICMP Router discovery preference this interface\n"
! 593: "Specify IRDP non-default preference to advertise\n"
! 594: "Set IRDP address for advertise\n"
! 595: "Preference level\n")
! 596: {
! 597: struct listnode *node;
! 598: struct in_addr ip;
! 599: int pref;
! 600: int ret;
! 601: struct interface *ifp;
! 602: struct zebra_if *zi;
! 603: struct irdp_interface *irdp;
! 604: struct Adv *adv;
! 605:
! 606: ifp = (struct interface *) vty->index;
! 607: if(!ifp) {
! 608: return CMD_WARNING;
! 609: }
! 610:
! 611: zi=ifp->info;
! 612: irdp=&zi->irdp;
! 613:
! 614: ret = inet_aton(argv[0], &ip);
! 615: if(!ret) return CMD_WARNING;
! 616:
! 617: pref = atoi(argv[1]);
! 618:
! 619: for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
! 620: if(adv->ip.s_addr == ip.s_addr)
! 621: return CMD_SUCCESS;
! 622:
! 623: adv = Adv_new();
! 624: adv->ip = ip;
! 625: adv->pref = pref;
! 626: listnode_add(irdp->AdvPrefList, adv);
! 627:
! 628: return CMD_SUCCESS;
! 629:
! 630: }
! 631:
! 632: DEFUN (no_ip_irdp_address_preference,
! 633: no_ip_irdp_address_preference_cmd,
! 634: "no ip irdp address A.B.C.D preference <0-2147483647>",
! 635: NO_STR
! 636: IP_STR
! 637: "Alter ICMP Router discovery preference this interface\n"
! 638: "Removes IRDP non-default preference\n"
! 639: "Select IRDP address\n"
! 640: "Old preference level\n")
! 641: {
! 642: struct listnode *node, *nnode;
! 643: struct in_addr ip;
! 644: int pref;
! 645: int ret;
! 646: struct interface *ifp;
! 647: struct zebra_if *zi;
! 648: struct irdp_interface *irdp;
! 649: struct Adv *adv;
! 650:
! 651: ifp = (struct interface *) vty->index;
! 652: if(!ifp) {
! 653: return CMD_WARNING;
! 654: }
! 655:
! 656: zi=ifp->info;
! 657: irdp=&zi->irdp;
! 658:
! 659: ret = inet_aton(argv[0], &ip);
! 660: if (!ret)
! 661: return CMD_WARNING;
! 662:
! 663: pref = atoi(argv[1]);
! 664:
! 665: for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv))
! 666: {
! 667: if(adv->ip.s_addr == ip.s_addr )
! 668: {
! 669: listnode_delete(irdp->AdvPrefList, adv);
! 670: break;
! 671: }
! 672: }
! 673:
! 674: return CMD_SUCCESS;
! 675: }
! 676:
! 677: DEFUN (ip_irdp_debug_messages,
! 678: ip_irdp_debug_messages_cmd,
! 679: "ip irdp debug messages",
! 680: IP_STR
! 681: "ICMP Router discovery debug Averts. and Solicits (short)\n")
! 682: {
! 683: struct interface *ifp;
! 684: struct zebra_if *zi;
! 685: struct irdp_interface *irdp;
! 686: ifp = (struct interface *) vty->index;
! 687: if(!ifp) {
! 688: return CMD_WARNING;
! 689: }
! 690:
! 691: zi=ifp->info;
! 692: irdp=&zi->irdp;
! 693:
! 694: irdp->flags |= IF_DEBUG_MESSAGES;
! 695:
! 696: return CMD_SUCCESS;
! 697: }
! 698:
! 699: DEFUN (ip_irdp_debug_misc,
! 700: ip_irdp_debug_misc_cmd,
! 701: "ip irdp debug misc",
! 702: IP_STR
! 703: "ICMP Router discovery debug Averts. and Solicits (short)\n")
! 704: {
! 705: struct interface *ifp;
! 706: struct zebra_if *zi;
! 707: struct irdp_interface *irdp;
! 708: ifp = (struct interface *) vty->index;
! 709: if(!ifp) {
! 710: return CMD_WARNING;
! 711: }
! 712:
! 713: zi=ifp->info;
! 714: irdp=&zi->irdp;
! 715:
! 716: irdp->flags |= IF_DEBUG_MISC;
! 717:
! 718: return CMD_SUCCESS;
! 719: }
! 720:
! 721: DEFUN (ip_irdp_debug_packet,
! 722: ip_irdp_debug_packet_cmd,
! 723: "ip irdp debug packet",
! 724: IP_STR
! 725: "ICMP Router discovery debug Averts. and Solicits (short)\n")
! 726: {
! 727: struct interface *ifp;
! 728: struct zebra_if *zi;
! 729: struct irdp_interface *irdp;
! 730: ifp = (struct interface *) vty->index;
! 731: if(!ifp) {
! 732: return CMD_WARNING;
! 733: }
! 734:
! 735: zi=ifp->info;
! 736: irdp=&zi->irdp;
! 737:
! 738: irdp->flags |= IF_DEBUG_PACKET;
! 739:
! 740: return CMD_SUCCESS;
! 741: }
! 742:
! 743:
! 744: DEFUN (ip_irdp_debug_disable,
! 745: ip_irdp_debug_disable_cmd,
! 746: "ip irdp debug disable",
! 747: IP_STR
! 748: "ICMP Router discovery debug Averts. and Solicits (short)\n")
! 749: {
! 750: struct interface *ifp;
! 751: struct zebra_if *zi;
! 752: struct irdp_interface *irdp;
! 753: ifp = (struct interface *) vty->index;
! 754: if(!ifp) {
! 755: return CMD_WARNING;
! 756: }
! 757:
! 758: zi=ifp->info;
! 759: irdp=&zi->irdp;
! 760:
! 761: irdp->flags &= ~IF_DEBUG_PACKET;
! 762: irdp->flags &= ~IF_DEBUG_MESSAGES;
! 763: irdp->flags &= ~IF_DEBUG_MISC;
! 764:
! 765: return CMD_SUCCESS;
! 766: }
! 767:
! 768: void
! 769: irdp_init ()
! 770: {
! 771: install_element (INTERFACE_NODE, &ip_irdp_broadcast_cmd);
! 772: install_element (INTERFACE_NODE, &ip_irdp_multicast_cmd);
! 773: install_element (INTERFACE_NODE, &no_ip_irdp_cmd);
! 774: install_element (INTERFACE_NODE, &ip_irdp_shutdown_cmd);
! 775: install_element (INTERFACE_NODE, &no_ip_irdp_shutdown_cmd);
! 776: install_element (INTERFACE_NODE, &ip_irdp_holdtime_cmd);
! 777: install_element (INTERFACE_NODE, &ip_irdp_maxadvertinterval_cmd);
! 778: install_element (INTERFACE_NODE, &ip_irdp_minadvertinterval_cmd);
! 779: install_element (INTERFACE_NODE, &ip_irdp_preference_cmd);
! 780: install_element (INTERFACE_NODE, &ip_irdp_address_preference_cmd);
! 781: install_element (INTERFACE_NODE, &no_ip_irdp_address_preference_cmd);
! 782:
! 783: install_element (INTERFACE_NODE, &ip_irdp_debug_messages_cmd);
! 784: install_element (INTERFACE_NODE, &ip_irdp_debug_misc_cmd);
! 785: install_element (INTERFACE_NODE, &ip_irdp_debug_packet_cmd);
! 786: install_element (INTERFACE_NODE, &ip_irdp_debug_disable_cmd);
! 787: }
! 788:
! 789: #endif /* HAVE_IRDP */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>