mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-03-21 13:57:04 +00:00
show protocols all in cbor works, added header
This commit is contained in:
parent
85d3eb7ebf
commit
f8bc20a211
@ -181,6 +181,8 @@ void write_args_cbor(char *cmd_buffer, struct cbor_writer *w)
|
|||||||
cbor_close_block_or_list(w);
|
cbor_close_block_or_list(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int serial_num = 0;
|
||||||
|
|
||||||
void
|
void
|
||||||
make_cmd_cbor(char *cmd_buffer)
|
make_cmd_cbor(char *cmd_buffer)
|
||||||
{
|
{
|
||||||
@ -189,6 +191,13 @@ make_cmd_cbor(char *cmd_buffer)
|
|||||||
struct linpool *lp = lp_new(&root_pool);
|
struct linpool *lp = lp_new(&root_pool);
|
||||||
|
|
||||||
struct cbor_writer *w = cbor_init(cbor_buf, l*10, lp);
|
struct cbor_writer *w = cbor_init(cbor_buf, l*10, lp);
|
||||||
|
|
||||||
|
write_item(w, 6, 24); // tag 24 - cbor binary
|
||||||
|
int length_pt = w->pt + 1;
|
||||||
|
cbor_write_item_with_constant_val_length_4(w, 2, 0);
|
||||||
|
cbor_open_list_with_length(w, 2);
|
||||||
|
cbor_write_item_with_constant_val_length_4(w, 0, serial_num);
|
||||||
|
|
||||||
cbor_open_block_with_length(w, 1);
|
cbor_open_block_with_length(w, 1);
|
||||||
cbor_add_string(w, "command:do");
|
cbor_add_string(w, "command:do");
|
||||||
|
|
||||||
@ -203,6 +212,7 @@ make_cmd_cbor(char *cmd_buffer)
|
|||||||
{
|
{
|
||||||
cbor_string_int(w, "command", SHOW_MEMORY);
|
cbor_string_int(w, "command", SHOW_MEMORY);
|
||||||
cbor_close_block_or_list(w);
|
cbor_close_block_or_list(w);
|
||||||
|
rewrite_4bytes_int(w, length_pt, w->pt);
|
||||||
server_send_byte(cbor_buf, w->pt);
|
server_send_byte(cbor_buf, w->pt);
|
||||||
lp_flush(lp);
|
lp_flush(lp);
|
||||||
return;
|
return;
|
||||||
@ -211,7 +221,7 @@ make_cmd_cbor(char *cmd_buffer)
|
|||||||
{
|
{
|
||||||
cbor_string_int(w, "command", SHOW_STATUS);
|
cbor_string_int(w, "command", SHOW_STATUS);
|
||||||
cbor_close_block_or_list(w);
|
cbor_close_block_or_list(w);
|
||||||
cbor_write_to_file(w, "status_command.cbor");
|
rewrite_4bytes_int(w, length_pt, w->pt);
|
||||||
server_send_byte(cbor_buf, w->pt);
|
server_send_byte(cbor_buf, w->pt);
|
||||||
lp_flush(lp);
|
lp_flush(lp);
|
||||||
return;
|
return;
|
||||||
@ -221,6 +231,7 @@ make_cmd_cbor(char *cmd_buffer)
|
|||||||
cbor_string_int(w, "command", SHOW_SYMBOLS);
|
cbor_string_int(w, "command", SHOW_SYMBOLS);
|
||||||
write_args_cbor(&cmd_buffer[buf_pt + strlen("symbols ")], w);
|
write_args_cbor(&cmd_buffer[buf_pt + strlen("symbols ")], w);
|
||||||
cbor_close_block_or_list(w);
|
cbor_close_block_or_list(w);
|
||||||
|
rewrite_4bytes_int(w, length_pt, w->pt);
|
||||||
server_send_byte(cbor_buf, w->pt);
|
server_send_byte(cbor_buf, w->pt);
|
||||||
lp_flush(lp);
|
lp_flush(lp);
|
||||||
return;
|
return;
|
||||||
@ -230,6 +241,7 @@ make_cmd_cbor(char *cmd_buffer)
|
|||||||
cbor_string_int(w, "command", SHOW_OSPF);
|
cbor_string_int(w, "command", SHOW_OSPF);
|
||||||
write_args_cbor(&cmd_buffer[buf_pt + strlen("ospf")], w);
|
write_args_cbor(&cmd_buffer[buf_pt + strlen("ospf")], w);
|
||||||
cbor_close_block_or_list(w);
|
cbor_close_block_or_list(w);
|
||||||
|
rewrite_4bytes_int(w, length_pt, w->pt);
|
||||||
server_send_byte(cbor_buf, w->pt);
|
server_send_byte(cbor_buf, w->pt);
|
||||||
lp_flush(lp);
|
lp_flush(lp);
|
||||||
return;
|
return;
|
||||||
@ -240,6 +252,7 @@ make_cmd_cbor(char *cmd_buffer)
|
|||||||
cbor_string_int(w, "command", SHOW_PROTOCOLS);
|
cbor_string_int(w, "command", SHOW_PROTOCOLS);
|
||||||
write_args_cbor(&cmd_buffer[buf_pt + strlen("protocols")], w);
|
write_args_cbor(&cmd_buffer[buf_pt + strlen("protocols")], w);
|
||||||
cbor_close_block_or_list(w);
|
cbor_close_block_or_list(w);
|
||||||
|
rewrite_4bytes_int(w, length_pt, w->pt);
|
||||||
server_send_byte(cbor_buf, w->pt);
|
server_send_byte(cbor_buf, w->pt);
|
||||||
lp_flush(lp);
|
lp_flush(lp);
|
||||||
return;
|
return;
|
||||||
@ -253,6 +266,7 @@ make_cmd_cbor(char *cmd_buffer)
|
|||||||
else if (compare_string(cmd_buffer, l, "down"))
|
else if (compare_string(cmd_buffer, l, "down"))
|
||||||
{
|
{
|
||||||
cbor_add_string(w, "down");
|
cbor_add_string(w, "down");
|
||||||
|
rewrite_4bytes_int(w, length_pt, w->pt);
|
||||||
server_send_byte(cbor_buf, w->pt);
|
server_send_byte(cbor_buf, w->pt);
|
||||||
die("Shutdown from client");
|
die("Shutdown from client");
|
||||||
return;
|
return;
|
||||||
@ -440,7 +454,6 @@ server_got_reply(char *x)
|
|||||||
void
|
void
|
||||||
server_got_binary(int c)
|
server_got_binary(int c)
|
||||||
{
|
{
|
||||||
// TODO check cbor hello
|
|
||||||
if (cbor_mode == 0)
|
if (cbor_mode == 0)
|
||||||
{
|
{
|
||||||
byte expected[] = {0x87, 0x42, 0x49, 0x52, 0x44, 0x0D, 0x0A, 0x1A, 0x0A, 0x01};
|
byte expected[] = {0x87, 0x42, 0x49, 0x52, 0x44, 0x0D, 0x0A, 0x1A, 0x0A, 0x01};
|
||||||
@ -456,7 +469,35 @@ server_got_binary(int c)
|
|||||||
cbor_mode = 1;
|
cbor_mode = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print_cbor_response(server_read_buf, c);
|
int length = 0;
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
length = length << 8;
|
||||||
|
length += server_read_buf[3 + i];
|
||||||
|
}
|
||||||
|
printf("length of message is %i\n", length);
|
||||||
|
if (length > c - 7)
|
||||||
|
{
|
||||||
|
byte bigger_buf[length];
|
||||||
|
memcpy(bigger_buf, server_read_buf, c);
|
||||||
|
int cc = read(server_fd, &bigger_buf[c], length - c + 7);
|
||||||
|
if (!cc)
|
||||||
|
die("Connection closed by server");
|
||||||
|
if (cc < 0)
|
||||||
|
{
|
||||||
|
DIE("Server read error");
|
||||||
|
}
|
||||||
|
print_cbor_response(&bigger_buf[13], length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("no need to load more\n");
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
{
|
||||||
|
printf("%i %x\n",i, server_read_buf[i] );
|
||||||
|
}
|
||||||
|
print_cbor_response(&server_read_buf[13], c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
busy = 0;
|
busy = 0;
|
||||||
skip_input = 0;
|
skip_input = 0;
|
||||||
|
@ -116,7 +116,7 @@ void discard_key(struct buff_reader *buf_read)
|
|||||||
struct value val = get_value(buf_read);
|
struct value val = get_value(buf_read);
|
||||||
if(!(val.major == TEXT))
|
if(!(val.major == TEXT))
|
||||||
{
|
{
|
||||||
bug("key is not text but %i", val.major);
|
bug("key is not text but %i, pt is %i", val.major, buf_read->pt);
|
||||||
}
|
}
|
||||||
buf_read->pt+=val.val;
|
buf_read->pt+=val.val;
|
||||||
}
|
}
|
||||||
@ -678,30 +678,6 @@ void print_show_symbols(struct buff_reader *buf_read)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_channel_show_limit(struct buff_reader *buf_read)
|
|
||||||
{
|
|
||||||
struct value val = get_value(buf_read);
|
|
||||||
int siz = val.val;
|
|
||||||
buf_read->pt += val.val;
|
|
||||||
val = get_value(buf_read); //block
|
|
||||||
val = get_value(buf_read);
|
|
||||||
if (val_is_break(val))
|
|
||||||
return;
|
|
||||||
buf_read->pt += val.val;
|
|
||||||
printf(" ");
|
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], siz);
|
|
||||||
for(int i = 0; i < 16 - siz; i++)
|
|
||||||
putc(' ', stdout);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf("%ld ", val.val);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
|
||||||
buf_read->pt += val.val;
|
|
||||||
printf("\n Action: ");
|
|
||||||
val = get_value(buf_read);
|
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_route_change_line(struct buff_reader *buf_read)
|
void print_route_change_line(struct buff_reader *buf_read)
|
||||||
{
|
{
|
||||||
@ -716,88 +692,6 @@ void print_route_change_line(struct buff_reader *buf_read)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_pipe_show_stats(struct buff_reader *buf_read)
|
|
||||||
{
|
|
||||||
struct value val = get_value(buf_read); //open block
|
|
||||||
discard_key(buf_read);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf(" Routes: %lu imported, ", val.val);
|
|
||||||
discard_key(buf_read);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf("%lu exported\n", val.val);
|
|
||||||
printf(" Route change stats: received rejected filtered ignored accepted\n");
|
|
||||||
discard_key(buf_read); //import_updates
|
|
||||||
val = get_value(buf_read); //open list
|
|
||||||
printf(" Import updates: ");
|
|
||||||
print_route_change_line(buf_read);
|
|
||||||
discard_key(buf_read);
|
|
||||||
val = get_value(buf_read); //open list
|
|
||||||
printf(" Import withdraws: ");
|
|
||||||
print_route_change_line(buf_read);
|
|
||||||
discard_key(buf_read);
|
|
||||||
val = get_value(buf_read); //open list
|
|
||||||
printf(" Export updates: ");
|
|
||||||
print_route_change_line(buf_read);
|
|
||||||
discard_key(buf_read);
|
|
||||||
val = get_value(buf_read); //open list
|
|
||||||
printf(" Export withdraws: ");
|
|
||||||
print_route_change_line(buf_read);
|
|
||||||
val = get_value(buf_read); //close block
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_show_protocols_rpki(struct buff_reader *buf_read)
|
|
||||||
{
|
|
||||||
struct value val = get_value(buf_read); //open block
|
|
||||||
discard_key(buf_read);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf(" Cache server: ");
|
|
||||||
print_with_size_(&buf_read->buff[buf_read->pt], val.val);
|
|
||||||
printf("\n");
|
|
||||||
buf_read->pt += val.val;
|
|
||||||
if (compare_buff_str(buf_read, val.val, "cache_port"))
|
|
||||||
{
|
|
||||||
buf_read->pt += val.val;
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf(" Cache port: %lu\n", val.val);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
}
|
|
||||||
|
|
||||||
print_string_string(buf_read, " Status: ");
|
|
||||||
print_string_string(buf_read, " Transport: ");
|
|
||||||
|
|
||||||
discard_key(buf_read);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf(" Protocol version: %lu\n", val.val);
|
|
||||||
|
|
||||||
discard_key(buf_read);
|
|
||||||
printf(" Session ID: ");
|
|
||||||
val = get_value(buf_read);
|
|
||||||
if (val.major == TEXT)
|
|
||||||
{
|
|
||||||
printf("---\n");
|
|
||||||
buf_read->pt += val.val;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf("%lu\n", val.val);
|
|
||||||
|
|
||||||
val = get_value(buf_read);
|
|
||||||
if (compare_buff_str(buf_read, val.val, "serial_num"))
|
|
||||||
{
|
|
||||||
buf_read->pt += val.val;
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf(" Serial number: %lu\n", val.val);
|
|
||||||
discard_key(buf_read);
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf(" Last update: before %lu s\n", val.val);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(" Serial number: ---\n");
|
|
||||||
printf(" Last update: ---\n");
|
|
||||||
}
|
|
||||||
val = get_value(buf_read);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_channel_show_stats(struct buff_reader *buf_read)
|
void print_channel_show_stats(struct buff_reader *buf_read)
|
||||||
{
|
{
|
||||||
struct value val = get_value(buf_read); //open block
|
struct value val = get_value(buf_read); //open block
|
||||||
@ -843,8 +737,35 @@ void print_channel_show_stats(struct buff_reader *buf_read)
|
|||||||
val = get_value(buf_read); //close block
|
val = get_value(buf_read); //close block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void print_channel_show_limit(struct buff_reader *buf_read)
|
||||||
|
{
|
||||||
|
struct value val = get_value(buf_read);
|
||||||
|
int siz = val.val;
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read); //block
|
||||||
|
val = get_value(buf_read);
|
||||||
|
if (val_is_break(val))
|
||||||
|
return;
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
printf(" ");
|
||||||
|
print_with_size(&buf_read->buff[buf_read->pt], siz);
|
||||||
|
for(int i = 0; i < 16 - siz; i++)
|
||||||
|
putc(' ', stdout);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf("%ld ", val.val);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
printf("\n Action: ");
|
||||||
|
val = get_value(buf_read);
|
||||||
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
}
|
||||||
|
|
||||||
void print_channel_show_info(struct buff_reader *buf_read)
|
void print_channel_show_info(struct buff_reader *buf_read)
|
||||||
{
|
{
|
||||||
|
// This function expect removed key channels and removed block opening. The reason is bgp channel list.
|
||||||
print_string_string(buf_read, " Channel ");
|
print_string_string(buf_read, " Channel ");
|
||||||
|
|
||||||
print_string_string(buf_read, " State: ");
|
print_string_string(buf_read, " State: ");
|
||||||
@ -892,6 +813,158 @@ void print_channel_show_info(struct buff_reader *buf_read)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void print_pipe_show_stats(struct buff_reader *buf_read)
|
||||||
|
{
|
||||||
|
struct value val = get_value(buf_read); //open block
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf(" Routes: %lu imported, ", val.val);
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf("%lu exported\n", val.val);
|
||||||
|
printf(" Route change stats: received rejected filtered ignored accepted\n");
|
||||||
|
discard_key(buf_read); //import_updates
|
||||||
|
val = get_value(buf_read); //open list
|
||||||
|
printf(" Import updates: ");
|
||||||
|
print_route_change_line(buf_read);
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read); //open list
|
||||||
|
printf(" Import withdraws: ");
|
||||||
|
print_route_change_line(buf_read);
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read); //open list
|
||||||
|
printf(" Export updates: ");
|
||||||
|
print_route_change_line(buf_read);
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read); //open list
|
||||||
|
printf(" Export withdraws: ");
|
||||||
|
print_route_change_line(buf_read);
|
||||||
|
val = get_value(buf_read); //close block
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_rpki_show_proto_info_timer(struct buff_reader *buf_read)
|
||||||
|
{
|
||||||
|
struct value val = get_value(buf_read); // name
|
||||||
|
printf(" ");
|
||||||
|
print_with_size_add_space(&buf_read->buff[buf_read->pt], val.val, 16);
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read); //open block
|
||||||
|
val = get_value(buf_read);
|
||||||
|
if (!val_is_break(val))
|
||||||
|
{
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf(": ");
|
||||||
|
print_as_time(val.val);
|
||||||
|
printf("/");
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf("%lu\n", val.val);
|
||||||
|
val = get_value(buf_read); //close block
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf(": ---\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_show_protocols_rpki(struct buff_reader *buf_read)
|
||||||
|
{
|
||||||
|
struct value val = get_value(buf_read); //open block
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf(" Cache server: ");
|
||||||
|
print_with_size_(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
printf("\n");
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read);
|
||||||
|
if (compare_buff_str(buf_read, val.val, "cache_port"))
|
||||||
|
{
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf(" Cache port: %lu\n", val.val);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf(" Status: ");
|
||||||
|
print_with_size_(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
printf("\n");
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
print_string_string(buf_read, " Transport: ");
|
||||||
|
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf(" Protocol version: %lu\n", val.val);
|
||||||
|
|
||||||
|
discard_key(buf_read);
|
||||||
|
printf(" Session ID: ");
|
||||||
|
val = get_value(buf_read);
|
||||||
|
if (val.major == TEXT)
|
||||||
|
{
|
||||||
|
printf("---\n");
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("%lu\n", val.val);
|
||||||
|
|
||||||
|
int pt = buf_read->pt;
|
||||||
|
val = get_value(buf_read);
|
||||||
|
if (compare_buff_str(buf_read, val.val, "serial_num"))
|
||||||
|
{
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf(" Serial number: %lu\n", val.val);
|
||||||
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
printf(" Last update: before ");
|
||||||
|
print_as_time(val.val);
|
||||||
|
printf(" s\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf(" Serial number: ---\n");
|
||||||
|
printf(" Last update: ---\n");
|
||||||
|
buf_read->pt = pt;
|
||||||
|
}
|
||||||
|
print_rpki_show_proto_info_timer(buf_read);
|
||||||
|
print_rpki_show_proto_info_timer(buf_read);
|
||||||
|
print_rpki_show_proto_info_timer(buf_read);
|
||||||
|
|
||||||
|
val = get_value(buf_read);
|
||||||
|
|
||||||
|
if (compare_buff_str(buf_read, val.val, "no_roa4"))
|
||||||
|
{
|
||||||
|
printf(" No roa4 channel\n");
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read);
|
||||||
|
print_channel_show_info(buf_read);
|
||||||
|
}
|
||||||
|
val = get_value(buf_read);
|
||||||
|
|
||||||
|
if (compare_buff_str(buf_read, val.val, "no_roa6"))
|
||||||
|
{
|
||||||
|
printf(" No roa6 channel\n");
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buf_read->pt += val.val;
|
||||||
|
val = get_value(buf_read);
|
||||||
|
print_channel_show_info(buf_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
val = get_value(buf_read);
|
||||||
|
val = get_value(buf_read);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void print_bgp_show_afis(struct buff_reader *buf_read)
|
void print_bgp_show_afis(struct buff_reader *buf_read)
|
||||||
{
|
{
|
||||||
struct value val = get_value(buf_read); //open list
|
struct value val = get_value(buf_read); //open list
|
||||||
@ -926,10 +999,8 @@ void print_bgp_show_afis(struct buff_reader *buf_read)
|
|||||||
|
|
||||||
void print_bgp_capabilities(struct buff_reader *buf_read)
|
void print_bgp_capabilities(struct buff_reader *buf_read)
|
||||||
{
|
{
|
||||||
printf("<debug capabilities <%s>, %x %x>\n", &buf_read->buff[buf_read->pt], buf_read->buff[buf_read->pt], buf_read->buff[buf_read->pt+1]);
|
|
||||||
discard_key(buf_read);
|
discard_key(buf_read);
|
||||||
struct value val = get_value(buf_read); //open block
|
struct value val = get_value(buf_read); //open block
|
||||||
printf("<debug: val major %i, val val %li>\n", val.major, val.val);
|
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
if (compare_buff_str(buf_read, val.val, "AF_announced"))
|
if (compare_buff_str(buf_read, val.val, "AF_announced"))
|
||||||
{
|
{
|
||||||
@ -1040,6 +1111,7 @@ void print_bgp_capabilities(struct buff_reader *buf_read)
|
|||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf(" Hostname: ");
|
printf(" Hostname: ");
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
@ -1049,6 +1121,7 @@ void print_bgp_capabilities(struct buff_reader *buf_read)
|
|||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf(" Role: ");
|
printf(" Role: ");
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
@ -1092,32 +1165,16 @@ void print_show_protocols_bgp(struct buff_reader *buf_read)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("<debug ");
|
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
|
||||||
printf("debug >");
|
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
}
|
}
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf("<debug maj %i val %li>\n", val.major, val.val);
|
|
||||||
for (int i = 0; i< 30; i++)
|
|
||||||
{
|
|
||||||
printf("<debug capabilities %x>\n", buf_read->buff[buf_read->pt+i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf(" Neighbor AS: %lu\n", val.val);
|
printf(" Neighbor AS: %lu\n", val.val);
|
||||||
//discard_key(buf_read);
|
discard_key(buf_read);
|
||||||
printf("<debug");
|
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf(" maj %i val %li>\n ", val.major, val.val);
|
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
|
||||||
buf_read->pt += val.val;
|
|
||||||
printf(" debug>\n");
|
|
||||||
val = get_value(buf_read);
|
|
||||||
printf("<debug maj %i val %li>\n", val.major, val.val);
|
|
||||||
printf(" Local AS: %lu\n", val.val);
|
printf(" Local AS: %lu\n", val.val);
|
||||||
|
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf("<debug maj %i val %li>\n", val.major, val.val);
|
|
||||||
if (compare_buff_str(buf_read, val.val, "gr_active"))
|
if (compare_buff_str(buf_read, val.val, "gr_active"))
|
||||||
{
|
{
|
||||||
printf(" Neighbor graceful restart active\n");
|
printf(" Neighbor graceful restart active\n");
|
||||||
@ -1129,7 +1186,9 @@ void print_show_protocols_bgp(struct buff_reader *buf_read)
|
|||||||
{
|
{
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf(" Error wait: %lu/", val.val);
|
printf(" Error wait: ");
|
||||||
|
print_as_time(val.val);
|
||||||
|
printf("/");
|
||||||
discard_key(buf_read);
|
discard_key(buf_read);
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf("%lu\n", val.val);
|
printf("%lu\n", val.val);
|
||||||
@ -1139,7 +1198,9 @@ void print_show_protocols_bgp(struct buff_reader *buf_read)
|
|||||||
{
|
{
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf(" Connect delay: %lu/", val.val);
|
printf(" Connect delay: ");
|
||||||
|
print_as_time(val.val);
|
||||||
|
printf("/");
|
||||||
discard_key(buf_read);
|
discard_key(buf_read);
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf("%lu\n", val.val);
|
printf("%lu\n", val.val);
|
||||||
@ -1149,18 +1210,15 @@ void print_show_protocols_bgp(struct buff_reader *buf_read)
|
|||||||
{
|
{
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf(" Connect delay: %lu/-\n", val.val);
|
printf(" Connect delay: ");
|
||||||
|
print_as_time(val.val);
|
||||||
|
printf("/-\n");
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
if (compare_buff_str(buf_read, val.val, "neighbor_id"))
|
if (compare_buff_str(buf_read, val.val, "neighbor_id"))
|
||||||
{
|
{
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
printf(" Neighbor ID: ");
|
printf(" Neighbor ID: ");
|
||||||
printf("<debug capabilities <%s>, %x %x>\n", &buf_read->buff[buf_read->pt], buf_read->buff[buf_read->pt], buf_read->buff[buf_read->pt+1]);
|
|
||||||
for (int i = 0; i< 30; i++)
|
|
||||||
{
|
|
||||||
printf("<debug capabilities %x>\n", buf_read->buff[buf_read->pt+i]);
|
|
||||||
}
|
|
||||||
print_ip_addr(buf_read);
|
print_ip_addr(buf_read);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf(" Local capabilities\n");
|
printf(" Local capabilities\n");
|
||||||
@ -1201,35 +1259,43 @@ void print_show_protocols_bgp(struct buff_reader *buf_read)
|
|||||||
discard_key(buf_read);
|
discard_key(buf_read);
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf("%lu\n", val.val);
|
printf("%lu\n", val.val);
|
||||||
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
if (compare_buff_str(buf_read, val.val, "last_err1"))
|
if (compare_buff_str(buf_read, val.val, "last_err1"))
|
||||||
{
|
{
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
printf(" Last error: ");
|
printf(" Last error: ");
|
||||||
discard_key(buf_read);
|
val = get_value(buf_read);
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
printf(" ");
|
printf(" ");
|
||||||
discard_key(buf_read);
|
discard_key(buf_read);
|
||||||
|
val = get_value(buf_read);
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
discard_key(buf_read); //channels
|
buf_read->pt += val.val; //channels
|
||||||
val = get_value(buf_read); //open list
|
val = get_value(buf_read); //open list
|
||||||
val = get_value(buf_read); //open block
|
val = get_value(buf_read); //open block
|
||||||
|
val = get_value(buf_read); //channel
|
||||||
while (!val_is_break(val))
|
while (!val_is_break(val))
|
||||||
{
|
{
|
||||||
discard_key(buf_read); //channel
|
buf_read->pt += val.val;
|
||||||
val = get_value(buf_read); //open block
|
val = get_value(buf_read); //open block
|
||||||
|
ASSERT(val.major == BLOCK);
|
||||||
|
|
||||||
print_channel_show_info(buf_read);
|
print_channel_show_info(buf_read);
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
|
|
||||||
if (compare_buff_str(buf_read, val.val, "neighbor_gr"))
|
if (compare_buff_str(buf_read, val.val, "neighbor_gr"))
|
||||||
{
|
{
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
printf(" Neighbor GR: ");
|
printf(" Neighbor GR: ");
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
@ -1267,14 +1333,17 @@ void print_show_protocols_bgp(struct buff_reader *buf_read)
|
|||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf(" IGP IPv4 table: ");
|
printf(" IGP IPv4 table: ");
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
if (compare_buff_str(buf_read, val.val, "igp_ipv4_table"))
|
if (compare_buff_str(buf_read, val.val, "igp_ipv6_table"))
|
||||||
{
|
{
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
printf(" IGP IPv6 table: ");
|
printf(" IGP IPv6 table: ");
|
||||||
|
val = get_value(buf_read);
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
@ -1282,14 +1351,15 @@ void print_show_protocols_bgp(struct buff_reader *buf_read)
|
|||||||
{
|
{
|
||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
printf(" Base table: ");
|
printf(" Base table: ");
|
||||||
|
val = get_value(buf_read);
|
||||||
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
print_with_size(&buf_read->buff[buf_read->pt], val.val);
|
||||||
|
buf_read->pt += val.val;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf("<debug: val major %i, val val %li>\n", val.major, val.val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_show_protocols(struct buff_reader *buf_read)
|
void print_show_protocols(struct buff_reader *buf_read)
|
||||||
@ -1398,12 +1468,14 @@ void print_show_protocols(struct buff_reader *buf_read)
|
|||||||
print_channel_show_limit(buf_read);
|
print_channel_show_limit(buf_read);
|
||||||
print_channel_show_limit(buf_read);
|
print_channel_show_limit(buf_read);
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
|
|
||||||
if (!val_is_break(val))
|
if (!val_is_break(val))
|
||||||
{
|
{
|
||||||
buf_read->pt += val.val; // discarding key "stats"
|
buf_read->pt += val.val; // discarding key "stats"
|
||||||
print_pipe_show_stats(buf_read);
|
print_pipe_show_stats(buf_read);
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
}
|
}
|
||||||
|
val = get_value(buf_read);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
else if (compare_buff_str(buf_read, val.val, "bgp"))
|
else if (compare_buff_str(buf_read, val.val, "bgp"))
|
||||||
@ -1411,7 +1483,6 @@ void print_show_protocols(struct buff_reader *buf_read)
|
|||||||
buf_read->pt += val.val;
|
buf_read->pt += val.val;
|
||||||
print_show_protocols_bgp(buf_read);
|
print_show_protocols_bgp(buf_read);
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf("<debug: val major %i, val val %li>\n", val.major, val.val);
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1432,7 +1503,6 @@ void print_show_protocols(struct buff_reader *buf_read)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val = get_value(buf_read);
|
val = get_value(buf_read);
|
||||||
printf("<debug: val major %i, val val %li>\n", val.major, val.val);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
nest/cbor.c
27
nest/cbor.c
@ -196,6 +196,33 @@ void write_item(struct cbor_writer *writer, uint8_t major, uint64_t num)
|
|||||||
writer->pt++;
|
writer->pt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cbor_write_item_with_constant_val_length_4(struct cbor_writer *writer, uint8_t major, uint64_t num)
|
||||||
|
{
|
||||||
|
// this is only for headers which should be constantly long.
|
||||||
|
major = major<<5;
|
||||||
|
check_memory(writer, 10);
|
||||||
|
major += 0x1a; // reserving those bytes
|
||||||
|
writer->cbor[writer->pt] = major;
|
||||||
|
writer->pt++;
|
||||||
|
for (int i = 3; i>=0; i--)
|
||||||
|
{ // write n-th byte of num
|
||||||
|
uint8_t to_write = (num>>(i*8)) & 0xff;
|
||||||
|
writer->cbor[writer->pt] = to_write;
|
||||||
|
writer->pt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rewrite_4bytes_int(struct cbor_writer *writer, int pt, int num)
|
||||||
|
{
|
||||||
|
for (int i = 3; i>=0; i--)
|
||||||
|
{
|
||||||
|
uint8_t to_write = (num>>(i*8)) & 0xff;
|
||||||
|
writer->cbor[pt] = to_write;
|
||||||
|
pt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void check_memory(struct cbor_writer *writer, int add_size)
|
void check_memory(struct cbor_writer *writer, int add_size)
|
||||||
{
|
{
|
||||||
if (writer->capacity - writer->pt-add_size < 0)
|
if (writer->capacity - writer->pt-add_size < 0)
|
||||||
|
@ -45,4 +45,10 @@ void cbor_add_string(struct cbor_writer *writer, const char *string);
|
|||||||
|
|
||||||
void cbor_nonterminated_string(struct cbor_writer *writer, const char *string, uint32_t length);
|
void cbor_nonterminated_string(struct cbor_writer *writer, const char *string, uint32_t length);
|
||||||
|
|
||||||
|
void write_item(struct cbor_writer *writer, uint8_t major, uint64_t num);
|
||||||
|
|
||||||
|
void cbor_write_item_with_constant_val_length_4(struct cbor_writer *writer, uint8_t major, uint64_t num);
|
||||||
|
|
||||||
|
void rewrite_4bytes_int(struct cbor_writer *writer, int pt, int num);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -127,28 +127,52 @@ do_command(struct buff_reader *rbuf_read, struct buff_reader *tbuf_read, int ite
|
|||||||
{
|
{
|
||||||
case SHOW_MEMORY:
|
case SHOW_MEMORY:
|
||||||
skip_optional_args(rbuf_read, items_in_block);
|
skip_optional_args(rbuf_read, items_in_block);
|
||||||
return cmd_show_memory_cbor(tbuf_read->buff, tbuf_read->size, lp);
|
return cmd_show_memory_cbor(&tbuf_read->buff[tbuf_read->pt], tbuf_read->size, lp);
|
||||||
case SHOW_STATUS:
|
case SHOW_STATUS:
|
||||||
log("show status");
|
log("show status");
|
||||||
skip_optional_args(rbuf_read, items_in_block);
|
skip_optional_args(rbuf_read, items_in_block);
|
||||||
return cmd_show_status_cbor(tbuf_read->buff, tbuf_read->size, lp);
|
return cmd_show_status_cbor(&tbuf_read->buff[tbuf_read->pt], tbuf_read->size, lp);
|
||||||
case SHOW_SYMBOLS:
|
case SHOW_SYMBOLS:
|
||||||
args = parse_arguments(rbuf_read, items_in_block, lp);
|
args = parse_arguments(rbuf_read, items_in_block, lp);
|
||||||
return cmd_show_symbols_cbor(tbuf_read->buff, tbuf_read->size, args, lp);
|
return cmd_show_symbols_cbor(&tbuf_read->buff[tbuf_read->pt], tbuf_read->size, args, lp);
|
||||||
case SHOW_OSPF:
|
case SHOW_OSPF:
|
||||||
args = parse_arguments(rbuf_read, items_in_block, lp);
|
args = parse_arguments(rbuf_read, items_in_block, lp);
|
||||||
log("args %i, pt %i", args, args->pt);
|
log("args %i, pt %i", args, args->pt);
|
||||||
return cmd_show_ospf_cbor(tbuf_read->buff, tbuf_read->size, args, lp);
|
return cmd_show_ospf_cbor(&tbuf_read->buff[tbuf_read->pt], tbuf_read->size, args, lp);
|
||||||
case SHOW_PROTOCOLS:
|
case SHOW_PROTOCOLS:
|
||||||
args = parse_arguments(rbuf_read, items_in_block, lp);
|
args = parse_arguments(rbuf_read, items_in_block, lp);
|
||||||
log("args %i, pt %i", args, args->pt);
|
log("args %i, pt %i", args, args->pt);
|
||||||
return cmd_show_protocols_cbor(tbuf_read->buff, tbuf_read->size, args, lp);
|
return cmd_show_protocols_cbor(&tbuf_read->buff[tbuf_read->pt], tbuf_read->size, args, lp);
|
||||||
default:
|
default:
|
||||||
bug("command %li not found", val.val);
|
bug("command %li not found", val.val);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint
|
||||||
|
add_header(struct buff_reader *tbuf_read, struct linpool *lp, int serial_num)
|
||||||
|
{
|
||||||
|
struct cbor_writer *w = cbor_init(tbuf_read->buff, tbuf_read->size, lp);
|
||||||
|
write_item(w, 6, 24); // tag 24 - cbor binary
|
||||||
|
int length_pt = w->pt + 1; // place where we will put final size
|
||||||
|
cbor_write_item_with_constant_val_length_4(w, 2, 0);
|
||||||
|
cbor_open_list_with_length(w, 2);
|
||||||
|
cbor_write_item_with_constant_val_length_4(w, 0, serial_num);
|
||||||
|
tbuf_read->pt+=w->pt;
|
||||||
|
return length_pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint
|
||||||
|
read_head(struct buff_reader *rbuf_read)
|
||||||
|
{
|
||||||
|
struct value val = get_value(rbuf_read); //tag
|
||||||
|
val = get_value(rbuf_read); //bytestring
|
||||||
|
val = get_value(rbuf_read); //list
|
||||||
|
val = get_value(rbuf_read); //serial_num
|
||||||
|
int ret = val.val;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
uint
|
uint
|
||||||
detect_down(uint size, byte *rbuf)
|
detect_down(uint size, byte *rbuf)
|
||||||
{
|
{
|
||||||
@ -156,6 +180,7 @@ detect_down(uint size, byte *rbuf)
|
|||||||
rbuf_read.buff = rbuf;
|
rbuf_read.buff = rbuf;
|
||||||
rbuf_read.size = size;
|
rbuf_read.size = size;
|
||||||
rbuf_read.pt = 0;
|
rbuf_read.pt = 0;
|
||||||
|
read_head(&rbuf_read);
|
||||||
struct value val = get_value(&rbuf_read);
|
struct value val = get_value(&rbuf_read);
|
||||||
ASSERT(val.major == BLOCK);
|
ASSERT(val.major == BLOCK);
|
||||||
val = get_value(&rbuf_read);
|
val = get_value(&rbuf_read);
|
||||||
@ -165,7 +190,6 @@ detect_down(uint size, byte *rbuf)
|
|||||||
return (val.major = TEXT && compare_buff_str(&rbuf_read, val.val, "down"));
|
return (val.major = TEXT && compare_buff_str(&rbuf_read, val.val, "down"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint
|
uint
|
||||||
parse_cbor(uint size, byte *rbuf, byte *tbuf, uint tbsize, struct linpool* lp)
|
parse_cbor(uint size, byte *rbuf, byte *tbuf, uint tbsize, struct linpool* lp)
|
||||||
{
|
{
|
||||||
@ -178,10 +202,19 @@ parse_cbor(uint size, byte *rbuf, byte *tbuf, uint tbsize, struct linpool* lp)
|
|||||||
rbuf_read.pt = 0;
|
rbuf_read.pt = 0;
|
||||||
tbuf_read.pt = 0;
|
tbuf_read.pt = 0;
|
||||||
|
|
||||||
if (size == 0)
|
if (size <=7)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int serial_num = read_head(&rbuf_read);
|
||||||
|
int length_pt = add_header(&tbuf_read, lp, serial_num);
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
{
|
||||||
|
log("%i %x",i, tbuf[i] );
|
||||||
|
}
|
||||||
|
tbuf_read.size = tbsize - tbuf_read.pt;
|
||||||
|
|
||||||
struct value val = get_value(&rbuf_read);
|
struct value val = get_value(&rbuf_read);
|
||||||
ASSERT(val.major == BLOCK);
|
ASSERT(val.major == BLOCK);
|
||||||
ASSERT(val.val <=1);
|
ASSERT(val.val <=1);
|
||||||
@ -207,7 +240,7 @@ parse_cbor(uint size, byte *rbuf, byte *tbuf, uint tbsize, struct linpool* lp)
|
|||||||
ASSERT(compare_buff_str(&rbuf_read, val.val, "command"));
|
ASSERT(compare_buff_str(&rbuf_read, val.val, "command"));
|
||||||
rbuf_read.pt+=val.val;
|
rbuf_read.pt+=val.val;
|
||||||
|
|
||||||
tbuf_read.pt = do_command(&rbuf_read, &tbuf_read, items_in_block, lp);
|
tbuf_read.pt += do_command(&rbuf_read, &tbuf_read, items_in_block, lp);
|
||||||
if (items_in_block == -1)
|
if (items_in_block == -1)
|
||||||
{
|
{
|
||||||
val = get_value(&rbuf_read);
|
val = get_value(&rbuf_read);
|
||||||
@ -216,6 +249,12 @@ parse_cbor(uint size, byte *rbuf, byte *tbuf, uint tbsize, struct linpool* lp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
struct cbor_writer *w = cbor_init(tbuf_read.buff, tbuf_read.size, lp);
|
||||||
|
rewrite_4bytes_int(w, length_pt, tbuf_read.pt - 7); // add final length to header
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
{
|
||||||
|
log("%i %x",i, tbuf[i] );
|
||||||
|
}
|
||||||
lp_flush(lp);
|
lp_flush(lp);
|
||||||
log("parsed");
|
log("parsed");
|
||||||
return tbuf_read.pt;
|
return tbuf_read.pt;
|
||||||
|
@ -399,6 +399,7 @@ cli_kick(cli *c)
|
|||||||
uint
|
uint
|
||||||
yi_process(uint size, byte *rbuf, byte *tbuf, uint tbsize) {
|
yi_process(uint size, byte *rbuf, byte *tbuf, uint tbsize) {
|
||||||
log("capacity %i buffer %i", tbsize, tbuf);
|
log("capacity %i buffer %i", tbsize, tbuf);
|
||||||
|
//TODO
|
||||||
if (detect_down(size, rbuf))
|
if (detect_down(size, rbuf))
|
||||||
{
|
{
|
||||||
order_shutdown(0);
|
order_shutdown(0);
|
||||||
|
@ -269,7 +269,7 @@ pipe_show_stats_cbor(struct cbor_writer *w, struct pipe_proto *p)
|
|||||||
cbor_add_int(w, s1->imp_updates_accepted);
|
cbor_add_int(w, s1->imp_updates_accepted);
|
||||||
|
|
||||||
cbor_add_string(w, "import_withdraws");
|
cbor_add_string(w, "import_withdraws");
|
||||||
cbor_open_block_with_length(w, 5);
|
cbor_open_list_with_length(w, 5);
|
||||||
cbor_add_int(w, s2->exp_withdraws_received);
|
cbor_add_int(w, s2->exp_withdraws_received);
|
||||||
cbor_add_int(w, s1->imp_withdraws_invalid);
|
cbor_add_int(w, s1->imp_withdraws_invalid);
|
||||||
cbor_add_int(w, -1);
|
cbor_add_int(w, -1);
|
||||||
@ -277,7 +277,7 @@ pipe_show_stats_cbor(struct cbor_writer *w, struct pipe_proto *p)
|
|||||||
cbor_add_int(w, s1->imp_withdraws_accepted);
|
cbor_add_int(w, s1->imp_withdraws_accepted);
|
||||||
|
|
||||||
cbor_add_string(w, "export_updates");
|
cbor_add_string(w, "export_updates");
|
||||||
cbor_open_block_with_length(w, 5);
|
cbor_open_list_with_length(w, 5);
|
||||||
cbor_add_int(w, s1->exp_updates_received);
|
cbor_add_int(w, s1->exp_updates_received);
|
||||||
cbor_add_int(w, s1->exp_updates_rejected + s2->imp_updates_invalid);
|
cbor_add_int(w, s1->exp_updates_rejected + s2->imp_updates_invalid);
|
||||||
cbor_add_int(w, s1->exp_updates_filtered);
|
cbor_add_int(w, s1->exp_updates_filtered);
|
||||||
@ -285,7 +285,7 @@ pipe_show_stats_cbor(struct cbor_writer *w, struct pipe_proto *p)
|
|||||||
cbor_add_int(w, s2->imp_updates_accepted);
|
cbor_add_int(w, s2->imp_updates_accepted);
|
||||||
|
|
||||||
cbor_add_string(w, "export_withdraws");
|
cbor_add_string(w, "export_withdraws");
|
||||||
cbor_open_block_with_length(w, 5);
|
cbor_open_list_with_length(w, 5);
|
||||||
cbor_add_int(w, s1->exp_withdraws_received);
|
cbor_add_int(w, s1->exp_withdraws_received);
|
||||||
cbor_add_int(w, s2->imp_withdraws_invalid);
|
cbor_add_int(w, s2->imp_withdraws_invalid);
|
||||||
cbor_add_int(w, -1);
|
cbor_add_int(w, -1);
|
||||||
|
@ -898,7 +898,7 @@ rpki_show_proto_info_timer_cbor(struct cbor_writer *w, const char *name, uint nu
|
|||||||
cbor_open_block(w);
|
cbor_open_block(w);
|
||||||
if (tm_active(t))
|
if (tm_active(t))
|
||||||
{
|
{
|
||||||
cbor_string_int(w, "time", tm_get_real_time(tm_remains(t)) TO_S);
|
cbor_string_int(w, "time", tm_remains(t));
|
||||||
cbor_string_int(w, "num", num);
|
cbor_string_int(w, "num", num);
|
||||||
}
|
}
|
||||||
cbor_close_block_or_list(w);
|
cbor_close_block_or_list(w);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user