aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/p7/packet-p7-template.c
diff options
context:
space:
mode:
authorGraeme Lunt <graeme.lunt@smhs.co.uk>2007-12-03 19:32:28 +0000
committerGraeme Lunt <graeme.lunt@smhs.co.uk>2007-12-03 19:32:28 +0000
commita58643173d6406fe05e39f370c7ca6232027996f (patch)
tree1617fc538a7e9b84740bb3f83a91a2f33ed0f6d0 /asn1/p7/packet-p7-template.c
parent5d8693069d80e1c3d45c2b9484b39878d3df2d61 (diff)
Revised P7 dissector to use #.TABLE directive to generate tables for the ROS dissector from
the [ABSTRACT] OPERATIONS definitions in the ASN.1 file. svn path=/trunk/; revision=23707
Diffstat (limited to 'asn1/p7/packet-p7-template.c')
-rw-r--r--asn1/p7/packet-p7-template.c280
1 files changed, 18 insertions, 262 deletions
diff --git a/asn1/p7/packet-p7-template.c b/asn1/p7/packet-p7-template.c
index 2e565e255a..e68c0b6921 100644
--- a/asn1/p7/packet-p7-template.c
+++ b/asn1/p7/packet-p7-template.c
@@ -71,262 +71,22 @@ static gint ett_p7 = -1;
#include "packet-p7-val.h"
+#include "packet-p7-table.c" /* operation and error codes */
+
#include "packet-p7-fn.c"
-/*
-* Dissect P7 PDUs inside a ROS PDUs
-*/
-static void
-dissect_p7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
-{
- int offset = 0;
- int old_offset;
- proto_item *item=NULL;
- proto_tree *tree=NULL;
- int (*p7_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) = NULL;
- char *p7_op_name;
- int hf_p7_index = -1;
- asn1_ctx_t asn1_ctx;
-
- asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
-
- /* do we have operation information from the ROS dissector? */
- if( !pinfo->private_data ){
- if(parent_tree){
- proto_tree_add_text(parent_tree, tvb, offset, -1,
- "Internal error: can't get operation information from ROS dissector.");
- }
- return ;
- } else {
- session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
- }
-
- if(parent_tree){
- item = proto_tree_add_item(parent_tree, proto_p7, tvb, 0, -1, FALSE);
- tree = proto_item_add_subtree(item, ett_p7);
- }
- if (check_col(pinfo->cinfo, COL_PROTOCOL))
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "P7");
- if (check_col(pinfo->cinfo, COL_INFO))
- col_clear(pinfo->cinfo, COL_INFO);
-
- switch(session->ros_op & ROS_OP_MASK) {
- case (ROS_OP_BIND | ROS_OP_ARGUMENT): /* BindInvoke */
- p7_dissector = dissect_p7_MSBindArgument;
- p7_op_name = "MS-Bind-Argument";
- hf_p7_index = hf_p7_MSBindArgument_PDU;
- break;
- case (ROS_OP_BIND | ROS_OP_RESULT): /* BindResult */
- p7_dissector = dissect_p7_MSBindResult;
- p7_op_name = "MS-Bind-Result";
- hf_p7_index = hf_p7_MSBindResult_PDU;
- break;
- case (ROS_OP_BIND | ROS_OP_ERROR): /* BindError */
- p7_dissector = dissect_p7_MSBindError;
- p7_op_name = "MS-Bind-Error";
- hf_p7_index = hf_p7_MSBindError_PDU;
- break;
- case (ROS_OP_INVOKE | ROS_OP_ARGUMENT): /* Invoke Argument */
- switch(session->ros_op & ROS_OP_OPCODE_MASK) {
- case op_ms_message_submission: /* msMessageSubmission */
- p7_dissector = dissect_p7_MSMessageSubmissionArgument;
- p7_op_name = "MS-Message-Submission-Argument";
- hf_p7_index = hf_p7_MSMessageSubmissionArgument_PDU;
- break;
- case op_ms_probe_submission: /* msProbeSubmission */
- p7_dissector = dissect_p7_MSProbeSubmissionArgument;
- p7_op_name = "MS-Probe-Submission-Argument";
- hf_p7_index = hf_p7_MSProbeSubmissionArgument_PDU;
- break;
- case op_summarize: /* summarize */
- p7_dissector = dissect_p7_SummarizeArgument;
- p7_op_name = "Summarize-Argument";
- hf_p7_index = hf_p7_SummarizeArgument_PDU;
- break;
- case op_list: /* list */
- p7_dissector = dissect_p7_ListArgument;
- p7_op_name = "List-Argument";
- hf_p7_index = hf_p7_ListArgument_PDU;
- break;
- case op_fetch: /* fetch */
- p7_dissector = dissect_p7_FetchArgument;
- p7_op_name = "Fetch-Argument";
- hf_p7_index = hf_p7_FetchArgument_PDU;
- break;
- case op_delete: /* delete */
- p7_dissector = dissect_p7_DeleteArgument;
- p7_op_name = "Delete-Argument";
- hf_p7_index = hf_p7_DeleteArgument_PDU;
- break;
- case op_register_ms: /* register-ms */
- p7_dissector = dissect_p7_Register_MSArgument;
- p7_op_name = "RegisterMS-Argument";
- hf_p7_index = hf_p7_Register_MSArgument_PDU;
- break;
- case op_alert: /* alert */
- p7_dissector = dissect_p7_AlertArgument;
- p7_op_name = "Alert-Argument";
- hf_p7_index = hf_p7_AlertArgument_PDU;
- break;
- case op_modify: /* modify */
- p7_dissector = dissect_p7_ModifyArgument;
- p7_op_name = "Modify-Argument";
- hf_p7_index = hf_p7_ModifyArgument_PDU;
- break;
- default:
- proto_tree_add_text(tree, tvb, offset, -1,"Unsupported P7 argument opcode (%d)",
- session->ros_op & ROS_OP_OPCODE_MASK);
- break;
- }
- break;
- case (ROS_OP_INVOKE | ROS_OP_RESULT): /* Return Result */
- switch(session->ros_op & ROS_OP_OPCODE_MASK) {
- case op_ms_message_submission: /* msMessageSubmission */
- p7_dissector = dissect_p7_MSMessageSubmissionResult;
- p7_op_name = "MS-Message-Submission-Result";
- hf_p7_index = hf_p7_MSMessageSubmissionResult_PDU;
- break;
- case op_ms_probe_submission: /* msProbeSubmission */
- p7_dissector = dissect_p7_MSProbeSubmissionResult;
- p7_op_name = "MS-Probe-Submission-Result";
- hf_p7_index = hf_p7_MSProbeSubmissionResult_PDU;
- break;
- case op_summarize: /* summarize */
- p7_dissector = dissect_p7_SummarizeResult;
- p7_op_name = "Summarize-Result";
- hf_p7_index = hf_p7_SummarizeResult_PDU;
- break;
- case op_list: /* list */
- p7_dissector = dissect_p7_ListResult;
- p7_op_name = "List-Result";
- hf_p7_index = hf_p7_ListResult_PDU;
- break;
- case op_fetch: /* fetch */
- p7_dissector = dissect_p7_FetchResult;
- p7_op_name = "Fetch-Result";
- hf_p7_index = hf_p7_FetchResult_PDU;
- break;
- case op_delete: /* delete */
- p7_dissector = dissect_p7_DeleteResult;
- p7_op_name = "Delete-Result";
- break;
- case op_register_ms: /* register-ms */
- p7_dissector = dissect_p7_Register_MSResult;
- p7_op_name = "RegisterMS-Result";
- hf_p7_index = hf_p7_Register_MSResult_PDU;
- break;
- case op_alert: /* alert */
- p7_dissector = dissect_p7_AlertResult;
- p7_op_name = "Alert-Result";
- hf_p7_index = hf_p7_AlertResult_PDU;
- break;
- case op_modify: /* modify */
- p7_dissector = dissect_p7_ModifyResult;
- p7_op_name = "Modify-Result";
- hf_p7_index = hf_p7_ModifyResult_PDU;
- break;
- default:
- proto_tree_add_text(tree, tvb, offset, -1,"Unsupported P7 result opcode (%d)",
- session->ros_op & ROS_OP_OPCODE_MASK);
- break;
- }
- break;
- case (ROS_OP_INVOKE | ROS_OP_ERROR): /* Return Error */
- switch(session->ros_op & ROS_OP_OPCODE_MASK) {
- case err_attribute_error: /* attributeError */
- p7_dissector = dissect_p7_AttributeErrorParameter;
- p7_op_name = "Attribute-Error";
- hf_p7_index = hf_p7_AttributeErrorParameter_PDU;
- break;
- case err_auto_action_request_error: /* autoActionRequestError */
- p7_dissector = dissect_p7_AutoActionRequestErrorParameter;
- p7_op_name = "Auto-Action-Request-Error";
- hf_p7_index = hf_p7_AutoActionRequestErrorParameter_PDU;
- break;
- case err_delete_error: /* deleteError */
- p7_dissector = dissect_p7_DeleteErrorParameter;
- p7_op_name = "Delete-Error";
- hf_p7_index = hf_p7_DeleteErrorParameter_PDU;
- break;
- case err_fetch_restriction_error: /* fetchRestrictionError */
- p7_dissector = dissect_p7_FetchRestrictionErrorParameter;
- p7_op_name = "Fetch-Restriction-Error";
- hf_p7_index = hf_p7_FetchRestrictionErrorParameter_PDU;
- break;
- case err_range_error: /* rangeError */
- p7_dissector = dissect_p7_RangeErrorParameter;
- p7_op_name = "Range-Error";
- hf_p7_index = hf_p7_RangeErrorParameter_PDU;
- break;
- case err_security_error: /* securityError */
- p7_dissector = dissect_x411_SecurityProblem;
- p7_op_name = "Security-Error";
- break;
- case err_service_error: /* serviceError*/
- p7_dissector = dissect_p7_ServiceErrorParameter;
- p7_op_name = "Service-Error";
- hf_p7_index = hf_p7_ServiceErrorParameter_PDU;
- break;
- case err_sequence_number_error: /* sequenceNumberError */
- p7_dissector = dissect_p7_SequenceNumberErrorParameter;
- p7_op_name = "Sequence-Number-Error";
- hf_p7_index = hf_p7_SequenceNumberErrorParameter_PDU;
- break;
- case err_invalid_parameters_error: /* invalidParametersError */
- p7_dissector = NULL;
- p7_op_name = "Invalid-Parameters-Error";
- break;
- case err_message_group_error: /* messageGroupError */
- p7_dissector = dissect_p7_MessageGroupErrorParameter;
- p7_op_name = "Message-Group-Error";
- hf_p7_index = hf_p7_MessageGroupErrorParameter_PDU;
- break;
- case err_ms_extension_error: /* msExtensioError */
- p7_dissector = dissect_p7_MSExtensionErrorParameter;
- p7_op_name = "MS-Extension-Error";
- hf_p7_index = hf_p7_MSExtensionErrorParameter_PDU;
- break;
- case err_register_ms_error: /* registerMSError */
- p7_dissector = dissect_p7_RegisterMSErrorParameter;
- p7_op_name = "Register-MS-Error";
- hf_p7_index = hf_p7_RegisterMSErrorParameter_PDU;
- break;
- case err_modify_error: /* modifyError */
- p7_dissector = dissect_p7_ModifyErrorParameter;
- p7_op_name = "Modify-Error";
- hf_p7_index = hf_p7_ModifyErrorParameter_PDU;
- break;
- case err_entry_class_error: /* entryClassError */
- p7_dissector = dissect_p7_EntryClassErrorParameter;
- p7_op_name = "Entry-Class-Error";
- hf_p7_index = hf_p7_EntryClassErrorParameter_PDU;
- break;
- default:
- proto_tree_add_text(tree, tvb, offset, -1,"Unsupported P7 error opcode (%d)",
- session->ros_op & ROS_OP_OPCODE_MASK);
- break;
- }
- break;
- default:
- proto_tree_add_text(tree, tvb, offset, -1,"Unsupported P7 PDU");
- return;
- }
-
- if(p7_dissector) {
- if (check_col(pinfo->cinfo, COL_INFO))
- col_set_str(pinfo->cinfo, COL_INFO, p7_op_name);
-
- while (tvb_reported_length_remaining(tvb, offset) > 0){
- old_offset=offset;
- offset=(*p7_dissector)(FALSE, tvb, offset, &asn1_ctx, tree, hf_p7_index);
- if(offset == old_offset){
- proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte P7 PDU");
- offset = tvb_length(tvb);
- break;
- }
- }
- }
-}
+#include "packet-p7-table11.c" /* operation argument/result dissectors */
+#include "packet-p7-table21.c" /* error dissector */
+
+static const ros_info_t p7_ros_info = {
+ "P7",
+ &proto_p7,
+ &ett_p7,
+ p7_opr_code_string_vals,
+ p7_opr_tab,
+ p7_err_code_string_vals,
+ p7_err_tab
+};
/*--- proto_register_p7 -------------------------------------------*/
@@ -347,7 +107,6 @@ void proto_register_p7(void) {
/* Register protocol */
proto_p7 = proto_register_protocol(PNAME, PSNAME, PFNAME);
- register_dissector("p7", dissect_p7, proto_p7);
/* Register fields and subtrees */
proto_register_field_array(proto_p7, hf, array_length(hf));
@@ -367,7 +126,6 @@ void proto_register_p7(void) {
/*--- proto_reg_handoff_p7 --- */
void proto_reg_handoff_p7(void) {
- dissector_handle_t handle = NULL;
/* #include "packet-p7-dis-tab.c" */
@@ -377,13 +135,11 @@ void proto_reg_handoff_p7(void) {
oid_add_from_string("id-ac-ms-reliable-access","2.6.0.1.12");
/* ABSTRACT SYNTAXES */
-
+
/* Register P7 with ROS (with no use of RTSE) */
- if((handle = find_dissector("p7"))) {
- register_ros_oid_dissector_handle("2.6.0.2.9", handle, 0, "id-as-ms", FALSE);
- register_ros_oid_dissector_handle("2.6.0.2.5", handle, 0, "id-as-mrse", FALSE);
- register_ros_oid_dissector_handle("2.6.0.2.1", handle, 0, "id-as-msse", FALSE);
- }
+ register_ros_protocol_info("2.6.0.2.9", &p7_ros_info, 0, "id-as-ms", FALSE);
+ register_ros_protocol_info("2.6.0.2.5", &p7_ros_info, 0, "id-as-mrse", FALSE);
+ register_ros_protocol_info("2.6.0.2.1", &p7_ros_info, 0, "id-as-msse", FALSE);
/* remember the tpkt handler for change in preferences */
tpkt_handle = find_dissector("tpkt");