diff options
Diffstat (limited to 'zebra/rtadv.c')
| -rw-r--r-- | zebra/rtadv.c | 153 |
1 files changed, 47 insertions, 106 deletions
diff --git a/zebra/rtadv.c b/zebra/rtadv.c index ac297890a5..3e0a198702 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -871,10 +871,8 @@ DEFUN (ipv6_nd_suppress_ra, "Neighbor discovery\n" "Suppress Router Advertisement\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = vty->index; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; if (if_is_loopback (ifp) || CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK)) @@ -884,7 +882,6 @@ DEFUN (ipv6_nd_suppress_ra, } ipv6_nd_suppress_ra_set (ifp, RA_SUPPRESS); - zif = ifp->info; zif->rtadv.configured = 0; return CMD_SUCCESS; } @@ -897,10 +894,8 @@ DEFUN (no_ipv6_nd_suppress_ra, "Neighbor discovery\n" "Suppress Router Advertisement\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = vty->index; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; if (if_is_loopback (ifp) || CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK)) @@ -910,7 +905,6 @@ DEFUN (no_ipv6_nd_suppress_ra, } ipv6_nd_suppress_ra_set (ifp, RA_ENABLE); - zif = ifp->info; zif->rtadv.configured = 1; return CMD_SUCCESS; } @@ -923,8 +917,8 @@ DEFUN (ipv6_nd_ra_interval_msec, "Router Advertisement interval\n" "Router Advertisement interval in milliseconds\n") { + VTY_DECLVAR_CONTEXT (interface, ifp); unsigned interval; - struct interface *ifp = (struct interface *) vty->index; struct zebra_if *zif = ifp->info; struct zebra_vrf *zvrf = vrf_info_lookup (ifp->vrf_id); struct zebra_ns *zns; @@ -958,8 +952,8 @@ DEFUN (ipv6_nd_ra_interval, "Router Advertisement interval\n" "Router Advertisement interval in seconds\n") { + VTY_DECLVAR_CONTEXT (interface, ifp); unsigned interval; - struct interface *ifp = (struct interface *) vty->index; struct zebra_if *zif = ifp->info; struct zebra_vrf *zvrf = vrf_info_lookup (ifp->vrf_id); struct zebra_ns *zns; @@ -993,13 +987,11 @@ DEFUN (no_ipv6_nd_ra_interval, "Neighbor discovery\n" "Router Advertisement interval\n") { - struct interface *ifp; - struct zebra_if *zif; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; struct zebra_vrf *zvrf; struct zebra_ns *zns; - ifp = (struct interface *) vty->index; - zif = ifp->info; zvrf = vrf_info_lookup (ifp->vrf_id); zns = zvrf->zns; @@ -1038,12 +1030,9 @@ DEFUN (ipv6_nd_ra_lifetime, "Router lifetime\n" "Router lifetime in seconds (0 stands for a non-default gw)\n") { + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; int lifetime; - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; VTY_GET_INTEGER_RANGE ("router lifetime", lifetime, argv[0], 0, 9000); @@ -1070,11 +1059,8 @@ DEFUN (no_ipv6_nd_ra_lifetime, "Neighbor discovery\n" "Router lifetime\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvDefaultLifetime = -1; @@ -1098,7 +1084,7 @@ DEFUN (ipv6_nd_reachable_time, "Reachable time\n" "Reachable time in milliseconds\n") { - struct interface *ifp = (struct interface *) vty->index; + VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; VTY_GET_INTEGER_RANGE ("reachable time", zif->rtadv.AdvReachableTime, argv[0], 1, RTADV_MAX_REACHABLE_TIME); return CMD_SUCCESS; @@ -1112,11 +1098,8 @@ DEFUN (no_ipv6_nd_reachable_time, "Neighbor discovery\n" "Reachable time\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvReachableTime = 0; @@ -1140,7 +1123,7 @@ DEFUN (ipv6_nd_homeagent_preference, "Home Agent preference\n" "preference value (default is 0, least preferred)\n") { - struct interface *ifp = (struct interface *) vty->index; + VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; VTY_GET_INTEGER_RANGE ("home agent preference", zif->rtadv.HomeAgentPreference, argv[0], 0, 65535); return CMD_SUCCESS; @@ -1154,11 +1137,8 @@ DEFUN (no_ipv6_nd_homeagent_preference, "Neighbor discovery\n" "Home Agent preference\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.HomeAgentPreference = 0; @@ -1182,7 +1162,7 @@ DEFUN (ipv6_nd_homeagent_lifetime, "Home Agent lifetime\n" "Home Agent lifetime in seconds (0 to track ra-lifetime)\n") { - struct interface *ifp = (struct interface *) vty->index; + VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; VTY_GET_INTEGER_RANGE ("home agent lifetime", zif->rtadv.HomeAgentLifetime, argv[0], 0, RTADV_MAX_HALIFETIME); return CMD_SUCCESS; @@ -1196,11 +1176,8 @@ DEFUN (no_ipv6_nd_homeagent_lifetime, "Neighbor discovery\n" "Home Agent lifetime\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.HomeAgentLifetime = -1; @@ -1223,11 +1200,8 @@ DEFUN (ipv6_nd_managed_config_flag, "Neighbor discovery\n" "Managed address configuration flag\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvManagedFlag = 1; @@ -1242,11 +1216,8 @@ DEFUN (no_ipv6_nd_managed_config_flag, "Neighbor discovery\n" "Managed address configuration flag\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvManagedFlag = 0; @@ -1260,11 +1231,8 @@ DEFUN (ipv6_nd_homeagent_config_flag, "Neighbor discovery\n" "Home Agent configuration flag\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvHomeAgentFlag = 1; @@ -1279,11 +1247,8 @@ DEFUN (no_ipv6_nd_homeagent_config_flag, "Neighbor discovery\n" "Home Agent configuration flag\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvHomeAgentFlag = 0; @@ -1297,11 +1262,8 @@ DEFUN (ipv6_nd_adv_interval_config_option, "Neighbor discovery\n" "Advertisement Interval Option\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvIntervalOption = 1; @@ -1316,11 +1278,8 @@ DEFUN (no_ipv6_nd_adv_interval_config_option, "Neighbor discovery\n" "Advertisement Interval Option\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvIntervalOption = 0; @@ -1334,11 +1293,8 @@ DEFUN (ipv6_nd_other_config_flag, "Neighbor discovery\n" "Other statefull configuration flag\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvOtherConfigFlag = 1; @@ -1353,11 +1309,8 @@ DEFUN (no_ipv6_nd_other_config_flag, "Neighbor discovery\n" "Other statefull configuration flag\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.AdvOtherConfigFlag = 0; @@ -1380,16 +1333,13 @@ DEFUN (ipv6_nd_prefix, "Do not use prefix for autoconfiguration\n" "Set Router Address flag\n") { + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zebra_if = ifp->info; int i; int ret; int cursor = 1; - struct interface *ifp; - struct zebra_if *zebra_if; struct rtadv_prefix rp; - ifp = (struct interface *) vty->index; - zebra_if = ifp->info; - ret = str2prefix_ipv6 (argv[0], &rp.prefix); if (!ret) { @@ -1611,14 +1561,11 @@ DEFUN (no_ipv6_nd_prefix, "Prefix information\n" "IPv6 prefix\n") { + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zebra_if = ifp->info; int ret; - struct interface *ifp; - struct zebra_if *zebra_if; struct rtadv_prefix rp; - ifp = (struct interface *) vty->index; - zebra_if = ifp->info; - ret = str2prefix_ipv6 (argv[0], &rp.prefix); if (!ret) { @@ -1801,13 +1748,10 @@ DEFUN (ipv6_nd_router_preference, "Low default router preference\n" "Medium default router preference (default)\n") { - struct interface *ifp; - struct zebra_if *zif; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; int i = 0; - ifp = (struct interface *) vty->index; - zif = ifp->info; - while (0 != rtadv_pref_strs[i]) { if (strncmp (argv[0], rtadv_pref_strs[i], 1) == 0) @@ -1829,11 +1773,8 @@ DEFUN (no_ipv6_nd_router_preference, "Neighbor discovery\n" "Default router preference\n") { - struct interface *ifp; - struct zebra_if *zif; - - ifp = (struct interface *) vty->index; - zif = ifp->info; + VTY_DECLVAR_CONTEXT (interface, ifp); + struct zebra_if *zif = ifp->info; zif->rtadv.DefaultPreference = RTADV_PREF_MEDIUM; /* Default per RFC4191. */ @@ -1859,7 +1800,7 @@ DEFUN (ipv6_nd_mtu, "Advertised MTU\n" "MTU in bytes\n") { - struct interface *ifp = (struct interface *) vty->index; + VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; VTY_GET_INTEGER_RANGE ("MTU", zif->rtadv.AdvLinkMTU, argv[0], 1, 65535); return CMD_SUCCESS; @@ -1873,7 +1814,7 @@ DEFUN (no_ipv6_nd_mtu, "Neighbor discovery\n" "Advertised MTU\n") { - struct interface *ifp = (struct interface *) vty->index; + VTY_DECLVAR_CONTEXT (interface, ifp); struct zebra_if *zif = ifp->info; zif->rtadv.AdvLinkMTU = 0; return CMD_SUCCESS; |
