epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / packet-uftp.c
blob07ae3cedc0ee61e9b664be8e641cf13515e82518
1 /* packet-uftp.c
2 * Routines for UFTP packet dissection
3 * Copyright Dennis Bush <bush@tcnj.edu>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/expert.h>
17 #define UFTP_VER_NUM 0x31
18 #define UFTP_3_0_VER 0x30
20 #define ANNOUNCE 1
21 #define REGISTER 2
22 #define CLIENT_KEY 3
23 #define REG_CONF 4
24 #define FILEINFO 5
25 #define KEYINFO 6
26 #define INFO_ACK 7
27 #define FILESEG 8
28 #define DONE 9
29 #define STATUS 10
30 #define PRSTATUS 11
31 #define COMPLETE 12
32 #define DONE_CONF 13
33 #define HB_REQ 14
34 #define HB_RESP 15
35 #define KEY_REQ 16
36 #define PROXY_KEY 17
37 #define ENCRYPTED 80
38 #define ABORT 99
40 #define MAXDEST 10000
41 #define MAXFILENAME 100
42 #define MAXDIRNAME 200
43 #define MAXPATHNAME 300
44 #define MAXPROXYDEST 1000
46 #define DESTNAME_LEN 100
47 #define MAXFILES 500
48 #define IFNAME_LEN 25
49 #define MAX_INTERFACES 20
50 #define IPSTR_LEN 16
52 #define FTYPE_REG 0
53 #define FTYPE_DIR 1
54 #define FTYPE_LINK 2
56 #define KEY_NONE 0x00
57 #define KEY_DES 0x01
58 #define KEY_DES_EDE3 0x02
59 #define KEY_AES128 0x03
60 #define KEY_AES256 0x04
62 #define HASH_NONE 0x00
63 #define HASH_MD5 0x01
64 #define HASH_SHA1 0x02
65 #define HASH_SHA256 0x03
67 #define SIG_NONE 0x00
68 #define SIG_HMAC 0x01
69 #define SIG_RSA 0x02
71 #define FLAG_RESTART 0x01
72 #define FLAG_SYNC_MODE 0x02
73 #define FLAG_SYNC_PREVIEW 0x04
74 #define FLAG_ANNOUNCE_RESERVED 0xF8
76 #define FLAG_PARTIAL 0x01
77 #define FLAG_INFOACK_RESERVED 0xFE
79 #define FLAG_CURRENT_FILE 0x01
80 #define FLAG_ABORT_RESERVED 0xFE
82 #define COMP_STAT_NORMAL 0
83 #define COMP_STAT_SKIPPED 1
84 #define COMP_STAT_OVERWRITE 2
85 #define COMP_STAT_REJECTED 3
87 #define HB_AUTH_FAILED 0
88 #define HB_AUTH_OK 1
89 #define HB_AUTH_CHALLENGE 2
91 #define PUBKEY_LEN 256 /* big enough for RSA-2048 */
92 #define RAND_LEN 32 /* rfc 5246 */
93 #define HMAC_LEN 32 /* big enough for SHA-256 */
94 #define VERIFY_LEN 12 /* rfc 5246 */
95 #define MASTER_LEN 48 /* rfc 5246 */
96 #define MAXIV 16 /* big enough for AES256 */
97 #define MAXKEY 32 /* big enough for AES256 */
98 #define KEYBLSIZE 16 /* Maximum symetric key blocksize */
99 #define DEF_RSA_LEN 512 /* Default length of generated RSA keys */
100 #define RSA_EXP 65537 /* Public key exponent of generated RSA keys */
102 #define UFTP_LEN 16
103 #define ANNOUNCE_LEN 64
104 #define REGISTER_LEN 40
105 #define CLIENT_KEY_LEN 12
106 #define REG_CONF_LEN 4
107 #define FILEINFO_LEN 324
108 #define FILEINFO_30_LEN 320
109 #define KEYINFO_LEN 12
110 #define DESTKEY_LEN 52
111 #define INFO_ACK_LEN 20
112 #define FILESEG_LEN 12
113 #define DONE_LEN 8
114 #define STATUS_LEN 12
115 #define PRSTATUS_LEN 12
116 #define COMPLETE_LEN 8
117 #define DONE_CONF_LEN 8
118 #define HB_REQ_LEN 16
119 #define HB_RESP_LEN 8
120 #define KEY_REQ_LEN 4
121 #define PROXY_KEY_LEN 16
122 #define ENCRYPTED_LEN 12
123 #define ABORT_LEN 308
125 void proto_register_uftp(void);
126 void proto_reg_handoff_uftp(void);
128 static dissector_handle_t uftp_handle;
130 static int proto_uftp;
131 #define UFTP_PORT 1044 /* Not IANA registered */
133 /* main header and common fields */
134 static int hf_uftp_version;
135 static int hf_uftp_func;
136 static int hf_uftp_blsize;
137 static int hf_uftp_group_id;
138 static int hf_uftp_srcaddr;
139 static int hf_uftp_destaddr;
141 static int hf_uftp_destlist;
142 static int hf_uftp_dest;
144 /* ANNOUNCE fields */
145 static int hf_uftp_announce;
146 static int hf_uftp_announce_func;
147 static int hf_uftp_announce_flags;
148 static int hf_uftp_announce_flags_restart;
149 static int hf_uftp_announce_flags_sync;
150 static int hf_uftp_announce_flags_syncpreview;
151 static int hf_uftp_announce_flags_reserved;
152 static int hf_uftp_announce_destcount;
153 static int hf_uftp_announce_announce_int;
154 static int hf_uftp_announce_status_int;
155 static int hf_uftp_announce_register_int;
156 static int hf_uftp_announce_done_int;
157 static int hf_uftp_announce_announce_time;
158 static int hf_uftp_announce_status_time;
159 static int hf_uftp_announce_mtu;
160 static int hf_uftp_announce_privatemcast;
161 static int hf_uftp_announce_client_auth;
162 static int hf_uftp_announce_sigtype;
163 static int hf_uftp_announce_hashtype;
164 static int hf_uftp_announce_keytype;
165 static int hf_uftp_announce_keylen;
166 static int hf_uftp_announce_reserved;
167 static int hf_uftp_announce_keyexp;
168 static int hf_uftp_announce_rand1;
169 static int hf_uftp_announce_keymod;
171 /* REGISTER fields */
172 static int hf_uftp_register;
173 static int hf_uftp_register_func;
174 static int hf_uftp_register_reserved;
175 static int hf_uftp_register_destcount;
176 static int hf_uftp_register_premaster_len;
177 static int hf_uftp_register_rand2;
178 static int hf_uftp_register_premaster;
180 /* CLIENT_KEY fields */
181 static int hf_uftp_clientkey;
182 static int hf_uftp_clientkey_func;
183 static int hf_uftp_clientkey_reserved;
184 static int hf_uftp_clientkey_keylen;
185 static int hf_uftp_clientkey_verifylen;
186 static int hf_uftp_clientkey_keyexp;
187 static int hf_uftp_clientkey_keymod;
188 static int hf_uftp_clientkey_verify;
190 /* REG_CONF fields */
191 static int hf_uftp_regconf;
192 static int hf_uftp_regconf_func;
193 static int hf_uftp_regconf_reserved;
194 static int hf_uftp_regconf_destcount;
196 /* FILEINFO fields */
197 static int hf_uftp_fileinfo;
198 static int hf_uftp_fileinfo_func;
199 static int hf_uftp_fileinfo_ftype;
200 static int hf_uftp_fileinfo_file_id;
201 static int hf_uftp_fileinfo_block_total;
202 static int hf_uftp_fileinfo_section_total;
203 static int hf_uftp_fileinfo_destcount;
204 static int hf_uftp_fileinfo_fsize;
205 static int hf_uftp_fileinfo_ftstamp;
206 static int hf_uftp_fileinfo_name;
208 /* KEYINFO fields */
209 static int hf_uftp_keyinfo;
210 static int hf_uftp_keyinfo_func;
211 static int hf_uftp_keyinfo_reserved;
212 static int hf_uftp_keyinfo_destcount;
213 static int hf_uftp_keyinfo_groupmaster_len;
214 static int hf_uftp_keyinfo_tstamp;
215 static int hf_uftp_keyinfo_destkey;
216 static int hf_uftp_keyinfo_destaddr;
217 static int hf_uftp_keyinfo_groupmaster;
219 /* INFO_ACK fields */
220 static int hf_uftp_infoack;
221 static int hf_uftp_infoack_func;
222 static int hf_uftp_infoack_flags;
223 static int hf_uftp_infoack_flags_partial;
224 static int hf_uftp_infoack_flags_reserved;
225 static int hf_uftp_infoack_file_id;
226 static int hf_uftp_infoack_destcount;
227 static int hf_uftp_infoack_reserved;
228 static int hf_uftp_infoack_verify_data;
230 /* FILESEG fields */
231 static int hf_uftp_fileseg;
232 static int hf_uftp_fileseg_func;
233 static int hf_uftp_fileseg_reserved1;
234 static int hf_uftp_fileseg_file_id;
235 static int hf_uftp_fileseg_pass;
236 static int hf_uftp_fileseg_reserved2;
237 static int hf_uftp_fileseg_section;
238 static int hf_uftp_fileseg_seq_num;
239 static int hf_uftp_fileseg_data;
241 /* DONE fields */
242 static int hf_uftp_done;
243 static int hf_uftp_done_func;
244 static int hf_uftp_done_pass;
245 static int hf_uftp_done_section;
246 static int hf_uftp_done_file_id;
247 static int hf_uftp_done_destcount;
249 /* STATUS fields */
250 static int hf_uftp_status;
251 static int hf_uftp_status_func;
252 static int hf_uftp_status_reserved;
253 static int hf_uftp_status_file_id;
254 static int hf_uftp_status_pass;
255 static int hf_uftp_status_seq;
256 static int hf_uftp_status_section;
257 static int hf_uftp_status_nak_count;
258 static int hf_uftp_status_naks;
260 /* PRSTATUS fields */
261 static int hf_uftp_prstatus;
262 static int hf_uftp_prstatus_func;
263 static int hf_uftp_prstatus_reserved1;
264 static int hf_uftp_prstatus_file_id;
265 static int hf_uftp_prstatus_pass;
266 static int hf_uftp_prstatus_seq;
267 static int hf_uftp_prstatus_section;
268 static int hf_uftp_prstatus_destcount;
269 static int hf_uftp_prstatus_reserved2;
271 /* COMPLETE fields */
272 static int hf_uftp_complete;
273 static int hf_uftp_complete_func;
274 static int hf_uftp_complete_status;
275 static int hf_uftp_complete_file_id;
276 static int hf_uftp_complete_destcount;
277 static int hf_uftp_complete_reserved2;
279 /* DONE_CONF fields */
280 static int hf_uftp_doneconf;
281 static int hf_uftp_doneconf_func;
282 static int hf_uftp_doneconf_reserved1;
283 static int hf_uftp_doneconf_file_id;
284 static int hf_uftp_doneconf_destcount;
285 static int hf_uftp_doneconf_reserved2;
287 /* HB_REQ fields */
288 static int hf_uftp_hbreq;
289 static int hf_uftp_hbreq_func;
290 static int hf_uftp_hbreq_reserved;
291 static int hf_uftp_hbreq_nonce;
292 static int hf_uftp_hbreq_keylen;
293 static int hf_uftp_hbreq_siglen;
294 static int hf_uftp_hbreq_keyexp;
295 static int hf_uftp_hbreq_keymod;
296 static int hf_uftp_hbreq_verify;
298 /* HB_RESP fields */
299 static int hf_uftp_hbresp;
300 static int hf_uftp_hbresp_func;
301 static int hf_uftp_hbresp_authenticated;
302 static int hf_uftp_hbresp_reserved;
303 static int hf_uftp_hbresp_nonce;
305 /* KEY_REQ fields */
306 static int hf_uftp_keyreq;
307 static int hf_uftp_keyreq_func;
308 static int hf_uftp_keyreq_reserved;
310 /* PROXY_KEY fields */
311 static int hf_uftp_proxykey;
312 static int hf_uftp_proxykey_func;
313 static int hf_uftp_proxykey_reserved;
314 static int hf_uftp_proxykey_nonce;
315 static int hf_uftp_proxykey_keylen;
316 static int hf_uftp_proxykey_siglen;
317 static int hf_uftp_proxykey_keyexp;
318 static int hf_uftp_proxykey_keymod;
319 static int hf_uftp_proxykey_verify;
321 /* ENCRYPTED fields */
322 static int hf_uftp_encrypted;
323 static int hf_uftp_encrypted_tstamp;
324 static int hf_uftp_encrypted_sig_len;
325 static int hf_uftp_encrypted_payload_len;
326 static int hf_uftp_encrypted_signature;
327 static int hf_uftp_encrypted_payload;
329 /* ABORT fields */
330 static int hf_uftp_abort;
331 static int hf_uftp_abort_func;
332 static int hf_uftp_abort_flags;
333 static int hf_uftp_abort_flags_curfile;
334 static int hf_uftp_abort_flags_reserved;
335 static int hf_uftp_abort_reserved;
336 static int hf_uftp_abort_host;
337 static int hf_uftp_abort_message;
339 static int ett_uftp;
340 static int ett_uftp_announce;
341 static int ett_uftp_register;
342 static int ett_uftp_clientkey;
343 static int ett_uftp_regconf;
344 static int ett_uftp_fileinfo;
345 static int ett_uftp_keyinfo;
346 static int ett_uftp_infoack;
347 static int ett_uftp_fileseg;
348 static int ett_uftp_done;
349 static int ett_uftp_status;
350 static int ett_uftp_prstatus;
351 static int ett_uftp_complete;
352 static int ett_uftp_doneconf;
353 static int ett_uftp_hbreq;
354 static int ett_uftp_hbresp;
355 static int ett_uftp_keyreq;
356 static int ett_uftp_proxykey;
357 static int ett_uftp_encrypted;
358 static int ett_uftp_abort;
360 static int ett_uftp_announce_flags;
361 static int ett_uftp_keyinfo_destkey;
362 static int ett_uftp_infoack_flags;
363 static int ett_uftp_abort_flags;
365 static int ett_uftp_destlist;
367 static expert_field ei_uftp_length_invalid;
368 static expert_field ei_uftp_func_unknown;
370 static dissector_handle_t uftp4_handle;
371 static dissector_handle_t uftp5_handle;
373 static const value_string messages[] = {
374 { ANNOUNCE, "ANNOUNCE" },
375 { REGISTER, "REGISTER" },
376 { CLIENT_KEY, "CLIENT_KEY" },
377 { REG_CONF, "REG_CONF" },
378 { FILEINFO, "FILEINFO" },
379 { KEYINFO, "KEYINFO" },
380 { INFO_ACK, "INFO_ACK" },
381 { FILESEG, "FILESEG" },
382 { DONE, "DONE" },
383 { STATUS, "STATUS" },
384 { PRSTATUS, "PRSTATUS" },
385 { COMPLETE, "COMPLETE" },
386 { DONE_CONF, "DONE_CONF" },
387 { HB_REQ, "HB_REQ" },
388 { HB_RESP, "HB_RESP" },
389 { KEY_REQ, "KEY_REQ" },
390 { PROXY_KEY, "PROXY_KEY" },
391 { ENCRYPTED, "ENCRYPTED" },
392 { ABORT, "ABORT" },
393 { 0, NULL }
396 static const value_string signature_types[] = {
397 { SIG_NONE, "NONE" },
398 { SIG_HMAC, "HMAC" },
399 { SIG_RSA, "RSA" },
400 { 0, NULL }
403 static const value_string hash_types[] = {
404 { HASH_NONE, "NONE" },
405 { HASH_MD5, "MD5" },
406 { HASH_SHA1, "SHA-1" },
407 { HASH_SHA256, "SHA-256" },
408 { 0, NULL }
411 static const value_string key_types[] = {
412 { KEY_NONE, "NONE" },
413 { KEY_DES, "DES" },
414 { KEY_DES_EDE3, "3 Key Triple DES" },
415 { KEY_AES128, "AES-128" },
416 { KEY_AES256, "AES-256" },
417 { 0, NULL }
420 static const value_string hb_auth_types[] = {
421 { HB_AUTH_FAILED, "Authorization Failed" },
422 { HB_AUTH_OK, "Authorization Succeeded" },
423 { HB_AUTH_CHALLENGE, "Authorization Required" },
424 { 0, NULL }
427 static const value_string file_types[] = {
428 { FTYPE_REG, "Regular file" },
429 { FTYPE_DIR, "Directory" },
430 { FTYPE_LINK, "Symbolic link" },
431 { 0, NULL }
434 static int * const announce_flags[] = {
435 &hf_uftp_announce_flags_restart,
436 &hf_uftp_announce_flags_sync,
437 &hf_uftp_announce_flags_syncpreview,
438 &hf_uftp_announce_flags_reserved,
439 NULL
442 static int * const infoack_flags[] = {
443 &hf_uftp_infoack_flags_partial,
444 &hf_uftp_infoack_flags_reserved,
445 NULL
448 static int * const abort_flags[] = {
449 &hf_uftp_abort_flags_curfile,
450 &hf_uftp_abort_flags_reserved,
451 NULL
454 static const value_string comp_status[] = {
455 { COMP_STAT_NORMAL, "Normal" },
456 { COMP_STAT_SKIPPED, "Skipped" },
457 { COMP_STAT_OVERWRITE, "Overwrite" },
458 { COMP_STAT_REJECTED, "Rejected" },
459 { 0, NULL }
462 static void dissect_uftp_announce(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
464 proto_item *ti = NULL;
465 proto_item *destlist = NULL;
466 proto_tree *announce_tree = NULL;
467 proto_tree *destlist_tree = NULL;
468 int offset = 0;
469 uint16_t destcount, keylen, idx;
471 if (tvb_reported_length(tvb) < ANNOUNCE_LEN) {
472 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
473 "Invalid length: %d", tvb_reported_length(tvb));
474 return;
477 destcount = tvb_get_ntohs(tvb, 2);
478 keylen = tvb_get_ntohs(tvb, 24);
479 if ((int)tvb_reported_length(tvb) < ANNOUNCE_LEN + keylen + (destcount * 4)) {
480 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
481 "Invalid length, len = %d, keylen = %d, count=%d",
482 tvb_reported_length(tvb), keylen, destcount);
483 return;
486 ti = proto_tree_add_item(tree, hf_uftp_announce, tvb, offset, -1, ENC_NA);
487 announce_tree = proto_item_add_subtree(ti, ett_uftp_announce);
488 proto_tree_add_item(announce_tree, hf_uftp_announce_func, tvb, offset, 1, ENC_BIG_ENDIAN);
489 offset += 1;
490 proto_tree_add_bitmask(announce_tree, tvb, offset, hf_uftp_announce_flags, ett_uftp_announce_flags, announce_flags, ENC_BIG_ENDIAN);
491 offset += 1;
492 proto_tree_add_item(announce_tree, hf_uftp_announce_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
493 offset += 2;
494 proto_tree_add_item(announce_tree, hf_uftp_announce_announce_int, tvb, offset, 2, ENC_BIG_ENDIAN);
495 offset += 2;
496 proto_tree_add_item(announce_tree, hf_uftp_announce_status_int, tvb, offset, 2, ENC_BIG_ENDIAN);
497 offset += 2;
498 proto_tree_add_item(announce_tree, hf_uftp_announce_register_int, tvb, offset, 2, ENC_BIG_ENDIAN);
499 offset += 2;
500 proto_tree_add_item(announce_tree, hf_uftp_announce_done_int, tvb, offset, 2, ENC_BIG_ENDIAN);
501 offset += 2;
502 proto_tree_add_item(announce_tree, hf_uftp_announce_announce_time, tvb, offset, 1, ENC_BIG_ENDIAN);
503 offset += 1;
504 proto_tree_add_item(announce_tree, hf_uftp_announce_status_time, tvb, offset, 1, ENC_BIG_ENDIAN);
505 offset += 1;
506 proto_tree_add_item(announce_tree, hf_uftp_announce_mtu, tvb, offset, 2, ENC_BIG_ENDIAN);
507 offset += 2;
508 proto_tree_add_item(announce_tree, hf_uftp_announce_privatemcast, tvb, offset, 4, ENC_BIG_ENDIAN);
509 offset += 4;
510 proto_tree_add_item(announce_tree, hf_uftp_announce_client_auth, tvb, offset, 1, ENC_BIG_ENDIAN);
511 offset += 1;
512 proto_tree_add_item(announce_tree, hf_uftp_announce_sigtype, tvb, offset, 1, ENC_BIG_ENDIAN);
513 offset += 1;
514 proto_tree_add_item(announce_tree, hf_uftp_announce_hashtype, tvb, offset, 1, ENC_BIG_ENDIAN);
515 offset += 1;
516 proto_tree_add_item(announce_tree, hf_uftp_announce_keytype, tvb, offset, 1, ENC_BIG_ENDIAN);
517 offset += 1;
518 proto_tree_add_item(announce_tree, hf_uftp_announce_keylen, tvb, offset, 2, ENC_BIG_ENDIAN);
519 offset += 2;
520 proto_tree_add_item(announce_tree, hf_uftp_announce_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
521 offset += 2;
522 proto_tree_add_item(announce_tree, hf_uftp_announce_keyexp, tvb, offset, 4, ENC_BIG_ENDIAN);
523 offset += 4;
524 proto_tree_add_item(announce_tree, hf_uftp_announce_rand1, tvb, offset, RAND_LEN, ENC_NA);
525 offset += RAND_LEN;
526 if (keylen > 0) {
527 proto_tree_add_item(announce_tree, hf_uftp_announce_keymod, tvb, offset, keylen, ENC_NA);
528 offset += keylen;
530 if (destcount > 0) {
531 destlist = proto_tree_add_item(announce_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
532 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
534 for (idx = 0; idx < destcount; idx++) {
535 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
536 offset += 4;
540 static void dissect_uftp_register(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
542 proto_item *ti = NULL;
543 proto_item *destlist = NULL;
544 proto_tree *register_tree = NULL;
545 proto_tree *destlist_tree = NULL;
546 int offset = 0;
547 uint16_t destcount, keylen, idx;
549 if (tvb_reported_length(tvb) < REGISTER_LEN) {
550 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
551 "Invalid length: %d", tvb_reported_length(tvb));
552 return;
555 destcount = tvb_get_ntohs(tvb, 4);
556 keylen = tvb_get_ntohs(tvb, 6);
557 if ((int)tvb_reported_length(tvb) < REGISTER_LEN + keylen + (destcount * 4)) {
558 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
559 "Invalid length, len = %d, keylen = %d, count=%d",
560 tvb_reported_length(tvb), keylen, destcount);
561 return;
564 ti = proto_tree_add_item(tree, hf_uftp_register, tvb, offset, -1, ENC_NA);
565 register_tree = proto_item_add_subtree(ti, ett_uftp_register);
566 proto_tree_add_item(register_tree, hf_uftp_register_func, tvb, offset, 1, ENC_BIG_ENDIAN);
567 offset += 1;
568 proto_tree_add_item(register_tree, hf_uftp_register_reserved, tvb, offset, 3, ENC_BIG_ENDIAN);
569 offset += 3;
570 proto_tree_add_item(register_tree, hf_uftp_register_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
571 offset += 2;
572 proto_tree_add_item(register_tree, hf_uftp_register_premaster_len, tvb, offset, 2, ENC_BIG_ENDIAN);
573 offset += 2;
574 proto_tree_add_item(register_tree, hf_uftp_register_rand2, tvb, offset, RAND_LEN, ENC_NA);
575 offset += RAND_LEN;
576 if (keylen > 0) {
577 proto_tree_add_item(register_tree, hf_uftp_register_premaster, tvb, offset, keylen, ENC_NA);
578 offset += keylen;
580 if (destcount > 0) {
581 destlist = proto_tree_add_item(register_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
582 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
584 for (idx = 0; idx < destcount; idx++) {
585 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
586 offset += 4;
590 static void dissect_uftp_clientkey(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
592 proto_item *ti = NULL;
593 proto_tree *clientkey_tree = NULL;
594 int offset = 0;
595 uint16_t keylen, verifylen;
597 if (tvb_reported_length(tvb) < CLIENT_KEY_LEN) {
598 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
599 "Invalid length: %d", tvb_reported_length(tvb));
600 return;
603 keylen = tvb_get_ntohs(tvb, 4);
604 verifylen = tvb_get_ntohs(tvb, 6);
605 if ((int)tvb_reported_length(tvb) < CLIENT_KEY_LEN + keylen + verifylen) {
606 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
607 "Invalid length, len = %d, keylen=%d verifylen=%d",
608 tvb_reported_length(tvb), keylen, verifylen);
609 return;
612 ti = proto_tree_add_item(tree, hf_uftp_clientkey, tvb, offset, -1, ENC_NA);
613 clientkey_tree = proto_item_add_subtree(ti, ett_uftp_clientkey);
614 proto_tree_add_item(clientkey_tree, hf_uftp_clientkey_func, tvb, offset, 1, ENC_BIG_ENDIAN);
615 offset += 1;
616 proto_tree_add_item(clientkey_tree, hf_uftp_clientkey_reserved, tvb, offset, 3, ENC_BIG_ENDIAN);
617 offset += 3;
618 proto_tree_add_item(clientkey_tree, hf_uftp_clientkey_keylen, tvb, offset, 2, ENC_BIG_ENDIAN);
619 offset += 2;
620 proto_tree_add_item(clientkey_tree, hf_uftp_clientkey_verifylen, tvb, offset, 2, ENC_BIG_ENDIAN);
621 offset += 2;
622 proto_tree_add_item(clientkey_tree, hf_uftp_clientkey_keyexp, tvb, offset, 4, ENC_BIG_ENDIAN);
623 offset += 4;
624 if (keylen > 0) {
625 proto_tree_add_item(clientkey_tree, hf_uftp_clientkey_keymod, tvb, offset, keylen, ENC_NA);
626 offset += keylen;
628 if (verifylen > 0) {
629 proto_tree_add_item(clientkey_tree, hf_uftp_clientkey_verify, tvb, offset, verifylen, ENC_NA);
633 static void dissect_uftp_regconf(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
635 proto_item *ti = NULL;
636 proto_item *destlist = NULL;
637 proto_tree *regconf_tree = NULL;
638 proto_tree *destlist_tree = NULL;
639 int offset = 0;
640 uint16_t destcount, idx;
642 if (tvb_reported_length(tvb) < REG_CONF_LEN) {
643 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
644 "Invalid length: %d", tvb_reported_length(tvb));
645 return;
648 destcount = tvb_get_ntohs(tvb, 2);
649 if ((int)tvb_reported_length(tvb) < REG_CONF_LEN + (destcount * 4)) {
650 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
651 "Invalid length, len = %d, count=%d",
652 tvb_reported_length(tvb), destcount);
653 return;
656 ti = proto_tree_add_item(tree, hf_uftp_regconf, tvb, offset, -1, ENC_NA);
657 regconf_tree = proto_item_add_subtree(ti, ett_uftp_regconf);
658 proto_tree_add_item(regconf_tree, hf_uftp_regconf_func, tvb, offset, 1, ENC_BIG_ENDIAN);
659 offset += 1;
660 proto_tree_add_item(regconf_tree, hf_uftp_regconf_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
661 offset += 1;
662 proto_tree_add_item(regconf_tree, hf_uftp_regconf_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
663 offset += 2;
664 if (destcount > 0) {
665 destlist = proto_tree_add_item(regconf_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
666 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
668 for (idx = 0; idx < destcount; idx++) {
669 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
670 offset += 4;
674 static void dissect_uftp_fileinfo_30(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
676 proto_item *ti = NULL;
677 proto_item *destlist = NULL;
678 proto_tree *fileinfo_tree = NULL;
679 proto_tree *destlist_tree = NULL;
680 int offset = 0;
681 uint16_t file_id, destcount, idx;
683 if (tvb_reported_length(tvb) < FILEINFO_30_LEN) {
684 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
685 "Invalid length: %d", tvb_reported_length(tvb));
686 return;
689 destcount = tvb_get_ntohs(tvb, 10);
690 if ((int)tvb_reported_length(tvb) < FILEINFO_30_LEN + (destcount * 4)) {
691 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
692 "Invalid length, len = %d, count=%d",
693 tvb_reported_length(tvb), destcount);
694 return;
697 file_id = tvb_get_ntohs(tvb, 2);
698 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X", file_id);
700 ti = proto_tree_add_item(tree, hf_uftp_fileinfo, tvb, offset, -1, ENC_NA);
701 fileinfo_tree = proto_item_add_subtree(ti, ett_uftp_fileinfo);
702 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_func, tvb, offset, 1, ENC_BIG_ENDIAN);
703 offset += 1;
704 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_ftype, tvb, offset, 1, ENC_BIG_ENDIAN);
705 offset += 1;
706 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
707 offset += 2;
708 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_block_total, tvb, offset, 4, ENC_BIG_ENDIAN);
709 offset += 4;
710 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_section_total, tvb, offset, 2, ENC_BIG_ENDIAN);
711 offset += 2;
712 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
713 offset += 2;
714 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_fsize, tvb, offset, 8, ENC_BIG_ENDIAN);
715 offset += 8;
716 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_name, tvb, offset, MAXPATHNAME, ENC_ASCII);
717 offset += MAXPATHNAME;
718 if (destcount > 0) {
719 destlist = proto_tree_add_item(fileinfo_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
720 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
722 for (idx = 0; idx < destcount; idx++) {
723 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
724 offset += 4;
728 static void dissect_uftp_fileinfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
730 proto_item *ti = NULL;
731 proto_item *destlist = NULL;
732 proto_tree *fileinfo_tree = NULL;
733 proto_tree *destlist_tree = NULL;
734 int offset = 0;
735 uint16_t file_id, destcount, idx;
737 if (tvb_reported_length(tvb) < FILEINFO_LEN) {
738 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
739 "Invalid length: %d", tvb_reported_length(tvb));
740 return;
743 destcount = tvb_get_ntohs(tvb, 10);
744 if ((int)tvb_reported_length(tvb) < FILEINFO_LEN + (destcount * 4)) {
745 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
746 "Invalid length, len = %d, count=%d",
747 tvb_reported_length(tvb), destcount);
748 return;
751 file_id = tvb_get_ntohs(tvb, 2);
752 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X", file_id);
754 ti = proto_tree_add_item(tree, hf_uftp_fileinfo, tvb, offset, -1, ENC_NA);
755 fileinfo_tree = proto_item_add_subtree(ti, ett_uftp_fileinfo);
756 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_func, tvb, offset, 1, ENC_BIG_ENDIAN);
757 offset += 1;
758 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_ftype, tvb, offset, 1, ENC_BIG_ENDIAN);
759 offset += 1;
760 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
761 offset += 2;
762 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_block_total, tvb, offset, 4, ENC_BIG_ENDIAN);
763 offset += 4;
764 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_section_total, tvb, offset, 2, ENC_BIG_ENDIAN);
765 offset += 2;
766 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
767 offset += 2;
768 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_fsize, tvb, offset, 8, ENC_BIG_ENDIAN);
769 offset += 8;
770 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_ftstamp, tvb, offset, 4, ENC_BIG_ENDIAN);
771 offset += 4;
772 proto_tree_add_item(fileinfo_tree, hf_uftp_fileinfo_name, tvb, offset, MAXPATHNAME, ENC_ASCII);
773 offset += MAXPATHNAME;
774 if (destcount > 0) {
775 destlist = proto_tree_add_item(fileinfo_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
776 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
778 for (idx = 0; idx < destcount; idx++) {
779 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
780 offset += 4;
784 static void dissect_uftp_keyinfo(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
786 proto_item *ti = NULL;
787 proto_item *destlist = NULL;
788 proto_item *destkey = NULL;
789 proto_tree *keyinfo_tree = NULL;
790 proto_tree *destlist_tree = NULL;
791 proto_tree *destkey_tree = NULL;
792 int offset = 0;
793 uint8_t destcount, idx;
795 if (tvb_reported_length(tvb) < KEYINFO_LEN) {
796 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
797 "Invalid length: %d", tvb_reported_length(tvb));
798 return;
801 destcount = tvb_get_uint8(tvb, 2);
802 if ((int)tvb_reported_length(tvb) < KEYINFO_LEN + (destcount * DESTKEY_LEN)) {
803 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
804 "Invalid length, len = %d, count=%d",
805 tvb_reported_length(tvb), destcount);
806 return;
809 ti = proto_tree_add_item(tree, hf_uftp_keyinfo, tvb, offset, -1, ENC_NA);
810 keyinfo_tree = proto_item_add_subtree(ti, ett_uftp_keyinfo);
811 proto_tree_add_item(keyinfo_tree, hf_uftp_keyinfo_func, tvb, offset, 1, ENC_BIG_ENDIAN);
812 offset += 1;
813 proto_tree_add_item(keyinfo_tree, hf_uftp_keyinfo_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
814 offset += 1;
815 proto_tree_add_item(keyinfo_tree, hf_uftp_keyinfo_destcount, tvb, offset, 1, ENC_BIG_ENDIAN);
816 offset += 1;
817 proto_tree_add_item(keyinfo_tree, hf_uftp_keyinfo_groupmaster_len, tvb, offset, 1, ENC_BIG_ENDIAN);
818 offset += 1;
819 proto_tree_add_item(keyinfo_tree, hf_uftp_keyinfo_tstamp, tvb, offset, 8, ENC_NA);
820 offset += 8;
821 if (destcount > 0) {
822 destlist = proto_tree_add_item(keyinfo_tree, hf_uftp_destlist, tvb, offset, destcount * DESTKEY_LEN, ENC_NA);
823 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
825 for (idx = 0; idx < destcount; idx++) {
826 destkey = proto_tree_add_item(destlist_tree, hf_uftp_keyinfo_destkey, tvb, offset, DESTKEY_LEN, ENC_NA);
827 destkey_tree = proto_item_add_subtree(destkey, ett_uftp_keyinfo_destkey);
828 proto_tree_add_item(destkey_tree, hf_uftp_keyinfo_destaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
829 offset += 4;
830 proto_tree_add_item(destkey_tree, hf_uftp_keyinfo_groupmaster, tvb, offset, 48, ENC_NA);
831 offset += 48;
835 static void dissect_uftp_infoack(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
837 proto_item *ti = NULL;
838 proto_item *destlist = NULL;
839 proto_tree *infoack_tree = NULL;
840 proto_tree *destlist_tree = NULL;
841 int offset = 0;
842 uint16_t file_id, destcount, idx;
844 if (tvb_reported_length(tvb) < INFO_ACK_LEN) {
845 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
846 "Invalid length: %d", tvb_reported_length(tvb));
847 return;
850 destcount = tvb_get_ntohs(tvb, 4);
851 if ((int)tvb_reported_length(tvb) < INFO_ACK_LEN + (destcount * 4)) {
852 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
853 "Invalid length, len = %d, count=%d",
854 tvb_reported_length(tvb), destcount);
855 return;
858 file_id = tvb_get_ntohs(tvb, 2);
859 if (file_id > 0) {
860 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X", file_id);
863 ti = proto_tree_add_item(tree, hf_uftp_infoack, tvb, offset, -1, ENC_NA);
864 infoack_tree = proto_item_add_subtree(ti, ett_uftp_infoack);
865 proto_tree_add_item(infoack_tree, hf_uftp_infoack_func, tvb, offset, 1, ENC_BIG_ENDIAN);
866 offset += 1;
867 proto_tree_add_bitmask(infoack_tree, tvb, offset, hf_uftp_infoack_flags, ett_uftp_infoack_flags, infoack_flags, ENC_BIG_ENDIAN);
868 offset += 1;
869 proto_tree_add_item(infoack_tree, hf_uftp_infoack_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
870 offset += 2;
871 proto_tree_add_item(infoack_tree, hf_uftp_infoack_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
872 offset += 2;
873 proto_tree_add_item(infoack_tree, hf_uftp_infoack_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
874 offset += 2;
875 proto_tree_add_item(infoack_tree, hf_uftp_infoack_verify_data, tvb, offset, VERIFY_LEN, ENC_NA);
876 offset += VERIFY_LEN;
877 if (destcount > 0) {
878 destlist = proto_tree_add_item(infoack_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
879 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
881 for (idx = 0; idx < destcount; idx++) {
882 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
883 offset += 4;
887 static void dissect_uftp_fileseg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
889 proto_item *ti = NULL;
890 proto_tree *fileseg_tree = NULL;
891 int offset = 0;
892 uint8_t pass;
893 uint16_t file_id;
894 uint32_t seq_num;
896 if (tvb_reported_length(tvb) < FILESEG_LEN) {
897 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
898 "Invalid length: %d", tvb_reported_length(tvb));
899 return;
902 file_id = tvb_get_ntohs(tvb, 2);
903 pass = tvb_get_uint8(tvb, 4);
904 seq_num = tvb_get_ntohl(tvb, 8);
905 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X Pass=%d Seq=%d",
906 file_id, pass, seq_num);
908 ti = proto_tree_add_item(tree, hf_uftp_fileseg, tvb, offset, -1, ENC_NA);
909 fileseg_tree = proto_item_add_subtree(ti, ett_uftp_fileseg);
910 proto_tree_add_item(fileseg_tree, hf_uftp_fileseg_func, tvb, offset, 1, ENC_BIG_ENDIAN);
911 offset += 1;
912 proto_tree_add_item(fileseg_tree, hf_uftp_fileseg_reserved1, tvb, offset, 1, ENC_BIG_ENDIAN);
913 offset += 1;
914 proto_tree_add_item(fileseg_tree, hf_uftp_fileseg_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
915 offset += 2;
916 proto_tree_add_item(fileseg_tree, hf_uftp_fileseg_pass, tvb, offset, 1, ENC_BIG_ENDIAN);
917 offset += 1;
918 proto_tree_add_item(fileseg_tree, hf_uftp_fileseg_reserved2, tvb, offset, 1, ENC_BIG_ENDIAN);
919 offset += 1;
920 proto_tree_add_item(fileseg_tree, hf_uftp_fileseg_section, tvb, offset, 2, ENC_BIG_ENDIAN);
921 offset += 2;
922 proto_tree_add_item(fileseg_tree, hf_uftp_fileseg_seq_num, tvb, offset, 4, ENC_BIG_ENDIAN);
923 offset += 4;
924 proto_tree_add_item(fileseg_tree, hf_uftp_fileseg_data, tvb, offset, -1, ENC_NA);
927 static void dissect_uftp_done(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
929 proto_item *ti = NULL;
930 proto_item *destlist = NULL;
931 proto_tree *done_tree = NULL;
932 proto_tree *destlist_tree = NULL;
933 int offset = 0;
934 uint8_t pass;
935 uint16_t file_id, section, destcount, idx;
937 if (tvb_reported_length(tvb) < DONE_LEN) {
938 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
939 "Invalid length: %d", tvb_reported_length(tvb));
940 return;
943 destcount = tvb_get_ntohs(tvb, 6);
944 if ((int)tvb_reported_length(tvb) < DONE_LEN + (destcount * 4)) {
945 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
946 "Invalid length, len = %d, count=%d",
947 tvb_reported_length(tvb), destcount);
948 return;
951 pass = tvb_get_uint8(tvb, 1);
952 section = tvb_get_ntohs(tvb, 2);
953 file_id = tvb_get_ntohs(tvb, 4);
954 if (file_id > 0) {
955 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X Pass=%d Section=%d",
956 file_id, pass, section);
959 ti = proto_tree_add_item(tree, hf_uftp_done, tvb, offset, -1, ENC_NA);
960 done_tree = proto_item_add_subtree(ti, ett_uftp_done);
961 proto_tree_add_item(done_tree, hf_uftp_done_func, tvb, offset, 1, ENC_BIG_ENDIAN);
962 offset += 1;
963 proto_tree_add_item(done_tree, hf_uftp_done_pass, tvb, offset, 1, ENC_BIG_ENDIAN);
964 offset += 1;
965 proto_tree_add_item(done_tree, hf_uftp_done_section, tvb, offset, 2, ENC_BIG_ENDIAN);
966 offset += 2;
967 proto_tree_add_item(done_tree, hf_uftp_done_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
968 offset += 2;
969 proto_tree_add_item(done_tree, hf_uftp_done_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
970 offset += 2;
971 if (destcount > 0) {
972 destlist = proto_tree_add_item(done_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
973 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
975 for (idx = 0; idx < destcount; idx++) {
976 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
977 offset += 4;
981 static void dissect_uftp_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
983 proto_item *ti = NULL;
984 proto_tree *status_tree = NULL;
985 int offset = 0;
986 uint8_t pass, seq;
987 uint16_t file_id, section;
988 uint32_t nak_count;
990 if (tvb_reported_length(tvb) < STATUS_LEN) {
991 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
992 "Invalid length: %d", tvb_reported_length(tvb));
993 return;
996 file_id = tvb_get_ntohs(tvb, 2);
997 section = tvb_get_ntohs(tvb, 2);
998 pass = tvb_get_uint8(tvb, 4);
999 seq = tvb_get_uint8(tvb, 5);
1000 nak_count = tvb_get_ntohl(tvb, 8);
1001 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X Pass=%d Section=%d Seq=%d",
1002 file_id, pass, section, seq);
1004 ti = proto_tree_add_item(tree, hf_uftp_status, tvb, offset, -1, ENC_NA);
1005 status_tree = proto_item_add_subtree(ti, ett_uftp_status);
1006 proto_tree_add_item(status_tree, hf_uftp_status_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1007 offset += 1;
1008 proto_tree_add_item(status_tree, hf_uftp_status_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
1009 offset += 1;
1010 proto_tree_add_item(status_tree, hf_uftp_status_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1011 offset += 2;
1012 proto_tree_add_item(status_tree, hf_uftp_status_pass, tvb, offset, 1, ENC_BIG_ENDIAN);
1013 offset += 1;
1014 proto_tree_add_item(status_tree, hf_uftp_status_seq, tvb, offset, 1, ENC_BIG_ENDIAN);
1015 offset += 1;
1016 proto_tree_add_item(status_tree, hf_uftp_status_section, tvb, offset, 2, ENC_BIG_ENDIAN);
1017 offset += 2;
1018 proto_tree_add_item(status_tree, hf_uftp_status_nak_count, tvb, offset, 4, ENC_BIG_ENDIAN);
1019 offset += 4;
1020 if (nak_count > 0) {
1021 proto_tree_add_item(status_tree, hf_uftp_status_naks, tvb, offset, -1, ENC_NA);
1025 static void dissect_uftp_prstatus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1027 proto_item *ti = NULL;
1028 proto_item *destlist = NULL;
1029 proto_tree *prstatus_tree = NULL;
1030 proto_tree *destlist_tree = NULL;
1031 int offset = 0;
1032 uint8_t pass, seq;
1033 uint16_t file_id, destcount, idx, section;
1034 uint32_t nak_count;
1036 if (tvb_reported_length(tvb) < PRSTATUS_LEN) {
1037 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1038 "Invalid length: %d", tvb_reported_length(tvb));
1039 return;
1042 destcount = tvb_get_ntohs(tvb, 8);
1043 if ((int)tvb_reported_length(tvb) < PRSTATUS_LEN + (destcount * 4)) {
1044 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1045 "Invalid length, len = %d, count=%d",
1046 tvb_reported_length(tvb), destcount);
1047 return;
1050 file_id = tvb_get_ntohs(tvb, 2);
1051 section = tvb_get_ntohs(tvb, 2);
1052 pass = tvb_get_uint8(tvb, 4);
1053 seq = tvb_get_uint8(tvb, 5);
1054 nak_count = tvb_get_ntohl(tvb, 8);
1055 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X Pass=%d Section=%d Seq=%d "
1056 "NAKs=%d", file_id, pass, section, seq, nak_count);
1058 ti = proto_tree_add_item(tree, hf_uftp_prstatus, tvb, offset, -1, ENC_NA);
1059 prstatus_tree = proto_item_add_subtree(ti, ett_uftp_prstatus);
1060 proto_tree_add_item(prstatus_tree, hf_uftp_prstatus_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1061 offset += 1;
1062 proto_tree_add_item(prstatus_tree, hf_uftp_prstatus_reserved1, tvb, offset, 1, ENC_BIG_ENDIAN);
1063 offset += 1;
1064 proto_tree_add_item(prstatus_tree, hf_uftp_prstatus_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1065 offset += 2;
1066 proto_tree_add_item(prstatus_tree, hf_uftp_prstatus_pass, tvb, offset, 1, ENC_BIG_ENDIAN);
1067 offset += 1;
1068 proto_tree_add_item(prstatus_tree, hf_uftp_prstatus_seq, tvb, offset, 1, ENC_BIG_ENDIAN);
1069 offset += 1;
1070 proto_tree_add_item(prstatus_tree, hf_uftp_prstatus_section, tvb, offset, 2, ENC_BIG_ENDIAN);
1071 offset += 2;
1072 proto_tree_add_item(prstatus_tree, hf_uftp_prstatus_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
1073 offset += 2;
1074 proto_tree_add_item(prstatus_tree, hf_uftp_prstatus_reserved2, tvb, offset, 2, ENC_BIG_ENDIAN);
1075 offset += 2;
1076 if (destcount > 0) {
1077 destlist = proto_tree_add_item(prstatus_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
1078 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
1080 for (idx = 0; idx < destcount; idx++) {
1081 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
1082 offset += 4;
1086 static void dissect_uftp_complete(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1088 proto_item *ti = NULL;
1089 proto_item *destlist = NULL;
1090 proto_tree *complete_tree = NULL;
1091 proto_tree *destlist_tree = NULL;
1092 int offset = 0;
1093 uint16_t file_id, destcount, idx;
1095 if (tvb_reported_length(tvb) < COMPLETE_LEN) {
1096 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1097 "Invalid length: %d", tvb_reported_length(tvb));
1098 return;
1101 destcount = tvb_get_ntohs(tvb, 4);
1102 if ((int)tvb_reported_length(tvb) < COMPLETE_LEN + (destcount * 4)) {
1103 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1104 "Invalid length, len = %d, count=%d",
1105 tvb_reported_length(tvb), destcount);
1106 return;
1109 file_id = tvb_get_ntohs(tvb, 2);
1110 if (file_id > 0) {
1111 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X", file_id);
1114 ti = proto_tree_add_item(tree, hf_uftp_complete, tvb, offset, -1, ENC_NA);
1115 complete_tree = proto_item_add_subtree(ti, ett_uftp_complete);
1116 proto_tree_add_item(complete_tree, hf_uftp_complete_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1117 offset += 1;
1118 proto_tree_add_item(complete_tree, hf_uftp_complete_status, tvb, offset, 1, ENC_BIG_ENDIAN);
1119 offset += 1;
1120 proto_tree_add_item(complete_tree, hf_uftp_complete_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1121 offset += 2;
1122 proto_tree_add_item(complete_tree, hf_uftp_complete_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
1123 offset += 2;
1124 proto_tree_add_item(complete_tree, hf_uftp_complete_reserved2, tvb, offset, 2, ENC_BIG_ENDIAN);
1125 offset += 2;
1126 if (destcount > 0) {
1127 destlist = proto_tree_add_item(complete_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
1128 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
1130 for (idx = 0; idx < destcount; idx++) {
1131 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
1132 offset += 4;
1136 static void dissect_uftp_doneconf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1138 proto_item *ti = NULL;
1139 proto_item *destlist = NULL;
1140 proto_tree *doneconf_tree = NULL;
1141 proto_tree *destlist_tree = NULL;
1142 int offset = 0;
1143 uint16_t file_id, destcount, idx;
1145 if (tvb_reported_length(tvb) < DONE_CONF_LEN) {
1146 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1147 "Invalid length: %d", tvb_reported_length(tvb));
1148 return;
1151 destcount = tvb_get_ntohs(tvb, 4);
1152 if ((int)tvb_reported_length(tvb) < DONE_CONF_LEN + (destcount * 4)) {
1153 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1154 "Invalid length, len = %d, count=%d",
1155 tvb_reported_length(tvb), destcount);
1156 return;
1159 file_id = tvb_get_ntohs(tvb, 2);
1160 if (file_id > 0) {
1161 col_append_fstr(pinfo->cinfo, COL_INFO, ":%04X", file_id);
1164 ti = proto_tree_add_item(tree, hf_uftp_doneconf, tvb, offset, -1, ENC_NA);
1165 doneconf_tree = proto_item_add_subtree(ti, ett_uftp_doneconf);
1166 proto_tree_add_item(doneconf_tree, hf_uftp_doneconf_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1167 offset += 1;
1168 proto_tree_add_item(doneconf_tree, hf_uftp_doneconf_reserved1, tvb, offset, 1, ENC_BIG_ENDIAN);
1169 offset += 1;
1170 proto_tree_add_item(doneconf_tree, hf_uftp_doneconf_file_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1171 offset += 2;
1172 proto_tree_add_item(doneconf_tree, hf_uftp_doneconf_destcount, tvb, offset, 2, ENC_BIG_ENDIAN);
1173 offset += 2;
1174 proto_tree_add_item(doneconf_tree, hf_uftp_doneconf_reserved2, tvb, offset, 2, ENC_BIG_ENDIAN);
1175 offset += 2;
1176 if (destcount > 0) {
1177 destlist = proto_tree_add_item(doneconf_tree, hf_uftp_destlist, tvb, offset, destcount * 4, ENC_NA);
1178 destlist_tree = proto_item_add_subtree(destlist, ett_uftp_destlist);
1180 for (idx = 0; idx < destcount; idx++) {
1181 proto_tree_add_item(destlist_tree, hf_uftp_dest, tvb, offset, 4, ENC_BIG_ENDIAN);
1182 offset += 4;
1186 static void dissect_uftp_hbreq(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1188 proto_item *ti = NULL;
1189 proto_tree *hbreq_tree = NULL;
1190 int offset = 0;
1191 uint16_t keylen, siglen;
1193 if (tvb_reported_length(tvb) < HB_REQ_LEN) {
1194 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1195 "Invalid length: %d", tvb_reported_length(tvb));
1196 return;
1199 keylen = tvb_get_ntohs(tvb, 8);
1200 siglen = tvb_get_ntohs(tvb, 10);
1201 if ((int)tvb_reported_length(tvb) < HB_REQ_LEN + keylen + siglen) {
1202 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1203 "Invalid length, len = %d, keylen=%d siglen=%d",
1204 tvb_reported_length(tvb), keylen, siglen);
1205 return;
1208 ti = proto_tree_add_item(tree, hf_uftp_hbreq, tvb, offset, -1, ENC_NA);
1209 hbreq_tree = proto_item_add_subtree(ti, ett_uftp_hbreq);
1210 proto_tree_add_item(hbreq_tree, hf_uftp_hbreq_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1211 offset += 1;
1212 proto_tree_add_item(hbreq_tree, hf_uftp_hbreq_reserved, tvb, offset, 3, ENC_BIG_ENDIAN);
1213 offset += 3;
1214 proto_tree_add_item(hbreq_tree, hf_uftp_hbreq_nonce, tvb, offset, 4, ENC_BIG_ENDIAN);
1215 offset += 4;
1216 proto_tree_add_item(hbreq_tree, hf_uftp_hbreq_keylen, tvb, offset, 2, ENC_BIG_ENDIAN);
1217 offset += 2;
1218 proto_tree_add_item(hbreq_tree, hf_uftp_hbreq_siglen, tvb, offset, 2, ENC_BIG_ENDIAN);
1219 offset += 2;
1220 proto_tree_add_item(hbreq_tree, hf_uftp_hbreq_keyexp, tvb, offset, 4, ENC_BIG_ENDIAN);
1221 offset += 4;
1222 if (keylen > 0) {
1223 proto_tree_add_item(hbreq_tree, hf_uftp_hbreq_keymod, tvb, offset, keylen, ENC_NA);
1224 offset += keylen;
1226 if (siglen > 0) {
1227 proto_tree_add_item(hbreq_tree, hf_uftp_hbreq_verify, tvb, offset, siglen, ENC_NA);
1231 static void dissect_uftp_hbresp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1233 proto_item *ti = NULL;
1234 proto_tree *hbresp_tree = NULL;
1235 int offset = 0;
1237 if (tvb_reported_length(tvb) < HB_RESP_LEN) {
1238 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1239 "Invalid length: %d", tvb_reported_length(tvb));
1240 return;
1243 ti = proto_tree_add_item(tree, hf_uftp_hbresp, tvb, offset, -1, ENC_NA);
1244 hbresp_tree = proto_item_add_subtree(ti, ett_uftp_hbresp);
1245 proto_tree_add_item(hbresp_tree, hf_uftp_hbresp_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1246 offset += 1;
1247 proto_tree_add_item(hbresp_tree, hf_uftp_hbresp_authenticated, tvb, offset, 1, ENC_BIG_ENDIAN);
1248 offset += 1;
1249 proto_tree_add_item(hbresp_tree, hf_uftp_hbresp_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1250 offset += 2;
1251 proto_tree_add_item(hbresp_tree, hf_uftp_hbresp_nonce, tvb, offset, 4, ENC_BIG_ENDIAN);
1254 static void dissect_uftp_keyreq(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1256 proto_item *ti = NULL;
1257 proto_tree *keyreq_tree = NULL;
1258 int offset = 0;
1260 if (tvb_reported_length(tvb) < KEY_REQ_LEN) {
1261 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1262 "Invalid length: %d", tvb_reported_length(tvb));
1263 return;
1266 ti = proto_tree_add_item(tree, hf_uftp_keyreq, tvb, offset, -1, ENC_NA);
1267 keyreq_tree = proto_item_add_subtree(ti, ett_uftp_keyreq);
1268 proto_tree_add_item(keyreq_tree, hf_uftp_keyreq_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1269 offset += 1;
1270 proto_tree_add_item(keyreq_tree, hf_uftp_keyreq_reserved, tvb, offset, 3, ENC_BIG_ENDIAN);
1273 static void dissect_uftp_proxykey(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1275 proto_item *ti = NULL;
1276 proto_tree *proxykey_tree = NULL;
1277 int offset = 0;
1278 uint16_t keylen, siglen;
1280 if (tvb_reported_length(tvb) < PROXY_KEY_LEN) {
1281 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1282 "Invalid length: %d", tvb_reported_length(tvb));
1283 return;
1286 keylen = tvb_get_ntohs(tvb, 8);
1287 siglen = tvb_get_ntohs(tvb, 10);
1288 if ((int)tvb_reported_length(tvb) < PROXY_KEY_LEN + keylen + siglen) {
1289 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1290 "Invalid length, len = %d, keylen=%d siglen=%d",
1291 tvb_reported_length(tvb), keylen, siglen);
1292 return;
1295 ti = proto_tree_add_item(tree, hf_uftp_proxykey, tvb, offset, -1, ENC_NA);
1296 proxykey_tree = proto_item_add_subtree(ti, ett_uftp_proxykey);
1297 proto_tree_add_item(proxykey_tree, hf_uftp_proxykey_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1298 offset += 1;
1299 proto_tree_add_item(proxykey_tree, hf_uftp_proxykey_reserved, tvb, offset, 3, ENC_BIG_ENDIAN);
1300 offset += 3;
1301 proto_tree_add_item(proxykey_tree, hf_uftp_proxykey_nonce, tvb, offset, 4, ENC_BIG_ENDIAN);
1302 offset += 4;
1303 proto_tree_add_item(proxykey_tree, hf_uftp_proxykey_keylen, tvb, offset, 2, ENC_BIG_ENDIAN);
1304 offset += 2;
1305 proto_tree_add_item(proxykey_tree, hf_uftp_proxykey_siglen, tvb, offset, 2, ENC_BIG_ENDIAN);
1306 offset += 2;
1307 proto_tree_add_item(proxykey_tree, hf_uftp_proxykey_keyexp, tvb, offset, 4, ENC_BIG_ENDIAN);
1308 offset += 4;
1309 if (keylen > 0) {
1310 proto_tree_add_item(proxykey_tree, hf_uftp_proxykey_keymod, tvb, offset, keylen, ENC_NA);
1311 offset += keylen;
1313 if (siglen > 0) {
1314 proto_tree_add_item(proxykey_tree, hf_uftp_proxykey_verify, tvb, offset, siglen, ENC_NA);
1318 static void dissect_uftp_encrypted(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1320 proto_item *ti = NULL;
1321 proto_tree *encrypted_tree = NULL;
1322 int offset = 0;
1323 uint16_t sig_len, payload_len;
1325 if (tvb_reported_length(tvb) < ENCRYPTED_LEN) {
1326 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1327 "Invalid length: %d", tvb_reported_length(tvb));
1328 return;
1331 sig_len = tvb_get_ntohs(tvb, 8);
1332 payload_len = tvb_get_ntohs(tvb, 10);
1333 if ((int)tvb_reported_length(tvb) < ENCRYPTED_LEN + sig_len + payload_len) {
1334 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1335 "Invalid length, len = %d, sig=%d, payload=%d",
1336 tvb_reported_length(tvb), sig_len, payload_len);
1337 return;
1340 ti = proto_tree_add_item(tree, hf_uftp_encrypted, tvb, offset, -1, ENC_NA);
1341 encrypted_tree = proto_item_add_subtree(ti, ett_uftp_encrypted);
1342 proto_tree_add_item(encrypted_tree, hf_uftp_encrypted_tstamp, tvb, offset, 8, ENC_NA);
1343 offset += 8;
1344 proto_tree_add_item(encrypted_tree, hf_uftp_encrypted_sig_len, tvb, offset, 2, ENC_BIG_ENDIAN);
1345 offset += 2;
1346 proto_tree_add_item(encrypted_tree, hf_uftp_encrypted_payload_len, tvb, offset, 2, ENC_BIG_ENDIAN);
1347 offset += 2;
1348 proto_tree_add_item(encrypted_tree, hf_uftp_encrypted_signature, tvb, offset, sig_len, ENC_NA);
1349 offset += sig_len;
1350 proto_tree_add_item(encrypted_tree, hf_uftp_encrypted_payload, tvb, offset, payload_len, ENC_NA);
1353 static void dissect_uftp_abort(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1355 proto_item *ti = NULL;
1356 proto_tree *abort_tree = NULL;
1357 int offset = 0;
1359 if (tvb_reported_length(tvb) < ABORT_LEN) {
1360 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_length_invalid, tvb, offset, -1,
1361 "Invalid length: %d", tvb_reported_length(tvb));
1362 return;
1365 ti = proto_tree_add_item(tree, hf_uftp_abort, tvb, offset, -1, ENC_NA);
1366 abort_tree = proto_item_add_subtree(ti, ett_uftp_abort);
1367 proto_tree_add_item(abort_tree, hf_uftp_abort_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1368 offset += 1;
1369 proto_tree_add_bitmask(abort_tree, tvb, offset, hf_uftp_abort_flags, ett_uftp_abort_flags, abort_flags, ENC_BIG_ENDIAN);
1370 offset += 1;
1371 proto_tree_add_item(abort_tree, hf_uftp_abort_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1372 offset += 2;
1373 proto_tree_add_item(abort_tree, hf_uftp_abort_host, tvb, offset, 4, ENC_BIG_ENDIAN);
1374 offset += 4;
1375 proto_tree_add_item(abort_tree, hf_uftp_abort_message, tvb, offset, -1, ENC_ASCII);
1378 static int dissect_uftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1380 uint8_t version;
1381 uint8_t mes_type;
1382 uint32_t group_id;
1383 uint16_t blsize;
1384 tvbuff_t *next_tvb;
1385 proto_item *ti = NULL;
1386 proto_tree *uftp_tree = NULL;
1387 int offset = 0;
1389 version = tvb_get_uint8(tvb, 0);
1390 if (version == 0x50) {
1391 return call_dissector(uftp5_handle, tvb, pinfo, tree);
1392 } else if (version == 0x40) {
1393 return call_dissector(uftp4_handle, tvb, pinfo, tree);
1394 } else if (version != UFTP_VER_NUM && version != UFTP_3_0_VER) {
1395 return 0;
1398 if (tvb_reported_length(tvb) < UFTP_LEN) {
1399 return 0;
1402 mes_type = tvb_get_uint8(tvb, 1);
1403 blsize = tvb_get_ntohs(tvb, 2);
1404 group_id = tvb_get_ntohl(tvb, 4);
1406 if (tvb_reported_length(tvb) != (unsigned)UFTP_LEN + blsize) {
1407 return 0;
1410 col_set_str(pinfo->cinfo, COL_PROTOCOL, "UFTP");
1411 /* Clear out stuff in the info column */
1412 col_clear(pinfo->cinfo,COL_INFO);
1413 col_add_fstr(pinfo->cinfo, COL_INFO, "%-10s",
1414 val_to_str(mes_type, messages, "Unknown (%d)"));
1415 if ((mes_type != HB_REQ) && (mes_type != HB_RESP)) {
1416 col_append_fstr(pinfo->cinfo, COL_INFO, " ID=%08X", group_id);
1419 ti = proto_tree_add_item(tree, proto_uftp, tvb, 0, -1, ENC_NA);
1420 uftp_tree = proto_item_add_subtree(ti, ett_uftp);
1421 proto_tree_add_item(uftp_tree, hf_uftp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
1422 offset += 1;
1423 proto_tree_add_item(uftp_tree, hf_uftp_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1424 offset += 1;
1425 proto_tree_add_item(uftp_tree, hf_uftp_blsize, tvb, offset, 2, ENC_BIG_ENDIAN);
1426 offset += 2;
1427 proto_tree_add_item(uftp_tree, hf_uftp_group_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1428 offset += 4;
1429 proto_tree_add_item(uftp_tree, hf_uftp_srcaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
1430 offset += 4;
1431 proto_tree_add_item(uftp_tree, hf_uftp_destaddr, tvb, offset, 4, ENC_BIG_ENDIAN);
1432 offset += 4;
1434 next_tvb = tvb_new_subset_length(tvb, offset, blsize);
1436 switch (mes_type) {
1437 case ANNOUNCE:
1438 dissect_uftp_announce(next_tvb, pinfo, uftp_tree);
1439 break;
1440 case REGISTER:
1441 dissect_uftp_register(next_tvb, pinfo, uftp_tree);
1442 break;
1443 case CLIENT_KEY:
1444 dissect_uftp_clientkey(next_tvb, pinfo, uftp_tree);
1445 break;
1446 case REG_CONF:
1447 dissect_uftp_regconf(next_tvb, pinfo, uftp_tree);
1448 break;
1449 case FILEINFO:
1450 if (version == UFTP_3_0_VER) {
1451 dissect_uftp_fileinfo_30(next_tvb, pinfo, uftp_tree);
1452 } else {
1453 dissect_uftp_fileinfo(next_tvb, pinfo, uftp_tree);
1455 break;
1456 case KEYINFO:
1457 dissect_uftp_keyinfo(next_tvb, pinfo, uftp_tree);
1458 break;
1459 case INFO_ACK:
1460 dissect_uftp_infoack(next_tvb, pinfo, uftp_tree);
1461 break;
1462 case FILESEG:
1463 dissect_uftp_fileseg(next_tvb, pinfo, uftp_tree);
1464 break;
1465 case DONE:
1466 dissect_uftp_done(next_tvb, pinfo, uftp_tree);
1467 break;
1468 case STATUS:
1469 dissect_uftp_status(next_tvb, pinfo, uftp_tree);
1470 break;
1471 case PRSTATUS:
1472 dissect_uftp_prstatus(next_tvb, pinfo, uftp_tree);
1473 break;
1474 case COMPLETE:
1475 dissect_uftp_complete(next_tvb, pinfo, uftp_tree);
1476 break;
1477 case DONE_CONF:
1478 dissect_uftp_doneconf(next_tvb, pinfo, uftp_tree);
1479 break;
1480 case HB_REQ:
1481 dissect_uftp_hbreq(next_tvb, pinfo, uftp_tree);
1482 break;
1483 case HB_RESP:
1484 dissect_uftp_hbresp(next_tvb, pinfo, uftp_tree);
1485 break;
1486 case KEY_REQ:
1487 dissect_uftp_keyreq(next_tvb, pinfo, uftp_tree);
1488 break;
1489 case PROXY_KEY:
1490 dissect_uftp_proxykey(next_tvb, pinfo, uftp_tree);
1491 break;
1492 case ENCRYPTED:
1493 dissect_uftp_encrypted(next_tvb, pinfo, uftp_tree);
1494 break;
1495 case ABORT:
1496 dissect_uftp_abort(next_tvb, pinfo, uftp_tree);
1497 break;
1498 default:
1499 proto_tree_add_expert_format(tree, pinfo, &ei_uftp_func_unknown, tvb, offset, -1,
1500 "Function unknown: %d", mes_type);
1501 break;
1504 return tvb_reported_length(tvb);
1507 void proto_register_uftp(void)
1509 static hf_register_info hf[] = {
1510 { &hf_uftp_version,
1511 { "Protocol Version", "uftp.version",
1512 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1514 { &hf_uftp_func,
1515 { "Type", "uftp.func",
1516 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1518 { &hf_uftp_blsize,
1519 { "Block Size", "uftp.blsize",
1520 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1522 { &hf_uftp_group_id,
1523 { "Group ID", "uftp.group_id",
1524 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
1526 { &hf_uftp_srcaddr,
1527 { "Source Address", "uftp.srcaddr",
1528 FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
1530 { &hf_uftp_destaddr,
1531 { "Destination Address", "uftp.destaddr",
1532 FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
1534 { &hf_uftp_destlist,
1535 { "Destination List", "uftp.destlist",
1536 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1538 { &hf_uftp_dest,
1539 { "Destination", "uftp.dest",
1540 FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
1542 { &hf_uftp_announce,
1543 { "ANNOUNCE", "uftp.announce",
1544 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1546 { &hf_uftp_announce_func,
1547 { "Type", "uftp.announce.func",
1548 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1550 { &hf_uftp_announce_flags,
1551 { "Flags", "uftp.announce.flags",
1552 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1554 { &hf_uftp_announce_flags_restart,
1555 { "Restart", "uftp.announce.flags.restart",
1556 FT_BOOLEAN, 8, NULL, FLAG_RESTART, NULL, HFILL }
1558 { &hf_uftp_announce_flags_sync,
1559 { "Sync mode", "uftp.announce.flags.sync",
1560 FT_BOOLEAN, 8, NULL, FLAG_SYNC_MODE, NULL, HFILL }
1562 { &hf_uftp_announce_flags_syncpreview,
1563 { "Sync preview mode", "uftp.announce.flags.syncpreview",
1564 FT_BOOLEAN, 8, NULL, FLAG_SYNC_PREVIEW, NULL, HFILL }
1566 { &hf_uftp_announce_flags_reserved,
1567 { "Reserved", "uftp.announce.flags.reserved",
1568 FT_BOOLEAN, 8, NULL, FLAG_ANNOUNCE_RESERVED, NULL, HFILL }
1570 { &hf_uftp_announce_destcount,
1571 { "Destination Count", "uftp.announce.destcount",
1572 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1574 { &hf_uftp_announce_announce_int,
1575 { "Announce Interval", "uftp.announce.announce_int",
1576 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1578 { &hf_uftp_announce_status_int,
1579 { "Status Interval", "uftp.announce.status_int",
1580 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1582 { &hf_uftp_announce_register_int,
1583 { "Register Interval", "uftp.announce.register_int",
1584 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1586 { &hf_uftp_announce_done_int,
1587 { "Done Interval", "uftp.announce.done_int",
1588 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1590 { &hf_uftp_announce_announce_time,
1591 { "Announce Time", "uftp.announce.announce_time",
1592 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1594 { &hf_uftp_announce_status_time,
1595 { "Status Time", "uftp.announce.status_time",
1596 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1598 { &hf_uftp_announce_mtu,
1599 { "MTU", "uftp.announce.mtu",
1600 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1602 { &hf_uftp_announce_privatemcast,
1603 { "Private Multicast Address", "uftp.announce.privatemcast",
1604 FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
1606 { &hf_uftp_announce_client_auth,
1607 { "Client Auth", "uftp.announce.client_auth",
1608 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1610 { &hf_uftp_announce_sigtype,
1611 { "Signature Type", "uftp.announce.sigtype",
1612 FT_UINT8, BASE_DEC, VALS(signature_types), 0x0, NULL, HFILL }
1614 { &hf_uftp_announce_hashtype,
1615 { "Hash Type", "uftp.announce.hashtype",
1616 FT_UINT8, BASE_DEC, VALS(hash_types), 0x0, NULL, HFILL }
1618 { &hf_uftp_announce_keytype,
1619 { "Key Type", "uftp.announce.keytype",
1620 FT_UINT8, BASE_DEC, VALS(key_types), 0x0, NULL, HFILL }
1622 { &hf_uftp_announce_keylen,
1623 { "Public Key Length", "uftp.announce.keylen",
1624 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1626 { &hf_uftp_announce_reserved,
1627 { "Reserved", "uftp.announce.reserved",
1628 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
1630 { &hf_uftp_announce_keyexp,
1631 { "Public Key Exponent", "uftp.announce.keyexp",
1632 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
1634 { &hf_uftp_announce_rand1,
1635 { "Server Random Number", "uftp.announce.rand1",
1636 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1638 { &hf_uftp_announce_keymod,
1639 { "Public Key Modulus", "uftp.announce.keymod",
1640 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1642 { &hf_uftp_register,
1643 { "REGISTER", "uftp.register",
1644 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1646 { &hf_uftp_register_func,
1647 { "Type", "uftp.register.func",
1648 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1650 { &hf_uftp_register_reserved,
1651 { "Reserved", "uftp.register.reserved",
1652 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL }
1654 { &hf_uftp_register_destcount,
1655 { "Destination Count", "uftp.register.destcount",
1656 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1658 { &hf_uftp_register_premaster_len,
1659 { "Premaster Secret Length", "uftp.register.premaster_len",
1660 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1662 { &hf_uftp_register_rand2,
1663 { "Client Random Number", "uftp.register.rand2",
1664 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1666 { &hf_uftp_register_premaster,
1667 { "Encrypted Premaster Secret", "uftp.register.premaster",
1668 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1670 { &hf_uftp_clientkey,
1671 { "CLIENT_KEY", "uftp.clientkey",
1672 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1674 { &hf_uftp_clientkey_func,
1675 { "Type", "uftp.clientkey.func",
1676 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1678 { &hf_uftp_clientkey_reserved,
1679 { "Reserved", "uftp.clientkey.reserved",
1680 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL }
1682 { &hf_uftp_clientkey_keylen,
1683 { "Key Length", "uftp.clientkey.keylen",
1684 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1686 { &hf_uftp_clientkey_verifylen,
1687 { "Signature Length", "uftp.clientkey.verifylen",
1688 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1690 { &hf_uftp_clientkey_keyexp,
1691 { "Public Key Exponent", "uftp.clientkey.keyexp",
1692 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
1694 { &hf_uftp_clientkey_keymod,
1695 { "Public Key Modulus", "uftp.clientkey.keymod",
1696 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1698 { &hf_uftp_clientkey_verify,
1699 { "Signature", "uftp.clientkey.verify",
1700 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1702 { &hf_uftp_regconf,
1703 { "REG_CONF", "uftp.regconf",
1704 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1706 { &hf_uftp_regconf_func,
1707 { "Type", "uftp.regconf.func",
1708 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1710 { &hf_uftp_regconf_reserved,
1711 { "Reserved", "uftp.regconf.reserved",
1712 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1714 { &hf_uftp_regconf_destcount,
1715 { "Destination Count", "uftp.regconf.destcount",
1716 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1718 { &hf_uftp_fileinfo,
1719 { "FILEINFO", "uftp.fileinfo",
1720 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1722 { &hf_uftp_fileinfo_func,
1723 { "Type", "uftp.fileinfo.func",
1724 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1726 { &hf_uftp_fileinfo_ftype,
1727 { "File Type", "uftp.fileinfo.ftype",
1728 FT_UINT8, BASE_DEC, VALS(file_types), 0x0, NULL, HFILL }
1730 { &hf_uftp_fileinfo_file_id,
1731 { "File ID", "uftp.fileinfo.file_id",
1732 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
1734 { &hf_uftp_fileinfo_block_total,
1735 { "Total Blocks", "uftp.fileinfo.block_total",
1736 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
1738 { &hf_uftp_fileinfo_section_total,
1739 { "Total Sections", "uftp.fileinfo.section_total",
1740 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1742 { &hf_uftp_fileinfo_destcount,
1743 { "Destination Count", "uftp.fileinfo.destcount",
1744 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1746 { &hf_uftp_fileinfo_fsize,
1747 { "File Size", "uftp.fileinfo.fsize",
1748 FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
1750 { &hf_uftp_fileinfo_ftstamp,
1751 { "File Timestamp", "uftp.fileinfo.tstamp",
1752 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
1754 { &hf_uftp_fileinfo_name,
1755 { "File Name", "uftp.fileinfo.name",
1756 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
1758 { &hf_uftp_keyinfo,
1759 { "KEYINFO", "uftp.keyinfo",
1760 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1762 { &hf_uftp_keyinfo_func,
1763 { "Type", "uftp.keyinfo.func",
1764 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1766 { &hf_uftp_keyinfo_reserved,
1767 { "Reserved", "uftp.keyinfo.reserved",
1768 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1770 { &hf_uftp_keyinfo_destcount,
1771 { "Destination Count", "uftp.keyinfo.destcount",
1772 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1774 { &hf_uftp_keyinfo_groupmaster_len,
1775 { "Group Master Length", "uftp.keyinfo.groupmaster_len",
1776 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1778 { &hf_uftp_keyinfo_tstamp,
1779 { "Timestamp", "uftp.keyinfo.tstamp",
1780 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL }
1782 { &hf_uftp_keyinfo_destkey,
1783 { "Destination Key", "uftp.keyinfo.destkey",
1784 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1786 { &hf_uftp_keyinfo_destaddr,
1787 { "Destination Address", "uftp.keyinfo.destaddr",
1788 FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
1790 { &hf_uftp_keyinfo_groupmaster,
1791 { "Encrypted Group Master", "uftp.keyinfo.groupmaster",
1792 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1794 { &hf_uftp_infoack,
1795 { "INFO_ACK", "uftp.infoack",
1796 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1798 { &hf_uftp_infoack_func,
1799 { "Type", "uftp.infoack.func",
1800 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1802 { &hf_uftp_infoack_flags,
1803 { "Flags", "uftp.infoack.flags",
1804 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1806 { &hf_uftp_infoack_flags_partial,
1807 { "Partial", "uftp.infoack.flags.partial",
1808 FT_BOOLEAN, 8, NULL, FLAG_PARTIAL, NULL, HFILL }
1810 { &hf_uftp_infoack_flags_reserved,
1811 { "Reserved", "uftp.infoack.flags.reserved",
1812 FT_BOOLEAN, 8, NULL, FLAG_INFOACK_RESERVED, NULL, HFILL }
1814 { &hf_uftp_infoack_file_id,
1815 { "File ID", "uftp.infoack.file_id",
1816 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
1818 { &hf_uftp_infoack_destcount,
1819 { "Destination Count", "uftp.infoack.destcount",
1820 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1822 { &hf_uftp_infoack_reserved,
1823 { "Reserved", "uftp.infoack.reserved",
1824 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
1826 { &hf_uftp_infoack_verify_data,
1827 { "Verify Data", "uftp.infoack.verify_data",
1828 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1830 { &hf_uftp_fileseg,
1831 { "FILESEG", "uftp.fileseg",
1832 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1834 { &hf_uftp_fileseg_func,
1835 { "Type", "uftp.fileseg.func",
1836 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1838 { &hf_uftp_fileseg_reserved1,
1839 { "Reserved", "uftp.fileseg.reserved1",
1840 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1842 { &hf_uftp_fileseg_file_id,
1843 { "File ID", "uftp.fileseg.file_id",
1844 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1846 { &hf_uftp_fileseg_pass,
1847 { "Pass", "uftp.fileseg.pass",
1848 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1850 { &hf_uftp_fileseg_reserved2,
1851 { "Reserved", "uftp.fileseg.reserved2",
1852 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1854 { &hf_uftp_fileseg_section,
1855 { "Section", "uftp.fileseg.section",
1856 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1858 { &hf_uftp_fileseg_seq_num,
1859 { "Sequence Number", "uftp.fileseg.seq_num",
1860 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
1862 { &hf_uftp_fileseg_data,
1863 { "Data", "uftp.fileseg.data",
1864 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1866 { &hf_uftp_done,
1867 { "DONE", "uftp.done",
1868 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1870 { &hf_uftp_done_func,
1871 { "Type", "uftp.done.func",
1872 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1874 { &hf_uftp_done_pass,
1875 { "Pass", "uftp.done.pass",
1876 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1878 { &hf_uftp_done_section,
1879 { "Section", "uftp.done.section",
1880 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1882 { &hf_uftp_done_file_id,
1883 { "File ID", "uftp.done.file_id",
1884 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1886 { &hf_uftp_done_destcount,
1887 { "Destination Count", "uftp.done.destcount",
1888 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1890 { &hf_uftp_status,
1891 { "STATUS", "uftp.status",
1892 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1894 { &hf_uftp_status_func,
1895 { "Type", "uftp.status.func",
1896 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1898 { &hf_uftp_status_reserved,
1899 { "Reserved", "uftp.status.reserved",
1900 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1902 { &hf_uftp_status_file_id,
1903 { "File ID", "uftp.status.file_id",
1904 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1906 { &hf_uftp_status_pass,
1907 { "Pass", "uftp.status.pass",
1908 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1910 { &hf_uftp_status_seq,
1911 { "Sequence", "uftp.status.seq",
1912 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1914 { &hf_uftp_status_section,
1915 { "Section", "uftp.status.section",
1916 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1918 { &hf_uftp_status_nak_count,
1919 { "NAK Count", "uftp.status.nak_count",
1920 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
1922 { &hf_uftp_status_naks,
1923 { "NAKs", "uftp.status.naks",
1924 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1926 { &hf_uftp_prstatus,
1927 { "PRSTATUS", "uftp.prstatus",
1928 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1930 { &hf_uftp_prstatus_func,
1931 { "Type", "uftp.prstatus.func",
1932 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1934 { &hf_uftp_prstatus_reserved1,
1935 { "Reserved", "uftp.prstatus.reserved1",
1936 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1938 { &hf_uftp_prstatus_file_id,
1939 { "File ID", "uftp.prstatus.file_id",
1940 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1942 { &hf_uftp_prstatus_pass,
1943 { "Pass", "uftp.prstatus.pass",
1944 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1946 { &hf_uftp_prstatus_seq,
1947 { "Sequence", "uftp.prstatus.seq",
1948 FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1950 { &hf_uftp_prstatus_section,
1951 { "Section", "uftp.prstatus.section",
1952 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1954 { &hf_uftp_prstatus_destcount,
1955 { "Destination Count", "uftp.prstatus.destcount",
1956 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
1958 { &hf_uftp_prstatus_reserved2,
1959 { "Reserved", "uftp.prstatus.reserved2",
1960 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
1962 { &hf_uftp_complete,
1963 { "COMPLETE", "uftp.complete",
1964 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1966 { &hf_uftp_complete_func,
1967 { "Type", "uftp.complete.func",
1968 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1970 { &hf_uftp_complete_status,
1971 { "Completion status", "uftp.complete.status",
1972 FT_UINT8, BASE_DEC, VALS(comp_status), 0x0, NULL, HFILL }
1974 { &hf_uftp_complete_file_id,
1975 { "File ID", "uftp.complete.file_id",
1976 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1978 { &hf_uftp_complete_destcount,
1979 { "Destination Count", "uftp.complete.destcount",
1980 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1982 { &hf_uftp_complete_reserved2,
1983 { "Reserved", "uftp.complete.reserved2",
1984 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
1986 { &hf_uftp_doneconf,
1987 { "DONE_CONF", "uftp.doneconf",
1988 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1990 { &hf_uftp_doneconf_func,
1991 { "Type", "uftp.doneconf.func",
1992 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
1994 { &hf_uftp_doneconf_reserved1,
1995 { "Reserved", "uftp.doneconf.reserved1",
1996 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1998 { &hf_uftp_doneconf_file_id,
1999 { "File ID", "uftp.doneconf.file_id",
2000 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
2002 { &hf_uftp_doneconf_destcount,
2003 { "Destination Count", "uftp.doneconf.destcount",
2004 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
2006 { &hf_uftp_doneconf_reserved2,
2007 { "Reserved", "uftp.doneconf.reserved2",
2008 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
2010 { &hf_uftp_hbreq,
2011 { "HB_REQ", "uftp.hbreq",
2012 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
2014 { &hf_uftp_hbreq_func,
2015 { "Type", "uftp.hbreq.func",
2016 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
2018 { &hf_uftp_hbreq_reserved,
2019 { "Reserved", "uftp.hbreq.reserved",
2020 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL }
2022 { &hf_uftp_hbreq_nonce,
2023 { "Nonce", "uftp.hbreq.nonce",
2024 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
2026 { &hf_uftp_hbreq_keylen,
2027 { "Key Length", "uftp.hbreq.keylen",
2028 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
2030 { &hf_uftp_hbreq_siglen,
2031 { "Signature Length", "uftp.hbreq.siglen",
2032 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
2034 { &hf_uftp_hbreq_keyexp,
2035 { "Public Key Exponent", "uftp.hbreq.keyexp",
2036 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
2038 { &hf_uftp_hbreq_keymod,
2039 { "Public Key Modulus", "uftp.hbreq.keymod",
2040 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
2042 { &hf_uftp_hbreq_verify,
2043 { "Signature", "uftp.hbreq.verify",
2044 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
2046 { &hf_uftp_hbresp,
2047 { "HB_RESP", "uftp.hbresp",
2048 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
2050 { &hf_uftp_hbresp_func,
2051 { "Type", "uftp.hbresp.func",
2052 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
2054 { &hf_uftp_hbresp_authenticated,
2055 { "Authenticated", "uftp.hbresp.authenticated",
2056 FT_UINT8, BASE_DEC, VALS(hb_auth_types), 0x0, NULL, HFILL }
2058 { &hf_uftp_hbresp_reserved,
2059 { "Reserved", "uftp.hbresp.reserved",
2060 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
2062 { &hf_uftp_hbresp_nonce,
2063 { "Nonce", "uftp.hbresp.nonce",
2064 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
2066 { &hf_uftp_keyreq,
2067 { "KEY_REQ", "uftp.keyreq",
2068 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
2070 { &hf_uftp_keyreq_func,
2071 { "Type", "uftp.keyreq.func",
2072 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
2074 { &hf_uftp_keyreq_reserved,
2075 { "Reserved", "uftp.keyreq.reserved",
2076 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL }
2078 { &hf_uftp_proxykey,
2079 { "PROXY_KEY", "uftp.proxykey",
2080 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
2082 { &hf_uftp_proxykey_func,
2083 { "Type", "uftp.proxykey.func",
2084 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
2086 { &hf_uftp_proxykey_reserved,
2087 { "Reserved", "uftp.proxykey.reserved",
2088 FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL }
2090 { &hf_uftp_proxykey_nonce,
2091 { "Nonce", "uftp.proxykey.nonce",
2092 FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
2094 { &hf_uftp_proxykey_keylen,
2095 { "Key Length", "uftp.proxykey.keylen",
2096 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
2098 { &hf_uftp_proxykey_siglen,
2099 { "Signature Length", "uftp.proxykey.siglen",
2100 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
2102 { &hf_uftp_proxykey_keyexp,
2103 { "Public Key Exponent", "uftp.proxykey.keyexp",
2104 FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
2106 { &hf_uftp_proxykey_keymod,
2107 { "Public Key Modulus", "uftp.proxykey.keymod",
2108 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
2110 { &hf_uftp_proxykey_verify,
2111 { "Signature", "uftp.proxykey.verify",
2112 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
2114 { &hf_uftp_encrypted,
2115 { "ENCRYPTED", "uftp.encrypted",
2116 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
2118 { &hf_uftp_encrypted_tstamp,
2119 { "Timestamp", "uftp.encrypted.tstamp",
2120 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL }
2122 { &hf_uftp_encrypted_sig_len,
2123 { "Signature Length", "uftp.encrypted.sig_len",
2124 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
2126 { &hf_uftp_encrypted_payload_len,
2127 { "Payload Length", "uftp.encrypted.payload_len",
2128 FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
2130 { &hf_uftp_encrypted_signature,
2131 { "Signature", "uftp.encrypted.signature",
2132 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
2134 { &hf_uftp_encrypted_payload,
2135 { "Encrypted Payload", "uftp.encrypted.payload",
2136 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
2138 { &hf_uftp_abort,
2139 { "ABORT", "uftp.abort",
2140 FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
2142 { &hf_uftp_abort_func,
2143 { "Type", "uftp.abort.func",
2144 FT_UINT8, BASE_DEC, VALS(messages), 0x0, NULL, HFILL }
2146 { &hf_uftp_abort_flags,
2147 { "Flags", "uftp.abort.flags",
2148 FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
2150 { &hf_uftp_abort_flags_curfile,
2151 { "Current file", "uftp.abort.flags.curfile",
2152 FT_BOOLEAN, 8, NULL, FLAG_CURRENT_FILE, NULL, HFILL }
2154 { &hf_uftp_abort_flags_reserved,
2155 { "Reserved", "uftp.abort.flags.reserved",
2156 FT_BOOLEAN, 8, NULL, FLAG_ABORT_RESERVED, NULL, HFILL }
2158 { &hf_uftp_abort_reserved,
2159 { "Reserved", "uftp.abort.reserved",
2160 FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }
2162 { &hf_uftp_abort_host,
2163 { "Host", "uftp.abort.host",
2164 FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
2166 { &hf_uftp_abort_message,
2167 { "Message", "uftp.abort.message",
2168 FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
2172 /* Setup protocol subtree array */
2173 static int *ett[] = {
2174 &ett_uftp,
2175 &ett_uftp_announce,
2176 &ett_uftp_register,
2177 &ett_uftp_clientkey,
2178 &ett_uftp_regconf,
2179 &ett_uftp_fileinfo,
2180 &ett_uftp_keyinfo,
2181 &ett_uftp_keyinfo_destkey,
2182 &ett_uftp_infoack,
2183 &ett_uftp_fileseg,
2184 &ett_uftp_done,
2185 &ett_uftp_status,
2186 &ett_uftp_prstatus,
2187 &ett_uftp_complete,
2188 &ett_uftp_doneconf,
2189 &ett_uftp_hbreq,
2190 &ett_uftp_hbresp,
2191 &ett_uftp_keyreq,
2192 &ett_uftp_proxykey,
2193 &ett_uftp_encrypted,
2194 &ett_uftp_abort,
2195 &ett_uftp_announce_flags,
2196 &ett_uftp_infoack_flags,
2197 &ett_uftp_abort_flags,
2198 &ett_uftp_destlist
2201 static ei_register_info ei[] = {
2202 { &ei_uftp_length_invalid, { "uftp.length.invalid", PI_MALFORMED, PI_ERROR, "Length is invalid", EXPFILL }},
2203 { &ei_uftp_func_unknown, { "uftp.func.invalid", PI_MALFORMED, PI_ERROR, "Unknown function", EXPFILL }}
2206 expert_module_t* expert_uftp;
2208 proto_uftp = proto_register_protocol("UDP based FTP w/ multicast", "UFTP", "uftp");
2210 proto_register_field_array(proto_uftp, hf, array_length(hf));
2211 proto_register_subtree_array(ett, array_length(ett));
2212 expert_uftp = expert_register_protocol(proto_uftp);
2213 expert_register_field_array(expert_uftp, ei, array_length(ei));
2214 uftp_handle = register_dissector("uftp", dissect_uftp, proto_uftp);
2217 void proto_reg_handoff_uftp(void)
2219 uftp4_handle = find_dissector("uftp4");
2220 uftp5_handle = find_dissector("uftp5");
2221 dissector_add_uint_with_preference("udp.port", UFTP_PORT, uftp_handle);
2225 * Editor modelines - https://www.wireshark.org/tools/modelines.html
2227 * Local variables:
2228 * c-basic-offset: 4
2229 * tab-width: 8
2230 * indent-tabs-mode: nil
2231 * End:
2233 * vi: set shiftwidth=4 tabstop=8 expandtab:
2234 * :indentSize=4:tabSize=8:noTabs=true: