diff options
Diffstat (limited to 'epan/dissectors/packet-p1.c')
-rw-r--r-- | epan/dissectors/packet-p1.c | 273 |
1 files changed, 143 insertions, 130 deletions
diff --git a/epan/dissectors/packet-p1.c b/epan/dissectors/packet-p1.c index 38c32c694b..17bec5c4b8 100644 --- a/epan/dissectors/packet-p1.c +++ b/epan/dissectors/packet-p1.c @@ -895,62 +895,62 @@ static const value_string p3_err_code_string_vals[] = { #line 88 "../../asn1/p1/packet-p1-template.c" typedef struct p1_address_ctx { - gboolean do_address; - const char *content_type_id; - gboolean report_unknown_content_type; - wmem_strbuf_t* oraddress; + gboolean do_address; + const char *content_type_id; + gboolean report_unknown_content_type; + wmem_strbuf_t* oraddress; } p1_address_ctx_t; static void set_do_address(asn1_ctx_t* actx, gboolean do_address) { - p1_address_ctx_t* ctx; + p1_address_ctx_t* ctx; - if (actx->subtree.tree_ctx == NULL) { - actx->subtree.tree_ctx = wmem_new0(wmem_packet_scope(), p1_address_ctx_t); - } + if (actx->subtree.tree_ctx == NULL) { + actx->subtree.tree_ctx = wmem_new0(wmem_packet_scope(), p1_address_ctx_t); + } - ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; - ctx->do_address = do_address; + ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + ctx->do_address = do_address; } static void do_address(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx) { - p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; - if (ctx && ctx->do_address) { - if (addr) { - wmem_strbuf_append(ctx->oraddress, addr); - } - if (tvb_string) { - wmem_strbuf_append(ctx->oraddress, tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); - } - } + if (ctx && ctx->do_address) { + if (addr) { + wmem_strbuf_append(ctx->oraddress, addr); + } + if (tvb_string) { + wmem_strbuf_append(ctx->oraddress, tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); + } + } } static void do_address_str(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx) { - wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr; - p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr; + p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; - do_address(addr, tvb_string, actx); + do_address(addr, tvb_string, actx); - if (ctx && ctx->do_address && ddatype && tvb_string) - wmem_strbuf_append(ddatype, tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); + if (ctx && ctx->do_address && ddatype && tvb_string) + wmem_strbuf_append(ddatype, tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); } static void do_address_str_tree(const char* addr, tvbuff_t* tvb_string, asn1_ctx_t* actx, proto_tree* tree) { - wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr; - p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + wmem_strbuf_t *ddatype = (wmem_strbuf_t *)actx->value_ptr; + p1_address_ctx_t* ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; - do_address(addr, tvb_string, actx); + do_address(addr, tvb_string, actx); - if (ctx && ctx->do_address && tvb_string && ddatype) { - if (wmem_strbuf_get_len(ddatype) > 0) { - proto_item_append_text (tree, " (%s=%s)", wmem_strbuf_get_str(ddatype), tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); - } - } + if (ctx && ctx->do_address && tvb_string && ddatype) { + if (wmem_strbuf_get_len(ddatype) > 0) { + proto_item_append_text (tree, " (%s=%s)", wmem_strbuf_get_str(ddatype), tvb_format_text(tvb_string, 0, tvb_captured_length(tvb_string))); + } + } } @@ -8509,32 +8509,32 @@ static const ros_info_t p3_ros_info = { void p1_initialize_content_globals (asn1_ctx_t* actx, proto_tree *tree, gboolean report_unknown_cont_type) { - p1_address_ctx_t* ctx; + p1_address_ctx_t* ctx; - if (actx->subtree.tree_ctx == NULL) { - actx->subtree.tree_ctx = wmem_new0(wmem_packet_scope(), p1_address_ctx_t); - } + if (actx->subtree.tree_ctx == NULL) { + actx->subtree.tree_ctx = wmem_new0(wmem_packet_scope(), p1_address_ctx_t); + } - ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; - actx->subtree.top_tree = tree; - actx->external.direct_reference = NULL; - ctx->content_type_id = NULL; - ctx->report_unknown_content_type = report_unknown_cont_type; + actx->subtree.top_tree = tree; + actx->external.direct_reference = NULL; + ctx->content_type_id = NULL; + ctx->report_unknown_content_type = report_unknown_cont_type; } const char* p1_get_last_oraddress (asn1_ctx_t* actx) { - p1_address_ctx_t* ctx; + p1_address_ctx_t* ctx; - if ((actx == NULL) || (actx->subtree.tree_ctx == NULL)) - return ""; + if ((actx == NULL) || (actx->subtree.tree_ctx == NULL)) + return ""; - ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; - if (wmem_strbuf_get_len(ctx->oraddress) <= 0) - return ""; + ctx = (p1_address_ctx_t*)actx->subtree.tree_ctx; + if (wmem_strbuf_get_len(ctx->oraddress) <= 0) + return ""; - return wmem_strbuf_get_str(ctx->oraddress); + return wmem_strbuf_get_str(ctx->oraddress); } /* @@ -8543,24 +8543,24 @@ const char* p1_get_last_oraddress (asn1_ctx_t* actx) void dissect_p1_mts_apdu (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; - asn1_ctx_t asn1_ctx; - asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); + proto_item *item=NULL; + proto_tree *tree=NULL; + asn1_ctx_t asn1_ctx; + asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); - /* save parent_tree so subdissectors can create new top nodes */ - p1_initialize_content_globals (&asn1_ctx, parent_tree, TRUE); + /* save parent_tree so subdissectors can create new top nodes */ + p1_initialize_content_globals (&asn1_ctx, parent_tree, TRUE); - if(parent_tree){ - item = proto_tree_add_item(parent_tree, proto_p1, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_p1); - } + if(parent_tree){ + item = proto_tree_add_item(parent_tree, proto_p1, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_p1); + } - col_set_str(pinfo->cinfo, COL_PROTOCOL, "P1"); - col_set_str(pinfo->cinfo, COL_INFO, "Transfer"); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "P1"); + col_set_str(pinfo->cinfo, COL_INFO, "Transfer"); - dissect_p1_MTS_APDU (FALSE, tvb, 0, &asn1_ctx, tree, hf_p1_MTS_APDU_PDU); - p1_initialize_content_globals (&asn1_ctx, NULL, FALSE); + dissect_p1_MTS_APDU (FALSE, tvb, 0, &asn1_ctx, tree, hf_p1_MTS_APDU_PDU); + p1_initialize_content_globals (&asn1_ctx, NULL, FALSE); } /* @@ -8569,71 +8569,71 @@ dissect_p1_mts_apdu (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) static int dissect_p1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { - int offset = 0; - int old_offset; - proto_item *item; - proto_tree *tree; - struct SESSION_DATA_STRUCTURE* session; - int (*p1_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) = NULL; - const char *p1_op_name; - int hf_p1_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 (data == NULL) - return 0; - session = (struct SESSION_DATA_STRUCTURE*)data; - - /* save parent_tree so subdissectors can create new top nodes */ - p1_initialize_content_globals (&asn1_ctx, parent_tree, TRUE); - - asn1_ctx.private_data = session; - - item = proto_tree_add_item(parent_tree, proto_p1, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_p1); - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "P1"); - col_clear(pinfo->cinfo, COL_INFO); - - switch(session->ros_op & ROS_OP_MASK) { - case (ROS_OP_BIND | ROS_OP_ARGUMENT): /* BindInvoke */ - p1_dissector = dissect_p1_MTABindArgument; - p1_op_name = "Bind-Argument"; - hf_p1_index = hf_p1_MTABindArgument_PDU; - break; - case (ROS_OP_BIND | ROS_OP_RESULT): /* BindResult */ - p1_dissector = dissect_p1_MTABindResult; - p1_op_name = "Bind-Result"; - hf_p1_index = hf_p1_MTABindResult_PDU; - break; - case (ROS_OP_BIND | ROS_OP_ERROR): /* BindError */ - p1_dissector = dissect_p1_MTABindError; - p1_op_name = "Bind-Error"; - hf_p1_index = hf_p1_MTABindError_PDU; - break; - case (ROS_OP_INVOKE | ROS_OP_ARGUMENT): /* Invoke Argument */ - p1_dissector = dissect_p1_MTS_APDU; - p1_op_name = "Transfer"; - hf_p1_index = hf_p1_MTS_APDU_PDU; - break; - default: - proto_tree_add_expert(tree, pinfo, &ei_p1_unsupported_pdu, tvb, offset, -1); - return tvb_captured_length(tvb); - } - - col_set_str(pinfo->cinfo, COL_INFO, p1_op_name); - - while (tvb_reported_length_remaining(tvb, offset) > 0){ - old_offset=offset; - offset=(*p1_dissector)(FALSE, tvb, offset, &asn1_ctx , tree, hf_p1_index); - if(offset == old_offset){ - proto_tree_add_expert(tree, pinfo, &ei_p1_zero_pdu, tvb, offset, -1); - break; - } - } - p1_initialize_content_globals (&asn1_ctx, NULL, FALSE); - return tvb_captured_length(tvb); + int offset = 0; + int old_offset; + proto_item *item; + proto_tree *tree; + struct SESSION_DATA_STRUCTURE* session; + int (*p1_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index _U_) = NULL; + const char *p1_op_name; + int hf_p1_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 (data == NULL) + return 0; + session = (struct SESSION_DATA_STRUCTURE*)data; + + /* save parent_tree so subdissectors can create new top nodes */ + p1_initialize_content_globals (&asn1_ctx, parent_tree, TRUE); + + asn1_ctx.private_data = session; + + item = proto_tree_add_item(parent_tree, proto_p1, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_p1); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "P1"); + col_clear(pinfo->cinfo, COL_INFO); + + switch(session->ros_op & ROS_OP_MASK) { + case (ROS_OP_BIND | ROS_OP_ARGUMENT): /* BindInvoke */ + p1_dissector = dissect_p1_MTABindArgument; + p1_op_name = "Bind-Argument"; + hf_p1_index = hf_p1_MTABindArgument_PDU; + break; + case (ROS_OP_BIND | ROS_OP_RESULT): /* BindResult */ + p1_dissector = dissect_p1_MTABindResult; + p1_op_name = "Bind-Result"; + hf_p1_index = hf_p1_MTABindResult_PDU; + break; + case (ROS_OP_BIND | ROS_OP_ERROR): /* BindError */ + p1_dissector = dissect_p1_MTABindError; + p1_op_name = "Bind-Error"; + hf_p1_index = hf_p1_MTABindError_PDU; + break; + case (ROS_OP_INVOKE | ROS_OP_ARGUMENT): /* Invoke Argument */ + p1_dissector = dissect_p1_MTS_APDU; + p1_op_name = "Transfer"; + hf_p1_index = hf_p1_MTS_APDU_PDU; + break; + default: + proto_tree_add_expert(tree, pinfo, &ei_p1_unsupported_pdu, tvb, offset, -1); + return tvb_captured_length(tvb); + } + + col_set_str(pinfo->cinfo, COL_INFO, p1_op_name); + + while (tvb_reported_length_remaining(tvb, offset) > 0){ + old_offset=offset; + offset=(*p1_dissector)(FALSE, tvb, offset, &asn1_ctx , tree, hf_p1_index); + if(offset == old_offset){ + proto_tree_add_expert(tree, pinfo, &ei_p1_zero_pdu, tvb, offset, -1); + break; + } + } + p1_initialize_content_globals (&asn1_ctx, NULL, FALSE); + return tvb_captured_length(tvb); } @@ -11157,9 +11157,9 @@ void proto_register_p1(void) { p1_module = prefs_register_protocol_subtree("OSI/X.400", proto_p1, prefs_register_p1); prefs_register_uint_preference(p1_module, "tcp.port", "P1 TCP Port", - "Set the port for P1 operations (if other" - " than the default of 102)", - 10, &global_p1_tcp_port); + "Set the port for P1 operations (if other" + " than the default of 102)", + 10, &global_p1_tcp_port); register_ber_syntax_dissector("P1 Message", proto_p1, dissect_p1_mts_apdu); @@ -11392,3 +11392,16 @@ prefs_register_p1(void) dissector_add_uint("tcp.port", tcp_port, tpkt_handle); } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ |