Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-afp.c
blob0255c15e941d14efe587baf5969ece2d400ca7ba
1 /* packet-afp.c
2 * Routines for afp packet dissection
3 * Copyright 2002, Didier Gautheron <dgautheron@magic.fr>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * Copied from README.developer
10 * Copied from packet-dsi.c
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
18 #include <epan/packet.h>
19 #include <epan/exceptions.h>
20 #include <epan/to_str.h>
21 #include <epan/conversation.h>
22 #include <epan/prefs.h>
23 #include <epan/tap.h>
24 #include <epan/srt_table.h>
25 #include <epan/expert.h>
27 #include "packet-afp.h"
29 /* The information in this module (AFP) comes from:
31 AFP 2.1 & 2.2 documentation, in PDF form, at
33 http://mirror.informatimago.com/next/developer.apple.com/documentation/macos8/pdf/ASAppleTalkFiling2.1_2.2.pdf
35 formerly at
37 http://developer.apple.com/DOCUMENTATION/macos8/pdf/ASAppleTalkFiling2.1_2.2.pdf
39 AFP3.0.pdf from http://www.apple.com (still available?)
41 AFP 3.1 programming guide, in PDF form, at
43 https://web.archive.org/web/20040721011424/http://developer.apple.com/documentation/Networking/Conceptual/AFP/AFP3_1.pdf
45 and, in HTML form, at
47 https://web.archive.org/web/20041010010846/http://developer.apple.com/documentation/Networking/Conceptual/AFP/index.html
49 AFP 3.2 programming guide, in PDF form, at
51 https://web.archive.org/web/20060207231337/http://developer.apple.com/documentation/Networking/Conceptual/AFP/AFP3_1.pdf
53 and, in HTML form, at
55 https://web.archive.org/web/20080514131536/http://developer.apple.com/documentation/Networking/Conceptual/AFP/Introduction/chapter_1_section_1.html
57 AFP 3.x specification, as of 2012, in PDF form, at
58 https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.363.9481&rep=rep1&type=pdf
60 Current AFP 3.x programming guide, in HTML form, at
61 https://developer.apple.com/library/archive/documentation/Networking/Conceptual/AFP/Introduction/Introduction.html
63 The netatalk source code by Wesley Craig & Adrian Sun
64 http://netatalk.sf.net
66 XXX - distinguish between UTF-8 and Mac proprietary encodings for strings?
67 Does that need a preference in case we didn't see the client and server
68 negotiate that?
70 /* Forward declarations */
71 void proto_register_afp(void);
72 void proto_reg_handoff_afp(void);
74 /* from netatalk/include/afp.h */
75 #define AFPTRANS_NONE 0
76 #define AFPTRANS_DDP (1U << 0)
77 #define AFPTRANS_TCP (1U << 1)
78 #define AFPTRANS_ALL (AFPTRANS_DDP | AFPTRANS_TCP)
80 /* AFP Attention Codes -- 4 bits */
81 #define AFPATTN_SHUTDOWN (1U << 15) /* shutdown/disconnect */
82 #define AFPATTN_CRASH (1U << 14) /* server crashed */
83 #define AFPATTN_MESG (1U << 13) /* server has message */
84 #define AFPATTN_NORECONNECT (1U << 12) /* don't reconnect */
85 /* server notification */
86 #define AFPATTN_NOTIFY (AFPATTN_MESG | AFPATTN_NORECONNECT)
88 /* extended bitmap -- 12 bits. volchanged is only useful w/ a server
89 * notification, and time is only useful for shutdown. */
90 #define AFPATTN_VOLCHANGED (1U << 0) /* volume has changed */
91 #define AFPATTN_TIME(x) ((x) & 0xfff) /* time in minutes */
93 /* AFP functions */
94 #define AFP_BYTELOCK 1
95 #define AFP_CLOSEVOL 2
96 #define AFP_CLOSEDIR 3
97 #define AFP_CLOSEFORK 4
98 #define AFP_COPYFILE 5
99 #define AFP_CREATEDIR 6
100 #define AFP_CREATEFILE 7
101 #define AFP_DELETE 8
102 #define AFP_ENUMERATE 9
103 #define AFP_FLUSH 10
104 #define AFP_FLUSHFORK 11
105 #define AFP_GETFORKPARAM 14
106 #define AFP_GETSRVINFO 15
107 #define AFP_GETSRVPARAM 16
108 #define AFP_GETVOLPARAM 17
109 #define AFP_LOGIN 18
110 #define AFP_LOGINCONT 19
111 #define AFP_LOGOUT 20
112 #define AFP_MAPID 21
113 #define AFP_MAPNAME 22
114 #define AFP_MOVE 23
115 #define AFP_OPENVOL 24
116 #define AFP_OPENDIR 25
117 #define AFP_OPENFORK 26
118 #define AFP_READ 27
119 #define AFP_RENAME 28
120 #define AFP_SETDIRPARAM 29
121 #define AFP_SETFILEPARAM 30
122 #define AFP_SETFORKPARAM 31
123 #define AFP_SETVOLPARAM 32
124 #define AFP_WRITE 33
125 #define AFP_GETFLDRPARAM 34
126 #define AFP_SETFLDRPARAM 35
127 #define AFP_CHANGEPW 36
128 #define AFP_GETUSERINFO 37
129 #define AFP_GETSRVRMSG 38
130 #define AFP_CREATEID 39
131 #define AFP_DELETEID 40
132 #define AFP_RESOLVEID 41
133 #define AFP_EXCHANGEFILE 42
134 #define AFP_CATSEARCH 43
135 #define AFP_OPENDT 48
136 #define AFP_CLOSEDT 49
137 #define AFP_GETICON 51
138 #define AFP_GTICNINFO 52
139 #define AFP_ADDAPPL 53
140 #define AFP_RMVAPPL 54
141 #define AFP_GETAPPL 55
142 #define AFP_ADDCMT 56
143 #define AFP_RMVCMT 57
144 #define AFP_GETCMT 58
146 #define AFP_ZZZ 122
147 #define AFP_ADDICON 192
149 /* AFP 3.0 new calls */
150 #define AFP_BYTELOCK_EXT 59
151 #define AFP_READ_EXT 60
152 #define AFP_WRITE_EXT 61
153 #define AFP_LOGIN_EXT 63
154 #define AFP_GETSESSTOKEN 64
155 #define AFP_DISCTOLDSESS 65
156 #define AFP_ENUMERATE_EXT 66
157 #define AFP_CATSEARCH_EXT 67
159 /* AFP 3.1 new calls */
160 #define AFP_ENUMERATE_EXT2 68
162 /* AFP 3.2 new calls */
163 #define AFP_GETEXTATTR 69
164 #define AFP_SETEXTATTR 70
165 #define AFP_REMOVEATTR 71
166 #define AFP_LISTEXTATTR 72
167 #define AFP_GETACL 73
168 #define AFP_SETACL 74
169 #define AFP_ACCESS 75
171 /* AFP 3.2 calls added in 10.5 */
172 #define AFP_SPOTLIGHTRPC 76
173 #define AFP_SYNCDIR 78
174 #define AFP_SYNCFORK 79
176 /* FPSpotlightRPC subcommand codes */
177 #define SPOTLIGHT_CMD_GET_VOLPATH 4
178 #define SPOTLIGHT_CMD_GET_VOLID 2
179 #define SPOTLIGHT_CMD_GET_THREE 3
181 /* Spotlight epoch is UNIX epoch minus SPOTLIGHT_TIME_DELTA */
182 #define SPOTLIGHT_TIME_DELTA UINT64_C(280878921600)
184 /* ----------------------------- */
185 static int proto_afp;
186 static int hf_afp_reserved;
187 static int hf_afp_unknown;
189 static int hf_afp_command; /* CommandCode */
190 static int hf_afp_Version;
191 static int hf_afp_UAM;
192 static int hf_afp_user;
193 static int hf_afp_passwd;
194 static int hf_afp_random;
196 static int hf_afp_response_to;
197 static int hf_afp_time;
198 static int hf_afp_response_in;
200 static int hf_afp_login_flags;
201 static int hf_afp_pad;
203 static int hf_afp_user_type;
204 static int hf_afp_user_len;
205 static int hf_afp_user_name;
207 static int hf_afp_vol_flag;
208 static int hf_afp_vol_flag_passwd;
209 static int hf_afp_vol_flag_has_config;
210 static int hf_afp_server_time;
212 static int hf_afp_vol_bitmap;
213 static int hf_afp_vol_name_offset;
214 static int hf_afp_vol_id;
215 static int hf_afp_vol_attribute;
216 static int hf_afp_vol_name;
217 static int hf_afp_vol_signature;
218 static int hf_afp_vol_creation_date;
219 static int hf_afp_vol_modification_date;
220 static int hf_afp_vol_backup_date;
221 static int hf_afp_vol_bytes_free;
222 static int hf_afp_vol_bytes_total;
223 static int hf_afp_vol_ex_bytes_free;
224 static int hf_afp_vol_ex_bytes_total;
225 static int hf_afp_vol_block_size;
227 /* desktop stuff */
228 static int hf_afp_comment;
229 static int hf_afp_file_creator;
230 static int hf_afp_file_type;
231 static int hf_afp_icon_type;
232 static int hf_afp_icon_length;
233 static int hf_afp_icon_tag;
234 static int hf_afp_icon_index;
235 static int hf_afp_appl_index;
236 static int hf_afp_appl_tag;
238 static int hf_afp_did;
239 static int hf_afp_file_id;
240 static int hf_afp_file_DataForkLen;
241 static int hf_afp_file_RsrcForkLen;
242 static int hf_afp_file_ExtDataForkLen;
243 static int hf_afp_file_ExtRsrcForkLen;
245 static int hf_afp_dir_bitmap;
246 static int hf_afp_dir_offspring;
247 static int hf_afp_dir_OwnerID;
248 static int hf_afp_dir_GroupID;
250 static int hf_afp_req_count;
251 static int hf_afp_start_index;
252 static int hf_afp_start_index32;
253 static int hf_afp_max_reply_size;
254 static int hf_afp_max_reply_size32;
255 static int hf_afp_file_flag;
256 static int hf_afp_create_flag;
257 static int hf_afp_struct_size;
258 static int hf_afp_struct_size16;
260 static int hf_afp_cat_count;
261 static int hf_afp_cat_req_matches;
262 static int hf_afp_cat_position;
264 static int hf_afp_creation_date;
265 static int hf_afp_modification_date;
266 static int hf_afp_backup_date;
267 static int hf_afp_finder_info;
268 static int hf_afp_long_name_offset;
269 static int hf_afp_short_name_offset;
270 static int hf_afp_unicode_name_offset;
271 static int hf_afp_unix_privs_uid;
272 static int hf_afp_unix_privs_gid;
273 static int hf_afp_unix_privs_permissions;
274 static int hf_afp_unix_privs_ua_permissions;
276 static int hf_afp_path_type;
277 static int hf_afp_path_len;
278 static int hf_afp_path_name;
279 static int hf_afp_path_unicode_hint;
280 static int hf_afp_path_unicode_len;
282 static int hf_afp_flag;
283 static int hf_afp_dt_ref;
284 static int hf_afp_ofork;
285 static int hf_afp_ofork_len;
286 static int hf_afp_offset;
287 static int hf_afp_rw_count;
288 static int hf_afp_newline_mask;
289 static int hf_afp_newline_char;
290 static int hf_afp_last_written;
292 static int hf_afp_fork_type;
293 static int hf_afp_access_mode;
294 static int hf_afp_access_read;
295 static int hf_afp_access_write;
296 static int hf_afp_access_deny_read;
297 static int hf_afp_access_deny_write;
299 static int hf_afp_lock_op;
300 static int hf_afp_lock_from;
301 static int hf_afp_lock_offset;
302 static int hf_afp_lock_len;
303 static int hf_afp_lock_range_start;
305 static int ett_afp;
307 static int ett_afp_vol_attribute;
308 static int ett_afp_enumerate;
309 static int ett_afp_enumerate_line;
310 static int ett_afp_access_mode;
312 static int ett_afp_vol_bitmap;
313 static int ett_afp_dir_bitmap;
314 static int ett_afp_dir_attribute;
315 static int ett_afp_file_attribute;
316 static int ett_afp_file_bitmap;
317 static int ett_afp_unix_privs;
318 static int ett_afp_path_name;
319 static int ett_afp_lock_flags;
320 static int ett_afp_dir_ar;
322 static int ett_afp_server_vol;
323 static int ett_afp_vol_list;
324 static int ett_afp_vol_flag;
325 static int ett_afp_cat_search;
326 static int ett_afp_cat_r_bitmap;
327 static int ett_afp_cat_spec;
328 static int ett_afp_vol_did;
330 /* AFP 3.0 parameters */
331 static int hf_afp_lock_offset64;
332 static int hf_afp_lock_len64;
333 static int hf_afp_lock_range_start64;
335 static int hf_afp_offset64;
336 static int hf_afp_rw_count64;
337 static int hf_afp_reqcount64;
339 static int hf_afp_last_written64;
341 static int hf_afp_ofork_len64;
342 static int hf_afp_session_token_type;
343 static int hf_afp_session_token_len;
344 static int hf_afp_session_token;
345 static int hf_afp_session_token_timestamp;
347 /* AFP 3.2 */
349 static int hf_afp_extattr_bitmap;
350 static int hf_afp_extattr_bitmap_NoFollow;
351 static int hf_afp_extattr_bitmap_Create;
352 static int hf_afp_extattr_bitmap_Replace;
353 static int ett_afp_extattr_bitmap;
354 static int hf_afp_extattr_namelen;
355 static int hf_afp_extattr_name;
356 static int hf_afp_extattr_len;
357 static int hf_afp_extattr_data;
358 static int hf_afp_extattr_req_count;
359 static int hf_afp_extattr_start_index;
360 static int hf_afp_extattr_reply_size;
361 static int ett_afp_extattr_names;
363 static expert_field ei_afp_subquery_count_over_safety_limit;
364 static expert_field ei_afp_subquery_count_over_query_count;
365 static expert_field ei_afp_abnormal_num_subqueries;
366 static expert_field ei_afp_too_many_acl_entries;
367 static expert_field ei_afp_ip_port_reused;
368 static expert_field ei_afp_toc_offset;
371 static int afp_tap;
373 static dissector_handle_t spotlight_handle;
375 static const value_string vol_signature_vals[] = {
376 {1, "Flat"},
377 {2, "Fixed Directory ID"},
378 {3, "Variable Directory ID (deprecated)"},
379 {0, NULL }
382 static const value_string CommandCode_vals[] = {
383 {AFP_BYTELOCK, "FPByteRangeLock" },
384 {AFP_CLOSEVOL, "FPCloseVol" },
385 {AFP_CLOSEDIR, "FPCloseDir" },
386 {AFP_CLOSEFORK, "FPCloseFork" },
387 {AFP_COPYFILE, "FPCopyFile" },
388 {AFP_CREATEDIR, "FPCreateDir" },
389 {AFP_CREATEFILE, "FPCreateFile" },
390 {AFP_DELETE, "FPDelete" },
391 {AFP_ENUMERATE, "FPEnumerate" },
392 {AFP_FLUSH, "FPFlush" },
393 {AFP_FLUSHFORK, "FPFlushFork" },
394 {AFP_GETFORKPARAM, "FPGetForkParms" },
395 {AFP_GETSRVINFO, "FPGetSrvrInfo" },
396 {AFP_GETSRVPARAM, "FPGetSrvrParms" },
397 {AFP_GETVOLPARAM, "FPGetVolParms" },
398 {AFP_LOGIN, "FPLogin" },
399 {AFP_LOGINCONT, "FPLoginCont" },
400 {AFP_LOGOUT, "FPLogout" },
401 {AFP_MAPID, "FPMapID" },
402 {AFP_MAPNAME, "FPMapName" },
403 {AFP_MOVE, "FPMoveAndRename" },
404 {AFP_OPENVOL, "FPOpenVol" },
405 {AFP_OPENDIR, "FPOpenDir" },
406 {AFP_OPENFORK, "FPOpenFork" },
407 {AFP_READ, "FPRead" },
408 {AFP_RENAME, "FPRename" },
409 {AFP_SETDIRPARAM, "FPSetDirParms" },
410 {AFP_SETFILEPARAM, "FPSetFileParms" },
411 {AFP_SETFORKPARAM, "FPSetForkParms" },
412 {AFP_SETVOLPARAM, "FPSetVolParms" },
413 {AFP_WRITE, "FPWrite" },
414 {AFP_GETFLDRPARAM, "FPGetFileDirParms" },
415 {AFP_SETFLDRPARAM, "FPSetFileDirParms" },
416 {AFP_CHANGEPW, "FPChangePassword" },
417 {AFP_GETUSERINFO, "FPGetUserInfo" },
418 {AFP_GETSRVRMSG, "FPGetSrvrMsg" },
419 {AFP_CREATEID, "FPCreateID" },
420 {AFP_DELETEID, "FPDeleteID" },
421 {AFP_RESOLVEID, "FPResolveID" },
422 {AFP_EXCHANGEFILE, "FPExchangeFiles" },
423 {AFP_CATSEARCH, "FPCatSearch" },
424 {AFP_OPENDT, "FPOpenDT" },
425 {AFP_CLOSEDT, "FPCloseDT" },
426 {AFP_GETICON, "FPGetIcon" },
427 {AFP_GTICNINFO, "FPGetIconInfo" },
428 {AFP_ADDAPPL, "FPAddAPPL" },
429 {AFP_RMVAPPL, "FPRemoveAPPL" },
430 {AFP_GETAPPL, "FPGetAPPL" },
431 {AFP_ADDCMT, "FPAddComment" },
432 {AFP_RMVCMT, "FPRemoveComment" },
433 {AFP_GETCMT, "FPGetComment" },
434 {AFP_BYTELOCK_EXT, "FPByteRangeLockExt" },
435 {AFP_READ_EXT, "FPReadExt" },
436 {AFP_WRITE_EXT, "FPWriteExt" },
437 {AFP_LOGIN_EXT, "FPLoginExt" },
438 {AFP_GETSESSTOKEN, "FPGetSessionToken" },
439 {AFP_DISCTOLDSESS, "FPDisconnectOldSession" },
440 {AFP_ENUMERATE_EXT, "FPEnumerateExt" },
441 {AFP_CATSEARCH_EXT, "FPCatSearchExt" },
442 {AFP_ENUMERATE_EXT2, "FPEnumerateExt2" },
443 {AFP_GETEXTATTR, "FPGetExtAttr" },
444 {AFP_SETEXTATTR, "FPSetExtAttr" },
445 {AFP_REMOVEATTR, "FPRemoveExtAttr" },
446 {AFP_LISTEXTATTR, "FPListExtAttrs" },
447 {AFP_GETACL, "FPGetACL" },
448 {AFP_SETACL, "FPSetACL" },
449 {AFP_ACCESS, "FPAccess" },
450 {AFP_SPOTLIGHTRPC, "FPSpotlightRPC" },
451 {AFP_SYNCDIR, "FPSyncDir" },
452 {AFP_SYNCFORK, "FPSyncFork" },
453 {AFP_ZZZ, "FPZzzzz" },
454 {AFP_ADDICON, "FPAddIcon" },
455 {0, NULL }
457 value_string_ext CommandCode_vals_ext = VALUE_STRING_EXT_INIT(CommandCode_vals);
459 static const value_string unicode_hint_vals[] = {
460 { 0, "MacRoman" },
461 { 1, "MacJapanese" },
462 { 2, "MacChineseTrad" },
463 { 3, "MacKorean" },
464 { 4, "MacArabic" },
465 { 5, "MacHebrew" },
466 { 6, "MacGreek" },
467 { 7, "MacCyrillic" },
468 { 9, "MacDevanagari" },
469 { 10, "MacGurmukhi" },
470 { 11, "MacGujarati" },
471 { 12, "MacOriya" },
472 { 13, "MacBengali" },
473 { 14, "MacTamil" },
474 { 15, "MacTelugu" },
475 { 16, "MacKannada" },
476 { 17, "MacMalayalam" },
477 { 18, "MacSinhalese" },
478 { 19, "MacBurmese" },
479 { 20, "MacKhmer" },
480 { 21, "MacThai" },
481 { 22, "MacLaotian" },
482 { 23, "MacGeorgian" },
483 { 24, "MacArmenian" },
484 { 25, "MacChineseSimp" },
485 { 26, "MacTibetan" },
486 { 27, "MacMongolian" },
487 { 28, "MacEthiopic" },
488 { 29, "MacCentralEurRoman" },
489 { 30, "MacVietnamese" },
490 { 31, "MacExtArabic" },
491 { 33, "MacSymbol" },
492 { 34, "MacDingbats" },
493 { 35, "MacTurkish" },
494 { 36, "MacCroatian" },
495 { 37, "MacIcelandic" },
496 { 38, "MacRomanian" },
497 { 39, "MacCeltic" },
498 { 40, "MacGaelic" },
499 { 41, "MacKeyboardGlyphs" },
500 { 126, "MacUnicode" },
501 { 140, "MacFarsi" },
502 { 152, "MacUkrainian" },
503 { 236, "MacInuit" },
504 { 252, "MacVT100" },
505 { 255, "MacHFS" },
506 { 256, "UnicodeDefault" },
507 /* ?? { 257, "UnicodeV1_1" }, */
508 { 257, "ISO10646_1993" },
509 { 259, "UnicodeV2_0" },
510 /* ?? { 259, "UnicodeV2_1" }, */
511 { 260, "UnicodeV3_0" },
512 { 513, "ISOLatin1" },
513 { 514, "ISOLatin2" },
514 { 515, "ISOLatin3" },
515 { 516, "ISOLatin4" },
516 { 517, "ISOLatinCyrillic" },
517 { 518, "ISOLatinArabic" },
518 { 519, "ISOLatinGreek" },
519 { 520, "ISOLatinHebrew" },
520 { 521, "ISOLatin5" },
521 { 522, "ISOLatin6" },
522 { 525, "ISOLatin7" },
523 { 526, "ISOLatin8" },
524 { 527, "ISOLatin9" },
525 { 1024, "DOSLatinUS" },
526 { 1029, "DOSGreek" },
527 { 1030, "DOSBalticRim" },
528 { 1040, "DOSLatin1" },
529 { 1041, "DOSGreek1" },
530 { 1042, "DOSLatin2" },
531 { 1043, "DOSCyrillic" },
532 { 1044, "DOSTurkish" },
533 { 1045, "DOSPortuguese" },
534 { 1046, "DOSIcelandic" },
535 { 1047, "DOSHebrew" },
536 { 1048, "DOSCanadianFrench" },
537 { 1049, "DOSArabic" },
538 { 1050, "DOSNordic" },
539 { 1051, "DOSRussian" },
540 { 1052, "DOSGreek2" },
541 { 1053, "DOSThai" },
542 { 1056, "DOSJapanese" },
543 { 1057, "DOSChineseSimplif" },
544 { 1058, "DOSKorean" },
545 { 1059, "DOSChineseTrad" },
546 { 1280, "WindowsLatin1" },
547 /* { 1280, "WindowsANSI" }, */
548 { 1281, "WindowsLatin2" },
549 { 1282, "WindowsCyrillic" },
550 { 1283, "WindowsGreek" },
551 { 1284, "WindowsLatin5" },
552 { 1285, "WindowsHebrew" },
553 { 1286, "WindowsArabic" },
554 { 1287, "WindowsBalticRim" },
555 { 1288, "WindowsVietnamese" },
556 { 1296, "WindowsKoreanJohab" },
557 { 1536, "US_ASCII" },
558 { 1568, "JIS_X0201_76" },
559 { 1569, "JIS_X0208_83" },
560 { 1570, "JIS_X0208_90" },
561 { 0, NULL }
563 static value_string_ext unicode_hint_vals_ext = VALUE_STRING_EXT_INIT(unicode_hint_vals);
565 /* volume bitmap
566 from Apple AFP3.0.pdf
567 Table 1-2 p. 20
569 #define kFPVolAttributeBit (1U << 0)
570 #define kFPVolSignatureBit (1U << 1)
571 #define kFPVolCreateDateBit (1U << 2)
572 #define kFPVolModDateBit (1U << 3)
573 #define kFPVolBackupDateBit (1U << 4)
574 #define kFPVolIDBit (1U << 5)
575 #define kFPVolBytesFreeBit (1U << 6)
576 #define kFPVolBytesTotalBit (1U << 7)
577 #define kFPVolNameBit (1U << 8)
578 #define kFPVolExtBytesFreeBit (1U << 9)
579 #define kFPVolExtBytesTotalBit (1U << 10)
580 #define kFPVolBlockSizeBit (1U << 11)
582 static int hf_afp_vol_bitmap_Attributes;
583 static int hf_afp_vol_bitmap_Signature;
584 static int hf_afp_vol_bitmap_CreateDate;
585 static int hf_afp_vol_bitmap_ModDate;
586 static int hf_afp_vol_bitmap_BackupDate;
587 static int hf_afp_vol_bitmap_ID;
588 static int hf_afp_vol_bitmap_BytesFree;
589 static int hf_afp_vol_bitmap_BytesTotal;
590 static int hf_afp_vol_bitmap_Name;
591 static int hf_afp_vol_bitmap_ExtBytesFree;
592 static int hf_afp_vol_bitmap_ExtBytesTotal;
593 static int hf_afp_vol_bitmap_BlockSize;
595 static int hf_afp_vol_attribute_ReadOnly;
596 static int hf_afp_vol_attribute_HasVolumePassword;
597 static int hf_afp_vol_attribute_SupportsFileIDs;
598 static int hf_afp_vol_attribute_SupportsCatSearch;
599 static int hf_afp_vol_attribute_SupportsBlankAccessPrivs;
600 static int hf_afp_vol_attribute_SupportsUnixPrivs;
601 static int hf_afp_vol_attribute_SupportsUTF8Names;
602 static int hf_afp_vol_attribute_NoNetworkUserID;
603 static int hf_afp_vol_attribute_DefaultPrivsFromParent;
604 static int hf_afp_vol_attribute_NoExchangeFiles;
605 static int hf_afp_vol_attribute_SupportsExtAttrs;
606 static int hf_afp_vol_attribute_SupportsACLs;
607 static int hf_afp_vol_attribute_CaseSensitive;
608 static int hf_afp_vol_attribute_SupportsTMLockSteal;
610 static int hf_afp_dir_bitmap_Attributes;
611 static int hf_afp_dir_bitmap_ParentDirID;
612 static int hf_afp_dir_bitmap_CreateDate;
613 static int hf_afp_dir_bitmap_ModDate;
614 static int hf_afp_dir_bitmap_BackupDate;
615 static int hf_afp_dir_bitmap_FinderInfo;
616 static int hf_afp_dir_bitmap_LongName;
617 static int hf_afp_dir_bitmap_ShortName;
618 static int hf_afp_dir_bitmap_NodeID;
619 static int hf_afp_dir_bitmap_OffspringCount;
620 static int hf_afp_dir_bitmap_OwnerID;
621 static int hf_afp_dir_bitmap_GroupID;
622 static int hf_afp_dir_bitmap_AccessRights;
623 static int hf_afp_dir_bitmap_UTF8Name;
624 static int hf_afp_dir_bitmap_UnixPrivs;
626 static int hf_afp_dir_attribute;
627 static int hf_afp_dir_attribute_Invisible;
628 static int hf_afp_dir_attribute_IsExpFolder;
629 static int hf_afp_dir_attribute_System;
630 static int hf_afp_dir_attribute_Mounted;
631 static int hf_afp_dir_attribute_InExpFolder;
632 static int hf_afp_dir_attribute_BackUpNeeded;
633 static int hf_afp_dir_attribute_RenameInhibit;
634 static int hf_afp_dir_attribute_DeleteInhibit;
636 static int hf_afp_file_bitmap;
637 static int hf_afp_file_bitmap_Attributes;
638 static int hf_afp_file_bitmap_ParentDirID;
639 static int hf_afp_file_bitmap_CreateDate;
640 static int hf_afp_file_bitmap_ModDate;
641 static int hf_afp_file_bitmap_BackupDate;
642 static int hf_afp_file_bitmap_FinderInfo;
643 static int hf_afp_file_bitmap_LongName;
644 static int hf_afp_file_bitmap_ShortName;
645 static int hf_afp_file_bitmap_NodeID;
646 static int hf_afp_file_bitmap_DataForkLen;
647 static int hf_afp_file_bitmap_RsrcForkLen;
648 static int hf_afp_file_bitmap_ExtDataForkLen;
649 static int hf_afp_file_bitmap_LaunchLimit;
651 static int hf_afp_file_bitmap_UTF8Name;
652 static int hf_afp_file_bitmap_ExtRsrcForkLen;
653 static int hf_afp_file_bitmap_UnixPrivs;
655 static int hf_afp_file_attribute;
656 static int hf_afp_file_attribute_Invisible;
657 static int hf_afp_file_attribute_MultiUser;
658 static int hf_afp_file_attribute_System;
659 static int hf_afp_file_attribute_DAlreadyOpen;
660 static int hf_afp_file_attribute_RAlreadyOpen;
661 static int hf_afp_file_attribute_WriteInhibit;
662 static int hf_afp_file_attribute_BackUpNeeded;
663 static int hf_afp_file_attribute_RenameInhibit;
664 static int hf_afp_file_attribute_DeleteInhibit;
665 static int hf_afp_file_attribute_CopyProtect;
666 static int hf_afp_file_attribute_SetClear;
668 static int hf_afp_map_name_type;
669 static int hf_afp_map_name;
670 static int hf_afp_map_id;
671 static int hf_afp_map_id_type;
672 static int hf_afp_map_id_reply_type;
674 /* catsearch stuff */
675 static int hf_afp_request_bitmap;
676 static int hf_afp_request_bitmap_Attributes;
677 static int hf_afp_request_bitmap_ParentDirID;
678 static int hf_afp_request_bitmap_CreateDate;
679 static int hf_afp_request_bitmap_ModDate;
680 static int hf_afp_request_bitmap_BackupDate;
681 static int hf_afp_request_bitmap_FinderInfo;
682 static int hf_afp_request_bitmap_LongName;
683 static int hf_afp_request_bitmap_DataForkLen;
684 static int hf_afp_request_bitmap_OffspringCount;
685 static int hf_afp_request_bitmap_RsrcForkLen;
686 static int hf_afp_request_bitmap_ExtDataForkLen;
687 static int hf_afp_request_bitmap_UTF8Name;
688 static int hf_afp_request_bitmap_ExtRsrcForkLen;
689 static int hf_afp_request_bitmap_PartialNames;
691 /* Spotlight stuff */
692 static int ett_afp_spotlight_queries;
693 static int ett_afp_spotlight_query_line;
694 static int ett_afp_spotlight_query;
695 static int ett_afp_spotlight_data;
696 static int ett_afp_spotlight_toc;
698 static int hf_afp_spotlight_request_flags;
699 static int hf_afp_spotlight_request_command;
700 static int hf_afp_spotlight_request_reserved;
701 static int hf_afp_spotlight_reply_reserved;
702 static int hf_afp_spotlight_volpath_server;
703 static int hf_afp_spotlight_volpath_client;
704 static int hf_afp_spotlight_returncode;
705 static int hf_afp_spotlight_volflags;
706 static int hf_afp_spotlight_reqlen;
707 static int hf_afp_spotlight_uuid;
708 static int hf_afp_spotlight_date;
710 /* Status stuff from ASP or DSI */
711 static int ett_afp_status;
712 static int ett_afp_uams;
713 static int ett_afp_vers;
714 static int ett_afp_server_addr;
715 static int ett_afp_server_addr_line;
716 static int ett_afp_directory;
717 static int ett_afp_utf8_name;
718 static int ett_afp_status_server_flag;
720 static const value_string flag_vals[] = {
721 {0, "Start" },
722 {1, "End" },
723 {0, NULL } };
725 static const value_string path_type_vals[] = {
726 {1, "Short names" },
727 {2, "Long names" },
728 {3, "Unicode names" },
729 {0, NULL } };
731 static const value_string map_name_type_vals[] = {
732 {1, "Unicode user name to a user ID" },
733 {2, "Unicode group name to a group ID" },
734 {3, "Macintosh roman user name to a user ID" },
735 {4, "Macintosh roman group name to a group ID" },
736 {5, "Unicode user name to a user UUID" },
737 {6, "Unicode group name to a group UUID" },
738 {0, NULL } };
739 static value_string_ext map_name_type_vals_ext = VALUE_STRING_EXT_INIT(map_name_type_vals);
741 static const value_string map_id_type_vals[] = {
742 {1, "User ID to a Macintosh roman user name" },
743 {2, "Group ID to a Macintosh roman group name" },
744 {3, "User ID to a unicode user name" },
745 {4, "Group ID to a unicode group name" },
746 {5, "User UUID to a unicode user name" },
747 {6, "Group UUID to a unicode group name" },
748 {0, NULL } };
749 static value_string_ext map_id_type_vals_ext = VALUE_STRING_EXT_INIT(map_id_type_vals);
751 /* map_id subfunctions 5,6: reply type */
752 static const value_string map_id_reply_type_vals[] = {
753 {1, "user name" },
754 {2, "group name" },
755 {0, NULL } };
758 volume attribute from Apple AFP3.0.pdf
759 Table 1-3 p. 22
761 #define kReadOnly (1U << 0)
762 #define kHasVolumePassword (1U << 1)
763 #define kSupportsFileIDs (1U << 2)
764 #define kSupportsCatSearch (1U << 3)
765 #define kSupportsBlankAccessPrivs (1U << 4)
766 #define kSupportsUnixPrivs (1U << 5)
767 #define kSupportsUTF8Names (1U << 6)
768 /* AFP3.1 */
769 #define kNoNetworkUserIDs (1U << 7)
770 /* AFP3.2 */
771 #define kDefaultPrivsFromParent (1U << 8)
772 #define kNoExchangeFiles (1U << 9)
773 #define kSupportsExtAttrs (1U << 10)
774 #define kSupportsACLs (1U << 11)
775 /* AFP3.2+ */
776 #define kCaseSensitive (1U << 12)
777 #define kSupportsTMLockSteal (1U << 13)
780 directory bitmap from Apple AFP3.1.pdf
781 Table 1-5 pp. 25-26
783 #define kFPAttributeBit (1U << 0)
784 #define kFPParentDirIDBit (1U << 1)
785 #define kFPCreateDateBit (1U << 2)
786 #define kFPModDateBit (1U << 3)
787 #define kFPBackupDateBit (1U << 4)
788 #define kFPFinderInfoBit (1U << 5)
789 #define kFPLongNameBit (1U << 6)
790 #define kFPShortNameBit (1U << 7)
791 #define kFPNodeIDBit (1U << 8)
792 #define kFPOffspringCountBit (1U << 9)
793 #define kFPOwnerIDBit (1U << 10)
794 #define kFPGroupIDBit (1U << 11)
795 #define kFPAccessRightsBit (1U << 12)
796 #define kFPUTF8NameBit (1U << 13)
798 /* FIXME AFP3.0 bit 14, AFP3.1 bit 15 */
800 #define kFPUnixPrivsBit (1U << 15)
803 directory Access Rights parameter AFP3.1.pdf
804 table 1-7 p. 28
807 #define AR_O_SEARCH (1U << 0) /* owner has search access */
808 #define AR_O_READ (1U << 1) /* owner has read access */
809 #define AR_O_WRITE (1U << 2) /* owner has write access */
811 #define AR_G_SEARCH (1U << 8) /* group has search access */
812 #define AR_G_READ (1U << 9) /* group has read access */
813 #define AR_G_WRITE (1U << 10) /* group has write access */
815 #define AR_E_SEARCH (1U << 16) /* everyone has search access */
816 #define AR_E_READ (1U << 17) /* everyone has read access */
817 #define AR_E_WRITE (1U << 18) /* everyone has write access */
819 #define AR_U_SEARCH (1U << 24) /* user has search access */
820 #define AR_U_READ (1U << 25) /* user has read access */
821 #define AR_U_WRITE (1U << 26) /* user has write access */
823 #define AR_BLANK (1U << 28) /* Blank Access Privileges (use parent dir privileges) */
824 #define AR_U_OWN (1U << 31) /* user is the owner */
826 static int hf_afp_dir_ar;
827 static int hf_afp_dir_ar_o_search;
828 static int hf_afp_dir_ar_o_read;
829 static int hf_afp_dir_ar_o_write;
830 static int hf_afp_dir_ar_g_search;
831 static int hf_afp_dir_ar_g_read;
832 static int hf_afp_dir_ar_g_write;
833 static int hf_afp_dir_ar_e_search;
834 static int hf_afp_dir_ar_e_read;
835 static int hf_afp_dir_ar_e_write;
836 static int hf_afp_dir_ar_u_search;
837 static int hf_afp_dir_ar_u_read;
838 static int hf_afp_dir_ar_u_write;
839 static int hf_afp_dir_ar_blank;
840 static int hf_afp_dir_ar_u_own;
842 static int hf_afp_user_flag;
843 static int hf_afp_user_ID;
844 static int hf_afp_group_ID;
845 static int hf_afp_UUID;
846 static int hf_afp_GRPUUID;
847 static int hf_afp_user_bitmap;
848 static int hf_afp_user_bitmap_UID;
849 static int hf_afp_user_bitmap_GID;
850 static int hf_afp_user_bitmap_UUID;
852 static int ett_afp_user_bitmap;
854 static const value_string user_flag_vals[] = {
855 {0, "Use user ID" },
856 {1, "Default user" },
857 {0, NULL } };
859 static int hf_afp_message;
860 static int hf_afp_message_type;
861 static int hf_afp_message_bitmap;
862 static int hf_afp_message_bitmap_REQ;
863 static int hf_afp_message_bitmap_UTF;
864 static int hf_afp_message_len;
866 static int ett_afp_message_bitmap;
868 static const value_string server_message_type[] = {
869 {0, "Login message" },
870 {1, "Server message" },
871 {0, NULL } };
874 file bitmap AFP3.1.pdf
875 Table 1-8 p. 29
876 same as dir
877 kFPAttributeBit (bit 0)
878 kFPParentDirIDBit (bit 1)
879 kFPCreateDateBit (bit 2)
880 kFPModDateBit (bit 3)
881 kFPBackupDateBit (bit 4)
882 kFPFinderInfoBit (bit 5)
883 kFPLongNameBit (bit 6)
884 kFPShortNameBit (bit 7)
885 kFPNodeIDBit (bit 8)
887 kFPUTF8NameBit (bit 13)
890 #define kFPDataForkLenBit (1U << 9)
891 #define kFPRsrcForkLenBit (1U << 10)
892 #define kFPExtDataForkLenBit (1U << 11)
893 #define kFPLaunchLimitBit (1U << 12)
895 #define kFPExtRsrcForkLenBit (1U << 14)
898 file attribute AFP3.1.pdf
899 Table 1-9 pp. 29-31
901 #define kFPInvisibleBit (1U << 0)
902 #define kFPMultiUserBit (1U << 1)
903 #define kFPSystemBit (1U << 2)
904 #define kFPDAlreadyOpenBit (1U << 3)
905 #define kFPRAlreadyOpenBit (1U << 4)
906 #define kFPWriteInhibitBit (1U << 5)
907 #define kFPBackUpNeededBit (1U << 6)
908 #define kFPRenameInhibitBit (1U << 7)
909 #define kFPDeleteInhibitBit (1U << 8)
910 #define kFPCopyProtectBit (1U << 10)
911 #define kFPSetClearBit (1U << 15)
913 /* dir attribute */
914 #define kIsExpFolder (1U << 1)
915 #define kMounted (1U << 3)
916 #define kInExpFolder (1U << 4)
918 /* AFP 3.1 getsession token type */
919 #define kLoginWithoutID 0
920 #define kLoginWithID 1
921 #define kReconnWithID 2
922 #define kLoginWithTimeAndID 3
923 #define kReconnWithTimeAndID 4
925 /* modified AFP 3.1 token type cf. page 327 */
926 #define kRecon1Login 5
927 #define kRecon1ReconnectLogin 6
928 #define kRecon1Refresh 7
929 #define kGetKerberosSessionKey 8
931 static const value_string token_type_vals[] = {
932 {kLoginWithoutID, "LoginWithoutID"},
933 {kLoginWithID, "LoginWithID"},
934 {kReconnWithID, "ReconnWithID"},
935 {kLoginWithTimeAndID, "LoginWithTimeAndID"},
936 {kReconnWithTimeAndID, "ReconnWithTimeAndID"},
937 {kRecon1Login, "Recon1Login"},
938 {kRecon1ReconnectLogin, "Recon1ReconnectLogin"},
939 {kRecon1Refresh, "Recon1Refresh"},
940 {kGetKerberosSessionKey, "GetKerberosSessionKey"},
942 {0, NULL } };
943 static value_string_ext token_type_vals_ext = VALUE_STRING_EXT_INIT(token_type_vals);
945 /* AFP 3.2 ACL bitmap */
946 #define kFileSec_UUID (1U << 0)
947 #define kFileSec_GRPUUID (1U << 1)
948 #define kFileSec_ACL (1U << 2)
949 #define kFileSec_REMOVEACL (1U << 3)
950 #define kFileSec_Inherit (1U << 4)
952 static int hf_afp_acl_list_bitmap;
953 static int hf_afp_acl_list_bitmap_UUID;
954 static int hf_afp_acl_list_bitmap_GRPUUID;
955 static int hf_afp_acl_list_bitmap_ACL;
956 static int hf_afp_acl_list_bitmap_REMOVEACL;
957 static int hf_afp_acl_list_bitmap_Inherit;
958 static int ett_afp_acl_list_bitmap;
960 static int hf_afp_access_bitmap;
962 static int hf_afp_acl_entrycount;
963 static int hf_afp_acl_flags;
965 static int hf_afp_ace_flags;
967 static int ett_afp_ace_flags;
968 static int hf_afp_ace_flags_allow;
969 static int hf_afp_ace_flags_deny;
970 static int hf_afp_ace_flags_inherited;
971 static int hf_afp_ace_flags_fileinherit;
972 static int hf_afp_ace_flags_dirinherit;
973 static int hf_afp_ace_flags_limitinherit;
974 static int hf_afp_ace_flags_onlyinherit;
976 /* AFP 3.2 ACE flags */
977 #define ACE_ALLOW (1U << 0)
978 #define ACE_DENY (1U << 1)
979 #define ACE_INHERITED (1U << 4)
980 #define ACE_FILE_INHERIT (1U << 5)
981 #define ACE_DIR_INHERIT (1U << 6)
982 #define ACE_LIMIT_INHERIT (1U << 7)
983 #define ACE_ONLY_INHERIT (1U << 8)
985 static int ett_afp_ace_entries;
986 static int ett_afp_ace_entry;
988 /* AFP 3.2 ACL access right cf page 248*/
989 #define KAUTH_VNODE_READ_DATA (1U << 1)
990 #define KAUTH_VNODE_LIST_DIRECTORY KAUTH_VNODE_READ_DATA
991 #define KAUTH_VNODE_WRITE_DATA (1U << 2)
992 #define KAUTH_VNODE_ADD_FILE KAUTH_VNODE_WRITE_DATA
993 #define KAUTH_VNODE_EXECUTE (1U << 3)
994 #define KAUTH_VNODE_SEARCH KAUTH_VNODE_EXECUTE
995 #define KAUTH_VNODE_DELETE (1U << 4)
996 #define KAUTH_VNODE_APPEND_DATA (1U << 5)
997 #define KAUTH_VNODE_ADD_SUBDIRECTORY KAUTH_VNODE_APPEND_DATA
998 #define KAUTH_VNODE_DELETE_CHILD (1U << 6)
999 #define KAUTH_VNODE_READ_ATTRIBUTES (1U << 7)
1000 #define KAUTH_VNODE_WRITE_ATTRIBUTES (1U << 8)
1001 #define KAUTH_VNODE_READ_EXTATTRIBUTES (1U << 9)
1002 #define KAUTH_VNODE_WRITE_EXTATTRIBUTES (1U << 10)
1003 #define KAUTH_VNODE_READ_SECURITY (1U << 11)
1004 #define KAUTH_VNODE_WRITE_SECURITY (1U << 12)
1005 #define KAUTH_VNODE_CHANGE_OWNER (1U << 13)
1006 #define KAUTH_VNODE_SYNCHRONIZE (1U << 20)
1007 #define KAUTH_VNODE_GENERIC_ALL (1U << 21)
1008 #define KAUTH_VNODE_GENERIC_EXECUTE (1U << 22)
1009 #define KAUTH_VNODE_GENERIC_WRITE (1U << 23)
1010 #define KAUTH_VNODE_GENERIC_READ (1U << 24)
1013 static int hf_afp_acl_access_bitmap;
1014 static int ett_afp_acl_access_bitmap;
1015 static int hf_afp_acl_access_bitmap_read_data;
1016 static int hf_afp_acl_access_bitmap_write_data;
1017 static int hf_afp_acl_access_bitmap_execute;
1018 static int hf_afp_acl_access_bitmap_delete;
1019 static int hf_afp_acl_access_bitmap_append_data;
1020 static int hf_afp_acl_access_bitmap_delete_child;
1021 static int hf_afp_acl_access_bitmap_read_attrs;
1022 static int hf_afp_acl_access_bitmap_write_attrs;
1023 static int hf_afp_acl_access_bitmap_read_extattrs;
1024 static int hf_afp_acl_access_bitmap_write_extattrs;
1025 static int hf_afp_acl_access_bitmap_read_security;
1026 static int hf_afp_acl_access_bitmap_write_security;
1027 static int hf_afp_acl_access_bitmap_change_owner;
1028 static int hf_afp_acl_access_bitmap_synchronize;
1029 static int hf_afp_acl_access_bitmap_generic_all;
1030 static int hf_afp_acl_access_bitmap_generic_execute;
1031 static int hf_afp_acl_access_bitmap_generic_write;
1032 static int hf_afp_acl_access_bitmap_generic_read;
1034 /* Status stuff from ASP or DSI */
1035 static int hf_afp_server_name;
1036 static int hf_afp_utf8_server_name_len;
1037 static int hf_afp_utf8_server_name;
1038 static int hf_afp_server_type;
1039 static int hf_afp_server_vers;
1040 static int hf_afp_server_uams;
1041 static int hf_afp_server_icon;
1042 static int hf_afp_server_directory;
1044 static int hf_afp_server_flag;
1045 static int hf_afp_server_flag_copyfile;
1046 static int hf_afp_server_flag_passwd;
1047 static int hf_afp_server_flag_no_save_passwd;
1048 static int hf_afp_server_flag_srv_msg;
1049 static int hf_afp_server_flag_srv_sig;
1050 static int hf_afp_server_flag_tcpip;
1051 static int hf_afp_server_flag_notify;
1052 static int hf_afp_server_flag_reconnect;
1053 static int hf_afp_server_flag_directory;
1054 static int hf_afp_server_flag_utf8_name;
1055 static int hf_afp_server_flag_uuid;
1056 static int hf_afp_server_flag_ext_sleep;
1057 static int hf_afp_server_flag_fast_copy;
1058 static int hf_afp_server_signature;
1060 static int hf_afp_server_addr_len;
1061 static int hf_afp_server_addr_type;
1062 static int hf_afp_server_addr_value;
1064 /* Generated from convert_proto_tree_add_text.pl */
1065 static int hf_afp_int64;
1066 static int hf_afp_float;
1067 static int hf_afp_unknown16;
1068 static int hf_afp_unknown32;
1069 static int hf_afp_cnid;
1070 static int hf_afp_null;
1071 static int hf_afp_string;
1072 static int hf_afp_utf_16_string;
1073 static int hf_afp_bool;
1074 static int hf_afp_query_type;
1075 static int hf_afp_toc_offset;
1076 static int hf_afp_toc_entry;
1077 static int hf_afp_endianness;
1078 static int hf_afp_query_len;
1079 static int hf_afp_num_toc_entries;
1080 static int hf_afp_machine_offset;
1081 static int hf_afp_version_offset;
1082 static int hf_afp_uams_offset;
1083 static int hf_afp_icon_offset;
1084 static int hf_afp_signature_offset;
1085 static int hf_afp_network_address_offset;
1086 static int hf_afp_directory_services_offset;
1087 static int hf_afp_utf8_server_name_offset;
1089 static const value_string afp_server_addr_type_vals[] = {
1090 {1, "IP address" },
1091 {2, "IP+port address" },
1092 {3, "DDP address" },
1093 {4, "DNS name" },
1094 {5, "IP+port ssh tunnel" },
1095 {6, "IP6 address" },
1096 {7, "IP6+port address" },
1097 {0, NULL } };
1098 value_string_ext afp_server_addr_type_vals_ext = VALUE_STRING_EXT_INIT(afp_server_addr_type_vals);
1100 #define AFP_NUM_PROCEDURES 256
1102 static void
1103 afpstat_init(struct register_srt* srt _U_, GArray* srt_array)
1105 srt_stat_table *afp_srt_table;
1106 uint32_t i;
1108 afp_srt_table = init_srt_table("AFP Commands", NULL, srt_array, AFP_NUM_PROCEDURES, NULL, "afp.command", NULL);
1109 for (i = 0; i < AFP_NUM_PROCEDURES; i++)
1111 char* tmp_str = val_to_str_ext_wmem(NULL, i, &CommandCode_vals_ext, "Unknown(%u)");
1112 init_srt_table_row(afp_srt_table, i, tmp_str);
1113 wmem_free(NULL, tmp_str);
1117 static tap_packet_status
1118 afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv, tap_flags_t flags _U_)
1120 unsigned i = 0;
1121 srt_stat_table *afp_srt_table;
1122 srt_data_t *data = (srt_data_t *)pss;
1123 const afp_request_val *request_val = (const afp_request_val *)prv;
1125 /* if we haven't seen the request, just ignore it */
1126 if (!request_val) {
1127 return TAP_PACKET_DONT_REDRAW;
1130 afp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
1132 add_srt_table_data(afp_srt_table, request_val->command, &request_val->req_time, pinfo);
1134 return TAP_PACKET_REDRAW;
1139 #define hash_init_count 20
1141 /* Forward declarations */
1143 /* Hash functions */
1144 static int afp_equal (const void *v, const void *v2);
1145 static unsigned afp_hash (const void *v);
1147 typedef struct {
1148 uint32_t conversation;
1149 uint16_t tid;
1150 } afp_request_key;
1152 static wmem_map_t *afp_request_hash;
1154 static unsigned Vol; /* volume */
1155 static unsigned Did; /* parent directory ID */
1158 * Returns the UTF-16 byte order, as an ENC_xxx_ENDIAN value,
1159 * by checking the 2-byte byte order mark.
1160 * If there is no byte order mark, 0xFFFFFFFF is returned.
1162 static unsigned
1163 spotlight_get_utf16_string_byte_order(tvbuff_t *tvb, int offset, int query_length, unsigned encoding) {
1164 unsigned byte_order;
1166 /* check for byte order mark */
1167 byte_order = 0xFFFFFFFF;
1168 if (query_length >= 2) {
1169 uint16_t byte_order_mark;
1170 byte_order_mark = tvb_get_uint16(tvb, offset, encoding);
1172 if (byte_order_mark == 0xFFFE) {
1173 byte_order = ENC_BIG_ENDIAN;
1175 else if (byte_order_mark == 0xFEFF) {
1176 byte_order = ENC_LITTLE_ENDIAN;
1180 return byte_order;
1183 /* Hash Functions */
1184 static int afp_equal (const void *v, const void *v2)
1186 const afp_request_key *val1 = (const afp_request_key*)v;
1187 const afp_request_key *val2 = (const afp_request_key*)v2;
1189 if (val1->conversation == val2->conversation &&
1190 val1->tid == val2->tid) {
1191 return 1;
1193 return 0;
1196 static unsigned afp_hash (const void *v)
1198 const afp_request_key *afp_key = (const afp_request_key*)v;
1199 return afp_key->tid;
1202 /* --------------------------
1204 #define PAD(x) { proto_tree_add_item(tree, hf_afp_pad, tvb, offset, x, ENC_NA); offset += x; }
1206 static uint16_t
1207 decode_vol_bitmap (proto_tree *tree, tvbuff_t *tvb, int offset)
1209 uint16_t bitmap;
1210 static int * const bitmaps[] = {
1211 &hf_afp_vol_bitmap_Attributes,
1212 &hf_afp_vol_bitmap_Signature,
1213 &hf_afp_vol_bitmap_CreateDate,
1214 &hf_afp_vol_bitmap_ModDate,
1215 &hf_afp_vol_bitmap_BackupDate,
1216 &hf_afp_vol_bitmap_ID,
1217 &hf_afp_vol_bitmap_BytesFree,
1218 &hf_afp_vol_bitmap_BytesTotal,
1219 &hf_afp_vol_bitmap_Name,
1220 &hf_afp_vol_bitmap_ExtBytesFree,
1221 &hf_afp_vol_bitmap_ExtBytesTotal,
1222 &hf_afp_vol_bitmap_BlockSize,
1223 NULL
1226 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_vol_bitmap,
1227 ett_afp_vol_bitmap, bitmaps, ENC_BIG_ENDIAN);
1228 bitmap = tvb_get_ntohs(tvb, offset);
1230 return bitmap;
1233 /* -------------------------- */
1234 static uint16_t
1235 decode_vol_attribute (proto_tree *tree, tvbuff_t *tvb, int offset)
1237 uint16_t bitmap;
1238 static int * const bitmaps[] = {
1239 &hf_afp_vol_attribute_ReadOnly,
1240 &hf_afp_vol_attribute_HasVolumePassword,
1241 &hf_afp_vol_attribute_SupportsFileIDs,
1242 &hf_afp_vol_attribute_SupportsCatSearch,
1243 &hf_afp_vol_attribute_SupportsBlankAccessPrivs,
1244 &hf_afp_vol_attribute_SupportsUnixPrivs,
1245 &hf_afp_vol_attribute_SupportsUTF8Names,
1246 &hf_afp_vol_attribute_NoNetworkUserID,
1247 &hf_afp_vol_attribute_DefaultPrivsFromParent,
1248 &hf_afp_vol_attribute_NoExchangeFiles,
1249 &hf_afp_vol_attribute_SupportsExtAttrs,
1250 &hf_afp_vol_attribute_SupportsACLs,
1251 &hf_afp_vol_attribute_CaseSensitive,
1252 &hf_afp_vol_attribute_SupportsTMLockSteal,
1253 NULL
1256 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_vol_attribute,
1257 ett_afp_vol_attribute, bitmaps, ENC_BIG_ENDIAN);
1258 bitmap = tvb_get_ntohs(tvb, offset);
1260 return bitmap;
1263 /* --------------------------
1264 cf AFP3.0.pdf page 38
1265 date are number of seconds from 12:00am on 01.01.2000 GMT
1266 backup : 0x8000000 not set
1267 from netatalk adouble.h
1269 #define DATE_NOT_SET 0x80000000
1270 #define AD_DATE_DELTA 946684800
1271 #define AD_DATE_TO_UNIX(x) (x + AD_DATE_DELTA)
1272 static void
1273 print_date(proto_tree *tree,int id, tvbuff_t *tvb, int offset)
1275 time_t date = tvb_get_ntohl(tvb, offset);
1276 nstime_t tv;
1278 tv.secs = AD_DATE_TO_UNIX(date);
1279 tv.nsecs = 0;
1280 proto_tree_add_time(tree, id, tvb, offset, 4, &tv);
1283 /* -------------------------- */
1284 static int
1285 parse_vol_bitmap (proto_tree *tree, tvbuff_t *tvb, int offset, uint16_t bitmap)
1287 uint16_t nameoff = 0;
1289 if ((bitmap & kFPVolAttributeBit)) {
1290 decode_vol_attribute(tree,tvb,offset);
1291 offset += 2;
1293 if ((bitmap & kFPVolSignatureBit)) {
1294 proto_tree_add_item(tree, hf_afp_vol_signature,tvb, offset, 2, ENC_BIG_ENDIAN);
1295 offset += 2;
1297 if ((bitmap & kFPVolCreateDateBit)) {
1298 print_date(tree, hf_afp_vol_creation_date,tvb, offset);
1299 offset += 4;
1301 if ((bitmap & kFPVolModDateBit)) {
1302 print_date(tree, hf_afp_vol_modification_date,tvb, offset);
1303 offset += 4;
1305 if ((bitmap & kFPVolBackupDateBit)) {
1306 print_date(tree, hf_afp_vol_backup_date,tvb, offset);
1307 offset += 4;
1309 if ((bitmap & kFPVolIDBit)) {
1310 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1311 offset += 2;
1313 if ((bitmap & kFPVolBytesFreeBit)) {
1314 proto_tree_add_item(tree, hf_afp_vol_bytes_free,tvb, offset, 4, ENC_BIG_ENDIAN);
1315 offset += 4;
1317 if ((bitmap & kFPVolBytesTotalBit)) {
1318 proto_tree_add_item(tree, hf_afp_vol_bytes_total,tvb, offset, 4, ENC_BIG_ENDIAN);
1319 offset += 4;
1321 if ((bitmap & kFPVolNameBit)) {
1322 nameoff = tvb_get_ntohs(tvb, offset);
1323 proto_tree_add_item(tree, hf_afp_vol_name_offset,tvb, offset, 2, ENC_BIG_ENDIAN);
1324 offset += 2;
1326 if ((bitmap & kFPVolExtBytesFreeBit)) {
1327 proto_tree_add_item(tree, hf_afp_vol_ex_bytes_free,tvb, offset, 8, ENC_BIG_ENDIAN);
1328 offset += 8;
1330 if ((bitmap & kFPVolExtBytesTotalBit)) {
1331 proto_tree_add_item(tree, hf_afp_vol_ex_bytes_total,tvb, offset, 8, ENC_BIG_ENDIAN);
1332 offset += 8;
1334 if ((bitmap & kFPVolBlockSizeBit)) {
1335 proto_tree_add_item(tree, hf_afp_vol_block_size,tvb, offset, 4, ENC_BIG_ENDIAN);
1336 offset += 4;
1338 if (nameoff) {
1339 uint8_t len;
1341 len = tvb_get_uint8(tvb, offset);
1342 proto_tree_add_item(tree, hf_afp_vol_name, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
1343 offset += len +1;
1346 return offset;
1349 /* -------------------------- */
1350 static uint16_t
1351 decode_file_bitmap (proto_tree *tree, tvbuff_t *tvb, int offset)
1353 uint16_t bitmap;
1354 static int * const bitmaps[] = {
1355 &hf_afp_file_bitmap_Attributes,
1356 &hf_afp_file_bitmap_ParentDirID,
1357 &hf_afp_file_bitmap_CreateDate,
1358 &hf_afp_file_bitmap_ModDate,
1359 &hf_afp_file_bitmap_BackupDate,
1360 &hf_afp_file_bitmap_FinderInfo,
1361 &hf_afp_file_bitmap_LongName,
1362 &hf_afp_file_bitmap_ShortName,
1363 &hf_afp_file_bitmap_NodeID,
1364 &hf_afp_file_bitmap_DataForkLen,
1365 &hf_afp_file_bitmap_RsrcForkLen,
1366 &hf_afp_file_bitmap_ExtDataForkLen,
1367 &hf_afp_file_bitmap_LaunchLimit,
1368 &hf_afp_file_bitmap_UTF8Name,
1369 &hf_afp_file_bitmap_ExtRsrcForkLen,
1370 &hf_afp_file_bitmap_UnixPrivs,
1371 NULL
1374 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_file_bitmap,
1375 ett_afp_file_bitmap, bitmaps, ENC_BIG_ENDIAN);
1376 bitmap = tvb_get_ntohs(tvb, offset);
1378 return bitmap;
1381 /* -------------------------- */
1382 static uint16_t
1383 decode_file_attribute(proto_tree *tree, tvbuff_t *tvb, int offset, int shared)
1385 uint16_t attribute;
1386 static int * const not_shared_attr[] = {
1387 &hf_afp_file_attribute_Invisible,
1388 &hf_afp_file_attribute_MultiUser,
1389 &hf_afp_file_attribute_System,
1390 &hf_afp_file_attribute_DAlreadyOpen,
1391 &hf_afp_file_attribute_RAlreadyOpen,
1392 /* writeinhibit is file only but Macs are setting it with FPSetFileDirParms too */
1393 &hf_afp_file_attribute_WriteInhibit,
1394 &hf_afp_file_attribute_BackUpNeeded,
1395 &hf_afp_file_attribute_RenameInhibit,
1396 &hf_afp_file_attribute_DeleteInhibit,
1397 &hf_afp_file_attribute_CopyProtect,
1398 &hf_afp_file_attribute_SetClear,
1399 NULL
1402 static int * const shared_attr[] = {
1403 &hf_afp_file_attribute_Invisible,
1404 &hf_afp_file_attribute_System,
1405 &hf_afp_file_attribute_WriteInhibit,
1406 &hf_afp_file_attribute_BackUpNeeded,
1407 &hf_afp_file_attribute_RenameInhibit,
1408 &hf_afp_file_attribute_DeleteInhibit,
1409 &hf_afp_file_attribute_SetClear,
1410 NULL
1413 if (!shared)
1415 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_file_attribute,
1416 ett_afp_file_attribute, not_shared_attr, ENC_BIG_ENDIAN);
1418 else
1420 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_file_attribute,
1421 ett_afp_file_attribute, shared_attr, ENC_BIG_ENDIAN);
1424 attribute = tvb_get_ntohs(tvb, offset);
1425 return attribute;
1428 static void
1429 decode_access_rights (proto_tree *tree, tvbuff_t *tvb, int hf, int offset)
1431 static int * const rights[] = {
1432 &hf_afp_dir_ar_o_search,
1433 &hf_afp_dir_ar_o_read,
1434 &hf_afp_dir_ar_o_write,
1435 &hf_afp_dir_ar_g_search,
1436 &hf_afp_dir_ar_g_read,
1437 &hf_afp_dir_ar_g_write,
1438 &hf_afp_dir_ar_e_search,
1439 &hf_afp_dir_ar_e_read,
1440 &hf_afp_dir_ar_e_write,
1441 &hf_afp_dir_ar_u_search,
1442 &hf_afp_dir_ar_u_read,
1443 &hf_afp_dir_ar_u_write,
1444 &hf_afp_dir_ar_blank,
1445 &hf_afp_dir_ar_u_own,
1446 NULL
1449 proto_tree_add_bitmask(tree, tvb, offset, hf,
1450 ett_afp_dir_ar, rights, ENC_BIG_ENDIAN);
1453 static void
1454 decode_unix_privs (proto_tree *tree, tvbuff_t *tvb, int offset)
1456 proto_tree *sub_tree;
1458 if (tree) {
1459 sub_tree = proto_tree_add_subtree(tree, tvb, offset, 16, ett_afp_unix_privs, NULL,
1460 "UNIX privileges");
1462 proto_tree_add_item(sub_tree, hf_afp_unix_privs_uid, tvb, offset, 4, ENC_BIG_ENDIAN);
1463 proto_tree_add_item(sub_tree, hf_afp_unix_privs_gid, tvb, offset+4, 4, ENC_BIG_ENDIAN);
1464 proto_tree_add_item(sub_tree, hf_afp_unix_privs_permissions, tvb, offset+8, 4, ENC_BIG_ENDIAN);
1465 decode_access_rights(sub_tree, tvb, hf_afp_unix_privs_ua_permissions, offset+12);
1469 /* -------------------------- */
1470 static int
1471 parse_long_filename(proto_tree *tree, tvbuff_t *tvb, int offset, int org_offset)
1473 uint16_t lnameoff;
1474 int tp_ofs = 0;
1475 uint8_t len;
1477 lnameoff = tvb_get_ntohs(tvb, offset);
1478 proto_tree_add_item(tree, hf_afp_long_name_offset,tvb, offset, 2, ENC_BIG_ENDIAN);
1479 if (lnameoff) {
1480 tp_ofs = lnameoff +org_offset;
1481 len = tvb_get_uint8(tvb, tp_ofs);
1482 proto_tree_add_item(tree, hf_afp_path_len, tvb, tp_ofs, 1, ENC_BIG_ENDIAN);
1483 tp_ofs++;
1484 proto_tree_add_item(tree, hf_afp_path_name, tvb, tp_ofs, len, ENC_UTF_8);
1485 tp_ofs += len;
1487 return tp_ofs;
1490 /* -------------------------- */
1491 static int
1492 parse_UTF8_filename(proto_tree *tree, tvbuff_t *tvb, int offset, int org_offset)
1494 uint16_t unameoff;
1495 int tp_ofs = 0;
1496 uint16_t len;
1498 unameoff = tvb_get_ntohs(tvb, offset);
1499 proto_tree_add_item(tree, hf_afp_unicode_name_offset,tvb, offset, 2, ENC_BIG_ENDIAN);
1500 offset += 2;
1501 if (unameoff) {
1502 /* FIXME AFP3.x reuses PDINFO bit for UTF8.
1503 * In enumerate_ext it's pad with 4 bytes, PDINFO was 6 bytes,
1504 * but not in catsearch_ext.
1505 * Last but not least there's a bug in OSX catsearch_ext for spec2
1506 * offset is off by 2 bytes.
1509 tp_ofs = unameoff +org_offset;
1510 if (tp_ofs > offset) {
1511 PAD(4);
1513 else if (tp_ofs < offset) {
1514 tp_ofs = offset;
1516 proto_tree_add_item( tree, hf_afp_path_unicode_hint, tvb, tp_ofs, 4, ENC_BIG_ENDIAN);
1517 tp_ofs += 4;
1519 len = tvb_get_ntohs(tvb, tp_ofs);
1520 proto_tree_add_item( tree, hf_afp_path_unicode_len, tvb, tp_ofs, 2, ENC_BIG_ENDIAN);
1521 tp_ofs += 2;
1523 proto_tree_add_item(tree, hf_afp_path_name, tvb, tp_ofs, len, ENC_UTF_8);
1524 tp_ofs += len;
1526 return tp_ofs;
1529 /* -------------------------- */
1530 static int
1531 parse_file_bitmap (proto_tree *tree, tvbuff_t *tvb, int offset, uint16_t bitmap, int shared)
1533 /* uint16_t snameoff = 0; */
1534 int max_offset = 0;
1536 int org_offset = offset;
1538 if ((bitmap & kFPAttributeBit)) {
1539 decode_file_attribute(tree, tvb, offset, shared);
1540 offset += 2;
1542 if ((bitmap & kFPParentDirIDBit)) {
1543 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
1544 offset += 4;
1546 if ((bitmap & kFPCreateDateBit)) {
1547 print_date(tree, hf_afp_creation_date,tvb, offset);
1548 offset += 4;
1550 if ((bitmap & kFPModDateBit)) {
1551 print_date(tree, hf_afp_modification_date,tvb, offset);
1552 offset += 4;
1554 if ((bitmap & kFPBackupDateBit)) {
1555 print_date(tree, hf_afp_backup_date,tvb, offset);
1556 offset += 4;
1558 if ((bitmap & kFPFinderInfoBit)) {
1559 proto_tree_add_item(tree, hf_afp_finder_info,tvb, offset, 32, ENC_NA);
1560 offset += 32;
1562 if ((bitmap & kFPLongNameBit)) {
1563 int tp_ofs;
1565 tp_ofs = parse_long_filename(tree, tvb, offset, org_offset);
1566 max_offset = (tp_ofs >max_offset)?tp_ofs:max_offset;
1568 offset += 2;
1571 if ((bitmap & kFPShortNameBit)) {
1572 /* snameoff = tvb_get_ntohs(tvb, offset); */
1573 proto_tree_add_item(tree, hf_afp_short_name_offset,tvb, offset, 2, ENC_BIG_ENDIAN);
1574 offset += 2;
1576 if ((bitmap & kFPNodeIDBit)) {
1577 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1578 offset += 4;
1581 if ((bitmap & kFPDataForkLenBit)) {
1582 proto_tree_add_item(tree, hf_afp_file_DataForkLen, tvb, offset, 4, ENC_BIG_ENDIAN);
1583 offset += 4;
1586 if ((bitmap & kFPRsrcForkLenBit)) {
1587 proto_tree_add_item(tree, hf_afp_file_RsrcForkLen, tvb, offset, 4, ENC_BIG_ENDIAN);
1588 offset += 4;
1591 if ((bitmap & kFPExtDataForkLenBit)) {
1592 proto_tree_add_item(tree, hf_afp_file_ExtDataForkLen, tvb, offset, 8, ENC_BIG_ENDIAN);
1593 offset += 8;
1596 if ((bitmap & kFPLaunchLimitBit)) {
1597 offset += 2; /* ? */
1600 if ((bitmap & kFPUTF8NameBit)) {
1601 int tp_ofs;
1603 tp_ofs = parse_UTF8_filename(tree, tvb, offset, org_offset);
1604 max_offset = (tp_ofs >max_offset)?tp_ofs:max_offset;
1605 offset += 6;
1608 if ((bitmap & kFPExtRsrcForkLenBit)) {
1609 proto_tree_add_item(tree, hf_afp_file_ExtRsrcForkLen, tvb, offset, 8, ENC_BIG_ENDIAN);
1610 offset += 8;
1613 if ((bitmap & kFPUnixPrivsBit)) {
1615 * XXX - the AFP 3.0 spec says this is "Four bytes", but
1616 * also says the privileges are "stored in an FPUnixPrivs
1617 * structure", which is 16 bytes long.
1619 * We assume, for now, that the latter is true.
1621 decode_unix_privs(tree, tvb, offset);
1622 offset += 16;
1625 return (max_offset)?max_offset:offset;
1628 /* -------------------------- */
1629 static uint16_t
1630 decode_dir_bitmap (proto_tree *tree, tvbuff_t *tvb, int offset)
1632 uint16_t bitmap;
1633 static int * const bitmaps[] = {
1634 &hf_afp_dir_bitmap_Attributes,
1635 &hf_afp_dir_bitmap_ParentDirID,
1636 &hf_afp_dir_bitmap_CreateDate,
1637 &hf_afp_dir_bitmap_ModDate,
1638 &hf_afp_dir_bitmap_BackupDate,
1639 &hf_afp_dir_bitmap_FinderInfo,
1640 &hf_afp_dir_bitmap_LongName,
1641 &hf_afp_dir_bitmap_ShortName,
1642 &hf_afp_dir_bitmap_NodeID,
1643 &hf_afp_dir_bitmap_OffspringCount,
1644 &hf_afp_dir_bitmap_OwnerID,
1645 &hf_afp_dir_bitmap_GroupID,
1646 &hf_afp_dir_bitmap_AccessRights,
1647 &hf_afp_dir_bitmap_UTF8Name,
1648 &hf_afp_dir_bitmap_UnixPrivs,
1649 NULL
1652 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_dir_bitmap,
1653 ett_afp_dir_bitmap, bitmaps, ENC_BIG_ENDIAN);
1654 bitmap = tvb_get_ntohs(tvb, offset);
1656 return bitmap;
1659 /* -------------------------- */
1660 static uint16_t
1661 decode_dir_attribute(proto_tree *tree, tvbuff_t *tvb, int offset)
1663 uint16_t attribute;
1664 static int * const attributes[] = {
1665 &hf_afp_dir_attribute_Invisible,
1666 &hf_afp_dir_attribute_IsExpFolder,
1667 &hf_afp_dir_attribute_System,
1668 &hf_afp_dir_attribute_Mounted,
1669 &hf_afp_dir_attribute_InExpFolder,
1670 &hf_afp_dir_attribute_BackUpNeeded,
1671 &hf_afp_dir_attribute_RenameInhibit,
1672 &hf_afp_dir_attribute_DeleteInhibit,
1673 NULL
1676 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_dir_attribute,
1677 ett_afp_dir_attribute, attributes, ENC_BIG_ENDIAN);
1678 attribute = tvb_get_ntohs(tvb, offset);
1680 return attribute;
1683 /* -------------------------- */
1684 static int
1685 parse_dir_bitmap (proto_tree *tree, tvbuff_t *tvb, int offset, uint16_t bitmap)
1687 /* uint16_t snameoff = 0; */
1688 int max_offset = 0;
1690 int org_offset = offset;
1692 if ((bitmap & kFPAttributeBit)) {
1693 decode_dir_attribute(tree, tvb, offset);
1694 offset += 2;
1696 if ((bitmap & kFPParentDirIDBit)) {
1697 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
1698 offset += 4;
1700 if ((bitmap & kFPCreateDateBit)) {
1701 print_date(tree, hf_afp_creation_date,tvb, offset);
1702 offset += 4;
1704 if ((bitmap & kFPModDateBit)) {
1705 print_date(tree, hf_afp_modification_date,tvb, offset);
1706 offset += 4;
1708 if ((bitmap & kFPBackupDateBit)) {
1709 print_date(tree, hf_afp_backup_date,tvb, offset);
1710 offset += 4;
1712 if ((bitmap & kFPFinderInfoBit)) {
1713 proto_tree_add_item(tree, hf_afp_finder_info,tvb, offset, 32, ENC_NA);
1714 offset += 32;
1716 if ((bitmap & kFPLongNameBit)) {
1717 int tp_ofs;
1719 tp_ofs = parse_long_filename(tree, tvb, offset, org_offset);
1720 max_offset = (tp_ofs >max_offset)?tp_ofs:max_offset;
1722 offset += 2;
1724 if ((bitmap & kFPShortNameBit)) {
1725 /* snameoff = tvb_get_ntohs(tvb, offset); */
1726 proto_tree_add_item(tree, hf_afp_short_name_offset,tvb, offset, 2, ENC_BIG_ENDIAN);
1727 offset += 2;
1729 if ((bitmap & kFPNodeIDBit)) {
1730 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1731 offset += 4;
1733 if ((bitmap & kFPOffspringCountBit)) {
1734 proto_tree_add_item(tree, hf_afp_dir_offspring, tvb, offset, 2, ENC_BIG_ENDIAN);
1735 offset += 2; /* error in AFP3.0.pdf */
1737 if ((bitmap & kFPOwnerIDBit)) {
1738 proto_tree_add_item(tree, hf_afp_dir_OwnerID, tvb, offset, 4, ENC_BIG_ENDIAN);
1739 offset += 4;
1741 if ((bitmap & kFPGroupIDBit)) {
1742 proto_tree_add_item(tree, hf_afp_dir_GroupID, tvb, offset, 4, ENC_BIG_ENDIAN);
1743 offset += 4;
1745 if ((bitmap & kFPAccessRightsBit)) {
1746 decode_access_rights(tree, tvb, hf_afp_dir_ar, offset);
1747 offset += 4;
1749 if ((bitmap & kFPUTF8NameBit)) {
1750 int tp_ofs;
1752 tp_ofs = parse_UTF8_filename(tree, tvb, offset, org_offset);
1753 max_offset = (tp_ofs >max_offset)?tp_ofs:max_offset;
1754 offset += 6;
1756 if ((bitmap & kFPUnixPrivsBit)) {
1758 * XXX - the AFP 3.0 spec says this is "Four bytes", but
1759 * also says the privileges are "stored in an FPUnixPrivs
1760 * structure", which is 16 bytes long.
1762 * We assume, for now, that the latter is true.
1764 decode_unix_privs(tree, tvb, offset);
1765 offset += 16;
1767 return (max_offset)?max_offset:offset;
1770 /* -------------------------- */
1771 static uint8_t *
1772 name_in_bitmap(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, uint16_t bitmap, int isdir)
1774 uint8_t *name;
1775 int org_offset = offset;
1776 uint16_t nameoff;
1777 uint8_t len;
1778 uint16_t len16;
1779 int tp_ofs;
1781 if ((bitmap & kFPAttributeBit)) /* 0 */
1782 offset += 2;
1783 if ((bitmap & kFPParentDirIDBit)) /* 1 */
1784 offset += 4;
1785 if ((bitmap & kFPCreateDateBit)) /* 2 */
1786 offset += 4;
1787 if ((bitmap & kFPModDateBit)) /* 3 */
1788 offset += 4;
1789 if ((bitmap & kFPBackupDateBit)) /* 4 */
1790 offset += 4;
1791 if ((bitmap & kFPFinderInfoBit)) /* 5 */
1792 offset += 32;
1794 if ((bitmap & kFPLongNameBit)) { /* 6 */
1795 nameoff = tvb_get_ntohs(tvb, offset);
1796 if (nameoff) {
1797 tp_ofs = nameoff +org_offset;
1798 len = tvb_get_uint8(tvb, tp_ofs);
1799 tp_ofs++;
1800 /* XXX - code page,, e.g. Mac{Roman,Japanese,etc.} */
1801 name = tvb_get_string_enc(scope, tvb, tp_ofs, len, ENC_ASCII|ENC_NA);
1802 return name;
1804 offset += 2;
1807 if ((bitmap & kFPShortNameBit)) /* 7 */
1808 offset += 2;
1809 if ((bitmap & kFPNodeIDBit)) /* 8 */
1810 offset += 4;
1812 if (isdir) {
1813 if ((bitmap & kFPOffspringCountBit)) /* 9 */
1814 offset += 2;
1815 if ((bitmap & kFPOwnerIDBit)) /* 10*/
1816 offset += 4;
1817 if ((bitmap & kFPGroupIDBit)) /* 11*/
1818 offset += 4;
1819 if ((bitmap & kFPAccessRightsBit)) /* 12*/
1820 offset += 4;
1822 else {
1823 if ((bitmap & kFPDataForkLenBit)) /* 9 */
1824 offset += 4;
1825 if ((bitmap & kFPRsrcForkLenBit)) /* 10*/
1826 offset += 4;
1827 if ((bitmap & kFPExtDataForkLenBit)) /* 11*/
1828 offset += 8;
1829 if ((bitmap & kFPLaunchLimitBit)) /* 12*/
1830 offset += 2; /* FIXME ? */
1833 if ((bitmap & kFPUTF8NameBit)) { /* 13 */
1834 nameoff = tvb_get_ntohs(tvb, offset);
1835 if (nameoff) {
1836 tp_ofs = nameoff +org_offset +4;
1837 len16 = tvb_get_ntohs(tvb, tp_ofs);
1838 tp_ofs += 2;
1839 name = tvb_get_string_enc(scope, tvb, tp_ofs, len16, ENC_UTF_8|ENC_NA);
1840 return name;
1843 return NULL;
1846 /* -------------------------- */
1847 static uint8_t *
1848 name_in_dbitmap(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, uint16_t bitmap)
1850 uint8_t *name;
1852 name = name_in_bitmap(scope, tvb, offset, bitmap, 1);
1853 if (name != NULL)
1854 return name;
1856 check UTF8 name
1859 return name;
1862 /* -------------------------- */
1863 static uint8_t *
1864 name_in_fbitmap(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, uint16_t bitmap)
1866 uint8_t *name;
1868 name = name_in_bitmap(scope, tvb, offset, bitmap, 0);
1869 if (name != NULL)
1870 return name;
1872 check UTF8 name
1875 return name;
1878 /* -------------------------- */
1879 static int
1880 decode_vol(proto_tree *tree, tvbuff_t *tvb, int offset)
1882 Vol = tvb_get_ntohs(tvb, offset);
1883 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1884 return offset + 2;
1887 /* -------------------------- */
1888 static int
1889 decode_vol_did(proto_tree *tree, tvbuff_t *tvb, int offset)
1891 Vol = tvb_get_ntohs(tvb, offset);
1892 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1893 offset += 2;
1895 Did = tvb_get_ntohl(tvb, offset);
1896 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
1897 offset += 4;
1898 return offset;
1901 /* -------------------------- */
1902 static int
1903 decode_vol_did_file_dir_bitmap (proto_tree *tree, tvbuff_t *tvb, int offset)
1905 offset = decode_vol_did(tree, tvb, offset);
1907 decode_file_bitmap(tree, tvb, offset);
1908 offset += 2;
1910 decode_dir_bitmap(tree, tvb, offset);
1911 offset += 2;
1913 return offset;
1916 /* ------------------------ */
1917 static const char *
1918 get_name(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, int type)
1920 int len;
1921 const char *string;
1923 switch (type) {
1924 case 1:
1925 case 2:
1926 len = tvb_get_uint8(tvb, offset);
1927 offset++;
1928 string = tvb_format_text(scope, tvb,offset, len);
1929 break;
1930 case 3:
1931 len = tvb_get_ntohs(tvb, offset +4);
1932 offset += 6;
1933 string = tvb_format_text(scope, tvb,offset, len);
1934 break;
1935 default:
1936 string = "Unknown type";
1937 break;
1939 return string;
1941 /* -------------------------- */
1942 static int
1943 decode_name_label (proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, const char *label, bool add_info)
1945 int len;
1946 int header;
1947 const char *name;
1948 uint8_t type;
1949 proto_tree *sub_tree = NULL;
1951 type = tvb_get_uint8(tvb, offset);
1952 if (type == 3) {
1953 header = 7;
1954 len = tvb_get_ntohs(tvb, offset +5);
1956 else {
1957 header = 2;
1958 len = tvb_get_uint8(tvb, offset +1);
1960 name = get_name(pinfo->pool, tvb, offset +1, type);
1962 if (add_info) {
1963 col_append_fstr(pinfo->cinfo, COL_INFO, ": Vol=%u Did=%u", Vol, Did);
1964 if (len) {
1965 col_append_fstr(pinfo->cinfo, COL_INFO, " Name=%s", name);
1969 if (tree) {
1970 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, len +header,
1971 ett_afp_path_name, NULL, label, name);
1973 proto_tree_add_item( sub_tree, hf_afp_path_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1974 offset++;
1975 if (type == 3) {
1976 proto_tree_add_item( sub_tree, hf_afp_path_unicode_hint, tvb, offset, 4, ENC_BIG_ENDIAN);
1977 offset += 4;
1978 proto_tree_add_item( sub_tree, hf_afp_path_unicode_len, tvb, offset, 2, ENC_BIG_ENDIAN);
1979 offset += 2;
1981 else {
1982 proto_tree_add_item( sub_tree, hf_afp_path_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1983 offset++;
1986 proto_tree_add_string(sub_tree, hf_afp_path_name, tvb, offset, len,name);
1988 else
1989 offset += header;
1991 return offset +len;
1994 /* -------------------------- */
1995 static int
1996 decode_name (proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset)
1998 return decode_name_label(tree, pinfo, tvb, offset, "Path: %s", true);
2001 /* -------------------------- */
2002 static void
2003 add_info_fork(tvbuff_t *tvb, packet_info *pinfo, int offset)
2005 uint16_t ofork;
2007 ofork = tvb_get_ntohs(tvb, offset);
2008 if (ofork) {
2009 col_append_fstr(pinfo->cinfo, COL_INFO, ": Fork=%u", ofork);
2013 /* -------------------------- */
2014 static void
2015 add_info_vol(tvbuff_t *tvb, packet_info *pinfo, int offset)
2017 uint16_t vol;
2019 vol = tvb_get_ntohs(tvb, offset);
2020 col_append_fstr(pinfo->cinfo, COL_INFO, ": Vol=%u", vol);
2023 /* ************************** */
2024 static int
2025 dissect_query_afp_open_vol(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2027 int len;
2028 const char *rep;
2030 PAD(1);
2032 decode_vol_bitmap(tree, tvb, offset);
2033 offset += 2;
2035 len = tvb_get_uint8(tvb, offset);
2037 rep = get_name(pinfo->pool, tvb, offset, 2);
2038 col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", rep);
2040 if (!tree)
2041 return offset;
2043 proto_tree_add_item(tree, hf_afp_vol_name, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
2044 offset += len +1;
2046 len = tvb_reported_length_remaining(tvb,offset);
2047 if (len >= 8) {
2048 /* optional password */
2049 proto_tree_add_item(tree, hf_afp_passwd, tvb, offset, 8, ENC_UTF_8|ENC_NA);
2050 offset += 8;
2052 return offset;
2055 /* -------------------------- */
2056 static int
2057 dissect_reply_afp_open_vol(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2059 uint16_t bitmap;
2061 if (!tree)
2062 return offset;
2063 bitmap = decode_vol_bitmap(tree, tvb, offset);
2064 offset += 2;
2065 offset = parse_vol_bitmap(tree, tvb, offset, bitmap);
2067 return offset;
2070 /* ************************** */
2071 static int
2072 dissect_reply_afp_get_server_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2074 uint8_t num;
2075 uint8_t len;
2076 uint8_t i;
2077 proto_tree *sub_tree;
2078 proto_item *item;
2080 static int * const flags[] = {
2081 &hf_afp_vol_flag_passwd,
2082 &hf_afp_vol_flag_has_config,
2083 NULL
2086 if (!tree)
2087 return offset;
2089 print_date(tree, hf_afp_server_time,tvb, offset);
2090 offset += 4;
2092 num = tvb_get_uint8(tvb, offset);
2093 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, 1,
2094 ett_afp_server_vol, NULL, "Volumes : %d", num);
2095 offset++;
2097 for (i = 0; i < num; i++) {
2098 const char *rep;
2100 tree = proto_tree_add_subtree(sub_tree, tvb, offset, -1,
2101 ett_afp_vol_list, NULL, "Volume");
2103 item = proto_tree_add_bitmask(tree, tvb, offset, hf_afp_vol_flag,
2104 ett_afp_vol_flag, flags, ENC_BIG_ENDIAN);
2105 offset++;
2107 len = tvb_get_uint8(tvb, offset) +1;
2108 rep = get_name(pinfo->pool, tvb, offset, 2);
2109 proto_item_set_text(item, "%s", rep);
2110 proto_item_set_len(item, len +1);
2112 proto_tree_add_item(tree, hf_afp_vol_name, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
2114 offset += len;
2116 return offset;
2119 /* **************************
2120 next calls use the same format :
2121 1 pad byte
2122 volume id
2123 AFP_FLUSH
2124 AFP_CLOSEVOL
2125 AFP_OPENDT
2127 static int
2128 dissect_query_afp_with_vol_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2131 if (!tree)
2132 return offset;
2133 PAD(1);
2135 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2136 offset += 2;
2137 return offset;
2140 /* ************************** */
2141 static int
2142 dissect_query_afp_open_fork(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2144 static int * const access[] = {
2145 &hf_afp_access_read,
2146 &hf_afp_access_write,
2147 &hf_afp_access_deny_read,
2148 &hf_afp_access_deny_write,
2149 NULL
2152 proto_tree_add_item(tree, hf_afp_fork_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2153 offset++;
2155 offset = decode_vol_did(tree, tvb, offset);
2157 decode_file_bitmap(tree, tvb, offset);
2158 offset += 2;
2159 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_access_mode,
2160 ett_afp_access_mode, access, ENC_BIG_ENDIAN);
2161 offset += 2;
2163 offset = decode_name(tree, pinfo, tvb, offset);
2165 return offset;
2168 /* -------------------------- */
2169 static int
2170 dissect_reply_afp_open_fork(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2172 uint16_t f_bitmap;
2174 f_bitmap = decode_file_bitmap(tree, tvb, offset);
2175 offset += 2;
2177 add_info_fork(tvb, pinfo, offset);
2178 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
2179 offset += 2;
2181 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap,0);
2183 return offset;
2186 /* ************************** */
2187 static int
2188 dissect_query_afp_enumerate_ext2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2191 PAD(1);
2192 offset = decode_vol_did_file_dir_bitmap(tree, tvb, offset);
2194 proto_tree_add_item(tree, hf_afp_req_count, tvb, offset, 2, ENC_BIG_ENDIAN);
2195 offset += 2;
2197 proto_tree_add_item(tree, hf_afp_start_index32, tvb, offset, 4, ENC_BIG_ENDIAN);
2198 offset += 4;
2200 proto_tree_add_item(tree, hf_afp_max_reply_size32, tvb, offset, 4, ENC_BIG_ENDIAN);
2201 offset += 4;
2203 offset = decode_name(tree, pinfo, tvb, offset);
2205 return offset;
2208 /* ************************** */
2209 static int
2210 dissect_query_afp_enumerate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2213 PAD(1);
2214 offset = decode_vol_did_file_dir_bitmap(tree, tvb, offset);
2216 proto_tree_add_item(tree, hf_afp_req_count, tvb, offset, 2, ENC_BIG_ENDIAN);
2217 offset += 2;
2219 proto_tree_add_item(tree, hf_afp_start_index, tvb, offset, 2, ENC_BIG_ENDIAN);
2220 offset += 2;
2222 proto_tree_add_item(tree, hf_afp_max_reply_size, tvb, offset, 2, ENC_BIG_ENDIAN);
2223 offset += 2;
2225 offset = decode_name(tree, pinfo, tvb, offset);
2227 return offset;
2230 /* -------------------------- */
2231 static int
2232 loop_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ptree, int offset,
2233 int count, uint16_t d_bitmap, uint16_t f_bitmap, int add, int ext)
2235 proto_tree *tree = NULL;
2236 uint8_t *name;
2237 uint8_t flags;
2238 unsigned size;
2239 int org;
2240 int i;
2241 int decal;
2243 for (i = 0; i < count; i++) {
2244 org = offset;
2245 if (ext) {
2246 size = tvb_get_ntohs(tvb, offset) +add *2;
2247 decal = 2;
2249 else {
2250 size = tvb_get_uint8(tvb, offset) +add;
2251 decal = 1;
2253 if (!size)
2254 return offset; /* packet is malformed */
2255 flags = tvb_get_uint8(tvb, offset +decal);
2257 decal += (ext)?2:1;
2259 if (ptree) {
2260 if (flags) {
2261 name = name_in_dbitmap(pinfo->pool, tvb, offset +decal, d_bitmap);
2263 else {
2264 name = name_in_fbitmap(pinfo->pool, tvb, offset +decal, f_bitmap);
2266 if (name) {
2267 tree = proto_tree_add_subtree(ptree, tvb, offset, size,
2268 ett_afp_enumerate_line, NULL, (const char*)name);
2270 else {
2271 tree = proto_tree_add_subtree_format(ptree, tvb, offset, size,
2272 ett_afp_enumerate_line, NULL, "line %d", i+1);
2275 if (ext) {
2276 proto_tree_add_item(tree, hf_afp_struct_size16, tvb, offset, 2, ENC_BIG_ENDIAN);
2277 offset += 2;
2279 else {
2280 proto_tree_add_item(tree, hf_afp_struct_size, tvb, offset, 1, ENC_BIG_ENDIAN);
2281 offset++;
2284 proto_tree_add_item(tree, hf_afp_file_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
2285 offset++;
2286 if (ext) {
2287 PAD(1);
2289 if (flags) {
2290 offset = parse_dir_bitmap(tree, tvb, offset, d_bitmap);
2292 else {
2293 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap,0);
2295 if ((offset & 1))
2296 PAD(1);
2297 offset = org +size; /* play safe */
2299 return offset;
2301 /* ------------------------- */
2302 static int
2303 reply_enumerate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ext)
2305 proto_tree *sub_tree = NULL;
2306 proto_item *item;
2307 int count;
2308 uint16_t f_bitmap;
2309 uint16_t d_bitmap;
2311 f_bitmap = decode_file_bitmap(tree, tvb, offset);
2312 offset += 2;
2314 d_bitmap = decode_dir_bitmap(tree, tvb, offset);
2315 offset += 2;
2317 count = tvb_get_ntohs(tvb, offset);
2318 if (tree) {
2319 item = proto_tree_add_item(tree, hf_afp_req_count, tvb, offset, 2, ENC_BIG_ENDIAN);
2320 sub_tree = proto_item_add_subtree(item, ett_afp_enumerate);
2322 offset += 2;
2324 return loop_record(tvb, pinfo, sub_tree, offset, count, d_bitmap, f_bitmap,0, ext);
2327 /* ------------------------- */
2328 static int
2329 dissect_reply_afp_enumerate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2331 return reply_enumerate(tvb, pinfo, tree, offset, 0);
2334 /* **************************/
2335 static int
2336 dissect_reply_afp_enumerate_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2338 return reply_enumerate(tvb, pinfo, tree, offset, 1);
2341 /* **************************/
2342 static int
2343 catsearch_spec(tvbuff_t *tvb, proto_tree *ptree, int offset, int ext, uint32_t r_bitmap, const char *label)
2345 proto_tree *tree;
2346 uint16_t size;
2347 int org;
2349 org = offset;
2351 if (ext) {
2352 size = tvb_get_ntohs(tvb, offset) +2;
2354 else {
2355 size = tvb_get_uint8(tvb, offset) +2;
2358 tree = proto_tree_add_subtree(ptree, tvb, offset, size, ett_afp_cat_spec, NULL, label);
2360 if (ext) {
2361 proto_tree_add_item(tree, hf_afp_struct_size16, tvb, offset, 2, ENC_BIG_ENDIAN);
2362 offset += 2;
2364 else {
2365 proto_tree_add_item(tree, hf_afp_struct_size, tvb, offset, 1, ENC_BIG_ENDIAN);
2366 offset++;
2367 PAD(1);
2370 /* AFP 3.1 spec pdf: The low-order word of ReqBitmap is equivalent to the
2371 File and Directory bitmaps used by the FPGetFileDirParms command. */
2372 parse_file_bitmap(tree, tvb, offset, (uint16_t) r_bitmap,0);
2373 offset = org +size;
2375 return offset;
2378 /* ------------------------- */
2379 static int
2380 query_catsearch(tvbuff_t *tvb, proto_tree *ptree, int offset, int ext)
2382 proto_tree *tree = NULL, *sub_tree;
2383 proto_item *item;
2384 uint16_t f_bitmap;
2385 uint16_t d_bitmap;
2386 uint32_t r_bitmap;
2388 if (!ptree)
2389 return offset;
2390 PAD(1);
2392 proto_tree_add_item(ptree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2393 offset += 2;
2395 proto_tree_add_item(ptree, hf_afp_cat_req_matches, tvb, offset, 4, ENC_BIG_ENDIAN);
2396 offset += 4;
2398 proto_tree_add_item(ptree, hf_afp_reserved, tvb, offset, 4, ENC_NA);
2399 offset += 4;
2401 proto_tree_add_item(ptree, hf_afp_cat_position, tvb, offset, 16, ENC_NA);
2402 offset += 16;
2404 f_bitmap = decode_file_bitmap(ptree, tvb, offset);
2405 offset += 2;
2407 d_bitmap = decode_dir_bitmap(ptree, tvb, offset);
2408 offset += 2;
2410 r_bitmap = tvb_get_ntohl(tvb, offset);
2411 /* Already checked this above: if (ptree) */ {
2412 item = proto_tree_add_item(ptree, hf_afp_request_bitmap, tvb, offset, 4, ENC_BIG_ENDIAN);
2413 sub_tree = proto_item_add_subtree(item, ett_afp_cat_r_bitmap);
2415 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_Attributes , tvb, offset, 4, ENC_BIG_ENDIAN);
2416 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_ParentDirID, tvb, offset, 4, ENC_BIG_ENDIAN);
2417 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_CreateDate , tvb, offset, 4, ENC_BIG_ENDIAN);
2418 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_ModDate , tvb, offset, 4, ENC_BIG_ENDIAN);
2419 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_BackupDate , tvb, offset, 4, ENC_BIG_ENDIAN);
2420 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_FinderInfo , tvb, offset, 4, ENC_BIG_ENDIAN);
2421 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_LongName , tvb, offset, 4, ENC_BIG_ENDIAN);
2423 if (d_bitmap == 0) {
2424 /* Only for file-only searches */
2425 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_DataForkLen , tvb, offset, 4, ENC_BIG_ENDIAN);
2426 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_RsrcForkLen , tvb, offset, 4, ENC_BIG_ENDIAN);
2427 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_ExtDataForkLen , tvb, offset, 4, ENC_BIG_ENDIAN);
2429 if (f_bitmap == 0) {
2430 /* Only for directory-only searches */
2431 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_OffspringCount , tvb, offset, 4, ENC_BIG_ENDIAN);
2434 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_UTF8Name , tvb, offset, 4, ENC_BIG_ENDIAN);
2436 if (d_bitmap == 0) {
2437 /* Only for file-only searches */
2438 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_ExtRsrcForkLen , tvb, offset, 4, ENC_BIG_ENDIAN);
2440 proto_tree_add_item(sub_tree, hf_afp_request_bitmap_PartialNames , tvb, offset, 4, ENC_BIG_ENDIAN);
2442 offset += 4;
2444 /* spec 1 */
2445 offset = catsearch_spec(tvb, ptree, offset, ext, r_bitmap, "Spec 1");
2447 /* spec 2 */
2448 offset = catsearch_spec(tvb, ptree, offset, ext, r_bitmap, "Spec 2");
2450 return offset;
2453 /* ------------------------- */
2454 static int
2455 dissect_query_afp_cat_search(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ptree, int offset)
2457 return query_catsearch(tvb, ptree, offset, 0);
2460 /* **************************/
2461 static int
2462 dissect_query_afp_cat_search_ext(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *ptree, int offset)
2464 return query_catsearch(tvb, ptree, offset, 1);
2468 /* **************************/
2469 static int
2470 reply_catsearch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int ext)
2472 proto_tree *sub_tree = NULL;
2473 proto_item *item;
2474 uint16_t f_bitmap;
2475 uint16_t d_bitmap;
2476 int count;
2478 proto_tree_add_item(tree, hf_afp_cat_position, tvb, offset, 16, ENC_NA);
2479 offset += 16;
2481 f_bitmap = decode_file_bitmap(tree, tvb, offset);
2482 offset += 2;
2484 d_bitmap = decode_dir_bitmap(tree, tvb, offset);
2485 offset += 2;
2487 count = tvb_get_ntohl(tvb, offset);
2488 if (tree) {
2489 item = proto_tree_add_item(tree, hf_afp_cat_count, tvb, offset, 4, ENC_BIG_ENDIAN);
2490 sub_tree = proto_item_add_subtree(item, ett_afp_cat_search);
2492 offset += 4;
2494 return loop_record(tvb, pinfo, sub_tree, offset, count, d_bitmap, f_bitmap, 2, ext);
2497 /* -------------------------- */
2498 static int
2499 dissect_reply_afp_cat_search(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2501 return reply_catsearch(tvb, pinfo, tree, offset, 0);
2504 /* **************************/
2505 static int
2506 dissect_reply_afp_cat_search_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2508 return reply_catsearch(tvb, pinfo, tree, offset, 1);
2511 /* **************************/
2512 static int
2513 dissect_query_afp_get_vol_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2516 PAD(1)
2517 add_info_vol(tvb, pinfo, offset);
2519 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2520 offset += 2;
2522 decode_vol_bitmap(tree, tvb, offset);
2523 offset += 2;
2525 return offset;
2528 /* ------------------------ */
2529 static int
2530 dissect_reply_afp_get_vol_param(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2532 uint16_t bitmap;
2534 bitmap = decode_vol_bitmap(tree, tvb, offset);
2535 offset += 2;
2537 offset = parse_vol_bitmap(tree, tvb, offset, bitmap);
2539 return offset;
2542 /* **************************/
2543 static int
2544 dissect_query_afp_set_vol_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2546 uint16_t bitmap;
2548 PAD(1)
2550 add_info_vol(tvb, pinfo, offset);
2551 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2552 offset += 2;
2554 bitmap = decode_vol_bitmap(tree, tvb, offset);
2555 offset += 2;
2557 offset = parse_vol_bitmap(tree, tvb, offset, bitmap);
2559 return offset;
2562 /* ***************************/
2563 static int
2564 decode_uam_parameters(const char *uam, int len_uam, tvbuff_t *tvb, proto_tree *tree, int offset)
2566 int len;
2568 if (!g_ascii_strncasecmp(uam, "Cleartxt passwrd", len_uam)) {
2569 if ((offset & 1))
2570 PAD(1);
2572 len = 8; /* tvb_strsize(tvb, offset);*/
2573 proto_tree_add_item(tree, hf_afp_passwd, tvb, offset, len, ENC_UTF_8|ENC_NA);
2574 offset += len;
2576 else if (!g_ascii_strncasecmp(uam, "DHCAST128", len_uam)) {
2577 if ((offset & 1))
2578 PAD(1);
2580 len = 16;
2581 proto_tree_add_item(tree, hf_afp_random, tvb, offset, len, ENC_NA);
2582 offset += len;
2584 else if (!g_ascii_strncasecmp(uam, "2-Way Randnum exchange", len_uam)) {
2585 /* nothing */
2586 return offset;
2588 return offset;
2591 /* ---------------- */
2592 static int
2593 dissect_query_afp_login(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2595 int len;
2596 int len_uam;
2597 const char *uam;
2599 len = tvb_get_uint8(tvb, offset);
2600 proto_tree_add_item(tree, hf_afp_Version, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
2601 offset += len +1;
2602 len_uam = tvb_get_uint8(tvb, offset);
2603 uam = (const char *)tvb_get_string_enc(pinfo->pool, tvb, offset +1, len_uam, ENC_UTF_8|ENC_NA);
2604 proto_tree_add_item(tree, hf_afp_UAM, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
2605 offset += len_uam +1;
2607 if (!g_ascii_strncasecmp(uam, "No User Authent", len_uam)) {
2608 return offset;
2611 len = tvb_get_uint8(tvb, offset);
2612 proto_tree_add_item(tree, hf_afp_user, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
2613 offset += len +1;
2615 return decode_uam_parameters(uam, len_uam, tvb, tree, offset);
2618 /* ***************************/
2619 static int
2620 dissect_query_afp_login_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2622 int len;
2623 int len_uam;
2624 const char *uam;
2625 uint8_t path_type;
2627 PAD(1);
2628 proto_tree_add_item(tree, hf_afp_login_flags, tvb, offset, 2, ENC_BIG_ENDIAN);
2629 offset += 2;
2631 len = tvb_get_uint8(tvb, offset);
2632 proto_tree_add_item(tree, hf_afp_Version, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
2633 offset += len +1;
2635 len_uam = tvb_get_uint8(tvb, offset);
2636 uam = (const char*)tvb_get_string_enc(pinfo->pool, tvb, offset +1, len_uam, ENC_UTF_8|ENC_NA);
2637 proto_tree_add_item(tree, hf_afp_UAM, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
2638 offset += len_uam +1;
2640 proto_tree_add_item(tree, hf_afp_user_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2641 offset++;
2642 /* only type 3 */
2643 len = tvb_get_ntohs(tvb, offset);
2644 proto_tree_add_item(tree, hf_afp_user_len, tvb, offset, 2, ENC_BIG_ENDIAN);
2645 offset += 2;
2646 proto_tree_add_item(tree, hf_afp_user_name, tvb, offset, len, ENC_UTF_8);
2647 offset += len;
2649 /* directory service */
2650 path_type = tvb_get_uint8(tvb, offset);
2651 proto_tree_add_item(tree, hf_afp_path_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2652 offset++;
2653 /* FIXME use 16 bit len + unicode from smb dissector */
2654 switch (path_type) {
2655 case 1:
2656 case 2:
2657 len = tvb_get_uint8(tvb, offset);
2658 proto_tree_add_item(tree, hf_afp_path_len, tvb, offset, 1, ENC_BIG_ENDIAN);
2659 offset++;
2660 proto_tree_add_item(tree, hf_afp_path_name, tvb, offset, len, ENC_UTF_8);
2661 offset += len;
2662 break;
2663 case 3:
2664 len = tvb_get_ntohs(tvb, offset);
2665 proto_tree_add_item( tree, hf_afp_path_unicode_len, tvb, offset, 2, ENC_BIG_ENDIAN);
2666 offset += 2;
2667 proto_tree_add_item(tree, hf_afp_path_name, tvb, offset, len, ENC_UTF_8);
2668 offset += len;
2669 break;
2670 default:
2671 break;
2674 return decode_uam_parameters(uam, len_uam, tvb, tree, offset);
2677 /* ************************** */
2678 static int
2679 dissect_query_afp_write(tvbuff_t *tvb, packet_info *pinfo , proto_tree *tree, int offset)
2681 int param;
2684 proto_tree_add_item(tree, hf_afp_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
2685 offset += 1;
2687 add_info_fork(tvb, pinfo, offset);
2688 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
2689 offset += 2;
2691 proto_tree_add_item(tree, hf_afp_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
2692 param = tvb_get_ntohl(tvb, offset);
2693 col_append_fstr(pinfo->cinfo, COL_INFO, " Offset=%d", param);
2694 offset += 4;
2696 proto_tree_add_item(tree, hf_afp_rw_count, tvb, offset, 4, ENC_BIG_ENDIAN);
2697 param = tvb_get_ntohl(tvb, offset);
2698 col_append_fstr(pinfo->cinfo, COL_INFO, " Size=%d", param);
2699 offset += 4;
2701 return offset;
2704 static int
2705 dissect_reply_afp_write(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2707 proto_tree_add_item(tree, hf_afp_last_written, tvb, offset, 4, ENC_BIG_ENDIAN);
2708 offset += 4;
2710 return offset;
2713 /* ************************** */
2714 static int
2715 dissect_query_afp_write_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2717 proto_tree_add_item(tree, hf_afp_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
2718 offset += 1;
2720 add_info_fork(tvb, pinfo, offset);
2721 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
2722 offset += 2;
2724 proto_tree_add_item(tree, hf_afp_offset64, tvb, offset, 8, ENC_BIG_ENDIAN);
2725 offset += 8;
2727 proto_tree_add_item(tree, hf_afp_rw_count64, tvb, offset, 8, ENC_BIG_ENDIAN);
2728 offset += 8;
2730 return offset;
2733 static int
2734 dissect_reply_afp_write_ext(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2736 proto_tree_add_item(tree, hf_afp_last_written64, tvb, offset, 8, ENC_BIG_ENDIAN);
2737 offset += 8;
2739 return offset;
2742 /* ************************** */
2743 static int
2744 dissect_query_afp_read(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2746 int param;
2748 PAD(1);
2750 add_info_fork(tvb, pinfo, offset);
2751 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
2752 offset += 2;
2754 proto_tree_add_item(tree, hf_afp_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
2755 param = tvb_get_ntohl(tvb, offset);
2756 col_append_fstr(pinfo->cinfo, COL_INFO, " Offset=%d", param);
2757 offset += 4;
2759 proto_tree_add_item(tree, hf_afp_rw_count, tvb, offset, 4, ENC_BIG_ENDIAN);
2760 param = tvb_get_ntohl(tvb, offset);
2761 col_append_fstr(pinfo->cinfo, COL_INFO, " Size=%d", param);
2762 offset += 4;
2764 proto_tree_add_item(tree, hf_afp_newline_mask, tvb, offset, 1, ENC_BIG_ENDIAN);
2765 offset++;
2767 proto_tree_add_item(tree, hf_afp_newline_char, tvb, offset, 1, ENC_BIG_ENDIAN);
2768 offset++;
2770 return offset;
2773 /* ************************** */
2774 static int
2775 dissect_query_afp_read_ext(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2777 PAD(1);
2779 add_info_fork(tvb, pinfo, offset);
2780 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
2781 offset += 2;
2783 proto_tree_add_item(tree, hf_afp_offset64, tvb, offset, 8, ENC_BIG_ENDIAN);
2784 offset += 8;
2786 proto_tree_add_item(tree, hf_afp_rw_count64, tvb, offset, 8, ENC_BIG_ENDIAN);
2787 offset += 8;
2789 return offset;
2792 /* **************************
2793 Open desktop call
2794 query is the same than AFP_FLUSH, AFP_CLOSEVOL
2797 static int
2798 dissect_reply_afp_open_dt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2800 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
2801 offset += 2;
2803 return offset;
2806 /* **************************
2807 no reply
2809 static int
2810 dissect_query_afp_close_dt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2812 PAD(1);
2813 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
2814 offset += 2;
2816 return offset;
2819 /* **************************
2820 calls using the same format :
2821 1 pad byte
2822 fork number
2823 AFP_FLUSHFORK
2824 AFP_CLOSEFORK
2825 AFP_SYNCFORK
2827 static int
2828 dissect_query_afp_with_fork(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2830 PAD(1);
2831 add_info_fork(tvb, pinfo, offset);
2832 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
2833 offset += 2;
2835 return offset;
2838 /* ************************** */
2839 static int
2840 dissect_query_afp_get_fldr_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2842 PAD(1);
2843 offset = decode_vol_did_file_dir_bitmap(tree, tvb, offset);
2845 offset = decode_name(tree, pinfo, tvb, offset);
2847 return offset;
2850 /* -------------------------- */
2851 static int
2852 dissect_reply_afp_get_fldr_param(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2854 uint8_t flags;
2855 uint16_t f_bitmap, d_bitmap;
2857 f_bitmap = decode_file_bitmap(tree, tvb, offset);
2858 offset += 2;
2860 d_bitmap = decode_dir_bitmap(tree, tvb, offset);
2861 offset += 2;
2863 flags = tvb_get_uint8(tvb, offset);
2864 proto_tree_add_item(tree, hf_afp_file_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
2865 offset++;
2866 PAD(1);
2867 if (flags) {
2868 offset = parse_dir_bitmap(tree, tvb, offset, d_bitmap);
2870 else {
2871 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap,0);
2873 return offset;
2876 /* **************************
2877 no reply
2879 static int
2880 dissect_query_afp_set_fldr_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2882 uint16_t f_bitmap;
2884 PAD(1);
2885 offset = decode_vol_did(tree, tvb, offset);
2887 f_bitmap = decode_file_bitmap(tree, tvb, offset);
2888 offset += 2;
2890 offset = decode_name(tree, pinfo, tvb, offset);
2892 if ((offset & 1))
2893 PAD(1);
2894 /* did:name can be a file or a folder but only the intersection between
2895 * file bitmap and dir bitmap can be set.
2896 * Well it's in afp spec, but clients (Mac) are setting 'file only' bits with this call
2897 * (WriteInhibit for example).
2899 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap, 1);
2901 return offset;
2904 /* **************************
2905 no reply
2907 static int
2908 dissect_query_afp_set_file_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2910 uint16_t f_bitmap;
2912 PAD(1);
2913 offset = decode_vol_did(tree, tvb, offset);
2915 f_bitmap = decode_file_bitmap(tree, tvb, offset);
2916 offset += 2;
2918 offset = decode_name(tree, pinfo, tvb, offset);
2920 if ((offset & 1))
2921 PAD(1);
2922 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap, 0);
2924 return offset;
2927 /* **************************
2928 no reply
2930 static int
2931 dissect_query_afp_set_dir_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2933 uint16_t d_bitmap;
2935 PAD(1);
2936 offset = decode_vol_did(tree, tvb, offset);
2938 d_bitmap = decode_dir_bitmap(tree, tvb, offset);
2939 offset += 2;
2941 offset = decode_name(tree, pinfo, tvb, offset);
2943 if ((offset & 1))
2944 PAD(1);
2945 offset = parse_dir_bitmap(tree, tvb, offset, d_bitmap);
2947 offset += 4;
2948 return offset;
2951 /* **************************
2952 AFP_DELETE
2953 AFP_CREATE_DIR
2955 static int
2956 dissect_query_afp_create_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
2958 PAD(1);
2959 offset = decode_vol_did(tree, tvb, offset);
2961 offset = decode_name(tree, pinfo, tvb, offset);
2962 return offset;
2965 /* --------------------------
2966 AFP_MOVE
2968 static int
2969 dissect_reply_afp_create_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2971 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4, ENC_BIG_ENDIAN);
2972 offset += 4;
2974 return offset;
2977 /* -------------------------- */
2978 static int
2979 dissect_reply_afp_create_dir(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2981 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
2982 offset += 4;
2984 return offset;
2987 /* **************************
2988 no reply
2990 static int
2991 dissect_query_afp_delete_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
2993 PAD(1);
2994 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2995 offset += 2;
2996 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4, ENC_BIG_ENDIAN);
2997 offset += 4;
2999 return offset;
3002 /* **************************
3003 same reply as get_fork_param
3005 static int
3006 dissect_query_afp_resolve_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3008 PAD(1);
3009 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2, ENC_BIG_ENDIAN);
3010 offset += 2;
3011 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4, ENC_BIG_ENDIAN);
3012 offset += 4;
3014 decode_file_bitmap(tree, tvb, offset);
3015 offset += 2;
3017 return offset;
3020 /* ************************** */
3021 static int
3022 dissect_query_afp_get_fork_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3025 PAD(1);
3026 add_info_fork(tvb, pinfo, offset);
3027 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
3028 offset += 2;
3030 decode_file_bitmap(tree, tvb, offset);
3031 offset += 2;
3032 return offset;
3035 /* -------------------------- */
3036 static int
3037 dissect_reply_afp_get_fork_param(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3039 uint16_t f_bitmap;
3041 f_bitmap = decode_file_bitmap(tree, tvb, offset);
3042 offset += 2;
3044 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap,0);
3046 return offset;
3049 /* ************************** */
3050 static int
3051 dissect_query_afp_set_fork_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3053 uint16_t bitmap;
3054 int param;
3056 PAD(1);
3057 add_info_fork(tvb, pinfo, offset);
3058 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
3059 offset += 2;
3061 bitmap = decode_file_bitmap(tree, tvb, offset);
3062 offset += 2;
3064 if ((bitmap & kFPExtDataForkLenBit) || (bitmap & kFPExtRsrcForkLenBit)) {
3065 proto_tree_add_item(tree, hf_afp_ofork_len64, tvb, offset, 8, ENC_BIG_ENDIAN);
3066 offset += 8;
3068 else {
3069 proto_tree_add_item(tree, hf_afp_ofork_len, tvb, offset, 4, ENC_BIG_ENDIAN);
3070 param = tvb_get_ntohl(tvb, offset);
3071 col_append_fstr(pinfo->cinfo, COL_INFO, " Size=%d", param);
3072 offset += 4;
3074 return offset;
3077 /* ************************** */
3078 static int
3079 dissect_query_afp_move(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3082 PAD(1);
3083 offset = decode_vol_did(tree, tvb, offset);
3085 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
3086 offset += 4;
3088 offset = decode_name_label(tree, pinfo, tvb, offset, "Source path: %s", true);
3089 offset = decode_name_label(tree, pinfo, tvb, offset, "Dest dir: %s", false);
3090 offset = decode_name_label(tree, pinfo, tvb, offset, "New name: %s", false);
3092 return offset;
3095 /* ************************** */
3096 static int
3097 dissect_query_afp_exchange_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3100 PAD(1);
3101 offset = decode_vol_did(tree, tvb, offset);
3103 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
3104 offset += 4;
3106 offset = decode_name_label(tree, pinfo, tvb, offset, "Source path: %s", true);
3107 offset = decode_name_label(tree, pinfo, tvb, offset, "Dest path: %s", false);
3109 return offset;
3111 /* ************************** */
3112 static int
3113 dissect_query_afp_copy_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3115 proto_tree *sub_tree;
3117 PAD(1);
3118 sub_tree = proto_tree_add_subtree(tree, tvb, offset, 6, ett_afp_vol_did, NULL, "Source volume");
3120 offset = decode_vol_did(sub_tree, tvb, offset);
3122 sub_tree = proto_tree_add_subtree(tree, tvb, offset, 6, ett_afp_vol_did, NULL, "Dest volume");
3124 offset = decode_vol_did(sub_tree, tvb, offset);
3126 offset = decode_name_label(tree, pinfo, tvb, offset, "Source path: %s", true);
3127 offset = decode_name_label(tree, pinfo, tvb, offset, "Dest dir: %s", false);
3128 offset = decode_name_label(tree, pinfo, tvb, offset, "New name: %s", false);
3130 return offset;
3133 /* ************************** */
3134 static int
3135 dissect_query_afp_rename(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3138 PAD(1);
3139 offset = decode_vol_did(tree, tvb, offset);
3141 offset = decode_name_label(tree, pinfo, tvb, offset, "Old name: %s", true);
3142 offset = decode_name_label(tree, pinfo, tvb, offset, "New name: %s", false);
3144 return offset;
3147 /* ************************** */
3148 static int
3149 dissect_query_afp_byte_lock(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3151 proto_tree *sub_tree;
3152 uint8_t flag;
3154 flag = tvb_get_uint8(tvb, offset);
3155 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, 1,
3156 ett_afp_lock_flags, NULL, "Flags: 0x%02x", flag);
3158 proto_tree_add_item(sub_tree, hf_afp_lock_op, tvb, offset, 1, ENC_BIG_ENDIAN);
3159 proto_tree_add_item(sub_tree, hf_afp_lock_from, tvb, offset, 1, ENC_BIG_ENDIAN);
3160 offset += 1;
3162 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
3163 offset += 2;
3165 proto_tree_add_item(tree, hf_afp_lock_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
3166 offset += 4;
3168 proto_tree_add_item(tree, hf_afp_lock_len, tvb, offset, 4, ENC_BIG_ENDIAN);
3169 offset += 4;
3170 return offset;
3173 /* -------------------------- */
3174 static int
3175 dissect_reply_afp_byte_lock(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3177 proto_tree_add_item(tree, hf_afp_lock_range_start, tvb, offset, 4, ENC_BIG_ENDIAN);
3178 offset += 4;
3180 return offset;
3183 /* ************************** */
3184 static int
3185 dissect_query_afp_byte_lock_ext(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3187 proto_tree *sub_tree;
3188 uint8_t flag;
3190 flag = tvb_get_uint8(tvb, offset);
3191 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, 1,
3192 ett_afp_lock_flags, NULL, "Flags: 0x%02x", flag);
3194 proto_tree_add_item(sub_tree, hf_afp_lock_op, tvb, offset, 1, ENC_BIG_ENDIAN);
3195 proto_tree_add_item(sub_tree, hf_afp_lock_from, tvb, offset, 1, ENC_BIG_ENDIAN);
3196 offset += 1;
3198 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2, ENC_BIG_ENDIAN);
3199 offset += 2;
3201 proto_tree_add_item(tree, hf_afp_lock_offset64, tvb, offset, 8, ENC_BIG_ENDIAN);
3202 offset += 8;
3204 proto_tree_add_item(tree, hf_afp_lock_len64, tvb, offset, 8, ENC_BIG_ENDIAN);
3205 offset += 8;
3206 return offset;
3209 /* -------------------------- */
3210 static int
3211 dissect_reply_afp_byte_lock_ext(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3213 proto_tree_add_item(tree, hf_afp_lock_range_start64, tvb, offset, 8, ENC_BIG_ENDIAN);
3214 offset += 8;
3216 return offset;
3219 /* ************************** */
3220 static int
3221 dissect_query_afp_add_cmt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3223 uint8_t len;
3225 PAD(1);
3226 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
3227 offset += 2;
3229 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
3230 offset += 4;
3232 offset = decode_name(tree, pinfo, tvb, offset);
3234 if ((offset & 1))
3235 PAD(1);
3237 len = tvb_get_uint8(tvb, offset);
3238 proto_tree_add_item(tree, hf_afp_comment, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
3239 offset += len +1;
3241 return offset;
3245 /* ************************** */
3246 static int
3247 dissect_query_afp_get_cmt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3250 PAD(1);
3251 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
3252 offset += 2;
3254 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
3255 offset += 4;
3257 offset = decode_name(tree, pinfo, tvb, offset);
3258 return offset;
3261 /* -------------------------- */
3262 static int
3263 dissect_reply_afp_get_cmt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3265 uint8_t len;
3267 len = tvb_get_uint8(tvb, offset);
3268 proto_tree_add_item(tree, hf_afp_comment, tvb, offset, 1, ENC_UTF_8|ENC_BIG_ENDIAN);
3269 offset += len +1;
3271 return offset;
3274 /* ************************** */
3275 static int
3276 dissect_query_afp_get_icon(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3279 PAD(1);
3280 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
3281 offset += 2;
3282 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4, ENC_UTF_8);
3283 offset += 4;
3285 proto_tree_add_item(tree, hf_afp_file_type, tvb, offset, 4, ENC_ASCII);
3286 offset += 4;
3288 proto_tree_add_item(tree, hf_afp_icon_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3289 offset += 1;
3290 PAD(1);
3292 proto_tree_add_item(tree, hf_afp_icon_length, tvb, offset, 2, ENC_BIG_ENDIAN);
3293 offset += 2;
3295 return offset;
3298 /* ************************** */
3299 static int
3300 dissect_query_afp_get_icon_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3303 PAD(1);
3304 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
3305 offset += 2;
3306 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4, ENC_ASCII);
3307 offset += 4;
3309 proto_tree_add_item(tree, hf_afp_icon_index, tvb, offset, 2, ENC_BIG_ENDIAN);
3310 offset += 2;
3312 return offset;
3315 /* -------------------------- */
3316 static int
3317 dissect_reply_afp_get_icon_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3320 proto_tree_add_item(tree, hf_afp_icon_tag, tvb, offset, 4, ENC_BIG_ENDIAN);
3321 offset += 4;
3323 proto_tree_add_item(tree, hf_afp_file_type, tvb, offset, 4, ENC_ASCII);
3324 offset += 4;
3326 proto_tree_add_item(tree, hf_afp_icon_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3327 offset += 1;
3329 PAD(1);
3330 proto_tree_add_item(tree, hf_afp_icon_length, tvb, offset, 2, ENC_BIG_ENDIAN);
3331 offset += 2;
3333 return offset;
3336 /* ************************** */
3337 static int
3338 dissect_query_afp_add_icon(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3341 PAD(1);
3342 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
3343 offset += 2;
3344 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4, ENC_ASCII);
3345 offset += 4;
3347 proto_tree_add_item(tree, hf_afp_file_type, tvb, offset, 4, ENC_ASCII);
3348 offset += 4;
3350 proto_tree_add_item(tree, hf_afp_icon_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3351 offset += 1;
3353 PAD(1);
3354 proto_tree_add_item(tree, hf_afp_icon_tag, tvb, offset, 4, ENC_BIG_ENDIAN);
3355 offset += 4;
3357 proto_tree_add_item(tree, hf_afp_icon_length, tvb, offset, 2, ENC_BIG_ENDIAN);
3358 offset += 2;
3360 return offset;
3363 /* **************************
3364 no reply
3366 static int
3367 decode_dt_did(proto_tree *tree, tvbuff_t *tvb, int offset)
3369 /* FIXME it's not volume but dt cf decode_name*/
3370 Vol = tvb_get_ntohs(tvb, offset);
3371 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
3372 offset += 2;
3374 Did = tvb_get_ntohl(tvb, offset);
3375 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
3376 offset += 4;
3377 return offset;
3380 /* -------------------------- */
3381 static int
3382 dissect_query_afp_add_appl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3385 PAD(1);
3386 offset = decode_dt_did(tree, tvb, offset);
3388 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4, ENC_ASCII);
3389 offset += 4;
3391 proto_tree_add_item(tree, hf_afp_appl_tag, tvb, offset, 4, ENC_BIG_ENDIAN);
3392 offset += 4;
3394 offset = decode_name(tree, pinfo, tvb, offset);
3396 return offset;
3399 /* **************************
3400 no reply
3402 static int
3403 dissect_query_afp_rmv_appl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3406 PAD(1);
3407 offset = decode_dt_did(tree, tvb, offset);
3409 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4, ENC_ASCII);
3410 offset += 4;
3412 offset = decode_name(tree, pinfo, tvb, offset);
3414 return offset;
3417 /* ************************** */
3418 static int
3419 dissect_query_afp_get_appl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3422 PAD(1);
3423 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2, ENC_BIG_ENDIAN);
3424 offset += 2;
3426 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4, ENC_ASCII);
3427 offset += 4;
3429 proto_tree_add_item(tree, hf_afp_appl_index, tvb, offset, 2, ENC_BIG_ENDIAN);
3430 offset += 2;
3432 decode_file_bitmap(tree, tvb, offset);
3433 offset += 2;
3435 return offset;
3438 /* -------------------------- */
3439 static int
3440 dissect_reply_afp_get_appl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3442 proto_tree_add_item(tree, hf_afp_appl_tag, tvb, offset, 4, ENC_BIG_ENDIAN);
3443 offset += 4;
3445 return offset;
3448 /* ************************** */
3449 static int
3450 dissect_query_afp_create_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3452 proto_tree_add_item(tree, hf_afp_create_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
3453 offset++;
3455 offset = decode_vol_did(tree, tvb, offset);
3457 offset = decode_name(tree, pinfo, tvb, offset);
3459 return offset;
3462 /* ************************** */
3463 static int
3464 dissect_query_afp_map_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3466 uint8_t type;
3468 type = tvb_get_uint8(tvb, offset);
3469 proto_tree_add_item(tree, hf_afp_map_id_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3470 offset++;
3472 if ( type < 5) {
3473 proto_tree_add_item(tree, hf_afp_map_id, tvb, offset, 4, ENC_BIG_ENDIAN);
3474 offset += 4;
3476 else {
3477 proto_tree_add_item(tree, hf_afp_UUID, tvb, offset, 16, ENC_BIG_ENDIAN);
3478 offset += 16;
3481 return offset;
3484 /* -------------------------- */
3485 static int
3486 dissect_reply_afp_map_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3488 int len;
3489 int size = 1;
3491 len = tvb_get_uint8(tvb, offset);
3492 /* for type 3 and 4 len is 16 bits but we don't keep the type from the request
3493 * XXX assume name < 256, ie the first byte is zero.
3495 if (!len) {
3496 len = tvb_get_uint8(tvb, offset +1);
3497 if (!len) {
3499 * Assume it's kUserUUIDToUTF8Name or
3500 * kGroupUUIDToUTF8Name.
3502 proto_tree_add_item(tree, hf_afp_map_id_reply_type, tvb, offset, 4, ENC_BIG_ENDIAN);
3503 offset += 4;
3505 proto_tree_add_item(tree, hf_afp_map_id, tvb, offset, 4, ENC_BIG_ENDIAN);
3506 offset += 4;
3508 size = 2;
3509 len = tvb_get_uint8(tvb, offset +1);
3512 else {
3513 int remain = tvb_reported_length_remaining(tvb,offset);
3514 if (remain == len +2) {
3515 size = 2;
3517 else {
3518 /* give up */
3519 len = remain;
3520 size = 0;
3524 if (size) {
3525 proto_tree_add_item(tree, hf_afp_map_name, tvb, offset, size, ENC_ASCII|ENC_BIG_ENDIAN);
3527 else {
3528 proto_tree_add_item(tree, hf_afp_unknown, tvb, offset, len, ENC_NA);
3530 offset += len +size;
3531 return offset;
3534 /* ************************** */
3535 static int
3536 dissect_query_afp_map_name(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3538 int len;
3539 int type;
3540 int size;
3542 type = tvb_get_uint8(tvb, offset);
3543 proto_tree_add_item(tree, hf_afp_map_name_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3544 offset++;
3545 switch (type) {
3546 case 5:
3547 case 6:
3549 * Maps to UUID, UTF-8 string
3551 * XXX - the spec doesn't say the string length is 2 bytes
3552 * for this case.
3554 size = 2;
3555 len = tvb_get_ntohs(tvb, offset);
3556 break;
3557 default:
3558 /* Maps to UID/GID */
3559 size = 1;
3560 len = tvb_get_uint8(tvb, offset);
3561 break;
3563 proto_tree_add_item(tree, hf_afp_map_name, tvb, offset, size, ENC_ASCII|ENC_BIG_ENDIAN);
3564 offset += len +size;
3566 return offset;
3569 /* -------------------------- */
3570 static int
3571 dissect_reply_afp_map_name(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3573 int remain;
3575 /* We don't keep the type from the request */
3576 /* If remain == 16, assume UUID */
3577 remain = tvb_reported_length(tvb);
3578 if (remain == 16) {
3579 proto_tree_add_item(tree, hf_afp_UUID, tvb, offset, 16, ENC_BIG_ENDIAN);
3580 offset += 16;
3582 else {
3583 proto_tree_add_item(tree, hf_afp_map_id, tvb, offset, 4, ENC_BIG_ENDIAN);
3584 offset += 4;
3587 return offset;
3590 /* ************************** */
3591 static int
3592 dissect_query_afp_disconnect_old_session(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3594 uint32_t token_len;
3596 PAD(1);
3598 proto_tree_add_item(tree, hf_afp_session_token_type, tvb, offset, 2, ENC_BIG_ENDIAN);
3599 offset += 2;
3601 proto_tree_add_item_ret_uint(tree, hf_afp_session_token_len,
3602 tvb, offset, 4, ENC_BIG_ENDIAN, &token_len);
3603 offset += 4;
3605 if ((uint32_t)offset + token_len > INT_MAX)
3606 return offset;
3608 proto_tree_add_item(tree, hf_afp_session_token,
3609 tvb, offset, (int)token_len, ENC_NA);
3610 offset += (int)token_len;
3612 return offset;
3615 /* ************************** */
3616 static int
3617 dissect_query_afp_get_session_token(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3619 uint16_t token;
3620 uint32_t token_len;
3622 PAD(1);
3624 token = tvb_get_ntohs(tvb, offset);
3625 proto_tree_add_item(tree, hf_afp_session_token_type, tvb, offset, 2, ENC_BIG_ENDIAN);
3626 offset += 2;
3627 if (token == kLoginWithoutID || token == kGetKerberosSessionKey) /* 0 || 8 */
3628 return offset;
3630 proto_tree_add_item_ret_uint(tree, hf_afp_session_token_len,
3631 tvb, offset, 4, ENC_BIG_ENDIAN, &token_len);
3632 offset += 4;
3634 if (token==kLoginWithTimeAndID || token==kReconnWithTimeAndID) {
3635 proto_tree_add_item(tree, hf_afp_session_token_timestamp,
3636 tvb, offset, 4, ENC_BIG_ENDIAN);
3637 offset += 4;
3640 if ((uint32_t)offset + token_len > INT_MAX)
3641 return offset;
3643 proto_tree_add_item(tree, hf_afp_session_token,
3644 tvb, offset, (int)token_len, ENC_NA);
3645 offset += (int)token_len;
3647 return offset;
3650 /* -------------------------- */
3651 static int
3652 dissect_reply_afp_get_session_token(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3654 int size;
3655 uint32_t token_len;
3657 /* FIXME spec and capture disagree : or it's 4 bytes with no token type, or it's 2 bytes */
3658 size = 4;
3659 /* [cm]: FIXME continued: Since size is set to 4, this test is never true.
3660 if (size == 2) {
3661 proto_tree_add_item(tree, hf_afp_session_token_type, tvb, offset, 2, ENC_BIG_ENDIAN);
3662 offset += 2;
3665 proto_tree_add_item_ret_uint(tree, hf_afp_session_token_len,
3666 tvb, offset, size, ENC_BIG_ENDIAN, &token_len);
3667 offset += size;
3669 if ((uint32_t)offset + token_len > INT_MAX)
3670 return offset;
3672 proto_tree_add_item(tree, hf_afp_session_token,
3673 tvb, offset, (int)token_len, ENC_NA);
3674 offset += (int)token_len;
3676 return offset;
3679 /* ************************** */
3680 static int * const afp_message_bitmaps[] = {
3681 &hf_afp_message_bitmap_REQ,
3682 &hf_afp_message_bitmap_UTF,
3683 NULL
3686 static int
3687 dissect_query_afp_get_server_message(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3690 PAD(1);
3691 proto_tree_add_item(tree, hf_afp_message_type, tvb, offset, 2, ENC_BIG_ENDIAN);
3692 offset += 2;
3694 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_message_bitmap,
3695 ett_afp_message_bitmap, afp_message_bitmaps, ENC_BIG_ENDIAN);
3696 offset += 2;
3698 return offset;
3701 /* ************************** */
3702 static int
3703 dissect_reply_afp_get_server_message(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3705 uint16_t bitmap;
3706 uint16_t len = 0;
3708 /* FIXME: APF 3.1 specs also specify a long reply format, yet unused */
3710 proto_tree_add_item(tree, hf_afp_message_type, tvb, offset, 2, ENC_BIG_ENDIAN);
3711 offset += 2;
3713 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_message_bitmap,
3714 ett_afp_message_bitmap, afp_message_bitmaps, ENC_BIG_ENDIAN);
3715 bitmap = tvb_get_ntohs(tvb, offset);
3716 offset += 2;
3719 * XXX - the spec says that the 0x01 bit indicates whether
3720 * the ServerMessage field contains a server message or a login
3721 * message.
3723 if (bitmap & 0x02) {
3724 /* Message is UTF-8, and message length is 2 bytes */
3725 len = tvb_get_ntohs(tvb, offset);
3726 proto_tree_add_item(tree, hf_afp_message_len, tvb, offset, 2, ENC_BIG_ENDIAN);
3727 offset += 2;
3728 if (len) {
3729 proto_tree_add_item(tree, hf_afp_message, tvb, offset, len , ENC_UTF_8);
3730 offset += len;
3732 } else {
3734 * Message is not UTF-8, and message length is 1 byte.
3736 * Is the message in some Mac encoding? Always Mac Roman,
3737 * or possibly some other encoding for other locales?
3739 len = tvb_get_uint8(tvb, offset);
3740 proto_tree_add_item(tree, hf_afp_message_len, tvb, offset, 1, ENC_BIG_ENDIAN);
3741 offset += 1;
3742 if (len) {
3743 proto_tree_add_item(tree, hf_afp_message, tvb, offset, len , ENC_ASCII);
3744 offset += len;
3748 return offset;
3751 /* ************************** */
3752 static int * const afp_user_bitmaps[] = {
3753 &hf_afp_user_bitmap_UID,
3754 &hf_afp_user_bitmap_GID,
3755 &hf_afp_user_bitmap_UUID,
3756 NULL
3759 static int
3760 dissect_query_afp_get_user_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3763 proto_tree_add_item(tree, hf_afp_user_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
3764 offset++;
3766 proto_tree_add_item(tree, hf_afp_user_ID, tvb, offset, 4, ENC_BIG_ENDIAN);
3767 offset += 4;
3769 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_user_bitmap,
3770 ett_afp_user_bitmap, afp_user_bitmaps, ENC_BIG_ENDIAN);
3771 offset += 2;
3773 return offset;
3776 /* -------------------------- */
3777 static int
3778 dissect_reply_afp_get_user_info(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3780 uint16_t bitmap;
3782 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_user_bitmap,
3783 ett_afp_user_bitmap, afp_user_bitmaps, ENC_BIG_ENDIAN);
3784 bitmap = tvb_get_ntohs(tvb, offset);
3786 offset += 2;
3787 if ((bitmap & 1)) {
3788 proto_tree_add_item(tree, hf_afp_user_ID, tvb, offset, 4, ENC_BIG_ENDIAN);
3789 offset += 4;
3792 if ((bitmap & 2)) {
3793 proto_tree_add_item(tree, hf_afp_group_ID, tvb, offset, 4, ENC_BIG_ENDIAN);
3794 offset += 4;
3797 if ((bitmap & 4)) {
3798 proto_tree_add_item(tree, hf_afp_UUID, tvb, offset, 16, ENC_BIG_ENDIAN);
3799 offset += 16;
3801 return offset;
3805 /* ************************** */
3806 static int
3807 decode_attr_name (proto_tree *tree, packet_info *pinfo _U_, tvbuff_t *tvb, int offset, const char *label)
3809 int len;
3811 if ((offset & 1))
3812 PAD(1);
3814 len = tvb_get_ntohs(tvb, offset);
3816 if (tree) {
3817 char *name;
3818 proto_tree *sub_tree;
3820 name = tvb_format_text(pinfo->pool, tvb,offset+2, len);
3821 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, len + 2,
3822 ett_afp_extattr_names, NULL, label, name);
3824 proto_tree_add_item(sub_tree, hf_afp_extattr_namelen, tvb, offset, 2, ENC_BIG_ENDIAN);
3825 proto_tree_add_item(sub_tree, hf_afp_extattr_name, tvb, offset +2, len, ENC_UTF_8);
3827 offset += 2 +len;
3829 return offset;
3832 /* ************************** */
3833 static int
3834 decode_attr_bitmap (proto_tree *tree, tvbuff_t *tvb, int offset)
3836 static int * const bitmaps[] = {
3837 &hf_afp_extattr_bitmap_NoFollow,
3838 &hf_afp_extattr_bitmap_Create,
3839 &hf_afp_extattr_bitmap_Replace,
3840 NULL
3843 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_extattr_bitmap,
3844 ett_afp_extattr_bitmap, bitmaps, ENC_BIG_ENDIAN);
3845 offset += 2;
3846 return offset;
3849 /* ************************** */
3850 static int
3851 dissect_query_afp_get_ext_attr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3853 PAD(1);
3854 offset = decode_vol_did(tree, tvb, offset);
3856 offset = decode_attr_bitmap(tree, tvb, offset);
3858 /* 8byte offset */
3859 proto_tree_add_item(tree, hf_afp_offset64, tvb, offset, 8, ENC_BIG_ENDIAN);
3860 offset += 8;
3861 /* 8byte reqcount */
3862 proto_tree_add_item(tree, hf_afp_reqcount64, tvb, offset, 8, ENC_BIG_ENDIAN);
3863 offset += 8;
3865 /* maxreply */
3866 proto_tree_add_item(tree, hf_afp_extattr_reply_size, tvb, offset, 4, ENC_BIG_ENDIAN);
3867 offset += 4;
3869 offset = decode_name(tree, pinfo, tvb, offset);
3871 offset = decode_attr_name(tree, pinfo, tvb, offset, "Attribute: %s");
3873 return offset;
3876 /* -------------------------- */
3877 static int
3878 dissect_reply_afp_get_ext_attr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3880 uint32_t extattr_len;
3882 offset = decode_attr_bitmap(tree, tvb, offset);
3884 proto_tree_add_item_ret_uint(tree, hf_afp_extattr_len,
3885 tvb, offset, 4, ENC_BIG_ENDIAN, &extattr_len);
3886 offset += 4;
3888 if ((uint32_t)offset + extattr_len > INT_MAX)
3889 return offset;
3891 proto_tree_add_item(tree, hf_afp_extattr_data,
3892 tvb, offset, (int)extattr_len, ENC_NA);
3893 offset += (int)extattr_len;
3895 return offset;
3898 /* ************************** */
3899 static int
3900 dissect_query_afp_set_ext_attr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3902 uint32_t len;
3904 PAD(1);
3905 offset = decode_vol_did(tree, tvb, offset);
3907 offset = decode_attr_bitmap(tree, tvb, offset);
3909 /* 8byte offset */
3910 proto_tree_add_item(tree, hf_afp_offset64, tvb, offset, 8, ENC_BIG_ENDIAN);
3911 offset += 8;
3913 offset = decode_name(tree, pinfo, tvb, offset);
3915 offset = decode_attr_name(tree, pinfo, tvb, offset, "Attribute: %s");
3917 proto_tree_add_item_ret_uint(tree, hf_afp_extattr_len, tvb, offset, 4, ENC_BIG_ENDIAN, &len);
3918 offset += 4;
3920 proto_tree_add_item(tree, hf_afp_extattr_data, tvb, offset, len, ENC_NA);
3921 offset += len;
3923 return offset;
3926 /* ************************** */
3927 static int
3928 dissect_query_afp_list_ext_attrs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3930 PAD(1);
3931 offset = decode_vol_did(tree, tvb, offset);
3933 /* for this command only kXAttrNoFollow is valid */
3934 offset = decode_attr_bitmap(tree, tvb, offset);
3936 proto_tree_add_item(tree, hf_afp_extattr_req_count, tvb, offset, 2, ENC_BIG_ENDIAN);
3937 offset += 2;
3939 proto_tree_add_item(tree, hf_afp_extattr_start_index, tvb, offset, 4, ENC_BIG_ENDIAN);
3940 offset += 4;
3942 proto_tree_add_item(tree, hf_afp_extattr_reply_size, tvb, offset, 4, ENC_BIG_ENDIAN);
3943 offset += 4;
3945 offset = decode_name(tree, pinfo, tvb, offset);
3947 return offset;
3950 /* -------------------------- */
3951 static int
3952 dissect_reply_afp_list_ext_attrs(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
3954 proto_tree *sub_tree;
3955 unsigned len_field = 0;
3956 int length;
3957 int remain;
3959 offset = decode_attr_bitmap(tree, tvb, offset);
3961 proto_tree_add_item_ret_uint(tree, hf_afp_extattr_reply_size,
3962 tvb, offset, 4, ENC_BIG_ENDIAN, &len_field);
3963 offset += 4;
3964 if (len_field > INT_MAX) {
3965 /* XXX - add expert info */
3966 return offset;
3969 /* If reply_size was 0 on request, server only reports the size of
3970 the entries without actually adding any entries */
3971 remain = tvb_reported_length_remaining(tvb, offset);
3972 if (remain < (int)len_field)
3973 return offset;
3975 sub_tree = proto_tree_add_subtree(tree, tvb, offset, remain,
3976 ett_afp_extattr_names, NULL, "Attributes");
3977 while (remain > 0) {
3978 length = (int)tvb_strsize(tvb, offset);
3980 proto_tree_add_item(sub_tree, hf_afp_extattr_name, tvb, offset, length, ENC_UTF_8);
3981 offset += length;
3982 remain -= length;
3985 return offset;
3988 /* ************************** */
3989 static int
3990 dissect_query_afp_remove_ext_attr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
3992 PAD(1);
3993 offset = decode_vol_did(tree, tvb, offset);
3995 offset = decode_attr_bitmap(tree, tvb, offset);
3997 offset = decode_name(tree, pinfo, tvb, offset);
3999 offset = decode_attr_name(tree, pinfo, tvb, offset, "Attribute: %s");
4001 return offset;
4004 /* ************************** */
4005 static int
4006 decode_acl_access_bitmap(tvbuff_t *tvb, proto_tree *tree, int offset)
4008 uint32_t bitmap;
4009 static int * const bitmaps[] = {
4010 &hf_afp_acl_access_bitmap_read_data,
4011 &hf_afp_acl_access_bitmap_write_data,
4012 &hf_afp_acl_access_bitmap_execute,
4013 &hf_afp_acl_access_bitmap_delete,
4014 &hf_afp_acl_access_bitmap_append_data,
4015 &hf_afp_acl_access_bitmap_delete_child,
4016 &hf_afp_acl_access_bitmap_read_attrs,
4017 &hf_afp_acl_access_bitmap_write_attrs,
4018 &hf_afp_acl_access_bitmap_read_extattrs,
4019 &hf_afp_acl_access_bitmap_write_extattrs,
4020 &hf_afp_acl_access_bitmap_read_security,
4021 &hf_afp_acl_access_bitmap_write_security,
4022 &hf_afp_acl_access_bitmap_change_owner,
4023 &hf_afp_acl_access_bitmap_synchronize,
4024 &hf_afp_acl_access_bitmap_generic_all,
4025 &hf_afp_acl_access_bitmap_generic_execute,
4026 &hf_afp_acl_access_bitmap_generic_write,
4027 &hf_afp_acl_access_bitmap_generic_read,
4028 NULL
4031 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_acl_access_bitmap,
4032 ett_afp_acl_access_bitmap, bitmaps, ENC_BIG_ENDIAN);
4033 bitmap = tvb_get_ntohl(tvb, offset);
4035 return bitmap;
4038 /* ************************** */
4039 static int
4040 dissect_query_afp_access(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
4042 PAD(1);
4043 offset = decode_vol_did(tree, tvb, offset);
4045 proto_tree_add_item(tree, hf_afp_access_bitmap, tvb, offset, 2, ENC_BIG_ENDIAN);
4046 offset += 2;
4048 proto_tree_add_item(tree, hf_afp_UUID, tvb, offset, 16, ENC_BIG_ENDIAN);
4049 offset += 16;
4051 decode_acl_access_bitmap(tvb, tree, offset);
4052 offset += 4;
4054 offset = decode_name(tree, pinfo, tvb, offset);
4056 return offset;
4059 /* ************************** */
4060 static int
4061 dissect_query_afp_with_did(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset)
4063 PAD(1);
4064 offset = decode_vol_did(tree, tvb, offset);
4066 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4, ENC_BIG_ENDIAN);
4067 offset += 4;
4069 return offset;
4072 /* ************************** */
4074 #define SQ_TYPE_NULL 0x0000
4075 #define SQ_TYPE_COMPLEX 0x0200
4076 #define SQ_TYPE_INT64 0x8400
4077 #define SQ_TYPE_BOOL 0x0100
4078 #define SQ_TYPE_FLOAT 0x8500
4079 #define SQ_TYPE_DATA 0x0700
4080 #define SQ_TYPE_CNIDS 0x8700
4081 #define SQ_TYPE_UUID 0x0e00
4082 #define SQ_TYPE_DATE 0x8600
4084 #define SQ_CPX_TYPE_ARRAY 0x0a00
4085 #define SQ_CPX_TYPE_STRING 0x0c00
4086 #define SQ_CPX_TYPE_UTF16_STRING 0x1c00
4087 #define SQ_CPX_TYPE_DICT 0x0d00
4088 #define SQ_CPX_TYPE_CNIDS 0x1a00
4089 #define SQ_CPX_TYPE_FILEMETA 0x1b00
4091 #define SUBQ_SAFETY_LIM 20
4093 static int
4094 spotlight_int64(tvbuff_t *tvb, proto_tree *tree, int offset, unsigned encoding)
4096 unsigned count, i;
4097 uint64_t query_data64;
4099 query_data64 = tvb_get_uint64(tvb, offset, encoding);
4100 count = (unsigned)(query_data64 >> 32);
4101 offset += 8;
4103 for (i = 0; i < count; i++) {
4104 proto_tree_add_item(tree, hf_afp_int64, tvb, offset, 8, encoding);
4105 offset += 8;
4108 return count;
4111 static int
4112 spotlight_date(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, unsigned encoding)
4114 unsigned count, i;
4115 uint64_t query_data64;
4116 nstime_t t;
4118 query_data64 = tvb_get_uint64(tvb, offset, encoding);
4119 count = (unsigned)(query_data64 >> 32);
4120 offset += 8;
4122 if (count > SUBQ_SAFETY_LIM) {
4123 expert_add_info_format(pinfo, tree, &ei_afp_subquery_count_over_safety_limit,
4124 "Subquery count (%d) > safety limit (%d)", count, SUBQ_SAFETY_LIM);
4125 return -1;
4128 for (i = 0; i < count; i++) {
4129 query_data64 = tvb_get_uint64(tvb, offset, encoding) >> 24;
4130 t.secs = (time_t)(query_data64 - SPOTLIGHT_TIME_DELTA);
4131 t.nsecs = 0;
4132 proto_tree_add_time(tree, hf_afp_spotlight_date, tvb, offset, 8, &t);
4133 offset += 8;
4136 return count;
4139 static int
4140 spotlight_uuid(tvbuff_t *tvb, proto_tree *tree, int offset, unsigned encoding)
4142 unsigned count, i;
4143 uint64_t query_data64;
4145 query_data64 = tvb_get_uint64(tvb, offset, encoding);
4146 count = (unsigned)(query_data64 >> 32);
4147 offset += 8;
4149 for (i = 0; i < count; i++) {
4150 proto_tree_add_item(tree, hf_afp_spotlight_uuid, tvb, offset, 16, ENC_BIG_ENDIAN);
4151 offset += 16;
4154 return count;
4157 static int
4158 spotlight_float(tvbuff_t *tvb, proto_tree *tree, int offset, unsigned encoding)
4160 unsigned count, i;
4161 uint64_t query_data64;
4163 query_data64 = tvb_get_uint64(tvb, offset, encoding);
4164 count = (unsigned)(query_data64 >> 32);
4165 offset += 8;
4167 for (i = 0; i < count; i++) {
4168 proto_tree_add_item(tree, hf_afp_float, tvb, offset, 8, encoding);
4169 offset += 8;
4172 return count;
4175 static int
4176 spotlight_CNID_array(tvbuff_t *tvb, proto_tree *tree, int offset, unsigned encoding)
4178 unsigned count;
4179 uint64_t query_data64;
4180 uint16_t unknown1;
4181 uint32_t unknown2;
4183 query_data64 = tvb_get_uint64(tvb, offset, encoding);
4184 count = (unsigned)(query_data64 & 0xffff);
4185 unknown1 = (query_data64 & 0xffff0000) >> 16;
4186 unknown2 = (uint32_t)(query_data64 >> 32);
4188 proto_tree_add_uint(tree, hf_afp_unknown16, tvb, offset + 2, 2, unknown1);
4189 proto_tree_add_uint(tree, hf_afp_unknown32, tvb, offset + 4, 4, unknown2);
4190 offset += 8;
4193 while (count --) {
4194 proto_tree_add_item(tree, hf_afp_cnid, tvb, offset, 8, encoding);
4195 offset += 8;
4198 return 0;
4201 static const val64_string qtype_string_values[] = {
4202 {SQ_TYPE_NULL, "null" },
4203 {SQ_TYPE_COMPLEX, "complex"},
4204 {SQ_TYPE_INT64, "int64" },
4205 {SQ_TYPE_BOOL, "bool"},
4206 {SQ_TYPE_FLOAT, "float" },
4207 {SQ_TYPE_DATA, "data"},
4208 {SQ_TYPE_CNIDS, "CNIDs" },
4209 {0, NULL}
4212 static const val64_string cpx_qtype_string_values[] = {
4213 {SQ_CPX_TYPE_ARRAY, "array" },
4214 {SQ_CPX_TYPE_STRING, "string"},
4215 {SQ_CPX_TYPE_UTF16_STRING, "utf-16 string" },
4216 {SQ_CPX_TYPE_DICT, "dictionary"},
4217 {SQ_CPX_TYPE_CNIDS, "CNIDs" },
4218 {SQ_CPX_TYPE_FILEMETA, "FileMeta"},
4219 {0, NULL}
4222 static int
4223 // NOLINTNEXTLINE(misc-no-recursion)
4224 spotlight_dissect_query_loop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
4225 uint64_t cpx_query_type, int count, int toc_offset, unsigned encoding)
4227 int i, j;
4228 int subquery_count;
4229 int toc_index;
4230 uint64_t query_data64;
4231 int query_length;
4232 uint64_t query_type;
4233 uint64_t complex_query_type;
4234 unsigned byte_order;
4235 bool mark_exists;
4236 tvbuff_t *spotlight_tvb;
4237 char *str_tmp;
4239 proto_item *item_query;
4240 proto_tree *sub_tree;
4243 * This loops through a possibly nested query data structure.
4244 * The outermost one is always without count and called from
4245 * dissect_spotlight() with count = prefs.gui_max_tree_depth
4246 * thus the while (...) loop terminates if (offset >= toc_offset).
4247 * If nested structures are found, these will have an encoded element
4248 * count which is used in a recursive call to
4249 * spotlight_dissect_query_loop as count parameter, thus in this case
4250 * the while (...) loop will terminate when count reaches 0.
4252 while ((offset < (toc_offset - 8)) && (count > 0)) {
4253 query_data64 = tvb_get_uint64(tvb, offset, encoding);
4254 query_length = ((int)query_data64 & 0xffff) * 8;
4255 if (query_length == 0) {
4256 /* XXX - report this as an error */
4257 break;
4259 query_type = (query_data64 & 0xffff0000) >> 16;
4261 switch (query_type) {
4262 case SQ_TYPE_COMPLEX:
4263 toc_index = (int)((query_data64 >> 32) - 1);
4264 query_data64 = tvb_get_uint64(tvb, toc_offset + toc_index * 8, encoding);
4265 complex_query_type = (query_data64 & 0xffff0000) >> 16;
4267 switch (complex_query_type) {
4268 case SQ_CPX_TYPE_ARRAY:
4269 case SQ_CPX_TYPE_DICT:
4270 subquery_count = (int)(query_data64 >> 32);
4271 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, query_length,
4272 ett_afp_spotlight_query_line, NULL,
4273 "%s, toc index: %u, children: %u",
4274 val64_to_str_const(complex_query_type, cpx_qtype_string_values, "Unknown"),
4275 toc_index + 1,
4276 subquery_count);
4277 break;
4278 case SQ_CPX_TYPE_STRING:
4279 subquery_count = 1;
4280 query_data64 = tvb_get_uint64(tvb, offset + 8, encoding);
4281 query_length = ((int)query_data64 & 0xffff) * 8;
4282 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, query_length + 8,
4283 ett_afp_spotlight_query_line, NULL,
4284 "%s, toc index: %u, string: '%s'",
4285 val64_to_str_const(complex_query_type, cpx_qtype_string_values, "Unknown"),
4286 toc_index + 1,
4287 tvb_get_string_enc(pinfo->pool, tvb, offset + 16, query_length - 8, ENC_UTF_8|ENC_NA));
4288 break;
4289 case SQ_CPX_TYPE_UTF16_STRING:
4291 * This is an UTF-16 string.
4292 * Dissections show the typical byte order mark 0xFFFE or 0xFEFF, respectively.
4293 * However the existence of such a mark can not be assumed.
4294 * If the mark is missing, big endian encoding is assumed.
4295 * XXX - assume the encoding given by "encoding"?
4298 subquery_count = 1;
4299 query_data64 = tvb_get_uint64(tvb, offset + 8, encoding);
4300 query_length = ((int)query_data64 & 0xffff) * 8;
4302 byte_order = spotlight_get_utf16_string_byte_order(tvb, offset + 16, query_length - 8, encoding);
4303 if (byte_order == 0xFFFFFFFF) {
4304 byte_order = ENC_BIG_ENDIAN;
4305 mark_exists = false;
4306 } else
4307 mark_exists = true;
4309 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, query_length + 8,
4310 ett_afp_spotlight_query_line, NULL,
4311 "%s, toc index: %u, utf-16 string: '%s'",
4312 val64_to_str_const(complex_query_type, cpx_qtype_string_values, "Unknown"),
4313 toc_index + 1,
4314 tvb_get_string_enc(pinfo->pool, tvb, offset + (mark_exists ? 18 : 16),
4315 query_length - (mark_exists? 10 : 8), ENC_UTF_16 | byte_order));
4316 break;
4317 default:
4318 subquery_count = 1;
4319 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, query_length,
4320 ett_afp_spotlight_query_line, NULL,
4321 "type: %s (%s), toc index: %u, children: %u",
4322 val64_to_str_const(query_type, qtype_string_values, "Unknown"),
4323 val64_to_str_const(complex_query_type, cpx_qtype_string_values, "Unknown"),
4324 toc_index + 1,
4325 subquery_count);
4326 break;
4329 offset += 8;
4330 offset = spotlight_dissect_query_loop(tvb, pinfo, sub_tree, offset, complex_query_type, subquery_count, toc_offset, encoding);
4331 count--;
4332 break;
4333 case SQ_TYPE_NULL:
4334 subquery_count = (int)(query_data64 >> 32);
4335 if (subquery_count > count) {
4336 item_query = proto_tree_add_item(tree, hf_afp_null, tvb, offset, query_length, ENC_NA);
4337 expert_add_info_format(pinfo, item_query, &ei_afp_subquery_count_over_query_count,
4338 "Subquery count (%d) > query count (%d)", subquery_count, count);
4339 count = 0;
4340 } else if (subquery_count > 20) {
4341 item_query = proto_tree_add_item(tree, hf_afp_null, tvb, offset, query_length, ENC_NA);
4342 expert_add_info_format(pinfo, item_query, &ei_afp_abnormal_num_subqueries,
4343 "Abnormal number of subqueries (%d)", subquery_count);
4344 count -= subquery_count;
4345 } else {
4346 for (i = 0; i < subquery_count; i++, count--)
4347 proto_tree_add_item(tree, hf_afp_null, tvb, offset, query_length, encoding);
4349 offset += query_length;
4350 break;
4351 case SQ_TYPE_BOOL:
4352 proto_tree_add_uint64_format_value(tree, hf_afp_bool, tvb, offset, query_length, (query_data64 >> 32), "%s", (query_data64 >> 32) ? "true" : "false");
4353 count--;
4354 offset += query_length;
4355 break;
4356 case SQ_TYPE_INT64:
4357 sub_tree = proto_tree_add_subtree(tree, tvb, offset, 8, ett_afp_spotlight_query_line, NULL, "int64");
4358 j = spotlight_int64(tvb, sub_tree, offset, encoding);
4359 count -= j;
4360 offset += query_length;
4361 break;
4362 case SQ_TYPE_UUID:
4363 sub_tree = proto_tree_add_subtree(tree, tvb, offset, 8, ett_afp_spotlight_query_line, NULL, "UUID");
4364 j = spotlight_uuid(tvb, sub_tree, offset, encoding);
4365 count -= j;
4366 offset += query_length;
4367 break;
4368 case SQ_TYPE_FLOAT:
4369 sub_tree = proto_tree_add_subtree(tree, tvb, offset, 8, ett_afp_spotlight_query_line, NULL, "float");
4370 j = spotlight_float(tvb, sub_tree, offset, encoding);
4371 count -= j;
4372 offset += query_length;
4373 break;
4374 case SQ_TYPE_DATA:
4375 switch (cpx_query_type) {
4376 case SQ_CPX_TYPE_STRING:
4377 str_tmp = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset + 8, query_length - 8, ENC_UTF_8|ENC_NA);
4378 proto_tree_add_string(tree, hf_afp_string, tvb, offset, query_length, str_tmp);
4379 break;
4380 case SQ_CPX_TYPE_UTF16_STRING: {
4381 /* description see above */
4382 byte_order = spotlight_get_utf16_string_byte_order(tvb, offset + 16, query_length - 8, encoding);
4383 if (byte_order == 0xFFFFFFFF) {
4384 byte_order = ENC_BIG_ENDIAN;
4385 mark_exists = false;
4386 } else
4387 mark_exists = true;
4389 str_tmp = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset + (mark_exists ? 10 : 8),
4390 query_length - (mark_exists? 10 : 8), ENC_UTF_16 | byte_order);
4391 proto_tree_add_string(tree, hf_afp_utf_16_string, tvb, offset, query_length, str_tmp);
4392 break;
4394 case SQ_CPX_TYPE_FILEMETA:
4395 sub_tree = proto_tree_add_subtree(tree, tvb, offset, query_length,
4396 ett_afp_spotlight_query_line, &item_query, "filemeta");
4397 if (query_length <= 8) {
4398 proto_item_append_text(item_query, " (empty)");
4399 } else {
4400 spotlight_tvb = tvb_new_subset_length(tvb, offset+8, query_length);
4401 call_dissector(spotlight_handle, spotlight_tvb, pinfo, sub_tree);
4403 break;
4405 count--;
4406 offset += query_length;
4407 break;
4408 case SQ_TYPE_CNIDS:
4409 sub_tree = proto_tree_add_subtree(tree, tvb, offset, query_length,
4410 ett_afp_spotlight_query_line, &item_query, "CNID Array");
4411 if (query_length <= 8) {
4412 proto_item_append_text(item_query, " (empty)");
4413 } else {
4414 spotlight_CNID_array(tvb, sub_tree, offset + 8, encoding);
4416 count--;
4417 offset += query_length;
4418 break;
4419 case SQ_TYPE_DATE:
4420 if ((j = spotlight_date(tvb, pinfo, tree, offset, encoding)) == -1)
4421 return offset;
4422 count -= j;
4423 offset += query_length;
4424 break;
4425 default:
4426 proto_tree_add_string(tree, hf_afp_query_type, tvb, offset, query_length, val64_to_str_const(query_type, qtype_string_values, "Unknown"));
4427 count--;
4428 offset += query_length;
4429 break;
4433 return offset;
4436 static const val64_string endian_vals[] = {
4437 {0, "Little Endian" },
4438 {1, "Big Endian" },
4439 {0, NULL } };
4441 static int
4442 dissect_spotlight(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4444 unsigned encoding;
4445 int i;
4446 int offset = 0;
4447 uint64_t toc_offset;
4448 uint64_t querylen;
4449 int toc_entries;
4450 uint64_t toc_entry;
4452 proto_tree *sub_tree_queries;
4453 proto_tree *sub_tree_toc;
4454 proto_item *ti;
4456 if (strncmp((char*)tvb_get_string_enc(pinfo->pool, tvb, offset, 8, ENC_UTF_8|ENC_NA), "md031234", 8) == 0)
4457 encoding = ENC_BIG_ENDIAN;
4458 else
4459 encoding = ENC_LITTLE_ENDIAN;
4460 proto_tree_add_uint64(tree, hf_afp_endianness, tvb, offset, 8, (encoding == ENC_BIG_ENDIAN));
4461 offset += 8;
4463 toc_offset = (tvb_get_uint64(tvb, offset, encoding) >> 32) * 8;
4464 if (toc_offset < 8) {
4465 ti = proto_tree_add_uint64(tree, hf_afp_toc_offset, tvb, offset, 8, toc_offset);
4466 expert_add_info_format(pinfo, ti, &ei_afp_toc_offset, "%" PRIu64 " < 8 (bogus)", toc_offset);
4467 return tvb_captured_length(tvb);
4469 toc_offset -= 8;
4470 if (offset + toc_offset + 8 > INT_MAX) {
4471 ti = proto_tree_add_uint64(tree, hf_afp_toc_offset, tvb, offset, 8, toc_offset);
4472 expert_add_info_format(pinfo, ti, &ei_afp_toc_offset, "%" PRIu64 " > %u (bogus)", toc_offset, INT_MAX - 8 - offset);
4473 return tvb_captured_length(tvb);
4475 querylen = (tvb_get_uint64(tvb, offset, encoding) & 0xffffffff) * 8;
4476 if (querylen < 8) {
4477 ti = proto_tree_add_uint64(tree, hf_afp_toc_offset, tvb, offset, 8, toc_offset);
4478 expert_add_info_format(pinfo, ti, &ei_afp_toc_offset, "%" PRIu64 " Bytes, Query length: %" PRIu64 " < 8 (bogus)",
4479 toc_offset, querylen);
4480 return tvb_captured_length(tvb);
4482 querylen -= 8;
4483 if (querylen > INT_MAX) {
4484 ti = proto_tree_add_uint64(tree, hf_afp_toc_offset, tvb, offset, 8, toc_offset);
4485 expert_add_info_format(pinfo, ti, &ei_afp_toc_offset, "%" PRIu64 " Bytes, Query length: %" PRIu64 " > %u (bogus)",
4486 toc_offset, querylen, INT_MAX);
4487 return tvb_captured_length(tvb);
4489 proto_tree_add_uint64(tree, hf_afp_toc_offset, tvb, offset, 8, toc_offset);
4490 proto_tree_add_uint64(tree, hf_afp_query_len, tvb, offset, 8, querylen);
4491 offset += 8;
4493 toc_entries = (int)(tvb_get_uint64(tvb, offset + (int)toc_offset, encoding) & 0xffff);
4495 sub_tree_queries = proto_tree_add_subtree(tree, tvb, offset, (int)toc_offset,
4496 ett_afp_spotlight_queries, NULL,
4497 "Spotlight RPC data");
4499 /* Queries */
4500 offset = spotlight_dissect_query_loop(tvb, pinfo, sub_tree_queries, offset, SQ_CPX_TYPE_ARRAY, prefs.gui_max_tree_depth, offset + (int)toc_offset + 8, encoding);
4502 /* ToC */
4503 sub_tree_toc = proto_tree_add_subtree_format(tree, tvb, offset,
4504 (int)querylen - (int)toc_offset,
4505 ett_afp_spotlight_toc, &ti,
4506 "Complex types ToC (%u entries)",
4507 toc_entries);
4508 if (toc_entries < 1) {
4509 proto_item_append_text(ti, " (%u < 1 - bogus)", toc_entries);
4510 return tvb_captured_length(tvb);
4512 proto_item_append_text(ti, " (%u entries)", toc_entries);
4514 toc_entries -= 1;
4515 proto_tree_add_uint(sub_tree_toc, hf_afp_num_toc_entries, tvb, offset, 2, toc_entries);
4516 proto_tree_add_item(sub_tree_toc, hf_afp_unknown16, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
4517 proto_tree_add_item(sub_tree_toc, hf_afp_unknown32, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
4519 offset += 8;
4520 for (i = 0; i < toc_entries; i++, offset += 8) {
4521 toc_entry = tvb_get_uint64(tvb, offset, encoding);
4522 switch((toc_entry & 0xffff0000) >> 16)
4524 case SQ_CPX_TYPE_ARRAY:
4525 case SQ_CPX_TYPE_DICT:
4526 proto_tree_add_uint64_format(sub_tree_toc, hf_afp_toc_entry, tvb, offset, 8, toc_entry,
4527 "%u: count: %" PRIu64 ", type: %s, offset: %" PRIu64,
4528 i+1, toc_entry >> 32, val64_to_str_const((toc_entry & 0xffff0000) >> 16, cpx_qtype_string_values, "Unknown"),
4529 (toc_entry & 0xffff) * 8);
4530 break;
4531 case SQ_CPX_TYPE_STRING:
4532 case SQ_CPX_TYPE_UTF16_STRING:
4533 proto_tree_add_uint64_format(sub_tree_toc, hf_afp_toc_entry, tvb, offset, 8, toc_entry,
4534 "%u: pad byte count: %" PRIx64 ", type: %s, offset: %" PRIu64,
4535 i+1, 8 - (toc_entry >> 32), val64_to_str_const((toc_entry & 0xffff0000) >> 16, cpx_qtype_string_values, "Unknown"),
4536 (toc_entry & 0xffff) * 8);
4537 break;
4538 default:
4539 proto_tree_add_uint64_format(sub_tree_toc, hf_afp_toc_entry, tvb, offset, 8, toc_entry,
4540 "%u: unknown: 0x%08" PRIx64 ", type: %s, offset: %" PRIu64,
4541 i+1, toc_entry >> 32, val64_to_str_const((toc_entry & 0xffff0000) >> 16, cpx_qtype_string_values, "Unknown"),
4542 (toc_entry & 0xffff) * 8);
4546 return offset;
4549 static int
4550 dissect_query_afp_spotlight(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, afp_request_val *request_val)
4552 int len;
4553 tvbuff_t *spotlight_tvb;
4555 PAD(1);
4556 offset = decode_vol(tree, tvb, offset);
4558 proto_tree_add_item(tree, hf_afp_spotlight_request_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
4559 offset += 4;
4561 proto_tree_add_item(tree, hf_afp_spotlight_request_command, tvb, offset, 4, ENC_BIG_ENDIAN);
4562 offset += 4;
4564 proto_tree_add_item(tree, hf_afp_spotlight_request_reserved, tvb, offset, 4, ENC_BIG_ENDIAN);
4565 offset += 4;
4567 switch (request_val->spotlight_req_command) {
4569 case SPOTLIGHT_CMD_GET_VOLPATH:
4570 tvb_get_stringz_enc(pinfo->pool, tvb, offset, &len, ENC_UTF_8|ENC_NA);
4571 proto_tree_add_item(tree, hf_afp_spotlight_volpath_client, tvb, offset, len, ENC_UTF_8);
4572 offset += len;
4573 break;
4575 case SPOTLIGHT_CMD_GET_VOLID:
4576 /* empty */
4577 break;
4579 case SPOTLIGHT_CMD_GET_THREE:
4580 proto_tree_add_item(tree, hf_afp_spotlight_volflags, tvb, offset, 4, ENC_BIG_ENDIAN);
4581 offset += 4;
4583 proto_tree_add_item(tree, hf_afp_spotlight_reqlen, tvb, offset, 4, ENC_BIG_ENDIAN);
4584 offset += 4;
4586 spotlight_tvb = tvb_new_subset_remaining(tvb, offset);
4587 offset += call_dissector(spotlight_handle, spotlight_tvb, pinfo, tree);
4588 break;
4590 return offset;
4593 /* ************************** */
4594 static uint16_t
4595 decode_acl_list_bitmap(tvbuff_t *tvb, proto_tree *tree, int offset)
4597 uint16_t bitmap;
4598 static int * const bitmaps[] = {
4599 &hf_afp_acl_list_bitmap_UUID,
4600 &hf_afp_acl_list_bitmap_GRPUUID,
4601 &hf_afp_acl_list_bitmap_ACL,
4602 &hf_afp_acl_list_bitmap_REMOVEACL,
4603 &hf_afp_acl_list_bitmap_Inherit,
4604 NULL
4607 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_acl_list_bitmap,
4608 ett_afp_acl_list_bitmap, bitmaps, ENC_BIG_ENDIAN);
4609 bitmap = tvb_get_ntohs(tvb, offset);
4610 return bitmap;
4614 /* ************************** */
4615 static uint32_t
4616 decode_ace_flags_bitmap(tvbuff_t *tvb, proto_tree *tree, int offset)
4618 uint32_t bitmap;
4620 static int * const bitmaps[] = {
4621 &hf_afp_ace_flags_allow,
4622 &hf_afp_ace_flags_deny,
4623 &hf_afp_ace_flags_inherited,
4624 &hf_afp_ace_flags_fileinherit,
4625 &hf_afp_ace_flags_dirinherit,
4626 &hf_afp_ace_flags_limitinherit,
4627 &hf_afp_ace_flags_onlyinherit,
4628 NULL
4631 proto_tree_add_bitmask(tree, tvb, offset, hf_afp_ace_flags,
4632 ett_afp_ace_flags, bitmaps, ENC_BIG_ENDIAN);
4633 bitmap = tvb_get_ntohl(tvb, offset);
4635 return bitmap;
4638 static int
4639 decode_kauth_ace(tvbuff_t *tvb, proto_tree *tree, int offset)
4641 /* FIXME: preliminary decoding... */
4642 if (tree) {
4643 proto_tree_add_item(tree, hf_afp_UUID, tvb, offset, 16, ENC_BIG_ENDIAN);
4644 offset += 16;
4646 decode_ace_flags_bitmap(tvb, tree, offset);
4647 offset += 4;
4649 decode_acl_access_bitmap(tvb, tree, offset);
4650 offset += 4;
4652 else {
4653 offset += 24;
4655 return offset;
4658 #define AFP_MAX_ACL_ENTRIES 500 /* Arbitrary. */
4659 static int
4660 decode_kauth_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
4662 uint32_t num_entries, i;
4663 proto_tree *sub_tree, *ace_tree;
4664 proto_item *item;
4666 item = proto_tree_add_item_ret_uint(tree, hf_afp_acl_entrycount,
4667 tvb, offset, 4, ENC_BIG_ENDIAN, &num_entries);
4668 sub_tree = proto_item_add_subtree(item, ett_afp_ace_entries);
4669 offset += 4;
4671 proto_tree_add_item(tree, hf_afp_acl_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
4672 offset += 4;
4674 if (num_entries > AFP_MAX_ACL_ENTRIES) {
4675 expert_add_info_format(pinfo, item, &ei_afp_too_many_acl_entries,
4676 "Too many ACL entries (%u). Stopping dissection.",
4677 num_entries);
4678 return offset;
4681 for (i = 0; i < num_entries; i++) {
4682 ace_tree = proto_tree_add_subtree_format(sub_tree, tvb, offset, 24, ett_afp_ace_entry, NULL, "ACE: %u", i);
4683 offset = decode_kauth_ace(tvb, ace_tree, offset);
4686 return offset;
4689 static int
4690 decode_uuid_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, uint16_t bitmap)
4692 if ((offset & 1))
4693 PAD(1);
4695 if ((bitmap & kFileSec_UUID)) {
4696 proto_tree_add_item(tree, hf_afp_UUID, tvb, offset, 16, ENC_BIG_ENDIAN);
4697 offset += 16;
4700 if ((bitmap & kFileSec_GRPUUID)) {
4701 proto_tree_add_item(tree, hf_afp_GRPUUID, tvb, offset, 16, ENC_BIG_ENDIAN);
4702 offset += 16;
4705 if ((bitmap & kFileSec_ACL)) {
4706 offset = decode_kauth_acl(tvb, pinfo, tree, offset);
4709 return offset;
4712 /* ************************** */
4713 static int
4714 dissect_query_afp_set_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
4716 uint16_t bitmap;
4718 PAD(1);
4719 offset = decode_vol_did(tree, tvb, offset);
4721 bitmap = decode_acl_list_bitmap(tvb, tree, offset);
4722 offset += 2;
4724 offset = decode_name(tree, pinfo, tvb, offset);
4726 offset = decode_uuid_acl(tvb, pinfo, tree, offset, bitmap);
4728 return offset;
4731 /* ************************** */
4732 static int
4733 dissect_query_afp_get_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
4735 PAD(1);
4736 offset = decode_vol_did(tree, tvb, offset);
4738 decode_acl_list_bitmap(tvb, tree, offset);
4739 offset += 2;
4741 proto_tree_add_item(tree, hf_afp_max_reply_size32, tvb, offset, 4, ENC_BIG_ENDIAN);
4742 offset += 4;
4744 offset = decode_name(tree, pinfo, tvb, offset);
4746 return offset;
4749 /* -------------------------- */
4750 static int
4751 dissect_reply_afp_get_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
4753 uint16_t bitmap;
4755 bitmap = decode_acl_list_bitmap(tvb, tree, offset);
4756 offset += 2;
4758 offset = decode_uuid_acl(tvb, pinfo, tree, offset, bitmap);
4760 return offset;
4763 /* ************************** */
4764 static int
4765 dissect_reply_afp_spotlight(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, afp_request_val *request_val)
4767 int len;
4768 tvbuff_t *spotlight_tvb;
4770 switch (request_val->spotlight_req_command) {
4772 case SPOTLIGHT_CMD_GET_VOLPATH:
4773 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 4, ENC_BIG_ENDIAN);
4774 offset += 4;
4776 proto_tree_add_item(tree, hf_afp_spotlight_reply_reserved, tvb, offset, 4, ENC_BIG_ENDIAN);
4777 offset += 4;
4779 tvb_get_stringz_enc(pinfo->pool, tvb, offset, &len, ENC_UTF_8|ENC_NA);
4780 proto_tree_add_item(tree, hf_afp_spotlight_volpath_server, tvb, offset, len, ENC_UTF_8);
4781 offset += len;
4782 break;
4784 case SPOTLIGHT_CMD_GET_VOLID:
4785 proto_tree_add_item(tree, hf_afp_spotlight_volflags, tvb, offset, 4, ENC_BIG_ENDIAN);
4786 offset += 4;
4787 break;
4789 case SPOTLIGHT_CMD_GET_THREE:
4790 proto_tree_add_item(tree, hf_afp_spotlight_returncode, tvb, offset, 4, ENC_BIG_ENDIAN);
4791 offset += 4;
4793 spotlight_tvb = tvb_new_subset_remaining(tvb, offset);
4794 offset += call_dissector(spotlight_handle, spotlight_tvb, pinfo, tree);
4795 break;
4797 return offset;
4800 /* -----------------------------
4801 from netatalk/etc/afpd/status.c
4804 /* server flags */
4805 #define AFPSRVRINFO_COPY (1<<0) /* supports copyfile */
4806 #define AFPSRVRINFO_PASSWD (1<<1) /* supports change password */
4807 #define AFPSRVRINFO_NOSAVEPASSWD (1<<2) /* don't allow save password */
4808 #define AFPSRVRINFO_SRVMSGS (1<<3) /* supports server messages */
4809 #define AFPSRVRINFO_SRVSIGNATURE (1<<4) /* supports server signature */
4810 #define AFPSRVRINFO_TCPIP (1<<5) /* supports tcpip */
4811 #define AFPSRVRINFO_SRVNOTIFY (1<<6) /* supports server notifications */
4812 #define AFPSRVRINFO_SRVRECONNECT (1<<7) /* supports reconnect */
4813 #define AFPSRVRINFO_SRVDIRECTORY (1<<8) /* supports directory services */
4814 #define AFPSRVRINFO_SRVUTF8 (1<<9) /* supports UTF8 names AFP 3.1 */
4815 #define AFPSRVRINFO_UUID (1<<10) /* supports UUIDs AFP 3.2 */
4816 #define AFPSRVRINFO_EXT_SLEEP (1<<11) /* supports extended sleep, AFP 3.3 */
4817 #define AFPSRVRINFO_FASTBOZO (1<<15) /* fast copying */
4819 #define AFPSTATUS_MACHOFF 0
4820 #define AFPSTATUS_VERSOFF 2
4821 #define AFPSTATUS_UAMSOFF 4
4822 #define AFPSTATUS_ICONOFF 6
4823 #define AFPSTATUS_FLAGOFF 8
4824 #define AFPSTATUS_PRELEN 10
4825 #define AFPSTATUS_POSTLEN 4
4826 #define AFPSTATUS_LEN (AFPSTATUS_PRELEN + AFPSTATUS_POSTLEN)
4828 #define INET6_ADDRLEN 16
4830 static int
4831 dissect_afp_server_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
4833 int offset = 0;
4834 proto_tree *sub_tree;
4836 uint16_t flag;
4837 uint8_t server_name_len;
4838 uint16_t sign_ofs = 0;
4839 uint16_t adr_ofs = 0;
4840 uint16_t dir_ofs = 0;
4841 uint16_t utf_ofs = 0;
4842 int variable_data_offset;
4843 uint8_t nbe;
4844 unsigned len;
4845 unsigned i;
4847 static int * const flags[] = {
4848 &hf_afp_server_flag_copyfile,
4849 &hf_afp_server_flag_passwd,
4850 &hf_afp_server_flag_no_save_passwd,
4851 &hf_afp_server_flag_srv_msg,
4852 &hf_afp_server_flag_srv_sig,
4853 &hf_afp_server_flag_tcpip,
4854 &hf_afp_server_flag_notify,
4855 &hf_afp_server_flag_reconnect,
4856 &hf_afp_server_flag_directory,
4857 &hf_afp_server_flag_utf8_name,
4858 &hf_afp_server_flag_uuid,
4859 &hf_afp_server_flag_ext_sleep,
4860 &hf_afp_server_flag_fast_copy,
4861 NULL
4864 tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_afp_status, NULL, "Get Status");
4866 proto_tree_add_item(tree, hf_afp_machine_offset, tvb, AFPSTATUS_MACHOFF, 2, ENC_BIG_ENDIAN);
4868 proto_tree_add_item(tree, hf_afp_version_offset, tvb, AFPSTATUS_VERSOFF, 2, ENC_BIG_ENDIAN);
4870 proto_tree_add_item(tree, hf_afp_uams_offset, tvb, AFPSTATUS_UAMSOFF, 2, ENC_BIG_ENDIAN);
4872 proto_tree_add_item(tree, hf_afp_icon_offset, tvb, AFPSTATUS_ICONOFF, 2, ENC_BIG_ENDIAN);
4874 flag = tvb_get_ntohs(tvb, AFPSTATUS_FLAGOFF);
4876 proto_tree_add_bitmask(tree, tvb, AFPSTATUS_FLAGOFF, hf_afp_server_flag,
4877 ett_afp_status_server_flag, flags, ENC_BIG_ENDIAN);
4879 offset = AFPSTATUS_PRELEN;
4880 server_name_len = tvb_get_uint8(tvb, offset);
4881 proto_tree_add_item(tree, hf_afp_server_name, tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN);
4882 offset += 1 + server_name_len; /* 1 for the length byte */
4884 if ((flag & AFPSRVRINFO_SRVSIGNATURE)) {
4885 if ((offset & 1))
4886 offset++;
4887 sign_ofs = tvb_get_ntohs(tvb, offset);
4888 proto_tree_add_item(tree, hf_afp_signature_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
4889 offset += 2;
4892 if ((flag & AFPSRVRINFO_TCPIP)) {
4893 if ((offset & 1))
4894 offset++;
4895 adr_ofs = tvb_get_ntohs(tvb, offset);
4896 proto_tree_add_item(tree, hf_afp_network_address_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
4897 offset += 2;
4900 if ((flag & AFPSRVRINFO_SRVDIRECTORY)) {
4901 if ((offset & 1))
4902 offset++;
4903 dir_ofs = tvb_get_ntohs(tvb, offset);
4904 proto_tree_add_item(tree, hf_afp_directory_services_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
4905 offset += 2;
4908 if ((flag & AFPSRVRINFO_SRVUTF8)) {
4909 if ((offset & 1))
4910 offset++;
4911 utf_ofs = tvb_get_ntohs(tvb, offset);
4912 proto_tree_add_item(tree, hf_afp_utf8_server_name_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
4913 offset += 2;
4917 * XXX - should also check for overlap between "variable data" fields;
4918 * that requires keeping all the offsets and lengths and checking
4919 * against all the ones we've dissected so far.
4921 * XXX - should report an error if there's overlap, rather than
4922 * just ignoring the field.
4924 variable_data_offset = offset;
4925 offset = tvb_get_ntohs(tvb, AFPSTATUS_MACHOFF);
4926 if (offset) {
4927 if (offset >= variable_data_offset) {
4928 proto_tree_add_item(tree, hf_afp_server_type, tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN);
4932 offset = tvb_get_ntohs(tvb, AFPSTATUS_VERSOFF);
4933 if (offset) {
4934 if (offset >= variable_data_offset) {
4935 nbe = tvb_get_uint8(tvb, offset);
4936 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, 1,
4937 ett_afp_vers, NULL, "Version list: %u", nbe);
4938 offset++;
4939 for (i = 0; i < nbe; i++) {
4940 len = tvb_get_uint8(tvb, offset);
4941 proto_tree_add_item(sub_tree, hf_afp_server_vers, tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN);
4942 offset += len + 1;
4947 offset = tvb_get_ntohs(tvb, AFPSTATUS_UAMSOFF);
4948 if (offset) {
4949 if (offset >= variable_data_offset) {
4950 nbe = tvb_get_uint8(tvb, offset);
4951 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, 1,
4952 ett_afp_uams, NULL, "UAMS list: %u", nbe);
4953 offset++;
4954 for (i = 0; i < nbe; i++) {
4955 len = tvb_get_uint8(tvb, offset);
4956 proto_tree_add_item(sub_tree, hf_afp_server_uams, tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN);
4957 offset += len + 1;
4962 offset = tvb_get_ntohs(tvb, AFPSTATUS_ICONOFF);
4963 if (offset) {
4964 if (offset >= variable_data_offset)
4965 proto_tree_add_item(tree, hf_afp_server_icon, tvb, offset, 256, ENC_NA);
4968 if ((flag & AFPSRVRINFO_SRVSIGNATURE)) {
4969 if (sign_ofs >= variable_data_offset)
4970 proto_tree_add_item(tree, hf_afp_server_signature, tvb, sign_ofs, 16, ENC_NA);
4973 if ((flag & AFPSRVRINFO_TCPIP)) {
4974 if (adr_ofs >= variable_data_offset) {
4975 proto_tree *adr_tree;
4976 unsigned char *tmp;
4977 uint16_t net;
4978 uint8_t node;
4979 uint16_t port;
4981 offset = adr_ofs;
4982 nbe = tvb_get_uint8(tvb, offset);
4983 adr_tree = proto_tree_add_subtree_format(tree, tvb, offset, 1,
4984 ett_afp_server_addr, NULL, "Address list: %d", nbe);
4985 offset++;
4986 for (i = 0; i < nbe; i++) {
4987 uint8_t type;
4989 len = tvb_get_uint8(tvb, offset);
4990 type = tvb_get_uint8(tvb, offset +1);
4991 switch (type) {
4992 case 1: /* IP */
4993 sub_tree = proto_tree_add_subtree_format(adr_tree, tvb, offset, len, ett_afp_server_addr_line, NULL, "IP: %s", tvb_ip_to_str(pinfo->pool, tvb, offset+2));
4994 break;
4995 case 2: /* IP + port */
4996 port = tvb_get_ntohs(tvb, offset+6);
4997 sub_tree = proto_tree_add_subtree_format(adr_tree, tvb, offset, len,
4998 ett_afp_server_addr_line, NULL,
4999 "IP: %s:%d", tvb_ip_to_str(pinfo->pool, tvb, offset+2), port);
5000 break;
5001 case 3: /* DDP, atalk_addr_to_str want host order not network */
5002 net = tvb_get_ntohs(tvb, offset+2);
5003 node = tvb_get_uint8(tvb, offset +4);
5004 port = tvb_get_uint8(tvb, offset +5);
5005 sub_tree = proto_tree_add_subtree_format(adr_tree, tvb, offset, len,
5006 ett_afp_server_addr_line, NULL,
5007 "DDP: %u.%u:%u", net, node, port);
5008 break;
5009 case 4: /* DNS */
5010 case 5: /* SSH tunnel */
5012 * The AFP specifcation says of
5013 * the SSH tunnel type:
5015 * IP address (four bytes) with port
5016 * number (2 bytes). If this tag is
5017 * present and the client is so
5018 * configured, the client attempts
5019 * to build a Secure Shell (SSH)
5020 * tunnel between itself and the
5021 * server and tries to connect
5022 * through it. This functionality
5023 * is deprecated.
5025 * and, in the only place I've seen
5026 * it, it was like DNS.
5028 * So we treat it as DNS.
5030 * XXX - should we treat it as
5031 * IP+port if this is transported
5032 * over ASP rather DSI? The old
5033 * ASP code to dissect this
5034 * dissected it as IP+port.
5036 if (len > 2) {
5037 /* XXX - internationalized DNS? */
5038 tmp = tvb_get_string_enc(pinfo->pool, tvb, offset +2, len -2, ENC_ASCII|ENC_NA);
5039 sub_tree = proto_tree_add_subtree_format(adr_tree, tvb, offset, len, ett_afp_server_addr_line, NULL, "%s: %s", (type==4)?"DNS":"IP (SSH tunnel)", tmp);
5040 break;
5042 else {
5043 sub_tree = proto_tree_add_subtree(adr_tree, tvb, offset, len,
5044 ett_afp_server_addr_line, NULL, "Malformed DNS address");
5046 break;
5047 case 6: /* IP6 */
5048 sub_tree = proto_tree_add_subtree_format(adr_tree, tvb, offset, len, ett_afp_server_addr_line, NULL, "IPv6: %s", tvb_ip6_to_str(pinfo->pool, tvb, offset+2));
5049 break;
5050 case 7: /* IP6 + 2bytes port */
5051 port = tvb_get_ntohs(tvb, offset+ 2+INET6_ADDRLEN);
5052 sub_tree = proto_tree_add_subtree_format(adr_tree, tvb, offset, len,
5053 ett_afp_server_addr_line, NULL,
5054 "IPv6: %s:%d", tvb_ip6_to_str(pinfo->pool, tvb, offset+2), port);
5055 break;
5056 default:
5057 sub_tree = proto_tree_add_subtree_format(adr_tree, tvb, offset, len, ett_afp_server_addr_line, NULL, "Unknown type: %u", type);
5058 break;
5060 len -= 2;
5061 proto_tree_add_item(sub_tree, hf_afp_server_addr_len, tvb, offset, 1, ENC_BIG_ENDIAN);
5062 offset++;
5063 proto_tree_add_item(sub_tree, hf_afp_server_addr_type, tvb, offset, 1, ENC_BIG_ENDIAN);
5064 offset++;
5065 proto_tree_add_item(sub_tree, hf_afp_server_addr_value,tvb, offset, len, ENC_NA);
5066 offset += len;
5071 if ((flag & AFPSRVRINFO_SRVDIRECTORY)) {
5072 if (dir_ofs >= variable_data_offset) {
5073 offset = dir_ofs;
5074 nbe = tvb_get_uint8(tvb, offset);
5075 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, 1,
5076 ett_afp_directory, NULL, "Directory services list: %d", nbe);
5077 offset++;
5078 for (i = 0; i < nbe; i++) {
5079 len = tvb_get_uint8(tvb, offset);
5080 proto_tree_add_item(sub_tree, hf_afp_server_directory, tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN);
5081 offset += len + 1;
5086 if ((flag & AFPSRVRINFO_SRVUTF8)) {
5087 if (utf_ofs >= variable_data_offset) {
5088 uint16_t ulen;
5089 char *tmp;
5091 offset = utf_ofs;
5092 ulen = tvb_get_ntohs(tvb, offset);
5093 tmp = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset + 2, ulen, ENC_UTF_8|ENC_NA);
5094 sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, ulen + 2,
5095 ett_afp_utf8_name, NULL, "UTF-8 server name: %s", tmp);
5096 proto_tree_add_uint(sub_tree, hf_afp_utf8_server_name_len, tvb, offset, 2, ulen);
5097 offset += 2;
5098 proto_tree_add_string(sub_tree, hf_afp_utf8_server_name, tvb, offset, ulen, tmp);
5099 offset += ulen;
5103 return offset;
5106 /* ************************** */
5107 static int
5108 dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
5110 struct atp_asp_dsi_info *atp_asp_dsi_info = (struct atp_asp_dsi_info*)data;
5111 proto_tree *afp_tree = NULL;
5112 proto_item *ti;
5113 conversation_t *conversation;
5114 int offset = 0;
5115 afp_request_key request_key, *new_request_key;
5116 afp_request_val *request_val;
5117 uint8_t afp_command;
5118 nstime_t delta_ts;
5119 int len;
5121 /* Reject the packet if data is NULL */
5122 if (data == NULL)
5123 return 0;
5125 len = tvb_reported_length(tvb);
5126 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AFP");
5127 col_clear(pinfo->cinfo, COL_INFO);
5129 conversation = find_or_create_conversation(pinfo);
5131 request_key.conversation = conversation->conv_index;
5132 request_key.tid = atp_asp_dsi_info->tid;
5134 request_val = (afp_request_val *) wmem_map_lookup(
5135 afp_request_hash, &request_key);
5137 if (!request_val && !atp_asp_dsi_info->reply) {
5138 afp_command = tvb_get_uint8(tvb, offset);
5139 new_request_key = wmem_new(wmem_file_scope(), afp_request_key);
5140 *new_request_key = request_key;
5142 request_val = wmem_new(wmem_file_scope(), afp_request_val);
5143 request_val->command = afp_command;
5145 if (afp_command == AFP_SPOTLIGHTRPC)
5146 request_val->spotlight_req_command = tvb_get_ntohl(tvb, offset + 2 + 2 + 4);
5147 else
5148 request_val->spotlight_req_command = -1;
5150 request_val->frame_req = pinfo->num;
5151 request_val->frame_res = 0;
5152 request_val->req_time=pinfo->abs_ts;
5154 wmem_map_insert(afp_request_hash, new_request_key,
5155 request_val);
5158 if (!request_val) { /* missing request */
5159 col_set_str(pinfo->cinfo, COL_INFO, "[Reply without query?]");
5160 return tvb_captured_length(tvb);
5163 afp_command = request_val->command;
5164 col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s",
5165 val_to_str_ext(afp_command, &CommandCode_vals_ext,
5166 "Unknown command (%u)"),
5167 atp_asp_dsi_info->reply ? "reply" : "request");
5168 if (atp_asp_dsi_info->reply && atp_asp_dsi_info->code != 0) {
5169 col_append_fstr(pinfo->cinfo, COL_INFO, ": %s (%d)",
5170 val_to_str_ext(atp_asp_dsi_info->code, &asp_error_vals_ext,
5171 "Unknown error (%u)"), atp_asp_dsi_info->code);
5174 ti = proto_tree_add_item(tree, proto_afp, tvb, offset, -1, ENC_NA);
5175 afp_tree = proto_item_add_subtree(ti, ett_afp);
5177 if (!atp_asp_dsi_info->reply) {
5179 ti = proto_tree_add_uint(afp_tree, hf_afp_command, tvb,offset, 1, afp_command);
5180 if (afp_command != tvb_get_uint8(tvb, offset)) {
5181 /* we have the same conversation for different connections eg:
5182 * ip1:2048 --> ip2:548
5183 * ip1:2048 --> ip2:548 <RST>
5184 * ....
5185 * ip1:2048 --> ip2:548 <SYN> use the same port but it's a new session!
5187 col_set_str(pinfo->cinfo, COL_INFO,
5188 "[Error!IP port reused, you need to split the capture file]");
5189 expert_add_info(pinfo, ti, &ei_afp_ip_port_reused);
5190 return tvb_captured_length(tvb);
5194 * Put in a field for the frame number of the frame to which
5195 * this is a response if we know that frame number (i.e.,
5196 * it's not 0).
5198 if (request_val->frame_res != 0) {
5199 ti = proto_tree_add_uint(afp_tree, hf_afp_response_in,
5200 tvb, 0, 0, request_val->frame_res);
5201 proto_item_set_generated(ti);
5204 offset++;
5205 switch (afp_command) {
5206 case AFP_BYTELOCK:
5207 offset = dissect_query_afp_byte_lock(tvb, pinfo, afp_tree, offset);
5208 break;
5209 case AFP_BYTELOCK_EXT:
5210 offset = dissect_query_afp_byte_lock_ext(tvb, pinfo, afp_tree, offset);
5211 break;
5212 case AFP_OPENDT: /* same as close vol */
5213 case AFP_FLUSH:
5214 case AFP_CLOSEVOL:
5215 offset = dissect_query_afp_with_vol_id(tvb, pinfo, afp_tree, offset);
5216 break;
5217 case AFP_CLOSEDIR:
5218 /* offset = dissect_query_afp_close_dir(tvb, pinfo, afp_tree, offset); */
5219 break;
5220 case AFP_CLOSEDT:
5221 offset = dissect_query_afp_close_dt(tvb, pinfo, afp_tree, offset);
5222 break;
5223 case AFP_FLUSHFORK: /* same packet as closefork */
5224 case AFP_SYNCFORK:
5225 case AFP_CLOSEFORK:
5226 offset = dissect_query_afp_with_fork(tvb, pinfo, afp_tree, offset);
5227 break;
5228 case AFP_COPYFILE:
5229 offset = dissect_query_afp_copy_file(tvb, pinfo, afp_tree, offset);
5230 break;
5231 case AFP_CREATEFILE:
5232 offset = dissect_query_afp_create_file(tvb, pinfo, afp_tree, offset);
5233 break;
5234 case AFP_DISCTOLDSESS:
5235 offset = dissect_query_afp_disconnect_old_session(tvb, pinfo, afp_tree, offset);
5236 break;
5237 case AFP_ENUMERATE_EXT2:
5238 offset = dissect_query_afp_enumerate_ext2(tvb, pinfo, afp_tree, offset);
5239 break;
5240 case AFP_ENUMERATE_EXT:
5241 case AFP_ENUMERATE:
5242 offset = dissect_query_afp_enumerate(tvb, pinfo, afp_tree, offset);
5243 break;
5244 case AFP_GETFORKPARAM:
5245 offset = dissect_query_afp_get_fork_param(tvb, pinfo, afp_tree, offset);
5246 break;
5247 case AFP_GETSESSTOKEN:
5248 offset = dissect_query_afp_get_session_token(tvb, pinfo, afp_tree, offset);
5249 break;
5250 case AFP_GETUSERINFO:
5251 offset = dissect_query_afp_get_user_info(tvb, pinfo, afp_tree, offset);
5252 break;
5253 case AFP_GETSRVINFO:
5254 /* offset = dissect_query_afp_get_server_info(tvb, pinfo, afp_tree, offset); */
5255 break;
5256 case AFP_GETSRVPARAM:
5257 break; /* no parameters */
5258 case AFP_GETVOLPARAM:
5259 offset = dissect_query_afp_get_vol_param(tvb, pinfo, afp_tree, offset);
5260 break;
5261 case AFP_LOGIN_EXT:
5262 offset = dissect_query_afp_login_ext(tvb, pinfo, afp_tree, offset);
5263 break;
5264 case AFP_LOGIN:
5265 offset = dissect_query_afp_login(tvb, pinfo, afp_tree, offset);
5266 break;
5267 case AFP_LOGINCONT:
5268 case AFP_LOGOUT:
5269 break;
5270 case AFP_MAPID:
5271 offset = dissect_query_afp_map_id(tvb, pinfo, afp_tree, offset);
5272 break;
5273 case AFP_MAPNAME:
5274 offset = dissect_query_afp_map_name(tvb, pinfo, afp_tree, offset);
5275 break;
5276 case AFP_MOVE:
5277 offset = dissect_query_afp_move(tvb, pinfo, afp_tree, offset);
5278 break;
5279 case AFP_OPENVOL:
5280 offset = dissect_query_afp_open_vol(tvb, pinfo, afp_tree, offset);
5281 break;
5282 case AFP_OPENDIR:
5283 break;
5284 case AFP_OPENFORK:
5285 offset = dissect_query_afp_open_fork(tvb, pinfo, afp_tree, offset);
5286 break;
5287 case AFP_READ:
5288 offset = dissect_query_afp_read(tvb, pinfo, afp_tree, offset);
5289 break;
5290 case AFP_READ_EXT:
5291 offset = dissect_query_afp_read_ext(tvb, pinfo, afp_tree, offset);
5292 break;
5293 case AFP_RENAME:
5294 offset = dissect_query_afp_rename(tvb, pinfo, afp_tree, offset);
5295 break;
5296 case AFP_SETDIRPARAM:
5297 offset = dissect_query_afp_set_dir_param(tvb, pinfo, afp_tree, offset);
5298 break;
5299 case AFP_SETFILEPARAM:
5300 offset = dissect_query_afp_set_file_param(tvb, pinfo, afp_tree, offset);
5301 break;
5302 case AFP_SETFORKPARAM:
5303 offset = dissect_query_afp_set_fork_param(tvb, pinfo, afp_tree, offset);
5304 break;
5305 case AFP_SETVOLPARAM:
5306 offset = dissect_query_afp_set_vol_param(tvb, pinfo, afp_tree, offset);
5307 break;
5308 case AFP_WRITE:
5309 offset = dissect_query_afp_write(tvb, pinfo, afp_tree, offset);
5310 break;
5311 case AFP_WRITE_EXT:
5312 offset = dissect_query_afp_write_ext(tvb, pinfo, afp_tree, offset);
5313 break;
5314 case AFP_GETFLDRPARAM:
5315 offset = dissect_query_afp_get_fldr_param(tvb, pinfo, afp_tree, offset);
5316 break;
5317 case AFP_SETFLDRPARAM:
5318 offset = dissect_query_afp_set_fldr_param(tvb, pinfo, afp_tree, offset);
5319 break;
5320 case AFP_CHANGEPW:
5321 break;
5322 case AFP_GETSRVRMSG:
5323 offset = dissect_query_afp_get_server_message(tvb, pinfo, afp_tree, offset);
5324 break;
5325 case AFP_DELETE: /* same as create_id */
5326 case AFP_CREATEDIR:
5327 case AFP_CREATEID:
5328 offset = dissect_query_afp_create_id(tvb, pinfo, afp_tree, offset);
5329 break;
5330 case AFP_DELETEID:
5331 offset = dissect_query_afp_delete_id(tvb, pinfo, afp_tree, offset);
5332 break;
5333 case AFP_RESOLVEID:
5334 offset = dissect_query_afp_resolve_id(tvb, pinfo, afp_tree, offset);
5335 break;
5336 case AFP_EXCHANGEFILE:
5337 offset = dissect_query_afp_exchange_file(tvb, pinfo, afp_tree, offset);
5338 break;
5339 case AFP_CATSEARCH_EXT:
5340 offset = dissect_query_afp_cat_search_ext(tvb, pinfo, afp_tree, offset);
5341 break;
5342 case AFP_CATSEARCH:
5343 offset = dissect_query_afp_cat_search(tvb, pinfo, afp_tree, offset);
5344 break;
5345 case AFP_GETICON:
5346 offset = dissect_query_afp_get_icon(tvb, pinfo, afp_tree, offset);
5347 break;
5348 case AFP_GTICNINFO:
5349 offset = dissect_query_afp_get_icon_info(tvb, pinfo, afp_tree, offset);
5350 break;
5351 case AFP_ADDAPPL:
5352 offset = dissect_query_afp_add_appl(tvb, pinfo, afp_tree, offset);
5353 break;
5354 case AFP_RMVAPPL:
5355 offset = dissect_query_afp_rmv_appl(tvb, pinfo, afp_tree, offset);
5356 break;
5357 case AFP_GETAPPL:
5358 offset = dissect_query_afp_get_appl(tvb, pinfo, afp_tree, offset);
5359 break;
5360 case AFP_ADDCMT:
5361 offset = dissect_query_afp_add_cmt(tvb, pinfo, afp_tree, offset);
5362 break;
5363 case AFP_RMVCMT: /* same as get_cmt */
5364 case AFP_GETCMT:
5365 offset = dissect_query_afp_get_cmt(tvb, pinfo, afp_tree, offset);
5366 break;
5367 case AFP_ADDICON:
5368 offset = dissect_query_afp_add_icon(tvb, pinfo, afp_tree, offset);
5369 break;
5370 case AFP_GETEXTATTR:
5371 offset = dissect_query_afp_get_ext_attr(tvb, pinfo, afp_tree, offset);
5372 break;
5373 case AFP_SETEXTATTR:
5374 offset = dissect_query_afp_set_ext_attr(tvb, pinfo, afp_tree, offset);
5375 break;
5376 case AFP_LISTEXTATTR:
5377 offset = dissect_query_afp_list_ext_attrs(tvb, pinfo, afp_tree, offset);
5378 break;
5379 case AFP_REMOVEATTR:
5380 offset = dissect_query_afp_remove_ext_attr(tvb, pinfo, afp_tree, offset);
5381 break;
5382 case AFP_GETACL:
5383 offset = dissect_query_afp_get_acl(tvb, pinfo, afp_tree, offset);
5384 break;
5385 case AFP_SETACL:
5386 offset = dissect_query_afp_set_acl(tvb, pinfo, afp_tree, offset);
5387 break;
5388 case AFP_ACCESS:
5389 offset = dissect_query_afp_access(tvb, pinfo, afp_tree, offset);
5390 break;
5391 case AFP_SYNCDIR:
5392 offset = dissect_query_afp_with_did(tvb, pinfo, afp_tree, offset);
5393 break;
5394 case AFP_SPOTLIGHTRPC:
5395 offset = dissect_query_afp_spotlight(tvb, pinfo, afp_tree, offset, request_val);
5396 break;
5399 else {
5400 proto_tree_add_uint(afp_tree, hf_afp_command, tvb, 0, 0, afp_command);
5403 * Put in fields for the frame with the response to this
5404 * frame - if we know the frame number (i.e., it's not 0).
5406 if (request_val->frame_req != 0) {
5407 ti = proto_tree_add_uint(afp_tree, hf_afp_response_to,
5408 tvb, 0, 0, request_val->frame_req);
5409 proto_item_set_generated(ti);
5410 nstime_delta(&delta_ts, &pinfo->abs_ts, &request_val->req_time);
5411 ti = proto_tree_add_time(afp_tree, hf_afp_time, tvb,
5412 0, 0, &delta_ts);
5413 proto_item_set_generated(ti);
5417 * Set "frame_res" if it's not already known.
5419 if (request_val->frame_res == 0)
5420 request_val->frame_res = pinfo->num;
5423 * Tap the packet before the dissectors are called so we
5424 * still get the tap listener called even if there is an
5425 * exception.
5427 tap_queue_packet(afp_tap, pinfo, request_val);
5429 if (!len) {
5430 /* for some calls if the reply is an error there's no data
5432 return tvb_captured_length(tvb);
5435 switch (afp_command) {
5436 case AFP_BYTELOCK:
5437 offset = dissect_reply_afp_byte_lock(tvb, pinfo, afp_tree, offset);
5438 break;
5439 case AFP_BYTELOCK_EXT:
5440 offset = dissect_reply_afp_byte_lock_ext(tvb, pinfo, afp_tree, offset);
5441 break;
5442 case AFP_ENUMERATE_EXT2:
5443 case AFP_ENUMERATE_EXT:
5444 offset = dissect_reply_afp_enumerate_ext(tvb, pinfo, afp_tree, offset);
5445 break;
5446 case AFP_ENUMERATE:
5447 offset = dissect_reply_afp_enumerate(tvb, pinfo, afp_tree, offset);
5448 break;
5449 case AFP_OPENVOL:
5450 offset = dissect_reply_afp_open_vol(tvb, pinfo, afp_tree, offset);
5451 break;
5452 case AFP_OPENFORK:
5453 offset = dissect_reply_afp_open_fork(tvb, pinfo, afp_tree, offset);
5454 break;
5455 case AFP_RESOLVEID:
5456 case AFP_GETFORKPARAM:
5457 offset = dissect_reply_afp_get_fork_param(tvb, pinfo, afp_tree, offset);
5458 break;
5459 case AFP_GETUSERINFO:
5460 offset = dissect_reply_afp_get_user_info(tvb, pinfo, afp_tree, offset);
5461 break;
5462 case AFP_GETSRVPARAM:
5463 offset = dissect_reply_afp_get_server_param(tvb, pinfo, afp_tree, offset);
5464 break;
5465 case AFP_GETSRVRMSG:
5466 offset = dissect_reply_afp_get_server_message(tvb, pinfo, afp_tree, offset);
5467 break;
5468 case AFP_CREATEDIR:
5469 offset = dissect_reply_afp_create_dir(tvb, pinfo, afp_tree, offset);
5470 break;
5471 case AFP_MAPID:
5472 offset = dissect_reply_afp_map_id(tvb, pinfo, afp_tree, offset);
5473 break;
5474 case AFP_MAPNAME:
5475 offset = dissect_reply_afp_map_name(tvb, pinfo, afp_tree, offset);
5476 break;
5477 case AFP_MOVE: /* same as create_id */
5478 case AFP_CREATEID:
5479 offset = dissect_reply_afp_create_id(tvb, pinfo, afp_tree, offset);
5480 break;
5481 case AFP_GETSESSTOKEN:
5482 offset = dissect_reply_afp_get_session_token(tvb, pinfo, afp_tree, offset);
5483 break;
5484 case AFP_GETVOLPARAM:
5485 offset = dissect_reply_afp_get_vol_param(tvb, pinfo, afp_tree, offset);
5486 break;
5487 case AFP_GETFLDRPARAM:
5488 offset = dissect_reply_afp_get_fldr_param(tvb, pinfo, afp_tree, offset);
5489 break;
5490 case AFP_OPENDT:
5491 offset = dissect_reply_afp_open_dt(tvb, pinfo, afp_tree, offset);
5492 break;
5493 case AFP_CATSEARCH_EXT:
5494 offset = dissect_reply_afp_cat_search_ext(tvb, pinfo, afp_tree, offset);
5495 break;
5496 case AFP_CATSEARCH:
5497 offset = dissect_reply_afp_cat_search(tvb, pinfo, afp_tree, offset);
5498 break;
5499 case AFP_GTICNINFO:
5500 offset = dissect_reply_afp_get_icon_info(tvb, pinfo, afp_tree, offset);
5501 break;
5502 case AFP_GETAPPL:
5503 offset = dissect_reply_afp_get_appl(tvb, pinfo, afp_tree, offset);
5504 break;
5505 case AFP_GETCMT:
5506 offset = dissect_reply_afp_get_cmt(tvb, pinfo, afp_tree, offset);
5507 break;
5508 case AFP_WRITE:
5509 offset = dissect_reply_afp_write(tvb, pinfo, afp_tree, offset);
5510 break;
5511 case AFP_WRITE_EXT:
5512 offset = dissect_reply_afp_write_ext(tvb, pinfo, afp_tree, offset);
5513 break;
5514 case AFP_GETEXTATTR:
5515 offset = dissect_reply_afp_get_ext_attr(tvb, pinfo, afp_tree, offset);
5516 break;
5517 case AFP_LISTEXTATTR:
5518 offset = dissect_reply_afp_list_ext_attrs(tvb, pinfo, afp_tree, offset);
5519 break;
5520 case AFP_GETACL:
5521 offset = dissect_reply_afp_get_acl(tvb, pinfo, afp_tree, offset);
5522 break;
5523 case AFP_SPOTLIGHTRPC:
5524 offset = dissect_reply_afp_spotlight(tvb, pinfo, afp_tree, offset, request_val);
5525 break;
5528 if (offset < len) {
5529 call_data_dissector(tvb_new_subset_remaining(tvb, offset),
5530 pinfo, afp_tree);
5533 return tvb_captured_length(tvb);
5536 void
5537 proto_register_afp(void)
5540 static hf_register_info hf[] = {
5541 { &hf_afp_command,
5542 { "Command", "afp.command",
5543 FT_UINT8, BASE_DEC|BASE_EXT_STRING, &CommandCode_vals_ext, 0x0,
5544 "AFP function", HFILL }},
5546 { &hf_afp_pad,
5547 { "Pad", "afp.pad",
5548 FT_NONE, BASE_NONE, NULL, 0,
5549 "Pad Byte", HFILL }},
5551 { &hf_afp_Version,
5552 { "AFP Version", "afp.Version",
5553 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
5554 "Client AFP version", HFILL }},
5556 { &hf_afp_UAM,
5557 { "UAM", "afp.UAM",
5558 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
5559 "User Authentication Method", HFILL }},
5561 { &hf_afp_user,
5562 { "User", "afp.user",
5563 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
5564 NULL, HFILL }},
5566 { &hf_afp_user_type,
5567 { "Type", "afp.user_type",
5568 FT_UINT8, BASE_HEX, VALS(path_type_vals), 0,
5569 "Type of user name", HFILL }},
5570 { &hf_afp_user_len,
5571 { "Len", "afp.user_len",
5572 FT_UINT16, BASE_DEC, NULL, 0x0,
5573 "User name length (unicode)", HFILL }},
5574 { &hf_afp_user_name,
5575 { "User", "afp.user_name",
5576 FT_STRING, BASE_NONE, NULL, 0x0,
5577 "User name (unicode)", HFILL }},
5579 { &hf_afp_passwd,
5580 { "Password", "afp.passwd",
5581 FT_STRINGZPAD, BASE_NONE, NULL, 0x0,
5582 NULL, HFILL }},
5584 { &hf_afp_random,
5585 { "Random number", "afp.random",
5586 FT_BYTES, BASE_NONE, NULL, 0x0,
5587 "UAM random number", HFILL }},
5589 { &hf_afp_response_to,
5590 { "Response to", "afp.response_to",
5591 FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
5592 "This packet is a response to the packet in this frame", HFILL }},
5594 { &hf_afp_time,
5595 { "Time from request", "afp.time",
5596 FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
5597 "Time between Request and Response for AFP cmds", HFILL }},
5599 { &hf_afp_response_in,
5600 { "Response in", "afp.response_in",
5601 FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
5602 "The response to this packet is in this packet", HFILL }},
5604 { &hf_afp_login_flags,
5605 { "Flags", "afp.login_flags",
5606 FT_UINT16, BASE_HEX, NULL, 0 /* 0x0FFF*/,
5607 "Login flags", HFILL }},
5609 { &hf_afp_vol_bitmap,
5610 { "Bitmap", "afp.vol_bitmap",
5611 FT_UINT16, BASE_HEX, NULL, 0 /* 0x0FFF*/,
5612 "Volume bitmap", HFILL }},
5614 { &hf_afp_vol_bitmap_Attributes,
5615 { "Attributes", "afp.vol_bitmap.attributes",
5616 FT_BOOLEAN, 16, NULL, kFPVolAttributeBit,
5617 "Volume attributes", HFILL }},
5619 { &hf_afp_vol_attribute,
5620 { "Attributes", "afp.vol_attributes",
5621 FT_UINT16, BASE_HEX, NULL, 0,
5622 "Volume attributes", HFILL }},
5624 { &hf_afp_vol_attribute_ReadOnly,
5625 { "Read only", "afp.vol_attribute.read_only",
5626 FT_BOOLEAN, 16, NULL, kReadOnly,
5627 "Read only volume", HFILL }},
5629 { &hf_afp_vol_attribute_HasVolumePassword,
5630 { "Volume password", "afp.vol_attribute.passwd",
5631 FT_BOOLEAN, 16, NULL, kHasVolumePassword,
5632 "Has a volume password", HFILL }},
5634 { &hf_afp_vol_attribute_SupportsFileIDs,
5635 { "File IDs", "afp.vol_attribute.fileIDs",
5636 FT_BOOLEAN, 16, NULL, kSupportsFileIDs,
5637 "Supports file IDs", HFILL }},
5639 { &hf_afp_vol_attribute_SupportsCatSearch,
5640 { "Catalog search", "afp.vol_attribute.cat_search",
5641 FT_BOOLEAN, 16, NULL, kSupportsCatSearch,
5642 "Supports catalog search operations", HFILL }},
5644 { &hf_afp_vol_attribute_SupportsBlankAccessPrivs,
5645 { "Blank access privileges", "afp.vol_attribute.blank_access_privs",
5646 FT_BOOLEAN, 16, NULL, kSupportsBlankAccessPrivs,
5647 "Supports blank access privileges", HFILL }},
5649 { &hf_afp_vol_attribute_SupportsUnixPrivs,
5650 { "UNIX access privileges", "afp.vol_attribute.unix_privs",
5651 FT_BOOLEAN, 16, NULL, kSupportsUnixPrivs,
5652 "Supports UNIX access privileges", HFILL }},
5654 { &hf_afp_vol_attribute_SupportsUTF8Names,
5655 { "UTF-8 names", "afp.vol_attribute.utf8_names",
5656 FT_BOOLEAN, 16, NULL, kSupportsUTF8Names,
5657 "Supports UTF-8 names", HFILL }},
5659 { &hf_afp_vol_attribute_NoNetworkUserID,
5660 { "No Network User ID", "afp.vol_attribute.network_user_id",
5661 FT_BOOLEAN, 16, NULL, kNoNetworkUserIDs,
5662 NULL, HFILL }},
5664 { &hf_afp_vol_attribute_DefaultPrivsFromParent,
5665 { "Inherit parent privileges", "afp.vol_attribute.inherit_parent_privs",
5666 FT_BOOLEAN, 16, NULL, kDefaultPrivsFromParent,
5667 NULL, HFILL }},
5669 { &hf_afp_vol_attribute_NoExchangeFiles,
5670 { "No exchange files", "afp.vol_attribute.no_exchange_files",
5671 FT_BOOLEAN, 16, NULL, kNoExchangeFiles,
5672 "Exchange files not supported", HFILL }},
5674 { &hf_afp_vol_attribute_SupportsExtAttrs,
5675 { "Extended Attributes", "afp.vol_attribute.extended_attributes",
5676 FT_BOOLEAN, 16, NULL, kSupportsExtAttrs,
5677 "Supports Extended Attributes", HFILL }},
5679 { &hf_afp_vol_attribute_SupportsACLs,
5680 { "ACLs", "afp.vol_attribute.acls",
5681 FT_BOOLEAN, 16, NULL, kSupportsACLs,
5682 "Supports access control lists", HFILL }},
5684 { &hf_afp_vol_attribute_CaseSensitive,
5685 { "Case sensitive", "afp.vol_attribute.case_sensitive",
5686 FT_BOOLEAN, 16, NULL, kCaseSensitive,
5687 "Supports case-sensitive filenames", HFILL }},
5689 { &hf_afp_vol_attribute_SupportsTMLockSteal,
5690 { "TM lock steal", "afp.vol_attribute.TM_lock_steal",
5691 FT_BOOLEAN, 16, NULL, kSupportsTMLockSteal,
5692 "Supports Time Machine lock stealing", HFILL }},
5694 { &hf_afp_vol_bitmap_Signature,
5695 { "Signature", "afp.vol_bitmap.signature",
5696 FT_BOOLEAN, 16, NULL, kFPVolSignatureBit,
5697 "Volume signature", HFILL }},
5699 { &hf_afp_vol_bitmap_CreateDate,
5700 { "Creation date", "afp.vol_bitmap.create_date",
5701 FT_BOOLEAN, 16, NULL, kFPVolCreateDateBit,
5702 "Volume creation date", HFILL }},
5704 { &hf_afp_vol_bitmap_ModDate,
5705 { "Modification date", "afp.vol_bitmap.mod_date",
5706 FT_BOOLEAN, 16, NULL, kFPVolModDateBit,
5707 "Volume modification date", HFILL }},
5709 { &hf_afp_vol_bitmap_BackupDate,
5710 { "Backup date", "afp.vol_bitmap.backup_date",
5711 FT_BOOLEAN, 16, NULL, kFPVolBackupDateBit,
5712 "Volume backup date", HFILL }},
5714 { &hf_afp_vol_bitmap_ID,
5715 { "ID", "afp.vol_bitmap.id",
5716 FT_BOOLEAN, 16, NULL, kFPVolIDBit,
5717 "Volume ID", HFILL }},
5719 { &hf_afp_vol_bitmap_BytesFree,
5720 { "Bytes free", "afp.vol_bitmap.bytes_free",
5721 FT_BOOLEAN, 16, NULL, kFPVolBytesFreeBit,
5722 "Volume free bytes", HFILL }},
5724 { &hf_afp_vol_bitmap_BytesTotal,
5725 { "Bytes total", "afp.vol_bitmap.bytes_total",
5726 FT_BOOLEAN, 16, NULL, kFPVolBytesTotalBit,
5727 "Volume total bytes", HFILL }},
5729 { &hf_afp_vol_bitmap_Name,
5730 { "Name", "afp.vol_bitmap.name",
5731 FT_BOOLEAN, 16, NULL, kFPVolNameBit,
5732 "Volume name", HFILL }},
5734 { &hf_afp_vol_bitmap_ExtBytesFree,
5735 { "Extended bytes free", "afp.vol_bitmap.ex_bytes_free",
5736 FT_BOOLEAN, 16, NULL, kFPVolExtBytesFreeBit,
5737 "Volume extended (>2GB) free bytes", HFILL }},
5739 { &hf_afp_vol_bitmap_ExtBytesTotal,
5740 { "Extended bytes total", "afp.vol_bitmap.ex_bytes_total",
5741 FT_BOOLEAN, 16, NULL, kFPVolExtBytesTotalBit,
5742 "Volume extended (>2GB) total bytes", HFILL }},
5744 { &hf_afp_vol_bitmap_BlockSize,
5745 { "Block size", "afp.vol_bitmap.block_size",
5746 FT_BOOLEAN, 16, NULL, kFPVolBlockSizeBit,
5747 "Volume block size", HFILL }},
5749 { &hf_afp_dir_bitmap_Attributes,
5750 { "Attributes", "afp.dir_bitmap.attributes",
5751 FT_BOOLEAN, 16, NULL, kFPAttributeBit,
5752 "Return attributes if directory", HFILL }},
5754 { &hf_afp_dir_bitmap_ParentDirID,
5755 { "DID", "afp.dir_bitmap.did",
5756 FT_BOOLEAN, 16, NULL, kFPParentDirIDBit,
5757 "Return parent directory ID if directory", HFILL }},
5759 { &hf_afp_dir_bitmap_CreateDate,
5760 { "Creation date", "afp.dir_bitmap.create_date",
5761 FT_BOOLEAN, 16, NULL, kFPCreateDateBit,
5762 "Return creation date if directory", HFILL }},
5764 { &hf_afp_dir_bitmap_ModDate,
5765 { "Modification date", "afp.dir_bitmap.mod_date",
5766 FT_BOOLEAN, 16, NULL, kFPModDateBit,
5767 "Return modification date if directory", HFILL }},
5769 { &hf_afp_dir_bitmap_BackupDate,
5770 { "Backup date", "afp.dir_bitmap.backup_date",
5771 FT_BOOLEAN, 16, NULL, kFPBackupDateBit,
5772 "Return backup date if directory", HFILL }},
5774 { &hf_afp_dir_bitmap_FinderInfo,
5775 { "Finder info", "afp.dir_bitmap.finder_info",
5776 FT_BOOLEAN, 16, NULL, kFPFinderInfoBit,
5777 "Return finder info if directory", HFILL }},
5779 { &hf_afp_dir_bitmap_LongName,
5780 { "Long name", "afp.dir_bitmap.long_name",
5781 FT_BOOLEAN, 16, NULL, kFPLongNameBit,
5782 "Return long name if directory", HFILL }},
5784 { &hf_afp_dir_bitmap_ShortName,
5785 { "Short name", "afp.dir_bitmap.short_name",
5786 FT_BOOLEAN, 16, NULL, kFPShortNameBit,
5787 "Return short name if directory", HFILL }},
5789 { &hf_afp_dir_bitmap_NodeID,
5790 { "File ID", "afp.dir_bitmap.fid",
5791 FT_BOOLEAN, 16, NULL, kFPNodeIDBit,
5792 "Return file ID if directory", HFILL }},
5794 { &hf_afp_dir_bitmap_OffspringCount,
5795 { "Offspring count", "afp.dir_bitmap.offspring_count",
5796 FT_BOOLEAN, 16, NULL, kFPOffspringCountBit,
5797 "Return offspring count if directory", HFILL }},
5799 { &hf_afp_dir_bitmap_OwnerID,
5800 { "Owner id", "afp.dir_bitmap.owner_id",
5801 FT_BOOLEAN, 16, NULL, kFPOwnerIDBit,
5802 "Return owner id if directory", HFILL }},
5804 { &hf_afp_dir_bitmap_GroupID,
5805 { "Group id", "afp.dir_bitmap.group_id",
5806 FT_BOOLEAN, 16, NULL, kFPGroupIDBit,
5807 "Return group id if directory", HFILL }},
5809 { &hf_afp_dir_bitmap_AccessRights,
5810 { "Access rights", "afp.dir_bitmap.access_rights",
5811 FT_BOOLEAN, 16, NULL, kFPAccessRightsBit,
5812 "Return access rights if directory", HFILL }},
5814 { &hf_afp_dir_bitmap_UTF8Name,
5815 { "UTF-8 name", "afp.dir_bitmap.UTF8_name",
5816 FT_BOOLEAN, 16, NULL, kFPUTF8NameBit,
5817 "Return UTF-8 name if directory", HFILL }},
5819 { &hf_afp_dir_bitmap_UnixPrivs,
5820 { "UNIX privileges", "afp.dir_bitmap.unix_privs",
5821 FT_BOOLEAN, 16, NULL, kFPUnixPrivsBit,
5822 "Return UNIX privileges if directory", HFILL }},
5824 { &hf_afp_dir_attribute,
5825 { "Directory Attributes", "afp.dir_attribute",
5826 FT_UINT16, BASE_HEX, NULL, 0x0,
5827 NULL, HFILL }},
5829 { &hf_afp_dir_attribute_Invisible,
5830 { "Invisible", "afp.dir_attribute.invisible",
5831 FT_BOOLEAN, 16, NULL, kFPInvisibleBit,
5832 "Directory is not visible", HFILL }},
5834 { &hf_afp_dir_attribute_IsExpFolder,
5835 { "Share point", "afp.dir_attribute.share",
5836 FT_BOOLEAN, 16, NULL, kFPMultiUserBit,
5837 "Directory is a share point", HFILL }},
5839 { &hf_afp_dir_attribute_System,
5840 { "System", "afp.dir_attribute.system",
5841 FT_BOOLEAN, 16, NULL, kFPSystemBit,
5842 "Directory is a system directory", HFILL }},
5844 { &hf_afp_dir_attribute_Mounted,
5845 { "Mounted", "afp.dir_attribute.mounted",
5846 FT_BOOLEAN, 16, NULL, kFPDAlreadyOpenBit,
5847 "Directory is mounted", HFILL }},
5849 { &hf_afp_dir_attribute_InExpFolder,
5850 { "Shared area", "afp.dir_attribute.in_exported_folder",
5851 FT_BOOLEAN, 16, NULL, kFPRAlreadyOpenBit,
5852 "Directory is in a shared area", HFILL }},
5854 { &hf_afp_dir_attribute_BackUpNeeded,
5855 { "Backup needed", "afp.dir_attribute.backup_needed",
5856 FT_BOOLEAN, 16, NULL, kFPBackUpNeededBit,
5857 "Directory needs to be backed up", HFILL }},
5859 { &hf_afp_dir_attribute_RenameInhibit,
5860 { "Rename inhibit", "afp.dir_attribute.rename_inhibit",
5861 FT_BOOLEAN, 16, NULL, kFPRenameInhibitBit,
5862 NULL, HFILL }},
5864 { &hf_afp_dir_attribute_DeleteInhibit,
5865 { "Delete inhibit", "afp.dir_attribute.delete_inhibit",
5866 FT_BOOLEAN, 16, NULL, kFPDeleteInhibitBit,
5867 NULL, HFILL }},
5869 { &hf_afp_file_bitmap,
5870 { "File bitmap", "afp.file_bitmap",
5871 FT_UINT16, BASE_HEX, NULL, 0x0,
5872 NULL, HFILL }},
5874 { &hf_afp_file_bitmap_Attributes,
5875 { "Attributes", "afp.file_bitmap.attributes",
5876 FT_BOOLEAN, 16, NULL, kFPAttributeBit,
5877 "Return attributes if file", HFILL }},
5879 { &hf_afp_file_bitmap_ParentDirID,
5880 { "DID", "afp.file_bitmap.did",
5881 FT_BOOLEAN, 16, NULL, kFPParentDirIDBit,
5882 "Return parent directory ID if file", HFILL }},
5884 { &hf_afp_file_bitmap_CreateDate,
5885 { "Creation date", "afp.file_bitmap.create_date",
5886 FT_BOOLEAN, 16, NULL, kFPCreateDateBit,
5887 "Return creation date if file", HFILL }},
5889 { &hf_afp_file_bitmap_ModDate,
5890 { "Modification date", "afp.file_bitmap.mod_date",
5891 FT_BOOLEAN, 16, NULL, kFPModDateBit,
5892 "Return modification date if file", HFILL }},
5894 { &hf_afp_file_bitmap_BackupDate,
5895 { "Backup date", "afp.file_bitmap.backup_date",
5896 FT_BOOLEAN, 16, NULL, kFPBackupDateBit,
5897 "Return backup date if file", HFILL }},
5899 { &hf_afp_file_bitmap_FinderInfo,
5900 { "Finder info", "afp.file_bitmap.finder_info",
5901 FT_BOOLEAN, 16, NULL, kFPFinderInfoBit,
5902 "Return finder info if file", HFILL }},
5904 { &hf_afp_file_bitmap_LongName,
5905 { "Long name", "afp.file_bitmap.long_name",
5906 FT_BOOLEAN, 16, NULL, kFPLongNameBit,
5907 "Return long name if file", HFILL }},
5909 { &hf_afp_file_bitmap_ShortName,
5910 { "Short name", "afp.file_bitmap.short_name",
5911 FT_BOOLEAN, 16, NULL, kFPShortNameBit,
5912 "Return short name if file", HFILL }},
5914 { &hf_afp_file_bitmap_NodeID,
5915 { "File ID", "afp.file_bitmap.fid",
5916 FT_BOOLEAN, 16, NULL, kFPNodeIDBit,
5917 "Return file ID if file", HFILL }},
5919 { &hf_afp_file_bitmap_DataForkLen,
5920 { "Data fork size", "afp.file_bitmap.data_fork_len",
5921 FT_BOOLEAN, 16, NULL, kFPDataForkLenBit,
5922 "Return data fork size if file", HFILL }},
5924 { &hf_afp_file_bitmap_RsrcForkLen,
5925 { "Resource fork size", "afp.file_bitmap.resource_fork_len",
5926 FT_BOOLEAN, 16, NULL, kFPRsrcForkLenBit,
5927 "Return resource fork size if file", HFILL }},
5929 { &hf_afp_file_bitmap_ExtDataForkLen,
5930 { "Extended data fork size", "afp.file_bitmap.ex_data_fork_len",
5931 FT_BOOLEAN, 16, NULL, kFPExtDataForkLenBit,
5932 "Return extended (>2GB) data fork size if file", HFILL }},
5934 { &hf_afp_file_bitmap_LaunchLimit,
5935 { "Launch limit", "afp.file_bitmap.launch_limit",
5936 FT_BOOLEAN, 16, NULL, kFPLaunchLimitBit,
5937 "Return launch limit if file", HFILL }},
5939 { &hf_afp_file_bitmap_UTF8Name,
5940 { "UTF-8 name", "afp.file_bitmap.UTF8_name",
5941 FT_BOOLEAN, 16, NULL, kFPUTF8NameBit,
5942 "Return UTF-8 name if file", HFILL }},
5944 { &hf_afp_file_bitmap_ExtRsrcForkLen,
5945 { "Extended resource fork size", "afp.file_bitmap.ex_resource_fork_len",
5946 FT_BOOLEAN, 16, NULL, kFPExtRsrcForkLenBit,
5947 "Return extended (>2GB) resource fork size if file", HFILL }},
5949 { &hf_afp_file_bitmap_UnixPrivs,
5950 { "UNIX privileges", "afp.file_bitmap.unix_privs",
5951 FT_BOOLEAN, 16, NULL, kFPUnixPrivsBit,
5952 "Return UNIX privileges if file", HFILL }},
5954 /* ---------- */
5955 { &hf_afp_file_attribute,
5956 { "File Attributes", "afp.file_attribute",
5957 FT_UINT16, BASE_HEX, NULL, 0x0,
5958 NULL, HFILL }},
5960 { &hf_afp_file_attribute_Invisible,
5961 { "Invisible", "afp.file_attribute.invisible",
5962 FT_BOOLEAN, 16, NULL, kFPInvisibleBit,
5963 "File is not visible", HFILL }},
5965 { &hf_afp_file_attribute_MultiUser,
5966 { "Multi user", "afp.file_attribute.multi_user",
5967 FT_BOOLEAN, 16, NULL, kFPMultiUserBit,
5968 NULL, HFILL }},
5970 { &hf_afp_file_attribute_System,
5971 { "System", "afp.file_attribute.system",
5972 FT_BOOLEAN, 16, NULL, kFPSystemBit,
5973 "File is a system file", HFILL }},
5975 { &hf_afp_file_attribute_DAlreadyOpen,
5976 { "Data fork open", "afp.file_attribute.df_open",
5977 FT_BOOLEAN, 16, NULL, kFPDAlreadyOpenBit,
5978 "Data fork already open", HFILL }},
5980 { &hf_afp_file_attribute_RAlreadyOpen,
5981 { "Resource fork open", "afp.file_attribute.rf_open",
5982 FT_BOOLEAN, 16, NULL, kFPRAlreadyOpenBit,
5983 "Resource fork already open", HFILL }},
5985 { &hf_afp_file_attribute_WriteInhibit,
5986 { "Write inhibit", "afp.file_attribute.write_inhibit",
5987 FT_BOOLEAN, 16, NULL, kFPWriteInhibitBit,
5988 NULL, HFILL }},
5990 { &hf_afp_file_attribute_BackUpNeeded,
5991 { "Backup needed", "afp.file_attribute.backup_needed",
5992 FT_BOOLEAN, 16, NULL, kFPBackUpNeededBit,
5993 "File needs to be backed up", HFILL }},
5995 { &hf_afp_file_attribute_RenameInhibit,
5996 { "Rename inhibit", "afp.file_attribute.rename_inhibit",
5997 FT_BOOLEAN, 16, NULL, kFPRenameInhibitBit,
5998 NULL, HFILL }},
6000 { &hf_afp_file_attribute_DeleteInhibit,
6001 { "Delete inhibit", "afp.file_attribute.delete_inhibit",
6002 FT_BOOLEAN, 16, NULL, kFPDeleteInhibitBit,
6003 NULL, HFILL }},
6005 { &hf_afp_file_attribute_CopyProtect,
6006 { "Copy protect", "afp.file_attribute.copy_protect",
6007 FT_BOOLEAN, 16, NULL, kFPCopyProtectBit,
6008 NULL, HFILL }},
6010 { &hf_afp_file_attribute_SetClear,
6011 { "Set", "afp.file_attribute.set_clear",
6012 FT_BOOLEAN, 16, NULL, kFPSetClearBit,
6013 "Clear/set attribute", HFILL }},
6014 /* ---------- */
6016 { &hf_afp_vol_name,
6017 { "Volume", "afp.vol_name",
6018 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
6019 "Volume name", HFILL }},
6021 { &hf_afp_vol_flag,
6022 { "Flags", "afp.vol_flag",
6023 FT_UINT8, BASE_HEX, NULL, 0x0,
6024 NULL, HFILL }},
6026 { &hf_afp_vol_flag_passwd,
6027 { "Password", "afp.vol_flag_passwd",
6028 FT_BOOLEAN, 8, NULL, 128,
6029 "Volume is password-protected", HFILL }},
6031 { &hf_afp_vol_flag_has_config,
6032 { "Has config", "afp.vol_flag_has_config",
6033 FT_BOOLEAN, 8, NULL, 1,
6034 "Volume has Apple II config info", HFILL }},
6036 { &hf_afp_vol_id,
6037 { "Volume id", "afp.vol_id",
6038 FT_UINT32, BASE_DEC, NULL, 0x0,
6039 NULL, HFILL }},
6041 { &hf_afp_vol_signature,
6042 { "Signature", "afp.vol_signature",
6043 FT_UINT16, BASE_DEC, VALS(vol_signature_vals), 0x0,
6044 "Volume signature", HFILL }},
6046 { &hf_afp_vol_name_offset,
6047 { "Volume name offset","afp.vol_name_offset",
6048 FT_UINT16, BASE_DEC, NULL, 0x0,
6049 "Volume name offset in packet", HFILL }},
6051 { &hf_afp_vol_creation_date,
6052 { "Creation date", "afp.vol_creation_date",
6053 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
6054 "Volume creation date", HFILL }},
6056 { &hf_afp_vol_modification_date,
6057 { "Modification date", "afp.vol_modification_date",
6058 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
6059 "Volume modification date", HFILL }},
6061 { &hf_afp_vol_backup_date,
6062 { "Backup date", "afp.vol_backup_date",
6063 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
6064 "Volume backup date", HFILL }},
6066 { &hf_afp_vol_bytes_free,
6067 { "Bytes free", "afp.vol_bytes_free",
6068 FT_UINT32, BASE_DEC, NULL, 0x0,
6069 "Free space", HFILL }},
6071 { &hf_afp_vol_bytes_total,
6072 { "Bytes total", "afp.vol_bytes_total",
6073 FT_UINT32, BASE_DEC, NULL, 0x0,
6074 "Volume size", HFILL }},
6076 { &hf_afp_vol_ex_bytes_free,
6077 { "Extended bytes free", "afp.vol_ex_bytes_free",
6078 FT_UINT64, BASE_DEC, NULL, 0x0,
6079 "Extended (>2GB) free space", HFILL }},
6081 { &hf_afp_vol_ex_bytes_total,
6082 { "Extended bytes total", "afp.vol_ex_bytes_total",
6083 FT_UINT64, BASE_DEC, NULL, 0x0,
6084 "Extended (>2GB) volume size", HFILL }},
6086 { &hf_afp_vol_block_size,
6087 { "Block size", "afp.vol_block_size",
6088 FT_UINT32, BASE_DEC, NULL, 0x0,
6089 "Volume block size", HFILL }},
6091 { &hf_afp_did,
6092 { "DID", "afp.did",
6093 FT_UINT32, BASE_DEC, NULL, 0x0,
6094 "Parent directory ID", HFILL }},
6096 { &hf_afp_dir_bitmap,
6097 { "Directory bitmap", "afp.dir_bitmap",
6098 FT_UINT16, BASE_HEX, NULL, 0x0,
6099 NULL, HFILL }},
6101 { &hf_afp_dir_offspring,
6102 { "Offspring", "afp.dir_offspring",
6103 FT_UINT16, BASE_DEC, NULL, 0x0,
6104 "Directory offspring", HFILL }},
6106 { &hf_afp_dir_OwnerID,
6107 { "Owner ID", "afp.dir_owner_id",
6108 FT_INT32, BASE_DEC, NULL, 0x0,
6109 "Directory owner ID", HFILL }},
6111 { &hf_afp_dir_GroupID,
6112 { "Group ID", "afp.dir_group_id",
6113 FT_INT32, BASE_DEC, NULL, 0x0,
6114 "Directory group ID", HFILL }},
6116 { &hf_afp_creation_date,
6117 { "Creation date", "afp.creation_date",
6118 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
6119 NULL, HFILL }},
6121 { &hf_afp_modification_date,
6122 { "Modification date", "afp.modification_date",
6123 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
6124 NULL, HFILL }},
6126 { &hf_afp_backup_date,
6127 { "Backup date", "afp.backup_date",
6128 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
6129 NULL, HFILL }},
6131 { &hf_afp_finder_info,
6132 { "Finder info", "afp.finder_info",
6133 FT_BYTES, BASE_NONE, NULL, 0x0,
6134 NULL, HFILL }},
6136 { &hf_afp_long_name_offset,
6137 { "Long name offset", "afp.long_name_offset",
6138 FT_UINT16, BASE_DEC, NULL, 0x0,
6139 "Long name offset in packet", HFILL }},
6141 { &hf_afp_short_name_offset,
6142 { "Short name offset", "afp.short_name_offset",
6143 FT_UINT16, BASE_DEC, NULL, 0x0,
6144 "Short name offset in packet", HFILL }},
6146 { &hf_afp_unicode_name_offset,
6147 { "Unicode name offset", "afp.unicode_name_offset",
6148 FT_UINT16, BASE_DEC, NULL, 0x0,
6149 "Unicode name offset in packet", HFILL }},
6151 { &hf_afp_unix_privs_uid,
6152 { "UID", "afp.unix_privs.uid",
6153 FT_UINT32, BASE_DEC, NULL, 0x0,
6154 "User ID", HFILL }},
6156 { &hf_afp_unix_privs_gid,
6157 { "GID", "afp.unix_privs.gid",
6158 FT_UINT32, BASE_DEC, NULL, 0x0,
6159 "Group ID", HFILL }},
6161 { &hf_afp_unix_privs_permissions,
6162 { "Permissions", "afp.unix_privs.permissions",
6163 FT_UINT32, BASE_OCT, NULL, 0x0,
6164 NULL, HFILL }},
6166 { &hf_afp_unix_privs_ua_permissions,
6167 { "User's access rights", "afp.unix_privs.ua_permissions",
6168 FT_UINT32, BASE_HEX, NULL, 0x0,
6169 NULL, HFILL }},
6171 { &hf_afp_file_id,
6172 { "File ID", "afp.file_id",
6173 FT_UINT32, BASE_DEC, NULL, 0x0,
6174 "File/directory ID", HFILL }},
6176 { &hf_afp_file_DataForkLen,
6177 { "Data fork size", "afp.data_fork_len",
6178 FT_UINT32, BASE_DEC, NULL, 0x0,
6179 NULL, HFILL }},
6181 { &hf_afp_file_RsrcForkLen,
6182 { "Resource fork size", "afp.resource_fork_len",
6183 FT_UINT32, BASE_DEC, NULL, 0x0,
6184 NULL, HFILL }},
6186 { &hf_afp_file_ExtDataForkLen,
6187 { "Extended data fork size", "afp.ext_data_fork_len",
6188 FT_UINT64, BASE_DEC, NULL, 0x0,
6189 "Extended (>2GB) data fork length", HFILL }},
6191 { &hf_afp_file_ExtRsrcForkLen,
6192 { "Extended resource fork size", "afp.ext_resource_fork_len",
6193 FT_UINT64, BASE_DEC, NULL, 0x0,
6194 "Extended (>2GB) resource fork length", HFILL }},
6196 { &hf_afp_req_count,
6197 { "Req count", "afp.req_count",
6198 FT_UINT16, BASE_DEC, NULL, 0x0,
6199 "Maximum number of structures returned", HFILL }},
6201 { &hf_afp_start_index,
6202 { "Start index", "afp.start_index",
6203 FT_UINT16, BASE_DEC, NULL, 0x0,
6204 "First structure returned", HFILL }},
6206 { &hf_afp_max_reply_size,
6207 { "Reply size", "afp.reply_size",
6208 FT_UINT16, BASE_DEC, NULL, 0x0,
6209 NULL, HFILL }},
6211 { &hf_afp_start_index32,
6212 { "Start index", "afp.start_index32",
6213 FT_UINT32, BASE_DEC, NULL, 0x0,
6214 "First structure returned", HFILL }},
6216 { &hf_afp_max_reply_size32,
6217 { "Reply size", "afp.reply_size32",
6218 FT_UINT32, BASE_DEC, NULL, 0x0,
6219 NULL, HFILL }},
6221 { &hf_afp_file_flag,
6222 { "Dir", "afp.file_flag",
6223 FT_BOOLEAN, 8, NULL, 0x80,
6224 "Is a dir", HFILL }},
6226 { &hf_afp_create_flag,
6227 { "Hard create", "afp.create_flag",
6228 FT_BOOLEAN, 8, NULL, 0x80,
6229 "Soft/hard create file", HFILL }},
6231 { &hf_afp_request_bitmap,
6232 { "Request Bitmap", "afp.request_bitmap",
6233 FT_UINT32, BASE_HEX, NULL, 0x0,
6234 NULL, HFILL }},
6236 { &hf_afp_request_bitmap_Attributes,
6237 { "Attributes", "afp.request_bitmap.attributes",
6238 FT_BOOLEAN, 32, NULL, kFPAttributeBit,
6239 "Search attributes", HFILL }},
6241 { &hf_afp_request_bitmap_ParentDirID,
6242 { "DID", "afp.request_bitmap.did",
6243 FT_BOOLEAN, 32, NULL, kFPParentDirIDBit,
6244 "Search parent directory ID", HFILL }},
6246 { &hf_afp_request_bitmap_CreateDate,
6247 { "Creation date", "afp.request_bitmap.create_date",
6248 FT_BOOLEAN, 32, NULL, kFPCreateDateBit,
6249 "Search creation date", HFILL }},
6251 { &hf_afp_request_bitmap_ModDate,
6252 { "Modification date", "afp.request_bitmap.mod_date",
6253 FT_BOOLEAN, 32, NULL, kFPModDateBit,
6254 "Search modification date", HFILL }},
6256 { &hf_afp_request_bitmap_BackupDate,
6257 { "Backup date", "afp.request_bitmap.backup_date",
6258 FT_BOOLEAN, 32, NULL, kFPBackupDateBit,
6259 "Search backup date", HFILL }},
6261 { &hf_afp_request_bitmap_FinderInfo,
6262 { "Finder info", "afp.request_bitmap.finder_info",
6263 FT_BOOLEAN, 32, NULL, kFPFinderInfoBit,
6264 "Search finder info", HFILL }},
6266 { &hf_afp_request_bitmap_LongName,
6267 { "Long name", "afp.request_bitmap.long_name",
6268 FT_BOOLEAN, 32, NULL, kFPLongNameBit,
6269 "Search long name", HFILL }},
6271 { &hf_afp_request_bitmap_DataForkLen,
6272 { "Data fork size", "afp.request_bitmap.data_fork_len",
6273 FT_BOOLEAN, 32, NULL, kFPDataForkLenBit,
6274 "Search data fork size", HFILL }},
6276 { &hf_afp_request_bitmap_OffspringCount,
6277 { "Offspring count", "afp.request_bitmap.offspring_count",
6278 FT_BOOLEAN, 32, NULL, kFPOffspringCountBit,
6279 "Search offspring count", HFILL }},
6281 { &hf_afp_request_bitmap_RsrcForkLen,
6282 { "Resource fork size", "afp.request_bitmap.resource_fork_len",
6283 FT_BOOLEAN, 32, NULL, kFPRsrcForkLenBit,
6284 "Search resource fork size", HFILL }},
6286 { &hf_afp_request_bitmap_ExtDataForkLen,
6287 { "Extended data fork size", "afp.request_bitmap.ex_data_fork_len",
6288 FT_BOOLEAN, 32, NULL, kFPExtDataForkLenBit,
6289 "Search extended (>2GB) data fork size", HFILL }},
6291 { &hf_afp_request_bitmap_UTF8Name,
6292 { "UTF-8 name", "afp.request_bitmap.UTF8_name",
6293 FT_BOOLEAN, 32, NULL, kFPUTF8NameBit,
6294 "Search UTF-8 name", HFILL }},
6296 { &hf_afp_request_bitmap_ExtRsrcForkLen,
6297 { "Extended resource fork size", "afp.request_bitmap.ex_resource_fork_len",
6298 FT_BOOLEAN, 32, NULL, kFPExtRsrcForkLenBit,
6299 "Search extended (>2GB) resource fork size", HFILL }},
6301 { &hf_afp_request_bitmap_PartialNames,
6302 { "Match on partial names", "afp.request_bitmap.partial_names",
6303 FT_BOOLEAN, 32, NULL, 0x80000000,
6304 NULL, HFILL }},
6306 { &hf_afp_struct_size,
6307 { "Struct size", "afp.struct_size",
6308 FT_UINT8, BASE_DEC, NULL,0,
6309 "Sizeof of struct", HFILL }},
6311 { &hf_afp_struct_size16,
6312 { "Struct size", "afp.struct_size16",
6313 FT_UINT16, BASE_DEC, NULL,0,
6314 "Sizeof of struct", HFILL }},
6316 { &hf_afp_flag,
6317 { "From", "afp.flag",
6318 FT_UINT8, BASE_HEX, VALS(flag_vals), 0x80,
6319 "Offset is relative to start/end of the fork", HFILL }},
6321 { &hf_afp_dt_ref,
6322 { "DT ref", "afp.dt_ref",
6323 FT_UINT16, BASE_DEC, NULL, 0x0,
6324 "Desktop database reference num", HFILL }},
6326 { &hf_afp_ofork,
6327 { "Fork", "afp.ofork",
6328 FT_UINT16, BASE_DEC, NULL, 0x0,
6329 "Open fork reference number", HFILL }},
6331 { &hf_afp_offset,
6332 { "Offset", "afp.offset",
6333 FT_INT32, BASE_DEC, NULL, 0x0,
6334 NULL, HFILL }},
6336 { &hf_afp_rw_count,
6337 { "Count", "afp.rw_count",
6338 FT_INT32, BASE_DEC, NULL, 0x0,
6339 "Number of bytes to be read/written", HFILL }},
6341 { &hf_afp_newline_mask,
6342 { "Newline mask", "afp.newline_mask",
6343 FT_UINT8, BASE_HEX, NULL, 0x0,
6344 "Value to AND bytes with when looking for newline", HFILL }},
6346 { &hf_afp_newline_char,
6347 { "Newline char", "afp.newline_char",
6348 FT_UINT8, BASE_HEX, NULL, 0x0,
6349 "Value to compare ANDed bytes with when looking for newline", HFILL }},
6351 { &hf_afp_last_written,
6352 { "Last written", "afp.last_written",
6353 FT_UINT32, BASE_DEC, NULL, 0x0,
6354 "Offset of the last byte written", HFILL }},
6356 { &hf_afp_ofork_len,
6357 { "New length", "afp.ofork_len",
6358 FT_INT32, BASE_DEC, NULL, 0x0,
6359 NULL, HFILL }},
6361 { &hf_afp_path_type,
6362 { "Type", "afp.path_type",
6363 FT_UINT8, BASE_HEX, VALS(path_type_vals), 0,
6364 "Type of names", HFILL }},
6366 { &hf_afp_path_len,
6367 { "Len", "afp.path_len",
6368 FT_UINT8, BASE_DEC, NULL, 0x0,
6369 "Path length", HFILL }},
6371 { &hf_afp_path_unicode_len,
6372 { "Len", "afp.path_unicode_len",
6373 FT_UINT16, BASE_DEC, NULL, 0x0,
6374 "Path length (unicode)", HFILL }},
6376 { &hf_afp_path_unicode_hint,
6377 { "Unicode hint", "afp.path_unicode_hint",
6378 FT_UINT32, BASE_HEX|BASE_EXT_STRING, &unicode_hint_vals_ext, 0x0,
6379 NULL, HFILL }},
6381 { &hf_afp_path_name,
6382 { "Name", "afp.path_name",
6383 FT_STRING, BASE_NONE, NULL, 0x0,
6384 "Path name", HFILL }},
6386 { &hf_afp_fork_type,
6387 { "Resource fork", "afp.fork_type",
6388 FT_BOOLEAN, 8, NULL, 0x80,
6389 "Data/resource fork", HFILL }},
6391 { &hf_afp_access_mode,
6392 { "Access mode", "afp.access",
6393 FT_UINT16, BASE_HEX, NULL, 0x0,
6394 "Fork access mode", HFILL }},
6396 { &hf_afp_access_read,
6397 { "Read", "afp.access.read",
6398 FT_BOOLEAN, 16, NULL, 0x0001,
6399 "Open for reading", HFILL }},
6401 { &hf_afp_access_write,
6402 { "Write", "afp.access.write",
6403 FT_BOOLEAN, 16, NULL, 0x0002,
6404 "Open for writing", HFILL }},
6406 { &hf_afp_access_deny_read,
6407 { "Deny read", "afp.access.deny_read",
6408 FT_BOOLEAN, 16, NULL, 0x0010,
6409 NULL, HFILL }},
6411 { &hf_afp_access_deny_write,
6412 { "Deny write", "afp.access.deny_write",
6413 FT_BOOLEAN, 16, NULL, 0x0020,
6414 NULL, HFILL }},
6416 { &hf_afp_comment,
6417 { "Comment", "afp.comment",
6418 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
6419 "File/folder comment", HFILL }},
6422 * XXX - should this be a type that's displayed as
6423 * text if it's all printable ASCII and hex otherwise,
6424 * or something such as that?
6426 { &hf_afp_file_creator,
6427 { "File creator", "afp.file_creator",
6428 FT_STRING, BASE_NONE, NULL, 0x0,
6429 NULL, HFILL }},
6432 * XXX - should this be a type that's displayed as
6433 * text if it's all printable ASCII and hex otherwise,
6434 * or something such as that?
6436 { &hf_afp_file_type,
6437 { "File type", "afp.file_type",
6438 FT_STRING, BASE_NONE, NULL, 0x0,
6439 NULL, HFILL }},
6441 { &hf_afp_icon_type,
6442 { "Icon type", "afp.icon_type",
6443 FT_UINT8, BASE_HEX, NULL , 0,
6444 NULL, HFILL }},
6446 { &hf_afp_icon_length,
6447 { "Size", "afp.icon_length",
6448 FT_UINT16, BASE_DEC, NULL, 0x0,
6449 "Size for icon bitmap", HFILL }},
6451 { &hf_afp_icon_index,
6452 { "Index", "afp.icon_index",
6453 FT_UINT16, BASE_DEC, NULL, 0x0,
6454 "Icon index in desktop database", HFILL }},
6456 { &hf_afp_icon_tag,
6457 { "Tag", "afp.icon_tag",
6458 FT_UINT32, BASE_HEX, NULL, 0x0,
6459 "Icon tag", HFILL }},
6461 { &hf_afp_appl_index,
6462 { "Index", "afp.appl_index",
6463 FT_UINT16, BASE_DEC, NULL, 0x0,
6464 "Application index", HFILL }},
6466 { &hf_afp_appl_tag,
6467 { "Tag", "afp.appl_tag",
6468 FT_UINT32, BASE_HEX, NULL, 0x0,
6469 "Application tag", HFILL }},
6471 { &hf_afp_lock_op,
6472 { "unlock", "afp.lock_op",
6473 FT_BOOLEAN, 8, NULL, 0x1,
6474 "Lock/unlock op", HFILL }},
6476 { &hf_afp_lock_from,
6477 { "End", "afp.lock_from",
6478 FT_BOOLEAN, 8, NULL, 0x80,
6479 "Offset is relative to the end of the fork", HFILL }},
6481 { &hf_afp_lock_offset,
6482 { "Offset", "afp.lock_offset",
6483 FT_INT32, BASE_DEC, NULL, 0x0,
6484 "First byte to be locked", HFILL }},
6486 { &hf_afp_lock_len,
6487 { "Length", "afp.lock_len",
6488 FT_INT32, BASE_DEC, NULL, 0x0,
6489 "Number of bytes to be locked/unlocked", HFILL }},
6491 { &hf_afp_lock_range_start,
6492 { "Start", "afp.lock_range_start",
6493 FT_INT32, BASE_DEC, NULL, 0x0,
6494 "First byte locked/unlocked", HFILL }},
6496 { &hf_afp_dir_ar,
6497 { "Access rights", "afp.dir_ar",
6498 FT_UINT32, BASE_HEX, NULL, 0x0,
6499 "Directory access rights", HFILL }},
6501 { &hf_afp_dir_ar_o_search,
6502 { "Owner has search access", "afp.dir_ar.o_search",
6503 FT_BOOLEAN, 32, NULL, AR_O_SEARCH,
6504 NULL, HFILL }},
6506 { &hf_afp_dir_ar_o_read,
6507 { "Owner has read access", "afp.dir_ar.o_read",
6508 FT_BOOLEAN, 32, NULL, AR_O_READ,
6509 NULL, HFILL }},
6511 { &hf_afp_dir_ar_o_write,
6512 { "Owner has write access", "afp.dir_ar.o_write",
6513 FT_BOOLEAN, 32, NULL, AR_O_WRITE,
6514 NULL, HFILL }},
6516 { &hf_afp_dir_ar_g_search,
6517 { "Group has search access", "afp.dir_ar.g_search",
6518 FT_BOOLEAN, 32, NULL, AR_G_SEARCH,
6519 NULL, HFILL }},
6521 { &hf_afp_dir_ar_g_read,
6522 { "Group has read access", "afp.dir_ar.g_read",
6523 FT_BOOLEAN, 32, NULL, AR_G_READ,
6524 NULL, HFILL }},
6526 { &hf_afp_dir_ar_g_write,
6527 { "Group has write access", "afp.dir_ar.g_write",
6528 FT_BOOLEAN, 32, NULL, AR_G_WRITE,
6529 NULL, HFILL }},
6531 { &hf_afp_dir_ar_e_search,
6532 { "Everyone has search access", "afp.dir_ar.e_search",
6533 FT_BOOLEAN, 32, NULL, AR_E_SEARCH,
6534 NULL, HFILL }},
6536 { &hf_afp_dir_ar_e_read,
6537 { "Everyone has read access", "afp.dir_ar.e_read",
6538 FT_BOOLEAN, 32, NULL, AR_E_READ,
6539 NULL, HFILL }},
6541 { &hf_afp_dir_ar_e_write,
6542 { "Everyone has write access", "afp.dir_ar.e_write",
6543 FT_BOOLEAN, 32, NULL, AR_E_WRITE,
6544 NULL, HFILL }},
6546 { &hf_afp_dir_ar_u_search,
6547 { "User has search access", "afp.dir_ar.u_search",
6548 FT_BOOLEAN, 32, NULL, AR_U_SEARCH,
6549 NULL, HFILL }},
6551 { &hf_afp_dir_ar_u_read,
6552 { "User has read access", "afp.dir_ar.u_read",
6553 FT_BOOLEAN, 32, NULL, AR_U_READ,
6554 NULL, HFILL }},
6556 { &hf_afp_dir_ar_u_write,
6557 { "User has write access", "afp.dir_ar.u_write",
6558 FT_BOOLEAN, 32, NULL, AR_U_WRITE,
6559 NULL, HFILL }},
6561 { &hf_afp_dir_ar_blank,
6562 { "Blank access right", "afp.dir_ar.blank",
6563 FT_BOOLEAN, 32, NULL, AR_BLANK,
6564 NULL, HFILL }},
6566 { &hf_afp_dir_ar_u_own,
6567 { "User is the owner", "afp.dir_ar.u_owner",
6568 FT_BOOLEAN, 32, NULL, AR_U_OWN,
6569 "Current user is the directory owner", HFILL }},
6571 { &hf_afp_server_time,
6572 { "Server time", "afp.server_time",
6573 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
6574 NULL, HFILL }},
6576 { &hf_afp_cat_req_matches,
6577 { "Max answers", "afp.cat_req_matches",
6578 FT_INT32, BASE_DEC, NULL, 0x0,
6579 "Maximum number of matches to return.", HFILL }},
6581 { &hf_afp_reserved,
6582 { "Reserved", "afp.reserved",
6583 FT_BYTES, BASE_NONE, NULL, 0x0,
6584 NULL, HFILL }},
6586 { &hf_afp_cat_count,
6587 { "Cat count", "afp.cat_count",
6588 FT_UINT32, BASE_DEC, NULL, 0x0,
6589 "Number of structures returned", HFILL }},
6591 { &hf_afp_cat_position,
6592 { "Position", "afp.cat_position",
6593 FT_BYTES, BASE_NONE, NULL, 0x0,
6594 "Catalog position", HFILL }},
6596 { &hf_afp_map_name_type,
6597 { "Type", "afp.map_name_type",
6598 FT_UINT8, BASE_DEC|BASE_EXT_STRING, &map_name_type_vals_ext, 0x0,
6599 "Map name type", HFILL }},
6601 { &hf_afp_map_id_type,
6602 { "Type", "afp.map_id_type",
6603 FT_UINT8, BASE_DEC|BASE_EXT_STRING, &map_id_type_vals_ext, 0x0,
6604 "Map ID type", HFILL }},
6606 { &hf_afp_map_id,
6607 { "ID", "afp.map_id",
6608 FT_UINT32, BASE_DEC, NULL, 0x0,
6609 "User/Group ID", HFILL }},
6611 { &hf_afp_map_id_reply_type,
6612 { "Reply type", "afp.map_id_reply_type",
6613 FT_UINT32, BASE_DEC, VALS(map_id_reply_type_vals), 0x0,
6614 "Map ID reply type", HFILL }},
6616 { &hf_afp_map_name,
6617 { "Name", "afp.map_name",
6618 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
6619 "User/Group name", HFILL }},
6621 /* AFP 3.0 */
6622 { &hf_afp_lock_offset64,
6623 { "Offset", "afp.lock_offset64",
6624 FT_INT64, BASE_DEC, NULL, 0x0,
6625 "First byte to be locked (64 bits)", HFILL }},
6627 { &hf_afp_lock_len64,
6628 { "Length", "afp.lock_len64",
6629 FT_INT64, BASE_DEC, NULL, 0x0,
6630 "Number of bytes to be locked/unlocked (64 bits)", HFILL }},
6632 { &hf_afp_lock_range_start64,
6633 { "Start", "afp.lock_range_start64",
6634 FT_INT64, BASE_DEC, NULL, 0x0,
6635 "First byte locked/unlocked (64 bits)", HFILL }},
6637 { &hf_afp_offset64,
6638 { "Offset", "afp.offset64",
6639 FT_INT64, BASE_DEC, NULL, 0x0,
6640 "Offset (64 bits)", HFILL }},
6642 { &hf_afp_rw_count64,
6643 { "Count", "afp.rw_count64",
6644 FT_INT64, BASE_DEC, NULL, 0x0,
6645 "Number of bytes to be read/written (64 bits)", HFILL }},
6647 { &hf_afp_last_written64,
6648 { "Last written", "afp.last_written64",
6649 FT_UINT64, BASE_DEC, NULL, 0x0,
6650 "Offset of the last byte written (64 bits)", HFILL }},
6652 { &hf_afp_ofork_len64,
6653 { "New length", "afp.ofork_len64",
6654 FT_INT64, BASE_DEC, NULL, 0x0,
6655 "New length (64 bits)", HFILL }},
6657 { &hf_afp_session_token_type,
6658 { "Type", "afp.session_token_type",
6659 FT_UINT16, BASE_HEX|BASE_EXT_STRING, &token_type_vals_ext, 0x0,
6660 "Session token type", HFILL }},
6662 /* FIXME FT_UINT32 in specs */
6663 { &hf_afp_session_token_len,
6664 { "Len", "afp.session_token_len",
6665 FT_UINT32, BASE_DEC, NULL, 0x0,
6666 "Session token length", HFILL }},
6668 { &hf_afp_session_token_timestamp,
6669 { "Time stamp", "afp.session_token_timestamp",
6670 FT_UINT32, BASE_HEX, NULL, 0x0,
6671 "Session time stamp", HFILL }},
6673 { &hf_afp_session_token,
6674 { "Token", "afp.session_token",
6675 FT_BYTES, BASE_NONE, NULL, 0x0,
6676 "Session token", HFILL }},
6678 { &hf_afp_user_flag,
6679 { "Flag", "afp.user_flag",
6680 FT_UINT8, BASE_HEX, VALS(user_flag_vals), 0x01,
6681 "User Info flag", HFILL }},
6683 { &hf_afp_user_ID,
6684 { "User ID", "afp.user_ID",
6685 FT_UINT32, BASE_DEC, NULL, 0x0,
6686 NULL, HFILL }},
6688 { &hf_afp_group_ID,
6689 { "Group ID", "afp.group_ID",
6690 FT_UINT32, BASE_DEC, NULL, 0x0,
6691 NULL, HFILL }},
6693 { &hf_afp_UUID,
6694 { "UUID", "afp.uuid",
6695 FT_GUID, BASE_NONE, NULL, 0x0,
6696 NULL, HFILL }},
6698 { &hf_afp_GRPUUID,
6699 { "GRPUUID", "afp.grpuuid",
6700 FT_GUID, BASE_NONE, NULL, 0x0,
6701 "Group UUID", HFILL }},
6703 { &hf_afp_user_bitmap,
6704 { "Bitmap", "afp.user_bitmap",
6705 FT_UINT16, BASE_HEX, NULL, 0,
6706 "User Info bitmap", HFILL }},
6708 { &hf_afp_user_bitmap_UID,
6709 { "User ID", "afp.user_bitmap.UID",
6710 FT_BOOLEAN, 16, NULL, 0x0001,
6711 NULL, HFILL }},
6713 { &hf_afp_user_bitmap_GID,
6714 { "Primary group ID", "afp.user_bitmap.GID",
6715 FT_BOOLEAN, 16, NULL, 0x0002,
6716 NULL, HFILL }},
6718 { &hf_afp_user_bitmap_UUID,
6719 { "UUID", "afp.user_bitmap.UUID",
6720 FT_BOOLEAN, 16, NULL, 0x0004,
6721 NULL, HFILL }},
6723 { &hf_afp_message_type,
6724 { "Type", "afp.message_type",
6725 FT_UINT16, BASE_HEX, VALS(server_message_type), 0,
6726 "Type of server message", HFILL }},
6728 { &hf_afp_message_bitmap,
6729 { "Bitmap", "afp.message_bitmap",
6730 FT_UINT16, BASE_HEX, NULL, 0,
6731 "Message bitmap", HFILL }},
6734 * XXX - in the reply, this indicates whether the message
6735 * is a server message or a login message.
6737 { &hf_afp_message_bitmap_REQ,
6738 { "Request message", "afp.message_bitmap.requested",
6739 FT_BOOLEAN, 16, NULL, 0x0001,
6740 "Message Requested", HFILL }},
6742 { &hf_afp_message_bitmap_UTF,
6743 { "Message is UTF-8", "afp.message_bitmap.utf8",
6744 FT_BOOLEAN, 16, NULL, 0x0002,
6745 NULL, HFILL }},
6747 { &hf_afp_message_len,
6748 { "Len", "afp.message_length",
6749 FT_UINT32, BASE_DEC, NULL, 0x0,
6750 "Message length", HFILL }},
6752 { &hf_afp_message,
6753 { "Message", "afp.message",
6754 FT_STRING, BASE_NONE, NULL, 0x0,
6755 NULL, HFILL }},
6757 { &hf_afp_reqcount64,
6758 { "Count", "afp.reqcount64",
6759 FT_INT64, BASE_DEC, NULL, 0x0,
6760 "Request Count (64 bits)", HFILL }},
6762 { &hf_afp_extattr_bitmap,
6763 { "Bitmap", "afp.extattr_bitmap",
6764 FT_UINT16, BASE_HEX, NULL, 0,
6765 "Extended attributes bitmap", HFILL }},
6767 { &hf_afp_extattr_bitmap_NoFollow,
6768 { "No follow symlinks", "afp.extattr_bitmap.nofollow",
6769 FT_BOOLEAN, 16, NULL, 0x0001,
6770 "Do not follow symlink", HFILL }},
6772 { &hf_afp_extattr_bitmap_Create,
6773 { "Create", "afp.extattr_bitmap.create",
6774 FT_BOOLEAN, 16, NULL, 0x0002,
6775 "Create extended attribute", HFILL }},
6777 { &hf_afp_extattr_bitmap_Replace,
6778 { "Replace", "afp.extattr_bitmap.replace",
6779 FT_BOOLEAN, 16, NULL, 0x0004,
6780 "Replace extended attribute", HFILL }},
6782 { &hf_afp_extattr_namelen,
6783 { "Length", "afp.extattr.namelen",
6784 FT_UINT16, BASE_DEC, NULL, 0x0,
6785 "Extended attribute name length", HFILL }},
6787 { &hf_afp_extattr_name,
6788 { "Name", "afp.extattr.name",
6789 FT_STRING, BASE_NONE, NULL, 0x0,
6790 "Extended attribute name", HFILL }},
6792 { &hf_afp_extattr_len,
6793 { "Length", "afp.extattr.len",
6794 FT_UINT32, BASE_DEC, NULL, 0x0,
6795 "Extended attribute length", HFILL }},
6797 { &hf_afp_extattr_data,
6798 { "Data", "afp.extattr.data",
6799 FT_BYTES, BASE_NONE, NULL, 0x0,
6800 "Extended attribute data", HFILL }},
6802 { &hf_afp_extattr_req_count,
6803 { "Request Count", "afp.extattr.req_count",
6804 FT_UINT16, BASE_DEC, NULL, 0x0,
6805 "Request Count.", HFILL }},
6807 { &hf_afp_extattr_start_index,
6808 { "Index", "afp.extattr.start_index",
6809 FT_UINT32, BASE_DEC, NULL, 0x0,
6810 "Start index", HFILL }},
6812 { &hf_afp_extattr_reply_size,
6813 { "Reply size", "afp.extattr.reply_size",
6814 FT_UINT32, BASE_DEC, NULL, 0x0,
6815 NULL, HFILL }},
6817 /* ACL control list bitmap */
6818 { &hf_afp_access_bitmap,
6819 { "Bitmap", "afp.access_bitmap",
6820 FT_UINT16, BASE_HEX, NULL, 0,
6821 "Bitmap (reserved)", HFILL }},
6823 { &hf_afp_acl_list_bitmap,
6824 { "ACL bitmap", "afp.acl_list_bitmap",
6825 FT_UINT16, BASE_HEX, NULL, 0,
6826 "ACL control list bitmap", HFILL }},
6828 { &hf_afp_acl_list_bitmap_UUID,
6829 { "UUID", "afp.acl_list_bitmap.UUID",
6830 FT_BOOLEAN, 16, NULL, kFileSec_UUID,
6831 "User UUID", HFILL }},
6833 { &hf_afp_acl_list_bitmap_GRPUUID,
6834 { "GRPUUID", "afp.acl_list_bitmap.GRPUUID",
6835 FT_BOOLEAN, 16, NULL, kFileSec_GRPUUID,
6836 "Group UUID", HFILL }},
6838 { &hf_afp_acl_list_bitmap_ACL,
6839 { "ACL", "afp.acl_list_bitmap.ACL",
6840 FT_BOOLEAN, 16, NULL, kFileSec_ACL,
6841 NULL, HFILL }},
6843 { &hf_afp_acl_list_bitmap_REMOVEACL,
6844 { "Remove ACL", "afp.acl_list_bitmap.REMOVEACL",
6845 FT_BOOLEAN, 16, NULL, kFileSec_REMOVEACL,
6846 NULL, HFILL }},
6848 { &hf_afp_acl_list_bitmap_Inherit,
6849 { "Inherit", "afp.acl_list_bitmap.Inherit",
6850 FT_BOOLEAN, 16, NULL, kFileSec_Inherit,
6851 "Inherit ACL", HFILL }},
6853 { &hf_afp_acl_entrycount,
6854 { "ACEs count", "afp.acl_entrycount",
6855 FT_UINT32, BASE_HEX, NULL, 0,
6856 "Number of ACL entries", HFILL }},
6858 { &hf_afp_acl_flags,
6859 { "ACL flags", "afp.acl_flags",
6860 FT_UINT32, BASE_HEX, NULL, 0,
6861 NULL, HFILL }},
6863 { &hf_afp_acl_access_bitmap,
6864 { "Bitmap", "afp.acl_access_bitmap",
6865 FT_UINT32, BASE_HEX, NULL, 0,
6866 "ACL access bitmap", HFILL }},
6868 { &hf_afp_acl_access_bitmap_read_data,
6869 { "Read/List", "afp.acl_access_bitmap.read_data",
6870 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_READ_DATA,
6871 "Read data / list directory", HFILL }},
6873 { &hf_afp_acl_access_bitmap_write_data,
6874 { "Write/Add file", "afp.acl_access_bitmap.write_data",
6875 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_WRITE_DATA,
6876 "Write data to a file / add a file to a directory", HFILL }},
6878 { &hf_afp_acl_access_bitmap_execute,
6879 { "Execute/Search", "afp.acl_access_bitmap.execute",
6880 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_EXECUTE,
6881 "Execute a program", HFILL }},
6883 { &hf_afp_acl_access_bitmap_delete,
6884 { "Delete", "afp.acl_access_bitmap.delete",
6885 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_DELETE,
6886 NULL, HFILL }},
6888 { &hf_afp_acl_access_bitmap_append_data,
6889 { "Append data/create subdir", "afp.acl_access_bitmap.append_data",
6890 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_APPEND_DATA,
6891 "Append data to a file / create a subdirectory", HFILL }},
6893 { &hf_afp_acl_access_bitmap_delete_child,
6894 { "Delete dir", "afp.acl_access_bitmap.delete_child",
6895 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_DELETE_CHILD,
6896 "Delete directory", HFILL }},
6898 { &hf_afp_acl_access_bitmap_read_attrs,
6899 { "Read attributes", "afp.acl_access_bitmap.read_attrs",
6900 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_READ_ATTRIBUTES,
6901 NULL, HFILL }},
6903 { &hf_afp_acl_access_bitmap_write_attrs,
6904 { "Write attributes", "afp.acl_access_bitmap.write_attrs",
6905 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_WRITE_ATTRIBUTES,
6906 NULL, HFILL }},
6908 { &hf_afp_acl_access_bitmap_read_extattrs,
6909 { "Read extended attributes", "afp.acl_access_bitmap.read_extattrs",
6910 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_READ_EXTATTRIBUTES,
6911 NULL, HFILL }},
6913 { &hf_afp_acl_access_bitmap_write_extattrs,
6914 { "Write extended attributes", "afp.acl_access_bitmap.write_extattrs",
6915 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_WRITE_EXTATTRIBUTES,
6916 NULL, HFILL }},
6918 { &hf_afp_acl_access_bitmap_read_security,
6919 { "Read security", "afp.acl_access_bitmap.read_security",
6920 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_READ_SECURITY,
6921 "Read access rights", HFILL }},
6923 { &hf_afp_acl_access_bitmap_write_security,
6924 { "Write security", "afp.acl_access_bitmap.write_security",
6925 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_WRITE_SECURITY,
6926 "Write access rights", HFILL }},
6928 { &hf_afp_acl_access_bitmap_change_owner,
6929 { "Change owner", "afp.acl_access_bitmap.change_owner",
6930 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_CHANGE_OWNER,
6931 NULL, HFILL }},
6933 { &hf_afp_acl_access_bitmap_synchronize,
6934 { "Synchronize", "afp.acl_access_bitmap.synchronize",
6935 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_SYNCHRONIZE,
6936 NULL, HFILL }},
6938 { &hf_afp_acl_access_bitmap_generic_all,
6939 { "Generic all", "afp.acl_access_bitmap.generic_all",
6940 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_GENERIC_ALL,
6941 NULL, HFILL }},
6943 { &hf_afp_acl_access_bitmap_generic_execute,
6944 { "Generic execute", "afp.acl_access_bitmap.generic_execute",
6945 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_GENERIC_EXECUTE,
6946 NULL, HFILL }},
6948 { &hf_afp_acl_access_bitmap_generic_write,
6949 { "Generic write", "afp.acl_access_bitmap.generic_write",
6950 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_GENERIC_WRITE,
6951 NULL, HFILL }},
6953 { &hf_afp_acl_access_bitmap_generic_read,
6954 { "Generic read", "afp.acl_access_bitmap.generic_read",
6955 FT_BOOLEAN, 32, NULL, KAUTH_VNODE_GENERIC_READ,
6956 NULL, HFILL }},
6958 { &hf_afp_ace_flags,
6959 { "Flags", "afp.ace_flags",
6960 FT_UINT32, BASE_HEX, NULL, 0,
6961 "ACE flags", HFILL }},
6963 { &hf_afp_ace_flags_allow,
6964 { "Allow", "afp.ace_flags.allow",
6965 FT_BOOLEAN, 32, NULL, ACE_ALLOW,
6966 "Allow rule", HFILL }},
6968 { &hf_afp_ace_flags_deny,
6969 { "Deny", "afp.ace_flags.deny",
6970 FT_BOOLEAN, 32, NULL, ACE_DENY,
6971 "Deny rule", HFILL }},
6973 { &hf_afp_ace_flags_inherited,
6974 { "Inherited", "afp.ace_flags.inherited",
6975 FT_BOOLEAN, 32, NULL, ACE_INHERITED,
6976 NULL, HFILL }},
6978 { &hf_afp_ace_flags_fileinherit,
6979 { "File inherit", "afp.ace_flags.file_inherit",
6980 FT_BOOLEAN, 32, NULL, ACE_FILE_INHERIT,
6981 NULL, HFILL }},
6983 { &hf_afp_ace_flags_dirinherit,
6984 { "Dir inherit", "afp.ace_flags.directory_inherit",
6985 FT_BOOLEAN, 32, NULL, ACE_DIR_INHERIT,
6986 NULL, HFILL }},
6988 { &hf_afp_ace_flags_limitinherit,
6989 { "Limit inherit", "afp.ace_flags.limit_inherit",
6990 FT_BOOLEAN, 32, NULL, ACE_LIMIT_INHERIT,
6991 NULL, HFILL }},
6993 { &hf_afp_ace_flags_onlyinherit,
6994 { "Only inherit", "afp.ace_flags.only_inherit",
6995 FT_BOOLEAN, 32, NULL, ACE_ONLY_INHERIT,
6996 NULL, HFILL }},
6998 { &hf_afp_spotlight_request_flags,
6999 { "Flags", "afp.spotlight.flags",
7000 FT_UINT32, BASE_HEX, NULL, 0x0,
7001 "Spotlight RPC Flags", HFILL }},
7003 { &hf_afp_spotlight_request_command,
7004 { "Command", "afp.spotlight.command",
7005 FT_UINT32, BASE_HEX, NULL, 0x0,
7006 "Spotlight RPC Command", HFILL }},
7008 { &hf_afp_spotlight_request_reserved,
7009 { "Reserved", "afp.spotlight.reserved",
7010 FT_UINT32, BASE_HEX, NULL, 0x0,
7011 "Spotlight RPC Padding", HFILL }},
7013 { &hf_afp_spotlight_reply_reserved,
7014 { "Reserved", "afp.spotlight.reserved",
7015 FT_UINT32, BASE_HEX, NULL, 0x0,
7016 "Spotlight RPC Padding", HFILL }},
7018 { &hf_afp_spotlight_volpath_client,
7019 { "Client's volume path", "afp.spotlight.volpath_client",
7020 FT_STRING, BASE_NONE, NULL, 0x0,
7021 NULL, HFILL }},
7023 { &hf_afp_spotlight_volpath_server,
7024 { "Server's volume path", "afp.spotlight.volpath_server",
7025 FT_STRING, BASE_NONE, NULL, 0x0,
7026 "Servers's volume path", HFILL }},
7028 { &hf_afp_spotlight_returncode,
7029 { "Return code", "afp.spotlight.return",
7030 FT_INT32, BASE_DEC, NULL, 0x0,
7031 NULL, HFILL }},
7033 { &hf_afp_spotlight_volflags,
7034 { "Volume flags", "afp.spotlight.volflags",
7035 FT_UINT32, BASE_HEX, NULL, 0x0,
7036 NULL, HFILL }},
7038 { &hf_afp_spotlight_reqlen,
7039 { "Length", "afp.spotlight.reqlen",
7040 FT_UINT32, BASE_DEC, NULL, 0x0,
7041 NULL, HFILL }},
7043 { &hf_afp_spotlight_uuid,
7044 { "UUID", "afp.spotlight.uuid",
7045 FT_GUID, BASE_NONE, NULL, 0x0,
7046 NULL, HFILL }},
7048 { &hf_afp_spotlight_date,
7049 { "Date", "afp.spotlight.date",
7050 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
7051 NULL, HFILL }},
7053 { &hf_afp_unknown,
7054 { "Unknown parameter", "afp.unknown_bytes",
7055 FT_BYTES, BASE_NONE, NULL, 0x0,
7056 NULL, HFILL }},
7058 /* Status stuff from ASP or DSI */
7059 { &hf_afp_utf8_server_name_len,
7060 { "UTF-8 server name length", "afp.utf8_server_name_len",
7061 FT_UINT16, BASE_DEC, NULL, 0x0,
7062 NULL, HFILL }},
7064 { &hf_afp_utf8_server_name,
7065 { "UTF-8 server name", "afp.utf8_server_name",
7066 FT_STRING, BASE_NONE, NULL, 0x0,
7067 NULL, HFILL }},
7069 { &hf_afp_server_name,
7070 { "Server name", "afp.server_name",
7071 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
7072 NULL, HFILL }},
7074 { &hf_afp_server_type,
7075 { "Server type", "afp.server_type",
7076 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
7077 NULL, HFILL }},
7079 { &hf_afp_server_vers,
7080 { "AFP version", "afp.server_vers",
7081 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
7082 NULL, HFILL }},
7084 { &hf_afp_server_uams,
7085 { "UAM", "afp.server_uams",
7086 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
7087 NULL, HFILL }},
7089 { &hf_afp_server_icon,
7090 { "Icon bitmap", "afp.server_icon",
7091 FT_BYTES, BASE_NONE, NULL, 0x0,
7092 "Server icon bitmap", HFILL }},
7094 { &hf_afp_server_directory,
7095 { "Directory service", "afp.server_directory",
7096 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
7097 "Server directory service", HFILL }},
7099 { &hf_afp_server_signature,
7100 { "Server signature", "afp.server_signature",
7101 FT_BYTES, BASE_NONE, NULL, 0x0,
7102 NULL, HFILL }},
7104 { &hf_afp_server_flag,
7105 { "Flag", "afp.server_flag",
7106 FT_UINT16, BASE_HEX, NULL, 0x0,
7107 "Server capabilities flag", HFILL }},
7108 { &hf_afp_server_flag_copyfile,
7109 { "Support copyfile", "afp.server_flag.copyfile",
7110 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_COPY,
7111 "Server support copyfile", HFILL }},
7112 { &hf_afp_server_flag_passwd,
7113 { "Support change password", "afp.server_flag.passwd",
7114 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_PASSWD,
7115 "Server support change password", HFILL }},
7116 { &hf_afp_server_flag_no_save_passwd,
7117 { "Don't allow save password", "afp.server_flag.no_save_passwd",
7118 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_NOSAVEPASSWD,
7119 NULL, HFILL }},
7120 { &hf_afp_server_flag_srv_msg,
7121 { "Support server message", "afp.server_flag.srv_msg",
7122 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVMSGS,
7123 NULL, HFILL }},
7124 { &hf_afp_server_flag_srv_sig,
7125 { "Support server signature", "afp.server_flag.srv_sig",
7126 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVSIGNATURE,
7127 NULL, HFILL }},
7128 { &hf_afp_server_flag_tcpip,
7129 { "Support TCP/IP", "afp.server_flag.tcpip",
7130 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_TCPIP,
7131 "Server support TCP/IP", HFILL }},
7132 { &hf_afp_server_flag_notify,
7133 { "Support server notifications", "afp.server_flag.notify",
7134 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVNOTIFY,
7135 NULL, HFILL }},
7136 { &hf_afp_server_flag_reconnect,
7137 { "Support server reconnect", "afp.server_flag.reconnect",
7138 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVRECONNECT,
7139 NULL, HFILL }},
7140 { &hf_afp_server_flag_directory,
7141 { "Support directory services", "afp.server_flag.directory",
7142 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVDIRECTORY,
7143 "Server support directory services", HFILL }},
7144 { &hf_afp_server_flag_utf8_name,
7145 { "Support UTF-8 server name", "afp.server_flag.utf8_name",
7146 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_SRVUTF8,
7147 "Server support UTF-8 server name", HFILL }},
7148 { &hf_afp_server_flag_uuid,
7149 { "Support UUIDs", "afp.server_flag.uuids",
7150 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_UUID,
7151 "Server supports UUIDs", HFILL }},
7152 { &hf_afp_server_flag_ext_sleep,
7153 { "Support extended sleep", "afp.server_flag.ext_sleep",
7154 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_EXT_SLEEP,
7155 "Server supports extended sleep", HFILL }},
7156 { &hf_afp_server_flag_fast_copy,
7157 { "Support fast copy", "afp.server_flag.fast_copy",
7158 FT_BOOLEAN, 16, NULL, AFPSRVRINFO_FASTBOZO,
7159 "Server support fast copy", HFILL }},
7162 { &hf_afp_server_addr_len,
7163 { "Length", "afp.server_addr.len",
7164 FT_UINT8, BASE_DEC, NULL, 0x0,
7165 "Address length.", HFILL }},
7167 { &hf_afp_server_addr_type,
7168 { "Type", "afp.server_addr.type",
7169 FT_UINT8, BASE_DEC|BASE_EXT_STRING, &afp_server_addr_type_vals_ext, 0x0,
7170 "Address type.", HFILL }},
7172 { &hf_afp_server_addr_value,
7173 { "Value", "afp.server_addr.value",
7174 FT_BYTES, BASE_NONE, NULL, 0x0,
7175 "Address value", HFILL }},
7177 /* Generated from convert_proto_tree_add_text.pl */
7178 { &hf_afp_int64, { "int64", "afp.int64", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7179 { &hf_afp_float, { "float", "afp.float", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7180 { &hf_afp_unknown16, { "unknown1", "afp.unknown", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7181 { &hf_afp_unknown32, { "unknown2", "afp.unknown", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7182 { &hf_afp_cnid, { "CNID", "afp.cnid", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7183 { &hf_afp_null, { "null", "afp.null", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7184 { &hf_afp_string, { "string", "afp.string", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7185 { &hf_afp_utf_16_string, { "utf-16 string", "afp.utf_16_string", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7186 { &hf_afp_bool, { "bool", "afp.bool", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7187 { &hf_afp_query_type, { "type", "afp.query_type", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
7188 { &hf_afp_toc_offset, { "ToC Offset", "afp.toc_offset", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7189 { &hf_afp_toc_entry, { "ToC Entry", "afp.toc_entry", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }},
7190 { &hf_afp_endianness, { "Endianness", "afp.endianness", FT_UINT64, BASE_HEX | BASE_VAL64_STRING, VALS64(endian_vals), 0x0, NULL, HFILL }},
7191 { &hf_afp_query_len, { "Query length", "afp.query_len", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7192 { &hf_afp_num_toc_entries, { "Number of entries", "afp.num_toc_entries", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7193 { &hf_afp_machine_offset, { "Machine offset", "afp.machine_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7194 { &hf_afp_version_offset, { "Version offset", "afp.version_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7195 { &hf_afp_uams_offset, { "UAMS offset", "afp.uams_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7196 { &hf_afp_icon_offset, { "Icon offset", "afp.icon_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7197 { &hf_afp_signature_offset, { "Signature offset", "afp.signature_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7198 { &hf_afp_network_address_offset, { "Network address offset", "afp.network_address_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7199 { &hf_afp_directory_services_offset, { "Directory services offset", "afp.directory_services_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7200 { &hf_afp_utf8_server_name_offset, { "UTF-8 server name offset", "afp.utf8_server_name_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
7203 static int *ett[] = {
7204 &ett_afp,
7205 &ett_afp_server_vol,
7206 &ett_afp_vol_list,
7207 &ett_afp_vol_flag,
7208 &ett_afp_vol_bitmap,
7209 &ett_afp_vol_attribute,
7210 &ett_afp_dir_bitmap,
7211 &ett_afp_file_bitmap,
7212 &ett_afp_unix_privs,
7213 &ett_afp_enumerate,
7214 &ett_afp_enumerate_line,
7215 &ett_afp_access_mode,
7216 &ett_afp_dir_attribute,
7217 &ett_afp_file_attribute,
7218 &ett_afp_path_name,
7219 &ett_afp_lock_flags,
7220 &ett_afp_dir_ar,
7221 &ett_afp_cat_search,
7222 &ett_afp_cat_r_bitmap,
7223 &ett_afp_cat_spec,
7224 &ett_afp_vol_did,
7225 &ett_afp_user_bitmap,
7226 &ett_afp_message_bitmap,
7227 &ett_afp_extattr_bitmap,
7228 &ett_afp_extattr_names,
7229 &ett_afp_acl_list_bitmap,
7230 &ett_afp_acl_access_bitmap,
7231 &ett_afp_ace_entries,
7232 &ett_afp_ace_entry,
7233 &ett_afp_ace_flags,
7234 &ett_afp_spotlight_queries,
7235 &ett_afp_spotlight_query_line,
7236 &ett_afp_spotlight_query,
7237 &ett_afp_spotlight_data,
7238 &ett_afp_spotlight_toc,
7240 /* Status stuff from ASP or DSI */
7241 &ett_afp_status,
7242 &ett_afp_status_server_flag,
7243 &ett_afp_vers,
7244 &ett_afp_uams,
7245 &ett_afp_server_addr,
7246 &ett_afp_server_addr_line,
7247 &ett_afp_directory,
7248 &ett_afp_utf8_name
7251 static ei_register_info ei[] = {
7252 { &ei_afp_subquery_count_over_safety_limit, { "afp.subquery_count_over_safety_limit", PI_MALFORMED, PI_ERROR, "Subquery count > safety limit", EXPFILL }},
7253 { &ei_afp_subquery_count_over_query_count, { "afp.subquery_count_over_query_count", PI_MALFORMED, PI_ERROR, "Subquery count > query count", EXPFILL }},
7254 { &ei_afp_abnormal_num_subqueries, { "afp.abnormal_num_subqueries", PI_PROTOCOL, PI_WARN, "Abnormal number of subqueries", EXPFILL }},
7255 { &ei_afp_too_many_acl_entries, { "afp.too_many_acl_entries", PI_UNDECODED, PI_WARN, "Too many ACL entries", EXPFILL }},
7256 { &ei_afp_ip_port_reused, { "afp.ip_port_reused", PI_SEQUENCE, PI_WARN, "IP port reused, you need to split the capture file", EXPFILL }},
7257 { &ei_afp_toc_offset, { "afp.toc_offset.bogus", PI_PROTOCOL, PI_WARN, "ToC offset bogus", EXPFILL }},
7259 expert_module_t* expert_afp;
7261 proto_afp = proto_register_protocol("Apple Filing Protocol", "AFP", "afp");
7262 proto_register_field_array(proto_afp, hf, array_length(hf));
7263 proto_register_subtree_array(ett, array_length(ett));
7264 expert_afp = expert_register_protocol(proto_afp);
7265 expert_register_field_array(expert_afp, ei, array_length(ei));
7267 afp_request_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), afp_hash, afp_equal);
7269 register_dissector("afp", dissect_afp, proto_afp);
7270 register_dissector("afp_server_status", dissect_afp_server_status,
7271 proto_afp);
7272 register_dissector("afp_spotlight", dissect_spotlight, proto_afp);
7274 afp_tap = register_tap("afp");
7276 register_srt_table(proto_afp, NULL, 1, afpstat_packet, afpstat_init, NULL);
7279 void
7280 proto_reg_handoff_afp(void)
7282 spotlight_handle = find_dissector_add_dependency("afp_spotlight", proto_afp);
7285 /* -------------------------------
7290 * Editor modelines - https://www.wireshark.org/tools/modelines.html
7292 * Local variables:
7293 * c-basic-offset: 8
7294 * tab-width: 8
7295 * indent-tabs-mode: t
7296 * End:
7298 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
7299 * :indentSize=8:tabSize=8:noTabs=false: