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>
This commit is contained in:
Guy Harris 2020-07-25 02:20:10 -07:00
parent ac2883f5e8
commit 75c739e4b7
7 changed files with 238 additions and 131 deletions

View File

@ -54,7 +54,7 @@ static int hf_actrace_cas_connection_id = -1;
static dissector_handle_t lapd_handle;
static dissector_handle_t lapd_phdr_handle;
#define ACTRACE_CAS_SOURCE_DSP 0
#define ACTRACE_CAS_SOURCE_USER 1
@ -634,20 +634,26 @@ static void dissect_actrace_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *
gint32 value, trunk;
tvbuff_t *next_tvb;
int offset = 0;
struct isdn_phdr isdn;
len = tvb_get_ntohs(tvb, 44);
offset += 4;
value = tvb_get_ntohl(tvb, offset+4);
proto_tree_add_int(actrace_tree, hf_actrace_isdn_direction, tvb, offset+4, 4, value);
proto_tree_add_int(actrace_tree, hf_actrace_isdn_direction, tvb, offset, 4, value);
offset += 4;
/* PSTN = Network */
isdn.uton = (value==BLADE_TO_PSTN);
isdn.channel = 0; /* D channel */
offset += 8;
trunk = tvb_get_ntohs(tvb, offset);
proto_tree_add_int(actrace_tree, hf_actrace_isdn_trunk, tvb, offset, 2, trunk);
offset += 4;
offset = 44;
offset += 32;
len = tvb_get_ntohs(tvb, offset);
proto_tree_add_int(actrace_tree, hf_actrace_isdn_length, tvb, offset, 2, len);
/* if it is a q931 packet (we don't want LAPD packets for Voip Graph) add tap info */
if (len > 4) {
/* Initialise packet info for passing to tap */
@ -664,7 +670,7 @@ static void dissect_actrace_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *
/* Dissect lapd payload */
offset += 2 ;
next_tvb = tvb_new_subset_length(tvb, offset, len);
call_dissector(lapd_handle, next_tvb, pinfo, tree);
call_dissector_with_data(lapd_phdr_handle, next_tvb, pinfo, tree, &isdn);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "AC_ISDN");
col_prepend_fstr(pinfo->cinfo, COL_INFO, "Trunk:%d Blade %s PSTN "
@ -788,8 +794,8 @@ void proto_reg_handoff_actrace(void)
{
dissector_handle_t actrace_handle;
/* Get a handle for the lapd dissector. */
lapd_handle = find_dissector_add_dependency("lapd", proto_actrace);
/* Get a handle for the LAPD-with-pseudoheader dissector. */
lapd_phdr_handle = find_dissector_add_dependency("lapd-phdr", proto_actrace);
actrace_handle = create_dissector_handle(dissect_actrace, proto_actrace);
dissector_add_uint_with_preference("udp.port", UDP_PORT_ACTRACE, actrace_handle);

View File

@ -26,13 +26,18 @@ static int hf_user_name = -1;
static gint ett_raw = -1;
static const value_string encaps_vals[] = {
{ASCEND_PFX_WDS_X, "PPP Transmit"},
{ASCEND_PFX_WDS_R, "PPP Receive" },
{ASCEND_PFX_WDD, "Ethernet" },
{0, NULL } };
{ASCEND_PFX_WDS_X, "PPP Transmit" },
{ASCEND_PFX_WDS_R, "PPP Receive" },
{ASCEND_PFX_WDD, "Ethernet triggering dialout"},
{ASCEND_PFX_ISDN_X, "ISDN Transmit" },
{ASCEND_PFX_ISDN_R, "ISDN Receive" },
{ASCEND_PFX_ETHER, "Ethernet" },
{0, NULL }
};
static dissector_handle_t eth_withoutfcs_handle;
static dissector_handle_t ppp_hdlc_handle;
static dissector_handle_t lapd_phdr_handle;
static int
dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
@ -40,6 +45,7 @@ dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
proto_tree *fh_tree;
proto_item *ti, *hidden_item;
union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
struct isdn_phdr isdn;
/* load the top pane info. This should be overwritten by
the next protocol in the stack */
@ -68,20 +74,31 @@ dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
fh_tree = proto_item_add_subtree(ti, ett_raw);
proto_tree_add_uint(fh_tree, hf_link_type, tvb, 0, 0,
pseudo_header->ascend.type);
if (pseudo_header->ascend.type == ASCEND_PFX_WDD) {
switch (pseudo_header->ascend.type) {
case ASCEND_PFX_WDD:
/* Ethernet packet forcing a call */
proto_tree_add_string(fh_tree, hf_called_number, tvb, 0, 0,
pseudo_header->ascend.call_num);
proto_tree_add_uint(fh_tree, hf_chunk, tvb, 0, 0,
pseudo_header->ascend.chunk);
hidden_item = proto_tree_add_uint(fh_tree, hf_session_id, tvb, 0, 0, 0);
proto_item_set_hidden(hidden_item);
} else { /* It's wandsession data */
break;
case ASCEND_PFX_WDS_X:
case ASCEND_PFX_WDS_R:
/* wandsession data */
proto_tree_add_string(fh_tree, hf_user_name, tvb, 0, 0,
pseudo_header->ascend.user);
proto_tree_add_uint(fh_tree, hf_session_id, tvb, 0, 0,
pseudo_header->ascend.sess);
hidden_item = proto_tree_add_uint(fh_tree, hf_chunk, tvb, 0, 0, 0);
proto_item_set_hidden(hidden_item);
break;
default:
break;
}
proto_tree_add_uint(fh_tree, hf_task, tvb, 0, 0, pseudo_header->ascend.task);
}
@ -92,8 +109,19 @@ dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
call_dissector(ppp_hdlc_handle, tvb, pinfo, tree);
break;
case ASCEND_PFX_WDD:
case ASCEND_PFX_ETHER:
call_dissector(eth_withoutfcs_handle, tvb, pinfo, tree);
break;
case ASCEND_PFX_ISDN_X:
isdn.uton = TRUE;
isdn.channel = 0;
call_dissector_with_data(lapd_phdr_handle, tvb, pinfo, tree, &isdn);
break;
case ASCEND_PFX_ISDN_R:
isdn.uton = FALSE;
isdn.channel = 0;
call_dissector_with_data(lapd_phdr_handle, tvb, pinfo, tree, &isdn);
break;
default:
break;
}
@ -144,10 +172,12 @@ proto_reg_handoff_ascend(void)
dissector_handle_t ascend_handle;
/*
* Get handles for the Ethernet and PPP-in-HDLC-like-framing dissectors.
* Get handles for the Ethernet, PPP-in-HDLC-like-framing, and
* LAPD-with-pseudoheader dissectors.
*/
eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_ascend);
ppp_hdlc_handle = find_dissector_add_dependency("ppp_hdlc", proto_ascend);
lapd_phdr_handle = find_dissector_add_dependency("lapd-phdr", proto_ascend);
ascend_handle = create_dissector_handle(dissect_ascend, proto_ascend);
dissector_add_uint("wtap_encap", WTAP_ENCAP_ASCEND, ascend_handle);

