mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-21 17:21:53 +00:00
CLI: v2 compatibility mode for attribute name display
This commit is contained in:
parent
e7bd976178
commit
29b721217b
@ -1293,16 +1293,25 @@ connects to it. If changed on the command line by the <tt/-s/ option,
|
||||
BIRD or the CLI tool connects there instead.
|
||||
|
||||
<p>It's also possible to configure additional remote control sockets in the
|
||||
configuration file by <cf/cli "name";/ and you can open how many
|
||||
configuration file by <cf/cli "name" { <m/options/ };/ and you can open how many
|
||||
sockets you wish. There are no checks whether the user configured the same
|
||||
socket multiple times and BIRD may behave weirdly if this happens. On shutdown,
|
||||
the additional sockets get removed immediately and only the main socket stays
|
||||
until the very end.
|
||||
until the very end. If there are no options, the braces may be omitted.
|
||||
|
||||
<p>The remote control socket can be also set as restricted by
|
||||
<cf/cli "name" { restrict; };/ instead of sending the <cf/restrict/ command
|
||||
after connecting. The user may still overload the daemon by requesting insanely
|
||||
complex filters so you shouldn't expose this socket to public anyway.
|
||||
<p>Options:
|
||||
|
||||
<descrip>
|
||||
<tag><label id="cli-conf-restrict">restrict</tag>
|
||||
Set the socket to be restricted as if the user always sent the
|
||||
<cf/restrict/ command after connecting. The user may still overload
|
||||
the daemon by requesting insanely complex filters so you shouldn't
|
||||
expose this socket to public even if restricted.
|
||||
|
||||
<tag><label id="cli-conf-v2mode">v2mode</tag>
|
||||
Display the names of route attributes the same way as BIRD 2 does.
|
||||
This is a compatibility option for easier transition from BIRD 2 to BIRD 3.
|
||||
</descrip>
|
||||
|
||||
<sect>Usage
|
||||
<label id="remote-control-usage">
|
||||
|
@ -287,6 +287,8 @@ cli_new(struct birdsock *sock, struct cli_config *cf)
|
||||
if (cf->restricted)
|
||||
c->restricted = 1;
|
||||
|
||||
c->v2mode = cf->v2mode;
|
||||
|
||||
ev_schedule(c->event);
|
||||
return c;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ typedef struct cli {
|
||||
struct config *main_config; /* Main config currently in use */
|
||||
int last_reply;
|
||||
int restricted; /* CLI is restricted to read-only commands */
|
||||
bool v2mode; /* CLI outputs are mimicking BIRD 2 */
|
||||
struct timeformat *tf; /* Time format override */
|
||||
struct linpool *parser_pool; /* Pool used during parsing */
|
||||
uint log_mask; /* Mask of allowed message levels */
|
||||
@ -63,6 +64,7 @@ struct cli_config {
|
||||
struct config *config;
|
||||
uint uid, gid, mode;
|
||||
_Bool restricted;
|
||||
_Bool v2mode;
|
||||
};
|
||||
#include "lib/tlists.h"
|
||||
|
||||
|
@ -1347,7 +1347,30 @@ ea_show(struct cli *c, const eattr *e)
|
||||
bsprintf(pos, "<type %02x>", e->type);
|
||||
}
|
||||
|
||||
cli_printf(c, -1012, "\t%s: %s", cls->name, buf);
|
||||
const char *name = cls->name;
|
||||
char v2n[64];
|
||||
|
||||
if (c->v2mode && !cls->conf)
|
||||
if (strcmp(cls->name, "bgp_path") == 0)
|
||||
name = "BGP.as_path";
|
||||
else
|
||||
{
|
||||
strncpy(v2n, name, sizeof v2n - 1);
|
||||
for (char *p = &v2n[0]; *p; p++)
|
||||
if (*p == '_')
|
||||
{
|
||||
*p = '.';
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT_DIE((*p >= 'a') && (*p <= 'z'));
|
||||
*p -= 'a' - 'A';
|
||||
}
|
||||
name = &v2n;
|
||||
}
|
||||
|
||||
cli_printf(c, -1012, "\t%s: %s", name, buf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -143,6 +143,7 @@ cli_opts_begin: {
|
||||
cli_opts_block:
|
||||
/* EMPTY */ |
|
||||
cli_opts_block RESTRICT { this_cli_config->restricted = 1; }
|
||||
cli_opts_block V2 MODE { this_cli_config->v2mode = 1; }
|
||||
;
|
||||
|
||||
conf: THREADS expr {
|
||||
|
Loading…
Reference in New Issue
Block a user