2 * Routines for V5 envelope function frame disassembly
3 * Rolf Fiedler <rolf.fiedler@innoventif.de>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
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 * V5 bitstream over HDLC handling
38 #include <epan/packet.h>
39 #include <epan/conversation.h>
40 #include <epan/xdlc.h>
41 #include <epan/crc16-tvb.h>
43 static int proto_v5ef
= -1;
44 static int hf_v5ef_direction
= -1;
45 static int hf_v5ef_address
= -1;
46 static int hf_v5ef_eah
= -1;
47 static int hf_v5ef_ea1
= -1;
48 static int hf_v5ef_eal
= -1;
49 static int hf_v5ef_ea2
= -1;
51 static gint ett_v5ef
= -1;
52 static gint ett_v5ef_address
= -1;
54 static dissector_handle_t v5dl_handle
, lapd_handle
;
57 * Bits in the address field.
59 #define V5EF_EAH 0xfc00 /* Service Access Point Identifier */
60 #define V5EF_EAH_SHIFT 10
61 #define V5EF_EA1 0x0100 /* First Address Extension bit */
62 #define V5EF_EAL 0x00fe /* Terminal Endpoint Identifier */
63 #define V5EF_EAL_SHIFT 1
64 #define V5EF_EA2 0x0001 /* Second Address Extension bit */
66 static const value_string v5ef_direction_vals
[] = {
72 #define MAX_V5EF_PACKET_LEN 1024
75 dissect_v5ef(tvbuff_t
*, packet_info
*, proto_tree
*);
78 dissect_v5ef(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
80 proto_tree
*v5ef_tree
, *addr_tree
;
81 proto_item
*v5ef_ti
, *addr_ti
;
84 guint16 addr
, eah
, eal
, efaddr
;
86 const char *srcname
= "src";
87 const char *dstname
= "dst";
89 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "V5-EF");
90 col_clear(pinfo
->cinfo
, COL_INFO
);
92 addr
= tvb_get_ntohs(tvb
, 0);
93 eah
= (addr
& V5EF_EAH
) >> V5EF_EAH_SHIFT
;
94 eal
= (addr
& V5EF_EAL
) >> V5EF_EAL_SHIFT
;
95 efaddr
= (eah
<< 7) + eal
;
96 v5ef_header_len
= 2; /* addr */
98 direction
= pinfo
->pseudo_header
->isdn
.uton
;
102 } else if (direction
> 0) {
106 col_set_str(pinfo
->cinfo
, COL_RES_DL_SRC
, srcname
);
107 col_set_str(pinfo
->cinfo
, COL_RES_DL_DST
, dstname
);
110 proto_item
*direction_ti
;
112 v5ef_ti
= proto_tree_add_item(tree
, proto_v5ef
, tvb
, 0, -1,
114 v5ef_tree
= proto_item_add_subtree(v5ef_ti
, ett_v5ef
);
117 * Don't show the direction if we don't know it.
119 if (direction
!= P2P_DIR_UNKNOWN
) {
120 direction_ti
= proto_tree_add_uint(v5ef_tree
, hf_v5ef_direction
,
121 tvb
, 0, 0, direction
);
122 PROTO_ITEM_SET_GENERATED(direction_ti
);
125 addr_ti
= proto_tree_add_uint(v5ef_tree
, hf_v5ef_address
, tvb
,
127 addr_tree
= proto_item_add_subtree(addr_ti
, ett_v5ef_address
);
129 proto_tree_add_uint(addr_tree
, hf_v5ef_eah
, tvb
, 0, 1, addr
);
130 proto_tree_add_uint(addr_tree
, hf_v5ef_ea1
, tvb
, 0, 1, addr
);
131 proto_tree_add_uint(addr_tree
, hf_v5ef_eal
, tvb
, 1, 1, addr
);
132 proto_tree_add_uint(addr_tree
, hf_v5ef_ea2
, tvb
, 1, 1, addr
);
140 proto_item_set_len(v5ef_ti
, v5ef_header_len
);
142 next_tvb
= tvb_new_subset_remaining(tvb
, v5ef_header_len
);
145 call_dissector(v5dl_handle
,next_tvb
, pinfo
, tree
);
147 call_dissector(lapd_handle
,next_tvb
, pinfo
, tree
);
151 proto_reg_handoff_v5ef(void);
154 proto_register_v5ef(void)
156 static hf_register_info hf
[] = {
158 { &hf_v5ef_direction
,
159 { "Direction", "v5ef.direction", FT_UINT8
, BASE_DEC
, VALS(v5ef_direction_vals
), 0x0,
163 { "Address Field", "v5ef.address", FT_UINT16
, BASE_HEX
, NULL
, 0x0,
167 { "EAH", "v5ef.eah", FT_UINT16
, BASE_DEC
, NULL
, V5EF_EAH
,
168 "Envelope Address High Part", HFILL
}},
171 { "EA1", "v5ef.ea1", FT_UINT16
, BASE_DEC
, NULL
, V5EF_EA1
,
172 "First Address Extension bit", HFILL
}},
175 { "EAL", "v5ef.eal", FT_UINT16
, BASE_DEC
, NULL
, V5EF_EAL
,
176 "Envelope Address Low Part", HFILL
}},
179 { "EA2", "v5ef.ea2", FT_UINT16
, BASE_DEC
, NULL
, V5EF_EA2
,
180 "Second Address Extension bit", HFILL
}},
183 static gint
*ett
[] = {
188 proto_v5ef
= proto_register_protocol("V5 Envelope Function (v5ef)",
190 proto_register_field_array (proto_v5ef
, hf
, array_length(hf
));
191 proto_register_subtree_array(ett
, array_length(ett
));
193 register_dissector("v5ef", dissect_v5ef
, proto_v5ef
);
198 proto_reg_handoff_v5ef(void)
200 dissector_handle_t v5ef_handle
;
202 v5ef_handle
= find_dissector("v5ef");
203 dissector_add_uint("wtap_encap", WTAP_ENCAP_V5_EF
, v5ef_handle
);
205 lapd_handle
= find_dissector("lapd");
206 v5dl_handle
= find_dissector("v5dl");