2 * Routines for DDTP (Dynamic DNS Tools Protocol) packet disassembly
3 * see http://ddt.sourceforge.net/
4 * Olivier Abad <oabad@noos.fr>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/packet.h>
31 #include "packet-ddtp.h"
33 void proto_register_ddtp (void);
34 void proto_reg_handoff_ddtp (void);
36 static int proto_ddtp
= -1;
37 static int hf_ddtp_version
= -1;
38 static int hf_ddtp_encrypt
= -1;
39 static int hf_ddtp_hostid
= -1;
40 static int hf_ddtp_msgtype
= -1;
41 static int hf_ddtp_opcode
= -1;
42 static int hf_ddtp_ipaddr
= -1;
43 static int hf_ddtp_status
= -1;
45 static int ett_ddtp
= -1;
47 #define UDP_PORT_DDTP 1052
50 * XXX - is 0 an invalid value? If so, should we remove it from this
51 * list, so that putative DDNS packets with a version number of 0 are
54 static const value_string vals_ddtp_version
[] = {
55 { DDTP_VERSION_ERROR
, "Protocol Error" },
56 { DDTP_VERSION_4
, "4" },
57 { DDTP_VERSION_5
, "5" },
61 static const value_string vals_ddtp_encrypt
[] = {
62 { DDTP_ENCRYPT_ERROR
, "Encryption Error" },
63 { DDTP_ENCRYPT_PLAINTEXT
, "Plain text" },
64 { DDTP_ENCRYPT_BLOWFISH
, "Blowfish" },
68 static const value_string vals_ddtp_msgtype
[] = {
69 { DDTP_MESSAGE_ERROR
, "Message Error" },
70 { DDTP_UPDATE_QUERY
, "Update Query" },
71 { DDTP_UPDATE_REPLY
, "Update Reply" },
72 { DDTP_ALIVE_QUERY
, "Alive Query" },
73 { DDTP_ALIVE_REPLY
, "Alive Reply" },
77 static const value_string vals_ddtp_opcode
[] = {
78 { DDTP_MARK_ONLINE
, "Mark online" },
79 { DDTP_MARK_OFFLINE
, "Mark offline" },
83 static const value_string vals_ddtp_status
[] = {
84 { DDTP_UPDATE_SUCCEEDED
, "Update succeeded" },
85 { DDTP_UPDATE_FAILED
, "Update failed" },
86 { DDTP_INVALID_PASSWORD
, "Invalid password" },
87 { DDTP_INVALID_ACCOUNT
, "Invalid account" },
88 { DDTP_INVALID_OPCODE
, "Invalid opcode" },
93 dissect_ddtp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
95 proto_tree
*ddtp_tree
= NULL
;
99 * If we don't recognize the version number, don't dissect this.
101 if (tvb_length(tvb
) >= 4) {
102 if (try_val_to_str(tvb_get_ntohl(tvb
, 0), vals_ddtp_version
) == NULL
)
106 /* Indicate what kind of message this is. */
107 col_set_str (pinfo
->cinfo
, COL_PROTOCOL
, "DDTP");
108 /* In case we throw an exception below. */
109 col_clear (pinfo
->cinfo
, COL_INFO
);
112 ti
= proto_tree_add_item(tree
, proto_ddtp
, tvb
, 0, -1, ENC_NA
);
113 ddtp_tree
= proto_item_add_subtree(ti
, ett_ddtp
);
115 proto_tree_add_item(ddtp_tree
, hf_ddtp_version
, tvb
, 0, 4, ENC_BIG_ENDIAN
);
116 proto_tree_add_item(ddtp_tree
, hf_ddtp_encrypt
, tvb
, 4, 4, ENC_BIG_ENDIAN
);
117 proto_tree_add_item(ddtp_tree
, hf_ddtp_hostid
, tvb
, 8, 4, ENC_BIG_ENDIAN
);
119 if (tvb_get_ntohl(tvb
, 4) == DDTP_ENCRYPT_PLAINTEXT
) {
121 proto_tree_add_item(ddtp_tree
, hf_ddtp_msgtype
, tvb
, 12, 4, ENC_BIG_ENDIAN
);
122 switch (tvb_get_ntohl(tvb
, 12)) {
123 case DDTP_MESSAGE_ERROR
:
124 col_set_str(pinfo
->cinfo
, COL_INFO
, "Message Error");
126 case DDTP_UPDATE_QUERY
:
127 col_set_str(pinfo
->cinfo
, COL_INFO
, "Update Query");
129 proto_tree_add_item(ddtp_tree
, hf_ddtp_opcode
, tvb
, 16, 4,
131 proto_tree_add_item(ddtp_tree
, hf_ddtp_ipaddr
, tvb
, 20, 4,
135 case DDTP_UPDATE_REPLY
:
136 col_set_str(pinfo
->cinfo
, COL_INFO
, "Update Reply");
138 proto_tree_add_item(ddtp_tree
, hf_ddtp_status
, tvb
, 16, 4,
142 case DDTP_ALIVE_QUERY
:
143 col_set_str(pinfo
->cinfo
, COL_INFO
, "Alive Query");
145 proto_tree_add_text(ddtp_tree
, tvb
, 16, 4, "Dummy : %u",
146 tvb_get_ntohl(tvb
, 16));
149 case DDTP_ALIVE_REPLY
:
150 col_set_str(pinfo
->cinfo
, COL_INFO
, "Alive Reply");
152 proto_tree_add_text(ddtp_tree
, tvb
, 16, 4, "Dummy : %u",
153 tvb_get_ntohl(tvb
, 16));
157 col_set_str(pinfo
->cinfo
, COL_INFO
, "Unknown type");
159 proto_tree_add_text(ddtp_tree
, tvb
, 12, 4, "Unknown type : %u",
160 tvb_get_ntohl(tvb
, 12));
164 col_set_str(pinfo
->cinfo
, COL_INFO
, "Encrypted payload");
166 return tvb_length(tvb
);
170 proto_register_ddtp(void)
172 static hf_register_info hf_ddtp
[] = {
174 { "Version", "ddtp.version", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_version
), 0x0,
177 { "Encryption", "ddtp.encrypt", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_encrypt
), 0x0,
178 "Encryption type", HFILL
}},
180 { "Hostid", "ddtp.hostid", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
183 { "Message type", "ddtp.msgtype", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_msgtype
), 0x0,
186 { "Opcode", "ddtp.opcode", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_opcode
), 0x0,
187 "Update query opcode", HFILL
}},
189 { "IP address", "ddtp.ipaddr", FT_IPv4
, BASE_NONE
, NULL
, 0x0,
192 { "Status", "ddtp.status", FT_UINT32
, BASE_DEC
, VALS(vals_ddtp_status
), 0x0,
193 "Update reply status", HFILL
}}
196 static gint
*ett
[] = { &ett_ddtp
};
198 proto_ddtp
= proto_register_protocol("Dynamic DNS Tools Protocol",
200 proto_register_field_array(proto_ddtp
, hf_ddtp
, array_length(hf_ddtp
));
201 proto_register_subtree_array(ett
, array_length(ett
));
205 proto_reg_handoff_ddtp(void)
207 dissector_handle_t ddtp_handle
;
209 ddtp_handle
= new_create_dissector_handle(dissect_ddtp
, proto_ddtp
);
210 dissector_add_uint("udp.port", UDP_PORT_DDTP
, ddtp_handle
);