|
@@ -42,7 +42,7 @@ static void process(BGPDUMP_ENTRY *entry);
|
|
|
static void process_bgpdump_mrtd_bgp(BGPDUMP_ENTRY *entry);
|
|
|
static void show_ipv4_address(struct in_addr ip);
|
|
|
static void show_attr(attributes_t *attr);
|
|
|
-static void show_prefixes(int count,struct prefix *prefix);
|
|
|
+static void show_prefixes(int count,struct prefix *prefix, int addpath);
|
|
|
static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY *entry,char *time_str);
|
|
|
static void table_line_announce(struct prefix *prefix,int count,BGPDUMP_ENTRY *entry,char *time_str);
|
|
|
static void mrtd_table_line_withdraw(struct prefix *prefix, int count, BGPDUMP_ENTRY *entry, char *time_str);
|
|
@@ -54,7 +54,7 @@ static char *describe_origin(int origin);
|
|
|
static int bgp4mp_message_direction_receive(BGPDUMP_ENTRY *entry);
|
|
|
|
|
|
#ifdef BGPDUMP_HAVE_IPV6
|
|
|
- void show_prefixes6(int count,struct prefix *prefix);
|
|
|
+ void show_prefixes6(int count,struct prefix *prefix, int addpath);
|
|
|
static void table_line_withdraw6(struct prefix *prefix,int count,BGPDUMP_ENTRY *entry,char *time_str);
|
|
|
static void table_line_announce6(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY *entry,char *time_str);
|
|
|
#endif
|
|
@@ -89,20 +89,60 @@ static int bgp4mp_message_direction_receive(BGPDUMP_ENTRY *entry) {
|
|
|
- BGP4MP_ET (Extended Header)
|
|
|
- BGP4MP_LOCAL (Local)
|
|
|
- BGP4MP_ET_LOCAL (Local and Extended Header)
|
|
|
+ - BGP4MP_AP (Standard, Additional Paths)
|
|
|
+ - BGP4MP_ET_AP (Extended Header, Additional Paths)
|
|
|
+ - BGP4MP_LOCAL_AP (Local, Additional Paths)
|
|
|
+ - BGP4MP_ET_LOCAL_AP (Local, Extended Header, Additional Paths)
|
|
|
*/
|
|
|
static const char* get_bgp4mp_format(BGPDUMP_ENTRY *entry) {
|
|
|
- if (entry->type == BGPDUMP_TYPE_ZEBRA_BGP_ET &&
|
|
|
- !bgp4mp_message_direction_receive(entry)) {
|
|
|
- return "BGP4MP_ET_LOCAL";
|
|
|
+ if (entry->type == BGPDUMP_TYPE_ZEBRA_BGP_ET && !bgp4mp_message_direction_receive(entry)) {
|
|
|
+ if (is_addpath(entry)) {
|
|
|
+ return "BGP4MP_ET_LOCAL_AP";
|
|
|
+ } else {
|
|
|
+ return "BGP4MP_ET_LOCAL";
|
|
|
+ }
|
|
|
} else if (entry->type == BGPDUMP_TYPE_ZEBRA_BGP_ET) {
|
|
|
- return "BGP4MP_ET";
|
|
|
+ if (is_addpath(entry)) {
|
|
|
+ return "BGP4MP_ET_AP";
|
|
|
+ } else {
|
|
|
+ return "BGP4MP_ET";
|
|
|
+ }
|
|
|
} else if (!bgp4mp_message_direction_receive(entry)) {
|
|
|
- return "BGP4MP_LOCAL";
|
|
|
+ if (is_addpath(entry)) {
|
|
|
+ return "BGP4MP_LOCAL_AP";
|
|
|
+ } else {
|
|
|
+ return "BGP4MP_LOCAL";
|
|
|
+ }
|
|
|
+ } else if (is_addpath(entry)) {
|
|
|
+ return "BGP4MP_AP";
|
|
|
} else {
|
|
|
return "BGP4MP";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static const char* get_bgp_state_name(u_int16_t state) {
|
|
|
+
|
|
|
+ const char *bgp_state_name[] = {
|
|
|
+ "Unknown",
|
|
|
+ "Idle",
|
|
|
+ "Connect",
|
|
|
+ "Active",
|
|
|
+ "Opensent",
|
|
|
+ "Openconfirm",
|
|
|
+ "Established",
|
|
|
+ /* not defined in RFC 6396 but quagga puts them into update files */
|
|
|
+ "Clearing",
|
|
|
+ "Deleted",
|
|
|
+ NULL
|
|
|
+ };
|
|
|
+
|
|
|
+ if (state && state >= (sizeof(bgp_state_name)) / (sizeof(*bgp_state_name))) {
|
|
|
+ return "Unknown";
|
|
|
+ } else {
|
|
|
+ return bgp_state_name[state];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static int mode=0;
|
|
|
static int timetype=0;
|
|
|
static int show_packet_index = 0;
|
|
@@ -137,7 +177,7 @@ extern int optind;
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
|
- char c;
|
|
|
+ int c;
|
|
|
int fd;
|
|
|
bool usage_error = false;
|
|
|
bool use_syslog = true;
|
|
@@ -233,17 +273,6 @@ int main(int argc, char *argv[]) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-const char *bgp_state_name[] = {
|
|
|
- "Unknown",
|
|
|
- "Idle",
|
|
|
- "Connect",
|
|
|
- "Active",
|
|
|
- "Opensent",
|
|
|
- "Openconfirm",
|
|
|
- "Established",
|
|
|
- NULL
|
|
|
-};
|
|
|
-
|
|
|
void process(BGPDUMP_ENTRY *entry) {
|
|
|
|
|
|
struct tm *date;
|
|
@@ -252,19 +281,21 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
char time_str_fixed[128];
|
|
|
char prefix[BGPDUMP_ADDRSTRLEN];
|
|
|
char *bgp4mp_format;
|
|
|
+ char *bgp4mp_subtype_format;
|
|
|
+ int len;
|
|
|
|
|
|
date=gmtime(&entry->time);
|
|
|
time2str(date,time_str_fixed);
|
|
|
|
|
|
if (mode == 1) {
|
|
|
// Timestamp mode
|
|
|
- sprintf(time_str, "%ld", entry->time);
|
|
|
+ len = sprintf(time_str, "%lld", (long long)entry->time);
|
|
|
} else {
|
|
|
- time2str(date,time_str);
|
|
|
+ len = time2str(date,time_str);
|
|
|
}
|
|
|
// Appending microseconds to time_str if needed
|
|
|
if (entry->type == BGPDUMP_TYPE_ZEBRA_BGP_ET) {
|
|
|
- sprintf(time_str, "%s.%06ld", time_str, entry->ms);
|
|
|
+ sprintf(time_str + len, ".%06ld", entry->ms);
|
|
|
}
|
|
|
|
|
|
if (mode==0)
|
|
@@ -352,9 +383,11 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
|
|
|
case BGPDUMP_TYPE_TABLE_DUMP_V2:
|
|
|
if(mode == 0){
|
|
|
+
|
|
|
char peer_ip[BGPDUMP_ADDRSTRLEN];
|
|
|
//char time_str[30];
|
|
|
int i;
|
|
|
+ int addpath = is_addpath(entry);
|
|
|
|
|
|
BGPDUMP_TABLE_DUMP_V2_PREFIX *e;
|
|
|
e = &entry->body.mrtd_table_dump_v2_prefix;
|
|
@@ -372,13 +405,22 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
// for multiple peers, we may need to print another TIME ourselves
|
|
|
if(i) printf("\nTIME: %s\n",time_str_fixed);
|
|
|
if(e->afi == AFI_IP){
|
|
|
- printf("TYPE: TABLE_DUMP_V2/IPV4_UNICAST\n");
|
|
|
+ if (addpath)
|
|
|
+ printf("TYPE: TABLE_DUMP_V2/IPV4_UNICAST_ADDPATH\n");
|
|
|
+ else
|
|
|
+ printf("TYPE: TABLE_DUMP_V2/IPV4_UNICAST\n");
|
|
|
#ifdef BGPDUMP_HAVE_IPV6
|
|
|
} else if(e->afi == AFI_IP6){
|
|
|
- printf("TYPE: TABLE_DUMP_V2/IPV6_UNICAST\n");
|
|
|
+ if (addpath)
|
|
|
+ printf("TYPE: TABLE_DUMP_V2/IPV6_UNICAST_ADDPATH\n");
|
|
|
+ else
|
|
|
+ printf("TYPE: TABLE_DUMP_V2/IPV6_UNICAST\n");
|
|
|
#endif
|
|
|
}
|
|
|
- printf("PREFIX: %s/%d\n",prefix, e->prefix_length);
|
|
|
+ printf("PREFIX: %s/%d",prefix, e->prefix_length);
|
|
|
+ if (addpath)
|
|
|
+ printf(" PATH_ID: %u", e->entries[i].path_id);
|
|
|
+ printf("\n");
|
|
|
printf("SEQUENCE: %d\n",e->seq);
|
|
|
|
|
|
if(e->entries[i].peer->afi == AFI_IP){
|
|
@@ -414,6 +456,8 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
} else {
|
|
|
bgp4mp_format = "BGP4MP_ET";
|
|
|
}
|
|
|
+
|
|
|
+ int addpath = is_addpath(entry);
|
|
|
|
|
|
switch(entry->subtype)
|
|
|
{
|
|
@@ -421,15 +465,31 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
case BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE_AS4:
|
|
|
case BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE_LOCAL:
|
|
|
case BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE_AS4_LOCAL:
|
|
|
+ case BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE_ADDPATH:
|
|
|
+ case BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE_AS4_ADDPATH:
|
|
|
+ case BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE_LOCAL_ADDPATH:
|
|
|
+ case BGPDUMP_SUBTYPE_ZEBRA_BGP_MESSAGE_AS4_LOCAL_ADDPATH:
|
|
|
+
|
|
|
+ if (addpath) {
|
|
|
+ if (bgp4mp_message_direction_receive(entry))
|
|
|
+ bgp4mp_subtype_format = "MESSAGE_ADDPATH";
|
|
|
+ else
|
|
|
+ bgp4mp_subtype_format = "MESSAGE_LOCAL_ADDPATH";
|
|
|
+ } else {
|
|
|
+ if (bgp4mp_message_direction_receive(entry))
|
|
|
+ bgp4mp_subtype_format = "MESSAGE";
|
|
|
+ else
|
|
|
+ bgp4mp_subtype_format = "MESSAGE_LOCAL";
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
switch(entry->body.zebra_message.type)
|
|
|
{
|
|
|
case BGP_MSG_UPDATE:
|
|
|
if (mode ==0)
|
|
|
{
|
|
|
- bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("TYPE: %s/MESSAGE/Update\n", bgp4mp_format)
|
|
|
- : printf("TYPE: %s/MESSAGE_LOCAL/Update\n", bgp4mp_format);
|
|
|
+
|
|
|
+ printf("TYPE: %s/%s/Update\n", bgp4mp_format, bgp4mp_subtype_format);
|
|
|
|
|
|
if (entry->body.zebra_message.source_as)
|
|
|
{
|
|
@@ -511,52 +571,58 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
#endif
|
|
|
printf("WITHDRAW\n");
|
|
|
if (entry->body.zebra_message.withdraw_count)
|
|
|
- show_prefixes(entry->body.zebra_message.withdraw_count,entry->body.zebra_message.withdraw);
|
|
|
+
|
|
|
+ // old style
|
|
|
+ show_prefixes(entry->body.zebra_message.withdraw_count,entry->body.zebra_message.withdraw, addpath);
|
|
|
|
|
|
+ // MP
|
|
|
if (entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST] && entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST]->prefix_count)
|
|
|
- show_prefixes(entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST]->nlri);
|
|
|
+ show_prefixes(entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST]->nlri, addpath);
|
|
|
|
|
|
if (entry->attr->mp_info->withdraw[AFI_IP][SAFI_MULTICAST] && entry->attr->mp_info->withdraw[AFI_IP][SAFI_MULTICAST]->prefix_count)
|
|
|
- show_prefixes(entry->attr->mp_info->withdraw[AFI_IP][SAFI_MULTICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP][SAFI_MULTICAST]->nlri);
|
|
|
+ show_prefixes(entry->attr->mp_info->withdraw[AFI_IP][SAFI_MULTICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP][SAFI_MULTICAST]->nlri, addpath);
|
|
|
|
|
|
if (entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST_MULTICAST] && entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST_MULTICAST]->prefix_count)
|
|
|
- show_prefixes(entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST_MULTICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST_MULTICAST]->nlri);
|
|
|
+ show_prefixes(entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST_MULTICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST_MULTICAST]->nlri, addpath);
|
|
|
|
|
|
#ifdef BGPDUMP_HAVE_IPV6
|
|
|
if (entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST] && entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST]->prefix_count)
|
|
|
- show_prefixes6(entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST]->nlri);
|
|
|
+ show_prefixes6(entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST]->nlri, addpath);
|
|
|
|
|
|
if (entry->attr->mp_info->withdraw[AFI_IP6][SAFI_MULTICAST] && entry->attr->mp_info->withdraw[AFI_IP6][SAFI_MULTICAST]->prefix_count)
|
|
|
- show_prefixes6(entry->attr->mp_info->withdraw[AFI_IP6][SAFI_MULTICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP6][SAFI_MULTICAST]->nlri);
|
|
|
+ show_prefixes6(entry->attr->mp_info->withdraw[AFI_IP6][SAFI_MULTICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP6][SAFI_MULTICAST]->nlri, addpath);
|
|
|
|
|
|
if (entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST_MULTICAST] && entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST_MULTICAST]->prefix_count)
|
|
|
- show_prefixes6(entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST_MULTICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST_MULTICAST]->nlri);
|
|
|
+ show_prefixes6(entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST_MULTICAST]->prefix_count,entry->attr->mp_info->withdraw[AFI_IP6][SAFI_UNICAST_MULTICAST]->nlri, addpath);
|
|
|
#endif
|
|
|
}
|
|
|
if ( (entry->body.zebra_message.announce_count) || (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MP_REACH_NLRI)))
|
|
|
{
|
|
|
printf("ANNOUNCE\n");
|
|
|
if (entry->body.zebra_message.announce_count)
|
|
|
- show_prefixes(entry->body.zebra_message.announce_count,entry->body.zebra_message.announce);
|
|
|
+
|
|
|
+ // old style
|
|
|
+ show_prefixes(entry->body.zebra_message.announce_count,entry->body.zebra_message.announce, addpath);
|
|
|
|
|
|
+ // MP
|
|
|
if (entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST] && entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->prefix_count)
|
|
|
- show_prefixes(entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nlri);
|
|
|
+ show_prefixes(entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nlri, addpath);
|
|
|
|
|
|
if (entry->attr->mp_info->announce[AFI_IP][SAFI_MULTICAST] && entry->attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->prefix_count)
|
|
|
- show_prefixes(entry->attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nlri);
|
|
|
+ show_prefixes(entry->attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nlri, addpath);
|
|
|
|
|
|
if (entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST] && entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->prefix_count)
|
|
|
- show_prefixes(entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nlri);
|
|
|
+ show_prefixes(entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nlri, addpath);
|
|
|
|
|
|
#ifdef BGPDUMP_HAVE_IPV6
|
|
|
if (entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST] && entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->prefix_count)
|
|
|
- show_prefixes6(entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nlri);
|
|
|
+ show_prefixes6(entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nlri, addpath);
|
|
|
|
|
|
if (entry->attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST] && entry->attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->prefix_count)
|
|
|
- show_prefixes6(entry->attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nlri);
|
|
|
+ show_prefixes6(entry->attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nlri, addpath);
|
|
|
|
|
|
if (entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST] && entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->prefix_count)
|
|
|
- show_prefixes6(entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nlri);
|
|
|
+ show_prefixes6(entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->prefix_count,entry->attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nlri, addpath);
|
|
|
#endif
|
|
|
}
|
|
|
}
|
|
@@ -565,8 +631,10 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
if ((entry->body.zebra_message.withdraw_count) || (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MP_UNREACH_NLRI)))
|
|
|
{
|
|
|
|
|
|
+ // old style
|
|
|
table_line_withdraw(entry->body.zebra_message.withdraw,entry->body.zebra_message.withdraw_count,entry,time_str);
|
|
|
-
|
|
|
+
|
|
|
+ // MP
|
|
|
if (entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST] && entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST]->prefix_count)
|
|
|
table_line_withdraw(entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST]->nlri,entry->attr->mp_info->withdraw[AFI_IP][SAFI_UNICAST]->prefix_count,entry,time_str);
|
|
|
|
|
@@ -590,7 +658,10 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
}
|
|
|
if ( (entry->body.zebra_message.announce_count) || (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MP_REACH_NLRI)))
|
|
|
{
|
|
|
+ // old style
|
|
|
table_line_announce(entry->body.zebra_message.announce,entry->body.zebra_message.announce_count,entry,time_str);
|
|
|
+
|
|
|
+ // MP
|
|
|
if (entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST] && entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->prefix_count)
|
|
|
table_line_announce_1(entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST],entry->attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->prefix_count,entry,time_str);
|
|
|
if (entry->attr->mp_info->announce[AFI_IP][SAFI_MULTICAST] && entry->attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->prefix_count)
|
|
@@ -614,9 +685,7 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
if (mode != 0)
|
|
|
break;
|
|
|
|
|
|
- bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("TYPE: %s/MESSAGE/Open\n", bgp4mp_format)
|
|
|
- : printf("TYPE: %s/MESSAGE_LOCAL/Open\n", bgp4mp_format);
|
|
|
+ printf("TYPE: %s/%s/Open\n", bgp4mp_format, bgp4mp_subtype_format);
|
|
|
|
|
|
if (entry->body.zebra_message.source_as)
|
|
|
{
|
|
@@ -671,9 +740,9 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
case BGP_MSG_NOTIFY:
|
|
|
if (mode != 0)
|
|
|
break;
|
|
|
- bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("TYPE: %s/MESSAGE/Notify\n", bgp4mp_format)
|
|
|
- : printf("TYPE: %s/MESSAGE_LOCAL/Notify\n", bgp4mp_format);
|
|
|
+
|
|
|
+ printf("TYPE: %s/%s/Notify\n", bgp4mp_format, bgp4mp_subtype_format);
|
|
|
+
|
|
|
if (entry->body.zebra_message.source_as)
|
|
|
{
|
|
|
printf("FROM:");
|
|
@@ -846,9 +915,8 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
if ( mode != 0)
|
|
|
break;
|
|
|
|
|
|
- bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("TYPE: %s/MESSAGE/Keepalive\n", bgp4mp_format)
|
|
|
- : printf("TYPE: %s/MESSAGE_LOCAL/Keepalive\n", bgp4mp_format);
|
|
|
+ printf("TYPE: %s/%s/Keepalive\n", bgp4mp_format, bgp4mp_subtype_format);
|
|
|
+
|
|
|
if (entry->body.zebra_message.source_as)
|
|
|
{
|
|
|
printf("FROM:");
|
|
@@ -926,7 +994,7 @@ void process(BGPDUMP_ENTRY *entry) {
|
|
|
// printf(" N/A ");
|
|
|
printf("AS%u\n",entry->body.zebra_state_change.source_as);
|
|
|
|
|
|
- printf("STATE: %s/%s\n",bgp_state_name[entry->body.zebra_state_change.old_state],bgp_state_name[entry->body.zebra_state_change.new_state]);
|
|
|
+ printf("STATE: %s/%s\n",get_bgp_state_name(entry->body.zebra_state_change.old_state),get_bgp_state_name(entry->body.zebra_state_change.new_state));
|
|
|
}
|
|
|
else if (mode==1 || mode==2 ) //-m -M
|
|
|
{
|
|
@@ -977,7 +1045,7 @@ void process_bgpdump_mrtd_bgp(BGPDUMP_ENTRY *entry) {
|
|
|
date=gmtime(&entry->time);
|
|
|
|
|
|
if (mode == 1) {
|
|
|
- sprintf(time_str, "%ld", entry->time);
|
|
|
+ sprintf(time_str, "%lld", (long long)entry->time);
|
|
|
} else {
|
|
|
|
|
|
time2str(date, time_str);
|
|
@@ -1005,11 +1073,11 @@ void process_bgpdump_mrtd_bgp(BGPDUMP_ENTRY *entry) {
|
|
|
show_attr(entry->attr);
|
|
|
if (entry->body.mrtd_message.withdraw_count) {
|
|
|
printf("WITHDRAW\n");
|
|
|
- show_prefixes(entry->body.mrtd_message.withdraw_count, entry->body.mrtd_message.withdraw);
|
|
|
+ show_prefixes(entry->body.mrtd_message.withdraw_count, entry->body.mrtd_message.withdraw, 0);
|
|
|
}
|
|
|
if (entry->body.mrtd_message.announce_count) {
|
|
|
printf("ANNOUNCE\n");
|
|
|
- show_prefixes(entry->body.mrtd_message.announce_count, entry->body.mrtd_message.announce);
|
|
|
+ show_prefixes(entry->body.mrtd_message.announce_count, entry->body.mrtd_message.announce, 0);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -1029,8 +1097,8 @@ void process_bgpdump_mrtd_bgp(BGPDUMP_ENTRY *entry) {
|
|
|
printf("PEER:");
|
|
|
show_ipv4_address(entry->body.mrtd_state_change.destination_ip);
|
|
|
printf("AS%u\n", entry->body.mrtd_state_change.destination_as);
|
|
|
- printf("STATE: %s/%s\n", bgp_state_name[entry->body.mrtd_state_change.old_state],
|
|
|
- bgp_state_name[entry->body.mrtd_state_change.new_state]);
|
|
|
+ printf("STATE: %s/%s\n", get_bgp_state_name(entry->body.mrtd_state_change.old_state),
|
|
|
+ get_bgp_state_name(entry->body.mrtd_state_change.new_state));
|
|
|
}
|
|
|
else if (mode == 1 || mode == 2) {
|
|
|
show_line_prefix("BGP", time_str, "STATE");
|
|
@@ -1170,68 +1238,89 @@ void show_attr(attributes_t *attr) {
|
|
|
printf("MP_REACH_NLRI");
|
|
|
#ifdef BGPDUMP_HAVE_IPV6
|
|
|
if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST] || attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST] || attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST])
|
|
|
-
|
|
|
{
|
|
|
char buf[128];
|
|
|
|
|
|
if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST])
|
|
|
{
|
|
|
printf("(IPv6 Unicast)\n");
|
|
|
- printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop,buf));
|
|
|
- if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_len==32)
|
|
|
- printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_local,buf));
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_len==4)
|
|
|
+ printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop.v4_addr));
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_len==16)
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop,buf));
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_len==32) {
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop,buf));
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_local,buf));
|
|
|
+ }
|
|
|
}
|
|
|
else if (attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST])
|
|
|
{
|
|
|
printf("(IPv6 Multicast)\n");
|
|
|
- printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop,buf));
|
|
|
- if (attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop_len==32)
|
|
|
- printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop_local,buf));
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- printf("(IPv6 Both unicast and multicast)\n");
|
|
|
- printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop,buf));
|
|
|
- if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop_len==32)
|
|
|
- printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop_local,buf));
|
|
|
-
|
|
|
-
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop_len==4)
|
|
|
+ printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop.v4_addr));
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop_len==16)
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop,buf));
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop_len==32) {
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop,buf));
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_MULTICAST]->nexthop_local,buf));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ printf("(IPv6 Both unicast and multicast)\n");
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop_len==4)
|
|
|
+ printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop.v4_addr));
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop_len==16)
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop,buf));
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop_len==32) {
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop,buf));
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST_MULTICAST]->nexthop_local,buf));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
#endif
|
|
|
{
|
|
|
-
|
|
|
- if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST])
|
|
|
- {
|
|
|
- printf("(IPv4 Unicast)\n");
|
|
|
- printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop.v4_addr));
|
|
|
- if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_len==32)
|
|
|
- printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_local.v4_addr));
|
|
|
-
|
|
|
- }
|
|
|
- else if (attr->mp_info->announce[AFI_IP][SAFI_MULTICAST])
|
|
|
- {
|
|
|
- printf("(IPv4 Multicast)\n");
|
|
|
- printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop.v4_addr));
|
|
|
- if (attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop_len==32)
|
|
|
- printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop_local.v4_addr));
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- else if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST])
|
|
|
- {
|
|
|
- printf("(IPv4 Both unicast and multicast)\n");
|
|
|
- printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop.v4_addr));
|
|
|
- if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop_len==32)
|
|
|
- printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop_local.v4_addr));
|
|
|
-
|
|
|
+ char buf[128];
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST])
|
|
|
+ {
|
|
|
+ printf("(IPv4 Unicast)\n");
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_len==4)
|
|
|
+ printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop.v4_addr));
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_len==16)
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop,buf));
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_len==32) {
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop,buf));
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_local,buf));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (attr->mp_info->announce[AFI_IP][SAFI_MULTICAST])
|
|
|
+ {
|
|
|
+ printf("(IPv4 Multicast)\n");
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop_len==4)
|
|
|
+ printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop.v4_addr));
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop_len==16)
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop,buf));
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop_len==32) {
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop,buf));
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_MULTICAST]->nexthop_local,buf));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST])
|
|
|
+ {
|
|
|
+ printf("(IPv4 Both unicast and multicast)\n");
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop_len==4)
|
|
|
+ printf("NEXT_HOP: %s\n",inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop.v4_addr));
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop_len==16)
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop,buf));
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop_len==32) {
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop,buf));
|
|
|
+ printf("NEXT_HOP: %s\n",fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_UNICAST_MULTICAST]->nexthop_local,buf));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if( (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MP_UNREACH_NLRI) )!=0)
|
|
|
{
|
|
@@ -1287,19 +1376,27 @@ void show_attr(attributes_t *attr) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-void show_prefixes(int count,struct prefix *prefix) {
|
|
|
+void show_prefixes(int count,struct prefix *prefix, int addpath) {
|
|
|
int i;
|
|
|
for(i=0;i<count;i++)
|
|
|
- printf(" %s/%d\n",inet_ntoa(prefix[i].address.v4_addr),prefix[i].len);
|
|
|
+ if (addpath)
|
|
|
+ printf(" %s/%d PATH_ID: %u\n",inet_ntoa(prefix[i].address.v4_addr),prefix[i].len, prefix[i].path_id);
|
|
|
+ else
|
|
|
+ printf(" %s/%d\n",inet_ntoa(prefix[i].address.v4_addr),prefix[i].len);
|
|
|
+
|
|
|
}
|
|
|
#ifdef BGPDUMP_HAVE_IPV6
|
|
|
-void show_prefixes6(int count,struct prefix *prefix)
|
|
|
+void show_prefixes6(int count,struct prefix *prefix, int addpath)
|
|
|
{
|
|
|
int i;
|
|
|
char buf[128];
|
|
|
|
|
|
for (i=0;i<count;i++)
|
|
|
- printf(" %s/%d\n",fmt_ipv6(prefix[i].address,buf),prefix[i].len);
|
|
|
+ if (addpath)
|
|
|
+ printf(" %s/%d PATH_ID: %u\n",fmt_ipv6(prefix[i].address,buf),prefix[i].len, prefix[i].path_id);
|
|
|
+ else
|
|
|
+ printf(" %s/%d\n",fmt_ipv6(prefix[i].address,buf),prefix[i].len);
|
|
|
+
|
|
|
}
|
|
|
#endif
|
|
|
|
|
@@ -1336,7 +1433,9 @@ static void table_line_withdraw(struct prefix *prefix,int count,BGPDUMP_ENTRY *e
|
|
|
entry->body.zebra_message.destination_as);
|
|
|
break;
|
|
|
}
|
|
|
- printf("%s/%d\n",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len);
|
|
|
+ is_addpath(entry)
|
|
|
+ ? printf("%s/%d|%u\n",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len,prefix[idx].path_id)
|
|
|
+ : printf("%s/%d\n",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1355,11 +1454,11 @@ static void table_line_withdraw6(struct prefix *prefix,int count,BGPDUMP_ENTRY *
|
|
|
switch(entry->body.zebra_message.address_family) {
|
|
|
case AFI_IP6:
|
|
|
bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("%s|%u|%s/%d\n",
|
|
|
+ ? printf("%s|%u|%s/%d",
|
|
|
fmt_ipv6(entry->body.zebra_message.source_ip,buf1),
|
|
|
entry->body.zebra_message.source_as,
|
|
|
fmt_ipv6(prefix[idx].address,buf),prefix[idx].len)
|
|
|
- : printf("%s|%u|%s/%d\n",
|
|
|
+ : printf("%s|%u|%s/%d",
|
|
|
fmt_ipv6(entry->body.zebra_message.destination_ip,buf1),
|
|
|
entry->body.zebra_message.destination_as,
|
|
|
fmt_ipv6(prefix[idx].address,buf),prefix[idx].len);
|
|
@@ -1367,16 +1466,19 @@ static void table_line_withdraw6(struct prefix *prefix,int count,BGPDUMP_ENTRY *
|
|
|
case AFI_IP:
|
|
|
default:
|
|
|
bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("%s|%u|%s/%d\n",
|
|
|
+ ? printf("%s|%u|%s/%d",
|
|
|
fmt_ipv4(entry->body.zebra_message.source_ip,buf1),
|
|
|
entry->body.zebra_message.source_as,
|
|
|
fmt_ipv6(prefix[idx].address,buf),prefix[idx].len)
|
|
|
- : printf("%s|%u|%s/%d\n",
|
|
|
+ : printf("%s|%u|%s/%d",
|
|
|
fmt_ipv6(entry->body.zebra_message.destination_ip,buf1),
|
|
|
entry->body.zebra_message.destination_as,
|
|
|
fmt_ipv6(prefix[idx].address,buf),prefix[idx].len);
|
|
|
break;
|
|
|
}
|
|
|
+ is_addpath(entry)
|
|
|
+ ? printf("|%u\n", prefix[idx].path_id)
|
|
|
+ : printf("\n");
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
@@ -1417,7 +1519,11 @@ static void table_line_announce(struct prefix *prefix,int count,BGPDUMP_ENTRY *e
|
|
|
: printf("%s|%u|",inet_ntoa(entry->body.zebra_message.destination_ip.v4_addr),entry->body.zebra_message.destination_as);
|
|
|
break;
|
|
|
}
|
|
|
- printf("%s/%d|%s|%s|",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
+
|
|
|
+ is_addpath(entry)
|
|
|
+ ? printf("%s/%d|%u|%s|%s|",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len,prefix[idx].path_id,attr_aspath(entry->attr),describe_origin(entry->attr->origin))
|
|
|
+ : printf("%s/%d|%s|%s|",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
+
|
|
|
npref=entry->attr->local_pref;
|
|
|
if( (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF) ) ==0)
|
|
|
npref=0;
|
|
@@ -1454,7 +1560,10 @@ static void table_line_announce(struct prefix *prefix,int count,BGPDUMP_ENTRY *e
|
|
|
: printf("%s|%u|",inet_ntoa(entry->body.zebra_message.destination_ip.v4_addr),entry->body.zebra_message.destination_as);
|
|
|
break;
|
|
|
}
|
|
|
- printf("%s/%d|%s|%s\n",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
+
|
|
|
+ is_addpath(entry)
|
|
|
+ ? printf("%s/%d|%u|%s|%s\n",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len,prefix[idx].path_id,attr_aspath(entry->attr),describe_origin(entry->attr->origin))
|
|
|
+ : printf("%s/%d|%s|%s\n",inet_ntoa(prefix[idx].address.v4_addr),prefix[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -1497,7 +1606,10 @@ static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
: printf("%s|%u|",inet_ntoa(entry->body.zebra_message.destination_ip.v4_addr),entry->body.zebra_message.destination_as);
|
|
|
break;
|
|
|
}
|
|
|
- printf("%s/%d|%s|%s|",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
+
|
|
|
+ is_addpath(entry)
|
|
|
+ ? printf("%s/%d|%u|%s|%s|",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,prefix->nlri[idx].path_id,attr_aspath(entry->attr),describe_origin(entry->attr->origin))
|
|
|
+ : printf("%s/%d|%s|%s|",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
|
|
|
npref=entry->attr->local_pref;
|
|
|
if( (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF) ) ==0)
|
|
@@ -1506,7 +1618,11 @@ static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
if( (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC) ) ==0)
|
|
|
nmed=0;
|
|
|
|
|
|
- printf("%s|%d|%d|",inet_ntoa(entry->attr->nexthop),npref,nmed);
|
|
|
+ if (prefix->nexthop_len == 4)
|
|
|
+ printf("%s|%d|%d|",inet_ntoa(prefix->nexthop.v4_addr),npref,nmed);
|
|
|
+ else if ((prefix->nexthop_len == 16) || (prefix->nexthop_len == 32))
|
|
|
+ printf("%s|%d|%d|",fmt_ipv6(prefix->nexthop,buf),npref,nmed);
|
|
|
+
|
|
|
//printf("%s|%d|%d|",inet_ntoa(prefix->nexthop.v4_addr),entry->attr->local_pref,entry->attr->med);
|
|
|
if( (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES) ) !=0)
|
|
|
printf("%s|%s|",entry->attr->community->str+1,tmp2);
|
|
@@ -1516,6 +1632,11 @@ static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ // I'm not convinced this code block is actually ever executed
|
|
|
+ // it appears to handle old-style (non-MP) yet this function isn't
|
|
|
+ // called for that type.....
|
|
|
+ // cpetrie@ 2016-08-12
|
|
|
+
|
|
|
switch(entry->body.zebra_message.address_family)
|
|
|
{
|
|
|
#ifdef BGPDUMP_HAVE_IPV6
|
|
@@ -1532,7 +1653,10 @@ static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
: printf("%s|%u|",inet_ntoa(entry->body.zebra_message.destination_ip.v4_addr),entry->body.zebra_message.destination_as);
|
|
|
break;
|
|
|
}
|
|
|
- printf("%s/%d|%s|%s|",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
+
|
|
|
+ is_addpath(entry)
|
|
|
+ ? printf("%s/%d|%u|%s|%s|",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,prefix->nlri[idx].path_id,attr_aspath(entry->attr),describe_origin(entry->attr->origin))
|
|
|
+ : printf("%s/%d|%s|%s|",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
|
|
|
npref=entry->attr->local_pref;
|
|
|
if( (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF) ) ==0)
|
|
@@ -1541,7 +1665,7 @@ static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
if( (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC) ) ==0)
|
|
|
nmed=0;
|
|
|
|
|
|
- printf("%s|%d|%d|",inet_ntoa(entry->attr->nexthop),npref,nmed);
|
|
|
+ printf("%s|%d|%d|",inet_ntoa(entry->attr->nexthop),npref,nmed);
|
|
|
//printf("%s|%d|%d|",inet_ntoa(entry->attr->nexthop),entry->attr->local_pref,entry->attr->med);
|
|
|
if( (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES) ) !=0)
|
|
|
printf("%s|%s|",entry->attr->community->str+1,tmp2);
|
|
@@ -1573,7 +1697,9 @@ static void table_line_announce_1(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
: printf("%s|%u|",inet_ntoa(entry->body.zebra_message.destination_ip.v4_addr),entry->body.zebra_message.destination_as);
|
|
|
break;
|
|
|
}
|
|
|
- printf("%s/%d|%s|%s\n",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
+ is_addpath(entry)
|
|
|
+ ? printf("%s/%d|%u|%s|%s\n",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,prefix->nlri[idx].path_id,attr_aspath(entry->attr),describe_origin(entry->attr->origin))
|
|
|
+ : printf("%s/%d|%s|%s\n",inet_ntoa(prefix->nlri[idx].address.v4_addr),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -1614,9 +1740,11 @@ static void table_line_announce6(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
nmed=0;
|
|
|
|
|
|
bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("%s|%u|%s/%d|%s|%s|%s|%u|%u|",fmt_ipv6(entry->body.zebra_message.source_ip,buf1),entry->body.zebra_message.source_as,fmt_ipv6(prefix->nlri[idx].address,buf2),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin),fmt_ipv6(prefix->nexthop,buf),npref,nmed)
|
|
|
- : printf("%s|%u|%s/%d|%s|%s|%s|%u|%u|",fmt_ipv6(entry->body.zebra_message.destination_ip,buf1),entry->body.zebra_message.destination_as,fmt_ipv6(prefix->nlri[idx].address,buf2),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin),fmt_ipv6(prefix->nexthop,buf),npref,nmed);
|
|
|
+ ? printf("%s|%u|%s/%d|",fmt_ipv6(entry->body.zebra_message.source_ip,buf1),entry->body.zebra_message.source_as,fmt_ipv6(prefix->nlri[idx].address,buf2),prefix->nlri[idx].len)
|
|
|
+ : printf("%s|%u|%s/%d|",fmt_ipv6(entry->body.zebra_message.destination_ip,buf1),entry->body.zebra_message.destination_as,fmt_ipv6(prefix->nlri[idx].address,buf2),prefix->nlri[idx].len);
|
|
|
+
|
|
|
break;
|
|
|
+
|
|
|
case AFI_IP:
|
|
|
default:
|
|
|
|
|
@@ -1629,10 +1757,20 @@ static void table_line_announce6(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
|
|
|
//printf("%s|%d|%d|",inet_ntoa(entry->attr->nexthop),nprof,nmed);
|
|
|
bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("%s|%u|%s/%d|%s|%s|%s|%u|%u|",fmt_ipv4(entry->body.zebra_message.source_ip,buf1),entry->body.zebra_message.source_as,fmt_ipv6(prefix->nlri[idx].address,buf2),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin),fmt_ipv6(prefix->nexthop,buf),npref,nmed)
|
|
|
- : printf("%s|%u|%s/%d|%s|%s|%s|%u|%u|",fmt_ipv4(entry->body.zebra_message.destination_ip,buf1),entry->body.zebra_message.destination_as,fmt_ipv6(prefix->nlri[idx].address,buf2),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin),fmt_ipv6(prefix->nexthop,buf),npref,nmed);
|
|
|
+ ? printf("%s|%u|%s/%d|",fmt_ipv4(entry->body.zebra_message.source_ip,buf1),entry->body.zebra_message.source_as,fmt_ipv6(prefix->nlri[idx].address,buf2),prefix->nlri[idx].len)
|
|
|
+ : printf("%s|%u|%s/%d|",fmt_ipv4(entry->body.zebra_message.destination_ip,buf1),entry->body.zebra_message.destination_as,fmt_ipv6(prefix->nlri[idx].address,buf2),prefix->nlri[idx].len);
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+ if (is_addpath(entry))
|
|
|
+ printf("%u|", prefix->nlri[idx].path_id);
|
|
|
+
|
|
|
+ if (prefix->nexthop_len == 4)
|
|
|
+ printf("%s|%s|%s|%u|%u|", attr_aspath(entry->attr),describe_origin(entry->attr->origin),inet_ntoa(prefix->nexthop.v4_addr),npref,nmed);
|
|
|
+ else if ((prefix->nexthop_len == 16) || (prefix->nexthop_len == 32))
|
|
|
+ printf("%s|%s|%s|%u|%u|", attr_aspath(entry->attr),describe_origin(entry->attr->origin),fmt_ipv6(prefix->nexthop,buf),npref,nmed);
|
|
|
+
|
|
|
if( (entry->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES) ) !=0)
|
|
|
printf("%s|%s|",entry->attr->community->str+1,tmp2);
|
|
|
else
|
|
@@ -1651,16 +1789,21 @@ static void table_line_announce6(struct mp_nlri *prefix,int count,BGPDUMP_ENTRY
|
|
|
{
|
|
|
case AFI_IP6:
|
|
|
bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("%s|%u|%s/%d|%s|%s\n",fmt_ipv6(entry->body.zebra_message.source_ip,buf1),entry->body.zebra_message.source_as,fmt_ipv6(prefix->nlri[idx].address,buf),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin))
|
|
|
- : printf("%s|%u|%s/%d|%s|%s\n",fmt_ipv6(entry->body.zebra_message.destination_ip,buf1),entry->body.zebra_message.destination_as,fmt_ipv6(prefix->nlri[idx].address,buf),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
+ ? printf("%s|%u|%s/%d|",fmt_ipv6(entry->body.zebra_message.source_ip,buf1),entry->body.zebra_message.source_as,fmt_ipv6(prefix->nlri[idx].address,buf),prefix->nlri[idx].len)
|
|
|
+ : printf("%s|%u|%s/%d|",fmt_ipv6(entry->body.zebra_message.destination_ip,buf1),entry->body.zebra_message.destination_as,fmt_ipv6(prefix->nlri[idx].address,buf),prefix->nlri[idx].len);
|
|
|
break;
|
|
|
case AFI_IP:
|
|
|
default:
|
|
|
bgp4mp_message_direction_receive(entry)
|
|
|
- ? printf("%s|%u|%s/%d|%s|%s\n",fmt_ipv4(entry->body.zebra_message.source_ip,buf1),entry->body.zebra_message.source_as,fmt_ipv6(prefix->nlri[idx].address,buf),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin))
|
|
|
- : printf("%s|%u|%s/%d|%s|%s\n",fmt_ipv4(entry->body.zebra_message.destination_ip,buf1),entry->body.zebra_message.destination_as,fmt_ipv6(prefix->nlri[idx].address,buf),prefix->nlri[idx].len,attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
+ ? printf("%s|%u|%s/%d|",fmt_ipv4(entry->body.zebra_message.source_ip,buf1),entry->body.zebra_message.source_as,fmt_ipv6(prefix->nlri[idx].address,buf),prefix->nlri[idx].len)
|
|
|
+ : printf("%s|%u|%s/%d|",fmt_ipv4(entry->body.zebra_message.destination_ip,buf1),entry->body.zebra_message.destination_as,fmt_ipv6(prefix->nlri[idx].address,buf),prefix->nlri[idx].len);
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+ if (is_addpath(entry))
|
|
|
+ printf("%u|", prefix->nlri[idx].path_id);
|
|
|
+
|
|
|
+ printf("%s|%s\n",attr_aspath(entry->attr),describe_origin(entry->attr->origin));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -1691,7 +1834,7 @@ static void table_line_mrtd_route(BGPDUMP_MRTD_TABLE_DUMP *route,BGPDUMP_ENTRY *
|
|
|
t = &route->uptime;
|
|
|
}
|
|
|
if (mode == 1) {
|
|
|
- sprintf(time_str, "%ld", *t);
|
|
|
+ sprintf(time_str, "%lld", (long long)*t);
|
|
|
} else {
|
|
|
date=gmtime(t);
|
|
|
time2str(date, time_str);
|
|
@@ -1769,6 +1912,7 @@ static void table_line_dump_v2_prefix(BGPDUMP_TABLE_DUMP_V2_PREFIX *e,BGPDUMP_EN
|
|
|
char peer[BGPDUMP_ADDRSTRLEN], prefix[BGPDUMP_ADDRSTRLEN], nexthop[BGPDUMP_ADDRSTRLEN];
|
|
|
|
|
|
int i;
|
|
|
+ int addpath = is_addpath(entry);
|
|
|
|
|
|
for(i = 0; i < e->entry_count; i++) {
|
|
|
attributes_t *attr = e->entries[i].attr;
|
|
@@ -1803,18 +1947,23 @@ static void table_line_dump_v2_prefix(BGPDUMP_TABLE_DUMP_V2_PREFIX *e,BGPDUMP_EN
|
|
|
t = &tmp;
|
|
|
}
|
|
|
if (mode == 1) {
|
|
|
- sprintf(time_str, "%ld", *t);
|
|
|
+ sprintf(time_str, "%lld", (long long)*t);
|
|
|
} else {
|
|
|
date=gmtime(t);
|
|
|
time2str(date, time_str);
|
|
|
}
|
|
|
- show_line_prefix("TABLE_DUMP2", time_str, "B");
|
|
|
|
|
|
-
|
|
|
+ (addpath)
|
|
|
+ ? show_line_prefix("TABLE_DUMP2_AP", time_str, "B")
|
|
|
+ : show_line_prefix("TABLE_DUMP2", time_str, "B");
|
|
|
+
|
|
|
if (mode == 1)
|
|
|
{
|
|
|
printf("%s|%u|",peer,e->entries[i].peer->peer_as);
|
|
|
- printf("%s/%d|%s|%s|",prefix,e->prefix_length,aspath_str,origin);
|
|
|
+
|
|
|
+ (addpath)
|
|
|
+ ? printf("%s/%d|%u|%s|%s|",prefix,e->prefix_length,e->entries[i].path_id,aspath_str,origin)
|
|
|
+ : printf("%s/%d|%s|%s|",prefix,e->prefix_length,aspath_str,origin);
|
|
|
|
|
|
npref=attr->local_pref;
|
|
|
if( (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF) ) ==0)
|
|
@@ -1823,13 +1972,25 @@ static void table_line_dump_v2_prefix(BGPDUMP_TABLE_DUMP_V2_PREFIX *e,BGPDUMP_EN
|
|
|
if( (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC) ) ==0)
|
|
|
nmed=0;
|
|
|
|
|
|
-#ifdef BGPDUMP_HAVE_IPV6
|
|
|
if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MP_REACH_NLRI)) && attr->mp_info->announce[AFI_IP6][SAFI_UNICAST])
|
|
|
{
|
|
|
- fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop,nexthop);
|
|
|
+ if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_len == 4)
|
|
|
+ strncpy(nexthop, inet_ntoa(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop.v4_addr), BGPDUMP_ADDRSTRLEN);
|
|
|
+ else if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_len == 16)
|
|
|
+ fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop,nexthop);
|
|
|
+ else if (attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop_len == 32)
|
|
|
+ fmt_ipv6(attr->mp_info->announce[AFI_IP6][SAFI_UNICAST]->nexthop,nexthop);
|
|
|
+ }
|
|
|
+ else if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MP_REACH_NLRI)) && attr->mp_info->announce[AFI_IP][SAFI_UNICAST])
|
|
|
+ {
|
|
|
+ if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_len == 4)
|
|
|
+ strncpy(nexthop, inet_ntoa(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop.v4_addr), BGPDUMP_ADDRSTRLEN);
|
|
|
+ else if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_len == 16)
|
|
|
+ fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop,nexthop);
|
|
|
+ else if (attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop_len == 32)
|
|
|
+ fmt_ipv6(attr->mp_info->announce[AFI_IP][SAFI_UNICAST]->nexthop,nexthop);
|
|
|
}
|
|
|
else
|
|
|
-#endif
|
|
|
{
|
|
|
strncpy(nexthop, inet_ntoa(attr->nexthop), BGPDUMP_ADDRSTRLEN);
|
|
|
}
|
|
@@ -1848,7 +2009,9 @@ static void table_line_dump_v2_prefix(BGPDUMP_TABLE_DUMP_V2_PREFIX *e,BGPDUMP_EN
|
|
|
else
|
|
|
{
|
|
|
printf("%s|%u|",peer,e->entries[i].peer->peer_as);
|
|
|
- printf("%s/%d|%s|%s\n",prefix,e->prefix_length,aspath_str,origin);
|
|
|
+ (addpath)
|
|
|
+ ? printf("%s/%d|%u|%s|%s\n",prefix,e->prefix_length,e->entries[i].path_id,aspath_str,origin)
|
|
|
+ : printf("%s/%d|%s|%s\n",prefix,e->prefix_length,aspath_str,origin);
|
|
|
|
|
|
}
|
|
|
}
|