diff options
Diffstat (limited to 'epan')
-rw-r--r-- | epan/Makefile.common | 7 | ||||
-rw-r--r-- | epan/dissectors/packet-fr.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-hpext.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-lapb.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-lapd.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-llc.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-sdlc.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-v120.c | 2 | ||||
-rw-r--r-- | epan/plugins.c | 2 | ||||
-rw-r--r-- | epan/xdlc.c | 380 | ||||
-rw-r--r-- | epan/xdlc.h | 140 |
11 files changed, 532 insertions, 11 deletions
diff --git a/epan/Makefile.common b/epan/Makefile.common index 18c558024b..994de14fdf 100644 --- a/epan/Makefile.common +++ b/epan/Makefile.common @@ -58,7 +58,8 @@ LIBETHEREAL_SRC = \ timestamp.c \ to_str.c \ tvbuff.c \ - value_string.c + value_string.c \ + xdlc.c LIBETHEREAL_INCLUDES = \ addr_and_mask.h \ @@ -106,7 +107,8 @@ LIBETHEREAL_INCLUDES = \ timestamp.h \ to_str.h \ tvbuff.h \ - value_string.h + value_string.h \ + xdlc.h # dissector helpers (needed from the dissectors, but not a dissector itself) DISSECTOR_SUPPORT_SRC = \ @@ -121,6 +123,5 @@ DISSECTOR_SUPPORT_SRC = \ ../req_resp_hdrs.c \ ../t35.c \ ../tap.c \ - ../xdlc.c \ ../xmlstub.c diff --git a/epan/dissectors/packet-fr.c b/epan/dissectors/packet-fr.c index 619c1bb1e1..a8c8f0eec6 100644 --- a/epan/dissectors/packet-fr.c +++ b/epan/dissectors/packet-fr.c @@ -48,7 +48,7 @@ #include <epan/prefs.h> #include "packet-llc.h" #include "packet-chdlc.h" -#include "xdlc.h" +#include <epan/xdlc.h> #include "etypes.h" #include "oui.h" #include "nlpid.h" diff --git a/epan/dissectors/packet-hpext.c b/epan/dissectors/packet-hpext.c index 3a14dbb9c3..8a461e028b 100644 --- a/epan/dissectors/packet-hpext.c +++ b/epan/dissectors/packet-hpext.c @@ -29,7 +29,7 @@ #include <glib.h> #include <epan/packet.h> -#include "xdlc.h" +#include <epan/xdlc.h> #include "etypes.h" #include "llcsaps.h" #include "packet-hpext.h" diff --git a/epan/dissectors/packet-lapb.c b/epan/dissectors/packet-lapb.c index 0b010e5073..b208b75525 100644 --- a/epan/dissectors/packet-lapb.c +++ b/epan/dissectors/packet-lapb.c @@ -31,7 +31,7 @@ #include <glib.h> #include <string.h> #include <epan/packet.h> -#include "xdlc.h" +#include <epan/xdlc.h> static int proto_lapb = -1; static int hf_lapb_address = -1; diff --git a/epan/dissectors/packet-lapd.c b/epan/dissectors/packet-lapd.c index d766047ef8..328f5d273f 100644 --- a/epan/dissectors/packet-lapd.c +++ b/epan/dissectors/packet-lapd.c @@ -31,7 +31,7 @@ #include <glib.h> #include <string.h> #include <epan/packet.h> -#include "xdlc.h" +#include <epan/xdlc.h> #include "lapd_sapi.h" diff --git a/epan/dissectors/packet-llc.c b/epan/dissectors/packet-llc.c index 6d488c446d..e7f1b21a2e 100644 --- a/epan/dissectors/packet-llc.c +++ b/epan/dissectors/packet-llc.c @@ -30,7 +30,7 @@ #include <glib.h> #include <epan/packet.h> #include "oui.h" -#include "xdlc.h" +#include <epan/xdlc.h> #include "etypes.h" #include "llcsaps.h" #include "bridged_pids.h" diff --git a/epan/dissectors/packet-sdlc.c b/epan/dissectors/packet-sdlc.c index 12a6e2c140..79b6848b71 100644 --- a/epan/dissectors/packet-sdlc.c +++ b/epan/dissectors/packet-sdlc.c @@ -30,7 +30,7 @@ #include <glib.h> #include <string.h> #include <epan/packet.h> -#include "xdlc.h" +#include <epan/xdlc.h> /* * See diff --git a/epan/dissectors/packet-v120.c b/epan/dissectors/packet-v120.c index b47668fc2a..571355c710 100644 --- a/epan/dissectors/packet-v120.c +++ b/epan/dissectors/packet-v120.c @@ -31,7 +31,7 @@ #include <glib.h> #include <string.h> #include <epan/packet.h> -#include "xdlc.h" +#include <epan/xdlc.h> static int proto_v120 = -1; static int hf_v120_address = -1; diff --git a/epan/plugins.c b/epan/plugins.c index aaf852dfeb..1e9f9c9575 100644 --- a/epan/plugins.c +++ b/epan/plugins.c @@ -72,7 +72,7 @@ #include <epan/dissectors/packet-ber.h> #include <epan/dissectors/packet-rtp.h> #include <epan/dissectors/packet-rtcp.h> -#include "xdlc.h" +#include <epan/xdlc.h> #include <epan/crc16.h> #include "report_err.h" #include "plugins/plugin_table.h" diff --git a/epan/xdlc.c b/epan/xdlc.c new file mode 100644 index 0000000000..1cef001f9c --- /dev/null +++ b/epan/xdlc.c @@ -0,0 +1,380 @@ +/* xdlc.c + * Routines for use by various SDLC-derived protocols, such as HDLC + * and its derivatives LAPB, IEEE 802.2 LLC, etc.. + * + * $Id$ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <string.h> + +#include <glib.h> +#include <epan/packet.h> +#include <epan/xdlc.h> + +const value_string ftype_vals[] = { + { XDLC_I, "Information frame" }, + { XDLC_S, "Supervisory frame" }, + { XDLC_U, "Unnumbered frame" }, + { 0, NULL } +}; + +const value_string stype_vals[] = { + { XDLC_RR>>2, "Receiver ready" }, + { XDLC_RNR>>2, "Receiver not ready" }, + { XDLC_REJ>>2, "Reject" }, + { XDLC_SREJ>>2, "Selective reject" }, + { 0, NULL } +}; + +static const value_string modifier_short_vals_cmd[] = { + { XDLC_UI, "UI" }, + { XDLC_UP, "UP" }, + { XDLC_DISC, "DISC" }, + { XDLC_UA, "UA" }, + { XDLC_SNRM, "SNRM" }, + { XDLC_SNRME, "SNRME" }, + { XDLC_TEST, "TEST" }, + { XDLC_SIM, "SIM" }, + { XDLC_FRMR, "FRMR" }, + { XDLC_CFGR, "CFGR" }, + { XDLC_SARM, "SARM" }, + { XDLC_SABM, "SABM" }, + { XDLC_SARME, "SARME" }, + { XDLC_SABME, "SABME" }, + { XDLC_RESET, "RESET" }, + { XDLC_XID, "XID" }, + { XDLC_SNRME, "SNRME" }, + { XDLC_BCN, "BCN" }, + { 0, NULL } +}; + +const value_string modifier_vals_cmd[] = { + { XDLC_UI>>2, "Unnumbered Information" }, + { XDLC_UP>>2, "Unnumbered Poll" }, + { XDLC_DISC>>2, "Disconnect" }, + { XDLC_UA>>2, "Unnumbered Acknowledge" }, + { XDLC_SNRM>>2, "Set Normal Response Mode" }, + { XDLC_TEST>>2, "Test" }, + { XDLC_SIM>>2, "Set Initialization Mode" }, + { XDLC_FRMR>>2, "Frame reject" }, + { XDLC_CFGR>>2, "Configure" }, + { XDLC_SARM>>2, "Set Asynchronous Response Mode" }, + { XDLC_SABM>>2, "Set Asynchronous Balanced Mode" }, + { XDLC_SARME>>2, "Set Asynchronous Response Mode Extended" }, + { XDLC_SABME>>2, "Set Asynchronous Balanced Mode Extended" }, + { XDLC_RESET>>2, "Reset" }, + { XDLC_XID>>2, "Exchange identification" }, + { XDLC_SNRME>>2, "Set Normal Response Mode Extended" }, + { XDLC_BCN>>2, "Beacon" }, + { 0, NULL } +}; + +static const value_string modifier_short_vals_resp[] = { + { XDLC_UI, "UI" }, + { XDLC_UP, "UP" }, + { XDLC_RD, "RD" }, + { XDLC_UA, "UA" }, + { XDLC_SNRM, "SNRM" }, + { XDLC_TEST, "TEST" }, + { XDLC_RIM, "RIM" }, + { XDLC_FRMR, "FRMR" }, + { XDLC_CFGR, "CFGR" }, + { XDLC_DM, "DM" }, + { XDLC_SABM, "SABM" }, + { XDLC_SARME, "SARME" }, + { XDLC_SABME, "SABME" }, + { XDLC_RESET, "RESET" }, + { XDLC_XID, "XID" }, + { XDLC_SNRME, "SNRME" }, + { XDLC_BCN, "BCN" }, + { 0, NULL } +}; + +const value_string modifier_vals_resp[] = { + { XDLC_UI>>2, "Unnumbered Information" }, + { XDLC_UP>>2, "Unnumbered Poll" }, + { XDLC_RD>>2, "Request Disconnect" }, + { XDLC_UA>>2, "Unnumbered Acknowledge" }, + { XDLC_SNRM>>2, "Set Normal Response Mode" }, + { XDLC_TEST>>2, "Test" }, + { XDLC_RIM>>2, "Request Initialization Mode" }, + { XDLC_FRMR>>2, "Frame reject" }, + { XDLC_CFGR>>2, "Configure" }, + { XDLC_DM>>2, "Disconnected mode" }, + { XDLC_SABM>>2, "Set Asynchronous Balanced Mode" }, + { XDLC_SARME>>2, "Set Asynchronous Response Mode Extended" }, + { XDLC_SABME>>2, "Set Asynchronous Balanced Mode Extended" }, + { XDLC_RESET>>2, "Reset" }, + { XDLC_XID>>2, "Exchange identification" }, + { XDLC_SNRME>>2, "Set Normal Response Mode Extended" }, + { XDLC_BCN>>2, "Beacon" }, + { 0, NULL } +}; + +int +get_xdlc_control(const guchar *pd, int offset, int is_extended) +{ + guint16 control; + + switch (pd[offset] & 0x03) { + + case XDLC_S: + default: + /* + * Supervisory or Information frame. + */ + if (is_extended) + control = pletohs(&pd[offset]); + else + control = pd[offset]; + break; + + case XDLC_U: + /* + * Unnumbered frame. + * + * XXX - is this two octets, with a P/F bit, in HDLC extended + * operation? It's one octet in LLC, even though the control + * field of I and S frames is a 2-byte extended-operation field + * in LLC. Given that there are no sequence numbers in the + * control field of a U frame, there doesn't appear to be any + * need for it to be 2 bytes in extended operation. + */ + control = pd[offset]; + break; + } + return control; +} + +int +dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control, + const xdlc_cf_items *cf_items_nonext, const xdlc_cf_items *cf_items_ext, + const value_string *u_modifier_short_vals_cmd, + const value_string *u_modifier_short_vals_resp, int is_response, + int is_extended, int append_info) +{ + guint16 control; + int control_len; + const xdlc_cf_items *cf_items; + char *control_format; + guint16 poll_final; + char info[80]; + proto_tree *tc, *control_tree; + gchar *frame_type = NULL; + gchar *modifier; + + switch (tvb_get_guint8(tvb, offset) & 0x03) { + + case XDLC_S: + if (is_extended) { + control = tvb_get_letohs(tvb, offset); + control_len = 2; + cf_items = cf_items_ext; + control_format = "Control field: %s (0x%04X)"; + } else { + control = tvb_get_guint8(tvb, offset); + control_len = 1; + cf_items = cf_items_nonext; + control_format = "Control field: %s (0x%02X)"; + } + /* + * Supervisory frame. + */ + switch (control & XDLC_S_FTYPE_MASK) { + case XDLC_RR: + frame_type = "RR"; + break; + + case XDLC_RNR: + frame_type = "RNR"; + break; + + case XDLC_REJ: + frame_type = "REJ"; + break; + + case XDLC_SREJ: + frame_type = "SREJ"; + break; + } + if (is_extended) { + poll_final = (control & XDLC_P_F_EXT); + sprintf(info, "S%s, func=%s, N(R)=%u", + (poll_final ? + (is_response ? " F" : " P") : + ""), + frame_type, + (control & XDLC_N_R_EXT_MASK) >> XDLC_N_R_EXT_SHIFT); + } else { + poll_final = (control & XDLC_P_F); + sprintf(info, "S%s, func=%s, N(R)=%u", + (poll_final ? + (is_response ? " F" : " P") : + ""), + frame_type, + (control & XDLC_N_R_MASK) >> XDLC_N_R_SHIFT); + } + 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, control_len, control, control_format, info, control); + control_tree = proto_item_add_subtree(tc, ett_xdlc_control); + proto_tree_add_uint(control_tree, *cf_items->hf_xdlc_n_r, + tvb, offset, control_len, control); + if (poll_final) { + proto_tree_add_boolean(control_tree, + (is_response ? *cf_items->hf_xdlc_f : + *cf_items->hf_xdlc_p), + tvb, offset, control_len, control); + } + proto_tree_add_uint(control_tree, *cf_items->hf_xdlc_s_ftype, + tvb, offset, control_len, control); + /* This will always say it's a supervisory frame */ + proto_tree_add_uint(control_tree, *cf_items->hf_xdlc_ftype_s_u, + tvb, offset, control_len, control); + } + break; + + case XDLC_U: + /* + * Unnumbered frame. + * + * XXX - is this two octets, with a P/F bit, in HDLC extended + * operation? It's one octet in LLC, even though the control + * field of I and S frames is a 2-byte extended-operation field + * in LLC. Given that there are no sequence numbers in the + * control field of a U frame, there doesn't appear to be any + * need for it to be 2 bytes in extended operation. + */ + if (u_modifier_short_vals_cmd == NULL) + u_modifier_short_vals_cmd = modifier_short_vals_cmd; + if (u_modifier_short_vals_resp == NULL) + u_modifier_short_vals_resp = modifier_short_vals_resp; + control = tvb_get_guint8(tvb, offset); + control_len = 1; + cf_items = cf_items_nonext; + control_format = "Control field: %s (0x%02X)"; + if (is_response) { + modifier = match_strval(control & XDLC_U_MODIFIER_MASK, + u_modifier_short_vals_resp); + } else { + modifier = match_strval(control & XDLC_U_MODIFIER_MASK, + u_modifier_short_vals_cmd); + } + if (modifier == NULL) + modifier = "Unknown"; + poll_final = (control & XDLC_P_F); + sprintf(info, "U%s, func=%s", + (poll_final ? + (is_response ? " F" : " P") : + ""), + modifier); + 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, control_len, control, control_format, info, control); + control_tree = proto_item_add_subtree(tc, ett_xdlc_control); + if (poll_final) { + proto_tree_add_boolean(control_tree, + (is_response ? *cf_items->hf_xdlc_f: + *cf_items->hf_xdlc_p), + tvb, offset, control_len, control); + } + proto_tree_add_uint(control_tree, + (is_response ? *cf_items->hf_xdlc_u_modifier_resp : + *cf_items->hf_xdlc_u_modifier_cmd), + tvb, offset, control_len, control); + /* This will always say it's an unnumbered frame */ + proto_tree_add_uint(control_tree, *cf_items->hf_xdlc_ftype_s_u, + tvb, offset, control_len, control); + } + break; + + default: + /* + * Information frame. + */ + if (is_extended) { + control = tvb_get_letohs(tvb, offset); + control_len = 2; + cf_items = cf_items_ext; + control_format = "Control field: %s (0x%04X)"; + poll_final = (control & XDLC_P_F_EXT); + sprintf(info, "I%s, N(R)=%u, N(S)=%u", + ((control & XDLC_P_F_EXT) ? " P" : ""), + (control & XDLC_N_R_EXT_MASK) >> XDLC_N_R_EXT_SHIFT, + (control & XDLC_N_S_EXT_MASK) >> XDLC_N_S_EXT_SHIFT); + } else { + control = tvb_get_guint8(tvb, offset); + control_len = 1; + cf_items = cf_items_nonext; + control_format = "Control field: %s (0x%02X)"; + poll_final = (control & XDLC_P_F); + sprintf(info, "I%s, N(R)=%u, N(S)=%u", + ((control & XDLC_P_F) ? " P" : ""), + (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)) { + 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, control_len, control, control_format, info, control); + control_tree = proto_item_add_subtree(tc, ett_xdlc_control); + proto_tree_add_uint(control_tree, *cf_items->hf_xdlc_n_r, + tvb, offset, control_len, control); + proto_tree_add_uint(control_tree, *cf_items->hf_xdlc_n_s, + tvb, offset, control_len, control); + if (poll_final) { + proto_tree_add_boolean(control_tree, *cf_items->hf_xdlc_p, + tvb, offset, control_len, control); + } + /* This will always say it's an information frame */ + proto_tree_add_uint(control_tree, *cf_items->hf_xdlc_ftype_i, + tvb, offset, control_len, control); + } + break; + } + return control; +} diff --git a/epan/xdlc.h b/epan/xdlc.h new file mode 100644 index 0000000000..fc924ef6ee --- /dev/null +++ b/epan/xdlc.h @@ -0,0 +1,140 @@ +/* xdlc.h + * Define *DLC frame types, and routine to dissect the control field of + * a *DLC frame. + * + * $Id$ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __XDLC_H__ +#define __XDLC_H__ + +/* + * Low-order bits of first (extended) or only (basic) octet of control + * field, specifying the frame type. + */ +#define XDLC_I_MASK 0x01 /* Mask to test for I or not I */ +#define XDLC_I 0x00 /* Information frames */ +#define XDLC_S_U_MASK 0x03 /* Mask to test for S or U */ +#define XDLC_S 0x01 /* Supervisory frames */ +#define XDLC_U 0x03 /* Unnumbered frames */ + +/* + * N(S) and N(R) fields, in basic and extended operation. + */ +#define XDLC_N_R_MASK 0xE0 /* basic */ +#define XDLC_N_R_SHIFT 5 +#define XDLC_N_R_EXT_MASK 0xFE00 /* extended */ +#define XDLC_N_R_EXT_SHIFT 9 +#define XDLC_N_S_MASK 0x0E /* basic */ +#define XDLC_N_S_SHIFT 1 +#define XDLC_N_S_EXT_MASK 0x00FE /* extended */ +#define XDLC_N_S_EXT_SHIFT 1 + +/* + * Poll/Final bit, in basic and extended operation. + */ +#define XDLC_P_F 0x10 /* basic */ +#define XDLC_P_F_EXT 0x0100 /* extended */ + +/* + * S-format frame types. + */ +#define XDLC_S_FTYPE_MASK 0x0C +#define XDLC_RR 0x00 /* Receiver ready */ +#define XDLC_RNR 0x04 /* Receiver not ready */ +#define XDLC_REJ 0x08 /* Reject */ +#define XDLC_SREJ 0x0C /* Selective reject */ + +/* + * U-format modifiers. + */ +#define XDLC_U_MODIFIER_MASK 0xEC +#define XDLC_UI 0x00 /* Unnumbered Information */ +#define XDLC_UP 0x20 /* Unnumbered Poll */ +#define XDLC_DISC 0x40 /* Disconnect (command) */ +#define XDLC_RD 0x40 /* Request Disconnect (response) */ +#define XDLC_UA 0x60 /* Unnumbered Acknowledge */ +#define XDLC_SNRM 0x80 /* Set Normal Response Mode */ +#define XDLC_TEST 0xE0 /* Test */ +#define XDLC_SIM 0x04 /* Set Initialization Mode (command) */ +#define XDLC_RIM 0x04 /* Request Initialization Mode (response) */ +#define XDLC_FRMR 0x84 /* Frame reject */ +#define XDLC_CFGR 0xC4 /* Configure */ +#define XDLC_SARM 0x0C /* Set Asynchronous Response Mode (command) */ +#define XDLC_DM 0x0C /* Disconnected mode (response) */ +#define XDLC_SABM 0x2C /* Set Asynchronous Balanced Mode */ +#define XDLC_SARME 0x4C /* Set Asynchronous Response Mode Extended */ +#define XDLC_SABME 0x6C /* Set Asynchronous Balanced Mode Extended */ +#define XDLC_RESET 0x8C /* Reset */ +#define XDLC_XID 0xAC /* Exchange identification */ +#define XDLC_SNRME 0xCC /* Set Normal Response Mode Extended */ +#define XDLC_BCN 0xEC /* Beacon */ + +/* + * This macro takes the control field of an xDLC frame, as returned by + * "get_xdlc_control()" or "dissect_xdlc_control()", and evaluates to + * TRUE if the frame is an "information" frame and FALSE if it isn't. + * Note that frames other than information frames can have data in them, + * e.g. TEST frames. + */ +#define XDLC_IS_INFORMATION(control) \ + (((control) & XDLC_I_MASK) == XDLC_I || (control) == (XDLC_UI|XDLC_U)) + +/* + * This macro takes the control field of an xDLC frame, and a flag saying + * whether we're doing basic or extended operation, and evaluates to + * the length of that field (if it's an Unnumbered frame, or we're not + * in extended mode, it's 1 byte long, otherwise it's 2 bytes long). + */ +#define XDLC_CONTROL_LEN(control, is_extended) \ + ((((control) & XDLC_S_U_MASK) == XDLC_U || !(is_extended)) ? 1 : 2) + +/* + * Structure containing pointers to hf_ values for various subfields of + * the control field. + */ +typedef struct { + int *hf_xdlc_n_r; + int *hf_xdlc_n_s; + int *hf_xdlc_p; + int *hf_xdlc_f; + int *hf_xdlc_s_ftype; + int *hf_xdlc_u_modifier_cmd; + int *hf_xdlc_u_modifier_resp; + int *hf_xdlc_ftype_i; + int *hf_xdlc_ftype_s_u; +} xdlc_cf_items; + +extern const value_string ftype_vals[]; +extern const value_string stype_vals[]; +extern const value_string modifier_vals_cmd[]; +extern const value_string modifier_vals_resp[]; + +extern int get_xdlc_control(const guchar *pd, int offset, int extended); + +extern int dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control, + const xdlc_cf_items *cf_items_nonext, const xdlc_cf_items *cf_items_ext, + const value_string *u_modifier_short_vals_cmd, + const value_string *u_modifier_short_vals_resp, int is_response, + int is_extended, int append_info); + +#endif |