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 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <epan/packet.h>
28 #include <epan/expert.h>
30 #define DDTP_VERSION_ERROR 0
31 #define DDTP_VERSION_4 1
32 #define DDTP_VERSION_5 2
34 #define DDTP_ENCRYPT_ERROR 0
35 #define DDTP_ENCRYPT_PLAINTEXT 1
36 #define DDTP_ENCRYPT_BLOWFISH 2
38 #define DDTP_MESSAGE_ERROR 0
39 #define DDTP_UPDATE_QUERY 1
40 #define DDTP_UPDATE_REPLY 2
41 #define DDTP_ALIVE_QUERY 3
42 #define DDTP_ALIVE_REPLY 4
44 #define DDTP_MARK_ONLINE 0
45 #define DDTP_MARK_OFFLINE 1
47 #define DDTP_UPDATE_SUCCEEDED 0
48 #define DDTP_UPDATE_FAILED 1
49 #define DDTP_INVALID_PASSWORD 2
50 #define DDTP_INVALID_ACCOUNT 3
51 #define DDTP_INVALID_OPCODE 4
53 void proto_register_ddtp (void);
54 void proto_reg_handoff_ddtp (void);
56 static int proto_ddtp = -1;
57 static int hf_ddtp_version = -1;
58 static int hf_ddtp_encrypt = -1;
59 static int hf_ddtp_hostid = -1;
60 static int hf_ddtp_msgtype = -1;
61 static int hf_ddtp_opcode = -1;
62 static int hf_ddtp_ipaddr = -1;
63 static int hf_ddtp_status = -1;
64 static int hf_ddtp_alive = -1;
66 static int ett_ddtp = -1;
68 static expert_field ei_ddtp_msgtype = EI_INIT;
70 #define UDP_PORT_DDTP 1052
73 * XXX - is 0 an invalid value? If so, should we remove it from this
74 * list, so that putative DDNS packets with a version number of 0 are
77 static const value_string vals_ddtp_version[] = {
78 { DDTP_VERSION_ERROR, "Protocol Error" },
79 { DDTP_VERSION_4, "4" },
80 { DDTP_VERSION_5, "5" },
84 static const value_string vals_ddtp_encrypt[] = {
85 { DDTP_ENCRYPT_ERROR, "Encryption Error" },
86 { DDTP_ENCRYPT_PLAINTEXT, "Plain text" },
87 { DDTP_ENCRYPT_BLOWFISH, "Blowfish" },
91 static const value_string vals_ddtp_msgtype[] = {
92 { DDTP_MESSAGE_ERROR, "Message Error" },
93 { DDTP_UPDATE_QUERY, "Update Query" },
94 { DDTP_UPDATE_REPLY, "Update Reply" },
95 { DDTP_ALIVE_QUERY, "Alive Query" },
96 { DDTP_ALIVE_REPLY, "Alive Reply" },
100 static const value_string vals_ddtp_opcode[] = {
101 { DDTP_MARK_ONLINE, "Mark online" },
102 { DDTP_MARK_OFFLINE, "Mark offline" },
106 static const value_string vals_ddtp_status[] = {
107 { DDTP_UPDATE_SUCCEEDED, "Update succeeded" },
108 { DDTP_UPDATE_FAILED, "Update failed" },
109 { DDTP_INVALID_PASSWORD, "Invalid password" },
110 { DDTP_INVALID_ACCOUNT, "Invalid account" },
111 { DDTP_INVALID_OPCODE, "Invalid opcode" },
116 dissect_ddtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
118 proto_tree *ddtp_tree;
122 * If we don't recognize the version number, don't dissect this.
124 if (tvb_reported_length(tvb) < 4)
127 if (try_val_to_str(tvb_get_ntohl(tvb, 0), vals_ddtp_version) == NULL)
130 /* Indicate what kind of message this is. */
131 col_set_str (pinfo->cinfo, COL_PROTOCOL, "DDTP");
132 /* In case we throw an exception below. */
133 col_clear (pinfo->cinfo, COL_INFO);
135 ti = proto_tree_add_item(tree, proto_ddtp, tvb, 0, -1, ENC_NA);
136 ddtp_tree = proto_item_add_subtree(ti, ett_ddtp);
138 proto_tree_add_item(ddtp_tree, hf_ddtp_version, tvb, 0, 4, ENC_BIG_ENDIAN);
139 proto_tree_add_item(ddtp_tree, hf_ddtp_encrypt, tvb, 4, 4, ENC_BIG_ENDIAN);
140 proto_tree_add_item(ddtp_tree, hf_ddtp_hostid, tvb, 8, 4, ENC_BIG_ENDIAN);
142 if (tvb_get_ntohl(tvb, 4) == DDTP_ENCRYPT_PLAINTEXT) {
143 ti = proto_tree_add_item(ddtp_tree, hf_ddtp_msgtype, tvb, 12, 4, ENC_BIG_ENDIAN);
144 switch (tvb_get_ntohl(tvb, 12)) {
145 case DDTP_MESSAGE_ERROR :
146 col_set_str(pinfo->cinfo, COL_INFO, "Message Error");
148 case DDTP_UPDATE_QUERY :
149 col_set_str(pinfo->cinfo, COL_INFO, "Update Query");
150 proto_tree_add_item(ddtp_tree, hf_ddtp_opcode, tvb, 16, 4, ENC_BIG_ENDIAN);
151 proto_tree_add_item(ddtp_tree, hf_ddtp_ipaddr, tvb, 20, 4, ENC_BIG_ENDIAN);
153 case DDTP_UPDATE_REPLY :
154 col_set_str(pinfo->cinfo, COL_INFO, "Update Reply");
155 proto_tree_add_item(ddtp_tree, hf_ddtp_status, tvb, 16, 4, ENC_BIG_ENDIAN);
157 case DDTP_ALIVE_QUERY :
158 col_set_str(pinfo->cinfo, COL_INFO, "Alive Query");
159 proto_tree_add_item(ddtp_tree, hf_ddtp_alive, tvb, 16, 4, ENC_BIG_ENDIAN);
161 case DDTP_ALIVE_REPLY :
162 col_set_str(pinfo->cinfo, COL_INFO, "Alive Reply");
163 proto_tree_add_item(ddtp_tree, hf_ddtp_alive, tvb, 16, 4, ENC_BIG_ENDIAN);
166 col_set_str(pinfo->cinfo, COL_INFO, "Unknown type");
167 expert_add_info(pinfo, ti, &ei_ddtp_msgtype);
170 col_set_str(pinfo->cinfo, COL_INFO, "Encrypted payload");
172 return tvb_reported_length(tvb);
176 proto_register_ddtp(void)
178 static hf_register_info hf_ddtp[] = {
180 { "Version", "ddtp.version", FT_UINT32, BASE_DEC, VALS(vals_ddtp_version), 0x0,
183 { "Encryption", "ddtp.encrypt", FT_UINT32, BASE_DEC, VALS(vals_ddtp_encrypt), 0x0,
184 "Encryption type", HFILL }},
186 { "Hostid", "ddtp.hostid", FT_UINT32, BASE_DEC, NULL, 0x0,
189 { "Message type", "ddtp.msgtype", FT_UINT32, BASE_DEC, VALS(vals_ddtp_msgtype), 0x0,
192 { "Opcode", "ddtp.opcode", FT_UINT32, BASE_DEC, VALS(vals_ddtp_opcode), 0x0,
193 "Update query opcode", HFILL }},
195 { "IP address", "ddtp.ipaddr", FT_IPv4, BASE_NONE, NULL, 0x0,
198 { "Status", "ddtp.status", FT_UINT32, BASE_DEC, VALS(vals_ddtp_status), 0x0,
199 "Update reply status", HFILL }},
201 { "Dummy", "ddtp.alive", FT_UINT32, BASE_DEC, NULL, 0x0,
205 static gint *ett[] = { &ett_ddtp };
207 static ei_register_info ei[] = {
208 { &ei_ddtp_msgtype, { "ddtp.msgtype.unknown", PI_PROTOCOL, PI_WARN, "Unknown type", EXPFILL }},
211 expert_module_t* expert_ddtp;
213 proto_ddtp = proto_register_protocol("Dynamic DNS Tools Protocol",
215 proto_register_field_array(proto_ddtp, hf_ddtp, array_length(hf_ddtp));
216 proto_register_subtree_array(ett, array_length(ett));
217 expert_ddtp = expert_register_protocol(proto_ddtp);
218 expert_register_field_array(expert_ddtp, ei, array_length(ei));
222 proto_reg_handoff_ddtp(void)
224 dissector_handle_t ddtp_handle;
226 ddtp_handle = new_create_dissector_handle(dissect_ddtp, proto_ddtp);
227 dissector_add_uint("udp.port", UDP_PORT_DDTP, ddtp_handle);
231 * Editor modelines - http://www.wireshark.org/tools/modelines.html
236 * indent-tabs-mode: nil
239 * vi: set shiftwidth=4 tabstop=8 expandtab:
240 * :indentSize=4:tabSize=8:noTabs=true: