From Rolf Fiedler:

Add DPNSS link layer dissector, support EyeSDN Trace files with DPNSS.
(Removed a couple of c++ style comments).
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3224

svn path=/trunk/; revision=27312
This commit is contained in:
Anders Broman 2009-01-27 21:13:26 +00:00
parent bae6a0d02f
commit a8c964cd44
5 changed files with 254 additions and 1 deletions

View File

@ -381,6 +381,7 @@ DISSECTOR_SRC = \
packet-dns.c \
packet-dplay.c \
packet-dpnss.c \
packet-dpnss-link.c \
packet-drda.c \
packet-dsi.c \
packet-dtls.c \

View File

@ -0,0 +1,227 @@
/* packet-dpnss-link.c
* Routines for DPNNS/DASS2 link layer dissection
* Copyright 2009, Rolf Fiedler <rolf.fiedler[at]innoventif[dot]de>
*
* $Id$
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* References:
* BTNR188
* ND1301:2001/03 http://www.nicc.org.uk/nicc-public/Public/interconnectstandards/dpnss/nd1301_2004_11.pdf
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include <epan/proto.h>
static dissector_handle_t dpnss_handle; /* DPNSS UI frame dissector */
#define LINK_HEADER_SIZE 3
static int proto_dpnss_link = -1;
static int hf_dpnss_link_address_framegroup = -1;
static int hf_dpnss_link_address_crbit = -1;
static int hf_dpnss_link_address_extension = -1;
static int hf_dpnss_link_address2_reserved = -1;
static int hf_dpnss_link_address2_dlcId = -1;
static int hf_dpnss_link_address2_dlcIdNr = -1;
static int hf_dpnss_link_address2_extension = -1;
static int hf_dpnss_link_control_frameType = -1;
static const value_string dpnss_link_framegroup_vals[] = {
{ 0x11, "Information Frame" },
{ 0x03, "Control Frame" },
{ 0, NULL }
};
static const value_string dpnss_link_crbit_vals[] = {
{ 0x0, "Command/Response Bit Cleared" },
{ 0x1, "Command/Response Bit Set" },
{ 0, NULL }
};
static const value_string dpnss_link_extend_vals[] = {
{ 0x0, "Extended to next octet" },
{ 0x1, "Final octet" },
{ 0, NULL }
};
static const value_string dpnss_link_reserved_vals[] = {
{ 0x0, "Reserved" },
{ 0x1, "Reserved" },
{ 0, NULL }
};
static const value_string dpnss_link_dlcId_vals[] = {
{ 0x0, "Real Channel" },
{ 0x1, "Virtual Channel" },
{ 0, NULL }
};
#define FRAME_TYPE_UI_EVEN 0x03
#define FRAME_TYPE_UI_ODD 0x13
#define FRAME_TYPE_SABMR 0xef
#define FRAME_TYPE_UA 0x63
static const value_string dpnss_link_frameType_vals[] = {
{ FRAME_TYPE_UI_EVEN, "UI (even)" },
{ FRAME_TYPE_UI_ODD, "UI (odd)" },
{ FRAME_TYPE_SABMR, "SABMR" },
{ FRAME_TYPE_UA, "UA" },
{ 0, NULL }
};
static int ett_dpnss_link = -1;
/* Code to actually dissect the packets */
static void
dissect_dpnss_link(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *item;
proto_tree *dpnss_link_tree;
guint8 octet;
tvbuff_t *protocol_data_tvb;
guint16 protocol_data_length;
int uton=0;
uton=pinfo->pseudo_header->l1event.uton;
/* Make entries in src and dst column */
if (check_col(pinfo->cinfo, COL_DEF_SRC))
col_set_str(pinfo->cinfo, COL_DEF_SRC, uton?"TE":"NT");
if (check_col(pinfo->cinfo, COL_DEF_DST))
col_set_str(pinfo->cinfo, COL_DEF_DST, uton?"NT":"TE");
item = proto_tree_add_item(tree, proto_dpnss_link, tvb, 0, -1, FALSE);
dpnss_link_tree = proto_item_add_subtree(item, ett_dpnss_link);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address_framegroup,
tvb, 0, 1, FALSE);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address_crbit,
tvb, 0, 1, FALSE);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address_extension,
tvb, 0, 1, FALSE);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address2_reserved,
tvb, 1, 1, FALSE);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address2_dlcId,
tvb, 1, 1, FALSE);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address2_dlcIdNr,
tvb, 1, 1, FALSE);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address2_extension,
tvb, 1, 1, FALSE);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_control_frameType,
tvb, 2, 1, FALSE);
octet = tvb_get_guint8(tvb, 2);
switch (octet){
case FRAME_TYPE_UI_EVEN:
case FRAME_TYPE_UI_ODD:
protocol_data_length=tvb_length(tvb)-LINK_HEADER_SIZE;
protocol_data_tvb=tvb_new_subset(tvb, LINK_HEADER_SIZE,
protocol_data_length,
protocol_data_length);
if(dpnss_handle && protocol_data_length>0) {
call_dissector(dpnss_handle, protocol_data_tvb, pinfo, tree);
}
break;
default:
break;
}
}
/* Register the protocol with Wireshark */
/* If this dissector uses sub-dissector registration add a registration routine.
This format is required because a script is used to find these routines and
create the code that calls these routines.
*/
void
proto_reg_handoff_dpnss_link(void)
{
dissector_handle_t dpnss_link_handle;
dpnss_link_handle=create_dissector_handle(dissect_dpnss_link,
proto_dpnss_link);
dissector_add("wtap_encap", WTAP_ENCAP_DPNSS, dpnss_link_handle);
}
void
proto_register_dpnss_link(void)
{
static hf_register_info hf[] = {
{ &hf_dpnss_link_address_framegroup,
{ "Frame Group", "dpnss_link.framegroup",
FT_UINT8, BASE_DEC, VALS(dpnss_link_framegroup_vals), 0xfc,
"Frame Group", HFILL }
},
{ &hf_dpnss_link_address_crbit,
{ "C/R Bit", "dpnss_link.crbit",
FT_UINT8, BASE_DEC, VALS(dpnss_link_crbit_vals), 0x02,
"C/R Bit", HFILL }
},
{ &hf_dpnss_link_address_extension,
{ "Extension", "dpnss_link.extension",
FT_UINT8, BASE_DEC, VALS(dpnss_link_extend_vals), 0x01,
"Extension", HFILL }
},
{ &hf_dpnss_link_address2_reserved,
{ "Reserved", "dpnss_link.reserved",
FT_UINT8, BASE_DEC, VALS(dpnss_link_reserved_vals), 0x80,
"Reserved", HFILL }
},
{ &hf_dpnss_link_address2_dlcId,
{ "DLC ID", "dpnss_link.dlcId",
FT_UINT8, BASE_DEC, VALS(dpnss_link_dlcId_vals), 0x40,
"DLC ID", HFILL }
},
{ &hf_dpnss_link_address2_dlcIdNr,
{ "DLC ID Number", "dpnss_link.dlcIdNr",
FT_UINT8, BASE_DEC, NULL, 0x3e,
"DLC ID Number", HFILL }
},
{ &hf_dpnss_link_address2_extension,
{ "Extension", "dpnss_link.extension2",
FT_UINT8, BASE_DEC, VALS(dpnss_link_extend_vals), 0x01,
"Extension", HFILL }
},
{ &hf_dpnss_link_control_frameType,
{ "Frame Type", "dpnss_link.frameType",
FT_UINT8, BASE_DEC, VALS(dpnss_link_frameType_vals), 0xff,
"Frame Type", HFILL }
}
};
static gint *ett[] = { &ett_dpnss_link };
/* Register the protocol name and description */
proto_dpnss_link = proto_register_protocol("Digital Private Signalling System No 1 Link Layer","DPNSS Link", "dpnss_link");
register_dissector("dpnss_link", dissect_dpnss_link, proto_dpnss_link);
dpnss_handle = find_dissector("dpnss");
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_dpnss_link, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}

