diff options
author | kukosa <kukosa@f5534014-38df-0310-8fa8-9805f1628bb7> | 2007-07-18 13:15:36 +0000 |
---|---|---|
committer | kukosa <kukosa@f5534014-38df-0310-8fa8-9805f1628bb7> | 2007-07-18 13:15:36 +0000 |
commit | c233fceab126a849d7bdffb18968cc84ffb60eb6 (patch) | |
tree | 5b808ce5d79a77ef3d582b7f65bb5cfe1566581c /asn1/q932 | |
parent | 6bb342b006499c617edebf62842ae8caad00ae6b (diff) |
rose_ctx_t structure usage in Q.932 dissector
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@22349 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'asn1/q932')
-rw-r--r-- | asn1/q932/Makefile | 4 | ||||
-rw-r--r-- | asn1/q932/Makefile.nmake | 9 | ||||
-rw-r--r-- | asn1/q932/packet-q932-ros-template.c | 31 | ||||
-rw-r--r-- | asn1/q932/packet-q932-ros-template.h | 34 | ||||
-rw-r--r-- | asn1/q932/packet-q932-template.c | 10 | ||||
-rw-r--r-- | asn1/q932/q932-ros.cnf | 87 |
6 files changed, 72 insertions, 103 deletions
diff --git a/asn1/q932/Makefile b/asn1/q932/Makefile index 135050ac3a..7f5b2a8d71 100644 --- a/asn1/q932/Makefile +++ b/asn1/q932/Makefile @@ -2,7 +2,7 @@ PROTOCOL_NAME=q932 Q932_FILES=packet-$(PROTOCOL_NAME).c packet-$(PROTOCOL_NAME).h -Q932_ROS_FILES=packet-$(PROTOCOL_NAME)-ros.c packet-$(PROTOCOL_NAME)-ros.h +Q932_ROS_FILES=packet-$(PROTOCOL_NAME)-ros.c DISSECTOR_FILES=$(Q932_FILES) $(Q932_ROS_FILES) Q932_ASN=Addressing-Data-Elements.asn Network-Facility-Extension.asn Network-Protocol-Profile-component.asn Interpretation-component.asn Q932_ROS_ASN=../ros/Remote-Operations-Information-Objects.asn Facility-Information-Element-Components.asn @@ -14,7 +14,7 @@ generate_dissector: $(DISSECTOR_FILES) $(Q932_FILES): ../../tools/asn2wrs.py $(Q932_ASN) packet-$(PROTOCOL_NAME)-template.c packet-$(PROTOCOL_NAME)-template.h $(PROTOCOL_NAME).cnf python ../../tools/asn2wrs.py -b -T -X -e -p $(PROTOCOL_NAME) -c $(PROTOCOL_NAME).cnf -s packet-$(PROTOCOL_NAME)-template $(Q932_ASN) -$(Q932_ROS_FILES): ../../tools/asn2wrs.py $(Q932_ROS_ASN) packet-$(PROTOCOL_NAME)-ros-template.c packet-$(PROTOCOL_NAME)-ros-template.h $(PROTOCOL_NAME)-ros.cnf +$(Q932_ROS_FILES): ../../tools/asn2wrs.py $(Q932_ROS_ASN) packet-$(PROTOCOL_NAME)-ros-template.c $(PROTOCOL_NAME)-ros.cnf python ../../tools/asn2wrs.py -b -T -X -e -p $(PROTOCOL_NAME).ros -c $(PROTOCOL_NAME)-ros.cnf -o $(PROTOCOL_NAME)-ros -s packet-$(PROTOCOL_NAME)-ros-template $(Q932_ROS_ASN) clean: diff --git a/asn1/q932/Makefile.nmake b/asn1/q932/Makefile.nmake index 02868121fb..68229ac96c 100644 --- a/asn1/q932/Makefile.nmake +++ b/asn1/q932/Makefile.nmake @@ -8,7 +8,7 @@ UNIX2DOS=$(PERL) ../../tools/unix2dos.pl PROTOCOL_NAME=q932 Q932_FILES=packet-$(PROTOCOL_NAME).c packet-$(PROTOCOL_NAME).h -Q932_ROS_FILES=packet-$(PROTOCOL_NAME)-ros.c packet-$(PROTOCOL_NAME)-ros.h +Q932_ROS_FILES=packet-$(PROTOCOL_NAME)-ros.c DISSECTOR_FILES=$(Q932_FILES) $(Q932_ROS_FILES) Q932_ASN=Addressing-Data-Elements.asn Network-Facility-Extension.asn Network-Protocol-Profile-component.asn Interpretation-component.asn Q932_ROS_ASN=../ros/Remote-Operations-Information-Objects.asn Facility-Information-Element-Components.asn @@ -25,7 +25,7 @@ $(Q932_FILES): ../../tools/asn2wrs.py $(Q932_ASN) packet-$(PROTOCOL_NAME)-templa @exit 1 !ENDIF -$(Q932_ROS_FILES): ../../tools/asn2wrs.py $(Q932_ROS_ASN) packet-$(PROTOCOL_NAME)-ros-template.c packet-$(PROTOCOL_NAME)-ros-template.h $(PROTOCOL_NAME)-ros.cnf +$(Q932_ROS_FILES): ../../tools/asn2wrs.py $(Q932_ROS_ASN) packet-$(PROTOCOL_NAME)-ros-template.c $(PROTOCOL_NAME)-ros.cnf !IFDEF PYTHON $(PYTHON) "../../tools/asn2wrs.py" -b -T -X -p $(PROTOCOL_NAME).ros -c $(PROTOCOL_NAME)-ros.cnf -o $(PROTOCOL_NAME)-ros -s packet-$(PROTOCOL_NAME)-ros-template $(Q932_ROS_ASN) !ELSE @@ -49,15 +49,12 @@ fix_eol: generate_dissector move packet-$(PROTOCOL_NAME).c packet-$(PROTOCOL_NAME).c.tmp move packet-$(PROTOCOL_NAME).h packet-$(PROTOCOL_NAME).h.tmp move packet-$(PROTOCOL_NAME)-ros.c packet-$(PROTOCOL_NAME)-ros.c.tmp - move packet-$(PROTOCOL_NAME)-ros.h packet-$(PROTOCOL_NAME)-ros.h.tmp $(UNIX2DOS) < packet-$(PROTOCOL_NAME).c.tmp > packet-$(PROTOCOL_NAME).c $(UNIX2DOS) < packet-$(PROTOCOL_NAME).h.tmp > packet-$(PROTOCOL_NAME).h $(UNIX2DOS) < packet-$(PROTOCOL_NAME)-ros.c.tmp > packet-$(PROTOCOL_NAME)-ros.c - $(UNIX2DOS) < packet-$(PROTOCOL_NAME)-ros.h.tmp > packet-$(PROTOCOL_NAME)-ros.h - del /f packet-$(PROTOCOL_NAME).c.tmp packet-$(PROTOCOL_NAME).h.tmp packet-$(PROTOCOL_NAME)-ros.c.tmp packet-$(PROTOCOL_NAME)-ros.h.tmp + del /f packet-$(PROTOCOL_NAME).c.tmp packet-$(PROTOCOL_NAME).h.tmp packet-$(PROTOCOL_NAME)-ros.c.tmp copy_files: generate_dissector fix_eol xcopy packet-$(PROTOCOL_NAME).c ..\..\epan\dissectors /d /y xcopy packet-$(PROTOCOL_NAME).h ..\..\epan\dissectors /d /y xcopy packet-$(PROTOCOL_NAME)-ros.c ..\..\epan\dissectors /d /y - xcopy packet-$(PROTOCOL_NAME)-ros.h ..\..\epan\dissectors /d /y diff --git a/asn1/q932/packet-q932-ros-template.c b/asn1/q932/packet-q932-ros-template.c index ff1e6746f6..f553fc18c6 100644 --- a/asn1/q932/packet-q932-ros-template.c +++ b/asn1/q932/packet-q932-ros-template.c @@ -36,14 +36,13 @@ #include <epan/asn1.h> #include "packet-ber.h" -#include "packet-q932-ros.h" #define PNAME "Q.932 Operations Service Element" #define PSNAME "Q932.ROS" #define PFNAME "q932.ros" /* Initialize the protocol and registered fields */ -int proto_rose = -1; +int proto_q932_ros = -1; #include "packet-q932-ros-hf.c" /* Initialize the subtree pointers */ @@ -55,11 +54,8 @@ int proto_rose = -1; static dissector_handle_t data_handle = NULL; /* Gloabl variables */ -static rose_ctx_t *rose_ctx; +static rose_ctx_t *rose_ctx_tmp; -static gint32 code_choice; -static guint32 code_local; -static const gchar *code_global; static guint32 problem_val; static gchar problem_str[64]; static tvbuff_t *arg_next_tvb, *res_next_tvb, *err_next_tvb; @@ -67,15 +63,15 @@ static tvbuff_t *arg_next_tvb, *res_next_tvb, *err_next_tvb; #include "packet-q932-ros-fn.c" -/*--- dissect_rose_apdu -----------------------------------------------------*/ -int dissect_rose_apdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rose_ctx_t *rctx) { - if (rctx) - rose_ctx = rctx; +/*--- dissect_q932_ros -----------------------------------------------------*/ +static int dissect_q932_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { + rose_ctx_tmp = get_rose_ctx(pinfo->private_data); + DISSECTOR_ASSERT(rose_ctx_tmp); return dissect_ROS_PDU(tvb, pinfo, tree); } -/*--- proto_register_rose ---------------------------------------------------*/ -void proto_register_rose(void) { +/*--- proto_register_q932_ros -----------------------------------------------*/ +void proto_register_q932_ros(void) { /* List of fields */ static hf_register_info hf[] = { @@ -88,17 +84,18 @@ void proto_register_rose(void) { }; /* Register protocol and dissector */ - proto_rose = proto_register_protocol(PNAME, PSNAME, PFNAME); - proto_set_cant_toggle(proto_rose); + proto_q932_ros = proto_register_protocol(PNAME, PSNAME, PFNAME); + proto_set_cant_toggle(proto_q932_ros); /* Register fields and subtrees */ - proto_register_field_array(proto_rose, hf, array_length(hf)); + proto_register_field_array(proto_q932_ros, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + register_dissector(PFNAME, dissect_q932_ros, proto_q932_ros); } -/*--- proto_reg_handoff_rose ------------------------------------------------*/ -void proto_reg_handoff_rose(void) { +/*--- proto_reg_handoff_q932_ros --------------------------------------------*/ +void proto_reg_handoff_q932_ros(void) { data_handle = find_dissector("data"); } diff --git a/asn1/q932/packet-q932-ros-template.h b/asn1/q932/packet-q932-ros-template.h deleted file mode 100644 index 585ca58d9f..0000000000 --- a/asn1/q932/packet-q932-ros-template.h +++ /dev/null @@ -1,34 +0,0 @@ -/* packet-q932-ros.h - * Routines for Q.932 packet dissection - * 2007 Tomas Kukosa - * - * $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. - */ - -#ifndef PACKET_ROSE_H -#define PACKET_ROSE_H - -#include "epan/asn1.h" - -int dissect_rose_apdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rose_ctx_t *rctx); - -#endif /* PACKET_ROSE_H */ - diff --git a/asn1/q932/packet-q932-template.c b/asn1/q932/packet-q932-template.c index 32b1b5174e..23c8c5c563 100644 --- a/asn1/q932/packet-q932-template.c +++ b/asn1/q932/packet-q932-template.c @@ -34,7 +34,6 @@ #include <epan/asn1.h> #include "packet-ber.h" -#include "packet-q932-ros.h" #include "packet-q932.h" #define PNAME "Q.932" @@ -62,6 +61,7 @@ static rose_ctx_t q932_rose_ctx; /* Subdissectors */ static dissector_handle_t data_handle = NULL; +static dissector_handle_t q932_ros_handle = NULL; /* Gloabl variables */ @@ -166,7 +166,8 @@ dissect_q932_facility_ie(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr case 3 : /* returnError */ case 4 : /* reject */ q932_rose_ctx.apdu_depth = 1; - dissect_rose_apdu(next_tvb, pinfo, tree, &q932_rose_ctx); + pinfo->private_data = &q932_rose_ctx; + call_dissector(q932_ros_handle, next_tvb, pinfo, tree); break; /* DSE APDU */ case 12 : /* begin */ @@ -270,7 +271,7 @@ dissect_q932_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /*--- dissect_q932_apdu -----------------------------------------------------*/ static void dissect_q932_apdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - dissect_rose_apdu(tvb, pinfo, tree, pinfo->private_data); + call_dissector(q932_ros_handle, tvb, pinfo, tree); } /*--- proto_register_q932 ---------------------------------------------------*/ @@ -311,6 +312,8 @@ void proto_register_q932(void) { proto_register_field_array(proto_q932, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + rose_ctx_init(&q932_rose_ctx); + /* Register dissector tables */ q932_rose_ctx.arg_global_dissector_table = register_dissector_table("q932.ros.global.arg", "Q.932 Operation Argument (global opcode)", FT_STRING, BASE_NONE); q932_rose_ctx.res_global_dissector_table = register_dissector_table("q932.ros.global.res", "Q.932 Operation Result (global opcode)", FT_STRING, BASE_NONE); @@ -328,6 +331,7 @@ void proto_reg_handoff_q932(void) { /* Notification indicator */ dissector_add("q931.ie", (0x00 << 8) | Q932_IE_NOTIFICATION_INDICATOR, q932_ie_handle); + q932_ros_handle = find_dissector("q932.ros"); data_handle = find_dissector("data"); } diff --git a/asn1/q932/q932-ros.cnf b/asn1/q932/q932-ros.cnf index 600a7427d2..ede1eef0a0 100644 --- a/asn1/q932/q932-ros.cnf +++ b/asn1/q932/q932-ros.cnf @@ -18,19 +18,24 @@ Reject/problem/returnResult returnResultProblem ReturnResult/result/result resultArgument +#--- ROS --- + +#.FN_PARS +ROS VAL_PTR = &%(ACTX)s->rose_ctx->d.pdu +#.FN_HDR ROS + /* will be moved to ROS_PDU when PDU function can be alternated from conformance file */ + actx->rose_ctx = rose_ctx_tmp; + rose_ctx_clean_data(actx->rose_ctx); +#.END + #--- Code --- -#.FN_HDR Code - code_choice = -1; - code_local = -1; - code_global = ""; #.FN_PARS -Code/local VAL_PTR = &code_local -Code/global FN_VARIANT = _str VAL_PTR = &code_global -#.FN_FTR Code/local - code_choice = 0; -#.FN_FTR Code/global - code_choice = 1; +Code VAL_PTR = &%(ACTX)s->rose_ctx->d.code +Code/local VAL_PTR = &%(ACTX)s->rose_ctx->d.code_local +Code/global FN_VARIANT = _str VAL_PTR = &%(ACTX)s->rose_ctx->d.code_global +#.FN_FTR Code + actx->rose_ctx->d.code_item = actx->created_item; #.END #--- Problem --- @@ -70,24 +75,24 @@ Invoke/argument TYPE = FT_BYTES DISPLAY = BASE_HEX arg_next_tvb = NULL; #.FN_FTR Invoke - if (code_choice == 0) { - arg_handle = dissector_get_port_handle(rose_ctx->arg_local_dissector_table, code_local); - } else if (code_choice == 1) { - arg_handle = dissector_get_string_handle(rose_ctx->arg_global_dissector_table, code_global); + if (actx->rose_ctx->d.code == 0) { + arg_handle = dissector_get_port_handle(actx->rose_ctx->arg_local_dissector_table, actx->rose_ctx->d.code_local); + } else if (actx->rose_ctx->d.code == 1) { + arg_handle = dissector_get_string_handle(actx->rose_ctx->arg_global_dissector_table, actx->rose_ctx->d.code_global); } else { arg_handle = NULL; } - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " INV:"); + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " INV:"); if (!arg_handle || !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(arg_handle)))) { - if (code_choice == 0) - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " %d", code_local); - else if (code_choice == 1) - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " %s", code_global); + if (actx->rose_ctx->d.code == 0) + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %d", actx->rose_ctx->d.code_local); + else if (actx->rose_ctx->d.code == 1) + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %s", actx->rose_ctx->d.code_global); } if (arg_next_tvb) { - actx->pinfo->private_data = rose_ctx; + actx->pinfo->private_data = actx->rose_ctx; call_dissector((arg_handle)?arg_handle:data_handle, arg_next_tvb, actx->pinfo, tree); } #.END @@ -113,24 +118,24 @@ ReturnResult/result/result TYPE = FT_BYTES DISPLAY = BASE_HEX res_next_tvb = NULL; #.FN_FTR ReturnResult - if (code_choice == 0) { - res_handle = dissector_get_port_handle(rose_ctx->res_local_dissector_table, code_local); - } else if (code_choice == 1) { - res_handle = dissector_get_string_handle(rose_ctx->res_global_dissector_table, code_global); + if (actx->rose_ctx->d.code == 0) { + res_handle = dissector_get_port_handle(actx->rose_ctx->res_local_dissector_table, actx->rose_ctx->d.code_local); + } else if (actx->rose_ctx->d.code == 1) { + res_handle = dissector_get_string_handle(actx->rose_ctx->res_global_dissector_table, actx->rose_ctx->d.code_global); } else { res_handle = NULL; } - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " RES:"); + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " RES:"); if (!res_handle || !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(res_handle)))) { - if (code_choice == 0) - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " %d", code_local); - else if (code_choice == 1) - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " %s", code_global); + if (actx->rose_ctx->d.code == 0) + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %d", actx->rose_ctx->d.code_local); + else if (actx->rose_ctx->d.code == 1) + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %s", actx->rose_ctx->d.code_global); } if (res_next_tvb) { - actx->pinfo->private_data = rose_ctx; + actx->pinfo->private_data = actx->rose_ctx; call_dissector((res_handle)?res_handle:data_handle, res_next_tvb, actx->pinfo, tree); } #.END @@ -156,24 +161,24 @@ ReturnError/parameter TYPE = FT_BYTES DISPLAY = BASE_HEX err_next_tvb = NULL; #.FN_FTR ReturnError - if (code_choice == 0) { - /*err_handle = dissector_get_port_handle(rose_ctx->err_local_dissector_table, code_local);*/ - } else if (code_choice == 1) { - /*err_handle = dissector_get_string_handle(rose_ctx->err_global_dissector_table, code_global);*/ + if (actx->rose_ctx->d.code == 0) { + /*err_handle = dissector_get_port_handle(actx->rose_ctx->err_local_dissector_table, actx->rose_ctx->d.code_local);*/ + } else if (actx->rose_ctx->d.code == 1) { + /*err_handle = dissector_get_string_handle(actx->rose_ctx->err_global_dissector_table, actx->rose_ctx->d.code_global);*/ } else { err_handle = NULL; } - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " ERR:"); + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " ERR:"); if (!err_handle || !proto_is_protocol_enabled(find_protocol_by_id(dissector_handle_get_protocol_index(err_handle)))) { - if (code_choice == 0) - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " %d", code_local); - else if (code_choice == 1) - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " %s", code_global); + if (actx->rose_ctx->d.code == 0) + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %d", actx->rose_ctx->d.code_local); + else if (actx->rose_ctx->d.code == 1) + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " %s", actx->rose_ctx->d.code_global); } if (err_next_tvb) { - actx->pinfo->private_data = rose_ctx; + actx->pinfo->private_data = actx->rose_ctx; call_dissector((err_handle)?err_handle:data_handle, err_next_tvb, actx->pinfo, tree); } #.END @@ -183,5 +188,5 @@ ReturnError/parameter TYPE = FT_BYTES DISPLAY = BASE_HEX #.FN_HDR Reject problem_str[0] = '\0'; #.FN_FTR Reject - proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rose_ctx->apdu_depth), " REJ: %s", problem_str); + proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), actx->rose_ctx->apdu_depth), " REJ: %s", problem_str); #.END |