add 'packet' log option for serializer. show protocol options

This commit is contained in:
Hannes Gredler
2023-09-01 08:28:47 +00:00
committed by Christian Giese
parent 2509241000
commit 2a70d6423a
2 changed files with 19 additions and 5 deletions
+16 -2
View File
@@ -80,6 +80,7 @@ struct keyval_ log_names[] = {
{ DEBUG, "debug" },
{ LSP, "lsp" },
{ LSDB, "lsdb" },
{ PACKET, "packet" },
{ CTRL, "ctrl" },
{ ERROR, "error" },
#ifdef BNGBLASTER_TIMER_LOGGING
@@ -95,7 +96,6 @@ struct keyval_ log_names[] = {
struct keyval_ proto_names[] = {
{ PROTO_ISIS, "isis" },
{ PROTO_OSPF2, "ospf2" },
{ PROTO_OSPF2, "ospf" }, /* "ospf" is an alias for ospf2 */
{ PROTO_OSPF3, "ospf3" },
{ 0, NULL}
};
@@ -124,7 +124,20 @@ lspgen_print_usage_arg(struct option *option)
int len;
if (option->has_arg == 1) {
if (strcmp(option->name, "log") == 0) {
/* protocol */
if (strcmp(option->name, "protocol") == 0) {
len = 0;
ptr = proto_names;
while (ptr->key) {
len += snprintf(buf+len, sizeof(buf)-len, "%s%s", len ? "|" : " ", ptr->key);
ptr++;
}
return buf;
}
/* logging */
if (strcmp(option->name, "log") == 0) {
len = 0;
ptr = log_names;
while (ptr->key) {
@@ -134,6 +147,7 @@ lspgen_print_usage_arg(struct option *option)
return buf;
}
/* authentication-type */
if (strcmp(option->name, "authentication-type") == 0) {
len = 0;
ptr = isis_auth_names;
+3 -3
View File
@@ -648,7 +648,7 @@ lspgen_propagate_buffer_up (lsdb_packet_t *packet, uint level)
}
char *
lspgen_log_serializer_state (uint16_t state)
lspgen_format_serializer_state (uint16_t state)
{
static char buf[128];
int len;
@@ -720,7 +720,7 @@ lspgen_serialize_ospf2_state(lsdb_attr_t *attr, lsdb_packet_t *packet, uint16_t
buf1 = &packet->bufX[1];
buf2 = &packet->bufX[2];
LOG(LSDB, " %s\n", lspgen_log_serializer_state(state));
LOG(PACKET, " %s\n", lspgen_format_serializer_state(state));
/* close Level 2 */
if (state & CLOSE_LEVEL2) {
@@ -930,7 +930,7 @@ lspgen_serialize_ospf2_attr(lsdb_attr_t *attr, lsdb_packet_t *packet)
{
uint16_t state;
LOG(LSDB, "Serialize attr {0x%02x, 0x%02x, 0x%02x, 0x%02x}, last attr {0x%02x, 0x%02x, 0x%02x, 0x%02x}\n",
LOG(PACKET, "Serialize attr {0x%02x, 0x%02x, 0x%02x, 0x%02x}, last attr {0x%02x, 0x%02x, 0x%02x, 0x%02x}\n",
attr->key.attr_cp[0],
attr->key.attr_cp[1],
attr->key.attr_cp[2],