diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2004-10-05 11:20:43 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2004-10-05 11:20:43 +0000 |
commit | eaf5cc19c39925668cd0b5f0d3a7562c627188a0 (patch) | |
tree | 1b729723518b14f04d3326771a78aa186e0844b5 | |
parent | fd08163595ab32de3b2eabe1d3ee4dc78de8eb7b (diff) | |
download | wireshark-eaf5cc19c39925668cd0b5f0d3a7562c627188a0.tar.gz wireshark-eaf5cc19c39925668cd0b5f0d3a7562c627188a0.tar.bz2 wireshark-eaf5cc19c39925668cd0b5f0d3a7562c627188a0.zip |
Add example template for how to add h248 extension packages to the megaco dissector
svn path=/trunk/; revision=12206
-rw-r--r-- | asn1/h248-package-bcp/BCP.asn | 16 | ||||
-rw-r--r-- | asn1/h248-package-bcp/h248_package_bcp.cnf | 21 | ||||
-rw-r--r-- | asn1/h248-package-bcp/packet-h248_package_bcp-template.c | 88 | ||||
-rw-r--r-- | asn1/h248-package-bcp/packet-h248_package_bcp-template.h | 32 | ||||
-rw-r--r-- | asn1/h248/packet-h248-template.c | 38 | ||||
-rw-r--r-- | epan/dissectors/Makefile.common | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-h248.c | 38 | ||||
-rw-r--r-- | epan/dissectors/packet-h248_package_bcp.c | 142 | ||||
-rw-r--r-- | epan/dissectors/packet-h248_package_bcp.h | 39 |
9 files changed, 412 insertions, 4 deletions
diff --git a/asn1/h248-package-bcp/BCP.asn b/asn1/h248-package-bcp/BCP.asn new file mode 100644 index 0000000000..e48996f597 --- /dev/null +++ b/asn1/h248-package-bcp/BCP.asn @@ -0,0 +1,16 @@ +-- This ASN definition is implemented from hand from itu-t documents + +MEDIA-GATEWAY-CONTROL-BCP {itu-t(0) recommendation(0) h(8) h248(248) +modules(0) media-gateway-control(0) version2(2)} +DEFINITIONS AUTOMATIC TAGS ::= +BEGIN + +BNCChar ::= ENUMERATED { + aal1(1), + aal2(2), + aal1struct(3), + ipRtp(4), + tdm(5) +} + +END diff --git a/asn1/h248-package-bcp/h248_package_bcp.cnf b/asn1/h248-package-bcp/h248_package_bcp.cnf new file mode 100644 index 0000000000..3696c8e69d --- /dev/null +++ b/asn1/h248-package-bcp/h248_package_bcp.cnf @@ -0,0 +1,21 @@ +# h248-package-bcp.cnf +# H.248-package-bcp conformation file + +# $Id: h248_package_bcp.cnf 12205 2004-10-05 09:50:19Z sahlberg $ + +#.MODULE_IMPORT + +#.EXPORTS + +#.PDU +BNCChar + +#.NO_EMIT + +#.TYPE_RENAME + +#.FIELD_RENAME + +#.END + + diff --git a/asn1/h248-package-bcp/packet-h248_package_bcp-template.c b/asn1/h248-package-bcp/packet-h248_package_bcp-template.c new file mode 100644 index 0000000000..139bf452a1 --- /dev/null +++ b/asn1/h248-package-bcp/packet-h248_package_bcp-template.c @@ -0,0 +1,88 @@ +/* packet-h248_package_bcp.c + * Routines for H.248/MEGACO-Package_bcp packet dissection + * Ronnie Sahlberg 2004 + * + * $Id: packet-h248_package_bcp-template.c 12205 2004-10-05 09:50:19Z sahlberg $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> +#include <epan/packet.h> +#include <epan/conversation.h> + +#include <stdio.h> +#include <string.h> + +#include "packet-ber.h" +#include "packet-h248_package_bcp.h" + +#define PNAME "H.248 MEGACO/BCP" +#define PSNAME "H248BCP" +#define PFNAME "h248bcp" + +/* Initialize the protocol and registered fields */ +static int proto_h248_package_bcp = -1; +#include "packet-h248_package_bcp-hf.c" + +/* Initialize the subtree pointers */ +static gint ett_h248_package_bcp = -1; +/*#include "packet-h248_package_bcp-ett.c"*/ + + +#include "packet-h248_package_bcp-fn.c" + + +/*--- proto_register_h248_package_bcp ----------------------------------------------*/ +void proto_register_h248_package_bcp(void) { + + /* List of fields */ + static hf_register_info hf[] = { +#include "packet-h248_package_bcp-hfarr.c" + }; + + /* List of subtrees */ + static gint *ett[] = { + &ett_h248_package_bcp, + /*#include "packet-h248_package_bcp-ettarr.c"*/ + }; + + /* Register protocol */ + proto_h248_package_bcp = proto_register_protocol(PNAME, PSNAME, PFNAME); + + /* Register fields and subtrees */ + proto_register_field_array(proto_h248_package_bcp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + +} + + +/*--- proto_reg_handoff_h248_package_bcp -------------------------------------------*/ +void proto_reg_handoff_h248_package_bcp(void) { + dissector_handle_t h248_package_bcp_handle; + + + h248_package_bcp_handle = create_dissector_handle(dissect_BNCChar_PDU, proto_h248_package_bcp); + dissector_add("h248.package.bin", 0x001e0001, h248_package_bcp_handle); +} + diff --git a/asn1/h248-package-bcp/packet-h248_package_bcp-template.h b/asn1/h248-package-bcp/packet-h248_package_bcp-template.h new file mode 100644 index 0000000000..2457a38699 --- /dev/null +++ b/asn1/h248-package-bcp/packet-h248_package_bcp-template.h @@ -0,0 +1,32 @@ +/* packet-h248_package_bcp.h + * Routines for H.248/MEGACO-Package-bcp packet dissection + * Ronnie Sahlberg 2004 + * + * $Id: packet-h248_package_bcp-template.h 12203 2004-10-05 09:18:55Z guy $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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. + */ + +#ifndef PACKET_H248_PACKAGE_BCP_H +#define PACKET_H248_PACKAGE_BCP_H + +/*#include "packet-h248_package_bcp-exp.h"*/ + +#endif /* PACKET_H248_PACKAGE_BCP_H */ + diff --git a/asn1/h248/packet-h248-template.c b/asn1/h248/packet-h248-template.c index 1dc09b73a2..cd2db73564 100644 --- a/asn1/h248/packet-h248-template.c +++ b/asn1/h248/packet-h248-template.c @@ -58,6 +58,9 @@ static gint ett_packagename = -1; #include "packet-h248-ett.c" +static dissector_table_t h248_package_bin_dissector_table=NULL; + + static const value_string package_name_vals[] = { { 0x0000, "Media stream properties H.248.1 Annex C" }, { 0x0001, "g H.248.1 Annex E" }, @@ -215,6 +218,8 @@ static const value_string package_name_vals[] = { {0, NULL} }; +static guint32 packageandid; + static int dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hf_index) { tvbuff_t *new_tvb; @@ -229,6 +234,7 @@ dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_i /* this field is always 4 bytes so just read it into two integers */ name_major=tvb_get_ntohs(new_tvb, 0); name_minor=tvb_get_ntohs(new_tvb, 2); + packageandid=(name_major<<16)|name_minor; /* do the prettification */ proto_item_append_text(ber_last_created_item, " %s (%04x)", val_to_str(name_major, package_name_vals, "Unknown Package"), name_major); @@ -243,9 +249,34 @@ dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_i static int dissect_h248_PropertyID(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hf_index) { - offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); + guint8 class; + gboolean pc, ind; + guint32 tag; + guint32 len; + int old_offset, end_offset; + tvbuff_t *next_tvb; - return offset; + old_offset=offset; + offset=dissect_ber_identifier(pinfo, tree, tvb, offset, &class, &pc, &tag); + offset=dissect_ber_length(pinfo, tree, tvb, offset, &len, &ind); + end_offset=offset+len; + + if( (class!=BER_CLASS_UNI) + ||(tag!=BER_UNI_TAG_OCTETSTRING) ){ + proto_tree_add_text(tree, tvb, offset-2, 2, "H.248 BER Error: OctetString expected but Class:%d PC:%d Tag:%d was unexpected", class, pc, tag); + return end_offset; + } + + + next_tvb = tvb_new_subset(tvb, offset, len, len); + + if(!dissector_try_port(h248_package_bin_dissector_table, packageandid, next_tvb, pinfo, tree)){ + proto_tree_add_text(tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "H.248: Dissector for Package/ID:0x%08x not implemented (yet).", packageandid); + + offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, old_offset, hf_index, NULL); + } + + return end_offset; } @@ -337,6 +368,9 @@ void proto_register_h248(void) { proto_register_field_array(proto_h248, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + /* register a dissector table packages can attach to */ + h248_package_bin_dissector_table = register_dissector_table("h248.package.bin", "Binary H.248 Package Dissectors", FT_UINT32, BASE_HEX); + } diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index 850c41248a..7d8687e415 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -255,6 +255,7 @@ DISSECTOR_SRC = \ packet-h235.c \ packet-h245.c \ packet-h248.c \ + packet-h248_package_bcp.c \ packet-h261.c \ packet-h263.c \ packet-h450.c \ @@ -617,6 +618,7 @@ DISSECTOR_INCLUDES = \ packet-h235.h \ packet-h245.h \ packet-h248.h \ + packet-h248_package_bcp.h \ packet-hclnfsd.h \ packet-hpext.h \ packet-http.h \ diff --git a/epan/dissectors/packet-h248.c b/epan/dissectors/packet-h248.c index 101fcb7b50..47a21bc3d4 100644 --- a/epan/dissectors/packet-h248.c +++ b/epan/dissectors/packet-h248.c @@ -469,6 +469,9 @@ static gint ett_h248_Value = -1; +static dissector_table_t h248_package_bin_dissector_table=NULL; + + static const value_string package_name_vals[] = { { 0x0000, "Media stream properties H.248.1 Annex C" }, { 0x0001, "g H.248.1 Annex E" }, @@ -626,6 +629,8 @@ static const value_string package_name_vals[] = { {0, NULL} }; +static guint32 packageandid; + static int dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hf_index) { tvbuff_t *new_tvb; @@ -640,6 +645,7 @@ dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_i /* this field is always 4 bytes so just read it into two integers */ name_major=tvb_get_ntohs(new_tvb, 0); name_minor=tvb_get_ntohs(new_tvb, 2); + packageandid=(name_major<<16)|name_minor; /* do the prettification */ proto_item_append_text(ber_last_created_item, " %s (%04x)", val_to_str(name_major, package_name_vals, "Unknown Package"), name_major); @@ -654,9 +660,34 @@ dissect_h248_PkgdName(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_i static int dissect_h248_PropertyID(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hf_index) { - offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL); + guint8 class; + gboolean pc, ind; + guint32 tag; + guint32 len; + int old_offset, end_offset; + tvbuff_t *next_tvb; - return offset; + old_offset=offset; + offset=dissect_ber_identifier(pinfo, tree, tvb, offset, &class, &pc, &tag); + offset=dissect_ber_length(pinfo, tree, tvb, offset, &len, &ind); + end_offset=offset+len; + + if( (class!=BER_CLASS_UNI) + ||(tag!=BER_UNI_TAG_OCTETSTRING) ){ + proto_tree_add_text(tree, tvb, offset-2, 2, "H.248 BER Error: OctetString expected but Class:%d PC:%d Tag:%d was unexpected", class, pc, tag); + return end_offset; + } + + + next_tvb = tvb_new_subset(tvb, offset, len, len); + + if(!dissector_try_port(h248_package_bin_dissector_table, packageandid, next_tvb, pinfo, tree)){ + proto_tree_add_text(tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "H.248: Dissector for Package/ID:0x%08x not implemented (yet).", packageandid); + + offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, old_offset, hf_index, NULL); + } + + return end_offset; } @@ -5195,6 +5226,9 @@ void proto_register_h248(void) { proto_register_field_array(proto_h248, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + /* register a dissector table packages can attach to */ + h248_package_bin_dissector_table = register_dissector_table("h248.package.bin", "Binary H.248 Package Dissectors", FT_UINT32, BASE_HEX); + } diff --git a/epan/dissectors/packet-h248_package_bcp.c b/epan/dissectors/packet-h248_package_bcp.c new file mode 100644 index 0000000000..cf632d778b --- /dev/null +++ b/epan/dissectors/packet-h248_package_bcp.c @@ -0,0 +1,142 @@ +/* Do not modify this file. */ +/* It is created automatically by the ASN.1 to Ethereal dissector compiler */ +/* ./packet-h248_package_bcp.c */ +/* ../../tools/asn2eth.py -X -b -e -p h248_package_bcp -c h248_package_bcp.cnf -s packet-h248_package_bcp-template BCP.asn */ + +/* Input file: packet-h248_package_bcp-template.c */ + +/* packet-h248_package_bcp.c + * Routines for H.248/MEGACO-Package_bcp packet dissection + * Ronnie Sahlberg 2004 + * + * $Id: packet-h248_package_bcp-template.c 12205 2004-10-05 09:50:19Z sahlberg $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> +#include <epan/packet.h> +#include <epan/conversation.h> + +#include <stdio.h> +#include <string.h> + +#include "packet-ber.h" +#include "packet-h248_package_bcp.h" + +#define PNAME "H.248 MEGACO/BCP" +#define PSNAME "H248BCP" +#define PFNAME "h248bcp" + +/* Initialize the protocol and registered fields */ +static int proto_h248_package_bcp = -1; + +/*--- Included file: packet-h248_package_bcp-hf.c ---*/ + +static int hf_h248_package_bcp_BNCChar_PDU = -1; /* BNCChar */ + +/*--- End of included file: packet-h248_package_bcp-hf.c ---*/ + + +/* Initialize the subtree pointers */ +static gint ett_h248_package_bcp = -1; +/*#include "packet-h248_package_bcp-ett.c"*/ + + + +/*--- Included file: packet-h248_package_bcp-fn.c ---*/ + +/*--- Fields for imported types ---*/ + + + +static const value_string BNCChar_vals[] = { + { 1, "aal1" }, + { 2, "aal2" }, + { 3, "aal1struct" }, + { 4, "ipRtp" }, + { 5, "tdm" }, + { 0, NULL } +}; + + +static int +dissect_h248_package_bcp_BNCChar(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { + offset = dissect_ber_integer(pinfo, tree, tvb, offset, hf_index, NULL); + + return offset; +} + +/*--- PDUs ---*/ + +static void dissect_BNCChar_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { + dissect_h248_package_bcp_BNCChar(FALSE, tvb, 0, pinfo, tree, hf_h248_package_bcp_BNCChar_PDU); +} + + +/*--- End of included file: packet-h248_package_bcp-fn.c ---*/ + + + +/*--- proto_register_h248_package_bcp ----------------------------------------------*/ +void proto_register_h248_package_bcp(void) { + + /* List of fields */ + static hf_register_info hf[] = { + +/*--- Included file: packet-h248_package_bcp-hfarr.c ---*/ + + { &hf_h248_package_bcp_BNCChar_PDU, + { "BNCChar", "h248_package_bcp.BNCChar", + FT_UINT32, BASE_DEC, VALS(BNCChar_vals), 0, + "BNCChar", HFILL }}, + +/*--- End of included file: packet-h248_package_bcp-hfarr.c ---*/ + + }; + + /* List of subtrees */ + static gint *ett[] = { + &ett_h248_package_bcp, + /*#include "packet-h248_package_bcp-ettarr.c"*/ + }; + + /* Register protocol */ + proto_h248_package_bcp = proto_register_protocol(PNAME, PSNAME, PFNAME); + + /* Register fields and subtrees */ + proto_register_field_array(proto_h248_package_bcp, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + +} + + +/*--- proto_reg_handoff_h248_package_bcp -------------------------------------------*/ +void proto_reg_handoff_h248_package_bcp(void) { + dissector_handle_t h248_package_bcp_handle; + + + h248_package_bcp_handle = create_dissector_handle(dissect_BNCChar_PDU, proto_h248_package_bcp); + dissector_add("h248.package.bin", 0x001e0001, h248_package_bcp_handle); +} + diff --git a/epan/dissectors/packet-h248_package_bcp.h b/epan/dissectors/packet-h248_package_bcp.h new file mode 100644 index 0000000000..4f1e1e009b --- /dev/null +++ b/epan/dissectors/packet-h248_package_bcp.h @@ -0,0 +1,39 @@ +/* Do not modify this file. */ +/* It is created automatically by the ASN.1 to Ethereal dissector compiler */ +/* ./packet-h248_package_bcp.h */ +/* ../../tools/asn2eth.py -X -b -e -p h248_package_bcp -c h248_package_bcp.cnf -s packet-h248_package_bcp-template BCP.asn */ + +/* Input file: packet-h248_package_bcp-template.h */ + +/* packet-h248_package_bcp.h + * Routines for H.248/MEGACO-Package-bcp packet dissection + * Ronnie Sahlberg 2004 + * + * $Id: packet-h248_package_bcp-template.h 12203 2004-10-05 09:18:55Z guy $ + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * 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. + */ + +#ifndef PACKET_H248_PACKAGE_BCP_H +#define PACKET_H248_PACKAGE_BCP_H + +/*#include "packet-h248_package_bcp-exp.h"*/ + +#endif /* PACKET_H248_PACKAGE_BCP_H */ + |