diff options
author | AndersBroman <anders.broman@ericsson.com> | 2014-08-05 15:22:14 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-08-05 13:36:03 +0000 |
commit | 79c55a34cb9869a846ed4e58a760c50e409eeeb5 (patch) | |
tree | 6b1fe2ca9dcaf41e448f56e19d20a053794c7299 /plugins/opcua/opcua.c | |
parent | 8b2a8a9636d0909e417112ef2d14601955a1458a (diff) |
Fix Bug #10348 Different dissection results for same file.
The fault is that reassembly_table_init() must be called when reloading
the file - move it to an init routine and register the init routine.
While there move the proto_register_opcua() routine to the end of the file
to be more consistent with other dissectors.
Change soft deprecated APIs
Change-Id: I2b93692be24dbf60f4ef09aa7283e55ebf3c1874
Reviewed-on: https://code.wireshark.org/review/3431
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'plugins/opcua/opcua.c')
-rw-r--r-- | plugins/opcua/opcua.c | 189 |
1 files changed, 99 insertions, 90 deletions
diff --git a/plugins/opcua/opcua.c b/plugins/opcua/opcua.c index dc37076b21..c3187243e4 100644 --- a/plugins/opcua/opcua.c +++ b/plugins/opcua/opcua.c @@ -123,93 +123,6 @@ static const char* g_szMessageTypes[] = -/** plugin entry functions. - * This registers the OpcUa protocol. - */ -void proto_register_opcua(void) -{ - char *tmp; - - static hf_register_info hf[] = - { - {&hf_opcua_fragments, - {"Message fragments", "opcua.fragments", - FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_fragment, - {"Message fragment", "opcua.fragment", - FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_fragment_overlap, - {"Message fragment overlap", "opcua.fragment.overlap", - FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_fragment_overlap_conflicts, - {"Message fragment overlapping with conflicting data", - "opcua.fragment.overlap.conflicts", - FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_fragment_multiple_tails, - {"Message has multiple tail fragments", - "opcua.fragment.multiple_tails", - FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_fragment_too_long_fragment, - {"Message fragment too long", "opcua.fragment.too_long_fragment", - FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_fragment_error, - {"Message defragmentation error", "opcua.fragment.error", - FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_fragment_count, - {"Message fragment count", "opcua.fragment.count", - FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_reassembled_in, - {"Reassembled in", "opcua.reassembled.in", - FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } }, - {&hf_opcua_reassembled_length, - {"Reassembled length", "opcua.reassembled.length", - FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } } - }; - - /** Setup protocol subtree array */ - static gint *ett[] = - { - &ett_opcua_extensionobject, - &ett_opcua_nodeid, - &ett_opcua_transport, - &ett_opcua_fragment, - &ett_opcua_fragments - }; - - module_t *opcua_module; - - proto_opcua = proto_register_protocol( - "OpcUa Binary Protocol", /* name */ - "OpcUa", /* short name */ - "opcua" /* abbrev */ - ); - - registerTransportLayerTypes(proto_opcua); - registerSecurityLayerTypes(proto_opcua); - registerApplicationLayerTypes(proto_opcua); - registerSimpleTypes(proto_opcua); - registerEnumTypes(proto_opcua); - registerComplexTypes(); - registerServiceTypes(); - registerFieldTypes(proto_opcua); - - proto_register_subtree_array(ett, array_length(ett)); - - tmp = g_strdup_printf("%d", OPCUA_PORT); - range_convert_str(&global_tcp_ports_opcua, tmp, 65535); - g_free(tmp); - - reassembly_table_init(&opcua_reassembly_table, - &addresses_reassembly_table_functions); - proto_register_field_array(proto_opcua, hf, array_length(hf)); - - /* register user preferences */ - opcua_module = prefs_register_protocol(proto_opcua, proto_reg_handoff_opcua); - prefs_register_range_preference(opcua_module, "tcp_ports", - "OPC UA TCP Ports", - "The TCP ports for the OPC UA TCP Binary Protocol", - &global_tcp_ports_opcua, 65535); -} /** header length that is needed to compute * the pdu length. @@ -362,7 +275,7 @@ static int dissect_opcua_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * opcua_seqid, /* ID for fragments belonging together */ NULL, opcua_seqnum, /* fragment sequence number */ - tvb_length_remaining(tvb, offset), /* fragment length - to the end */ + tvb_captured_length_remaining(tvb, offset), /* fragment length - to the end */ bMoreFragments); /* More fragments? */ new_tvb = process_reassembled_data(tvb, @@ -439,7 +352,7 @@ static int dissect_opcua_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree * } } - return tvb_length(tvb); + return tvb_reported_length(tvb); } /** The main OpcUa dissector functions. @@ -450,7 +363,7 @@ static int dissect_opcua(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo { tcp_dissect_pdus(tvb, pinfo, tree, TRUE, FRAME_HEADER_LEN, get_opcua_message_len, dissect_opcua_message, data); - return tvb_length(tvb); + return tvb_reported_length(tvb); } static void register_tcp_port(guint32 port) @@ -465,6 +378,102 @@ static void unregister_tcp_port(guint32 port) dissector_delete_uint("tcp.port", port, opcua_handle); } +static void +init_opcua(void) +{ + reassembly_table_init(&opcua_reassembly_table, + &addresses_reassembly_table_functions); +} + +/** plugin entry functions. + * This registers the OpcUa protocol. + */ +void proto_register_opcua(void) +{ + char *tmp; + + static hf_register_info hf[] = + { + {&hf_opcua_fragments, + {"Message fragments", "opcua.fragments", + FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_fragment, + {"Message fragment", "opcua.fragment", + FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_fragment_overlap, + {"Message fragment overlap", "opcua.fragment.overlap", + FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_fragment_overlap_conflicts, + {"Message fragment overlapping with conflicting data", + "opcua.fragment.overlap.conflicts", + FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_fragment_multiple_tails, + {"Message has multiple tail fragments", + "opcua.fragment.multiple_tails", + FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_fragment_too_long_fragment, + {"Message fragment too long", "opcua.fragment.too_long_fragment", + FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_fragment_error, + {"Message defragmentation error", "opcua.fragment.error", + FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_fragment_count, + {"Message fragment count", "opcua.fragment.count", + FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_reassembled_in, + {"Reassembled in", "opcua.reassembled.in", + FT_FRAMENUM, BASE_NONE, NULL, 0x00, NULL, HFILL } }, + {&hf_opcua_reassembled_length, + {"Reassembled length", "opcua.reassembled.length", + FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL } } + }; + + /** Setup protocol subtree array */ + static gint *ett[] = + { + &ett_opcua_extensionobject, + &ett_opcua_nodeid, + &ett_opcua_transport, + &ett_opcua_fragment, + &ett_opcua_fragments + }; + + module_t *opcua_module; + + proto_opcua = proto_register_protocol( + "OpcUa Binary Protocol", /* name */ + "OpcUa", /* short name */ + "opcua" /* abbrev */ + ); + + registerTransportLayerTypes(proto_opcua); + registerSecurityLayerTypes(proto_opcua); + registerApplicationLayerTypes(proto_opcua); + registerSimpleTypes(proto_opcua); + registerEnumTypes(proto_opcua); + registerComplexTypes(); + registerServiceTypes(); + registerFieldTypes(proto_opcua); + + proto_register_subtree_array(ett, array_length(ett)); + + tmp = g_strdup_printf("%d", OPCUA_PORT); + range_convert_str(&global_tcp_ports_opcua, tmp, 65535); + g_free(tmp); + + proto_register_field_array(proto_opcua, hf, array_length(hf)); + + register_init_routine(&init_opcua); + + /* register user preferences */ + opcua_module = prefs_register_protocol(proto_opcua, proto_reg_handoff_opcua); + prefs_register_range_preference(opcua_module, "tcp_ports", + "OPC UA TCP Ports", + "The TCP ports for the OPC UA TCP Binary Protocol", + &global_tcp_ports_opcua, 65535); + +} + void proto_reg_handoff_opcua(void) { static gboolean opcua_initialized = FALSE; |