2 * Define *DLC frame types, and routine to dissect the control field of
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "ws_symbol_export.h"
18 * Define *DLC frame types, and routine to dissect the control field of
22 * Low-order bits of first (extended) or only (basic) octet of control
23 * field, specifying the frame type.
25 #define XDLC_I_MASK 0x01 /**< Mask to test for I or not I */
26 #define XDLC_I 0x00 /**< Information frames */
27 #define XDLC_S_U_MASK 0x03 /**< Mask to test for S or U */
28 #define XDLC_S 0x01 /**< Supervisory frames */
29 #define XDLC_U 0x03 /**< Unnumbered frames */
32 * N(S) and N(R) fields, in basic and extended operation.
34 #define XDLC_N_R_MASK 0xE0 /**< basic */
35 #define XDLC_N_R_SHIFT 5
36 #define XDLC_N_R_EXT_MASK 0xFE00 /**< extended */
37 #define XDLC_N_R_EXT_SHIFT 9
38 #define XDLC_N_S_MASK 0x0E /**< basic */
39 #define XDLC_N_S_SHIFT 1
40 #define XDLC_N_S_EXT_MASK 0x00FE /**< extended */
41 #define XDLC_N_S_EXT_SHIFT 1
44 * Poll/Final bit, in basic and extended operation.
46 #define XDLC_P_F 0x10 /**< basic */
47 #define XDLC_P_F_EXT 0x0100 /**< extended */
50 * S-format frame types.
52 #define XDLC_S_FTYPE_MASK 0x0C
53 #define XDLC_RR 0x00 /**< Receiver ready */
54 #define XDLC_RNR 0x04 /**< Receiver not ready */
55 #define XDLC_REJ 0x08 /**< Reject */
56 #define XDLC_SREJ 0x0C /**< Selective reject */
61 #define XDLC_U_MODIFIER_MASK 0xEC
62 #define XDLC_UI 0x00 /**< Unnumbered Information */
63 #define XDLC_UP 0x20 /**< Unnumbered Poll */
64 #define XDLC_DISC 0x40 /**< Disconnect (command) */
65 #define XDLC_RD 0x40 /**< Request Disconnect (response) */
66 #define XDLC_UA 0x60 /**< Unnumbered Acknowledge */
67 #define XDLC_SNRM 0x80 /**< Set Normal Response Mode */
68 #define XDLC_TEST 0xE0 /**< Test */
69 #define XDLC_SIM 0x04 /**< Set Initialization Mode (command) */
70 #define XDLC_RIM 0x04 /**< Request Initialization Mode (response) */
71 #define XDLC_FRMR 0x84 /**< Frame reject */
72 #define XDLC_CFGR 0xC4 /**< Configure */
73 #define XDLC_SARM 0x0C /**< Set Asynchronous Response Mode (command) */
74 #define XDLC_DM 0x0C /**< Disconnected mode (response) */
75 #define XDLC_SABM 0x2C /**< Set Asynchronous Balanced Mode */
76 #define XDLC_SARME 0x4C /**< Set Asynchronous Response Mode Extended */
77 #define XDLC_SABME 0x6C /**< Set Asynchronous Balanced Mode Extended */
78 #define XDLC_RESET 0x8C /**< Reset */
79 #define XDLC_XID 0xAC /**< Exchange identification */
80 #define XDLC_SNRME 0xCC /**< Set Normal Response Mode Extended */
81 #define XDLC_BCN 0xEC /**< Beacon */
84 * This macro takes the control field of an xDLC frame, as returned by
85 * "get_xdlc_control()" or "dissect_xdlc_control()", and evaluates to
86 * true if the frame is an "information" frame and false if it isn't.
87 * Note that frames other than information frames can have data in them,
90 #define XDLC_IS_INFORMATION(control) \
91 (((control) & XDLC_I_MASK) == XDLC_I || (control) == (XDLC_UI|XDLC_U))
94 * This macro takes the control field of an xDLC frame, and a flag saying
95 * whether we're doing basic or extended operation, and evaluates to
96 * the length of that field (if it's an Unnumbered frame, or we're not
97 * in extended mode, it's 1 byte long, otherwise it's 2 bytes long).
99 #define XDLC_CONTROL_LEN(control, is_extended) \
100 ((((control) & XDLC_S_U_MASK) == XDLC_U || !(is_extended)) ? 1 : 2)
103 * Structure containing pointers to hf_ values for various subfields of
111 int *hf_xdlc_s_ftype
;
112 int *hf_xdlc_u_modifier_cmd
;
113 int *hf_xdlc_u_modifier_resp
;
114 int *hf_xdlc_ftype_i
;
115 int *hf_xdlc_ftype_s_u
;
118 extern const value_string ftype_vals
[];
119 extern const value_string stype_vals
[];
120 extern const value_string modifier_vals_cmd
[];
121 extern const value_string modifier_vals_resp
[];
123 extern int get_xdlc_control(const uint8_t *pd
, int offset
, bool is_extended
);
125 WS_DLL_PUBLIC
int dissect_xdlc_control(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo
,
126 proto_tree
*xdlc_tree
, int hf_xdlc_control
, int ett_xdlc_control
,
127 const xdlc_cf_items
*cf_items_nonext
, const xdlc_cf_items
*cf_items_ext
,
128 const value_string
*u_modifier_short_vals_cmd
,
129 const value_string
*u_modifier_short_vals_resp
, bool is_response
,
130 bool is_extended
, bool append_info
);