aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-iec104.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2016-05-09 20:06:33 +0200
committerJaap Keuter <jaap.keuter@xs4all.nl>2016-05-11 12:34:15 +0000
commit980f58bc277df178a15b4c730fb1b0cbd462da0b (patch)
tree68d3b119b403024496b362f118b0fbafe12e0694 /epan/dissectors/packet-iec104.c
parentaba9a5a299a07379ba6a6c42e84bfd3c4b8260ca (diff)
Create IEC401 source TCP port preference.
In order to decode IEC401 over TCP/IP it's not always the case that the source port is the default 2404. Makeing this port a preference addresses the decoding issue and src/dst determination. Bug: 12407 Change-Id: Ifaee829e014a5e0ce449d047d9e0e44c470cd2f5 Ping-Bug: 10933 Reviewed-on: https://code.wireshark.org/review/15321 Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Diffstat (limited to 'epan/dissectors/packet-iec104.c')
-rw-r--r--epan/dissectors/packet-iec104.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/epan/dissectors/packet-iec104.c b/epan/dissectors/packet-iec104.c
index dae39e3b2e..8507fbd10d 100644
--- a/epan/dissectors/packet-iec104.c
+++ b/epan/dissectors/packet-iec104.c
@@ -33,6 +33,7 @@
#include <math.h> /* floor */
#include <epan/packet.h>
+#include <epan/prefs.h>
#include <epan/expert.h>
#include "packet-tcp.h"
@@ -75,7 +76,7 @@ typedef struct {
gboolean SE; /* Select (1) / Execute (0) */
} td_CmdInfo;
-#define IEC104_PORT 2404
+static guint iec104_port = 2404;
/* Define the iec104 proto */
static int proto_iec104apci = -1;
@@ -1429,7 +1430,7 @@ static int dissect_iec104apci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
if (len <= APDU_MAX_LEN) {
wmem_strbuf_append_printf(res, "%s %s ",
- (pinfo->srcport == IEC104_PORT ? "->" : "<-"),
+ (pinfo->srcport == iec104_port ? "->" : "<-"),
val_to_str_const(type, apci_types, "<ERR>"));
}
else {
@@ -1522,6 +1523,8 @@ proto_register_iec104apci(void)
&ett_apci,
};
+ module_t *iec104_module;
+
proto_iec104apci = proto_register_protocol(
"IEC 60870-5-104-Apci",
"104apci",
@@ -1529,6 +1532,13 @@ proto_register_iec104apci(void)
);
proto_register_field_array(proto_iec104apci, hf_ap, array_length(hf_ap));
proto_register_subtree_array(ett_ap, array_length(ett_ap));
+
+ iec104_module = prefs_register_protocol(proto_iec104apci, proto_reg_handoff_iec104);
+
+ prefs_register_uint_preference(iec104_module, "tcp.port",
+ "IEC104 TCP port used by source",
+ "TCP port used by source of IEC104, usually 2404",
+ 10, &iec104_port);
}
@@ -1854,12 +1864,22 @@ proto_register_iec104asdu(void)
void
proto_reg_handoff_iec104(void)
{
- dissector_handle_t iec104apci_handle;
-
- iec104apci_handle = create_dissector_handle(dissect_iec104reas, proto_iec104apci);
- iec104asdu_handle = create_dissector_handle(dissect_iec104asdu, proto_iec104asdu);
+ static dissector_handle_t iec104apci_handle;
+ static gboolean iec104_prefs_initialized = FALSE;
+ static guint saved_iec104_port;
+
+ if (!iec104_prefs_initialized) {
+ iec104apci_handle = create_dissector_handle(dissect_iec104reas, proto_iec104apci);
+ iec104asdu_handle = create_dissector_handle(dissect_iec104asdu, proto_iec104asdu);
+ dissector_add_uint("tcp.port", iec104_port, iec104apci_handle);
+ } else {
+ dissector_delete_uint("tcp.port", saved_iec104_port, iec104apci_handle);
+ }
- dissector_add_uint("tcp.port", IEC104_PORT, iec104apci_handle);
+ saved_iec104_port = iec104_port;
+ if (iec104_port != 0) {
+ dissector_add_uint("tcp.port", iec104_port, iec104apci_handle);
+ }
}
/*