From df078a219c75355b1c7437482a433a91a4852e24 Mon Sep 17 00:00:00 2001 From: ulfl Date: Sun, 25 Feb 2007 15:48:43 +0000 Subject: add a new function dissect_dcom_HRESULT_item() for some more flexibility, use it in the CBA-ACCO dissector - as the value_strings from dcom can't be used in hf_register_info from a plugin git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@20926 f5534014-38df-0310-8fa8-9805f1628bb7 --- epan/dissectors/packet-dcom.c | 24 ++++++++++++++++++++++++ epan/dissectors/packet-dcom.h | 5 +++++ epan/libwireshark.def | 1 + plugins/profinet/packet-dcom-cba-acco.c | 22 ++++++++++++++++------ 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/epan/dissectors/packet-dcom.c b/epan/dissectors/packet-dcom.c index 5544c48a99..94dae3f139 100644 --- a/epan/dissectors/packet-dcom.c +++ b/epan/dissectors/packet-dcom.c @@ -1034,6 +1034,30 @@ dissect_dcom_indexed_DWORD(tvbuff_t *tvb, int offset, packet_info *pinfo, } +/* dissect hresult field of a usual DCOM call (create "raw" item) */ +int +dissect_dcom_HRESULT_item(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, guint8 *drep, + guint32 * pu32HResult, int field_index, proto_item **item) +{ + guint32 u32HResult; + + /* dissect the DWORD, but don't add to tree */ + offset = dissect_dcom_DWORD(tvb, offset, pinfo, NULL /*tree*/, drep, + field_index, &u32HResult); + + if (tree) { + /* special formatted output of indexed value */ + item = proto_tree_add_item (tree, field_index, tvb, offset-4, 4, (drep[0] & 0x10)); + } + + if (pu32HResult) + *pu32HResult = u32HResult; + + return offset; +} + + /* dissect hresult field of a usual DCOM call (seperate method, because often used) */ int dissect_dcom_HRESULT(tvbuff_t *tvb, int offset, packet_info *pinfo, diff --git a/epan/dissectors/packet-dcom.h b/epan/dissectors/packet-dcom.h index d3a1fded56..a381cced7a 100644 --- a/epan/dissectors/packet-dcom.h +++ b/epan/dissectors/packet-dcom.h @@ -120,6 +120,11 @@ extern int dissect_dcom_HRESULT(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, guint32 * pu32hresult); +extern int +dissect_dcom_HRESULT_item(tvbuff_t *tvb, int offset, packet_info *pinfo, + proto_tree *tree, guint8 *drep, + guint32 * pu32HResult, int field_index, proto_item **item); + extern int dissect_dcom_indexed_HRESULT(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, diff --git a/epan/libwireshark.def b/epan/libwireshark.def index 897c726e45..11ebdf55a4 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -167,6 +167,7 @@ dissect_dcom_BSTR dissect_dcom_dcerpc_array_size dissect_dcom_dcerpc_pointer dissect_dcom_HRESULT +dissect_dcom_HRESULT_item dissect_dcom_indexed_DWORD dissect_dcom_indexed_HRESULT dissect_dcom_indexed_LPWSTR diff --git a/plugins/profinet/packet-dcom-cba-acco.c b/plugins/profinet/packet-dcom-cba-acco.c index 3f85b951c6..883be61778 100644 --- a/plugins/profinet/packet-dcom-cba-acco.c +++ b/plugins/profinet/packet-dcom-cba-acco.c @@ -327,6 +327,9 @@ typedef struct server_disconnectme_call_s { GList *cba_pdevs; +/* as we are a plugin, we cannot get this from libwireshark! */ +const true_false_string acco_flags_set_truth = { "Set", "Not set" }; + static void cba_connection_dump(cba_connection_t *conn, const char *role) @@ -3978,6 +3981,7 @@ dissect_ICBAAccoMgt2_DiagConsConnections_resp(tvbuff_t *tvb, int offset, guint16 u16ConnVersion; proto_item *sub_item; proto_tree *sub_tree; + proto_item *state_item; guint32 u32SubStart; guint32 u32Idx; guint32 u32VariableOffset; @@ -4011,8 +4015,15 @@ dissect_ICBAAccoMgt2_DiagConsConnections_resp(tvbuff_t *tvb, int offset, hf_cba_acco_conn_persist, &u16Persistence); offset = dissect_dcom_WORD(tvb, offset, pinfo, sub_tree, drep, hf_cba_acco_conn_version, &u16ConnVersion); - offset = dissect_dcom_DWORD(tvb, offset, pinfo, sub_tree, drep, - hf_cba_acco_conn_error_state, &u32ConnErrorState); + /* connection state */ +/* offset = dissect_dcom_DWORD(tvb, offset, pinfo, sub_tree, drep, + hf_cba_acco_conn_error_state, &u32ConnErrorState);*/ + offset = dissect_dcom_HRESULT_item(tvb, offset, pinfo, sub_tree, drep, + &u32ConnErrorState, hf_cba_acco_conn_error_state, &state_item); + proto_item_set_text(state_item, "ConnErrorState: %s (0x%x)", + val_to_str(u32ConnErrorState, dcom_hresult_vals, "Unknown (0x%08x)"), + u32ConnErrorState); + offset = dissect_dcom_indexed_HRESULT(tvb, offset, pinfo, sub_tree, drep, &u32HResult, u32Idx); @@ -4737,8 +4748,8 @@ proto_register_dcom_cba_acco (void) { "WriteItemIn", "cba.acco.writeitemin", FT_NONE, BASE_NONE, NULL, 0x0, "", HFILL }}, { &hf_cba_acco_cdb_cookie, { "CDBCookie", "cba.acco.cdb_cookie", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }}, + /* dcom_hresult_vals from packet-dcom.h doesn't work here, as length is unknown! */ { &hf_cba_acco_conn_error_state, - /* XXX - find out, why VALS doesn't work here! */ { "ConnErrorState", "cba.acco.conn_error_state", FT_UINT32, BASE_HEX, NULL /*VALS(dcom_hresult_vals)*/, 0x0, "", HFILL }}, { &hf_cba_acco_diag_req, { "Request", "cba.acco.diag_req", FT_UINT32, BASE_HEX, VALS(cba_acco_diag_req_vals), 0x0, "", HFILL }}, @@ -4772,11 +4783,10 @@ proto_register_dcom_cba_acco (void) { "CRLength", "cba.acco.serversrt_cr_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }}, { &hf_cba_acco_serversrt_cr_flags, { "Flags", "cba.acco.serversrt_cr_flags", FT_UINT32, BASE_HEX, 0, 0x0, "", HFILL }}, - /* XXX - find out, why TFS doesn't work here! */ { &hf_cba_acco_serversrt_cr_flags_timestamped, - { "Timestamped", "cba.acco.serversrt_cr_flags_timestamped", FT_BOOLEAN, 32, NULL /*TFS (&flags_set_truth)*/, 0x1, "", HFILL }}, + { "Timestamped", "cba.acco.serversrt_cr_flags_timestamped", FT_BOOLEAN, 32, TFS (&acco_flags_set_truth), 0x1, "", HFILL }}, { &hf_cba_acco_serversrt_cr_flags_reconfigure, - { "Reconfigure", "cba.acco.serversrt_cr_flags_reconfigure", FT_BOOLEAN, 32, NULL /*TFS (&flags_set_truth)*/, 0x2, "", HFILL }}, + { "Reconfigure", "cba.acco.serversrt_cr_flags_reconfigure", FT_BOOLEAN, 32, TFS (&acco_flags_set_truth), 0x2, "", HFILL }}, { &hf_cba_type_desc_len, { "TypeDescLen", "cba.acco.type_desc_len", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }}, { &hf_cba_acco_serversrt_record_length, -- cgit v1.2.3