Skip to content

Commit

Permalink
*: use vty_outln
Browse files Browse the repository at this point in the history
Saves 400 lines

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
  • Loading branch information
qlyoung committed Jun 29, 2017
1 parent 4d5f445 commit 96ade3e
Show file tree
Hide file tree
Showing 121 changed files with 4,177 additions and 4,545 deletions.
110 changes: 52 additions & 58 deletions babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ DEFUN (babel_network,
ret = babel_enable_if_add (argv[1]->arg);

if (ret < 0) {
vty_out (vty, "There is same network configuration %s%s", argv[1]->arg,
VTY_NEWLINE);
vty_outln (vty, "There is same network configuration %s",
argv[1]->arg);
return CMD_WARNING;
}

Expand All @@ -318,8 +318,7 @@ DEFUN (no_babel_network,
ret = babel_enable_if_delete (argv[2]->arg);

if (ret < 0) {
vty_out (vty, "can't find network %s%s", argv[2]->arg,
VTY_NEWLINE);
vty_outln (vty, "can't find network %s",argv[2]->arg);
return CMD_WARNING;
}

Expand Down Expand Up @@ -862,30 +861,31 @@ show_babel_interface_sub (struct vty *vty, struct interface *ifp)
int is_up;
babel_interface_nfo *babel_ifp;

vty_out (vty, "%s is %s%s", ifp->name,
((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
vty_out (vty, " ifindex %u, MTU %u bytes %s%s",
ifp->ifindex, MIN(ifp->mtu, ifp->mtu6), if_flag_dump(ifp->flags), VTY_NEWLINE);
vty_outln (vty, "%s is %s", ifp->name,
((is_up = if_is_operative(ifp)) ? "up" : "down"));
vty_outln (vty, " ifindex %u, MTU %u bytes %s",
ifp->ifindex, MIN(ifp->mtu, ifp->mtu6), if_flag_dump(ifp->flags));

if (!IS_ENABLE(ifp))
{
vty_out (vty, " Babel protocol is not enabled on this interface%s", VTY_NEWLINE);
vty_outln (vty, " Babel protocol is not enabled on this interface");
return;
}
if (!is_up)
{
vty_out (vty, " Babel protocol is enabled, but not running on this interface%s", VTY_NEWLINE);
vty_outln (vty,
" Babel protocol is enabled, but not running on this interface");
return;
}
babel_ifp = babel_get_if_nfo (ifp);
vty_out (vty, " Babel protocol is running on this interface%s", VTY_NEWLINE);
vty_out (vty, " Operating mode is \"%s\"%s",
CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED) ? "wired" : "wireless", VTY_NEWLINE);
vty_out (vty, " Split horizon mode is %s%s",
CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON) ? "On" : "Off", VTY_NEWLINE);
vty_out (vty, " Hello interval is %u ms%s", babel_ifp->hello_interval, VTY_NEWLINE);
vty_out (vty, " Update interval is %u ms%s", babel_ifp->update_interval, VTY_NEWLINE);
vty_out (vty, " Rxcost multiplier is %u%s", babel_ifp->cost, VTY_NEWLINE);
vty_outln (vty, " Babel protocol is running on this interface");
vty_outln (vty, " Operating mode is \"%s\"",
CHECK_FLAG(babel_ifp->flags, BABEL_IF_WIRED) ? "wired" : "wireless");
vty_outln (vty, " Split horizon mode is %s",
CHECK_FLAG(babel_ifp->flags, BABEL_IF_SPLIT_HORIZON) ? "On" : "Off");
vty_outln (vty, " Hello interval is %u ms", babel_ifp->hello_interval);
vty_outln (vty, " Update interval is %u ms", babel_ifp->update_interval);
vty_outln (vty, " Rxcost multiplier is %u", babel_ifp->cost);
}

DEFUN (show_babel_interface,
Expand All @@ -907,7 +907,7 @@ DEFUN (show_babel_interface,
}
if ((ifp = if_lookup_by_name (argv[3]->arg, VRF_DEFAULT)) == NULL)
{
vty_out (vty, "No such interface name%s", VTY_NEWLINE);
vty_outln (vty, "No such interface name");
return CMD_WARNING;
}
show_babel_interface_sub (vty, ifp);
Expand All @@ -917,18 +917,17 @@ DEFUN (show_babel_interface,
static void
show_babel_neighbour_sub (struct vty *vty, struct neighbour *neigh)
{
vty_out (vty,
vty_outln (vty,
"Neighbour %s dev %s reach %04x rxcost %d txcost %d "
"rtt %s rttcost %d%s.%s",
"rtt %s rttcost %d%s.",
format_address(neigh->address),
neigh->ifp->name,
neigh->reach,
neighbour_rxcost(neigh),
neigh->txcost,
format_thousands(neigh->rtt),
neighbour_rttcost(neigh),
if_up(neigh->ifp) ? "" : " (down)",
VTY_NEWLINE);
if_up(neigh->ifp) ? "" : " (down)");
}

DEFUN (show_babel_neighbour,
Expand All @@ -950,7 +949,7 @@ DEFUN (show_babel_neighbour,
}
if ((ifp = if_lookup_by_name (argv[3]->arg, VRF_DEFAULT)) == NULL)
{
vty_out (vty, "No such interface name%s", VTY_NEWLINE);
vty_outln (vty, "No such interface name");
return CMD_WARNING;
}
FOR_ALL_NEIGHBOURS(neigh) {
Expand Down Expand Up @@ -1010,9 +1009,9 @@ show_babel_routes_sub(struct babel_route *route, struct vty *vty,
channels[0] = '\0';
}

vty_out(vty,
vty_outln (vty,
"%s metric %d refmetric %d id %s seqno %d%s age %d "
"via %s neigh %s%s%s%s%s",
"via %s neigh %s%s%s%s",
format_prefix(route->src->prefix, route->src->plen),
route_metric(route), route->refmetric,
format_eui64(route->src->id),
Expand All @@ -1023,9 +1022,7 @@ show_babel_routes_sub(struct babel_route *route, struct vty *vty,
format_address(route->neigh->address),
nexthop ? " nexthop " : "",
nexthop ? format_address(nexthop) : "",
route->installed ? " (installed)" :
route_feasible(route) ? " (feasible)" : "",
VTY_NEWLINE);
route->installed ? " (installed)" : route_feasible(route) ? " (feasible)" : "");
}

static void
Expand All @@ -1035,10 +1032,9 @@ show_babel_xroutes_sub (struct xroute *xroute, struct vty *vty,
if(prefix && !babel_prefix_eq(prefix, xroute->prefix, xroute->plen))
return;

vty_out(vty, "%s metric %d (exported)%s",
vty_outln (vty, "%s metric %d (exported)",
format_prefix(xroute->prefix, xroute->plen),
xroute->metric,
VTY_NEWLINE);
xroute->metric);
}

DEFUN (show_babel_route,
Expand Down Expand Up @@ -1093,7 +1089,7 @@ DEFUN (show_babel_route_prefix,

ret = str2prefix(argv[3]->arg, &prefix);
if(ret == 0) {
vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
vty_outln (vty, "%% Malformed address");
return CMD_WARNING;
}

Expand Down Expand Up @@ -1142,7 +1138,7 @@ DEFUN (show_babel_route_addr,

ret = inet_aton (argv[3]->arg, &addr);
if (ret <= 0) {
vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
vty_outln (vty, "%% Malformed address");
return CMD_WARNING;
}

Expand All @@ -1151,7 +1147,7 @@ DEFUN (show_babel_route_addr,

ret = str2prefix(buf, &prefix);
if (ret == 0) {
vty_out (vty, "%% Parse error -- this shouldn't happen%s", VTY_NEWLINE);
vty_outln (vty, "%% Parse error -- this shouldn't happen");
return CMD_WARNING;
}

Expand Down Expand Up @@ -1200,7 +1196,7 @@ DEFUN (show_babel_route_addr6,

ret = inet_pton (AF_INET6, argv[3]->arg, &addr);
if (ret <= 0) {
vty_out (vty, "%% Malformed address%s", VTY_NEWLINE);
vty_outln (vty, "%% Malformed address");
return CMD_WARNING;
}

Expand All @@ -1210,7 +1206,7 @@ DEFUN (show_babel_route_addr6,

ret = str2prefix(buf, &prefix);
if (ret == 0) {
vty_out (vty, "%% Parse error -- this shouldn't happen%s", VTY_NEWLINE);
vty_outln (vty, "%% Parse error -- this shouldn't happen");
return CMD_WARNING;
}

Expand Down Expand Up @@ -1248,9 +1244,9 @@ DEFUN (show_babel_parameters,
"Babel information\n"
"Configuration information\n")
{
vty_out(vty, " -- Babel running configuration --%s", VTY_NEWLINE);
vty_outln (vty, " -- Babel running configuration --");
show_babel_main_configuration(vty);
vty_out(vty, " -- distribution lists --%s", VTY_NEWLINE);
vty_outln (vty, " -- distribution lists --");
config_show_distribute(vty);

return CMD_SUCCESS;
Expand Down Expand Up @@ -1325,65 +1321,63 @@ interface_config_write (struct vty *vty)
int write = 0;

for (ALL_LIST_ELEMENTS_RO (vrf_iflist(VRF_DEFAULT), node, ifp)) {
vty_out (vty, "interface %s%s", ifp->name,
VTY_NEWLINE);
vty_outln (vty, "interface %s",ifp->name);
if (ifp->desc)
vty_out (vty, " description %s%s", ifp->desc,
VTY_NEWLINE);
vty_outln (vty, " description %s",ifp->desc);
babel_interface_nfo *babel_ifp = babel_get_if_nfo (ifp);
/* wireless is the default*/
if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED))
{
vty_out (vty, " babel wired%s", VTY_NEWLINE);
vty_outln (vty, " babel wired");
write++;
}
if (babel_ifp->hello_interval != BABEL_DEFAULT_HELLO_INTERVAL)
{
vty_out (vty, " babel hello-interval %u%s", babel_ifp->hello_interval, VTY_NEWLINE);
vty_outln (vty, " babel hello-interval %u",
babel_ifp->hello_interval);
write++;
}
if (babel_ifp->update_interval != BABEL_DEFAULT_UPDATE_INTERVAL)
{
vty_out (vty, " babel update-interval %u%s", babel_ifp->update_interval, VTY_NEWLINE);
vty_outln (vty, " babel update-interval %u",
babel_ifp->update_interval);
write++;
}
/* Some parameters have different defaults for wired/wireless. */
if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_WIRED)) {
if (!CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON)) {
vty_out (vty, " no babel split-horizon%s", VTY_NEWLINE);
vty_outln (vty, " no babel split-horizon");
write++;
}
if (babel_ifp->cost != BABEL_DEFAULT_RXCOST_WIRED) {
vty_out (vty, " babel rxcost %u%s", babel_ifp->cost, VTY_NEWLINE);
vty_outln (vty, " babel rxcost %u", babel_ifp->cost);
write++;
}
if (babel_ifp->channel == BABEL_IF_CHANNEL_INTERFERING) {
vty_out (vty, " babel channel interfering%s", VTY_NEWLINE);
vty_outln (vty, " babel channel interfering");
write++;
} else if(babel_ifp->channel != BABEL_IF_CHANNEL_NONINTERFERING) {
vty_out (vty, " babel channel %d%s", babel_ifp->channel,
VTY_NEWLINE);
vty_outln (vty, " babel channel %d",babel_ifp->channel);
write++;
}
} else {
if (CHECK_FLAG (babel_ifp->flags, BABEL_IF_SPLIT_HORIZON)) {
vty_out (vty, " babel split-horizon%s", VTY_NEWLINE);
vty_outln (vty, " babel split-horizon");
write++;
}
if (babel_ifp->cost != BABEL_DEFAULT_RXCOST_WIRELESS) {
vty_out (vty, " babel rxcost %u%s", babel_ifp->cost, VTY_NEWLINE);
vty_outln (vty, " babel rxcost %u", babel_ifp->cost);
write++;
}
if (babel_ifp->channel == BABEL_IF_CHANNEL_NONINTERFERING) {
vty_out (vty, " babel channel noninterfering%s", VTY_NEWLINE);
vty_outln (vty, " babel channel noninterfering");
write++;
} else if(babel_ifp->channel != BABEL_IF_CHANNEL_INTERFERING) {
vty_out (vty, " babel channel %d%s", babel_ifp->channel,
VTY_NEWLINE);
vty_outln (vty, " babel channel %d",babel_ifp->channel);
write++;
}
}
vty_out (vty, "!%s", VTY_NEWLINE);
vty_outln (vty, "!");
write++;
}
return write;
Expand All @@ -1399,7 +1393,7 @@ babel_enable_if_config_write (struct vty * vty)
for (i = 0; i < vector_active (babel_enable_if); i++)
if ((str = vector_slot (babel_enable_if, i)) != NULL)
{
vty_out (vty, " network %s%s", str, VTY_NEWLINE);
vty_outln (vty, " network %s", str);
lines++;
}
return lines;
Expand Down
6 changes: 3 additions & 3 deletions babeld/babel_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ babel_save_state_file(void)
void
show_babel_main_configuration (struct vty *vty)
{
vty_out(vty,
vty_outln (vty,
"state file = %s%s"
"configuration file = %s%s"
"protocol informations:%s"
Expand All @@ -386,7 +386,7 @@ show_babel_main_configuration (struct vty *vty)
"vty address = %s%s"
"vty port = %d%s"
"id = %s%s"
"kernel_metric = %d%s",
"kernel_metric = %d",
state_file, VTY_NEWLINE,
babel_config_file ? babel_config_file : babel_config_default,
VTY_NEWLINE,
Expand All @@ -397,5 +397,5 @@ show_babel_main_configuration (struct vty *vty)
VTY_NEWLINE,
babel_vty_port, VTY_NEWLINE,
format_eui64(myid), VTY_NEWLINE,
kernel_metric, VTY_NEWLINE);
kernel_metric);
}
20 changes: 10 additions & 10 deletions babeld/babel_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ DEFUN (babel_redistribute_type,
type = babel_proto_redistnum(argv[1]->arg);

if (type < 0) {
vty_out(vty, "Invalid type %s%s", argv[1]->arg, VTY_NEWLINE);
vty_outln (vty, "Invalid type %s", argv[1]->arg);
return CMD_WARNING;
}

Expand All @@ -243,7 +243,7 @@ DEFUN (no_babel_redistribute_type,
type = babel_proto_redistnum(argv[2]->arg);

if (type < 0) {
vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE);
vty_outln (vty, "Invalid type %s", argv[2]->arg);
return CMD_WARNING;
}

Expand Down Expand Up @@ -277,7 +277,7 @@ DEFUN (debug_babel,
}
}

vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE);
vty_outln (vty, "Invalid type %s", argv[2]->arg);

return CMD_WARNING;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ DEFUN (no_debug_babel,
}
}

vty_out(vty, "Invalid type %s%s", argv[3]->arg, VTY_NEWLINE);
vty_outln (vty, "Invalid type %s", argv[3]->arg);

return CMD_WARNING;
}
Expand All @@ -324,7 +324,7 @@ debug_babel_config_write (struct vty * vty)

if (debug == BABEL_DEBUG_ALL)
{
vty_out (vty, "debug babel all%s", VTY_NEWLINE);
vty_outln (vty, "debug babel all");
lines++;
}
else
Expand All @@ -335,12 +335,12 @@ debug_babel_config_write (struct vty * vty)
&& CHECK_FLAG (debug, debug_type[i].type)
)
{
vty_out (vty, "debug babel %s%s", debug_type[i].str, VTY_NEWLINE);
vty_outln (vty, "debug babel %s", debug_type[i].str);
lines++;
}
if (lines)
{
vty_out (vty, "!%s", VTY_NEWLINE);
vty_outln (vty, "!");
lines++;
}
return lines;
Expand Down Expand Up @@ -384,13 +384,13 @@ zebra_config_write (struct vty *vty)
{
if (! zclient->enable)
{
vty_out (vty, "no router zebra%s", VTY_NEWLINE);
vty_outln (vty, "no router zebra");
return 1;
}
else if (! vrf_bitmap_check (zclient->redist[AFI_IP][ZEBRA_ROUTE_BABEL], VRF_DEFAULT))
{
vty_out (vty, "router zebra%s", VTY_NEWLINE);
vty_out (vty, " no redistribute babel%s", VTY_NEWLINE);
vty_outln (vty, "router zebra");
vty_outln (vty, " no redistribute babel");
return 1;
}
return 0;
Expand Down
Loading

0 comments on commit 96ade3e

Please sign in to comment.