|
@@ -143,10 +143,27 @@ static const char* get_bgp_state_name(u_int16_t state) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* Check if -u (compact attributes) is enabled and append a field
|
|
|
|
+ * to the output to show any unknown attributes. */
|
|
|
|
+static void append_compact_unknown_attributes(attributes_t *attr) {
|
|
|
|
+ for(int i = 0; i < attr->unknown_num; i++) {
|
|
|
|
+ struct unknown_attr *ua = &(attr->unknown[i]);
|
|
|
|
+ printf("%02x:%02x:", ua->type, ua->flag);
|
|
|
|
+ for(size_t s = 0; s < ua->len; s++) {
|
|
|
|
+ printf("%02x", (uint8_t)(ua->raw[s]));
|
|
|
|
+ }
|
|
|
|
+ if(i < attr->unknown_num - 1) {
|
|
|
|
+ printf(" ");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ printf("|");
|
|
|
|
+}
|
|
|
|
+
|
|
static int mode=0;
|
|
static int mode=0;
|
|
static int timetype=0;
|
|
static int timetype=0;
|
|
static int show_packet_index = 0;
|
|
static int show_packet_index = 0;
|
|
static int show_large_comms = 0;
|
|
static int show_large_comms = 0;
|
|
|
|
+static int show_unknown_attributes = 0;
|
|
static int packet_index = 0;
|
|
static int packet_index = 0;
|
|
|
|
|
|
static const char USAGE[] = "\
|
|
static const char USAGE[] = "\
|
|
@@ -170,6 +187,7 @@ Options for -m and -M modes:\n\
|
|
-t change timestamps for RIB dumps reflect the last route modification\n\
|
|
-t change timestamps for RIB dumps reflect the last route modification\n\
|
|
-p show packet index at second position\n\
|
|
-p show packet index at second position\n\
|
|
-l show large communities field after regular communities\n\
|
|
-l show large communities field after regular communities\n\
|
|
|
|
+ -u show unassigned attributes in one-line mode\n\
|
|
\n\
|
|
\n\
|
|
Special options:\n\
|
|
Special options:\n\
|
|
-T run unit tests and exit\n\
|
|
-T run unit tests and exit\n\
|
|
@@ -188,7 +206,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
|
log_to_stderr();
|
|
log_to_stderr();
|
|
|
|
|
|
- while ((c=getopt(argc,argv,"if:o:t:mMHO:svTplq"))!=-1)
|
|
|
|
|
|
+ while ((c=getopt(argc,argv,"if:o:t:mMHO:svTplqu"))!=-1)
|
|
switch(c)
|
|
switch(c)
|
|
{
|
|
{
|
|
case 'H':
|
|
case 'H':
|
|
@@ -239,6 +257,9 @@ int main(int argc, char *argv[]) {
|
|
case 'l':
|
|
case 'l':
|
|
show_large_comms = 1;
|
|
show_large_comms = 1;
|
|
break;
|
|
break;
|
|
|
|
+ case 'u':
|
|
|
|
+ show_unknown_attributes = 1;
|
|
|
|
+ break;
|
|
case 'q':
|
|
case 'q':
|
|
quiet = true;
|
|
quiet = true;
|
|
break;
|
|
break;
|
|
@@ -1562,10 +1583,15 @@ static void table_line_announce(struct prefix *prefix,int count,BGPDUMP_ENTRY *e
|
|
|
|
|
|
printf("%s|", aggregate); /* AG/NAG */
|
|
printf("%s|", aggregate); /* AG/NAG */
|
|
|
|
|
|
- if (entry->attr->aggregator_addr.s_addr != -1)
|
|
|
|
- printf("%u %s|\n",entry->attr->aggregator_as,inet_ntoa(entry->attr->aggregator_addr));
|
|
|
|
- else
|
|
|
|
- printf("|\n");
|
|
|
|
|
|
+ if (entry->attr->aggregator_addr.s_addr != -1) {
|
|
|
|
+ printf("%u %s",entry->attr->aggregator_as,inet_ntoa(entry->attr->aggregator_addr));
|
|
|
|
+ }
|
|
|
|
+ printf("|");
|
|
|
|
+
|
|
|
|
+ if (show_unknown_attributes) {
|
|
|
|
+ append_compact_unknown_attributes(entry->attr);
|
|
|
|
+ }
|
|
|
|
+ printf("\n");
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1716,10 +1742,16 @@ static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
printf("%s|",aggregate); /* AG/NAG */
|
|
printf("%s|",aggregate); /* AG/NAG */
|
|
|
|
|
|
}
|
|
}
|
|
- if (entry->attr->aggregator_addr.s_addr != -1)
|
|
|
|
- printf("%u %s|\n",entry->attr->aggregator_as,inet_ntoa(entry->attr->aggregator_addr));
|
|
|
|
- else
|
|
|
|
- printf("|\n");
|
|
|
|
|
|
+ if (entry->attr->aggregator_addr.s_addr != -1) {
|
|
|
|
+ printf("%u %s",entry->attr->aggregator_as,inet_ntoa(entry->attr->aggregator_addr));
|
|
|
|
+ }
|
|
|
|
+ printf("|");
|
|
|
|
+
|
|
|
|
+ if (show_unknown_attributes) {
|
|
|
|
+ append_compact_unknown_attributes(entry->attr);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ printf("\n");
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1829,11 +1861,16 @@ static void table_line_announce6(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
printf("%s|", aggregate); /* AG/NAG */
|
|
printf("%s|", aggregate); /* AG/NAG */
|
|
|
|
|
|
|
|
|
|
- if (entry->attr->aggregator_addr.s_addr != -1)
|
|
|
|
- printf("%u %s|\n",entry->attr->aggregator_as,inet_ntoa(entry->attr->aggregator_addr));
|
|
|
|
- else
|
|
|
|
- printf("|\n");
|
|
|
|
|
|
+ if (entry->attr->aggregator_addr.s_addr != -1) {
|
|
|
|
+ printf("%u %s",entry->attr->aggregator_as,inet_ntoa(entry->attr->aggregator_addr));
|
|
|
|
+ }
|
|
|
|
+ printf("|");
|
|
|
|
+
|
|
|
|
+ if (show_unknown_attributes) {
|
|
|
|
+ append_compact_unknown_attributes(entry->attr);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ printf("\n");
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1946,17 +1983,25 @@ static void table_line_mrtd_route(BGPDUMP_MRTD_TABLE_DUMP *route,BGPDUMP_ENTRY *
|
|
|
|
|
|
printf("%s|",aggregate); /* AG/NAG */
|
|
printf("%s|",aggregate); /* AG/NAG */
|
|
|
|
|
|
- if (entry->attr->aggregator_addr.s_addr != -1)
|
|
|
|
- printf("%u %s|\n",entry->attr->aggregator_as,inet_ntoa(entry->attr->aggregator_addr));
|
|
|
|
- else
|
|
|
|
- printf("|\n");
|
|
|
|
|
|
+ if (entry->attr->aggregator_addr.s_addr != -1) {
|
|
|
|
+ printf("%u %s",entry->attr->aggregator_as,inet_ntoa(entry->attr->aggregator_addr));
|
|
|
|
+ }
|
|
|
|
+ printf("|");
|
|
|
|
+
|
|
|
|
+ if (show_unknown_attributes) {
|
|
|
|
+ append_compact_unknown_attributes(entry->attr);
|
|
|
|
+ }
|
|
|
|
+ printf("\n");
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
else
|
|
else
|
|
{
|
|
{
|
|
printf("%s|%u|",peer,route->peer_as);
|
|
printf("%s|%u|",peer,route->peer_as);
|
|
printf("%s/%d|%s|%s\n",prefix,route->mask,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
printf("%s/%d|%s|%s\n",prefix,route->mask,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
static char *describe_origin(int origin) {
|
|
static char *describe_origin(int origin) {
|
|
@@ -2072,10 +2117,15 @@ static void table_line_dump_v2_prefix(BGPDUMP_TABLE_DUMP_V2_PREFIX *e,BGPDUMP_EN
|
|
|
|
|
|
printf("%s|",aggregate);
|
|
printf("%s|",aggregate);
|
|
|
|
|
|
- if (attr->aggregator_addr.s_addr != -1)
|
|
|
|
- printf("%u %s|\n",attr->aggregator_as,inet_ntoa(attr->aggregator_addr));
|
|
|
|
- else
|
|
|
|
- printf("|\n");
|
|
|
|
|
|
+ if (attr->aggregator_addr.s_addr != -1) {
|
|
|
|
+ printf("%u %s",attr->aggregator_as,inet_ntoa(attr->aggregator_addr));
|
|
|
|
+ }
|
|
|
|
+ printf("|");
|
|
|
|
+
|
|
|
|
+ if (show_unknown_attributes) {
|
|
|
|
+ append_compact_unknown_attributes(attr);
|
|
|
|
+ }
|
|
|
|
+ printf("\n");
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|