View File

@ -334,6 +334,27 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh,
wth->phdr.pkt_encap = WTAP_ENCAP_MTP2;
}
break;
case EYESDN_ENCAP_DPNSS: /* DPNSS */
pseudo_header->isdn.uton = direction & 1;
pseudo_header->isdn.channel = channel;
if(wth) {
wth->phdr.pkt_encap = WTAP_ENCAP_DPNSS;
}
break;
case EYESDN_ENCAP_DASS2: /* DASS2 frames */
pseudo_header->isdn.uton = direction & 1;
pseudo_header->isdn.channel = channel;
if(wth) {
wth->phdr.pkt_encap = WTAP_ENCAP_DPNSS;
}
break;
case EYESDN_ENCAP_BACNET: /* BACNET async over HDLC frames */
/* pseudo_header->isdn.uton = direction & 1; */
/* pseudo_header->isdn.channel = channel; */
if(wth) {
wth->phdr.pkt_encap = WTAP_ENCAP_BACNET_MS_TP;
}
break;
}
if(pkt_len > EYESDN_MAX_PACKET_LEN) {

View File

@ -31,7 +31,10 @@ enum EyeSDN_TYPES {
EYESDN_ENCAP_MSG,
EYESDN_ENCAP_LAPB,
EYESDN_ENCAP_ATM,
EYESDN_ENCAP_MTP2
EYESDN_ENCAP_MTP2,
EYESDN_ENCAP_DPNSS,
EYESDN_ENCAP_DASS2,
EYESDN_ENCAP_BACNET
};
#endif

View File

@ -207,6 +207,7 @@ extern "C" {
#define WTAP_ENCAP_TNEF 114
#define WTAP_ENCAP_USB_LINUX_MMAPPED 115
#define WTAP_ENCAP_GSM_UM 116
#define WTAP_ENCAP_DPNSS 117
#define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()