wireshark/epan/dissectors/packet-v5ef.c

200 lines
5.0 KiB
C
Raw Normal View History

/* packet-v5ef.c
* Routines for V5 envelope function frame disassembly
* Rolf Fiedler <rolf.fiedler@innoventif.de>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* V5 bitstream over HDLC handling
*
* V5 references:
*
* ETS 300 324-1
* ETS 300 347-1
*/
#include "config.h"
#include <epan/packet.h>
#include <wiretap/wtap.h>
void proto_register_v5ef(void);
void proto_reg_handoff_v5ef(void);
static int proto_v5ef = -1;
static int hf_v5ef_direction = -1;
static int hf_v5ef_address = -1;
static int hf_v5ef_eah = -1;
static int hf_v5ef_ea1 = -1;
static int hf_v5ef_eal = -1;
static int hf_v5ef_ea2 = -1;
static gint ett_v5ef = -1;
static gint ett_v5ef_address = -1;
ISDN, LAPD: clean up the way they connect to other dissectors. Have the ISDN dissector take the ISDN pseudo-header through its data argument, rather than assuming it's in pinfo->pseudo_header, so it can be used if the link-layer type of the capture isn't ISDN. Have it add the direction to its protocol tree, so it's there for all ISDN packets. Have more versions of the LAPD dissector: one where the ISDN direction information is available through an ISDN pseudo-header passed as its data argument; one for use when the link-layer type *is* LAPD, where the ISDN direction information may be available through the direction part of the packet flags. Pass more flags to the routine that does LAPD dissection to indicate the direction (user->network or network->user) and whether the user or network side is on another machine; set those appropriately in the dissector routines that call it. To set those flags: in the routine that handles WTAP_ENCAP_LAPD, check the direction flags in pinfo->rec->rec_header.packet_header.pack_flags; in the routine that handles WTAP_ENCAP_LINUX_LAPD, check the SLL header; in the routine that's called from the ISDN dissector and other dissectors that can supply an ISDN pseudo-header, check the struct isdn_phdr passed to it via the data argument; for the routine that's to be called from L2TP pseudowire type and SCTP dissector tables, pass nothing, as there's currently no direction indication supplied - if that information is available from the encapsulating protocol in some fashion, we should make changes to supply that information. Have the AudioCodes Trunk trace protocol dissector call the LAPD-with-pseudoheader dissector, handing it an ISDN pseudo-header with a direction indication from the direction field (and a channel of 0 to indicate the D channel). Have the Ascend text dump reader in libwiretap use WTAP_ENCAP_ASCEND for all packets, even Ethernet and ISDN packets, and have the Ascend text dump dissector handle that, calling the "no FCS" version of the Ethernet dissector and calling the LAPD-with-pseudoheader dissector with a pseudo-header filled in with the direction (and a channel of 0). Have the Catapult DCT 2000 text dump dissector call the LAPD-with-pseudoheader dissector with the pseudo-header supplied by libwireshark. Have the V5 envelope function frame get its ISDN pseudo-header from its data argument, and call the LAPD-with-pseudoheader dissector with that pseudo-header. Have the ISDN dissector treat its data argument as pointing to the ISDN pseudo-header, rather than assuming it's the one in pinfo->pseudo_header->isdn - the latter is the one supplied by libwiretap, but there's no guarantee that an ISDN pseudo-header was supplied by libwiretap, as the lowest-level protocol layer might not have been ISDN. Change-Id: I9f702b879bbc3fb42bcb43c28f797bfc327562c6 Reviewed-on: https://code.wireshark.org/review/37953 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-25 09:20:10 +00:00
static dissector_handle_t v5dl_handle, lapd_phdr_handle, v5ef_handle;
/*
* Bits in the address field.
*/
#define V5EF_EAH 0xfc00 /* Service Access Point Identifier */
#define V5EF_EAH_SHIFT 10
#define V5EF_EA1 0x0100 /* First Address Extension bit */
#define V5EF_EAL 0x00fe /* Terminal Endpoint Identifier */
#define V5EF_EAL_SHIFT 1
#define V5EF_EA2 0x0001 /* Second Address Extension bit */
static const value_string v5ef_direction_vals[] = {
{ 0, "AN->LE"},
{ 1, "LE->AN"},
{ 0, NULL }
};
#define MAX_V5EF_PACKET_LEN 1024
static int
ISDN, LAPD: clean up the way they connect to other dissectors. Have the ISDN dissector take the ISDN pseudo-header through its data argument, rather than assuming it's in pinfo->pseudo_header, so it can be used if the link-layer type of the capture isn't ISDN. Have it add the direction to its protocol tree, so it's there for all ISDN packets. Have more versions of the LAPD dissector: one where the ISDN direction information is available through an ISDN pseudo-header passed as its data argument; one for use when the link-layer type *is* LAPD, where the ISDN direction information may be available through the direction part of the packet flags. Pass more flags to the routine that does LAPD dissection to indicate the direction (user->network or network->user) and whether the user or network side is on another machine; set those appropriately in the dissector routines that call it. To set those flags: in the routine that handles WTAP_ENCAP_LAPD, check the direction flags in pinfo->rec->rec_header.packet_header.pack_flags; in the routine that handles WTAP_ENCAP_LINUX_LAPD, check the SLL header; in the routine that's called from the ISDN dissector and other dissectors that can supply an ISDN pseudo-header, check the struct isdn_phdr passed to it via the data argument; for the routine that's to be called from L2TP pseudowire type and SCTP dissector tables, pass nothing, as there's currently no direction indication supplied - if that information is available from the encapsulating protocol in some fashion, we should make changes to supply that information. Have the AudioCodes Trunk trace protocol dissector call the LAPD-with-pseudoheader dissector, handing it an ISDN pseudo-header with a direction indication from the direction field (and a channel of 0 to indicate the D channel). Have the Ascend text dump reader in libwiretap use WTAP_ENCAP_ASCEND for all packets, even Ethernet and ISDN packets, and have the Ascend text dump dissector handle that, calling the "no FCS" version of the Ethernet dissector and calling the LAPD-with-pseudoheader dissector with a pseudo-header filled in with the direction (and a channel of 0). Have the Catapult DCT 2000 text dump dissector call the LAPD-with-pseudoheader dissector with the pseudo-header supplied by libwireshark. Have the V5 envelope function frame get its ISDN pseudo-header from its data argument, and call the LAPD-with-pseudoheader dissector with that pseudo-header. Have the ISDN dissector treat its data argument as pointing to the ISDN pseudo-header, rather than assuming it's the one in pinfo->pseudo_header->isdn - the latter is the one supplied by libwiretap, but there's no guarantee that an ISDN pseudo-header was supplied by libwiretap, as the lowest-level protocol layer might not have been ISDN. Change-Id: I9f702b879bbc3fb42bcb43c28f797bfc327562c6 Reviewed-on: https://code.wireshark.org/review/37953 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-25 09:20:10 +00:00
dissect_v5ef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
ISDN, LAPD: clean up the way they connect to other dissectors. Have the ISDN dissector take the ISDN pseudo-header through its data argument, rather than assuming it's in pinfo->pseudo_header, so it can be used if the link-layer type of the capture isn't ISDN. Have it add the direction to its protocol tree, so it's there for all ISDN packets. Have more versions of the LAPD dissector: one where the ISDN direction information is available through an ISDN pseudo-header passed as its data argument; one for use when the link-layer type *is* LAPD, where the ISDN direction information may be available through the direction part of the packet flags. Pass more flags to the routine that does LAPD dissection to indicate the direction (user->network or network->user) and whether the user or network side is on another machine; set those appropriately in the dissector routines that call it. To set those flags: in the routine that handles WTAP_ENCAP_LAPD, check the direction flags in pinfo->rec->rec_header.packet_header.pack_flags; in the routine that handles WTAP_ENCAP_LINUX_LAPD, check the SLL header; in the routine that's called from the ISDN dissector and other dissectors that can supply an ISDN pseudo-header, check the struct isdn_phdr passed to it via the data argument; for the routine that's to be called from L2TP pseudowire type and SCTP dissector tables, pass nothing, as there's currently no direction indication supplied - if that information is available from the encapsulating protocol in some fashion, we should make changes to supply that information. Have the AudioCodes Trunk trace protocol dissector call the LAPD-with-pseudoheader dissector, handing it an ISDN pseudo-header with a direction indication from the direction field (and a channel of 0 to indicate the D channel). Have the Ascend text dump reader in libwiretap use WTAP_ENCAP_ASCEND for all packets, even Ethernet and ISDN packets, and have the Ascend text dump dissector handle that, calling the "no FCS" version of the Ethernet dissector and calling the LAPD-with-pseudoheader dissector with a pseudo-header filled in with the direction (and a channel of 0). Have the Catapult DCT 2000 text dump dissector call the LAPD-with-pseudoheader dissector with the pseudo-header supplied by libwireshark. Have the V5 envelope function frame get its ISDN pseudo-header from its data argument, and call the LAPD-with-pseudoheader dissector with that pseudo-header. Have the ISDN dissector treat its data argument as pointing to the ISDN pseudo-header, rather than assuming it's the one in pinfo->pseudo_header->isdn - the latter is the one supplied by libwiretap, but there's no guarantee that an ISDN pseudo-header was supplied by libwiretap, as the lowest-level protocol layer might not have been ISDN. Change-Id: I9f702b879bbc3fb42bcb43c28f797bfc327562c6 Reviewed-on: https://code.wireshark.org/review/37953 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-25 09:20:10 +00:00
struct isdn_phdr *isdn = (struct isdn_phdr *)data;
proto_tree *v5ef_tree, *addr_tree;
proto_item *v5ef_ti, *addr_ti;
int direction;
int v5ef_header_len;
guint16 addr, eah, eal, efaddr;
tvbuff_t *next_tvb;
const char *srcname = "src";
const char *dstname = "dst";
col_set_str(pinfo->cinfo, COL_PROTOCOL, "V5-EF");
col_clear(pinfo->cinfo, COL_INFO);
addr = tvb_get_ntohs(tvb, 0);
eah = (addr & V5EF_EAH) >> V5EF_EAH_SHIFT;
eal = (addr & V5EF_EAL) >> V5EF_EAL_SHIFT;
efaddr = (eah << 7) + eal;
v5ef_header_len = 2; /* addr */
ISDN, LAPD: clean up the way they connect to other dissectors. Have the ISDN dissector take the ISDN pseudo-header through its data argument, rather than assuming it's in pinfo->pseudo_header, so it can be used if the link-layer type of the capture isn't ISDN. Have it add the direction to its protocol tree, so it's there for all ISDN packets. Have more versions of the LAPD dissector: one where the ISDN direction information is available through an ISDN pseudo-header passed as its data argument; one for use when the link-layer type *is* LAPD, where the ISDN direction information may be available through the direction part of the packet flags. Pass more flags to the routine that does LAPD dissection to indicate the direction (user->network or network->user) and whether the user or network side is on another machine; set those appropriately in the dissector routines that call it. To set those flags: in the routine that handles WTAP_ENCAP_LAPD, check the direction flags in pinfo->rec->rec_header.packet_header.pack_flags; in the routine that handles WTAP_ENCAP_LINUX_LAPD, check the SLL header; in the routine that's called from the ISDN dissector and other dissectors that can supply an ISDN pseudo-header, check the struct isdn_phdr passed to it via the data argument; for the routine that's to be called from L2TP pseudowire type and SCTP dissector tables, pass nothing, as there's currently no direction indication supplied - if that information is available from the encapsulating protocol in some fashion, we should make changes to supply that information. Have the AudioCodes Trunk trace protocol dissector call the LAPD-with-pseudoheader dissector, handing it an ISDN pseudo-header with a direction indication from the direction field (and a channel of 0 to indicate the D channel). Have the Ascend text dump reader in libwiretap use WTAP_ENCAP_ASCEND for all packets, even Ethernet and ISDN packets, and have the Ascend text dump dissector handle that, calling the "no FCS" version of the Ethernet dissector and calling the LAPD-with-pseudoheader dissector with a pseudo-header filled in with the direction (and a channel of 0). Have the Catapult DCT 2000 text dump dissector call the LAPD-with-pseudoheader dissector with the pseudo-header supplied by libwireshark. Have the V5 envelope function frame get its ISDN pseudo-header from its data argument, and call the LAPD-with-pseudoheader dissector with that pseudo-header. Have the ISDN dissector treat its data argument as pointing to the ISDN pseudo-header, rather than assuming it's the one in pinfo->pseudo_header->isdn - the latter is the one supplied by libwiretap, but there's no guarantee that an ISDN pseudo-header was supplied by libwiretap, as the lowest-level protocol layer might not have been ISDN. Change-Id: I9f702b879bbc3fb42bcb43c28f797bfc327562c6 Reviewed-on: https://code.wireshark.org/review/37953 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-25 09:20:10 +00:00
direction = isdn->uton;
if (direction==0) {
srcname = "LE";
dstname = "AN";
} else if (direction > 0) {
srcname = "AN";
dstname = "LE";
}
col_set_str(pinfo->cinfo, COL_RES_DL_SRC, srcname);
col_set_str(pinfo->cinfo, COL_RES_DL_DST, dstname);
if (tree) {
proto_item *direction_ti;
v5ef_ti = proto_tree_add_item(tree, proto_v5ef, tvb, 0, -1,
ENC_NA);
v5ef_tree = proto_item_add_subtree(v5ef_ti, ett_v5ef);
/*
* Don't show the direction if we don't know it.
*/
if (direction != P2P_DIR_UNKNOWN) {
direction_ti = proto_tree_add_uint(v5ef_tree, hf_v5ef_direction,
tvb, 0, 0, direction);
proto_item_set_generated(direction_ti);
}
addr_ti = proto_tree_add_uint(v5ef_tree, hf_v5ef_address, tvb,
0, 2, addr);
addr_tree = proto_item_add_subtree(addr_ti, ett_v5ef_address);
proto_tree_add_uint(addr_tree, hf_v5ef_eah, tvb, 0, 1, addr);
proto_tree_add_uint(addr_tree, hf_v5ef_ea1, tvb, 0, 1, addr);
proto_tree_add_uint(addr_tree, hf_v5ef_eal, tvb, 1, 1, addr);
proto_tree_add_uint(addr_tree, hf_v5ef_ea2, tvb, 1, 1, addr);
}
else {
v5ef_ti = NULL;
v5ef_tree = NULL;
}
if (tree)
proto_item_set_len(v5ef_ti, v5ef_header_len);
next_tvb = tvb_new_subset_remaining(tvb, v5ef_header_len);
if (efaddr>8175)
call_dissector(v5dl_handle,next_tvb, pinfo, tree);
else
ISDN, LAPD: clean up the way they connect to other dissectors. Have the ISDN dissector take the ISDN pseudo-header through its data argument, rather than assuming it's in pinfo->pseudo_header, so it can be used if the link-layer type of the capture isn't ISDN. Have it add the direction to its protocol tree, so it's there for all ISDN packets. Have more versions of the LAPD dissector: one where the ISDN direction information is available through an ISDN pseudo-header passed as its data argument; one for use when the link-layer type *is* LAPD, where the ISDN direction information may be available through the direction part of the packet flags. Pass more flags to the routine that does LAPD dissection to indicate the direction (user->network or network->user) and whether the user or network side is on another machine; set those appropriately in the dissector routines that call it. To set those flags: in the routine that handles WTAP_ENCAP_LAPD, check the direction flags in pinfo->rec->rec_header.packet_header.pack_flags; in the routine that handles WTAP_ENCAP_LINUX_LAPD, check the SLL header; in the routine that's called from the ISDN dissector and other dissectors that can supply an ISDN pseudo-header, check the struct isdn_phdr passed to it via the data argument; for the routine that's to be called from L2TP pseudowire type and SCTP dissector tables, pass nothing, as there's currently no direction indication supplied - if that information is available from the encapsulating protocol in some fashion, we should make changes to supply that information. Have the AudioCodes Trunk trace protocol dissector call the LAPD-with-pseudoheader dissector, handing it an ISDN pseudo-header with a direction indication from the direction field (and a channel of 0 to indicate the D channel). Have the Ascend text dump reader in libwiretap use WTAP_ENCAP_ASCEND for all packets, even Ethernet and ISDN packets, and have the Ascend text dump dissector handle that, calling the "no FCS" version of the Ethernet dissector and calling the LAPD-with-pseudoheader dissector with a pseudo-header filled in with the direction (and a channel of 0). Have the Catapult DCT 2000 text dump dissector call the LAPD-with-pseudoheader dissector with the pseudo-header supplied by libwireshark. Have the V5 envelope function frame get its ISDN pseudo-header from its data argument, and call the LAPD-with-pseudoheader dissector with that pseudo-header. Have the ISDN dissector treat its data argument as pointing to the ISDN pseudo-header, rather than assuming it's the one in pinfo->pseudo_header->isdn - the latter is the one supplied by libwiretap, but there's no guarantee that an ISDN pseudo-header was supplied by libwiretap, as the lowest-level protocol layer might not have been ISDN. Change-Id: I9f702b879bbc3fb42bcb43c28f797bfc327562c6 Reviewed-on: https://code.wireshark.org/review/37953 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-25 09:20:10 +00:00
call_dissector_with_data(lapd_phdr_handle, next_tvb, pinfo, tree, isdn);
return tvb_captured_length(tvb);
}
void
proto_register_v5ef(void)
{
static hf_register_info hf[] = {
{ &hf_v5ef_direction,
{ "Direction", "v5ef.direction", FT_UINT8, BASE_DEC, VALS(v5ef_direction_vals), 0x0,
NULL, HFILL }},
{ &hf_v5ef_address,
{ "Address Field", "v5ef.address", FT_UINT16, BASE_HEX, NULL, 0x0,
"Address", HFILL }},
{ &hf_v5ef_eah,
{ "EAH", "v5ef.eah", FT_UINT16, BASE_DEC, NULL, V5EF_EAH,
"Envelope Address High Part", HFILL }},
{ &hf_v5ef_ea1,
{ "EA1", "v5ef.ea1", FT_UINT16, BASE_DEC, NULL, V5EF_EA1,
"First Address Extension bit", HFILL }},
{ &hf_v5ef_eal,
{ "EAL", "v5ef.eal", FT_UINT16, BASE_DEC, NULL, V5EF_EAL,
"Envelope Address Low Part", HFILL }},
{ &hf_v5ef_ea2,
{ "EA2", "v5ef.ea2", FT_UINT16, BASE_DEC, NULL, V5EF_EA2,
"Second Address Extension bit", HFILL }},
};
static gint *ett[] = {
&ett_v5ef,
&ett_v5ef_address,
};
proto_v5ef = proto_register_protocol("V5 Envelope Function (v5ef)",
"v5ef", "v5ef");
proto_register_field_array (proto_v5ef, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
v5ef_handle = register_dissector("v5ef", dissect_v5ef, proto_v5ef);
}
void
proto_reg_handoff_v5ef(void)
{
dissector_add_uint("wtap_encap", WTAP_ENCAP_V5_EF, v5ef_handle);
ISDN, LAPD: clean up the way they connect to other dissectors. Have the ISDN dissector take the ISDN pseudo-header through its data argument, rather than assuming it's in pinfo->pseudo_header, so it can be used if the link-layer type of the capture isn't ISDN. Have it add the direction to its protocol tree, so it's there for all ISDN packets. Have more versions of the LAPD dissector: one where the ISDN direction information is available through an ISDN pseudo-header passed as its data argument; one for use when the link-layer type *is* LAPD, where the ISDN direction information may be available through the direction part of the packet flags. Pass more flags to the routine that does LAPD dissection to indicate the direction (user->network or network->user) and whether the user or network side is on another machine; set those appropriately in the dissector routines that call it. To set those flags: in the routine that handles WTAP_ENCAP_LAPD, check the direction flags in pinfo->rec->rec_header.packet_header.pack_flags; in the routine that handles WTAP_ENCAP_LINUX_LAPD, check the SLL header; in the routine that's called from the ISDN dissector and other dissectors that can supply an ISDN pseudo-header, check the struct isdn_phdr passed to it via the data argument; for the routine that's to be called from L2TP pseudowire type and SCTP dissector tables, pass nothing, as there's currently no direction indication supplied - if that information is available from the encapsulating protocol in some fashion, we should make changes to supply that information. Have the AudioCodes Trunk trace protocol dissector call the LAPD-with-pseudoheader dissector, handing it an ISDN pseudo-header with a direction indication from the direction field (and a channel of 0 to indicate the D channel). Have the Ascend text dump reader in libwiretap use WTAP_ENCAP_ASCEND for all packets, even Ethernet and ISDN packets, and have the Ascend text dump dissector handle that, calling the "no FCS" version of the Ethernet dissector and calling the LAPD-with-pseudoheader dissector with a pseudo-header filled in with the direction (and a channel of 0). Have the Catapult DCT 2000 text dump dissector call the LAPD-with-pseudoheader dissector with the pseudo-header supplied by libwireshark. Have the V5 envelope function frame get its ISDN pseudo-header from its data argument, and call the LAPD-with-pseudoheader dissector with that pseudo-header. Have the ISDN dissector treat its data argument as pointing to the ISDN pseudo-header, rather than assuming it's the one in pinfo->pseudo_header->isdn - the latter is the one supplied by libwiretap, but there's no guarantee that an ISDN pseudo-header was supplied by libwiretap, as the lowest-level protocol layer might not have been ISDN. Change-Id: I9f702b879bbc3fb42bcb43c28f797bfc327562c6 Reviewed-on: https://code.wireshark.org/review/37953 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-07-25 09:20:10 +00:00
lapd_phdr_handle = find_dissector_add_dependency("lapd-phdr", proto_v5ef);
v5dl_handle = find_dissector_add_dependency("v5dl", proto_v5ef);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/