2 * Routines for DDTP (Dynamic DNS Tools Protocol) packet disassembly
3 * see http://ddt.sourceforge.net/
4 * Olivier Abad <oabad@noos.fr>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include <epan/expert.h>
18 #define DDTP_VERSION_ERROR 0
19 #define DDTP_VERSION_4 1
20 #define DDTP_VERSION_5 2
22 #define DDTP_ENCRYPT_ERROR 0
23 #define DDTP_ENCRYPT_PLAINTEXT 1
24 #define DDTP_ENCRYPT_BLOWFISH 2
26 #define DDTP_MESSAGE_ERROR 0
27 #define DDTP_UPDATE_QUERY 1
28 #define DDTP_UPDATE_REPLY 2
29 #define DDTP_ALIVE_QUERY 3
30 #define DDTP_ALIVE_REPLY 4
32 #define DDTP_MARK_ONLINE 0
33 #define DDTP_MARK_OFFLINE 1
35 #define DDTP_UPDATE_SUCCEEDED 0
36 #define DDTP_UPDATE_FAILED 1
37 #define DDTP_INVALID_PASSWORD 2
38 #define DDTP_INVALID_ACCOUNT 3
39 #define DDTP_INVALID_OPCODE 4
41 void proto_register_ddtp (void);
42 void proto_reg_handoff_ddtp (void);
44 static dissector_handle_t ddtp_handle
;
46 static int proto_ddtp
;
47 static int hf_ddtp_version
;
48 static int hf_ddtp_encrypt
;
49 static int hf_ddtp_hostid
;
50 static int hf_ddtp_msgtype
;
51 static int hf_ddtp_opcode
;
52 static int hf_ddtp_ipaddr
;
53 static int hf_ddtp_status
;
54 static int hf_ddtp_alive
;
58 static expert_field ei_ddtp_msgtype
;
60 #define UDP_PORT_DDTP 1052
63 * XXX - is 0 an invalid value? If so, should we remove it from this
64 * list, so that putative DDNS packets with a version number of 0 are
67 static const value_string vals_ddtp_version
[] = {
68 { DDTP_VERSION_ERROR
, "Protocol Error" },
69 { DDTP_VERSION_4
, "4" },
70 { DDTP_VERSION_5
, "5" },
74 static const value_string vals_ddtp_encrypt
[] = {
75 { DDTP_ENCRYPT_ERROR
, "Encryption Error" },
76 { DDTP_ENCRYPT_PLAINTEXT
, "Plain text" },
77 { DDTP_ENCRYPT_BLOWFISH
, "Blowfish" },
81 static const value_string vals_ddtp_msgtype
[] = {
82 { DDTP_MESSAGE_ERROR
, "Message Error" },
83 { DDTP_UPDATE_QUERY
, "Update Query" },
84 { DDTP_UPDATE_REPLY
, "Update Reply" },
85 { DDTP_ALIVE_QUERY
, "Alive Query" },
86 { DDTP_ALIVE_REPLY
, "Alive Reply" },
90 static const value_string vals_ddtp_opcode
[] = {
91 { DDTP_MARK_ONLINE
, "Mark online" },
92 { DDTP_MARK_OFFLINE
, "Mark offline" },
96 static const value_string vals_ddtp_status
[] = {
97 { DDTP_UPDATE_SUCCEEDED
, "Update succeeded" },
98 { DDTP_UPDATE_FAILED
, "Update failed" },
99 { DDTP_INVALID_PASSWORD
, "Invalid password" },
100 { DDTP_INVALID_ACCOUNT
, "Invalid account" },
101 { DDTP_INVALID_OPCODE
, "Invalid opcode" },
106 dissect_ddtp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
108 proto_tree
*ddtp_tree
;
112 * If we don't recognize the version number, don't dissect this.
114 if (tvb_reported_length(tvb
) < 4)
117 if (try_val_to_str(tvb_get_ntohl(tvb
, 0), vals_ddtp_version
) == NULL
)
120 /* Indicate what kind of message this is. */
121 col_set_str (pinfo
->cinfo
, COL_PROTOCOL
, "DDTP");
122 /* In case we throw an exception below. */
123 col_clear (pinfo
->cinfo
, COL_INFO
);
125 ti
= proto_tree_add_item(tree
, proto_ddtp
, tvb
, 0, -1, ENC_NA
);
126 ddtp_tree
= proto_item_add_subtree(ti
, ett_ddtp
);
128 proto_tree_add_item(ddtp_tree
, hf_ddtp_version
, tvb
, 0, 4, ENC_BIG_ENDIAN
);
129 proto_tree_add_item(ddtp_tree
, hf_ddtp_encrypt
, tvb
, 4, 4, ENC_BIG_ENDIAN
);
130 proto_tree_add_item(ddtp_tree
, hf_ddtp_hostid
, tvb
, 8, 4, ENC_BIG_ENDIAN
);
132 if (tvb_get_ntohl(tvb
, 4) == DDTP_ENCRYPT_PLAINTEXT
) {
133 ti
= proto_tree_add_item(ddtp_tree
, hf_ddtp_msgtype
, tvb
, 12, 4, ENC_BIG_ENDIAN
);
134 switch (tvb_get_ntohl(tvb
, 12)) {
135 case DDTP_MESSAGE_ERROR
:
136 col_set_str(pinfo
->cinfo
, COL_INFO
, "Message Error");
138 case DDTP_UPDATE_QUERY
:
139 col_set_str(pinfo
->cinfo
, COL_INFO
, "Update Query");
140 proto_tree_add_item(ddtp_tree
, hf_ddtp_opcode
, tvb
, 16, 4, ENC_BIG_ENDIAN
);
141 proto_tree_add_item(ddtp_tree
, hf_ddtp_ipaddr
, tvb
, 20, 4, ENC_BIG_ENDIAN
);
143 case DDTP_UPDATE_REPLY
:
144 col_set_str(pinfo
->cinfo
, COL_INFO
, "Update Reply");
145 proto_tree_add_item(ddtp_tree
, hf_ddtp_status
, tvb
, 16, 4, ENC_BIG_ENDIAN
);
147 case DDTP_ALIVE_QUERY
:
148 col_set_str(pinfo
->cinfo
, COL_INFO
, "Alive Query");
149 proto_tree_add_item(ddtp_tree
, hf_ddtp_alive
, tvb
, 16, 4, ENC_BIG_ENDIAN
);
151 case DDTP_ALIVE_REPLY
:
152 col_set_str(pinfo
->cinfo
, COL_INFO
, "Alive Reply");
153 proto_tree_add_item(ddtp_tree
, hf_ddtp_alive
, tvb
, 16, 4, ENC_BIG_ENDIAN
);
156 col_set_str(pinfo
->cinfo
, COL_INFO
, "Unknown type");
157 expert_add_info(pinfo
, ti
, &ei_ddtp_msgtype
);
160 col_set_str(pinfo
->cinfo
, COL_INFO
, "Encrypted payload");
162 return tvb_reported_length(tvb
);
166 proto_register_ddtp(void)
168 static hf_register_info hf_ddtp
[] = {
170 { "Version", "ddtp.version", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_version
), 0x0,
173 { "Encryption", "ddtp.encrypt", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_encrypt
), 0x0,
174 "Encryption type", HFILL
}},
176 { "Hostid", "ddtp.hostid", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
179 { "Message type", "ddtp.msgtype", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_msgtype
), 0x0,
182 { "Opcode", "ddtp.opcode", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_opcode
), 0x0,
183 "Update query opcode", HFILL
}},
185 { "IP address", "ddtp.ipaddr", FT_IPv4
, BASE_NONE
, NULL
, 0x0,
188 { "Status", "ddtp.status", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_status
), 0x0,
189 "Update reply status", HFILL
}},
191 { "Dummy", "ddtp.alive", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
195 static int *ett
[] = { &ett_ddtp
};
197 static ei_register_info ei
[] = {
198 { &ei_ddtp_msgtype
, { "ddtp.msgtype.unknown", PI_PROTOCOL
, PI_WARN
, "Unknown type", EXPFILL
}},
201 expert_module_t
* expert_ddtp
;
203 proto_ddtp
= proto_register_protocol("Dynamic DNS Tools Protocol", "DDTP", "ddtp");
204 proto_register_field_array(proto_ddtp
, hf_ddtp
, array_length(hf_ddtp
));
205 proto_register_subtree_array(ett
, array_length(ett
));
206 expert_ddtp
= expert_register_protocol(proto_ddtp
);
207 expert_register_field_array(expert_ddtp
, ei
, array_length(ei
));
209 ddtp_handle
= register_dissector("ddtp", dissect_ddtp
, proto_ddtp
);
213 proto_reg_handoff_ddtp(void)
215 dissector_add_uint_with_preference("udp.port", UDP_PORT_DDTP
, ddtp_handle
);
219 * Editor modelines - https://www.wireshark.org/tools/modelines.html
224 * indent-tabs-mode: nil
227 * vi: set shiftwidth=4 tabstop=8 expandtab:
228 * :indentSize=4:tabSize=8:noTabs=true: