wireshark/epan/dissectors/packet-bmp.c

1094 lines
46 KiB
C

/* packet-bmp.c
* Routines for BMP packet dissection
* (c) Copyright Ebben Aries <exa@fb.com>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* Supports:
* RFC7854 BGP Monitoring Protocol
* RFC8671 Support for Adj-RIB-Out in the BGP Monitoring Protocol (BMP)
* draft-ietf-grow-bmp-local-rib-06 Support for Local RIB in BGP Monitoring Protocol (BMP)
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/prefs.h>
#include "packet-tcp.h"
#include "packet-bgp.h"
void proto_register_bmp(void);
void proto_reg_handoff_bmp(void);
#define FRAME_HEADER_LEN 5
/* BMP Common Header Message Types */
#define BMP_MSG_TYPE_ROUTE_MONITORING 0x00 /* Route Monitoring */
#define BMP_MSG_TYPE_STAT_REPORT 0x01 /* Statistics Report */
#define BMP_MSG_TYPE_PEER_DOWN 0x02 /* Peer Down Notification */
#define BMP_MSG_TYPE_PEER_UP 0x03 /* Peer Up Notification */
#define BMP_MSG_TYPE_INIT 0x04 /* Initiation Message */
#define BMP_MSG_TYPE_TERM 0x05 /* Termination Message */
#define BMP_MSG_TYPE_ROUTE_MIRRORING 0x06 /* Route Mirroring */
/* BMP Initiation Message Types */
#define BMP_INIT_INFO_STRING 0x00 /* String */
#define BMP_INIT_SYSTEM_DESCRIPTION 0x01 /* sysDescr */
#define BMP_INIT_SYSTEM_NAME 0x02 /* sysName */
#define BMP_INIT_VRF_TABLE_NAME 0x03 /* VRF/Table Name */
#define BMP_INIT_ADMIN_LABEL 0x04 /* Admin Label */
/* BMP Per Peer Types */
#define BMP_PEER_GLOBAL_INSTANCE 0x00 /* Global Instance Peer */
#define BMP_PEER_RD_INSTANCE 0x01 /* RD Instance Peer */
#define BMP_PEER_LOCAL_INSTANCE 0x02 /* Local Instance Peer */
#define BMP_PEER_LOC_RIB_INSTANCE 0x03 /* Loc-RIB Instance Peer */
/* BMP Per Peer Header Flags */
#define BMP_PEER_FLAG_IPV6 0x80 /* V Flag: IPv6 */
#define BMP_PEER_FLAG_POST_POLICY 0x40 /* L Flag: Post-policy */
#define BMP_PEER_FLAG_AS_PATH 0x20 /* A Flag: AS_PATH */
#define BMP_PEER_FLAG_ADJ_RIB_OUT 0x10
#define BMP_PEER_FLAG_RES 0x0F /* Reserved */
#define BMP_PEER_FLAG_MASK 0xFF
/* BMP Per Peer Loc-RIB Header Flags : draft-ietf-grow-bmp-local-rib-06 */
#define BMP_PEER_FLAG_LOC_RIB 0x80 /* F Flag : Loc-RIB */
#define BMP_PEER_FLAG_LOC_RIB_RES 0x7F /* Reserved */
/* BMP Stat Types */
#define BMP_STAT_PREFIX_REJ 0x00 /* Number of prefixes rejected by inbound policy */
#define BMP_STAT_PREFIX_DUP 0x01 /* Number of (known) duplicate prefix advertisements */
#define BMP_STAT_WITHDRAW_DUP 0x02 /* Number of (known) duplicate withdraws */
#define BMP_STAT_CLUSTER_LOOP 0x03 /* Number of updates invalidated due to CLUSTER_LIST loop */
#define BMP_STAT_AS_LOOP 0x04 /* Number of updates invalidated due to AS_PATH loop */
#define BMP_STAT_INV_ORIGINATOR 0x05 /* Number of updates invalidated due to ORIGINATOR_ID loop */
#define BMP_STAT_AS_CONFED_LOOP 0x06 /* Number of updates invalidated due to AS_CONFED loop */
#define BMP_STAT_ROUTES_ADJ_RIB_IN 0x07 /* Number of routes in Adj-RIBs-In */
#define BMP_STAT_ROUTES_LOC_RIB 0x08 /* Number of routes in Loc-RIB */
#define BMP_STAT_ROUTES_PER_ADJ_RIB_IN 0x09 /* Number of routes in per-AFI/SAFI Adj-RIBs-In */
#define BMP_STAT_ROUTES_PER_LOC_RIB 0x0A /* Number of routes in per-AFI/SAFI Loc-RIB */
#define BMP_STAT_UPDATE_TREAT 0x0B /* Number of updates subjected to treat-as-withdraw treatment */
#define BMP_STAT_PREFIXES_TREAT 0x0C /* Number of prefixes subjected to treat-as-withdraw treatment */
#define BMP_STAT_DUPLICATE_UPDATE 0x0D /* Number of duplicate update messages received */
#define BMP_STAT_ROUTES_PRE_ADJ_RIB_OUT 0x0E /* Number of routes in pre-policy Adj-RIB-Out */
#define BMP_STAT_ROUTES_POST_ADJ_RIB_OUT 0x0F /* Number of routes in post-policy Adj-RIB-Out */
#define BMP_STAT_ROUTES_PRE_PER_ADJ_RIB_OUT 0x10 /* Number of routes in per-AFI/SAFI pre-policy Adj-RIB-Out */
#define BMP_STAT_ROUTES_POST_PER_ADJ_RIB_OUT 0x11 /* Number of routes in per-AFI/SAFI post-policy Adj RIB-Out */
/* BMP Peer Down Reason Codes */
#define BMP_PEER_DOWN_LOCAL_NOTIFY 0x1 /* Local system closed the session with notification */
#define BMP_PEER_DOWN_LOCAL_NO_NOTIFY 0x2 /* Local system closed the session with FSM code */
#define BMP_PEER_DOWN_REMOTE_NOTIFY 0x3 /* Remote system closed the session with notification */
#define BMP_PEER_DOWN_REMOTE_NO_NOTIFY 0x4 /* Remote system closed the session without notification */
#define BMP_PEER_DOWN_INFO_NO_LONGER 0x5 /* Information for this peer will no longer be sent to the monitoring station for configuration reasons */
#define BMP_LOCAL_SYSTEM_CLOSED 0x6 /* Local system CLosed, TLV data Follows */ //draft-ietf-grow-bmp-local-rib-06 TBD3
/* BMP Termination Message Types */
#define BMP_TERM_TYPE_STRING 0x00 /* String */
#define BMP_TERM_TYPE_REASON 0x01 /* Reason */
/* BMP Termination Reason Codes */
#define BMP_TERM_REASON_ADMIN_CLOSE 0x00 /* Session administratively closed */
#define BMP_TERM_REASON_UNSPECIFIED 0x01 /* Unspecified reason */
#define BMP_TERM_REASON_RESOURCES 0x02 /* Out of resources */
#define BMP_TERM_REASON_REDUNDANT 0x03 /* Redundant connection */
#define BMP_TERM_REASON_PERM_CLOSE 0x04 /* Session permanently administratively closed */
static const value_string bmp_typevals[] = {
{ BMP_MSG_TYPE_ROUTE_MONITORING, "Route Monitoring" },
{ BMP_MSG_TYPE_STAT_REPORT, "Statistics Report" },
{ BMP_MSG_TYPE_PEER_DOWN, "Peer Down Notification" },
{ BMP_MSG_TYPE_PEER_UP, "Peer Up Notification" },
{ BMP_MSG_TYPE_INIT, "Initiation Message" },
{ BMP_MSG_TYPE_TERM, "Termination Message" },
{ BMP_MSG_TYPE_ROUTE_MIRRORING, "Route Mirroring" },
{ 0, NULL }
};
static const value_string init_typevals[] = {
{ BMP_INIT_INFO_STRING, "String" },
{ BMP_INIT_SYSTEM_DESCRIPTION, "sysDescr" },
{ BMP_INIT_SYSTEM_NAME, "sysName" },
{ BMP_INIT_VRF_TABLE_NAME, "VRF/Table" },
{ BMP_INIT_ADMIN_LABEL, "Admin Label" },
{ 0, NULL }
};
static const value_string peer_typevals[] = {
{ BMP_PEER_GLOBAL_INSTANCE, "Global Instance Peer" },
{ BMP_PEER_RD_INSTANCE, "RD Instance Peer" },
{ BMP_PEER_LOCAL_INSTANCE, "Local Instance Peer" },
{ BMP_PEER_LOC_RIB_INSTANCE, "Loc-RIB Instance Peer" },
{ 0, NULL }
};
static const value_string down_reason_typevals[] = {
{ BMP_PEER_DOWN_LOCAL_NOTIFY, "Local System, Notification" },
{ BMP_PEER_DOWN_LOCAL_NO_NOTIFY, "Local System, No Notification" },
{ BMP_PEER_DOWN_REMOTE_NOTIFY, "Remote System, Notification" },
{ BMP_PEER_DOWN_REMOTE_NO_NOTIFY, "Remote System, No Notification" },
{ BMP_PEER_DOWN_INFO_NO_LONGER, "Peer no longer be sent INformation (Configuration reasons)" },
{ BMP_LOCAL_SYSTEM_CLOSED, "Local system CLosed, TLV data Follows" },
{ 0, NULL }
};
static const value_string term_typevals[] = {
{ BMP_TERM_TYPE_STRING, "String" },
{ BMP_TERM_TYPE_REASON, "Reason" },
{ 0, NULL }
};
static const value_string term_reason_typevals[] = {
{ BMP_TERM_REASON_ADMIN_CLOSE, "Session administratively closed" },
{ BMP_TERM_REASON_UNSPECIFIED, "Unspecified reason" },
{ BMP_TERM_REASON_RESOURCES, "Out of resources" },
{ BMP_TERM_REASON_REDUNDANT, "Redundant connection" },
{ BMP_TERM_REASON_PERM_CLOSE, "Session permanently administratively closed" },
{ 0, NULL }
};
static const value_string stat_typevals[] = {
{ BMP_STAT_PREFIX_REJ, "Rejected Prefixes" },
{ BMP_STAT_PREFIX_DUP, "Duplicate Prefixes" },
{ BMP_STAT_WITHDRAW_DUP, "Duplicate Withdraws" },
{ BMP_STAT_CLUSTER_LOOP, "Invalid CLUSTER_LIST Loop" },
{ BMP_STAT_AS_LOOP, "Invalid AS_PATH Loop" },
{ BMP_STAT_INV_ORIGINATOR, "Invalid ORIGINATOR_ID" },
{ BMP_STAT_AS_CONFED_LOOP, "Invalid AS_CONFED Loop" },
{ BMP_STAT_ROUTES_ADJ_RIB_IN, "Routes in Adj-RIB-In" },
{ BMP_STAT_ROUTES_LOC_RIB, "Routes in Loc-RIB" },
{ BMP_STAT_ROUTES_PER_ADJ_RIB_IN, "Routes in per-AFI/SAF Adj-RIB-In" },
{ BMP_STAT_ROUTES_PER_LOC_RIB, "Routes in per-AFI/SAFLoc-RIB" },
{ BMP_STAT_UPDATE_TREAT, "Updates subjected to treat-as-withdraw treatment" },
{ BMP_STAT_PREFIXES_TREAT, "Prefixes subjected to treat-as-withdraw treatment" },
{ BMP_STAT_DUPLICATE_UPDATE, "Duplicate update messages received" },
{ BMP_STAT_ROUTES_PRE_ADJ_RIB_OUT, "Routes in pre-policy Adj-RIB-Out" },
{ BMP_STAT_ROUTES_POST_ADJ_RIB_OUT, "Routes in post-policy Adj-RIB-Out" },
{ BMP_STAT_ROUTES_PRE_PER_ADJ_RIB_OUT, "Routes in per-AFI/SAFI pre-policy Adj-RIB-Out" },
{ BMP_STAT_ROUTES_POST_PER_ADJ_RIB_OUT, "Routes in per-AFI/SAFI post-policy Adj RIB-Out" },
{ 0, NULL }
};
static int proto_bmp = -1;
/* BMP Common Header filed */
static int hf_bmp_version = -1;
static int hf_bmp_length = -1;
static int hf_bmp_type = -1;
/* BMP Unused Bytes filed */
static int hf_bmp_unused = -1;
/* BMP Initiation Header filed */
static int hf_init_types = -1;
static int hf_init_type = -1;
static int hf_init_length = -1;
static int hf_init_info = -1;
/* BMP Per Peer Header filed */
static int hf_peer_header = -1;
static int hf_peer_type = -1;
static int hf_peer_flags = -1;
static int hf_peer_flags_ipv6 = -1;
static int hf_peer_flags_post_policy = -1;
static int hf_peer_flags_as_path = -1;
static int hf_peer_flags_adj_rib_out = -1;
static int hf_peer_flags_res = -1;
static int hf_peer_flags_loc_rib = -1;
static int hf_peer_flags_loc_rib_res = -1;
static int hf_peer_distinguisher = -1;
static int hf_peer_ipv4_address = -1;
static int hf_peer_ipv6_address = -1;
static int hf_peer_asn = -1;
static int hf_peer_bgp_id = -1;
static int hf_peer_timestamp_sec = -1;
static int hf_peer_timestamp_msec = -1;
/* BMP Peer Up Notification filed */
static int hf_peer_up_ipv4_address = -1;
static int hf_peer_up_ipv6_address = -1;
static int hf_peer_up_local_port = -1;
static int hf_peer_up_remote_port = -1;
/* BMP Peer Down Notification filed */
static int hf_peer_down_reason = -1;
static int hf_peer_down_data = -1;
/* BMP Stat Reports filed */
static int hf_stats_count = -1;
static int hf_stat_type = -1;
static int hf_stat_len = -1;
static int hf_stat_data = -1;
static int hf_stat_data_prefix_rej = -1;
static int hf_stat_data_prefix_dup = -1;
static int hf_stat_data_withdraw_dup = -1;
static int hf_stat_data_cluster_loop = -1;
static int hf_stat_data_as_loop = -1;
static int hf_stat_data_inv_originator = -1;
static int hf_stat_data_as_confed_loop = -1;
static int hf_stat_data_routes_adj_rib_in = -1;
static int hf_stat_data_routes_loc_rib = -1;
static int hf_stat_data_routes_per_adj_rib_in_afi = -1;
static int hf_stat_data_routes_per_adj_rib_in_safi = -1;
static int hf_stat_data_routes_per_adj_rib_in = -1;
static int hf_stat_data_routes_per_loc_rib_afi = -1;
static int hf_stat_data_routes_per_loc_rib_safi = -1;
static int hf_stat_data_routes_per_loc_rib = -1;
static int hf_stat_data_update_treat = -1;
static int hf_stat_data_prefixes_treat = -1;
static int hf_stat_data_duplicate_update = -1;
static int hf_stat_data_routes_pre_adj_rib_out = -1;
static int hf_stat_data_routes_post_adj_rib_out = -1;
static int hf_stat_data_routes_pre_per_adj_rib_out_afi = -1;
static int hf_stat_data_routes_pre_per_adj_rib_out_safi = -1;
static int hf_stat_data_routes_pre_per_adj_rib_out = -1;
static int hf_stat_data_routes_post_per_adj_rib_out_afi = -1;
static int hf_stat_data_routes_post_per_adj_rib_out_safi = -1;
static int hf_stat_data_routes_post_per_adj_rib_out = -1;
/* BMP Termination filed */
static int hf_term_types = -1;
static int hf_term_type = -1;
static int hf_term_len = -1;
static int hf_term_info = -1;
static int hf_term_reason = -1;
static gint ett_bmp = -1;
static gint ett_bmp_route_monitoring = -1;
static gint ett_bmp_stat_report = -1;
static gint ett_bmp_stat_type = -1;
static gint ett_bmp_peer_down = -1;
static gint ett_bmp_peer_up = -1;
static gint ett_bmp_peer_header = -1;
static gint ett_bmp_peer_flags = -1;
static gint ett_bmp_init = -1;
static gint ett_bmp_init_types = -1;
static gint ett_bmp_init_type = -1;
static gint ett_bmp_term = -1;
static gint ett_bmp_term_type = -1;
static gint ett_bmp_term_types = -1;
static gint ett_bmp_route_mirroring = -1;
static expert_field ei_stat_data_unknown = EI_INIT;
static dissector_handle_t dissector_bgp;
/* desegmentation */
static gboolean bmp_desegment = TRUE;
/*
* Dissect BMP Peer Down Notification
*
* 0 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+
* | Reason | 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Data (present if Reason = 1, 2 or 3) |
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
static void
dissect_bmp_peer_down_notification(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset, gint8 flags _U_)
{
guint8 down_reason;
down_reason = tvb_get_guint8(tvb, offset);
proto_tree_add_item(tree, hf_peer_down_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
if (down_reason != BMP_PEER_DOWN_REMOTE_NO_NOTIFY) {
if (down_reason == BMP_PEER_DOWN_LOCAL_NO_NOTIFY) {
proto_tree_add_item(tree, hf_peer_down_data, tvb, offset, 2, ENC_NA);
} else {
call_dissector(dissector_bgp, tvb_new_subset_remaining(tvb, offset), pinfo, tree);
}
}
}
/*
* Dissect BMP Peer Up Notification
*
* 0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Local Address (16 bytes) |
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Local Port | Remote Port |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Sent OPEN Message |
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Received OPEN Message |
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
static void
dissect_bmp_peer_up_notification(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset, gint8 flags)
{
if (flags & BMP_PEER_FLAG_IPV6) {
proto_tree_add_item(tree, hf_peer_up_ipv6_address, tvb, offset, 16, ENC_NA);
offset += 16;
} else {
proto_tree_add_item(tree, hf_bmp_unused, tvb, offset, 12, ENC_NA);
offset += 12;
proto_tree_add_item(tree, hf_peer_up_ipv4_address, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
proto_tree_add_item(tree, hf_peer_up_local_port, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(tree, hf_peer_up_remote_port, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
call_dissector(dissector_bgp, tvb_new_subset_remaining(tvb, offset), pinfo, tree);
}
/*
* Dissect BMP Stats Report
*
* 0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Stats Count |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*
* 0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Stat Type | Stat Len |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Stat Data |
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
static void
dissect_bmp_stat_report(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset, gint8 flags _U_)
{
guint32 stat_len, stat_type;
guint32 i;
guint32 stats_count = tvb_get_ntohl(tvb, offset);
proto_tree_add_item(tree, hf_stats_count, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
for (i = 0; i < stats_count; i++) {
proto_item *ti;
proto_item *subtree;
ti = proto_tree_add_item_ret_uint(tree, hf_stat_type, tvb, offset, 2, ENC_BIG_ENDIAN, &stat_type);
subtree = proto_item_add_subtree(ti, ett_bmp_stat_type);
offset += 2;
proto_tree_add_item_ret_uint(subtree, hf_stat_len, tvb, offset, 2, ENC_BIG_ENDIAN, &stat_len);
offset += 2;
proto_tree_add_item(subtree, hf_stat_data, tvb, offset, stat_len, ENC_NA);
switch(stat_type){
case BMP_STAT_PREFIX_REJ:
proto_tree_add_item(subtree, hf_stat_data_prefix_rej, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_PREFIX_DUP:
proto_tree_add_item(subtree, hf_stat_data_prefix_dup, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_WITHDRAW_DUP:
proto_tree_add_item(subtree, hf_stat_data_withdraw_dup, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_CLUSTER_LOOP:
proto_tree_add_item(subtree, hf_stat_data_cluster_loop, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_AS_LOOP:
proto_tree_add_item(subtree, hf_stat_data_as_loop, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_INV_ORIGINATOR:
proto_tree_add_item(subtree, hf_stat_data_inv_originator, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_AS_CONFED_LOOP:
proto_tree_add_item(subtree, hf_stat_data_as_confed_loop, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_ROUTES_ADJ_RIB_IN:
proto_tree_add_item(subtree, hf_stat_data_routes_adj_rib_in, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
break;
case BMP_STAT_ROUTES_LOC_RIB:
proto_tree_add_item(subtree, hf_stat_data_routes_loc_rib, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
break;
case BMP_STAT_ROUTES_PER_ADJ_RIB_IN:
proto_tree_add_item(subtree, hf_stat_data_routes_per_adj_rib_in_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(subtree, hf_stat_data_routes_per_adj_rib_in_safi, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(subtree, hf_stat_data_routes_per_adj_rib_in, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
break;
case BMP_STAT_ROUTES_PER_LOC_RIB:
proto_tree_add_item(subtree, hf_stat_data_routes_per_loc_rib_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(subtree, hf_stat_data_routes_per_loc_rib_safi, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(subtree, hf_stat_data_routes_per_loc_rib, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
break;
case BMP_STAT_UPDATE_TREAT:
proto_tree_add_item(subtree, hf_stat_data_update_treat, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_PREFIXES_TREAT:
proto_tree_add_item(subtree, hf_stat_data_prefixes_treat, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_DUPLICATE_UPDATE:
proto_tree_add_item(subtree, hf_stat_data_duplicate_update, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
case BMP_STAT_ROUTES_PRE_ADJ_RIB_OUT:
proto_tree_add_item(subtree, hf_stat_data_routes_pre_adj_rib_out, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
break;
case BMP_STAT_ROUTES_POST_ADJ_RIB_OUT:
proto_tree_add_item(subtree, hf_stat_data_routes_post_adj_rib_out, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
break;
case BMP_STAT_ROUTES_PRE_PER_ADJ_RIB_OUT:
proto_tree_add_item(subtree, hf_stat_data_routes_pre_per_adj_rib_out_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(subtree, hf_stat_data_routes_pre_per_adj_rib_out_safi, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(subtree, hf_stat_data_routes_pre_per_adj_rib_out, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
break;
case BMP_STAT_ROUTES_POST_PER_ADJ_RIB_OUT:
proto_tree_add_item(subtree, hf_stat_data_routes_post_per_adj_rib_out_afi, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(subtree, hf_stat_data_routes_post_per_adj_rib_out_safi, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(subtree, hf_stat_data_routes_post_per_adj_rib_out, tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
break;
default:
proto_tree_add_expert(subtree, pinfo, &ei_stat_data_unknown, tvb, 4, stat_type);
offset += stat_len;
break;
}
}
}
/*
* Dissect BMP Termination Message
*
* 0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Information Type | Information Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Information (variable) |
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
static void
dissect_bmp_termination(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, int offset, guint8 bmp_type _U_, guint16 len)
{
guint16 term_type;
guint16 term_len;
proto_item *ti;
proto_item *subtree;
ti = proto_tree_add_item(tree, hf_term_types, tvb, offset, len, ENC_NA);
subtree = proto_item_add_subtree(ti, ett_bmp_term_types);
term_type = tvb_get_ntohs(tvb, offset);
proto_item_append_text(subtree, ", Type %s",
val_to_str(term_type, term_typevals, "Unknown (0x%02x)"));
proto_tree_add_item(subtree, hf_term_type, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
term_len = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(subtree, hf_term_len, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
if (term_type == BMP_TERM_TYPE_STRING) {
proto_tree_add_item(subtree, hf_term_info, tvb, offset, term_len, ENC_ASCII|ENC_NA);
} else {
proto_tree_add_item(subtree, hf_term_reason, tvb, offset, term_len, ENC_BIG_ENDIAN);
}
/*offset += term_len;*/
}
/*
* Dissect BMP Per-Peer Header
*
* 0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Peer Type | Peer Flags |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Peer Distinguisher (present based on peer type) |
* | |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Peer Address (16 bytes) |
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Peer AS |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Peer BGP ID |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Timestamp (seconds) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Timestamp (microseconds) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
static void
dissect_bmp_peer_header(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, int offset, guint8 bmp_type, guint16 len)
{
guint8 flags;
guint32 type;
proto_item *item;
proto_item *ti;
proto_item *subtree;
static int * const peer_flags[] = {
&hf_peer_flags_ipv6,
&hf_peer_flags_post_policy,
&hf_peer_flags_as_path,
&hf_peer_flags_adj_rib_out,
&hf_peer_flags_res,
NULL
};
static int * const peer_flags_loc_rib[] = {
&hf_peer_flags_loc_rib,
&hf_peer_flags_loc_rib_res,
NULL
};
ti = proto_tree_add_item(tree, hf_peer_header, tvb, offset, len, ENC_NA);
subtree = proto_item_add_subtree(ti, ett_bmp_peer_header);
proto_tree_add_item_ret_uint(subtree, hf_peer_type, tvb, offset, 1, ENC_BIG_ENDIAN, &type);
offset += 1;
flags = tvb_get_guint8(tvb, offset);
if (type == BMP_PEER_LOC_RIB_INSTANCE) {
proto_tree_add_bitmask(subtree, tvb, offset, hf_peer_flags, ett_bmp_peer_flags, peer_flags_loc_rib, ENC_NA);
} else {
proto_tree_add_bitmask(subtree, tvb, offset, hf_peer_flags, ett_bmp_peer_flags, peer_flags, ENC_NA);
}
offset += 1;
item = proto_tree_add_item(subtree, hf_peer_distinguisher, tvb, offset, 8, ENC_NA);
proto_item_set_text(item, "Peer Distinguisher: %s", decode_bgp_rd(tvb, offset));
offset += 8;
if (flags & BMP_PEER_FLAG_IPV6) {
proto_tree_add_item(subtree, hf_peer_ipv6_address, tvb, offset, 16, ENC_NA);
offset += 16;
} else {
proto_tree_add_item(subtree, hf_bmp_unused, tvb, offset, 12, ENC_NA);
offset += 12;
proto_tree_add_item(subtree, hf_peer_ipv4_address, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
proto_tree_add_item(subtree, hf_peer_asn, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_peer_bgp_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_peer_timestamp_sec, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(subtree, hf_peer_timestamp_msec, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
switch (bmp_type) {
case BMP_MSG_TYPE_ROUTE_MONITORING:
case BMP_MSG_TYPE_ROUTE_MIRRORING:
call_dissector(dissector_bgp, tvb_new_subset_remaining(tvb, offset), pinfo, tree);
break;
case BMP_MSG_TYPE_STAT_REPORT:
dissect_bmp_stat_report(tvb, tree, pinfo, offset, flags);
break;
case BMP_MSG_TYPE_PEER_DOWN:
dissect_bmp_peer_down_notification(tvb, tree, pinfo, offset, flags);
break;
case BMP_MSG_TYPE_PEER_UP:
dissect_bmp_peer_up_notification(tvb, tree, pinfo, offset, flags);
break;
case BMP_MSG_TYPE_INIT:
case BMP_MSG_TYPE_TERM:
default:
DISSECTOR_ASSERT_NOT_REACHED();
break;
}
}
/*
* Dissect BMP Initiation Message
*
* 0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Information Type | Information Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Information (variable) |
* ~ ~
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
static void
dissect_bmp_init(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_, int offset, guint8 bmp_type _U_, guint16 len)
{
guint16 init_type;
guint16 init_len;
proto_tree *pti;
proto_tree *parent_tree;
pti = proto_tree_add_item(tree, hf_init_types, tvb, offset, len, ENC_NA);
parent_tree = proto_item_add_subtree(pti, ett_bmp_init_types);
while (tvb_reported_length_remaining(tvb, offset) > 0) {
proto_tree *ti;
proto_tree *subtree;
init_type = tvb_get_ntohs(tvb, offset);
proto_item_append_text(pti, ", Type %s",
val_to_str(init_type, init_typevals, "Unknown (0x%02x)"));
ti = proto_tree_add_item(parent_tree, hf_init_type, tvb, offset, 2, ENC_BIG_ENDIAN);
subtree = proto_item_add_subtree(ti, ett_bmp_init_type);
offset += 2;
init_len = tvb_get_ntohs(tvb, offset);
proto_tree_add_item(subtree, hf_init_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(subtree, hf_init_info, tvb, offset, init_len, ENC_ASCII|ENC_NA);
offset += init_len;
}
}
/*
* Dissect BMP PDU and Common Header
*
* 0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
* +-+-+-+-+-+-+-+-+
* | Version |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Message Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Msg. Type |
* +---------------+
*
*/
static guint
get_bmp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
{
return tvb_get_ntohl(tvb, offset + 1);
}
static int
dissect_bmp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
int offset = 0;
guint8 bmp_type;
guint16 len;
gint arg;
proto_item *ti;
proto_item *bmp_tree;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "BMP");
col_clear(pinfo->cinfo, COL_INFO);
bmp_type = tvb_get_guint8(tvb, 5);
col_add_fstr(pinfo->cinfo, COL_INFO, "Type: %s",
val_to_str(bmp_type, bmp_typevals, "Unknown (0x%02x)"));
ti = proto_tree_add_item(tree, proto_bmp, tvb, 0, -1, ENC_NA);
proto_item_append_text(ti, ", Type %s",
val_to_str(bmp_type, bmp_typevals, "Unknown (0x%02x)"));
switch (bmp_type) {
case BMP_MSG_TYPE_ROUTE_MONITORING:
arg = ett_bmp_route_monitoring;
break;
case BMP_MSG_TYPE_STAT_REPORT:
arg = ett_bmp_stat_report;
break;
case BMP_MSG_TYPE_PEER_DOWN:
arg = ett_bmp_peer_down;
break;
case BMP_MSG_TYPE_PEER_UP:
arg = ett_bmp_peer_up;
break;
case BMP_MSG_TYPE_INIT:
arg = ett_bmp_init;
break;
case BMP_MSG_TYPE_TERM:
arg = ett_bmp_term;
break;
case BMP_MSG_TYPE_ROUTE_MIRRORING:
arg = ett_bmp_route_mirroring;
break;
default:
arg = ett_bmp;
break;
}
bmp_tree = proto_item_add_subtree(ti, arg);
proto_tree_add_item(bmp_tree, hf_bmp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(bmp_tree, hf_bmp_length, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(bmp_tree, hf_bmp_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
len = tvb_get_ntohs(tvb, offset);
switch (bmp_type) {
case BMP_MSG_TYPE_INIT:
dissect_bmp_init(tvb, bmp_tree, pinfo, offset, bmp_type, len);
break;
case BMP_MSG_TYPE_ROUTE_MONITORING:
case BMP_MSG_TYPE_STAT_REPORT:
case BMP_MSG_TYPE_PEER_DOWN:
case BMP_MSG_TYPE_PEER_UP:
case BMP_MSG_TYPE_ROUTE_MIRRORING:
dissect_bmp_peer_header(tvb, bmp_tree, pinfo, offset, bmp_type, len);
break;
case BMP_MSG_TYPE_TERM:
dissect_bmp_termination(tvb, bmp_tree, pinfo, offset, bmp_type, len);
break;
default:
break;
}
return tvb_captured_length(tvb);
}
/* Main dissecting routine */
static int
dissect_bmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
tcp_dissect_pdus(tvb, pinfo, tree, bmp_desegment, FRAME_HEADER_LEN, get_bmp_pdu_len, dissect_bmp_pdu, data);
return tvb_captured_length(tvb);
}
void
proto_register_bmp(void)
{
expert_module_t *expert_bmp;
static hf_register_info hf[] = {
/* BMP Common Header */
{ &hf_bmp_version,
{ "Version", "bmp.version", FT_UINT8, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_bmp_length,
{ "Length", "bmp.length", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_bmp_type,
{ "Type", "bmp.type", FT_UINT8, BASE_DEC,
VALS(bmp_typevals), 0x0, "BMP message type", HFILL }},
/* Unused/Reserved Bytes */
{ &hf_bmp_unused,
{ "Unused", "bmp.unused", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
/* Initiation Header */
{ &hf_init_types,
{ "Information Types", "bmp.init.types", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_init_type,
{ "Type", "bmp.init.type", FT_UINT16, BASE_DEC,
VALS(init_typevals), 0x0, "Initiation type", HFILL }},
{ &hf_init_length,
{ "Length", "bmp.init.length", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_init_info,
{ "Information", "bmp.init.info", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
/* Per Peer Header */
{ &hf_peer_header,
{ "Per Peer Header", "bmp.peer.header", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_type,
{ "Type", "bmp.peer.type", FT_UINT8, BASE_DEC,
VALS(peer_typevals), 0x0, NULL, HFILL }},
{ &hf_peer_flags,
{ "Flags", "bmp.peer.flags", FT_UINT8, BASE_HEX,
NULL, BMP_PEER_FLAG_MASK, NULL, HFILL }},
{ &hf_peer_flags_ipv6,
{ "IPv6", "bmp.peer.flags.ipv6", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), BMP_PEER_FLAG_IPV6, NULL, HFILL }},
{ &hf_peer_flags_post_policy,
{ "Post-policy", "bmp.peer.flags.post_policy", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), BMP_PEER_FLAG_POST_POLICY, NULL, HFILL }},
{ &hf_peer_flags_as_path,
{ "AS PATH", "bmp.peer.flags.as_path", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), BMP_PEER_FLAG_AS_PATH, NULL, HFILL }},
{ &hf_peer_flags_adj_rib_out,
{ "Adj-RIB-Out", "bmp.peer.flags.adj_rib_out", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), BMP_PEER_FLAG_ADJ_RIB_OUT, NULL, HFILL }},
{ &hf_peer_flags_res,
{ "Reserved", "bmp.peer.flags.reserved", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), BMP_PEER_FLAG_RES, NULL, HFILL }},
{ &hf_peer_flags_loc_rib,
{ "Loc-RIB", "bmp.peer.flags.loc_rib", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), BMP_PEER_FLAG_LOC_RIB, NULL, HFILL }},
{ &hf_peer_flags_loc_rib_res,
{ "Reserved", "bmp.peer.flags.loc_rib.res", FT_BOOLEAN, 8,
TFS(&tfs_set_notset), BMP_PEER_FLAG_LOC_RIB_RES, NULL, HFILL }},
{ &hf_peer_distinguisher,
{ "Peer Distinguisher", "bmp.peer.distinguisher", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_ipv4_address,
{ "Address", "bmp.peer.ip.addr", FT_IPv4, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_ipv6_address,
{ "Address", "bmp.peer.ipv6.addr", FT_IPv6, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_asn,
{ "ASN", "bmp.peer.asn", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_bgp_id,
{ "BGP ID", "bmp.peer.id", FT_IPv4, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_timestamp_sec,
{ "Timestamp (sec)", "bmp.peer.timestamp.sec", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_timestamp_msec,
{ "Timestamp (msec)", "bmp.peer.timestamp.msec", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_up_ipv4_address,
{ "Local Address", "bmp.peer.up.ip.addr", FT_IPv4, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_up_ipv6_address,
{ "Local Address", "bmp.peer.up.ipv6.addr", FT_IPv6, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_up_local_port,
{ "Local Port", "bmp.peer.up.port.local", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_peer_up_remote_port,
{ "Remote Port", "bmp.peer.up.port.remote", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
/* Peer Down Notification */
{ &hf_peer_down_reason,
{ "Reason", "bmp.peer.down.reason", FT_UINT8, BASE_DEC,
VALS(down_reason_typevals), 0x0, NULL, HFILL }},
{ &hf_peer_down_data,
{ "Data", "bmp.peer.down.data", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
/* Stats Report */
{ &hf_stats_count,
{ "Stats Count", "bmp.stats.count", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_type,
{ "Type", "bmp.stats.type", FT_UINT16, BASE_DEC,
VALS(stat_typevals), 0x0, NULL, HFILL }},
{ &hf_stat_len,
{ "Length", "bmp.stats.length", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data,
{ "Data", "bmp.stats.data", FT_BYTES, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_prefix_rej,
{ "Number of prefixes rejected by inbound policy", "bmp.stats.data.prefix_rej", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_prefix_dup,
{ "Number of (known) duplicate prefix advertisements", "bmp.stats.data.prefix_dup", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_withdraw_dup,
{ "Number of (known) duplicate withdraws", "bmp.stats.data.withdraw_dup", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_cluster_loop,
{ "Number of updates invalidated due to CLUSTER_LIST loop", "bmp.stats.data.cluster_loop", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_as_loop,
{ "Number of updates invalidated due to AS_PATH loop", "bmp.stats.data.as_loop", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_inv_originator,
{ "Number of updates invalidated due to ORIGINATOR_ID", "bmp.stats.data.inv_originator", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_as_confed_loop,
{ "Number of updates invalidated due to a loop found in AS_CONFED_SEQUENCE or AS_CONFED_SET", "bmp.stats.data.as_confed_loop", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_adj_rib_in,
{ "Number of routes in Adj-RIBs-In", "bmp.stats.data.routes_adj_rib_in", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_loc_rib,
{ "Number of routes in Loc-RIB", "bmp.stats.data.routes_loc_rib", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_per_adj_rib_in_afi,
{ "AFI", "bmp.stats.data.routes_per_adj_rib_in.afi", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_per_adj_rib_in_safi,
{ "SAFI", "bmp.stats.data.routes_per_adj_rib_in.safi", FT_UINT8, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_per_adj_rib_in,
{ "Number of routes in per-AFI/SAFI Adj-RIB-In", "bmp.stats.data.routes_per_adj_rib_in", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_per_loc_rib_afi,
{ "AFI", "bmp.stats.data.routes_per_loc_rib.afi", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_per_loc_rib_safi,
{ "SAFI", "bmp.stats.data.routes_per_loc_rib.safi", FT_UINT8, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_per_loc_rib,
{ "Number of routes in per-AFI/SAFI Adj-RIB-In", "bmp.stats.data.routes_per_loc_rib", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_update_treat,
{ "Number of updates subjected to treat-as-withdraw", "bmp.stats.data.update_treat", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_prefixes_treat,
{ "Number of prefixes subjected to treat-as-withdraw", "bmp.stats.data.prefixes_treat", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_duplicate_update,
{ "Number of duplicate update messages received", "bmp.stats.data.duplicate_update", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_pre_adj_rib_out,
{ "Number of routes in pre-policy Adj-RIBs-Out", "bmp.stats.data.routes_pre_adj_rib_out", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_post_adj_rib_out,
{ "Number of routes in post-policy Adj-RIBs-Out", "bmp.stats.data.routes_pre_adj_rib_out", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_pre_per_adj_rib_out_afi,
{ "AFI", "bmp.stats.data.routes_pre_per_adj_rib_out.afi", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_pre_per_adj_rib_out_safi,
{ "SAFI", "bmp.stats.data.routes_pre_per_adj_rib_out.safi", FT_UINT8, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_pre_per_adj_rib_out,
{ "Number of routes in per-AFI/SAFI pre-policy Adj-RIB-Out", "bmp.stats.data.routes_pre_per_adj_rib_out", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_post_per_adj_rib_out_afi,
{ "AFI", "bmp.stats.data.routes_post_per_adj_rib_out.afi", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_post_per_adj_rib_out_safi,
{ "SAFI", "bmp.stats.data.routes_post_per_adj_rib_out.safi", FT_UINT8, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_stat_data_routes_post_per_adj_rib_out,
{ "Number of routes in per-AFI/SAFI post-policy Adj-RIB-Out", "bmp.stats.data.routes_post_per_adj_rib_out", FT_UINT64, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
/* Termination Message */
{ &hf_term_types,
{ "Termination Types", "bmp.term.types", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_term_type,
{ "Type", "bmp.term.type", FT_UINT16, BASE_DEC,
VALS(term_typevals), 0x0, NULL, HFILL }},
{ &hf_term_len,
{ "Length", "bmp.term.length", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL }},
{ &hf_term_info,
{ "Information", "bmp.term.info", FT_STRING, BASE_NONE,
NULL, 0x0, NULL, HFILL }},
{ &hf_term_reason,
{ "Reason", "bmp.term.reason", FT_UINT16, BASE_DEC,
VALS(term_reason_typevals), 0x0, NULL, HFILL }}
};
/* Setup protocol subtree array */
static gint *ett[] = {
&ett_bmp,
&ett_bmp_route_monitoring,
&ett_bmp_stat_report,
&ett_bmp_stat_type,
&ett_bmp_peer_down,
&ett_bmp_peer_up,
&ett_bmp_peer_header,
&ett_bmp_peer_flags,
&ett_bmp_init,
&ett_bmp_init_type,
&ett_bmp_init_types,
&ett_bmp_term,
&ett_bmp_term_type,
&ett_bmp_term_types,
&ett_bmp_route_mirroring,
};
static ei_register_info ei[] = {
{ &ei_stat_data_unknown,
{ "bmp.stats.data.unknown", PI_UNDECODED, PI_NOTE,
"Unknown stats type payload", EXPFILL }
},
};
module_t *bmp_module;
proto_bmp = proto_register_protocol(
"BGP Monitoring Protocol", /* name */
"BMP", /* short name */
"bmp" /* abbrev */
);
proto_register_field_array(proto_bmp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_bmp = expert_register_protocol(proto_bmp);
expert_register_field_array(expert_bmp, ei, array_length(ei));
bmp_module = prefs_register_protocol(proto_bmp, NULL);
prefs_register_bool_preference(bmp_module, "desegment",
"Reassemble BMP messages spanning multiple TCP segments",
"Whether the BMP dissector should reassemble messages spanning multiple TCP segments."
" To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
&bmp_desegment);
}
void
proto_reg_handoff_bmp(void)
{
static dissector_handle_t bmp_handle;
bmp_handle = create_dissector_handle(dissect_bmp, proto_bmp);
dissector_add_for_decode_as_with_preference("tcp.port", bmp_handle);
dissector_bgp = find_dissector_add_dependency("bgp", proto_bmp);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/