View File

@ -2573,8 +2573,14 @@ dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo
protocol_handle = find_dissector("eth_withoutfcs");
break;
case WTAP_ENCAP_ISDN:
protocol_handle = find_dissector("lapd");
pinfo->p2p_dir = pinfo->pseudo_header->isdn.uton;
/*
* XXX - if the file can handle B-channel traffic as well
* as D-channel traffic, have the libwiretap code fill
* in the channel, and call the ISDN dissector rather
* than the LAPD-with-pseudoheader dissector.
*/
protocol_handle = find_dissector("lapd-phdr");
protocol_data = &pinfo->pseudo_header->dct2000.inner_pseudo_header.isdn;
break;
case WTAP_ENCAP_ATM_PDUS_UNTRUNCATED:
protocol_handle = find_dissector("atm_untruncated");

View File

@ -19,10 +19,13 @@ void proto_register_isdn(void);
void proto_reg_handoff_isdn(void);
static int proto_isdn = -1;
static int hf_isdn_direction = -1;
static int hf_isdn_channel = -1;
static gint ett_isdn = -1;
static dissector_handle_t isdn_handle;
/*
* Protocol used on the D channel.
*/
@ -37,11 +40,16 @@ static const enum_val_t dchannel_protocol_options[] = {
static int dchannel_protocol = DCHANNEL_LAPD;
static dissector_handle_t lapd_handle;
static dissector_handle_t lapd_phdr_handle;
static dissector_handle_t dpnss_link_handle;
static dissector_handle_t ppp_hdlc_handle;
static dissector_handle_t v120_handle;
static const true_false_string isdn_direction_tfs = {
"User->Network",
"Network->User"
};
static const value_string channel_vals[] = {
{ 0, "D" },
{ 1, "B1" },
@ -78,8 +86,9 @@ static const value_string channel_vals[] = {
};
static int
dissect_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
dissect_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
struct isdn_phdr *isdn = (struct isdn_phdr *)data;
proto_tree *isdn_tree;
proto_item *ti;
static const guint8 v120_sabme[3] = { 0x08, 0x01, 0x7F };
@ -88,33 +97,38 @@ dissect_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ISDN");
if (pinfo->pseudo_header->isdn.uton) {
if (isdn->uton) {
col_set_str(pinfo->cinfo, COL_RES_DL_DST, "Network");
col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "User");
pinfo->p2p_dir = P2P_DIR_SENT;
} else {
col_set_str(pinfo->cinfo, COL_RES_DL_DST, "User");
col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "Network");
pinfo->p2p_dir = P2P_DIR_RECV;
}
if (tree) {
ti = proto_tree_add_item(tree, proto_isdn, tvb, 0, 0, ENC_NA);
isdn_tree = proto_item_add_subtree(ti, ett_isdn);
proto_tree_add_boolean(isdn_tree, hf_isdn_direction, tvb, 0, 0,
isdn->uton);
proto_tree_add_uint(isdn_tree, hf_isdn_channel, tvb, 0, 0,
pinfo->pseudo_header->isdn.channel);
isdn->channel);
}
/*
* Set up a circuit for this channel, and assign it a dissector.
*/
conv = find_or_create_conversation_by_id(pinfo, ENDPOINT_ISDN,
pinfo->pseudo_header->isdn.channel);
isdn->channel);
if (conversation_get_dissector(conv, 0) == NULL) {
/*
* We don't yet know the type of traffic on the circuit.
*/
switch (pinfo->pseudo_header->isdn.channel) {
switch (isdn->channel) {
case 0:
/*
@ -125,7 +139,7 @@ dissect_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
switch (dchannel_protocol) {
case DCHANNEL_LAPD:
conversation_set_dissector(conv, lapd_handle);
conversation_set_dissector(conv, lapd_phdr_handle);
break;
case DCHANNEL_DPNSS:
@ -179,8 +193,8 @@ dissect_isdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
}
}
if (!try_conversation_dissector_by_id(ENDPOINT_ISDN, pinfo->pseudo_header->isdn.channel,
tvb, pinfo, tree, NULL))
if (!try_conversation_dissector_by_id(ENDPOINT_ISDN, isdn->channel,
tvb, pinfo, tree, data))
call_data_dissector(tvb, pinfo, tree);
return tvb_captured_length(tvb);
@ -190,6 +204,10 @@ void
proto_register_isdn(void)
{
static hf_register_info hf[] = {
{ &hf_isdn_direction,
{ "Direction", "isdn.direction", FT_BOOLEAN, BASE_NONE,
TFS(&isdn_direction_tfs), 0x0, NULL, HFILL }},
{ &hf_isdn_channel,
{ "Channel", "isdn.channel", FT_UINT8, BASE_DEC,
VALS(channel_vals), 0x0, NULL, HFILL }},
@ -209,24 +227,22 @@ proto_register_isdn(void)
"D-channel protocol",
"The protocol running on the D channel",
&dchannel_protocol, dchannel_protocol_options, FALSE);
isdn_handle = register_dissector("isdn", dissect_isdn, proto_isdn);
}
void
proto_reg_handoff_isdn(void)
{
dissector_handle_t isdn_handle;
/*
* Get handles for the LAPD, DPNSS link-layer, PPP, and V.120
* dissectors.
* Get handles for the LAPD-with-pseudoheader, DPNSS link-layer,
* PPP, and V.120 dissectors.
*/
lapd_handle = find_dissector("lapd");
lapd_phdr_handle = find_dissector("lapd-phdr");
dpnss_link_handle = find_dissector("dpnss_link");
ppp_hdlc_handle = find_dissector("ppp_hdlc");
v120_handle = find_dissector("v120");
isdn_handle = create_dissector_handle(dissect_isdn, proto_isdn);
dissector_add_uint("wtap_encap", WTAP_ENCAP_ISDN, isdn_handle);
}

View File

@ -76,6 +76,7 @@ static expert_field ei_lapd_abort = EI_INIT;
static expert_field ei_lapd_checksum_bad = EI_INIT;
static dissector_handle_t lapd_handle;
static dissector_handle_t lapd_phdr_handle;
static dissector_handle_t linux_lapd_handle;
static dissector_handle_t lapd_bitstream_handle;
@ -96,10 +97,13 @@ static gboolean global_lapd_gsm_sapis = FALSE;
#define LAPD_TEI_SHIFT 1
#define LAPD_EA2 0x0001 /* Second Address Extension bit */
#define LAPD_DIR_USER_TO_NETWORK 0
#define LAPD_DIR_NETWORK_TO_USER 1
static const value_string lapd_direction_vals[] = {
{ P2P_DIR_RECV, "Network->User"},
{ P2P_DIR_SENT, "User->Network"},
{ 0, NULL }
{ LAPD_DIR_USER_TO_NETWORK, "User->Network"},
{ LAPD_DIR_NETWORK_TO_USER, "Network->User"},
{ 0, NULL }
};
static const value_string lapd_sapi_vals[] = {
@ -212,8 +216,12 @@ lapd_log_abort(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset
/*
* Flags to pass to dissect_lapd_full.
*/
#define LAPD_HAS_CRC 0x00000001
#define LAPD_HAS_LINUX_SLL 0x00000002
#define LAPD_HAS_CRC 0x00000001
#define LAPD_HAS_DIRECTION 0x00000002
#define LAPD_HAS_LINUX_SLL 0x00000004
#define LAPD_USER_TO_NETWORK 0x00000008
#define LAPD_NETWORK_IS_REMOTE 0x00000010
#define LAPD_USER_IS_REMOTE 0x00000020
static int
dissect_lapd_bitstream(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dissector_data _U_)
@ -403,13 +411,107 @@ dissect_lapd_bitstream(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
static int
dissect_linux_lapd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
dissect_lapd_full(tvb, pinfo, tree, LAPD_HAS_LINUX_SLL);
guint32 flags = LAPD_HAS_LINUX_SLL | LAPD_HAS_DIRECTION;
/* frame is captured via libpcap */
if (pinfo->pseudo_header->lapd.pkttype == 4 /*PACKET_OUTGOING*/) {
if (pinfo->pseudo_header->lapd.we_network) {
/*
* We're the network side, so the user is remote,
* and we're sending it, so this is Network->User.
*/
flags |= LAPD_USER_IS_REMOTE;
} else {
/*
* We're the user side, so the network is remote,
* and we're sending it, so this is User->Network.
*/
flags |= LAPD_NETWORK_IS_REMOTE | LAPD_USER_TO_NETWORK;
}
}
else if (pinfo->pseudo_header->lapd.pkttype == 3 /*PACKET_OTHERHOST*/) {
/*
* We must be a TE, sniffing what other TE transmit, so
* both sides are remote.
*
* XXX - do we know whether it's User->Network or
* Network->User?
*/
flags |= LAPD_USER_IS_REMOTE | LAPD_NETWORK_IS_REMOTE | LAPD_USER_TO_NETWORK;
}
else {
/* The frame is incoming */
if (pinfo->pseudo_header->lapd.we_network) {
/*
* We're the network side, so the user is remote,
* and we received it, so this is User->Network.
*/
flags |= LAPD_USER_IS_REMOTE | LAPD_USER_TO_NETWORK;
} else {
/*
* We're the user side, so the network is remote,
* and we received it, so this is Network->User.
*/
flags |= LAPD_NETWORK_IS_REMOTE;
}
}
dissect_lapd_full(tvb, pinfo, tree, flags);
return tvb_captured_length(tvb);
}
/*
* Called from dissectors, such as the ISDN dissector, that supply a
* struct isdn_pndr giving the packet direction.
*/
static int
dissect_lapd_phdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
struct isdn_phdr *isdn = (struct isdn_phdr *)data;
guint32 flags = LAPD_HAS_DIRECTION;
if (isdn->uton)
flags |= LAPD_USER_TO_NETWORK;
dissect_lapd_full(tvb, pinfo, tree, flags);
return tvb_captured_length(tvb);
}
/*
* Called for link-layer encapsulation.
*/
static int
dissect_lapd_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
guint32 flags = 0;
/*
* If we have direction flags, we have a direction;
* "outbound" packets are presumed to be User->Network and
* "inbound" packets are presumed to be Network->User.
* Other packets, we have no idea.
*/
if (pinfo->rec->presence_flags & WTAP_HAS_PACK_FLAGS) {
switch (PACK_FLAGS_DIRECTION(pinfo->rec->rec_header.packet_header.pack_flags)) {
case PACK_FLAGS_DIRECTION_OUTBOUND:
flags |= LAPD_HAS_DIRECTION | LAPD_USER_TO_NETWORK;
break;
case PACK_FLAGS_DIRECTION_INBOUND:
flags |= LAPD_HAS_DIRECTION;
break;
default:
break;
}
}
dissect_lapd_full(tvb, pinfo, tree, flags);
return tvb_captured_length(tvb);
}
static int
dissect_lapd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
dissect_lapd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
/* XXX - direction is unknown */
dissect_lapd_full(tvb, pinfo, tree, 0);
return tvb_captured_length(tvb);
}
@ -419,7 +521,6 @@ dissect_lapd_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 f
{
proto_tree *lapd_tree, *addr_tree;
proto_item *lapd_ti, *addr_ti;
int direction;
guint16 control;
int lapd_header_len, checksum_offset;
guint16 addr, cr, sapi, tei;
@ -443,56 +544,31 @@ dissect_lapd_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 f
col_append_fstr(pinfo->cinfo, COL_INFO, "TEI:%02u ", tei);
col_set_fence(pinfo->cinfo, COL_INFO);
if (flags & LAPD_HAS_LINUX_SLL) {
/* frame is captured via libpcap */
if (pinfo->pseudo_header->lapd.pkttype == 4 /*PACKET_OUTGOING*/) {
if (pinfo->pseudo_header->lapd.we_network) {
is_response = cr ? FALSE : TRUE;
srcname = "Local Network";
dstname = "Remote User";
direction = P2P_DIR_RECV; /* Network->User */
} else {
srcname = "Local User";
dstname = "Remote Network";
direction = P2P_DIR_SENT; /* User->Network */
}
}
else if (pinfo->pseudo_header->lapd.pkttype == 3 /*PACKET_OTHERHOST*/) {
/* We must be a TE, sniffing what other TE transmit */
if (flags & LAPD_HAS_DIRECTION) {
if (flags & LAPD_USER_TO_NETWORK) {
is_response = cr ? TRUE : FALSE;
srcname = "Remote User";
dstname = "Remote Network";
direction = P2P_DIR_SENT; /* User->Network */
}
else {
/* The frame is incoming */
if (pinfo->pseudo_header->lapd.we_network) {
is_response = cr ? TRUE : FALSE;
srcname = "Remote User";
dstname = "Local Network";
direction = P2P_DIR_SENT; /* User->Network */
if (flags & LAPD_HAS_LINUX_SLL) {
srcname = (flags & LAPD_USER_IS_REMOTE) ?
"Remote User" : "Local User";
dstname = (flags & LAPD_NETWORK_IS_REMOTE) ?
"Remote Network" : "Local Network";
} else {
is_response = cr ? FALSE : TRUE;
srcname = "Remote Network";
dstname = "Local User";
direction = P2P_DIR_RECV; /* Network->User */
srcname = "User";
dstname = "Network";
}
}
} else {
direction = pinfo->p2p_dir;
if (pinfo->p2p_dir == P2P_DIR_RECV) {
} else {
is_response = cr ? FALSE : TRUE;
srcname = "Network";
dstname = "User";
}
else if (pinfo->p2p_dir == P2P_DIR_SENT) {
is_response = cr ? TRUE : FALSE;
srcname = "User";
dstname = "Network";
if (flags & LAPD_HAS_LINUX_SLL) {
srcname = (flags & LAPD_NETWORK_IS_REMOTE) ?
"Remote Network" : "Local Network";
dstname = (flags & LAPD_USER_IS_REMOTE) ?
"Remote User" : "Local User";
} else {
srcname = "Network";
dstname = "User";
}
}
}
col_set_str(pinfo->cinfo, COL_RES_DL_SRC, srcname);
col_set_str(pinfo->cinfo, COL_RES_DL_DST, dstname);
@ -506,9 +582,10 @@ dissect_lapd_full(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 f
/*
* Don't show the direction if we don't know it.
*/
if (direction != P2P_DIR_UNKNOWN) {
if (flags & LAPD_HAS_DIRECTION) {
direction_ti = proto_tree_add_uint(lapd_tree, hf_lapd_direction,
tvb, 0, 0, pinfo->p2p_dir);
tvb, 0, 0,
(flags & LAPD_USER_TO_NETWORK) ? LAPD_DIR_USER_TO_NETWORK : LAPD_DIR_NETWORK_TO_USER);
proto_item_set_generated(direction_ti);
}
@ -577,7 +654,7 @@ proto_register_lapd(void)
static hf_register_info hf[] = {
{ &hf_lapd_direction,
{ "Direction", "lapd.direction", FT_UINT8, BASE_DEC, VALS(lapd_direction_vals), 0x0,
{ "Direction", "lapd.direction", FT_UINT32, BASE_DEC, VALS(lapd_direction_vals), 0x0,
NULL, HFILL }},
{ &hf_lapd_address,
@ -690,7 +767,8 @@ proto_register_lapd(void)
expert_lapd = expert_register_protocol(proto_lapd);
expert_register_field_array(expert_lapd, ei, array_length(ei));
lapd_handle = register_dissector("lapd", dissect_lapd, proto_lapd);
lapd_handle = create_dissector_handle(dissect_lapd, proto_lapd);
lapd_phdr_handle = register_dissector("lapd-phdr", dissect_lapd_phdr, proto_lapd);
linux_lapd_handle = register_dissector("linux-lapd", dissect_linux_lapd, proto_lapd);
lapd_bitstream_handle = register_dissector("lapd-bitstream", dissect_lapd_bitstream, proto_lapd);
@ -724,12 +802,15 @@ proto_reg_handoff_lapd(void)
static gboolean init = FALSE;
static range_t* lapd_rtp_payload_type_range = NULL;
static guint lapd_sctp_ppi;
dissector_handle_t lapd_frame_handle;
if (!init) {
dissector_add_uint("wtap_encap", WTAP_ENCAP_LINUX_LAPD, linux_lapd_handle);
dissector_add_uint("wtap_encap", WTAP_ENCAP_LAPD, lapd_handle);
dissector_add_uint("l2tp.pw_type", L2TPv3_PROTOCOL_LAPD, lapd_handle);
lapd_frame_handle = create_dissector_handle(dissect_lapd_frame, proto_lapd);
dissector_add_uint("wtap_encap", WTAP_ENCAP_LAPD, lapd_frame_handle);
dissector_add_uint("l2tp.pw_type", L2TPv3_PROTOCOL_LAPD, lapd_handle);
dissector_add_for_decode_as("sctp.ppi", lapd_handle);
dissector_add_for_decode_as("sctp.port", lapd_handle);
dissector_add_uint_range_with_preference("udp.port", "", lapd_handle);

View File

@ -36,7 +36,7 @@ static int hf_v5ef_ea2 = -1;
static gint ett_v5ef = -1;
static gint ett_v5ef_address = -1;
static dissector_handle_t v5dl_handle, lapd_handle, v5ef_handle;
static dissector_handle_t v5dl_handle, lapd_phdr_handle, v5ef_handle;
/*
@ -58,8 +58,9 @@ static const value_string v5ef_direction_vals[] = {
#define MAX_V5EF_PACKET_LEN 1024
static int
dissect_v5ef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
dissect_v5ef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
struct isdn_phdr *isdn = (struct isdn_phdr *)data;
proto_tree *v5ef_tree, *addr_tree;
proto_item *v5ef_ti, *addr_ti;
int direction;
@ -78,7 +79,7 @@ dissect_v5ef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
efaddr = (eah << 7) + eal;
v5ef_header_len = 2; /* addr */
direction = pinfo->pseudo_header->isdn.uton;
direction = isdn->uton;
if (direction==0) {
srcname = "LE";
dstname = "AN";
@ -127,7 +128,7 @@ dissect_v5ef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
if (efaddr>8175)
call_dissector(v5dl_handle,next_tvb, pinfo, tree);
else
call_dissector(lapd_handle,next_tvb, pinfo, tree);
call_dissector_with_data(lapd_phdr_handle, next_tvb, pinfo, tree, isdn);
return tvb_captured_length(tvb);
}
@ -180,7 +181,7 @@ proto_reg_handoff_v5ef(void)
{
dissector_add_uint("wtap_encap", WTAP_ENCAP_V5_EF, v5ef_handle);
lapd_handle = find_dissector_add_dependency("lapd", proto_v5ef);
lapd_phdr_handle = find_dissector_add_dependency("lapd-phdr", proto_v5ef);
v5dl_handle = find_dissector_add_dependency("v5dl", proto_v5ef);
}

View File

@ -253,20 +253,7 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info)
}
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ASCEND;
switch(rec.rec_header.packet_header.pseudo_header.ascend.type) {
case ASCEND_PFX_ISDN_X:
case ASCEND_PFX_ISDN_R:
wth->file_encap = WTAP_ENCAP_ISDN;
break;
case ASCEND_PFX_ETHER:
wth->file_encap = WTAP_ENCAP_ETHERNET;
break;
default:
wth->file_encap = WTAP_ENCAP_ASCEND;
}
wth->file_encap = WTAP_ENCAP_ASCEND;
wth->snapshot_length = ASCEND_MAX_PKT_LEN;
wth->subtype_read = ascend_read;
@ -364,26 +351,6 @@ parse_ascend(ascend_t *ascend, FILE_T fh, wtap_rec *rec, Buffer *buf,
rec->rec_header.packet_header.caplen = parser_state.caplen;
rec->rec_header.packet_header.len = parser_state.wirelen;
/*
* For these types, the encapsulation we use is not WTAP_ENCAP_ASCEND,
* so set the pseudo-headers appropriately for the type (WTAP_ENCAP_ISDN
* or WTAP_ENCAP_ETHERNET).
*/
switch(rec->rec_header.packet_header.pseudo_header.ascend.type) {
case ASCEND_PFX_ISDN_X:
rec->rec_header.packet_header.pseudo_header.isdn.uton = TRUE;
rec->rec_header.packet_header.pseudo_header.isdn.channel = 0;
break;
case ASCEND_PFX_ISDN_R:
rec->rec_header.packet_header.pseudo_header.isdn.uton = FALSE;
rec->rec_header.packet_header.pseudo_header.isdn.channel = 0;
break;
case ASCEND_PFX_ETHER:
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
break;
}
return TRUE;
}