mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Adds %R printf directive for Router ID.
This commit is contained in:
parent
f0333f44a5
commit
2f6483cd31
15
lib/printf.c
15
lib/printf.c
@ -120,7 +120,8 @@ static char * number(char * str, long num, int base, int size, int precision,
|
|||||||
* available space to avoid buffer overflows and it allows some more
|
* available space to avoid buffer overflows and it allows some more
|
||||||
* format specifiers: |%I| for formatting of IP addresses (any non-zero
|
* format specifiers: |%I| for formatting of IP addresses (any non-zero
|
||||||
* width is automatically replaced by standard IP address width which
|
* width is automatically replaced by standard IP address width which
|
||||||
* depends on whether we use IPv4 or IPv6; |%#I| gives hexadecimal format)
|
* depends on whether we use IPv4 or IPv6; |%#I| gives hexadecimal format),
|
||||||
|
* |%R| for Router / Network ID (u32 value printed as IPv4 address)
|
||||||
* and |%m| resp. |%M| for error messages (uses strerror() to translate @errno code to
|
* and |%m| resp. |%M| for error messages (uses strerror() to translate @errno code to
|
||||||
* message text). On the other hand, it doesn't support floating
|
* message text). On the other hand, it doesn't support floating
|
||||||
* point numbers.
|
* point numbers.
|
||||||
@ -133,6 +134,7 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
|
|||||||
int len;
|
int len;
|
||||||
unsigned long num;
|
unsigned long num;
|
||||||
int i, base;
|
int i, base;
|
||||||
|
u32 x;
|
||||||
char *str, *start;
|
char *str, *start;
|
||||||
const char *s;
|
const char *s;
|
||||||
char ipbuf[STD_ADDRESS_P_LENGTH+1];
|
char ipbuf[STD_ADDRESS_P_LENGTH+1];
|
||||||
@ -277,6 +279,17 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
|
|||||||
s = ipbuf;
|
s = ipbuf;
|
||||||
goto str;
|
goto str;
|
||||||
|
|
||||||
|
/* Router/Network ID - essentially IPv4 address in u32 value */
|
||||||
|
case 'R':
|
||||||
|
x = va_arg(args, u32);
|
||||||
|
bsprintf(ipbuf, "%d.%d.%d.%d",
|
||||||
|
((x >> 24) & 0xff),
|
||||||
|
((x >> 16) & 0xff),
|
||||||
|
((x >> 8) & 0xff),
|
||||||
|
(x & 0xff));
|
||||||
|
s = ipbuf;
|
||||||
|
goto str;
|
||||||
|
|
||||||
/* integer number formats - set up the flags and "break" */
|
/* integer number formats - set up the flags and "break" */
|
||||||
case 'o':
|
case 'o':
|
||||||
base = 8;
|
base = 8;
|
||||||
|
@ -34,9 +34,7 @@ int_set_format(struct adata *set, int way, byte *buf, unsigned int size)
|
|||||||
if (way)
|
if (way)
|
||||||
buf += bsprintf(buf, "(%d,%d)", *z >> 16, *z & 0xffff);
|
buf += bsprintf(buf, "(%d,%d)", *z >> 16, *z & 0xffff);
|
||||||
else
|
else
|
||||||
buf += bsprintf(buf, "%d.%d.%d.%d",
|
buf += bsprintf(buf, "%R", *z);
|
||||||
(*z >> 24) & 0xff, (*z >> 16) & 0xff,
|
|
||||||
(*z >> 8) & 0xff, *z & 0xff);
|
|
||||||
|
|
||||||
z++;
|
z++;
|
||||||
sp = 0;
|
sp = 0;
|
||||||
|
@ -19,6 +19,7 @@ cmd_show_status(void)
|
|||||||
|
|
||||||
cli_msg(-1000, "BIRD " BIRD_VERSION);
|
cli_msg(-1000, "BIRD " BIRD_VERSION);
|
||||||
tm_format_datetime(tim, now);
|
tm_format_datetime(tim, now);
|
||||||
|
cli_msg(-1011, "Router ID is %R", config->router_id);
|
||||||
cli_msg(-1011, "Current server time is %s", tim);
|
cli_msg(-1011, "Current server time is %s", tim);
|
||||||
tm_format_datetime(tim, boot_time);
|
tm_format_datetime(tim, boot_time);
|
||||||
cli_msg(-1011, "Last reboot on %s", tim);
|
cli_msg(-1011, "Last reboot on %s", tim);
|
||||||
|
@ -419,11 +419,7 @@ ea_format(eattr *e, byte *buf)
|
|||||||
bsprintf(buf, "%I", *(ip_addr *) ad->data);
|
bsprintf(buf, "%I", *(ip_addr *) ad->data);
|
||||||
break;
|
break;
|
||||||
case EAF_TYPE_ROUTER_ID:
|
case EAF_TYPE_ROUTER_ID:
|
||||||
bsprintf(buf, "%d.%d.%d.%d",
|
bsprintf(buf, "%R", e->u.data);
|
||||||
(e->u.data >> 24) & 0xff,
|
|
||||||
(e->u.data >> 16) & 0xff,
|
|
||||||
(e->u.data >> 8) & 0xff,
|
|
||||||
e->u.data & 0xff);
|
|
||||||
break;
|
break;
|
||||||
case EAF_TYPE_AS_PATH:
|
case EAF_TYPE_AS_PATH:
|
||||||
as_path_format(ad, buf, end - buf);
|
as_path_format(ad, buf, end - buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user