mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-07 01:21:54 +00:00
show route flowspec: wrap lines
This commit is contained in:
parent
f5d4593b56
commit
5f507ad42d
@ -1086,7 +1086,7 @@ net_format_flow_bitmask(buffer *b, const byte *part)
|
||||
}
|
||||
|
||||
static uint
|
||||
net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6)
|
||||
net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6, const char *sep)
|
||||
{
|
||||
buffer b = {
|
||||
.start = buf,
|
||||
@ -1098,13 +1098,13 @@ net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6)
|
||||
*buf = 0;
|
||||
|
||||
if (ipv6)
|
||||
buffer_puts(&b, "flow6 { ");
|
||||
buffer_puts(&b, "flow6 {");
|
||||
else
|
||||
buffer_puts(&b, "flow4 { ");
|
||||
buffer_puts(&b, "flow4 {");
|
||||
|
||||
while (part)
|
||||
{
|
||||
buffer_print(&b, "%s ", flow_type_str(*part, ipv6));
|
||||
buffer_print(&b, "%s%s ", sep, flow_type_str(*part, ipv6));
|
||||
|
||||
switch (*part)
|
||||
{
|
||||
@ -1132,7 +1132,7 @@ net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6)
|
||||
part = flow_next_part(part, data+dlen, ipv6);
|
||||
}
|
||||
|
||||
buffer_puts(&b, "}");
|
||||
buffer_print(&b, "%s}", sep);
|
||||
|
||||
if (b.pos == b.end)
|
||||
{
|
||||
@ -1154,9 +1154,9 @@ net_format_flow(char *buf, uint blen, const byte *data, uint dlen, int ipv6)
|
||||
* ' ...}' sequence and zero-terminator.
|
||||
*/
|
||||
uint
|
||||
flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f)
|
||||
flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f, const char *sep)
|
||||
{
|
||||
return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow4), 0);
|
||||
return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow4), 0, sep);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1170,7 +1170,7 @@ flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f)
|
||||
* ' ...}' sequence and zero-terminator.
|
||||
*/
|
||||
uint
|
||||
flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f)
|
||||
flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f, const char *sep)
|
||||
{
|
||||
return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow6), 1);
|
||||
return net_format_flow(buf, blen, f->data, f->length - sizeof(net_addr_flow6), 1, sep);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ void flow6_validate_cf(net_addr_flow6 *f);
|
||||
* Net Formatting
|
||||
*/
|
||||
|
||||
uint flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f);
|
||||
uint flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f);
|
||||
uint flow4_net_format(char *buf, uint blen, const net_addr_flow4 *f, const char *sep);
|
||||
uint flow6_net_format(char *buf, uint blen, const net_addr_flow6 *f, const char *sep);
|
||||
|
||||
#endif /* _BIRD_FLOWSPEC_H_ */
|
||||
|
@ -99,9 +99,9 @@ net_format(const net_addr *N, char *buf, int buflen)
|
||||
case NET_ROA6:
|
||||
return bsnprintf(buf, buflen, "%I6/%u-%u AS%u", n->roa6.prefix, n->roa6.pxlen, n->roa6.max_pxlen, n->roa6.asn);
|
||||
case NET_FLOW4:
|
||||
return flow4_net_format(buf, buflen, &n->flow4);
|
||||
return flow4_net_format(buf, buflen, &n->flow4, " ");
|
||||
case NET_FLOW6:
|
||||
return flow6_net_format(buf, buflen, &n->flow6);
|
||||
return flow6_net_format(buf, buflen, &n->flow6, " ");
|
||||
case NET_MPLS:
|
||||
return bsnprintf(buf, buflen, "%u", n->mpls.label);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nest/cli.h"
|
||||
#include "nest/iface.h"
|
||||
#include "filter/filter.h"
|
||||
#include "lib/flowspec.h"
|
||||
|
||||
static void
|
||||
rt_show_table(struct cli *c, struct rt_show_data *d)
|
||||
@ -90,16 +91,26 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, ea_list *tm
|
||||
}
|
||||
|
||||
static void
|
||||
rt_show_net(struct cli *c, net *n, struct rt_show_data *d)
|
||||
rt_show_net(struct cli *c, net *n, struct rt_show_data *d, const uint addr_type)
|
||||
{
|
||||
rte *e, *ee;
|
||||
byte ia[NET_MAX_TEXT_LENGTH+1];
|
||||
byte ia[(net_max_text_length[addr_type] ?: 65536)];
|
||||
struct ea_list *tmpa;
|
||||
struct channel *ec = d->tab->export_channel;
|
||||
int first = 1;
|
||||
int pass = 0;
|
||||
|
||||
bsnprintf(ia, sizeof(ia), "%N", n->n.addr);
|
||||
switch (addr_type)
|
||||
{
|
||||
case NET_FLOW4:
|
||||
flow4_net_format(ia, sizeof(ia), (net_addr_flow4 *) n->n.addr, "\n\t");
|
||||
break;
|
||||
case NET_FLOW6:
|
||||
flow6_net_format(ia, sizeof(ia), (net_addr_flow6 *) n->n.addr, "\n\t");
|
||||
break;
|
||||
default:
|
||||
bsnprintf(ia, sizeof(ia), "%N", n->n.addr);
|
||||
}
|
||||
|
||||
for (e = n->routes; e; e = e->next)
|
||||
{
|
||||
@ -210,6 +221,7 @@ rt_show_cont(struct cli *c)
|
||||
#endif
|
||||
struct fib *fib = &d->tab->table->fib;
|
||||
struct fib_iterator *it = &d->fit;
|
||||
uint addr_type = d->tab->table->addr_type;
|
||||
|
||||
if (d->running_on_config && (d->running_on_config != config))
|
||||
{
|
||||
@ -238,7 +250,7 @@ rt_show_cont(struct cli *c)
|
||||
FIB_ITERATE_PUT(it);
|
||||
return;
|
||||
}
|
||||
rt_show_net(c, n, d);
|
||||
rt_show_net(c, n, d, addr_type);
|
||||
}
|
||||
FIB_ITERATE_END;
|
||||
|
||||
@ -402,7 +414,7 @@ rt_show(struct rt_show_data *d)
|
||||
n = net_find(tab->table, d->addr);
|
||||
|
||||
if (n)
|
||||
rt_show_net(this_cli, n, d);
|
||||
rt_show_net(this_cli, n, d, tab->table->addr_type);
|
||||
}
|
||||
|
||||
if (d->rt_counter)
|
||||
|
Loading…
Reference in New Issue
Block a user