* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
- * 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.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
void
ospf6_route_zebra_copy_nexthops (struct ospf6_route *route,
- unsigned int *ifindexes,
+ ifindex_t *ifindexes,
struct in6_addr **nexthop_addr,
int entries)
{
{
if (IS_OSPF6_DEBUG_ZEBRA (SEND))
{
- char ifname[IFNAMSIZ];
+ const char *ifname;
inet_ntop (AF_INET6, &nh->address, buf, sizeof (buf));
- if (!if_indextoname(nh->ifindex, ifname))
- strlcpy(ifname, "unknown", sizeof(ifname));
+ ifname = ifindex2ifname (nh->ifindex, VRF_DEFAULT);
zlog_debug (" nexthop: %s%%%.*s(%d)", buf, IFNAMSIZ, ifname,
nh->ifindex);
}
route_table_assert (struct ospf6_route_table *table)
{
struct ospf6_route *prev, *r, *next;
- char buf[64];
+ char buf[PREFIX2STR_BUFFER];
unsigned int link_error = 0, num = 0;
r = ospf6_route_head (table);
struct route_node *node, *nextnode, *prevnode;
struct ospf6_route *current = NULL;
struct ospf6_route *prev = NULL, *old = NULL, *next = NULL;
- char buf[64];
+ char buf[PREFIX2STR_BUFFER];
struct timeval now;
assert (route->rnode == NULL);
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_debug ("%s %p: route add %p: %s", ospf6_route_table_name (table),
- table, route, buf);
+ (void *)table, (void *)route, buf);
else if (IS_OSPF6_DEBUG_ROUTE (TABLE))
zlog_debug ("%s: route add: %s", ospf6_route_table_name (table), buf);
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
node = route_node_get (table->table, &route->prefix);
route->rnode = node;
{
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_debug ("%s %p: route add %p: needless update of %p",
- ospf6_route_table_name (table), table, route, old);
+ ospf6_route_table_name (table),
+ (void *)table, (void *)route, (void *)old);
else if (IS_OSPF6_DEBUG_ROUTE (TABLE))
zlog_debug ("%s: route add: needless update",
ospf6_route_table_name (table));
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_debug ("%s %p: route add %p: update of %p",
- ospf6_route_table_name (table), table, route, old);
+ ospf6_route_table_name (table),
+ (void *)table, (void *)route, (void *)old);
else if (IS_OSPF6_DEBUG_ROUTE (TABLE))
zlog_debug ("%s: route add: update",
ospf6_route_table_name (table));
{
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_debug ("%s %p: route add %p: another path: prev %p, next %p",
- ospf6_route_table_name (table), table, route, prev, next);
+ ospf6_route_table_name (table),
+ (void *)table, (void *)route, (void *)prev, (void *)next);
else if (IS_OSPF6_DEBUG_ROUTE (TABLE))
zlog_debug ("%s: route add: another path found",
ospf6_route_table_name (table));
SET_FLAG (route->flag, OSPF6_ROUTE_BEST);
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_info ("%s %p: route add %p: replacing previous best: %p",
- ospf6_route_table_name (table), table, route, next);
+ ospf6_route_table_name (table),
+ (void *)table, (void *)route, (void *)next);
}
route->installed = now;
/* Else, this is the brand new route regarding to the prefix */
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_debug ("%s %p: route add %p: brand new route",
- ospf6_route_table_name (table), table, route);
+ ospf6_route_table_name (table), (void *)table, (void *)route);
else if (IS_OSPF6_DEBUG_ROUTE (TABLE))
zlog_debug ("%s: route add: brand new route",
ospf6_route_table_name (table));
{
struct route_node *node;
struct ospf6_route *current;
- char buf[64];
+ char buf[PREFIX2STR_BUFFER];
if (route->type == OSPF6_DEST_TYPE_LINKSTATE)
ospf6_linkstate_prefix2str (&route->prefix, buf, sizeof (buf));
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_debug ("%s %p: route remove %p: %s",
- ospf6_route_table_name (table), table, route, buf);
+ ospf6_route_table_name (table),
+ (void *)table, (void *)route, buf);
else if (IS_OSPF6_DEBUG_ROUTE (TABLE))
zlog_debug ("%s: route remove: %s", ospf6_route_table_name (table), buf);
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_info ("%s %p: route head: %p<-[%p]->%p",
- ospf6_route_table_name (table), table,
- route->prev, route, route->next);
+ ospf6_route_table_name (table), (void *)table,
+ (void *)route->prev, (void *)route, (void *)route->next);
return route;
}
if (IS_OSPF6_DEBUG_ROUTE (MEMORY))
zlog_info ("%s %p: route next: %p<-[%p]->%p",
- ospf6_route_table_name (route->table), route->table,
- route->prev, route, route->next);
+ ospf6_route_table_name (route->table), (void *)route->table,
+ (void *)route->prev, (void *)route, (void *)route->next);
ospf6_route_unlock (route);
if (next)
ospf6_route_show (struct vty *vty, struct ospf6_route *route)
{
int i;
- char destination[64], nexthop[64];
- char duration[16], ifname[IFNAMSIZ];
+ char destination[PREFIX2STR_BUFFER], nexthop[64];
+ char duration[16];
+ const char *ifname;
struct timeval now, res;
struct listnode *node;
struct ospf6_nexthop *nh;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
timersub (&now, &route->changed, &res);
timerstring (&res, duration, sizeof (duration));
else
prefix2str (&route->prefix, destination, sizeof (destination));
-
i = 0;
for (ALL_LIST_ELEMENTS_RO (route->nh_list, node, nh))
{
/* nexthop */
inet_ntop (AF_INET6, &nh->address, nexthop,
sizeof (nexthop));
- if (! if_indextoname (nh->ifindex, ifname))
- snprintf (ifname, sizeof (ifname), "%d", nh->ifindex);
+ ifname = ifindex2ifname (nh->ifindex, VRF_DEFAULT);
if (!i)
{
void
ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route)
{
- char destination[64], nexthop[64], ifname[IFNAMSIZ];
+ const char *ifname;
+ char destination[PREFIX2STR_BUFFER], nexthop[64];
char area_id[16], id[16], adv_router[16], capa[16], options[16];
struct timeval now, res;
char duration[16];
struct listnode *node;
struct ospf6_nexthop *nh;
- quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
+ monotime(&now);
/* destination */
if (route->type == OSPF6_DEST_TYPE_LINKSTATE)
(CHECK_FLAG (route->flag, OSPF6_ROUTE_CHANGE) ? "C" : "-"),
VNL);
vty_out (vty, "Memory: prev: %p this: %p next: %p%s",
- route->prev, route, route->next, VNL);
+ (void *)route->prev, (void *)route, (void *)route->next, VNL);
/* Path section */
{
/* nexthop */
inet_ntop (AF_INET6, &nh->address, nexthop, sizeof (nexthop));
- if (! if_indextoname (nh->ifindex, ifname))
- snprintf (ifname, sizeof (ifname), "%d", nh->ifindex);
+ ifname = ifindex2ifname (nh->ifindex, VRF_DEFAULT);
vty_out (vty, " %s %.*s%s", nexthop, IFNAMSIZ, ifname, VNL);
}
vty_out (vty, "%s", VNL);
}
int
-ospf6_route_table_show (struct vty *vty, int argc, const char *argv[],
+ospf6_route_table_show (struct vty *vty, int argc_start, int argc, struct cmd_token **argv,
struct ospf6_route_table *table)
{
int summary = 0;
memset (&prefix, 0, sizeof (struct prefix));
- for (i = 0; i < argc; i++)
+ for (i = argc_start; i < argc; i++)
{
- if (! strcmp (argv[i], "summary"))
+ if (! strcmp (argv[i]->arg, "summary"))
{
summary++;
continue;
}
- if (! strcmp (argv[i], "intra-area"))
+ if (! strcmp (argv[i]->arg, "intra-area"))
{
type = OSPF6_PATH_TYPE_INTRA;
continue;
}
- if (! strcmp (argv[i], "inter-area"))
+ if (! strcmp (argv[i]->arg, "inter-area"))
{
type = OSPF6_PATH_TYPE_INTER;
continue;
}
- if (! strcmp (argv[i], "external-1"))
+ if (! strcmp (argv[i]->arg, "external-1"))
{
type = OSPF6_PATH_TYPE_EXTERNAL1;
continue;
}
- if (! strcmp (argv[i], "external-2"))
+ if (! strcmp (argv[i]->arg, "external-2"))
{
type = OSPF6_PATH_TYPE_EXTERNAL2;
continue;
}
- if (! strcmp (argv[i], "detail"))
+ if (! strcmp (argv[i]->arg, "detail"))
{
detail++;
continue;
}
- if (! strcmp (argv[i], "match"))
+ if (! strcmp (argv[i]->arg, "match"))
{
match++;
continue;
}
- ret = str2prefix (argv[i], &prefix);
+ ret = str2prefix (argv[i]->arg, &prefix);
if (ret == 1 && prefix.family == AF_INET6)
{
isprefix++;
- if (strchr (argv[i], '/'))
+ if (strchr (argv[i]->arg, '/'))
slash++;
continue;
}
- vty_out (vty, "Malformed argument: %s%s", argv[i], VNL);
+ vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL);
return CMD_SUCCESS;
}
}
int
-ospf6_linkstate_table_show (struct vty *vty, int argc, const char *argv[],
+ospf6_linkstate_table_show (struct vty *vty, int idx_ipv4, int argc,
+ struct cmd_token **argv,
struct ospf6_route_table *table)
{
int detail = 0;
memset (&id, 0, sizeof (struct prefix));
memset (&prefix, 0, sizeof (struct prefix));
- for (i = 0; i < argc; i++)
+ for (i = idx_ipv4; i < argc; i++)
{
- if (! strcmp (argv[i], "detail"))
+ if (! strcmp (argv[i]->arg, "detail"))
{
detail++;
continue;
if (! is_router)
{
- ret = str2prefix (argv[i], &router);
+ ret = str2prefix (argv[i]->arg, &router);
if (ret == 1 && router.family == AF_INET)
{
is_router++;
continue;
}
- vty_out (vty, "Malformed argument: %s%s", argv[i], VNL);
+ vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL);
return CMD_SUCCESS;
}
if (! is_id)
{
- ret = str2prefix (argv[i], &id);
+ ret = str2prefix (argv[i]->arg, &id);
if (ret == 1 && id.family == AF_INET)
{
is_id++;
continue;
}
- vty_out (vty, "Malformed argument: %s%s", argv[i], VNL);
+ vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL);
return CMD_SUCCESS;
}
- vty_out (vty, "Malformed argument: %s%s", argv[i], VNL);
+ vty_out (vty, "Malformed argument: %s%s", argv[i]->arg, VNL);
return CMD_SUCCESS;
}
DEFUN (debug_ospf6_route,
debug_ospf6_route_cmd,
- "debug ospf6 route (table|intra-area|inter-area|memory)",
+ "debug ospf6 route <table|intra-area|inter-area|memory>",
DEBUG_STR
OSPF6_STR
+ "Debug routes\n"
"Debug route table calculation\n"
- "Debug detail\n"
"Debug intra-area route calculation\n"
"Debug inter-area route calculation\n"
"Debug route memory use\n"
)
{
+ int idx_type = 3;
unsigned char level = 0;
- if (! strncmp (argv[0], "table", 5))
+ if (! strncmp (argv[idx_type]->arg, "table", 5))
level = OSPF6_DEBUG_ROUTE_TABLE;
- else if (! strncmp (argv[0], "intra", 5))
+ else if (! strncmp (argv[idx_type]->arg, "intra", 5))
level = OSPF6_DEBUG_ROUTE_INTRA;
- else if (! strncmp (argv[0], "inter", 5))
+ else if (! strncmp (argv[idx_type]->arg, "inter", 5))
level = OSPF6_DEBUG_ROUTE_INTER;
- else if (! strncmp (argv[0], "memor", 5))
+ else if (! strncmp (argv[idx_type]->arg, "memor", 5))
level = OSPF6_DEBUG_ROUTE_MEMORY;
OSPF6_DEBUG_ROUTE_ON (level);
return CMD_SUCCESS;
DEFUN (no_debug_ospf6_route,
no_debug_ospf6_route_cmd,
- "no debug ospf6 route (table|intra-area|inter-area|memory)",
+ "no debug ospf6 route <table|intra-area|inter-area|memory>",
NO_STR
DEBUG_STR
OSPF6_STR
+ "Debug routes\n"
"Debug route table calculation\n"
"Debug intra-area route calculation\n"
+ "Debug inter-area route calculation\n"
"Debug route memory use\n")
{
+ int idx_type = 4;
unsigned char level = 0;
- if (! strncmp (argv[0], "table", 5))
+ if (! strncmp (argv[idx_type]->arg, "table", 5))
level = OSPF6_DEBUG_ROUTE_TABLE;
- else if (! strncmp (argv[0], "intra", 5))
+ else if (! strncmp (argv[idx_type]->arg, "intra", 5))
level = OSPF6_DEBUG_ROUTE_INTRA;
- else if (! strncmp (argv[0], "inter", 5))
+ else if (! strncmp (argv[idx_type]->arg, "inter", 5))
level = OSPF6_DEBUG_ROUTE_INTER;
- else if (! strncmp (argv[0], "memor", 5))
+ else if (! strncmp (argv[idx_type]->arg, "memor", 5))
level = OSPF6_DEBUG_ROUTE_MEMORY;
OSPF6_DEBUG_ROUTE_OFF (level);
return CMD_SUCCESS;