forked from osmocom/wireshark
Use "dissect_xdlc_control()" to dissect the control field of Frame Relay
packets that have one. Add an argument to "dissect_xdlc_control()" to indicate whether it should append the information to the Info field or just put it in the Info field. Use the #defines for the DLCI bitfields to extract the DLCI bits when constructing the DLCI. svn path=/trunk/; revision=8335
This commit is contained in:
parent
7cb23da0fb
commit
454806eeff
41
packet-fr.c
41
packet-fr.c
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright 2001, Paul Ionescu <paul@acorp.ro>
|
||||
*
|
||||
* $Id: packet-fr.c,v 1.36 2003/09/02 18:45:06 guy Exp $
|
||||
* $Id: packet-fr.c,v 1.37 2003/09/02 19:18:51 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -77,6 +77,7 @@
|
|||
static gint proto_fr = -1;
|
||||
static gint ett_fr = -1;
|
||||
static gint ett_fr_address = -1;
|
||||
static gint ett_fr_control = -1;
|
||||
static gint hf_fr_ea = -1;
|
||||
static gint hf_fr_upper_dlci = -1;
|
||||
static gint hf_fr_cr = -1;
|
||||
|
@ -89,6 +90,7 @@ static gint hf_fr_dlcore_control = -1;
|
|||
static gint hf_fr_lower_dlci = -1;
|
||||
static gint hf_fr_dc = -1;
|
||||
static gint hf_fr_dlci = -1;
|
||||
static gint hf_fr_control = -1;
|
||||
static gint hf_fr_nlpid = -1;
|
||||
static gint hf_fr_oui = -1;
|
||||
static gint hf_fr_pid = -1;
|
||||
|
@ -157,6 +159,7 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
proto_item *octet_item = NULL;
|
||||
proto_tree *octet_tree = NULL;
|
||||
guint8 fr_octet;
|
||||
int is_response = FALSE;
|
||||
guint32 address;
|
||||
guint8 fr_ctrl;
|
||||
guint16 fr_type;
|
||||
|
@ -203,7 +206,8 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
* The first octet contains the upper 6 bits of the DLCI, as well
|
||||
* as the C/R bit.
|
||||
*/
|
||||
address = (fr_octet & 0xFC) >> 2;
|
||||
address = (fr_octet & FRELAY_UPPER_DLCI) >> 2;
|
||||
is_response = (fr_octet & FRELAY_CR);
|
||||
if (tree) {
|
||||
octet_item = proto_tree_add_text(fr_tree, tvb, offset, 1,
|
||||
"First address octet: 0x%02x", fr_octet);
|
||||
|
@ -219,7 +223,7 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
* BECN, and DE.
|
||||
*/
|
||||
fr_octet = tvb_get_guint8(tvb, offset);
|
||||
address = (address << 4) | ((fr_octet & 0xF0) >> 4);
|
||||
address = (address << 4) | ((fr_octet & FRELAY_SECOND_DLCI) >> 4);
|
||||
if (tree) {
|
||||
octet_item = proto_tree_add_text(fr_tree, tvb, offset, 1,
|
||||
"Second address octet: 0x%02x",
|
||||
|
@ -246,7 +250,7 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
/*
|
||||
* 7 more bits of DLCI.
|
||||
*/
|
||||
address = (address << 7) | ((fr_octet & 0xFE) >> 1);
|
||||
address = (address << 7) | ((fr_octet & FRELAY_THIRD_DLCI) >> 1);
|
||||
if (tree) {
|
||||
octet_item = proto_tree_add_text(fr_tree, tvb, offset, 1,
|
||||
"Third address octet: 0x%02x",
|
||||
|
@ -289,7 +293,7 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
/*
|
||||
* Last 6 bits of DLCI.
|
||||
*/
|
||||
address = (address << 6) | ((fr_octet & 0xFC) >> 2);
|
||||
address = (address << 6) | ((fr_octet & FRELAY_LOWER_DLCI) >> 2);
|
||||
proto_tree_add_uint(octet_tree, hf_fr_lower_dlci, tvb, offset, 1, fr_octet);
|
||||
}
|
||||
proto_tree_add_boolean(octet_tree, hf_fr_dc, tvb, offset, 1, fr_octet);
|
||||
|
@ -309,15 +313,10 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
|
||||
fr_ctrl = tvb_get_guint8(tvb, offset);
|
||||
if (fr_ctrl == XDLC_U) {
|
||||
if (tree) {
|
||||
if (tree)
|
||||
proto_tree_add_text(fr_tree, tvb, offset, 0, "------- Q.922 Encapsulation -------");
|
||||
/*
|
||||
* XXX - if we're going to show this as Unnumbered
|
||||
* Information, should we just hand it to
|
||||
* "dissect_xdlc_control()"?
|
||||
*/
|
||||
proto_tree_add_text(fr_tree, tvb, offset, 1, "Unnumbered Information");
|
||||
}
|
||||
dissect_xdlc_control(tvb, offset, pinfo, fr_tree, hf_fr_control,
|
||||
ett_fr_control, is_response, FALSE, TRUE);
|
||||
offset++;
|
||||
|
||||
dissect_fr_nlpid(tvb, offset, pinfo, tree, ti, fr_tree, fr_ctrl);
|
||||
|
@ -327,10 +326,16 @@ dissect_fr_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
|||
/* because DLCI 0 is rezerved for LMI and SVC signaling encaplulated in lapf */
|
||||
/* and LMI is transmitted in unnumbered information (03) */
|
||||
/* so this must be lapf (guessing) */
|
||||
dissect_xdlc_control(tvb, offset, pinfo, fr_tree,
|
||||
hf_fr_control, ett_fr_control,
|
||||
is_response, FALSE, TRUE);
|
||||
dissect_lapf(tvb_new_subset(tvb,offset,-1,-1),pinfo,tree);
|
||||
return;
|
||||
}
|
||||
if (fr_ctrl == (XDLC_U|XDLC_XID)) {
|
||||
dissect_xdlc_control(tvb, offset, pinfo, fr_tree,
|
||||
hf_fr_control, ett_fr_control,
|
||||
is_response, FALSE, TRUE);
|
||||
dissect_fr_xid(tvb_new_subset(tvb,offset,-1,-1),pinfo,tree);
|
||||
return;
|
||||
}
|
||||
|
@ -539,9 +544,12 @@ void proto_register_fr(void)
|
|||
{ &hf_fr_dlci, {
|
||||
"DLCI", "fr.dlci", FT_UINT32, BASE_DEC,
|
||||
NULL, 0x0, "Data-Link Connection Identifier", HFILL }},
|
||||
{ &hf_fr_control, {
|
||||
"Control Field", "fr.control", FT_UINT8, BASE_HEX,
|
||||
NULL, 0x0, "Control field", HFILL }},
|
||||
{ &hf_fr_nlpid, {
|
||||
"NLPID", "fr.nlpid", FT_UINT8, BASE_HEX,
|
||||
VALS(fr_nlpid_vals), 0x0, "FrameRelay Encapsulated Protocol NLPID", HFILL }},
|
||||
VALS(fr_nlpid_vals), 0x0, "Frame Relay Encapsulated Protocol NLPID", HFILL }},
|
||||
{ &hf_fr_oui, {
|
||||
"Organization Code", "fr.snap.oui", FT_UINT24, BASE_HEX,
|
||||
VALS(oui_vals), 0x0, "", HFILL }},
|
||||
|
@ -550,10 +558,10 @@ void proto_register_fr(void)
|
|||
NULL, 0x0, "", HFILL }},
|
||||
{ &hf_fr_snaptype, {
|
||||
"Type", "fr.snaptype", FT_UINT16, BASE_HEX,
|
||||
VALS(etype_vals), 0x0, "FrameRelay SNAP Encapsulated Protocol", HFILL }},
|
||||
VALS(etype_vals), 0x0, "Frame Relay SNAP Encapsulated Protocol", HFILL }},
|
||||
{ &hf_fr_chdlctype, {
|
||||
"Type", "fr.chdlctype", FT_UINT16, BASE_HEX,
|
||||
VALS(chdlc_vals), 0x0, "FrameRelay Cisco HDLC Encapsulated Protocol", HFILL }},
|
||||
VALS(chdlc_vals), 0x0, "Frame Relay Cisco HDLC Encapsulated Protocol", HFILL }},
|
||||
};
|
||||
|
||||
|
||||
|
@ -561,6 +569,7 @@ void proto_register_fr(void)
|
|||
static gint *ett[] = {
|
||||
&ett_fr,
|
||||
&ett_fr_address,
|
||||
&ett_fr_control,
|
||||
};
|
||||
|
||||
proto_fr = proto_register_protocol("Frame Relay", "FR", "fr");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for lapb frame disassembly
|
||||
* Olivier Abad <oabad@noos.fr>
|
||||
*
|
||||
* $Id: packet-lapb.c,v 1.38 2002/09/01 14:30:30 oabad Exp $
|
||||
* $Id: packet-lapb.c,v 1.39 2003/09/02 19:18:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -97,7 +97,7 @@ dissect_lapb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
lapb_tree = NULL;
|
||||
|
||||
dissect_xdlc_control(tvb, 1, pinfo, lapb_tree, hf_lapb_control,
|
||||
ett_lapb_control, is_response, FALSE);
|
||||
ett_lapb_control, is_response, FALSE, FALSE);
|
||||
|
||||
/* not end of frame ==> X.25 */
|
||||
if (tvb_reported_length(tvb) > 2) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for LAPD frame disassembly
|
||||
* Gilbert Ramirez <gram@alumni.rice.edu>
|
||||
*
|
||||
* $Id: packet-lapd.c,v 1.34 2003/01/07 01:08:27 guy Exp $
|
||||
* $Id: packet-lapd.c,v 1.35 2003/09/02 19:18:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -137,7 +137,7 @@ dissect_lapd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
}
|
||||
|
||||
control = dissect_xdlc_control(tvb, 2, pinfo, lapd_tree, hf_lapd_control,
|
||||
ett_lapd_control, is_response, TRUE);
|
||||
ett_lapd_control, is_response, TRUE, FALSE);
|
||||
lapd_header_len += XDLC_CONTROL_LEN(control, TRUE);
|
||||
|
||||
if (tree)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for IEEE 802.2 LLC layer
|
||||
* Gilbert Ramirez <gram@alumni.rice.edu>
|
||||
*
|
||||
* $Id: packet-llc.c,v 1.112 2003/08/28 01:29:15 guy Exp $
|
||||
* $Id: packet-llc.c,v 1.113 2003/09/02 19:18:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -351,7 +351,7 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
*/
|
||||
control = dissect_xdlc_control(tvb, 2, pinfo, llc_tree,
|
||||
hf_llc_ctrl, ett_llc_ctrl,
|
||||
ssap & SSAP_CR_BIT, TRUE);
|
||||
ssap & SSAP_CR_BIT, TRUE, FALSE);
|
||||
llc_header_len += XDLC_CONTROL_LEN(control, TRUE);
|
||||
if (is_snap)
|
||||
llc_header_len += 5; /* 3 bytes of OUI, 2 bytes of protocol ID */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* packet-sdlc.c
|
||||
* Routines for SDLC frame disassembly
|
||||
*
|
||||
* $Id: packet-sdlc.c,v 1.1 2003/01/03 22:31:24 guy Exp $
|
||||
* $Id: packet-sdlc.c,v 1.2 2003/09/02 19:18:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -107,7 +107,7 @@ dissect_sdlc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
* to control what to use.
|
||||
*/
|
||||
control = dissect_xdlc_control(tvb, 1, pinfo, sdlc_tree, hf_sdlc_control,
|
||||
ett_sdlc_control, is_response, FALSE);
|
||||
ett_sdlc_control, is_response, FALSE, FALSE);
|
||||
sdlc_header_len += XDLC_CONTROL_LEN(control, FALSE);
|
||||
|
||||
if (tree)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Routines for v120 frame disassembly
|
||||
* Bert Driehuis <driehuis@playbeing.org>
|
||||
*
|
||||
* $Id: packet-v120.c,v 1.30 2002/10/31 07:43:10 guy Exp $
|
||||
* $Id: packet-v120.c,v 1.31 2003/09/02 19:18:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -126,7 +126,7 @@ dissect_v120(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
ti = NULL;
|
||||
}
|
||||
control = dissect_xdlc_control(tvb, 2, pinfo, v120_tree, hf_v120_control,
|
||||
ett_v120_control, is_response, TRUE);
|
||||
ett_v120_control, is_response, TRUE, FALSE);
|
||||
if (tree) {
|
||||
v120len = 2 + XDLC_CONTROL_LEN(control, TRUE);
|
||||
if (tvb_bytes_exist(tvb, v120len, 1))
|
||||
|
|
31
xdlc.c
31
xdlc.c
|
@ -2,7 +2,7 @@
|
|||
* Routines for use by various SDLC-derived protocols, such as HDLC
|
||||
* and its derivatives LAPB, IEEE 802.2 LLC, etc..
|
||||
*
|
||||
* $Id: xdlc.c,v 1.20 2002/08/28 21:00:41 jmayer Exp $
|
||||
* $Id: xdlc.c,v 1.21 2003/09/02 19:18:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -192,7 +192,7 @@ get_xdlc_control(const guchar *pd, int offset, int is_extended)
|
|||
int
|
||||
dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control,
|
||||
int is_response, int is_extended)
|
||||
int is_response, int is_extended, int append_info)
|
||||
{
|
||||
guint16 control;
|
||||
char info[80];
|
||||
|
@ -240,8 +240,13 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
""),
|
||||
(control & XDLC_N_R_MASK) >> XDLC_N_R_SHIFT);
|
||||
}
|
||||
if (check_col(pinfo->cinfo, COL_INFO))
|
||||
col_add_str(pinfo->cinfo, COL_INFO, info);
|
||||
if (check_col(pinfo->cinfo, COL_INFO)) {
|
||||
if (append_info) {
|
||||
col_append_str(pinfo->cinfo, COL_INFO, ", ");
|
||||
col_append_str(pinfo->cinfo, COL_INFO, info);
|
||||
} else
|
||||
col_add_str(pinfo->cinfo, COL_INFO, info);
|
||||
}
|
||||
if (xdlc_tree) {
|
||||
if (is_extended) {
|
||||
tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, tvb,
|
||||
|
@ -315,8 +320,13 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
(is_response ? " F" : " P") :
|
||||
""),
|
||||
modifier);
|
||||
if (check_col(pinfo->cinfo, COL_INFO))
|
||||
col_add_str(pinfo->cinfo, COL_INFO, info);
|
||||
if (check_col(pinfo->cinfo, COL_INFO)) {
|
||||
if (append_info) {
|
||||
col_append_str(pinfo->cinfo, COL_INFO, ", ");
|
||||
col_append_str(pinfo->cinfo, COL_INFO, info);
|
||||
} else
|
||||
col_add_str(pinfo->cinfo, COL_INFO, info);
|
||||
}
|
||||
if (xdlc_tree) {
|
||||
tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, tvb,
|
||||
offset, 1,
|
||||
|
@ -358,8 +368,13 @@ dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
(control & XDLC_N_R_MASK) >> XDLC_N_R_SHIFT,
|
||||
(control & XDLC_N_S_MASK) >> XDLC_N_S_SHIFT);
|
||||
}
|
||||
if (check_col(pinfo->cinfo, COL_INFO))
|
||||
col_add_str(pinfo->cinfo, COL_INFO, info);
|
||||
if (check_col(pinfo->cinfo, COL_INFO)) {
|
||||
if (append_info) {
|
||||
col_append_str(pinfo->cinfo, COL_INFO, ", ");
|
||||
col_append_str(pinfo->cinfo, COL_INFO, info);
|
||||
} else
|
||||
col_add_str(pinfo->cinfo, COL_INFO, info);
|
||||
}
|
||||
if (xdlc_tree) {
|
||||
tc = proto_tree_add_uint_format(xdlc_tree, hf_xdlc_control, tvb,
|
||||
offset, (is_extended) ? 2 : 1,
|
||||
|
|
4
xdlc.h
4
xdlc.h
|
@ -2,7 +2,7 @@
|
|||
* Define *DLC frame types, and routine to dissect the control field of
|
||||
* a *DLC frame.
|
||||
*
|
||||
* $Id: xdlc.h,v 1.17 2002/08/28 21:00:41 jmayer Exp $
|
||||
* $Id: xdlc.h,v 1.18 2003/09/02 19:18:52 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -84,6 +84,6 @@ int get_xdlc_control(const guchar *pd, int offset,
|
|||
|
||||
int dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control,
|
||||
int is_response, int extended);
|
||||
int is_response, int extended, int append_info);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue