mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 17:56:47 +00:00
Add interface name to route print output
This commit is contained in:
parent
5a3dec28d9
commit
10234018b0
@ -1999,6 +1999,15 @@ int app_route_print(const struct cli_parsed *parsed, void *context)
|
|||||||
|
|
||||||
mdp.packetTypeAndFlags=MDP_ROUTING_TABLE;
|
mdp.packetTypeAndFlags=MDP_ROUTING_TABLE;
|
||||||
overlay_mdp_send(&mdp,0,0);
|
overlay_mdp_send(&mdp,0,0);
|
||||||
|
|
||||||
|
const char *names[]={
|
||||||
|
"Subscriber id",
|
||||||
|
"Routing flags",
|
||||||
|
"Interface",
|
||||||
|
"Next hop"
|
||||||
|
};
|
||||||
|
cli_columns(4, names);
|
||||||
|
|
||||||
while(overlay_mdp_client_poll(200)){
|
while(overlay_mdp_client_poll(200)){
|
||||||
overlay_mdp_frame rx;
|
overlay_mdp_frame rx;
|
||||||
int ttl;
|
int ttl;
|
||||||
@ -2010,25 +2019,25 @@ int app_route_print(const struct cli_parsed *parsed, void *context)
|
|||||||
struct overlay_route_record *p=(struct overlay_route_record *)&rx.out.payload[ofs];
|
struct overlay_route_record *p=(struct overlay_route_record *)&rx.out.payload[ofs];
|
||||||
ofs+=sizeof(struct overlay_route_record);
|
ofs+=sizeof(struct overlay_route_record);
|
||||||
|
|
||||||
cli_printf(alloca_tohex_sid(p->sid));
|
cli_put_hexvalue(p->sid, SID_SIZE, ":");
|
||||||
cli_delim(":");
|
char flags[32];
|
||||||
|
strbuf b = strbuf_local(flags, sizeof flags);
|
||||||
|
|
||||||
if (p->reachable==REACHABLE_NONE)
|
if (p->reachable==REACHABLE_NONE)
|
||||||
cli_printf("NONE");
|
strbuf_puts(b, "NONE");
|
||||||
if (p->reachable & REACHABLE_SELF)
|
if (p->reachable & REACHABLE_SELF)
|
||||||
cli_printf("SELF ");
|
strbuf_puts(b, "SELF ");
|
||||||
if (p->reachable & REACHABLE_ASSUMED)
|
if (p->reachable & REACHABLE_ASSUMED)
|
||||||
cli_printf("ASSUMED ");
|
strbuf_puts(b, "ASSUMED ");
|
||||||
if (p->reachable & REACHABLE_BROADCAST)
|
if (p->reachable & REACHABLE_BROADCAST)
|
||||||
cli_printf("BROADCAST ");
|
strbuf_puts(b, "BROADCAST ");
|
||||||
if (p->reachable & REACHABLE_UNICAST)
|
if (p->reachable & REACHABLE_UNICAST)
|
||||||
cli_printf("UNICAST ");
|
strbuf_puts(b, "UNICAST ");
|
||||||
if (p->reachable & REACHABLE_INDIRECT)
|
if (p->reachable & REACHABLE_INDIRECT)
|
||||||
cli_printf("INDIRECT ");
|
strbuf_puts(b, "INDIRECT ");
|
||||||
|
cli_put_string(strbuf_str(b), ":");
|
||||||
cli_delim(":");
|
cli_put_string(p->interface_name, ":");
|
||||||
cli_printf(alloca_tohex_sid(p->neighbour));
|
cli_put_hexvalue(p->neighbour, SID_SIZE, "\n");
|
||||||
cli_delim("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
struct overlay_route_record{
|
struct overlay_route_record{
|
||||||
unsigned char sid[SID_SIZE];
|
unsigned char sid[SID_SIZE];
|
||||||
|
char interface_name[256];
|
||||||
int reachable;
|
int reachable;
|
||||||
unsigned char neighbour[SID_SIZE];
|
unsigned char neighbour[SID_SIZE];
|
||||||
};
|
};
|
||||||
|
@ -856,6 +856,10 @@ static int routing_table(struct subscriber *subscriber, void *context){
|
|||||||
r->reachable = subscriber->reachable;
|
r->reachable = subscriber->reachable;
|
||||||
if (subscriber->reachable==REACHABLE_INDIRECT && subscriber->next_hop)
|
if (subscriber->reachable==REACHABLE_INDIRECT && subscriber->next_hop)
|
||||||
memcpy(r->neighbour, subscriber->next_hop->sid, SID_SIZE);
|
memcpy(r->neighbour, subscriber->next_hop->sid, SID_SIZE);
|
||||||
|
if (subscriber->reachable & REACHABLE_DIRECT && subscriber->interface)
|
||||||
|
strcpy(r->interface_name, subscriber->interface->name);
|
||||||
|
else
|
||||||
|
r->interface_name[0]=0;
|
||||||
overlay_mdp_reply(mdp_named.poll.fd, state->recvaddr_un, state->recvaddrlen, &reply);
|
overlay_mdp_reply(mdp_named.poll.fd, state->recvaddr_un, state->recvaddrlen, &reply);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user