summaryrefslogtreecommitdiffstats
path: root/zebra/irdp_interface.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2016-10-18 01:36:21 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2016-10-18 01:36:21 +0200
commite52702f29d003585dcfbb4914b2a52d77a177739 (patch)
tree3e130ded38c48316796bfb602dc6fe6d119129d2 /zebra/irdp_interface.c
parentospf6d: fix a few vty help strings (diff)
parentvtysh: fix build failure in vtysh_writeconfig_integrated() (diff)
downloadfrr-e52702f29d003585dcfbb4914b2a52d77a177739.tar.xz
frr-e52702f29d003585dcfbb4914b2a52d77a177739.zip
Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Conflicts: bgpd/bgp_route.c bgpd/bgp_routemap.c bgpd/bgp_vty.c isisd/isis_redist.c isisd/isis_routemap.c isisd/isis_vty.c isisd/isisd.c lib/command.c lib/distribute.c lib/if.c lib/keychain.c lib/routemap.c lib/routemap.h ospf6d/ospf6_asbr.c ospf6d/ospf6_interface.c ospf6d/ospf6_neighbor.c ospf6d/ospf6_top.c ospf6d/ospf6_zebra.c ospf6d/ospf6d.c ospfd/ospf_routemap.c ospfd/ospf_vty.c ripd/rip_routemap.c ripngd/ripng_routemap.c vtysh/extract.pl.in vtysh/vtysh.c zebra/interface.c zebra/irdp_interface.c zebra/rt_netlink.c zebra/rtadv.c zebra/test_main.c zebra/zebra_routemap.c zebra/zebra_vty.c
Diffstat (limited to 'zebra/irdp_interface.c')
-rw-r--r--zebra/irdp_interface.c187
1 files changed, 60 insertions, 127 deletions
diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c
index 2f741380f..3e244f5af 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -18,17 +18,17 @@
* You should have received a copy of the GNU General Public License
* along with GNU Zebra; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * 02111-1307, USA.
*/
-/*
+/*
* This work includes work with the following copywrite:
*
* Copyright (C) 1997, 2000 Kunihiro Ishiguro
*
*/
-/*
+/*
* Thanks to Jens Låås at Swedish University of Agricultural Sciences
* for reviewing and tests.
*/
@@ -36,7 +36,7 @@
#include <zebra.h>
-#ifdef HAVE_IRDP
+#ifdef HAVE_IRDP
#include "if.h"
#include "vty.h"
@@ -81,7 +81,7 @@ irdp_get_prefix(struct interface *ifp)
{
struct listnode *node;
struct connected *ifc;
-
+
if (ifp->connected)
for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
return ifc->address;
@@ -91,9 +91,9 @@ irdp_get_prefix(struct interface *ifp)
/* Join to the add/leave multicast group. */
static int
-if_group (struct interface *ifp,
- int sock,
- u_int32_t group,
+if_group (struct interface *ifp,
+ int sock,
+ u_int32_t group,
int add_leave)
{
struct ip_mreq m;
@@ -116,7 +116,7 @@ if_group (struct interface *ifp,
(char *) &m, sizeof (struct ip_mreq));
if (ret < 0)
zlog_warn ("IRDP: %s can't setsockopt %s: %s",
- add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group",
+ add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group",
inet_2a(group, b1),
safe_strerror (errno));
@@ -137,7 +137,7 @@ if_add_group (struct interface *ifp)
}
if(irdp->flags & IF_DEBUG_MISC )
- zlog_debug("IRDP: Adding group %s for %s",
+ zlog_debug("IRDP: Adding group %s for %s",
inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1),
ifp->name);
return 0;
@@ -156,7 +156,7 @@ if_drop_group (struct interface *ifp)
return ret;
if(irdp->flags & IF_DEBUG_MISC)
- zlog_debug("IRDP: Leaving group %s for %s",
+ zlog_debug("IRDP: Leaving group %s for %s",
inet_2a(htonl(INADDR_ALLRTRS_GROUP), b1),
ifp->name);
return 0;
@@ -206,7 +206,7 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
}
irdp->flags |= IF_ACTIVE;
- if(!multicast)
+ if(!multicast)
irdp->flags |= IF_BROADCAST;
if_add_update(ifp);
@@ -219,13 +219,13 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
if( multicast) {
if_add_group(ifp);
-
+
if (! (ifp->flags & (IFF_MULTICAST|IFF_ALLMULTI))) {
zlog_warn("IRDP: Interface not multicast enabled %s", ifp->name);
}
}
- if(set_defaults)
+ if(set_defaults)
if_set_defaults(ifp);
irdp->irdp_sent = 0;
@@ -239,9 +239,9 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
seed = ifc->address->u.prefix4.s_addr;
break;
}
-
+
srandom(seed);
- timer = (random () % IRDP_DEFAULT_INTERVAL) + 1;
+ timer = (random () % IRDP_DEFAULT_INTERVAL) + 1;
irdp->AdvPrefList = list_new();
irdp->AdvPrefList->del = (void (*)(void *)) Adv_free; /* Destructor */
@@ -250,18 +250,18 @@ irdp_if_start(struct interface *ifp, int multicast, int set_defaults)
/* And this for startup. Speed limit from 1991 :-). But it's OK*/
if(irdp->irdp_sent < MAX_INITIAL_ADVERTISEMENTS &&
- timer > MAX_INITIAL_ADVERT_INTERVAL )
+ timer > MAX_INITIAL_ADVERT_INTERVAL )
timer= MAX_INITIAL_ADVERT_INTERVAL;
-
+
if(irdp->flags & IF_DEBUG_MISC)
- zlog_debug("IRDP: Init timer for %s set to %u",
- ifp->name,
+ zlog_debug("IRDP: Init timer for %s set to %u",
+ ifp->name,
timer);
- irdp->t_advertise = thread_add_timer(zebrad.master,
- irdp_send_thread,
- ifp,
+ irdp->t_advertise = thread_add_timer(zebrad.master,
+ irdp_send_thread,
+ ifp,
timer);
}
@@ -270,7 +270,7 @@ irdp_if_stop(struct interface *ifp)
{
struct zebra_if *zi=ifp->info;
struct irdp_interface *irdp=&zi->irdp;
-
+
if (irdp == NULL) {
zlog_warn ("Interface %s structure is NULL", ifp->name);
return;
@@ -281,7 +281,7 @@ irdp_if_stop(struct interface *ifp)
return;
}
- if(! (irdp->flags & IF_BROADCAST))
+ if(! (irdp->flags & IF_BROADCAST))
if_drop_group(ifp);
irdp_advert_off(ifp);
@@ -307,9 +307,9 @@ irdp_if_shutdown(struct interface *ifp)
irdp->flags |= IF_SHUTDOWN;
irdp->flags &= ~IF_ACTIVE;
- if(! (irdp->flags & IF_BROADCAST))
+ if(! (irdp->flags & IF_BROADCAST))
if_drop_group(ifp);
-
+
/* Tell the hosts we are out of service */
irdp_advert_off(ifp);
}
@@ -327,7 +327,7 @@ irdp_if_no_shutdown(struct interface *ifp)
irdp->flags &= ~IF_SHUTDOWN;
- irdp_if_start(ifp, irdp->flags & IF_BROADCAST? FALSE : TRUE, FALSE);
+ irdp_if_start(ifp, irdp->flags & IF_BROADCAST? FALSE : TRUE, FALSE);
}
@@ -344,30 +344,30 @@ void irdp_config_write (struct vty *vty, struct interface *ifp)
if(irdp->flags & IF_ACTIVE || irdp->flags & IF_SHUTDOWN) {
- if( irdp->flags & IF_SHUTDOWN)
+ if( irdp->flags & IF_SHUTDOWN)
vty_out (vty, " ip irdp shutdown %s", VTY_NEWLINE);
- if( irdp->flags & IF_BROADCAST)
+ if( irdp->flags & IF_BROADCAST)
vty_out (vty, " ip irdp broadcast%s", VTY_NEWLINE);
- else
+ else
vty_out (vty, " ip irdp multicast%s", VTY_NEWLINE);
- vty_out (vty, " ip irdp preference %ld%s",
+ vty_out (vty, " ip irdp preference %ld%s",
irdp->Preference, VTY_NEWLINE);
for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
vty_out (vty, " ip irdp address %s preference %d%s",
inet_2a(adv->ip.s_addr, b1),
- adv->pref,
+ adv->pref,
VTY_NEWLINE);
- vty_out (vty, " ip irdp holdtime %d%s",
+ vty_out (vty, " ip irdp holdtime %d%s",
irdp->Lifetime, VTY_NEWLINE);
- vty_out (vty, " ip irdp minadvertinterval %ld%s",
+ vty_out (vty, " ip irdp minadvertinterval %ld%s",
irdp->MinAdvertInterval, VTY_NEWLINE);
- vty_out (vty, " ip irdp maxadvertinterval %ld%s",
+ vty_out (vty, " ip irdp maxadvertinterval %ld%s",
irdp->MaxAdvertInterval, VTY_NEWLINE);
}
@@ -380,12 +380,7 @@ DEFUN (ip_irdp_multicast,
IP_STR
"ICMP Router discovery on this interface using multicast\n")
{
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT (interface, ifp);
irdp_if_start(ifp, TRUE, TRUE);
return CMD_SUCCESS;
@@ -397,12 +392,7 @@ DEFUN (ip_irdp_broadcast,
IP_STR
"ICMP Router discovery on this interface using broadcast\n")
{
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT (interface, ifp);
irdp_if_start(ifp, FALSE, TRUE);
return CMD_SUCCESS;
@@ -415,12 +405,7 @@ DEFUN (no_ip_irdp,
IP_STR
"Disable ICMP Router discovery on this interface\n")
{
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT (interface, ifp);
irdp_if_stop(ifp);
return CMD_SUCCESS;
@@ -432,12 +417,7 @@ DEFUN (ip_irdp_shutdown,
IP_STR
"ICMP Router discovery shutdown on this interface\n")
{
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT (interface, ifp);
irdp_if_shutdown(ifp);
return CMD_SUCCESS;
@@ -450,12 +430,7 @@ DEFUN (no_ip_irdp_shutdown,
IP_STR
"ICMP Router discovery no shutdown on this interface\n")
{
- struct interface *ifp;
-
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
+ VTY_DECLVAR_CONTEXT (interface, ifp);
irdp_if_no_shutdown(ifp);
return CMD_SUCCESS;
@@ -470,13 +445,9 @@ DEFUN (ip_irdp_holdtime,
"Holdtime value in seconds. Default is 1800 seconds\n")
{
int idx_number = 3;
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct zebra_if *zi;
struct irdp_interface *irdp;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
zi=ifp->info;
irdp=&zi->irdp;
@@ -494,13 +465,9 @@ DEFUN (ip_irdp_minadvertinterval,
"Minimum advertisement interval in seconds\n")
{
int idx_number = 3;
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct zebra_if *zi;
struct irdp_interface *irdp;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
zi=ifp->info;
irdp=&zi->irdp;
@@ -511,10 +478,10 @@ DEFUN (ip_irdp_minadvertinterval,
return CMD_SUCCESS;
}
- vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
+ vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
VTY_NEWLINE);
- vty_out (vty, "Please correct!%s",
+ vty_out (vty, "Please correct!%s",
VTY_NEWLINE);
return CMD_WARNING;
}
@@ -528,13 +495,9 @@ DEFUN (ip_irdp_maxadvertinterval,
"Maximum advertisement interval in seconds\n")
{
int idx_number = 3;
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct zebra_if *zi;
struct irdp_interface *irdp;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
zi=ifp->info;
irdp=&zi->irdp;
@@ -546,10 +509,10 @@ DEFUN (ip_irdp_maxadvertinterval,
return CMD_SUCCESS;
}
- vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
+ vty_out (vty, "ICMP warning maxadvertinterval is greater or equal than minadvertinterval%s",
VTY_NEWLINE);
- vty_out (vty, "Please correct!%s",
+ vty_out (vty, "Please correct!%s",
VTY_NEWLINE);
return CMD_WARNING;
}
@@ -568,13 +531,9 @@ DEFUN (ip_irdp_preference,
"Preference level\n")
{
int idx_number = 3;
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct zebra_if *zi;
struct irdp_interface *irdp;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
zi=ifp->info;
irdp=&zi->irdp;
@@ -594,20 +553,15 @@ DEFUN (ip_irdp_address_preference,
{
int idx_ipv4 = 3;
int idx_number = 5;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct listnode *node;
- struct in_addr ip;
+ struct in_addr ip;
int pref;
int ret;
- struct interface *ifp;
struct zebra_if *zi;
struct irdp_interface *irdp;
struct Adv *adv;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
-
zi=ifp->info;
irdp=&zi->irdp;
@@ -617,7 +571,7 @@ DEFUN (ip_irdp_address_preference,
pref = atoi(argv[idx_number]->arg);
for (ALL_LIST_ELEMENTS_RO (irdp->AdvPrefList, node, adv))
- if(adv->ip.s_addr == ip.s_addr)
+ if(adv->ip.s_addr == ip.s_addr)
return CMD_SUCCESS;
adv = Adv_new();
@@ -640,24 +594,19 @@ DEFUN (no_ip_irdp_address_preference,
"Old preference level\n")
{
int idx_ipv4 = 4;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct listnode *node, *nnode;
- struct in_addr ip;
+ struct in_addr ip;
int ret;
- struct interface *ifp;
struct zebra_if *zi;
struct irdp_interface *irdp;
struct Adv *adv;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
-
zi=ifp->info;
irdp=&zi->irdp;
ret = inet_aton(argv[idx_ipv4]->arg, &ip);
- if (!ret)
+ if (!ret)
return CMD_WARNING;
for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv))
@@ -668,7 +617,7 @@ DEFUN (no_ip_irdp_address_preference,
break;
}
}
-
+
return CMD_SUCCESS;
}
@@ -678,13 +627,9 @@ DEFUN (ip_irdp_debug_messages,
IP_STR
"ICMP Router discovery debug Averts. and Solicits (short)\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct zebra_if *zi;
struct irdp_interface *irdp;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
zi=ifp->info;
irdp=&zi->irdp;
@@ -700,13 +645,9 @@ DEFUN (ip_irdp_debug_misc,
IP_STR
"ICMP Router discovery debug Averts. and Solicits (short)\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct zebra_if *zi;
struct irdp_interface *irdp;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
zi=ifp->info;
irdp=&zi->irdp;
@@ -722,13 +663,9 @@ DEFUN (ip_irdp_debug_packet,
IP_STR
"ICMP Router discovery debug Averts. and Solicits (short)\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct zebra_if *zi;
struct irdp_interface *irdp;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
zi=ifp->info;
irdp=&zi->irdp;
@@ -745,13 +682,9 @@ DEFUN (ip_irdp_debug_disable,
IP_STR
"ICMP Router discovery debug Averts. and Solicits (short)\n")
{
- struct interface *ifp;
+ VTY_DECLVAR_CONTEXT (interface, ifp);
struct zebra_if *zi;
struct irdp_interface *irdp;
- ifp = (struct interface *) vty->index;
- if(!ifp) {
- return CMD_WARNING;
- }
zi=ifp->info;
irdp=&zi->irdp;