more updates to bgp dissector.

- separate tree for each message
- added some comments
- merged my code for OPEN message, mainly just terminology updates
- searched all RFCs and defined known attributes

from: Greg Hankins <gregh@cc.gatech.edu>

svn path=/trunk/; revision=979
This commit is contained in:
Jun-ichiro itojun Hagino 1999-11-06 01:28:50 +00:00
parent 907090770c
commit 004607a3fe
4 changed files with 87 additions and 33 deletions

View File

@ -76,6 +76,8 @@ Didier Jorand <Didier.Jorand@alcatel.fr> {
}
Jun-ichiro itojun Hagino <itojun@itojun.org> {
http://www.itojun.org/
IPv6 support
RIPng support
IPsec support
@ -166,6 +168,12 @@ Warren Young <tangent@mail.com> {
"Print" button support in "Tools:Follow TCP Stream" window
}
Greg Hankins <gregh@cc.gatech.edu> {
http://www.cc.gatech.edu/staff/h/Greg.Hankins/
updates to BGP (Border Gateway Protocol) support
}
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c.

View File

@ -1,8 +1,19 @@
/* packet-bgp.c
* Routines for BGP packet dissection
* Routines for BGP packet dissection.
* Copyright 1999, Jun-ichiro itojun Hagino <itojun@itojun.org>
*
* $Id: packet-bgp.c,v 1.7 1999/11/02 00:11:58 itojun Exp $
* $Id: packet-bgp.c,v 1.8 1999/11/06 01:28:49 itojun Exp $
*
* Supports:
* RFC1771 A Border Gateway Protocol 4 (BGP-4)
* RFC2283 Multiprotocol Extensions for BGP-4
*
* TODO:
* RFC1863 A BGP/IDRP Route Server alternative to a full mesh routing
* RFC1965 Autonomous System Confederations for BGP
* RFC1997 BGP Communities Attribute
* RFC1998 An Application of the BGP Community Attribute in Multi-home Routing
* Destination Preference Attribute for BGP (work in progress)
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -203,12 +214,16 @@ decode_prefix6(const u_char *pd, char *buf, int buflen)
return 1 + (plen + 7) / 8;
}
/*
* Dissect a BGP OPEN message.
*/
static void
dissect_bgp_open(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
struct bgp_open bgpo;
int hlen;
struct bgp_open bgpo; /* BGP OPEN message */
int hlen; /* message length */
/* snarf OPEN message */
memcpy(&bgpo, &pd[offset], sizeof(bgpo));
hlen = ntohs(bgpo.bgpo_len);
@ -220,17 +235,19 @@ dissect_bgp_open(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
"My AS: %u", ntohs(bgpo.bgpo_myas));
proto_tree_add_text(tree,
offset + offsetof(struct bgp_open, bgpo_holdtime), 2,
"Holdtime: %u", ntohs(bgpo.bgpo_holdtime));
"Hold Time: %u", ntohs(bgpo.bgpo_holdtime));
proto_tree_add_text(tree,
offset + offsetof(struct bgp_open, bgpo_id), 4,
"ID: %s", ip_to_str((guint8 *)&bgpo.bgpo_id));
"BGP Identifier: %s", ip_to_str((guint8 *)&bgpo.bgpo_id));
proto_tree_add_text(tree,
offset + offsetof(struct bgp_open, bgpo_optlen), 1,
"Option length: %u", bgpo.bgpo_optlen);
"Optional Parameters Length: %u %s", bgpo.bgpo_optlen,
(bgpo.bgpo_optlen == 1) ? "byte" : "bytes");
if (hlen > sizeof(struct bgp_open)) {
proto_tree_add_text(tree,
offset + sizeof(struct bgp_open), hlen - sizeof(struct bgp_open),
"Option data%s");
"Optional Parameters");
}
}
@ -654,9 +671,9 @@ static void
dissect_bgp_notification(const u_char *pd, int offset, frame_data *fd,
proto_tree *tree)
{
struct bgp_notification bgpn;
int hlen;
char *p;
struct bgp_notification bgpn; /* BGP NOTIFICATION message */
int hlen; /* message length */
char *p; /* string pointer */
/* snarf message */
memcpy(&bgpn, &pd[offset], sizeof(bgpn));
@ -695,19 +712,19 @@ dissect_bgp_notification(const u_char *pd, int offset, frame_data *fd,
void
dissect_bgp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
proto_item *ti;
proto_tree *bgp_tree;
proto_tree *bgp1_tree;
const u_char *p;
int l, i;
int found;
static u_char marker[] = {
proto_item *ti; /* tree item */
proto_tree *bgp_tree; /* BGP packet tree */
proto_tree *bgp1_tree; /* BGP message tree */
const u_char *p; /* packet offset pointer */
int l, i; /* tmp */
int found; /* number of BGP messages in packet */
static u_char marker[] = { /* BGP message marker */
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
struct bgp bgp;
int hlen;
char *typ;
struct bgp bgp; /* BGP header */
int hlen; /* BGP header length */
char *typ; /* BGP message type */
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "BGP");
@ -778,7 +795,24 @@ dissect_bgp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
ti = proto_tree_add_text(bgp_tree, offset + i, hlen,
"%s", typ);
}
bgp1_tree = proto_item_add_subtree(ti, ETT_BGP);
/* add a different tree for each message type */
switch (bgp.bgp_type) {
case BGP_OPEN:
bgp1_tree = proto_item_add_subtree(ti, ETT_BGP_OPEN);
break;
case BGP_UPDATE:
bgp1_tree = proto_item_add_subtree(ti, ETT_BGP_UPDATE);
break;
case BGP_NOTIFICATION:
bgp1_tree = proto_item_add_subtree(ti, ETT_BGP_NOTIFICATION);
break;
case BGP_KEEPALIVE:
bgp1_tree = proto_item_add_subtree(ti, ETT_BGP);
break;
default:
bgp1_tree = proto_item_add_subtree(ti, ETT_BGP);
break;
}
proto_tree_add_text(bgp1_tree, offset + i, BGP_MARKER_SIZE,
"Marker", NULL);

View File

@ -1,7 +1,7 @@
/* packet-bgp.c
* Definitions for BGP packet disassembly structures and routine
*
* $Id: packet-bgp.h,v 1.2 1999/11/02 00:11:58 itojun Exp $
* $Id: packet-bgp.h,v 1.3 1999/11/06 01:28:50 itojun Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@unicom.net>
@ -75,15 +75,21 @@ struct bgp_attr {
guint8 bgpa_type;
};
#define BGPTYPE_ORIGIN 1
#define BGPTYPE_AS_PATH 2
#define BGPTYPE_NEXT_HOP 3
#define BGPTYPE_MULTI_EXIT_DISC 4
#define BGPTYPE_LOCAL_PREF 5
#define BGPTYPE_ATOMIC_AGGREGATE 6
#define BGPTYPE_AGGREGATOR 7
#define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */
#define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */
#define BGPTYPE_ORIGIN 1 /* RFC1771 */
#define BGPTYPE_AS_PATH 2 /* RFC1771 */
#define BGPTYPE_NEXT_HOP 3 /* RFC1771 */
#define BGPTYPE_MULTI_EXIT_DISC 4 /* RFC1771 */
#define BGPTYPE_LOCAL_PREF 5 /* RFC1771 */
#define BGPTYPE_ATOMIC_AGGREGATE 6 /* RFC1771 */
#define BGPTYPE_AGGREGATOR 7 /* RFC1771 */
#define BGPTYPE_COMMUNITIES 8 /* RFC1997 */
#define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */
#define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */
#define BGPTYPE_DPA 11 /* work in progress */
#define BGPTYPE_ADVERTISERS 12 /* RFC1863 */
#define BGPTYPE_RCID_PATH 13 /* RFC1863 */
#define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */
#define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */
/* RFC1700 address family numbers */
#define AFNUM_INET 1

View File

@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
* $Id: packet.h,v 1.125 1999/11/05 07:16:22 guy Exp $
* $Id: packet.h,v 1.126 1999/11/06 01:28:50 itojun Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -277,6 +277,12 @@ enum {
ETT_BOOTP_OPTION,
ETT_IPv6,
ETT_BGP,
ETT_BGP_OPEN,
ETT_BGP_UPDATE,
ETT_BGP_NOTIFICATION,
ETT_BGP_ATTRS,
ETT_BGP_ATTR,
ETT_BGP_NLRI,
ETT_CLNP,
ETT_COTP,
ETT_VINES_FRP,