CPMConnect: unify version handling
[wireshark-wip.git] / epan / xdlc.h
blob47d9dd1542758d381d67758ff48bab7b7c17b5b1
1 /* xdlc.h
2 * Define *DLC frame types, and routine to dissect the control field of
3 * a *DLC frame.
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #ifndef __XDLC_H__
27 #define __XDLC_H__
29 #include "ws_symbol_export.h"
31 /** @file
32 * Define *DLC frame types, and routine to dissect the control field of
33 * a *DLC frame.
36 * Low-order bits of first (extended) or only (basic) octet of control
37 * field, specifying the frame type.
39 #define XDLC_I_MASK 0x01 /**< Mask to test for I or not I */
40 #define XDLC_I 0x00 /**< Information frames */
41 #define XDLC_S_U_MASK 0x03 /**< Mask to test for S or U */
42 #define XDLC_S 0x01 /**< Supervisory frames */
43 #define XDLC_U 0x03 /**< Unnumbered frames */
46 * N(S) and N(R) fields, in basic and extended operation.
48 #define XDLC_N_R_MASK 0xE0 /**< basic */
49 #define XDLC_N_R_SHIFT 5
50 #define XDLC_N_R_EXT_MASK 0xFE00 /**< extended */
51 #define XDLC_N_R_EXT_SHIFT 9
52 #define XDLC_N_S_MASK 0x0E /**< basic */
53 #define XDLC_N_S_SHIFT 1
54 #define XDLC_N_S_EXT_MASK 0x00FE /**< extended */
55 #define XDLC_N_S_EXT_SHIFT 1
58 * Poll/Final bit, in basic and extended operation.
60 #define XDLC_P_F 0x10 /**< basic */
61 #define XDLC_P_F_EXT 0x0100 /**< extended */
64 * S-format frame types.
66 #define XDLC_S_FTYPE_MASK 0x0C
67 #define XDLC_RR 0x00 /**< Receiver ready */
68 #define XDLC_RNR 0x04 /**< Receiver not ready */
69 #define XDLC_REJ 0x08 /**< Reject */
70 #define XDLC_SREJ 0x0C /**< Selective reject */
73 * U-format modifiers.
75 #define XDLC_U_MODIFIER_MASK 0xEC
76 #define XDLC_UI 0x00 /**< Unnumbered Information */
77 #define XDLC_UP 0x20 /**< Unnumbered Poll */
78 #define XDLC_DISC 0x40 /**< Disconnect (command) */
79 #define XDLC_RD 0x40 /**< Request Disconnect (response) */
80 #define XDLC_UA 0x60 /**< Unnumbered Acknowledge */
81 #define XDLC_SNRM 0x80 /**< Set Normal Response Mode */
82 #define XDLC_TEST 0xE0 /**< Test */
83 #define XDLC_SIM 0x04 /**< Set Initialization Mode (command) */
84 #define XDLC_RIM 0x04 /**< Request Initialization Mode (response) */
85 #define XDLC_FRMR 0x84 /**< Frame reject */
86 #define XDLC_CFGR 0xC4 /**< Configure */
87 #define XDLC_SARM 0x0C /**< Set Asynchronous Response Mode (command) */
88 #define XDLC_DM 0x0C /**< Disconnected mode (response) */
89 #define XDLC_SABM 0x2C /**< Set Asynchronous Balanced Mode */
90 #define XDLC_SARME 0x4C /**< Set Asynchronous Response Mode Extended */
91 #define XDLC_SABME 0x6C /**< Set Asynchronous Balanced Mode Extended */
92 #define XDLC_RESET 0x8C /**< Reset */
93 #define XDLC_XID 0xAC /**< Exchange identification */
94 #define XDLC_SNRME 0xCC /**< Set Normal Response Mode Extended */
95 #define XDLC_BCN 0xEC /**< Beacon */
97 /**
98 * This macro takes the control field of an xDLC frame, as returned by
99 * "get_xdlc_control()" or "dissect_xdlc_control()", and evaluates to
100 * TRUE if the frame is an "information" frame and FALSE if it isn't.
101 * Note that frames other than information frames can have data in them,
102 * e.g. TEST frames.
104 #define XDLC_IS_INFORMATION(control) \
105 (((control) & XDLC_I_MASK) == XDLC_I || (control) == (XDLC_UI|XDLC_U))
108 * This macro takes the control field of an xDLC frame, and a flag saying
109 * whether we're doing basic or extended operation, and evaluates to
110 * the length of that field (if it's an Unnumbered frame, or we're not
111 * in extended mode, it's 1 byte long, otherwise it's 2 bytes long).
113 #define XDLC_CONTROL_LEN(control, is_extended) \
114 ((((control) & XDLC_S_U_MASK) == XDLC_U || !(is_extended)) ? 1 : 2)
117 * Structure containing pointers to hf_ values for various subfields of
118 * the control field.
120 typedef struct {
121 int *hf_xdlc_n_r;
122 int *hf_xdlc_n_s;
123 int *hf_xdlc_p;
124 int *hf_xdlc_f;
125 int *hf_xdlc_s_ftype;
126 int *hf_xdlc_u_modifier_cmd;
127 int *hf_xdlc_u_modifier_resp;
128 int *hf_xdlc_ftype_i;
129 int *hf_xdlc_ftype_s_u;
130 } xdlc_cf_items;
132 extern const value_string ftype_vals[];
133 extern const value_string stype_vals[];
134 extern const value_string modifier_vals_cmd[];
135 extern const value_string modifier_vals_resp[];
137 extern int get_xdlc_control(const guchar *pd, int offset, gboolean is_extended);
140 * Check whether the control field of the packet looks valid.
142 WS_DLL_PUBLIC gboolean check_xdlc_control(tvbuff_t *tvb, int offset,
143 const value_string *u_modifier_short_vals_cmd,
144 const value_string *u_modifier_short_vals_resp, gboolean is_response,
145 gboolean is_extended _U_);
147 WS_DLL_PUBLIC int dissect_xdlc_control(tvbuff_t *tvb, int offset, packet_info *pinfo,
148 proto_tree *xdlc_tree, int hf_xdlc_control, gint ett_xdlc_control,
149 const xdlc_cf_items *cf_items_nonext, const xdlc_cf_items *cf_items_ext,
150 const value_string *u_modifier_short_vals_cmd,
151 const value_string *u_modifier_short_vals_resp, gboolean is_response,
152 gboolean is_extended, gboolean append_info);
154 #endif