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>
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 * V5 bitstream over HDLC handling
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
;
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
[] = {
58 #define MAX_V5EF_PACKET_LEN 1024
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
;
68 uint16_t addr
, eah
, eal
, efaddr
;
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
;
86 } else if (direction
> 0) {
90 col_set_str(pinfo
->cinfo
, COL_RES_DL_SRC
, srcname
);
91 col_set_str(pinfo
->cinfo
, COL_RES_DL_DST
, dstname
);
94 proto_item
*direction_ti
;
96 v5ef_ti
= proto_tree_add_item(tree
, proto_v5ef
, tvb
, 0, -1,
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
,
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
);
124 proto_item_set_len(v5ef_ti
, v5ef_header_len
);
126 next_tvb
= tvb_new_subset_remaining(tvb
, v5ef_header_len
);
129 call_dissector(v5dl_handle
,next_tvb
, pinfo
, tree
);
131 call_dissector_with_data(lapd_phdr_handle
, next_tvb
, pinfo
, tree
, isdn
);
133 return tvb_captured_length(tvb
);
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,
146 { "Address Field", "v5ef.address", FT_UINT16
, BASE_HEX
, NULL
, 0x0,
150 { "EAH", "v5ef.eah", FT_UINT16
, BASE_DEC
, NULL
, V5EF_EAH
,
151 "Envelope Address High Part", HFILL
}},
154 { "EA1", "v5ef.ea1", FT_UINT16
, BASE_DEC
, NULL
, V5EF_EA1
,
155 "First Address Extension bit", HFILL
}},
158 { "EAL", "v5ef.eal", FT_UINT16
, BASE_DEC
, NULL
, V5EF_EAL
,
159 "Envelope Address Low Part", HFILL
}},
162 { "EA2", "v5ef.ea2", FT_UINT16
, BASE_DEC
, NULL
, V5EF_EA2
,
163 "Second Address Extension bit", HFILL
}},
166 static int *ett
[] = {
171 proto_v5ef
= proto_register_protocol("V5 Envelope Function (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
);
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
194 * indent-tabs-mode: t
197 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
198 * :indentSize=8:tabSize=8:noTabs=false: