Wireshark  4.3.0
The Wireshark network protocol analyzer
xdlc.h
Go to the documentation of this file.
1 /* xdlc.h
2  * Define *DLC frame types, and routine to dissect the control field of
3  * a *DLC frame.
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11 
12 #ifndef __XDLC_H__
13 #define __XDLC_H__
14 
15 #include "ws_symbol_export.h"
16 
21 /*
22  * Low-order bits of first (extended) or only (basic) octet of control
23  * field, specifying the frame type.
24  */
25 #define XDLC_I_MASK 0x01
26 #define XDLC_I 0x00
27 #define XDLC_S_U_MASK 0x03
28 #define XDLC_S 0x01
29 #define XDLC_U 0x03
31 /*
32  * N(S) and N(R) fields, in basic and extended operation.
33  */
34 #define XDLC_N_R_MASK 0xE0
35 #define XDLC_N_R_SHIFT 5
36 #define XDLC_N_R_EXT_MASK 0xFE00
37 #define XDLC_N_R_EXT_SHIFT 9
38 #define XDLC_N_S_MASK 0x0E
39 #define XDLC_N_S_SHIFT 1
40 #define XDLC_N_S_EXT_MASK 0x00FE
41 #define XDLC_N_S_EXT_SHIFT 1
42 
43 /*
44  * Poll/Final bit, in basic and extended operation.
45  */
46 #define XDLC_P_F 0x10
47 #define XDLC_P_F_EXT 0x0100
49 /*
50  * S-format frame types.
51  */
52 #define XDLC_S_FTYPE_MASK 0x0C
53 #define XDLC_RR 0x00
54 #define XDLC_RNR 0x04
55 #define XDLC_REJ 0x08
56 #define XDLC_SREJ 0x0C
58 /*
59  * U-format modifiers.
60  */
61 #define XDLC_U_MODIFIER_MASK 0xEC
62 #define XDLC_UI 0x00
63 #define XDLC_UP 0x20
64 #define XDLC_DISC 0x40
65 #define XDLC_RD 0x40
66 #define XDLC_UA 0x60
67 #define XDLC_SNRM 0x80
68 #define XDLC_TEST 0xE0
69 #define XDLC_SIM 0x04
70 #define XDLC_RIM 0x04
71 #define XDLC_FRMR 0x84
72 #define XDLC_CFGR 0xC4
73 #define XDLC_SARM 0x0C
74 #define XDLC_DM 0x0C
75 #define XDLC_SABM 0x2C
76 #define XDLC_SARME 0x4C
77 #define XDLC_SABME 0x6C
78 #define XDLC_RESET 0x8C
79 #define XDLC_XID 0xAC
80 #define XDLC_SNRME 0xCC
81 #define XDLC_BCN 0xEC
90 #define XDLC_IS_INFORMATION(control) \
91  (((control) & XDLC_I_MASK) == XDLC_I || (control) == (XDLC_UI|XDLC_U))
92 
99 #define XDLC_CONTROL_LEN(control, is_extended) \
100  ((((control) & XDLC_S_U_MASK) == XDLC_U || !(is_extended)) ? 1 : 2)
101 
106 typedef struct {
107  int *hf_xdlc_n_r;
108  int *hf_xdlc_n_s;
109  int *hf_xdlc_p;
110  int *hf_xdlc_f;
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;
116 } xdlc_cf_items;
117 
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[];
122 
123 extern int get_xdlc_control(const guint8 *pd, int offset, gboolean is_extended);
124 
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, gint 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, gboolean is_response,
130  gboolean is_extended, gboolean append_info);
131 
132 #endif
Definition: packet_info.h:44
Definition: proto.h:904
Definition: value_string.h:26
Definition: tvbuff-int.h:35
Definition: xdlc.h:106