Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-v5ef.c
blob36f3cc19864ad73e07eecf13a49bd26344236792
1 /* packet-v5ef.c
2 * Routines for V5 envelope function frame disassembly
3 * Rolf Fiedler <rolf.fiedler@innoventif.de>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 * V5 bitstream over HDLC handling
14 * V5 references:
16 * ETS 300 324-1
17 * ETS 300 347-1
20 #include "config.h"
22 #include <epan/packet.h>
23 #include <wiretap/wtap.h>
25 void proto_register_v5ef(void);
26 void proto_reg_handoff_v5ef(void);
28 static int proto_v5ef;
29 static int hf_v5ef_direction;
30 static int hf_v5ef_address;
31 static int hf_v5ef_eah;
32 static int hf_v5ef_ea1;
33 static int hf_v5ef_eal;
34 static int hf_v5ef_ea2;
36 static int ett_v5ef;
37 static int ett_v5ef_address;
39 static dissector_handle_t v5dl_handle, lapd_phdr_handle, v5ef_handle;
43 * Bits in the address field.
45 #define V5EF_EAH 0xfc00 /* Service Access Point Identifier */
46 #define V5EF_EAH_SHIFT 10
47 #define V5EF_EA1 0x0100 /* First Address Extension bit */
48 #define V5EF_EAL 0x00fe /* Terminal Endpoint Identifier */
49 #define V5EF_EAL_SHIFT 1
50 #define V5EF_EA2 0x0001 /* Second Address Extension bit */
52 static const value_string v5ef_direction_vals[] = {
53 { 0, "AN->LE"},
54 { 1, "LE->AN"},
55 { 0, NULL }
58 #define MAX_V5EF_PACKET_LEN 1024
60 static int
61 dissect_v5ef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
63 struct isdn_phdr *isdn = (struct isdn_phdr *)data;
64 proto_tree *v5ef_tree, *addr_tree;
65 proto_item *v5ef_ti, *addr_ti;
66 int direction;
67 int v5ef_header_len;
68 uint16_t addr, eah, eal, efaddr;
69 tvbuff_t *next_tvb;
70 const char *srcname = "src";
71 const char *dstname = "dst";
73 col_set_str(pinfo->cinfo, COL_PROTOCOL, "V5-EF");
74 col_clear(pinfo->cinfo, COL_INFO);
76 addr = tvb_get_ntohs(tvb, 0);
77 eah = (addr & V5EF_EAH) >> V5EF_EAH_SHIFT;
78 eal = (addr & V5EF_EAL) >> V5EF_EAL_SHIFT;
79 efaddr = (eah << 7) + eal;
80 v5ef_header_len = 2; /* addr */
82 direction = isdn->uton;
83 if (direction==0) {
84 srcname = "LE";
85 dstname = "AN";
86 } else if (direction > 0) {
87 srcname = "AN";
88 dstname = "LE";
90 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, srcname);
91 col_set_str(pinfo->cinfo, COL_RES_DL_DST, dstname);
93 if (tree) {
94 proto_item *direction_ti;
96 v5ef_ti = proto_tree_add_item(tree, proto_v5ef, tvb, 0, -1,
97 ENC_NA);
98 v5ef_tree = proto_item_add_subtree(v5ef_ti, ett_v5ef);
101 * Don't show the direction if we don't know it.
103 if (direction != P2P_DIR_UNKNOWN) {
104 direction_ti = proto_tree_add_uint(v5ef_tree, hf_v5ef_direction,
105 tvb, 0, 0, direction);
106 proto_item_set_generated(direction_ti);
109 addr_ti = proto_tree_add_uint(v5ef_tree, hf_v5ef_address, tvb,
110 0, 2, addr);
111 addr_tree = proto_item_add_subtree(addr_ti, ett_v5ef_address);
113 proto_tree_add_uint(addr_tree, hf_v5ef_eah, tvb, 0, 1, addr);
114 proto_tree_add_uint(addr_tree, hf_v5ef_ea1, tvb, 0, 1, addr);
115 proto_tree_add_uint(addr_tree, hf_v5ef_eal, tvb, 1, 1, addr);
116 proto_tree_add_uint(addr_tree, hf_v5ef_ea2, tvb, 1, 1, addr);
118 else {
119 v5ef_ti = NULL;
120 v5ef_tree = NULL;
123 if (tree)
124 proto_item_set_len(v5ef_ti, v5ef_header_len);
126 next_tvb = tvb_new_subset_remaining(tvb, v5ef_header_len);
128 if (efaddr>8175)
129 call_dissector(v5dl_handle,next_tvb, pinfo, tree);
130 else
131 call_dissector_with_data(lapd_phdr_handle, next_tvb, pinfo, tree, isdn);
133 return tvb_captured_length(tvb);
136 void
137 proto_register_v5ef(void)
139 static hf_register_info hf[] = {
141 { &hf_v5ef_direction,
142 { "Direction", "v5ef.direction", FT_UINT8, BASE_DEC, VALS(v5ef_direction_vals), 0x0,
143 NULL, HFILL }},
145 { &hf_v5ef_address,
146 { "Address Field", "v5ef.address", FT_UINT16, BASE_HEX, NULL, 0x0,
147 NULL, HFILL }},
149 { &hf_v5ef_eah,
150 { "EAH", "v5ef.eah", FT_UINT16, BASE_DEC, NULL, V5EF_EAH,
151 "Envelope Address High Part", HFILL }},
153 { &hf_v5ef_ea1,
154 { "EA1", "v5ef.ea1", FT_UINT16, BASE_DEC, NULL, V5EF_EA1,
155 "First Address Extension bit", HFILL }},
157 { &hf_v5ef_eal,
158 { "EAL", "v5ef.eal", FT_UINT16, BASE_DEC, NULL, V5EF_EAL,
159 "Envelope Address Low Part", HFILL }},
161 { &hf_v5ef_ea2,
162 { "EA2", "v5ef.ea2", FT_UINT16, BASE_DEC, NULL, V5EF_EA2,
163 "Second Address Extension bit", HFILL }},
166 static int *ett[] = {
167 &ett_v5ef,
168 &ett_v5ef_address,
171 proto_v5ef = proto_register_protocol("V5 Envelope Function (v5ef)",
172 "v5ef", "v5ef");
173 proto_register_field_array (proto_v5ef, hf, array_length(hf));
174 proto_register_subtree_array(ett, array_length(ett));
176 v5ef_handle = register_dissector("v5ef", dissect_v5ef, proto_v5ef);
179 void
180 proto_reg_handoff_v5ef(void)
182 dissector_add_uint("wtap_encap", WTAP_ENCAP_V5_EF, v5ef_handle);
184 lapd_phdr_handle = find_dissector_add_dependency("lapd-phdr", proto_v5ef);
185 v5dl_handle = find_dissector_add_dependency("v5dl", proto_v5ef);
189 * Editor modelines - https://www.wireshark.org/tools/modelines.html
191 * Local variables:
192 * c-basic-offset: 8
193 * tab-width: 8
194 * indent-tabs-mode: t
195 * End:
197 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
198 * :indentSize=8:tabSize=8:noTabs=false: