2 * Routines for afp packet dissection
3 * Copyright 2002, Didier Gautheron <dgautheron@magic.fr>
5 * $Id: packet-afp.c,v 1.4 2002/04/28 21:04:04 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * Copied from README.developer
12 * Copied from packet-dsi.c
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 #ifdef HAVE_SYS_TYPES_H
36 # include <sys/types.h>
39 #ifdef HAVE_NETINET_IN_H
40 # include <netinet/in.h>
43 #ifdef NEED_SNPRINTF_H
49 # include "snprintf.h"
54 #include <epan/packet.h>
55 #include <epan/strutil.h>
56 #include <epan/conversation.h>
58 #include "packet-afp.h"
60 /* The information in this module (AFP) comes from:
62 AFP 2.1 & 2.2.pdf contained in AppleShare_IP_6.3_SDK
63 available from http://www.apple.com
65 AFP3.0.pdf from http://www.apple.com
67 The netatalk source code by Wesley Craig & Adrian Sun
68 http://netatalk.sf.net
70 /* from netatalk/include/afp.h */
71 #define AFPTRANS_NONE 0
72 #define AFPTRANS_DDP (1 << 0)
73 #define AFPTRANS_TCP (1 << 1)
74 #define AFPTRANS_ALL (AFPTRANS_DDP | AFPTRANS_TCP)
77 #define AFPSRVRINFO_COPY (1<<0) /* supports copyfile */
78 #define AFPSRVRINFO_PASSWD (1<<1) /* supports change password */
79 #define AFPSRVRINFO_NOSAVEPASSWD (1<<2) /* don't allow save password */
80 #define AFPSRVRINFO_SRVMSGS (1<<3) /* supports server messages */
81 #define AFPSRVRINFO_SRVSIGNATURE (1<<4) /* supports server signature */
82 #define AFPSRVRINFO_TCPIP (1<<5) /* supports tcpip */
83 #define AFPSRVRINFO_SRVNOTIFY (1<<6) /* supports server notifications */
84 #define AFPSRVRINFO_FASTBOZO (1<<15) /* fast copying */
86 /* AFP Attention Codes -- 4 bits */
87 #define AFPATTN_SHUTDOWN (1 << 15) /* shutdown/disconnect */
88 #define AFPATTN_CRASH (1 << 14) /* server crashed */
89 #define AFPATTN_MESG (1 << 13) /* server has message */
90 #define AFPATTN_NORECONNECT (1 << 12) /* don't reconnect */
91 /* server notification */
92 #define AFPATTN_NOTIFY (AFPATTN_MESG | AFPATTN_NORECONNECT)
94 /* extended bitmap -- 12 bits. volchanged is only useful w/ a server
95 * notification, and time is only useful for shutdown. */
96 #define AFPATTN_VOLCHANGED (1 << 0) /* volume has changed */
97 #define AFPATTN_TIME(x) ((x) & 0xfff) /* time in minutes */
100 #define AFP_BYTELOCK 1
101 #define AFP_CLOSEVOL 2
102 #define AFP_CLOSEDIR 3
103 #define AFP_CLOSEFORK 4
104 #define AFP_COPYFILE 5
105 #define AFP_CREATEDIR 6
106 #define AFP_CREATEFILE 7
108 #define AFP_ENUMERATE 9
110 #define AFP_FLUSHFORK 11
111 #define AFP_GETFORKPARAM 14
112 #define AFP_GETSRVINFO 15
113 #define AFP_GETSRVPARAM 16
114 #define AFP_GETVOLPARAM 17
116 #define AFP_LOGINCONT 19
117 #define AFP_LOGOUT 20
119 #define AFP_MAPNAME 22
121 #define AFP_OPENVOL 24
122 #define AFP_OPENDIR 25
123 #define AFP_OPENFORK 26
125 #define AFP_RENAME 28
126 #define AFP_SETDIRPARAM 29
127 #define AFP_SETFILEPARAM 30
128 #define AFP_SETFORKPARAM 31
129 #define AFP_SETVOLPARAM 32
131 #define AFP_GETFLDRPARAM 34
132 #define AFP_SETFLDRPARAM 35
133 #define AFP_CHANGEPW 36
134 #define AFP_GETSRVRMSG 38
135 #define AFP_CREATEID 39
136 #define AFP_DELETEID 40
137 #define AFP_RESOLVEID 41
138 #define AFP_EXCHANGEFILE 42
139 #define AFP_CATSEARCH 43
140 #define AFP_OPENDT 48
141 #define AFP_CLOSEDT 49
142 #define AFP_GETICON 51
143 #define AFP_GTICNINFO 52
144 #define AFP_ADDAPPL 53
145 #define AFP_RMVAPPL 54
146 #define AFP_GETAPPL 55
147 #define AFP_ADDCMT 56
148 #define AFP_RMVCMT 57
149 #define AFP_GETCMT 58
150 #define AFP_ADDICON 192
152 /* ----------------------------- */
153 static int proto_afp = -1;
154 static int hf_afp_requestid = -1;
155 static int hf_afp_code = -1;
156 static int hf_afp_length = -1;
157 static int hf_afp_reserved = -1;
159 static int hf_afp_command = -1; /* CommandCode */
160 static int hf_afp_AFPVersion = -1;
161 static int hf_afp_UAM = -1;
162 static int hf_afp_user = -1;
163 static int hf_afp_passwd = -1;
164 static int hf_afp_pad = -1;
166 static int hf_afp_vol_bitmap = -1;
167 static int hf_afp_bitmap_offset = -1;
168 static int hf_afp_vol_id = -1;
169 static int hf_afp_vol_attribute = -1;
170 static int hf_afp_vol_name = -1;
171 static int hf_afp_vol_signature = -1;
172 static int hf_afp_vol_creation_date = -1;
173 static int hf_afp_vol_modification_date = -1;
174 static int hf_afp_vol_backup_date = -1;
175 static int hf_afp_vol_bytes_free = -1;
176 static int hf_afp_vol_bytes_total = -1;
177 static int hf_afp_vol_ex_bytes_free = -1;
178 static int hf_afp_vol_ex_bytes_total = -1;
179 static int hf_afp_vol_block_size = -1;
182 static int hf_afp_comment = -1;
183 static int hf_afp_file_creator = -1;
184 static int hf_afp_file_type = -1;
185 static int hf_afp_icon_type = -1;
186 static int hf_afp_icon_length = -1;
187 static int hf_afp_icon_tag = -1;
188 static int hf_afp_icon_index = -1;
189 static int hf_afp_appl_index = -1;
190 static int hf_afp_appl_tag = -1;
192 static int hf_afp_did = -1;
193 static int hf_afp_file_id = -1;
194 static int hf_afp_file_DataForkLen = -1;
195 static int hf_afp_file_RsrcForkLen = -1;
196 static int hf_afp_file_ExtDataForkLen = -1;
197 static int hf_afp_file_ExtRsrcForkLen = -1;
198 static int hf_afp_file_UnixPrivs = -1;
200 static int hf_afp_dir_bitmap = -1;
201 static int hf_afp_dir_offspring = -1;
202 static int hf_afp_dir_OwnerID = -1;
203 static int hf_afp_dir_GroupID = -1;
205 static int hf_afp_file_bitmap = -1;
206 static int hf_afp_req_count = -1;
207 static int hf_afp_start_index = -1;
208 static int hf_afp_max_reply_size = -1;
209 static int hf_afp_file_flag = -1;
210 static int hf_afp_create_flag = -1;
211 static int hf_afp_struct_size = -1;
213 static int hf_afp_creation_date = -1;
214 static int hf_afp_modification_date = -1;
215 static int hf_afp_backup_date = -1;
216 static int hf_afp_finder_info = -1;
218 static int hf_afp_path_type = -1;
219 static int hf_afp_path_len = -1;
220 static int hf_afp_path_name = -1;
222 static int hf_afp_flag = -1;
223 static int hf_afp_dt_ref = -1;
224 static int hf_afp_ofork = -1;
225 static int hf_afp_ofork_len = -1;
226 static int hf_afp_offset = -1;
227 static int hf_afp_rw_count = -1;
228 static int hf_afp_last_written = -1;
229 static int hf_afp_actual_count = -1;
231 static int hf_afp_fork_type = -1;
232 static int hf_afp_access_mode = -1;
233 static int hf_afp_access_read = -1;
234 static int hf_afp_access_write = -1;
235 static int hf_afp_access_deny_read = -1;
236 static int hf_afp_access_deny_write = -1;
238 static gint hf_afp_lock_op = -1;
239 static gint hf_afp_lock_from = -1;
240 static gint hf_afp_lock_offset = -1;
241 static gint hf_afp_lock_len = -1;
242 static gint hf_afp_lock_range_start = -1;
244 static gint ett_afp = -1;
246 static gint ett_afp_vol_attribute = -1;
247 static gint ett_afp_enumerate = -1;
248 static gint ett_afp_enumerate_line = -1;
249 static gint ett_afp_access_mode = -1;
251 static gint ett_afp_vol_bitmap = -1;
252 static gint ett_afp_dir_bitmap = -1;
253 static gint ett_afp_dir_attribute = -1;
254 static gint ett_afp_file_attribute = -1;
255 static gint ett_afp_file_bitmap = -1;
256 static gint ett_afp_path_name = -1;
257 static gint ett_afp_lock_flags = -1;
258 static gint ett_afp_dir_ar = -1;
260 static dissector_handle_t afp_handle;
261 static dissector_handle_t data_handle;
263 static const value_string vol_signature_vals[] = {
265 {2, "Fixed Directory ID"},
266 {3, "Variable Directory ID (deprecated)"},
270 static const value_string CommandCode_vals[] = {
271 {AFP_BYTELOCK, "afpByteRangeLock" },
272 {AFP_CLOSEVOL, "afpVolClose" },
273 {AFP_CLOSEDIR, "afpDirClose" },
274 {AFP_CLOSEFORK, "afpForkClose" },
275 {AFP_COPYFILE, "afpCopyFile" },
276 {AFP_CREATEDIR, "afpDirCreate" },
277 {AFP_CREATEFILE, "afpFileCreate" },
278 {AFP_DELETE, "afpDelete" },
279 {AFP_ENUMERATE, "afpEnumerate" },
280 {AFP_FLUSH, "afpFlush" },
281 {AFP_FLUSHFORK, "afpForkFlush" },
282 {AFP_GETFORKPARAM, "afpGetForkParms" },
283 {AFP_GETSRVINFO, "afpGetSInfo" },
284 {AFP_GETSRVPARAM, "afpGetSParms" },
285 {AFP_GETVOLPARAM, "afpGetVolParms" },
286 {AFP_LOGIN, "afpLogin" },
287 {AFP_LOGINCONT, "afpContLogin" },
288 {AFP_LOGOUT, "afpLogout" },
289 {AFP_MAPID, "afpMapID" },
290 {AFP_MAPNAME, "afpMapName" },
291 {AFP_MOVE, "afpMove" },
292 {AFP_OPENVOL, "afpOpenVol" },
293 {AFP_OPENDIR, "afpOpenDir" },
294 {AFP_OPENFORK, "afpOpenFork" },
295 {AFP_READ, "afpRead" },
296 {AFP_RENAME, "afpRename" },
297 {AFP_SETDIRPARAM, "afpSetDirParms" },
298 {AFP_SETFILEPARAM, "afpSetFileParms" },
299 {AFP_SETFORKPARAM, "afpSetForkParms" },
300 {AFP_SETVOLPARAM, "afpSetVolParms" },
301 {AFP_WRITE, "afpWrite" },
302 {AFP_GETFLDRPARAM, "afpGetFlDrParms" },
303 {AFP_SETFLDRPARAM, "afpSetFlDrParms" },
304 {AFP_CHANGEPW, "afpChangePw" },
305 {AFP_GETSRVRMSG, "afpGetSrvrMsg" },
306 {AFP_CREATEID, "afpCreateID" },
307 {AFP_DELETEID, "afpDeleteID" },
308 {AFP_RESOLVEID, "afpResolveID" },
309 {AFP_EXCHANGEFILE, "afpExchangeFiles" },
310 {AFP_CATSEARCH, "afpCatSearch" },
311 {AFP_OPENDT, "afpDTOpen" },
312 {AFP_CLOSEDT, "afpDTClose" },
313 {AFP_GETICON, "afpGetIcon" },
314 {AFP_GTICNINFO, "afpGtIcnInfo" },
315 {AFP_ADDAPPL, "afpAddAPPL" },
316 {AFP_RMVAPPL, "afpRmvAPPL" },
317 {AFP_GETAPPL, "afpGetAPPL" },
318 {AFP_ADDCMT, "afpAddCmt" },
319 {AFP_RMVCMT, "afpRmvCmt" },
320 {AFP_GETCMT, "afpGetCmt" },
321 {AFP_ADDICON, "afpAddIcon" },
327 from Apple AFP3.0.pdf
330 #define kFPVolAttributeBit (1 << 0)
331 #define kFPVolSignatureBit (1 << 1)
332 #define kFPVolCreateDateBit (1 << 2)
333 #define kFPVolModDateBit (1 << 3)
334 #define kFPVolBackupDateBit (1 << 4)
335 #define kFPVolIDBit (1 << 5)
336 #define kFPVolBytesFreeBit (1 << 6)
337 #define kFPVolBytesTotalBit (1 << 7)
338 #define kFPVolNameBit (1 << 8)
339 #define kFPVolExtBytesFreeBit (1 << 9)
340 #define kFPVolExtBytesTotalBit (1 << 10)
341 #define kFPVolBlockSizeBit (1 << 11)
343 static int hf_afp_vol_bitmap_Attributes = -1;
344 static int hf_afp_vol_bitmap_Signature = -1;
345 static int hf_afp_vol_bitmap_CreateDate = -1;
346 static int hf_afp_vol_bitmap_ModDate = -1;
347 static int hf_afp_vol_bitmap_BackupDate = -1;
348 static int hf_afp_vol_bitmap_ID = -1;
349 static int hf_afp_vol_bitmap_BytesFree = -1;
350 static int hf_afp_vol_bitmap_BytesTotal = -1;
351 static int hf_afp_vol_bitmap_Name = -1;
352 static int hf_afp_vol_bitmap_ExtBytesFree = -1;
353 static int hf_afp_vol_bitmap_ExtBytesTotal = -1;
354 static int hf_afp_vol_bitmap_BlockSize = -1;
356 static int hf_afp_vol_attribute_ReadOnly = -1;
357 static int hf_afp_vol_attribute_HasVolumePassword = -1;
358 static int hf_afp_vol_attribute_SupportsFileIDs = -1;
359 static int hf_afp_vol_attribute_SupportsCatSearch = -1;
360 static int hf_afp_vol_attribute_SupportsBlankAccessPrivs = -1;
361 static int hf_afp_vol_attribute_SupportsUnixPrivs = -1;
362 static int hf_afp_vol_attribute_SupportsUTF8Names = -1;
364 static int hf_afp_dir_bitmap_Attributes = -1;
365 static int hf_afp_dir_bitmap_ParentDirID = -1;
366 static int hf_afp_dir_bitmap_CreateDate = -1;
367 static int hf_afp_dir_bitmap_ModDate = -1;
368 static int hf_afp_dir_bitmap_BackupDate = -1;
369 static int hf_afp_dir_bitmap_FinderInfo = -1;
370 static int hf_afp_dir_bitmap_LongName = -1;
371 static int hf_afp_dir_bitmap_ShortName = -1;
372 static int hf_afp_dir_bitmap_NodeID = -1;
373 static int hf_afp_dir_bitmap_OffspringCount = -1;
374 static int hf_afp_dir_bitmap_OwnerID = -1;
375 static int hf_afp_dir_bitmap_GroupID = -1;
376 static int hf_afp_dir_bitmap_AccessRights = -1;
377 static int hf_afp_dir_bitmap_UTF8Name = -1;
378 static int hf_afp_dir_bitmap_UnixPrivs = -1;
380 static int hf_afp_dir_attribute_Invisible = -1;
381 static int hf_afp_dir_attribute_IsExpFolder = -1;
383 static int hf_afp_dir_attribute_System = -1;
384 static int hf_afp_dir_attribute_Mounted = -1;
385 static int hf_afp_dir_attribute_InExpFolder = -1;
387 static int hf_afp_dir_attribute_BackUpNeeded = -1;
388 static int hf_afp_dir_attribute_RenameInhibit = -1;
389 static int hf_afp_dir_attribute_DeleteInhibit = -1;
390 static int hf_afp_dir_attribute_SetClear = -1;
392 static int hf_afp_file_bitmap_Attributes = -1;
393 static int hf_afp_file_bitmap_ParentDirID = -1;
394 static int hf_afp_file_bitmap_CreateDate = -1;
395 static int hf_afp_file_bitmap_ModDate = -1;
396 static int hf_afp_file_bitmap_BackupDate = -1;
397 static int hf_afp_file_bitmap_FinderInfo = -1;
398 static int hf_afp_file_bitmap_LongName = -1;
399 static int hf_afp_file_bitmap_ShortName = -1;
400 static int hf_afp_file_bitmap_NodeID = -1;
401 static int hf_afp_file_bitmap_DataForkLen = -1;
402 static int hf_afp_file_bitmap_RsrcForkLen = -1;
403 static int hf_afp_file_bitmap_ExtDataForkLen = -1;
404 static int hf_afp_file_bitmap_LaunchLimit = -1;
406 static int hf_afp_file_bitmap_UTF8Name = -1;
407 static int hf_afp_file_bitmap_ExtRsrcForkLen = -1;
408 static int hf_afp_file_bitmap_UnixPrivs = -1;
410 static int hf_afp_file_attribute_Invisible = -1;
411 static int hf_afp_file_attribute_MultiUser = -1;
412 static int hf_afp_file_attribute_System = -1;
413 static int hf_afp_file_attribute_DAlreadyOpen = -1;
414 static int hf_afp_file_attribute_RAlreadyOpen = -1;
415 static int hf_afp_file_attribute_WriteInhibit = -1;
416 static int hf_afp_file_attribute_BackUpNeeded = -1;
417 static int hf_afp_file_attribute_RenameInhibit = -1;
418 static int hf_afp_file_attribute_DeleteInhibit = -1;
419 static int hf_afp_file_attribute_CopyProtect = -1;
420 static int hf_afp_file_attribute_SetClear = -1;
422 static const value_string vol_bitmap_vals[] = {
423 {kFPVolAttributeBit, "VolAttribute"},
424 {kFPVolSignatureBit, "VolSignature"},
425 {kFPVolCreateDateBit, "VolCreateDate"},
426 {kFPVolModDateBit, "VolModDate"},
427 {kFPVolBackupDateBit, "VolBackupDate"},
428 {kFPVolIDBit, "VolID"},
429 {kFPVolBytesFreeBit, "VolBytesFree"},
430 {kFPVolBytesTotalBit, "VolBytesTotal"},
431 {kFPVolNameBit, "VolNameBit"},
432 {kFPVolExtBytesFreeBit, "VolExtBytesFree"},
433 {kFPVolExtBytesTotalBit, "VolExtBytesTotal"},
434 {kFPVolBlockSizeBit, "VolBlockSize"},
437 static const value_string flag_vals[] = {
442 static const value_string path_type_vals[] = {
445 {3, "Unicode names" },
449 volume attribute from Apple AFP3.0.pdf
452 #define kReadOnly (1 << 0)
453 #define kHasVolumePassword (1 << 1)
454 #define kSupportsFileIDs (1 << 2)
455 #define kSupportsCatSearch (1 << 3)
456 #define kSupportsBlankAccessPrivs (1 << 4)
457 #define kSupportsUnixPrivs (1 << 5)
458 #define kSupportsUTF8Names (1 << 6)
461 directory bitmap from Apple AFP3.0.pdf
464 #define kFPAttributeBit (1 << 0)
465 #define kFPParentDirIDBit (1 << 1)
466 #define kFPCreateDateBit (1 << 2)
467 #define kFPModDateBit (1 << 3)
468 #define kFPBackupDateBit (1 << 4)
469 #define kFPFinderInfoBit (1 << 5)
470 #define kFPLongNameBit (1 << 6)
471 #define kFPShortNameBit (1 << 7)
472 #define kFPNodeIDBit (1 << 8)
473 #define kFPOffspringCountBit (1 << 9)
474 #define kFPOwnerIDBit (1 << 10)
475 #define kFPGroupIDBit (1 << 11)
476 #define kFPAccessRightsBit (1 << 12)
477 #define kFPUTF8NameBit (1 << 13)
478 #define kFPUnixPrivsBit (1 << 14)
481 directory Access Rights parameter AFP3.0.pdf
485 #define AR_O_SEARCH (1 << 0) /* owner has search access */
486 #define AR_O_READ (1 << 1) /* owner has read access */
487 #define AR_O_WRITE (1 << 2) /* owner has write access */
489 #define AR_G_SEARCH (1 << 8) /* group has search access */
490 #define AR_G_READ (1 << 9) /* group has read access */
491 #define AR_G_WRITE (1 << 10) /* group has write access */
493 #define AR_E_SEARCH (1 << 16) /* everyone has search access */
494 #define AR_E_READ (1 << 17) /* everyone has read access */
495 #define AR_E_WRITE (1 << 18) /* everyone has write access */
497 #define AR_U_SEARCH (1 << 24) /* user has search access */
498 #define AR_U_READ (1 << 25) /* user has read access */
499 #define AR_U_WRITE (1 << 26) /* user has write access */
501 #define AR_BLANK (1 << 28) /* Blank Access Privileges (use parent dir privileges) */
502 #define AR_U_OWN (1 << 31) /* user is the owner */
504 static int hf_afp_dir_ar = -1;
505 static int hf_afp_dir_ar_o_search = -1;
506 static int hf_afp_dir_ar_o_read = -1;
507 static int hf_afp_dir_ar_o_write = -1;
508 static int hf_afp_dir_ar_g_search = -1;
509 static int hf_afp_dir_ar_g_read = -1;
510 static int hf_afp_dir_ar_g_write = -1;
511 static int hf_afp_dir_ar_e_search = -1;
512 static int hf_afp_dir_ar_e_read = -1;
513 static int hf_afp_dir_ar_e_write = -1;
514 static int hf_afp_dir_ar_u_search = -1;
515 static int hf_afp_dir_ar_u_read = -1;
516 static int hf_afp_dir_ar_u_write = -1;
517 static int hf_afp_dir_ar_blank = -1;
518 static int hf_afp_dir_ar_u_own = -1;
521 file bitmap AFP3.0.pdf
524 kFPAttributeBit (bit 0)
525 kFPParentDirIDBit (bit 1)
526 kFPCreateDateBit (bit 2)
527 kFPModDateBit (bit 3)
528 kFPBackupDateBit (bit 4)
529 kFPFinderInfoBit (bit 5)
530 kFPLongNameBit (bit 6)
531 kFPShortNameBit (bit 7)
534 kFPUTF8NameBit (bit 13)
537 #define kFPDataForkLenBit (1 << 9)
538 #define kFPRsrcForkLenBit (1 << 10)
539 #define kFPExtDataForkLenBit (1 << 11)
540 #define kFPLaunchLimitBit (1 << 12)
542 #define kFPExtRsrcForkLenBit (1 << 14)
543 #define kFPUnixPrivsBit_file (1 << 15) /* :( */
546 file attribute AFP3.0.pdf
549 #define kFPInvisibleBit (1 << 0)
550 #define kFPMultiUserBit (1 << 1)
551 #define kFPSystemBit (1 << 2)
552 #define kFPDAlreadyOpenBit (1 << 3)
553 #define kFPRAlreadyOpenBit (1 << 4)
554 #define kFPWriteInhibitBit (1 << 5)
555 #define kFPBackUpNeededBit (1 << 6)
556 #define kFPRenameInhibitBit (1 << 7)
557 #define kFPDeleteInhibitBit (1 << 8)
558 #define kFPCopyProtectBit (1 << 10)
559 #define kFPSetClearBit (1 << 15)
562 #define kIsExpFolder (1 << 1)
563 #define kMounted (1 << 3)
564 #define kInExpFolder (1 << 4)
566 #define hash_init_count 20
569 static gint afp_equal (gconstpointer v, gconstpointer v2);
570 static guint afp_hash (gconstpointer v);
572 static guint afp_packet_init_count = 200;
575 guint32 conversation;
583 static GHashTable *afp_request_hash = NULL;
584 static GMemChunk *afp_request_keys = NULL;
585 static GMemChunk *afp_request_vals = NULL;
588 static gint afp_equal (gconstpointer v, gconstpointer v2)
590 afp_request_key *val1 = (afp_request_key*)v;
591 afp_request_key *val2 = (afp_request_key*)v2;
593 if (val1->conversation == val2->conversation &&
594 val1->seq == val2->seq) {
600 static guint afp_hash (gconstpointer v)
602 afp_request_key *afp_key = (afp_request_key*)v;
606 /* --------------------------
608 #define PAD(x) { proto_tree_add_item(tree, hf_afp_pad, tvb, offset, x, FALSE); offset += x; }
611 decode_vol_bitmap (proto_tree *tree, tvbuff_t *tvb, gint offset)
613 proto_tree *sub_tree = NULL;
617 bitmap = tvb_get_ntohs(tvb, offset);
619 item = proto_tree_add_item(tree, hf_afp_vol_bitmap, tvb, offset, 2,FALSE);
620 sub_tree = proto_item_add_subtree(item, ett_afp_vol_bitmap);
623 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_Attributes, tvb, offset, 2,FALSE);
624 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_Signature, tvb, offset, 2,FALSE);
625 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_CreateDate, tvb, offset, 2,FALSE);
626 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_ModDate, tvb, offset, 2,FALSE);
627 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_BackupDate, tvb, offset, 2,FALSE);
628 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_ID, tvb, offset, 2,FALSE);
629 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_BytesFree, tvb, offset, 2,FALSE);
630 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_BytesTotal, tvb, offset, 2,FALSE);
631 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_Name, tvb, offset, 2,FALSE);
632 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_ExtBytesFree, tvb, offset, 2,FALSE);
633 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_ExtBytesTotal, tvb, offset, 2,FALSE);
634 proto_tree_add_item(sub_tree, hf_afp_vol_bitmap_BlockSize , tvb, offset, 2,FALSE);
639 /* -------------------------- */
641 decode_vol_attribute (proto_tree *tree, tvbuff_t *tvb, gint offset)
643 proto_tree *sub_tree = NULL;
647 bitmap = tvb_get_ntohs(tvb, offset);
649 item = proto_tree_add_item(tree, hf_afp_vol_attribute, tvb, offset, 2,FALSE);
650 sub_tree = proto_item_add_subtree(item, ett_afp_vol_attribute);
652 proto_tree_add_item(sub_tree, hf_afp_vol_attribute_ReadOnly ,tvb, offset, 2,FALSE);
653 proto_tree_add_item(sub_tree, hf_afp_vol_attribute_HasVolumePassword ,tvb, offset, 2,FALSE);
654 proto_tree_add_item(sub_tree, hf_afp_vol_attribute_SupportsFileIDs ,tvb, offset, 2,FALSE);
655 proto_tree_add_item(sub_tree, hf_afp_vol_attribute_SupportsCatSearch ,tvb, offset, 2,FALSE);
656 proto_tree_add_item(sub_tree, hf_afp_vol_attribute_SupportsBlankAccessPrivs,tvb, offset, 2,FALSE);
657 proto_tree_add_item(sub_tree, hf_afp_vol_attribute_SupportsUnixPrivs ,tvb, offset, 2,FALSE);
658 proto_tree_add_item(sub_tree, hf_afp_vol_attribute_SupportsUTF8Names ,tvb, offset, 2,FALSE);
663 /* --------------------------
664 cf AFP3.0.pdf page 38
665 date are number of seconds from 12:00am on 01.01.2000 GMT
666 backup : 0x8000000 not set
667 from netatalk adouble.h
669 #define DATE_NOT_SET 0x80000000
670 #define AD_DATE_DELTA 946684800
671 #define AD_DATE_TO_UNIX(x) (x + AD_DATE_DELTA)
673 print_date(proto_tree *tree,int id, tvbuff_t *tvb, gint offset)
675 time_t date = tvb_get_ntohl(tvb, offset);
678 tv.secs = AD_DATE_TO_UNIX(date);
679 proto_tree_add_time(tree, id, tvb, offset, 4, &tv);
684 /* -------------------------- */
686 parse_vol_bitmap (proto_tree *tree, tvbuff_t *tvb, gint offset, guint16 bitmap)
690 if ((bitmap & kFPVolAttributeBit)) {
691 decode_vol_attribute(tree,tvb,offset);
694 if ((bitmap & kFPVolSignatureBit)) {
695 proto_tree_add_item(tree, hf_afp_vol_signature,tvb, offset, 2, FALSE);
698 if ((bitmap & kFPVolCreateDateBit)) {
699 print_date(tree, hf_afp_vol_creation_date,tvb, offset);
702 if ((bitmap & kFPVolModDateBit)) {
703 print_date(tree, hf_afp_vol_modification_date,tvb, offset);
706 if ((bitmap & kFPVolBackupDateBit)) {
707 print_date(tree, hf_afp_vol_backup_date,tvb, offset);
710 if ((bitmap & kFPVolIDBit)) {
711 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2,FALSE);
714 if ((bitmap & kFPVolBytesFreeBit)) {
715 proto_tree_add_item(tree, hf_afp_vol_bytes_free,tvb, offset, 4, FALSE);
718 if ((bitmap & kFPVolBytesTotalBit)) {
719 proto_tree_add_item(tree, hf_afp_vol_bytes_total,tvb, offset, 4, FALSE);
722 if ((bitmap & kFPVolNameBit)) {
723 nameoff = tvb_get_ntohs(tvb, offset);
724 proto_tree_add_item(tree, hf_afp_bitmap_offset,tvb, offset, 2, FALSE);
728 if ((bitmap & kFPVolExtBytesFreeBit)) {
729 proto_tree_add_item(tree, hf_afp_vol_ex_bytes_free,tvb, offset, 8, FALSE);
732 if ((bitmap & kFPVolExtBytesTotalBit)) {
733 proto_tree_add_item(tree, hf_afp_vol_ex_bytes_total,tvb, offset, 8, FALSE);
736 if ((bitmap & kFPVolBlockSizeBit)) {
737 proto_tree_add_item(tree, hf_afp_vol_block_size,tvb, offset, 4, FALSE);
743 len = tvb_get_guint8(tvb, offset);
744 proto_tree_add_item(tree, hf_afp_vol_name, tvb, offset, 1,FALSE);
751 /* -------------------------- */
753 decode_file_bitmap (proto_tree *tree, tvbuff_t *tvb, gint offset)
755 proto_tree *sub_tree = NULL;
759 bitmap = tvb_get_ntohs(tvb, offset);
761 item = proto_tree_add_item(tree, hf_afp_file_bitmap, tvb, offset, 2,FALSE);
762 sub_tree = proto_item_add_subtree(item, ett_afp_file_bitmap);
764 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_Attributes , tvb, offset, 2,FALSE);
765 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_ParentDirID , tvb, offset, 2,FALSE);
766 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_CreateDate , tvb, offset, 2,FALSE);
767 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_ModDate , tvb, offset, 2,FALSE);
768 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_BackupDate , tvb, offset, 2,FALSE);
769 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_FinderInfo , tvb, offset, 2,FALSE);
770 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_LongName , tvb, offset, 2,FALSE);
771 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_ShortName , tvb, offset, 2,FALSE);
772 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_NodeID , tvb, offset, 2,FALSE);
774 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_DataForkLen , tvb, offset, 2,FALSE);
775 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_RsrcForkLen , tvb, offset, 2,FALSE);
776 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_ExtDataForkLen , tvb, offset, 2,FALSE);
777 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_LaunchLimit , tvb, offset, 2,FALSE);
778 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_UTF8Name , tvb, offset, 2,FALSE);
780 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_ExtRsrcForkLen , tvb, offset, 2,FALSE);
781 proto_tree_add_item(sub_tree, hf_afp_file_bitmap_UnixPrivs , tvb, offset, 2,FALSE);
786 /* -------------------------- */
788 decode_file_attribute(proto_tree *tree, tvbuff_t *tvb, gint offset, int shared)
790 proto_tree *sub_tree = NULL;
794 attribute = tvb_get_ntohs(tvb, offset);
796 item = proto_tree_add_text(tree, tvb, offset, 2,
797 "file Attributes: 0x%04x", attribute);
798 sub_tree = proto_item_add_subtree(item, ett_afp_file_attribute);
800 proto_tree_add_item(sub_tree, hf_afp_file_attribute_Invisible , tvb, offset, 2,FALSE);
802 proto_tree_add_item(sub_tree, hf_afp_file_attribute_MultiUser , tvb, offset, 2,FALSE);
804 proto_tree_add_item(sub_tree, hf_afp_file_attribute_System , tvb, offset, 2,FALSE);
807 proto_tree_add_item(sub_tree, hf_afp_file_attribute_DAlreadyOpen , tvb, offset, 2,FALSE);
808 proto_tree_add_item(sub_tree, hf_afp_file_attribute_RAlreadyOpen , tvb, offset, 2,FALSE);
809 proto_tree_add_item(sub_tree, hf_afp_file_attribute_WriteInhibit , tvb, offset, 2,FALSE);
811 proto_tree_add_item(sub_tree, hf_afp_file_attribute_BackUpNeeded , tvb, offset, 2,FALSE);
812 proto_tree_add_item(sub_tree, hf_afp_file_attribute_RenameInhibit, tvb, offset, 2,FALSE);
813 proto_tree_add_item(sub_tree, hf_afp_file_attribute_DeleteInhibit, tvb, offset, 2,FALSE);
816 proto_tree_add_item(sub_tree, hf_afp_file_attribute_CopyProtect , tvb, offset, 2,FALSE);
818 proto_tree_add_item(sub_tree, hf_afp_file_attribute_SetClear , tvb, offset, 2,FALSE);
823 /* -------------------------- */
825 parse_file_bitmap (proto_tree *tree, tvbuff_t *tvb, gint offset, guint16 bitmap, int shared)
827 guint16 lnameoff = 0;
828 guint16 snameoff = 0;
829 guint16 unameoff = 0;
832 gint org_offset = offset;
834 if ((bitmap & kFPAttributeBit)) {
835 decode_file_attribute(tree, tvb, offset, shared);
838 if ((bitmap & kFPParentDirIDBit)) {
839 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
842 if ((bitmap & kFPCreateDateBit)) {
843 print_date(tree, hf_afp_creation_date,tvb, offset);
846 if ((bitmap & kFPModDateBit)) {
847 print_date(tree, hf_afp_modification_date,tvb, offset);
850 if ((bitmap & kFPBackupDateBit)) {
851 print_date(tree, hf_afp_backup_date,tvb, offset);
854 if ((bitmap & kFPFinderInfoBit)) {
855 proto_tree_add_item(tree, hf_afp_finder_info,tvb, offset, 32, FALSE);
858 if ((bitmap & kFPLongNameBit)) {
862 lnameoff = tvb_get_ntohs(tvb, offset);
864 tp_ofs = lnameoff +org_offset;
865 proto_tree_add_item(tree, hf_afp_bitmap_offset,tvb, offset, 2, FALSE);
866 len = tvb_get_guint8(tvb, tp_ofs);
867 proto_tree_add_item(tree, hf_afp_path_len, tvb, tp_ofs, 1,FALSE);
869 proto_tree_add_item(tree, hf_afp_path_name, tvb, tp_ofs, len,FALSE);
871 max_offset = (tp_ofs >max_offset)?tp_ofs:max_offset;
875 if ((bitmap & kFPShortNameBit)) {
876 snameoff = tvb_get_ntohs(tvb, offset);
877 proto_tree_add_item(tree, hf_afp_bitmap_offset,tvb, offset, 2, FALSE);
880 if ((bitmap & kFPNodeIDBit)) {
881 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4,FALSE);
885 if ((bitmap & kFPDataForkLenBit)) {
886 proto_tree_add_item(tree, hf_afp_file_DataForkLen, tvb, offset, 4,FALSE);
890 if ((bitmap & kFPRsrcForkLenBit)) {
891 proto_tree_add_item(tree, hf_afp_file_RsrcForkLen, tvb, offset, 4,FALSE);
895 if ((bitmap & kFPExtDataForkLenBit)) {
896 proto_tree_add_item(tree, hf_afp_file_ExtDataForkLen, tvb, offset, 8,FALSE);
900 if ((bitmap & kFPLaunchLimitBit)) {
904 if ((bitmap & kFPUTF8NameBit)) {
908 if ((bitmap & kFPExtRsrcForkLenBit)) {
909 proto_tree_add_item(tree, hf_afp_file_ExtRsrcForkLen, tvb, offset, 8,FALSE);
913 if ((bitmap & kFPUnixPrivsBit_file)) {
914 proto_tree_add_item(tree, hf_afp_file_UnixPrivs, tvb, offset, 4,FALSE);
918 return (max_offset)?max_offset:offset;
921 /* -------------------------- */
923 decode_dir_bitmap (proto_tree *tree, tvbuff_t *tvb, gint offset)
925 proto_tree *sub_tree = NULL;
929 bitmap = tvb_get_ntohs(tvb, offset);
931 item = proto_tree_add_item(tree, hf_afp_dir_bitmap, tvb, offset, 2,FALSE);
932 sub_tree = proto_item_add_subtree(item, ett_afp_dir_bitmap);
935 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_Attributes , tvb, offset, 2,FALSE);
936 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_ParentDirID , tvb, offset, 2,FALSE);
937 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_CreateDate , tvb, offset, 2,FALSE);
938 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_ModDate , tvb, offset, 2,FALSE);
939 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_BackupDate , tvb, offset, 2,FALSE);
940 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_FinderInfo , tvb, offset, 2,FALSE);
941 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_LongName , tvb, offset, 2,FALSE);
942 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_ShortName , tvb, offset, 2,FALSE);
943 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_NodeID , tvb, offset, 2,FALSE);
944 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_OffspringCount , tvb, offset, 2,FALSE);
945 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_OwnerID , tvb, offset, 2,FALSE);
946 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_GroupID , tvb, offset, 2,FALSE);
947 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_AccessRights , tvb, offset, 2,FALSE);
948 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_UTF8Name , tvb, offset, 2,FALSE);
949 proto_tree_add_item(sub_tree, hf_afp_dir_bitmap_UnixPrivs , tvb, offset, 2,FALSE);
954 /* -------------------------- */
956 decode_dir_attribute(proto_tree *tree, tvbuff_t *tvb, gint offset)
958 proto_tree *sub_tree = NULL;
962 attribute = tvb_get_ntohs(tvb, offset);
964 item = proto_tree_add_text(tree, tvb, offset, 2,
965 "dir Attributes: 0x%04x", attribute);
966 sub_tree = proto_item_add_subtree(item, ett_afp_dir_attribute);
968 proto_tree_add_item(sub_tree, hf_afp_dir_attribute_Invisible , tvb, offset, 2,FALSE);
969 proto_tree_add_item(sub_tree, hf_afp_dir_attribute_IsExpFolder , tvb, offset, 2,FALSE);
970 proto_tree_add_item(sub_tree, hf_afp_dir_attribute_System , tvb, offset, 2,FALSE);
971 proto_tree_add_item(sub_tree, hf_afp_dir_attribute_Mounted , tvb, offset, 2,FALSE);
972 proto_tree_add_item(sub_tree, hf_afp_dir_attribute_InExpFolder , tvb, offset, 2,FALSE);
973 proto_tree_add_item(sub_tree, hf_afp_dir_attribute_BackUpNeeded , tvb, offset, 2,FALSE);
974 proto_tree_add_item(sub_tree, hf_afp_dir_attribute_RenameInhibit, tvb, offset, 2,FALSE);
975 proto_tree_add_item(sub_tree, hf_afp_dir_attribute_DeleteInhibit, tvb, offset, 2,FALSE);
980 /* -------------------------- */
982 parse_dir_bitmap (proto_tree *tree, tvbuff_t *tvb, gint offset, guint16 bitmap)
984 guint16 lnameoff = 0;
985 guint16 snameoff = 0;
986 guint16 unameoff = 0;
989 gint org_offset = offset;
991 if ((bitmap & kFPAttributeBit)) {
992 decode_dir_attribute(tree, tvb, offset);
995 if ((bitmap & kFPParentDirIDBit)) {
996 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
999 if ((bitmap & kFPCreateDateBit)) {
1000 print_date(tree, hf_afp_creation_date,tvb, offset);
1003 if ((bitmap & kFPModDateBit)) {
1004 print_date(tree, hf_afp_modification_date,tvb, offset);
1007 if ((bitmap & kFPBackupDateBit)) {
1008 print_date(tree, hf_afp_backup_date,tvb, offset);
1011 if ((bitmap & kFPFinderInfoBit)) {
1012 proto_tree_add_item(tree, hf_afp_finder_info,tvb, offset, 32, FALSE);
1015 if ((bitmap & kFPLongNameBit)) {
1018 lnameoff = tvb_get_ntohs(tvb, offset);
1020 tp_ofs = lnameoff +org_offset;
1021 proto_tree_add_item(tree, hf_afp_bitmap_offset,tvb, offset, 2, FALSE);
1022 len = tvb_get_guint8(tvb, tp_ofs);
1023 proto_tree_add_item(tree, hf_afp_path_len, tvb, tp_ofs, 1,FALSE);
1025 proto_tree_add_item(tree, hf_afp_path_name, tvb, tp_ofs, len,FALSE);
1027 max_offset = (tp_ofs >max_offset)?tp_ofs:max_offset;
1031 if ((bitmap & kFPShortNameBit)) {
1032 snameoff = tvb_get_ntohs(tvb, offset);
1033 proto_tree_add_item(tree, hf_afp_bitmap_offset,tvb, offset, 2, FALSE);
1036 if ((bitmap & kFPNodeIDBit)) {
1037 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4,FALSE);
1040 if ((bitmap & kFPOffspringCountBit)) {
1041 proto_tree_add_item(tree, hf_afp_dir_offspring, tvb, offset, 2,FALSE);
1042 offset += 2; /* error in AFP3.0.pdf */
1044 if ((bitmap & kFPOwnerIDBit)) {
1045 proto_tree_add_item(tree, hf_afp_dir_OwnerID, tvb, offset, 4, FALSE);
1048 if ((bitmap & kFPGroupIDBit)) {
1049 proto_tree_add_item(tree, hf_afp_dir_GroupID, tvb, offset, 4, FALSE);
1052 if ((bitmap & kFPAccessRightsBit)) {
1053 proto_tree *sub_tree = NULL;
1057 item = proto_tree_add_item(tree, hf_afp_dir_ar, tvb, offset, 4, FALSE);
1058 sub_tree = proto_item_add_subtree(item, ett_afp_dir_ar);
1060 proto_tree_add_item(sub_tree, hf_afp_dir_ar_o_search, tvb, offset, 4, FALSE);
1061 proto_tree_add_item(sub_tree, hf_afp_dir_ar_o_read , tvb, offset, 4, FALSE);
1062 proto_tree_add_item(sub_tree, hf_afp_dir_ar_o_write , tvb, offset, 4, FALSE);
1064 proto_tree_add_item(sub_tree, hf_afp_dir_ar_g_search, tvb, offset, 4, FALSE);
1065 proto_tree_add_item(sub_tree, hf_afp_dir_ar_g_read , tvb, offset, 4, FALSE);
1066 proto_tree_add_item(sub_tree, hf_afp_dir_ar_g_write , tvb, offset, 4, FALSE);
1068 proto_tree_add_item(sub_tree, hf_afp_dir_ar_e_search, tvb, offset, 4, FALSE);
1069 proto_tree_add_item(sub_tree, hf_afp_dir_ar_e_read , tvb, offset, 4, FALSE);
1070 proto_tree_add_item(sub_tree, hf_afp_dir_ar_e_write , tvb, offset, 4, FALSE);
1072 proto_tree_add_item(sub_tree, hf_afp_dir_ar_u_search, tvb, offset, 4, FALSE);
1073 proto_tree_add_item(sub_tree, hf_afp_dir_ar_u_read , tvb, offset, 4, FALSE);
1074 proto_tree_add_item(sub_tree, hf_afp_dir_ar_u_write , tvb, offset, 4, FALSE);
1076 proto_tree_add_item(sub_tree, hf_afp_dir_ar_blank , tvb, offset, 4, FALSE);
1077 proto_tree_add_item(sub_tree, hf_afp_dir_ar_u_own , tvb, offset, 4, FALSE);
1081 if ((bitmap & kFPUTF8NameBit)) {
1084 if ((bitmap & kFPUnixPrivsBit)) {
1087 return (max_offset)?max_offset:offset;
1090 /* -------------------------- */
1092 name_in_bitmap(tvbuff_t *tvb, gint *offset, guint16 bitmap)
1095 gint org_offset = *offset;
1101 if ((bitmap & kFPAttributeBit))
1103 if ((bitmap & kFPParentDirIDBit))
1105 if ((bitmap & kFPCreateDateBit))
1107 if ((bitmap & kFPModDateBit))
1109 if ((bitmap & kFPBackupDateBit))
1111 if ((bitmap & kFPFinderInfoBit))
1114 if ((bitmap & kFPLongNameBit)) {
1115 nameoff = tvb_get_ntohs(tvb, *offset);
1117 tp_ofs = nameoff +org_offset;
1118 len = tvb_get_guint8(tvb, tp_ofs);
1120 if (!(name = g_malloc(len +1)))
1122 tvb_memcpy(tvb, name, tp_ofs, len);
1131 /* -------------------------- */
1133 name_in_dbitmap(tvbuff_t *tvb, gint offset, guint16 bitmap)
1137 name = name_in_bitmap(tvb, &offset, bitmap);
1147 /* -------------------------- */
1149 name_in_fbitmap(tvbuff_t *tvb, gint offset, guint16 bitmap)
1153 name = name_in_bitmap(tvb, &offset, bitmap);
1163 /* -------------------------- */
1165 decode_vol_did(proto_tree *tree, tvbuff_t *tvb, gint offset)
1167 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2,FALSE);
1170 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
1175 /* -------------------------- */
1177 decode_vol_did_file_dir_bitmap (proto_tree *tree, tvbuff_t *tvb, gint offset)
1179 offset = decode_vol_did(tree, tvb, offset);
1181 decode_file_bitmap(tree, tvb, offset);
1184 decode_dir_bitmap(tree, tvb, offset);
1190 /* ------------------------
1191 * idea from packet-smb
1195 get_name(tvbuff_t *tvb, int offset, int type)
1197 static gchar str[3][256];
1202 len = tvb_get_guint8(tvb, offset);
1208 tvb_memcpy(tvb, (guint8 *)string, offset, len);
1210 /* FIXME should use something else as separator ?
1212 for (i = 0; i < len; i++) if (!string[i])
1216 strcpy(string, "error Unicode...,next time ");
1224 /* -------------------------- */
1226 decode_name_label (proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset, const gchar *label)
1231 proto_tree *sub_tree = NULL;
1234 type = tvb_get_guint8(tvb, offset);
1235 len = tvb_get_guint8(tvb, offset +1);
1236 name = get_name(tvb, offset +1, type);
1238 if (pinfo && check_col(pinfo->cinfo, COL_INFO)) {
1239 col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", name);
1243 item = proto_tree_add_text(tree, tvb, offset, len +2, label, name);
1244 sub_tree = proto_item_add_subtree(item, ett_afp_path_name);
1245 proto_tree_add_item( sub_tree, hf_afp_path_type, tvb, offset, 1,FALSE);
1247 proto_tree_add_item( sub_tree, hf_afp_path_len, tvb, offset, 1,FALSE);
1249 proto_tree_add_string(sub_tree, hf_afp_path_name, tvb, offset, len,name);
1257 /* -------------------------- */
1259 decode_name (proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset)
1261 return decode_name_label(tree, pinfo, tvb, offset, "Path: %s");
1264 /* ************************** */
1266 dissect_query_afp_open_vol(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1272 decode_vol_bitmap(tree, tvb, offset);
1275 len = tvb_get_guint8(tvb, offset);
1277 if (check_col(pinfo->cinfo, COL_INFO)) {
1279 rep = get_name(tvb, offset, 2);
1280 col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", rep);
1286 proto_tree_add_item(tree, hf_afp_vol_name, tvb, offset, 1,FALSE);
1289 len = tvb_reported_length_remaining(tvb,offset);
1291 /* optionnal password */
1292 proto_tree_add_item(tree, hf_afp_passwd, tvb, offset, 8,FALSE);
1298 /* -------------------------- */
1300 dissect_reply_afp_open_vol(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1306 bitmap = decode_vol_bitmap(tree, tvb, offset);
1308 offset = parse_vol_bitmap(tree, tvb, offset, bitmap);
1313 /* **************************
1314 next calls use the same format :
1322 dissect_query_afp_with_vol_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1329 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2,FALSE);
1334 /* ************************** */
1336 dissect_query_afp_open_fork(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1338 proto_tree *sub_tree = NULL;
1341 proto_tree_add_item(tree, hf_afp_fork_type, tvb, offset, 1,FALSE);
1344 offset = decode_vol_did(tree, tvb, offset);
1346 decode_file_bitmap(tree, tvb, offset);
1349 item = proto_tree_add_item(tree, hf_afp_access_mode, tvb, offset, 2,FALSE);
1350 sub_tree = proto_item_add_subtree(item, ett_afp_access_mode);
1352 proto_tree_add_item(sub_tree, hf_afp_access_read , tvb, offset, 2,FALSE);
1353 proto_tree_add_item(sub_tree, hf_afp_access_write , tvb, offset, 2,FALSE);
1354 proto_tree_add_item(sub_tree, hf_afp_access_deny_read , tvb, offset, 2,FALSE);
1355 proto_tree_add_item(sub_tree, hf_afp_access_deny_write, tvb, offset, 2,FALSE);
1359 offset = decode_name(tree, pinfo, tvb, offset);
1364 /* -------------------------- */
1366 dissect_reply_afp_open_fork(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1370 f_bitmap = decode_file_bitmap(tree, tvb, offset);
1373 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2,FALSE);
1376 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap,0);
1381 /* ************************** */
1383 dissect_query_afp_enumerate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1387 offset = decode_vol_did_file_dir_bitmap(tree, tvb, offset);
1389 proto_tree_add_item(tree, hf_afp_req_count, tvb, offset, 2,FALSE);
1392 proto_tree_add_item(tree, hf_afp_start_index, tvb, offset, 2,FALSE);
1395 proto_tree_add_item(tree, hf_afp_max_reply_size, tvb, offset, 2,FALSE);
1398 offset = decode_name(tree, pinfo, tvb, offset);
1403 /* -------------------------- */
1405 dissect_reply_afp_enumerate(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1407 proto_tree *sub_tree = NULL;
1418 f_bitmap = decode_file_bitmap(tree, tvb, offset);
1421 d_bitmap = decode_dir_bitmap(tree, tvb, offset);
1424 count = tvb_get_ntohs(tvb, offset);
1426 item = proto_tree_add_item(tree, hf_afp_req_count, tvb, offset, 2,FALSE);
1427 sub_tree = proto_item_add_subtree(item, ett_afp_enumerate);
1431 for (i = 0; i < count; i++) {
1434 size = tvb_get_guint8(tvb, offset);
1435 flags = tvb_get_guint8(tvb, offset +1);
1439 name = name_in_dbitmap(tvb, offset +2, d_bitmap);
1442 name = name_in_fbitmap(tvb, offset +2, f_bitmap);
1445 if (!(name = g_malloc(50))) { /* no memory ! */
1447 snprintf(name, 50,"line %d", i +1);
1449 item = proto_tree_add_text(sub_tree, tvb, offset, size, name);
1450 tree = proto_item_add_subtree(item, ett_afp_enumerate_line);
1452 proto_tree_add_item(tree, hf_afp_struct_size, tvb, offset, 1,FALSE);
1455 proto_tree_add_item(tree, hf_afp_file_flag, tvb, offset, 1,FALSE);
1458 offset = parse_dir_bitmap(tree, tvb, offset, d_bitmap);
1461 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap,0);
1465 offset = org +size; /* play safe */
1467 g_free((gpointer)name);
1473 /* **************************/
1475 dissect_query_afp_get_vol_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1478 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2,FALSE);
1481 decode_vol_bitmap(tree, tvb, offset);
1487 /* ------------------------ */
1489 dissect_reply_afp_get_vol_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1493 bitmap = decode_vol_bitmap(tree, tvb, offset);
1496 offset = parse_vol_bitmap(tree, tvb, offset, bitmap);
1501 /* **************************/
1503 dissect_query_afp_set_vol_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1508 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2,FALSE);
1511 bitmap = decode_vol_bitmap(tree, tvb, offset);
1514 offset = parse_vol_bitmap(tree, tvb, offset, bitmap);
1519 /* ***************************/
1521 dissect_query_afp_login(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1526 len = tvb_get_guint8(tvb, offset);
1527 proto_tree_add_item(tree, hf_afp_AFPVersion, tvb, offset, 1,FALSE);
1529 len = tvb_get_guint8(tvb, offset);
1530 uam = tvb_get_ptr(tvb, offset +1, len);
1531 proto_tree_add_item(tree, hf_afp_UAM, tvb, offset, 1,FALSE);
1534 if (!strncmp(uam, "Cleartxt passwrd", len)) {
1536 len = tvb_get_guint8(tvb, offset);
1537 proto_tree_add_item(tree, hf_afp_user, tvb, offset, 1,FALSE);
1540 len = tvb_strsize(tvb, offset);
1541 proto_tree_add_item(tree, hf_afp_passwd, tvb, offset, len,FALSE);
1544 else if (!strncmp(uam, "No User Authent", len)) {
1549 /* ************************** */
1551 dissect_query_afp_write(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1555 proto_tree_add_item(tree, hf_afp_flag, tvb, offset, 1,FALSE);
1558 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2,FALSE);
1561 proto_tree_add_item(tree, hf_afp_offset, tvb, offset, 4,FALSE);
1564 proto_tree_add_item(tree, hf_afp_rw_count, tvb, offset, 4,FALSE);
1571 dissect_reply_afp_write(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1573 proto_tree_add_item(tree, hf_afp_last_written, tvb, offset, 4, FALSE);
1579 /* ************************** */
1581 dissect_query_afp_read(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1587 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2,FALSE);
1590 proto_tree_add_item(tree, hf_afp_offset, tvb, offset, 4,FALSE);
1593 proto_tree_add_item(tree, hf_afp_rw_count, tvb, offset, 4,FALSE);
1603 /* **************************
1605 query is the same than AFP_FLUSH, AFP_CLOSEVOL
1609 dissect_reply_afp_open_dt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1611 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
1617 /* **************************
1621 dissect_query_afp_close_dt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1624 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
1630 /* **************************
1631 calls using the same format :
1638 dissect_query_afp_with_fork(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1641 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2,FALSE);
1647 /* ************************** */
1649 dissect_query_afp_get_fldr_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1652 offset = decode_vol_did_file_dir_bitmap(tree, tvb, offset);
1654 offset = decode_name(tree, pinfo, tvb, offset);
1659 /* -------------------------- */
1661 dissect_reply_afp_get_fldr_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1664 guint16 f_bitmap, d_bitmap;
1666 f_bitmap = decode_file_bitmap(tree, tvb, offset);
1669 d_bitmap = decode_dir_bitmap(tree, tvb, offset);
1672 flags = tvb_get_guint8(tvb, offset);
1673 proto_tree_add_item(tree, hf_afp_file_flag, tvb, offset, 1,FALSE);
1677 offset = parse_dir_bitmap(tree, tvb, offset, d_bitmap);
1680 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap,0);
1685 /* **************************
1689 dissect_query_afp_set_fldr_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1694 offset = decode_vol_did(tree, tvb, offset);
1696 f_bitmap = decode_file_bitmap(tree, tvb, offset);
1699 offset = decode_name(tree, pinfo, tvb, offset);
1703 /* did:name can be a file or a folder but only the intersection between
1704 * file bitmap and dir bitmap can be set
1706 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap, 1);
1711 /* **************************
1715 dissect_query_afp_set_file_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1720 offset = decode_vol_did(tree, tvb, offset);
1722 f_bitmap = decode_file_bitmap(tree, tvb, offset);
1725 offset = decode_name(tree, pinfo, tvb, offset);
1729 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap, 0);
1734 /* **************************
1738 dissect_query_afp_set_dir_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1743 offset = decode_vol_did(tree, tvb, offset);
1745 d_bitmap = decode_dir_bitmap(tree, tvb, offset);
1748 offset = decode_name(tree, pinfo, tvb, offset);
1752 offset = parse_dir_bitmap(tree, tvb, offset, d_bitmap);
1758 /* **************************
1763 dissect_query_afp_create_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1766 offset = decode_vol_did(tree, tvb, offset);
1768 offset = decode_name(tree, pinfo, tvb, offset);
1772 /* --------------------------
1776 dissect_reply_afp_create_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1778 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4,FALSE);
1784 /* -------------------------- */
1786 dissect_reply_afp_create_dir(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1788 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
1794 /* **************************
1798 dissect_query_afp_delete_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1801 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2,FALSE);
1803 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4,FALSE);
1809 /* **************************
1810 same reply as get_fork_param
1813 dissect_query_afp_resolve_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1816 proto_tree_add_item(tree, hf_afp_vol_id, tvb, offset, 2,FALSE);
1818 proto_tree_add_item(tree, hf_afp_file_id, tvb, offset, 4,FALSE);
1821 decode_file_bitmap(tree, tvb, offset);
1827 /* ************************** */
1829 dissect_query_afp_get_fork_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1833 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2,FALSE);
1836 decode_file_bitmap(tree, tvb, offset);
1841 /* -------------------------- */
1843 dissect_reply_afp_get_fork_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1847 f_bitmap = decode_file_bitmap(tree, tvb, offset);
1850 offset = parse_file_bitmap(tree, tvb, offset, f_bitmap,0);
1855 /* ************************** */
1857 dissect_query_afp_set_fork_param(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1861 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2,FALSE);
1864 decode_file_bitmap(tree, tvb, offset);
1867 proto_tree_add_item(tree, hf_afp_ofork_len, tvb, offset, 4,FALSE);
1872 /* ************************** */
1874 dissect_query_afp_move(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1878 offset = decode_vol_did(tree, tvb, offset);
1880 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
1883 offset = decode_name_label(tree, pinfo, tvb, offset, "Source path: %s");
1884 offset = decode_name_label(tree, NULL, tvb, offset, "Dest dir: %s");
1885 offset = decode_name_label(tree, NULL, tvb, offset, "New name: %s");
1890 /* ************************** */
1892 dissect_query_afp_rename(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1896 offset = decode_vol_did(tree, tvb, offset);
1898 offset = decode_name_label(tree, pinfo, tvb, offset, "Old name: %s");
1899 offset = decode_name_label(tree, NULL, tvb, offset, "New name: %s");
1904 /* ************************** */
1906 dissect_query_afp_byte_lock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1908 proto_tree *sub_tree = NULL;
1912 flag = tvb_get_guint8(tvb, offset);
1914 item = proto_tree_add_text(tree, tvb, offset, 1, "Flags: 0x%02x", flag);
1915 sub_tree = proto_item_add_subtree(item, ett_afp_lock_flags);
1918 proto_tree_add_item(sub_tree, hf_afp_lock_op, tvb, offset, 1,FALSE);
1919 proto_tree_add_item(sub_tree, hf_afp_lock_from, tvb, offset, 1,FALSE);
1922 proto_tree_add_item(tree, hf_afp_ofork, tvb, offset, 2,FALSE);
1925 proto_tree_add_item(tree, hf_afp_lock_offset, tvb, offset, 4,FALSE);
1928 proto_tree_add_item(tree, hf_afp_lock_len, tvb, offset, 4,FALSE);
1933 /* -------------------------- */
1935 dissect_reply_afp_byte_lock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1937 proto_tree_add_item(tree, hf_afp_lock_range_start, tvb, offset, 4,FALSE);
1943 /* ************************** */
1945 dissect_query_afp_add_cmt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1950 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
1953 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
1956 offset = decode_name(tree, pinfo, tvb, offset);
1961 len = tvb_get_guint8(tvb, offset);
1962 proto_tree_add_item(tree, hf_afp_comment, tvb, offset, 1,FALSE);
1969 /* ************************** */
1971 dissect_query_afp_get_cmt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1975 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
1978 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
1981 offset = decode_name(tree, pinfo, tvb, offset);
1985 /* -------------------------- */
1987 dissect_reply_afp_get_cmt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1991 len = tvb_get_guint8(tvb, offset);
1992 proto_tree_add_item(tree, hf_afp_comment, tvb, offset, 1,FALSE);
1998 /* ************************** */
2000 dissect_query_afp_get_icon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2004 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
2006 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4,FALSE);
2009 proto_tree_add_item(tree, hf_afp_file_type, tvb, offset, 4,FALSE);
2012 proto_tree_add_item(tree, hf_afp_icon_type, tvb, offset, 1,FALSE);
2016 proto_tree_add_item(tree, hf_afp_icon_length, tvb, offset, 2,FALSE);
2022 /* --------------------------
2023 fallback to data in afp dissector
2026 dissect_reply_afp_get_icon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2031 /* ************************** */
2033 dissect_query_afp_get_icon_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2037 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
2039 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4,FALSE);
2042 proto_tree_add_item(tree, hf_afp_icon_index, tvb, offset, 2,FALSE);
2048 /* -------------------------- */
2050 dissect_reply_afp_get_icon_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2053 proto_tree_add_item(tree, hf_afp_icon_tag, tvb, offset, 4,FALSE);
2056 proto_tree_add_item(tree, hf_afp_file_type, tvb, offset, 4,FALSE);
2059 proto_tree_add_item(tree, hf_afp_icon_type, tvb, offset, 1,FALSE);
2063 proto_tree_add_item(tree, hf_afp_icon_length, tvb, offset, 2,FALSE);
2069 /* ************************** */
2071 dissect_query_afp_add_icon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2075 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
2077 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4,FALSE);
2080 proto_tree_add_item(tree, hf_afp_file_type, tvb, offset, 4,FALSE);
2083 proto_tree_add_item(tree, hf_afp_icon_type, tvb, offset, 1,FALSE);
2087 proto_tree_add_item(tree, hf_afp_icon_tag, tvb, offset, 4,FALSE);
2090 proto_tree_add_item(tree, hf_afp_icon_length, tvb, offset, 2,FALSE);
2096 /* **************************
2100 dissect_query_afp_add_appl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2104 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
2107 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
2110 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4,FALSE);
2113 proto_tree_add_item(tree, hf_afp_appl_tag, tvb, offset, 4,FALSE);
2116 offset = decode_name(tree, pinfo, tvb, offset);
2121 /* **************************
2125 dissect_query_afp_rmv_appl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2129 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
2132 proto_tree_add_item(tree, hf_afp_did, tvb, offset, 4,FALSE);
2135 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4,FALSE);
2138 offset = decode_name(tree, pinfo, tvb, offset);
2143 /* ************************** */
2145 dissect_query_afp_get_appl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2149 proto_tree_add_item(tree, hf_afp_dt_ref, tvb, offset, 2,FALSE);
2152 proto_tree_add_item(tree, hf_afp_file_creator, tvb, offset, 4,FALSE);
2155 proto_tree_add_item(tree, hf_afp_appl_index, tvb, offset, 2,FALSE);
2158 decode_file_bitmap(tree, tvb, offset);
2164 /* -------------------------- */
2166 dissect_reply_afp_get_appl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2168 proto_tree_add_item(tree, hf_afp_appl_tag, tvb, offset, 4,FALSE);
2174 /* ************************** */
2176 dissect_query_afp_create_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2178 proto_tree_add_item(tree, hf_afp_create_flag, tvb, offset, 1,FALSE);
2181 offset = decode_vol_did(tree, tvb, offset);
2183 offset = decode_name(tree, pinfo, tvb, offset);
2188 /* -------------------------- */
2190 dissect_reply_afp_create_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
2195 /* ************************** */
2197 dissect_afp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2199 struct aspinfo *aspinfo = pinfo->private_data;
2200 proto_tree *afp_tree = NULL;
2202 conversation_t *conversation;
2204 afp_request_key request_key, *new_request_key;
2205 afp_request_val *request_val;
2210 guint16 afp_requestid;
2213 guint32 afp_reserved;
2214 int len = tvb_reported_length_remaining(tvb,0);
2216 if (check_col(pinfo->cinfo, COL_PROTOCOL))
2217 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AFP");
2218 if (check_col(pinfo->cinfo, COL_INFO))
2219 col_clear(pinfo->cinfo, COL_INFO);
2221 conversation = find_conversation(&pinfo->src, &pinfo->dst, pinfo->ptype,
2222 pinfo->srcport, pinfo->destport, 0);
2224 if (conversation == NULL)
2226 conversation = conversation_new(&pinfo->src, &pinfo->dst,
2227 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
2230 request_key.conversation = conversation->index;
2231 request_key.seq = aspinfo->seq;
2233 request_val = (afp_request_val *) g_hash_table_lookup(
2234 afp_request_hash, &request_key);
2236 if (!request_val && !aspinfo->reply) {
2237 afp_command = tvb_get_guint8(tvb, offset);
2238 new_request_key = g_mem_chunk_alloc(afp_request_keys);
2239 *new_request_key = request_key;
2241 request_val = g_mem_chunk_alloc(afp_request_vals);
2242 request_val->command = tvb_get_guint8(tvb, offset);
2244 g_hash_table_insert(afp_request_hash, new_request_key,
2248 if (!request_val) { /* missing request */
2252 afp_command = request_val->command;
2253 if (check_col(pinfo->cinfo, COL_INFO)) {
2256 if ((func_str = match_strval(afp_command, CommandCode_vals)))
2258 col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s", func_str, aspinfo->reply?"reply":"");
2264 ti = proto_tree_add_item(tree, proto_afp, tvb, offset, -1,FALSE);
2265 afp_tree = proto_item_add_subtree(ti, ett_afp);
2267 if (!aspinfo->reply) {
2268 proto_tree_add_uint(afp_tree, hf_afp_command, tvb,offset, 1, afp_command);
2270 switch(afp_command) {
2272 offset = dissect_query_afp_byte_lock(tvb, pinfo, afp_tree, offset);break;
2273 case AFP_OPENDT: /* same as close vol */
2276 offset = dissect_query_afp_with_vol_id(tvb, pinfo, afp_tree, offset);break;
2278 /* offset = dissect_query_afp_close_dir(tvb, pinfo, afp_tree, offset);break; */
2281 offset = dissect_query_afp_close_dt(tvb, pinfo, afp_tree, offset);break;
2282 case AFP_FLUSHFORK: /* same packet as closefork */
2284 offset = dissect_query_afp_with_fork(tvb, pinfo, afp_tree, offset);break;
2286 /* offset = dissect_query_afp_copy_file(tvb, pinfo, afp_tree, offset);break; */
2287 case AFP_CREATEFILE:
2288 offset = dissect_query_afp_create_file(tvb, pinfo, afp_tree, offset);break;
2290 offset = dissect_query_afp_enumerate(tvb, pinfo, afp_tree, offset);break;
2291 case AFP_GETFORKPARAM:
2292 offset = dissect_query_afp_get_fork_param(tvb, pinfo, afp_tree, offset);break;
2293 case AFP_GETSRVINFO:
2294 /* offset = dissect_query_afp_get_server_info(tvb, pinfo, afp_tree, offset);break; */
2295 case AFP_GETSRVPARAM:
2296 break; /* no parameters */
2297 case AFP_GETVOLPARAM:
2298 offset = dissect_query_afp_get_vol_param(tvb, pinfo, afp_tree, offset);break;
2300 offset = dissect_query_afp_login(tvb, pinfo, afp_tree, offset);break;
2307 offset = dissect_query_afp_move(tvb, pinfo, afp_tree, offset);break;
2309 offset = dissect_query_afp_open_vol(tvb, pinfo, afp_tree, offset);break;
2313 offset = dissect_query_afp_open_fork(tvb, pinfo, afp_tree, offset);break;
2315 offset = dissect_query_afp_read(tvb, pinfo, afp_tree, offset);break;
2317 offset = dissect_query_afp_rename(tvb, pinfo, afp_tree, offset);break;
2318 case AFP_SETDIRPARAM:
2319 offset = dissect_query_afp_set_dir_param(tvb, pinfo, afp_tree, offset);break;
2320 case AFP_SETFILEPARAM:
2321 offset = dissect_query_afp_set_file_param(tvb, pinfo, afp_tree, offset);break;
2322 case AFP_SETFORKPARAM:
2323 offset = dissect_query_afp_set_fork_param(tvb, pinfo, afp_tree, offset);break;
2324 case AFP_SETVOLPARAM:
2325 offset = dissect_query_afp_set_vol_param(tvb, pinfo, afp_tree, offset);break;
2327 offset = dissect_query_afp_write(tvb, pinfo, afp_tree, offset);break;
2328 case AFP_GETFLDRPARAM:
2329 offset = dissect_query_afp_get_fldr_param(tvb, pinfo, afp_tree, offset);break;
2330 case AFP_SETFLDRPARAM:
2331 offset = dissect_query_afp_set_fldr_param(tvb, pinfo, afp_tree, offset);break;
2333 case AFP_GETSRVRMSG:
2335 case AFP_DELETE: /* same as create_id */
2338 offset = dissect_query_afp_create_id(tvb, pinfo, afp_tree, offset);break;
2340 offset = dissect_query_afp_delete_id(tvb, pinfo, afp_tree, offset);break;
2342 offset = dissect_query_afp_resolve_id(tvb, pinfo, afp_tree, offset);break;
2343 case AFP_EXCHANGEFILE:
2347 offset = dissect_query_afp_get_icon(tvb, pinfo, afp_tree, offset);break;
2349 offset = dissect_query_afp_get_icon_info(tvb, pinfo, afp_tree, offset);break;
2351 offset = dissect_query_afp_add_appl(tvb, pinfo, afp_tree, offset);break;
2353 offset = dissect_query_afp_rmv_appl(tvb, pinfo, afp_tree, offset);break;
2355 offset = dissect_query_afp_get_appl(tvb, pinfo, afp_tree, offset);break;
2357 offset = dissect_query_afp_add_cmt(tvb, pinfo, afp_tree, offset);break;
2358 case AFP_RMVCMT: /* same as get_cmt */
2360 offset = dissect_query_afp_get_cmt(tvb, pinfo, afp_tree, offset);break;
2362 offset = dissect_query_afp_add_icon(tvb, pinfo, afp_tree, offset);break;
2367 switch(afp_command) {
2369 offset = dissect_reply_afp_byte_lock(tvb, pinfo, afp_tree, offset);break;
2371 offset = dissect_reply_afp_enumerate(tvb, pinfo, afp_tree, offset);break;
2373 offset = dissect_reply_afp_open_vol(tvb, pinfo, afp_tree, offset);break;
2375 offset = dissect_reply_afp_open_fork(tvb, pinfo, afp_tree, offset);break;
2377 case AFP_GETFORKPARAM:
2378 offset =dissect_reply_afp_get_fork_param(tvb, pinfo, afp_tree, offset);break;
2379 case AFP_GETSRVINFO:
2380 case AFP_GETSRVPARAM:
2383 offset = dissect_reply_afp_create_dir(tvb, pinfo, afp_tree, offset);break;
2384 case AFP_MOVE: /* same as create_id */
2386 offset = dissect_reply_afp_create_id(tvb, pinfo, afp_tree, offset);break;
2387 case AFP_GETVOLPARAM:
2388 offset = dissect_reply_afp_get_vol_param(tvb, pinfo, afp_tree, offset);break;
2389 case AFP_GETFLDRPARAM:
2390 offset = dissect_reply_afp_get_fldr_param(tvb, pinfo, afp_tree, offset);break;
2392 offset = dissect_reply_afp_open_dt(tvb, pinfo, afp_tree, offset);break;
2394 offset = dissect_reply_afp_get_icon(tvb, pinfo, afp_tree, offset);break;
2396 offset = dissect_reply_afp_get_icon_info(tvb, pinfo, afp_tree, offset);break;
2398 offset = dissect_reply_afp_get_appl(tvb, pinfo, afp_tree, offset);break;
2400 offset = dissect_reply_afp_get_cmt(tvb, pinfo, afp_tree, offset);break;
2402 offset = dissect_reply_afp_write(tvb, pinfo, afp_tree, offset);break;
2405 if (tree && offset < len)
2406 call_dissector(data_handle,tvb_new_subset(tvb, offset,-1,tvb_reported_length_remaining(tvb,offset)), pinfo, afp_tree);
2409 static void afp_reinit( void)
2412 if (afp_request_hash)
2413 g_hash_table_destroy(afp_request_hash);
2414 if (afp_request_keys)
2415 g_mem_chunk_destroy(afp_request_keys);
2416 if (afp_request_vals)
2417 g_mem_chunk_destroy(afp_request_vals);
2419 afp_request_hash = g_hash_table_new(afp_hash, afp_equal);
2421 afp_request_keys = g_mem_chunk_new("afp_request_keys",
2422 sizeof(afp_request_key),
2423 afp_packet_init_count * sizeof(afp_request_key),
2425 afp_request_vals = g_mem_chunk_new("afp_request_vals",
2426 sizeof(afp_request_val),
2427 afp_packet_init_count * sizeof(afp_request_val),
2433 proto_register_afp(void)
2436 static hf_register_info hf[] = {
2438 { "Command", "afp.command",
2439 FT_UINT8, BASE_DEC, VALS(CommandCode_vals), 0x0,
2440 "AFP function", HFILL }},
2444 FT_NONE, BASE_NONE, NULL, 0,
2445 "Pad Byte", HFILL }},
2447 { &hf_afp_AFPVersion,
2448 { "AFP Version", "afp.AFPVersion",
2449 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
2450 "Client AFP version", HFILL }},
2454 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
2455 "User Authentication Method", HFILL }},
2458 { "User", "afp.user",
2459 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
2463 { "Password", "afp.passwd",
2464 FT_STRINGZ, BASE_NONE, NULL, 0x0,
2465 "Password", HFILL }},
2467 { &hf_afp_vol_bitmap,
2468 { "Bitmap", "afp.vol_bitmap",
2469 FT_UINT16, BASE_HEX, NULL, 0 /* 0x0FFF*/,
2470 "Volume bitmap", HFILL }},
2472 { &hf_afp_vol_bitmap_Attributes,
2473 { "Attributes", "afp.vol_bitmap.attributes",
2474 FT_BOOLEAN, 16, NULL, kFPVolAttributeBit,
2475 "Volume attributes", HFILL }},
2477 { &hf_afp_vol_attribute,
2478 { "Attributes", "afp.vol_attribute",
2479 FT_UINT16, BASE_HEX, NULL, 0,
2480 "Volume attributes", HFILL }},
2482 { &hf_afp_vol_attribute_ReadOnly,
2483 { "Read only", "afp.vol_attribute.read_only",
2484 FT_BOOLEAN, 16, NULL, kReadOnly,
2485 "Read only volume", HFILL }},
2487 { &hf_afp_vol_attribute_HasVolumePassword,
2488 { "Volume password", "afp.vol_attribute.passwd",
2489 FT_BOOLEAN, 16, NULL, kHasVolumePassword,
2490 "Has a volume password", HFILL }},
2492 { &hf_afp_vol_attribute_SupportsFileIDs,
2493 { "File IDs", "afp.vol_attribute.fileIDs",
2494 FT_BOOLEAN, 16, NULL, kSupportsFileIDs,
2495 "Supports file IDs", HFILL }},
2497 { &hf_afp_vol_attribute_SupportsCatSearch,
2498 { "Catalog search", "afp.vol_attribute.cat_search",
2499 FT_BOOLEAN, 16, NULL, kSupportsCatSearch,
2500 "Supports catalog search operations", HFILL }},
2502 { &hf_afp_vol_attribute_SupportsBlankAccessPrivs,
2503 { "Blank access privileges", "afp.vol_attribute.blank_access_privs",
2504 FT_BOOLEAN, 16, NULL, kSupportsBlankAccessPrivs,
2505 "Supports blank access privileges", HFILL }},
2507 { &hf_afp_vol_attribute_SupportsUnixPrivs,
2508 { "UNIX access privileges", "afp.vol_attribute.unix_privs",
2509 FT_BOOLEAN, 16, NULL, kSupportsUnixPrivs,
2510 "Supports UNIX access privileges", HFILL }},
2512 { &hf_afp_vol_attribute_SupportsUTF8Names,
2513 { "UTF-8 names", "afp.vol_attribute.utf8_names",
2514 FT_BOOLEAN, 16, NULL, kSupportsUTF8Names,
2515 "Supports UTF-8 names", HFILL }},
2517 { &hf_afp_vol_bitmap_Signature,
2518 { "Signature", "afp.vol_bitmap.signature",
2519 FT_BOOLEAN, 16, NULL, kFPVolSignatureBit,
2520 "Volume signature", HFILL }},
2522 { &hf_afp_vol_bitmap_CreateDate,
2523 { "Creation date", "afp.vol_bitmap.create_date",
2524 FT_BOOLEAN, 16, NULL, kFPVolCreateDateBit,
2525 "Volume creation date", HFILL }},
2527 { &hf_afp_vol_bitmap_ModDate,
2528 { "Modification date", "afp.vol_bitmap.mod_date",
2529 FT_BOOLEAN, 16, NULL, kFPVolModDateBit,
2530 "Volume modification date", HFILL }},
2532 { &hf_afp_vol_bitmap_BackupDate,
2533 { "Backup date", "afp.vol_bitmap.backup_date",
2534 FT_BOOLEAN, 16, NULL, kFPVolBackupDateBit,
2535 "Volume backup date", HFILL }},
2537 { &hf_afp_vol_bitmap_ID,
2538 { "ID", "afp.vol_bitmap.id",
2539 FT_BOOLEAN, 16, NULL, kFPVolIDBit,
2540 "Volume ID", HFILL }},
2542 { &hf_afp_vol_bitmap_BytesFree,
2543 { "Bytes free", "afp.vol_bitmap.bytes_free",
2544 FT_BOOLEAN, 16, NULL, kFPVolBytesFreeBit,
2545 "Volume free bytes", HFILL }},
2547 { &hf_afp_vol_bitmap_BytesTotal,
2548 { "Bytes total", "afp.vol_bitmap.bytes_total",
2549 FT_BOOLEAN, 16, NULL, kFPVolBytesTotalBit,
2550 "Volume total bytes", HFILL }},
2552 { &hf_afp_vol_bitmap_Name,
2553 { "Name", "afp.vol_bitmap.name",
2554 FT_BOOLEAN, 16, NULL, kFPVolNameBit,
2555 "Volume name", HFILL }},
2557 { &hf_afp_vol_bitmap_ExtBytesFree,
2558 { "Extended bytes free", "afp.vol_bitmap.ex_bytes_free",
2559 FT_BOOLEAN, 16, NULL, kFPVolExtBytesFreeBit,
2560 "Volume extended (>2GB) free bytes", HFILL }},
2562 { &hf_afp_vol_bitmap_ExtBytesTotal,
2563 { "Extended bytes total", "afp.vol_bitmap.ex_bytes_total",
2564 FT_BOOLEAN, 16, NULL, kFPVolExtBytesTotalBit,
2565 "Volume extended (>2GB) total bytes", HFILL }},
2567 { &hf_afp_vol_bitmap_BlockSize,
2568 { "Block size", "afp.vol_bitmap.block_size",
2569 FT_BOOLEAN, 16, NULL, kFPVolBlockSizeBit,
2570 "Volume block size", HFILL }},
2572 { &hf_afp_dir_bitmap_Attributes,
2573 { "Attributes", "afp.dir_bitmap.attributes",
2574 FT_BOOLEAN, 16, NULL, kFPAttributeBit,
2575 "Return attributes if directory", HFILL }},
2577 { &hf_afp_dir_bitmap_ParentDirID,
2578 { "DID", "afp.dir_bitmap.did",
2579 FT_BOOLEAN, 16, NULL, kFPParentDirIDBit,
2580 "Return parent directory ID if directory", HFILL }},
2582 { &hf_afp_dir_bitmap_CreateDate,
2583 { "Creation date", "afp.dir_bitmap.create_date",
2584 FT_BOOLEAN, 16, NULL, kFPCreateDateBit,
2585 "Return creation date if directory", HFILL }},
2587 { &hf_afp_dir_bitmap_ModDate,
2588 { "Modification date", "afp.dir_bitmap.mod_date",
2589 FT_BOOLEAN, 16, NULL, kFPModDateBit,
2590 "Return modification date if directory", HFILL }},
2592 { &hf_afp_dir_bitmap_BackupDate,
2593 { "Backup date", "afp.dir_bitmap.backup_date",
2594 FT_BOOLEAN, 16, NULL, kFPBackupDateBit,
2595 "Return backup date if directory", HFILL }},
2597 { &hf_afp_dir_bitmap_FinderInfo,
2598 { "Finder info", "afp.dir_bitmap.finder_info",
2599 FT_BOOLEAN, 16, NULL, kFPFinderInfoBit,
2600 "Return finder info if directory", HFILL }},
2602 { &hf_afp_dir_bitmap_LongName,
2603 { "Long name", "afp.dir_bitmap.long_name",
2604 FT_BOOLEAN, 16, NULL, kFPLongNameBit,
2605 "Return long name if directory", HFILL }},
2607 { &hf_afp_dir_bitmap_ShortName,
2608 { "Short name", "afp.dir_bitmap.short_name",
2609 FT_BOOLEAN, 16, NULL, kFPShortNameBit,
2610 "Return short name if directory", HFILL }},
2612 { &hf_afp_dir_bitmap_NodeID,
2613 { "File ID", "afp.dir_bitmap.fid",
2614 FT_BOOLEAN, 16, NULL, kFPNodeIDBit,
2615 "Return file ID if directory", HFILL }},
2617 { &hf_afp_dir_bitmap_OffspringCount,
2618 { "Offspring count", "afp.dir_bitmap.offspring_count",
2619 FT_BOOLEAN, 16, NULL, kFPOffspringCountBit,
2620 "Return offspring count if directory", HFILL }},
2622 { &hf_afp_dir_bitmap_OwnerID,
2623 { "Owner id", "afp.dir_bitmap.owner_id",
2624 FT_BOOLEAN, 16, NULL, kFPOwnerIDBit,
2625 "Return owner id if directory", HFILL }},
2627 { &hf_afp_dir_bitmap_GroupID,
2628 { "Group id", "afp.dir_bitmap.group_id",
2629 FT_BOOLEAN, 16, NULL, kFPGroupIDBit,
2630 "Return group id if directory", HFILL }},
2632 { &hf_afp_dir_bitmap_AccessRights,
2633 { "Access rights", "afp.dir_bitmap.access_rights",
2634 FT_BOOLEAN, 16, NULL, kFPAccessRightsBit,
2635 "Return access rights if directory", HFILL }},
2637 { &hf_afp_dir_bitmap_UTF8Name,
2638 { "UTF-8 name", "afp.dir_bitmap.UTF8_name",
2639 FT_BOOLEAN, 16, NULL, kFPUTF8NameBit,
2640 "Return UTF-8 name if diectory", HFILL }},
2642 { &hf_afp_dir_bitmap_UnixPrivs,
2643 { "UNIX privileges", "afp.dir_bitmap.unix_privs",
2644 FT_BOOLEAN, 16, NULL, kFPUnixPrivsBit,
2645 "Return UNIX privileges if directory", HFILL }},
2647 { &hf_afp_dir_attribute_Invisible,
2648 { "Invisible", "afp.dir_attribute.invisible",
2649 FT_BOOLEAN, 16, NULL, kFPInvisibleBit,
2650 "Directory is not visible", HFILL }},
2652 { &hf_afp_dir_attribute_IsExpFolder,
2653 { "Share point", "afp.dir_attribute.share",
2654 FT_BOOLEAN, 16, NULL, kFPMultiUserBit,
2655 "Directory is a share point", HFILL }},
2657 { &hf_afp_dir_attribute_System,
2658 { "System", "afp.dir_attribute.system",
2659 FT_BOOLEAN, 16, NULL, kFPSystemBit,
2660 "Directory is a system directory", HFILL }},
2662 { &hf_afp_dir_attribute_Mounted,
2663 { "Mounted", "afp.dir_attribute.mounted",
2664 FT_BOOLEAN, 16, NULL, kFPDAlreadyOpenBit,
2665 "Directory is mounted", HFILL }},
2667 { &hf_afp_dir_attribute_InExpFolder,
2668 { "Shared area", "afp.dir_attribute.in_exported_folder",
2669 FT_BOOLEAN, 16, NULL, kFPRAlreadyOpenBit,
2670 "Directory is in a shared area", HFILL }},
2672 { &hf_afp_dir_attribute_BackUpNeeded,
2673 { "Backup needed", "afp.dir_attribute.backup_needed",
2674 FT_BOOLEAN, 16, NULL, kFPBackUpNeededBit,
2675 "Directory needs to be backed up", HFILL }},
2677 { &hf_afp_dir_attribute_RenameInhibit,
2678 { "Rename inhibit", "afp.dir_attribute.rename_inhibit",
2679 FT_BOOLEAN, 16, NULL, kFPRenameInhibitBit,
2680 "Rename inhibit", HFILL }},
2682 { &hf_afp_dir_attribute_DeleteInhibit,
2683 { "Delete inhibit", "afp.dir_attribute.delete_inhibit",
2684 FT_BOOLEAN, 16, NULL, kFPDeleteInhibitBit,
2685 "Delete inhibit", HFILL }},
2687 { &hf_afp_dir_attribute_SetClear,
2688 { "Set", "afp.dir_attribute.set_clear",
2689 FT_BOOLEAN, 16, NULL, kFPSetClearBit,
2690 "Clear/set attribute", HFILL }},
2692 { &hf_afp_file_bitmap_Attributes,
2693 { "Attributes", "afp.file_bitmap.attributes",
2694 FT_BOOLEAN, 16, NULL, kFPAttributeBit,
2695 "Return attributes if file", HFILL }},
2697 { &hf_afp_file_bitmap_ParentDirID,
2698 { "DID", "afp.file_bitmap.did",
2699 FT_BOOLEAN, 16, NULL, kFPParentDirIDBit,
2700 "Return parent directory ID if file", HFILL }},
2702 { &hf_afp_file_bitmap_CreateDate,
2703 { "Creation date", "afp.file_bitmap.create_date",
2704 FT_BOOLEAN, 16, NULL, kFPCreateDateBit,
2705 "Return creation date if file", HFILL }},
2707 { &hf_afp_file_bitmap_ModDate,
2708 { "Modification date", "afp.file_bitmap.mod_date",
2709 FT_BOOLEAN, 16, NULL, kFPModDateBit,
2710 "Return modification date if file", HFILL }},
2712 { &hf_afp_file_bitmap_BackupDate,
2713 { "Backup date", "afp.file_bitmap.backup_date",
2714 FT_BOOLEAN, 16, NULL, kFPBackupDateBit,
2715 "Return backup date if file", HFILL }},
2717 { &hf_afp_file_bitmap_FinderInfo,
2718 { "Finder info", "afp.file_bitmap.finder_info",
2719 FT_BOOLEAN, 16, NULL, kFPFinderInfoBit,
2720 "Return finder info if file", HFILL }},
2722 { &hf_afp_file_bitmap_LongName,
2723 { "Long name", "afp.file_bitmap.long_name",
2724 FT_BOOLEAN, 16, NULL, kFPLongNameBit,
2725 "Return long name if file", HFILL }},
2727 { &hf_afp_file_bitmap_ShortName,
2728 { "Short name", "afp.file_bitmap.short_name",
2729 FT_BOOLEAN, 16, NULL, kFPShortNameBit,
2730 "Return short name if file", HFILL }},
2732 { &hf_afp_file_bitmap_NodeID,
2733 { "File ID", "afp.file_bitmap.fid",
2734 FT_BOOLEAN, 16, NULL, kFPNodeIDBit,
2735 "Return file ID if file", HFILL }},
2737 { &hf_afp_file_bitmap_DataForkLen,
2738 { "Data fork size", "afp.file_bitmap.data_fork_len",
2739 FT_BOOLEAN, 16, NULL, kFPDataForkLenBit,
2740 "Return data fork size if file", HFILL }},
2742 { &hf_afp_file_bitmap_RsrcForkLen,
2743 { "Resource fork size", "afp.file_bitmap.resource_fork_len",
2744 FT_BOOLEAN, 16, NULL, kFPRsrcForkLenBit,
2745 "Return resource fork size if file", HFILL }},
2747 { &hf_afp_file_bitmap_ExtDataForkLen,
2748 { "Extended data fork size", "afp.file_bitmap.ex_data_fork_len",
2749 FT_BOOLEAN, 16, NULL, kFPExtDataForkLenBit,
2750 "Return extended (>2GB) data fork size if file", HFILL }},
2752 { &hf_afp_file_bitmap_LaunchLimit,
2753 { "Launch limit", "afp.file_bitmap.launch_limit",
2754 FT_BOOLEAN, 16, NULL, kFPLaunchLimitBit,
2755 "Return launch limit if file", HFILL }},
2757 { &hf_afp_file_bitmap_UTF8Name,
2758 { "UTF-8 name", "afp.file_bitmap.UTF8_name",
2759 FT_BOOLEAN, 16, NULL, kFPUTF8NameBit,
2760 "Return UTF-8 name if file", HFILL }},
2762 { &hf_afp_file_bitmap_ExtRsrcForkLen,
2763 { "Extended resource fork size", "afp.file_bitmap.ex_resource_fork_len",
2764 FT_BOOLEAN, 16, NULL, kFPExtRsrcForkLenBit,
2765 "Return extended (>2GB) resource fork size if file", HFILL }},
2767 { &hf_afp_file_bitmap_UnixPrivs,
2768 { "UNIX privileges", "afp.file_bitmap.unix_privs",
2769 FT_BOOLEAN, 16, NULL, kFPUnixPrivsBit_file,
2770 "Return UNIX privileges if file", HFILL }},
2773 { &hf_afp_file_attribute_Invisible,
2774 { "Invisible", "afp.file_attribute.invisible",
2775 FT_BOOLEAN, 16, NULL, kFPInvisibleBit,
2776 "File is not visible", HFILL }},
2778 { &hf_afp_file_attribute_MultiUser,
2779 { "Multi user", "afp.file_attribute.multi_user",
2780 FT_BOOLEAN, 16, NULL, kFPMultiUserBit,
2781 "multi user", HFILL }},
2783 { &hf_afp_file_attribute_System,
2784 { "System", "afp.file_attribute.system",
2785 FT_BOOLEAN, 16, NULL, kFPSystemBit,
2786 "File is a system file", HFILL }},
2788 { &hf_afp_file_attribute_DAlreadyOpen,
2789 { "Data fork open", "afp.file_attribute.df_open",
2790 FT_BOOLEAN, 16, NULL, kFPDAlreadyOpenBit,
2791 "Data fork already open", HFILL }},
2793 { &hf_afp_file_attribute_RAlreadyOpen,
2794 { "Resource fork open", "afp.file_attribute.rf_open",
2795 FT_BOOLEAN, 16, NULL, kFPRAlreadyOpenBit,
2796 "Resource fork already open", HFILL }},
2798 { &hf_afp_file_attribute_WriteInhibit,
2799 { "Write inhibit", "afp.file_attribute.write_inhibit",
2800 FT_BOOLEAN, 16, NULL, kFPWriteInhibitBit,
2801 "Write inhibit", HFILL }},
2803 { &hf_afp_file_attribute_BackUpNeeded,
2804 { "Backup needed", "afp.file_attribute.backup_needed",
2805 FT_BOOLEAN, 16, NULL, kFPBackUpNeededBit,
2806 "File needs to be backed up", HFILL }},
2808 { &hf_afp_file_attribute_RenameInhibit,
2809 { "Rename inhibit", "afp.file_attribute.rename_inhibit",
2810 FT_BOOLEAN, 16, NULL, kFPRenameInhibitBit,
2811 "rename inhibit", HFILL }},
2813 { &hf_afp_file_attribute_DeleteInhibit,
2814 { "Delete inhibit", "afp.file_attribute.delete_inhibit",
2815 FT_BOOLEAN, 16, NULL, kFPDeleteInhibitBit,
2816 "delete inhibit", HFILL }},
2818 { &hf_afp_file_attribute_CopyProtect,
2819 { "Copy protect", "afp.file_attribute.copy_protect",
2820 FT_BOOLEAN, 16, NULL, kFPCopyProtectBit,
2821 "copy protect", HFILL }},
2823 { &hf_afp_file_attribute_SetClear,
2824 { "Set", "afp.file_attribute.set_clear",
2825 FT_BOOLEAN, 16, NULL, kFPSetClearBit,
2826 "Clear/set attribute", HFILL }},
2830 { "Volume", "afp.vol_name",
2831 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
2832 "Volume name", HFILL }},
2835 { "Volume id", "afp.vol_id",
2836 FT_UINT16, BASE_DEC, NULL, 0x0,
2837 "Volume id", HFILL }},
2839 { &hf_afp_vol_signature,
2840 { "Signature", "afp.vol_signature",
2841 FT_UINT16, BASE_DEC, VALS(vol_signature_vals), 0x0,
2842 "Volume signature", HFILL }},
2844 { &hf_afp_bitmap_offset,
2845 { "Offset", "afp.bitmap_offset",
2846 FT_UINT16, BASE_DEC, NULL, 0x0,
2847 "Name offset in packet", HFILL }},
2849 { &hf_afp_vol_creation_date,
2850 { "Creation date", "afp.vol_creation_date",
2851 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
2852 "Volume creation date", HFILL }},
2854 { &hf_afp_vol_modification_date,
2855 { "Modification date", "afp.vol_modification_date",
2856 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
2857 "Volume modification date", HFILL }},
2859 { &hf_afp_vol_backup_date,
2860 { "Backup date", "afp.vol_backup_date",
2861 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
2862 "Volume backup date", HFILL }},
2864 { &hf_afp_vol_bytes_free,
2865 { "Bytes free", "afp.vol_bytes_free",
2866 FT_UINT32, BASE_DEC, NULL, 0x0,
2867 "Free space", HFILL }},
2869 { &hf_afp_vol_bytes_total,
2870 { "Bytes total", "afp.vol_bytes_total",
2871 FT_UINT32, BASE_DEC, NULL, 0x0,
2872 "Volume size", HFILL }},
2874 { &hf_afp_vol_ex_bytes_free,
2875 { "Extended bytes free", "afp.vol_ex_bytes_free",
2876 FT_UINT64, BASE_DEC, NULL, 0x0,
2877 "Extended (>2GB) free space", HFILL }},
2879 { &hf_afp_vol_ex_bytes_total,
2880 { "Extended bytes total", "afp.vol_ex_bytes_total",
2881 FT_UINT64, BASE_DEC, NULL, 0x0,
2882 "Extended (>2GB) volume size", HFILL }},
2884 { &hf_afp_vol_block_size,
2885 { "Block size", "afp.vol_block_size",
2886 FT_UINT32, BASE_DEC, NULL, 0x0,
2887 "Volume block size", HFILL }},
2891 FT_UINT32, BASE_DEC, NULL, 0x0,
2892 "Parent directory ID", HFILL }},
2894 { &hf_afp_dir_bitmap,
2895 { "Directory bitmap", "afp.dir_bitmap",
2896 FT_UINT16, BASE_HEX, NULL, 0x0,
2897 "Directory bitmap", HFILL }},
2899 { &hf_afp_dir_offspring,
2900 { "Offspring", "afp.dir_offspring",
2901 FT_UINT16, BASE_DEC, NULL, 0x0,
2902 "Directory offspring", HFILL }},
2904 { &hf_afp_dir_OwnerID,
2905 { "Owner ID", "afp.dir_owner_id",
2906 FT_INT32, BASE_DEC, NULL, 0x0,
2907 "Directory owner ID", HFILL }},
2909 { &hf_afp_dir_GroupID,
2910 { "Group ID", "afp.dir_group_id",
2911 FT_INT32, BASE_DEC, NULL, 0x0,
2912 "Directory group ID", HFILL }},
2914 { &hf_afp_creation_date,
2915 { "Creation date", "afp.creation_date",
2916 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
2917 "Creation date", HFILL }},
2919 { &hf_afp_modification_date,
2920 { "Modification date", "afp.modification_date",
2921 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
2922 "Modification date", HFILL }},
2924 { &hf_afp_backup_date,
2925 { "Backup date", "afp.backup_date",
2926 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
2927 "Backup date", HFILL }},
2929 { &hf_afp_finder_info,
2930 { "Finder info", "afp.finder_info",
2931 FT_BYTES, BASE_HEX, NULL, 0x0,
2932 "Finder info", HFILL }},
2935 { "File ID", "afp.file_id",
2936 FT_UINT32, BASE_DEC, NULL, 0x0,
2937 "File/directory ID", HFILL }},
2939 { &hf_afp_file_DataForkLen,
2940 { "Data fork size", "afp.data_fork_len",
2941 FT_UINT32, BASE_DEC, NULL, 0x0,
2942 "Data fork size", HFILL }},
2944 { &hf_afp_file_RsrcForkLen,
2945 { "Resource fork size", "afp.resource_fork_len",
2946 FT_UINT32, BASE_DEC, NULL, 0x0,
2947 "Resource fork size", HFILL }},
2949 { &hf_afp_file_ExtDataForkLen,
2950 { "Extended data fork size", "afp.ext_data_fork_len",
2951 FT_UINT64, BASE_DEC, NULL, 0x0,
2952 "Extended (>2GB) data fork length", HFILL }},
2954 { &hf_afp_file_ExtRsrcForkLen,
2955 { "Extended resource fork size", "afp.ext_resource_fork_len",
2956 FT_UINT64, BASE_DEC, NULL, 0x0,
2957 "Extended (>2GB) resource fork length", HFILL }},
2959 { &hf_afp_file_UnixPrivs,
2960 { "UNIX privileges", "afp.unix_privs",
2961 FT_UINT32, BASE_DEC, NULL, 0x0,
2962 "UNIX privileges", HFILL }},
2964 { &hf_afp_file_bitmap,
2965 { "File bitmap", "afp.file_bitmap",
2966 FT_UINT16, BASE_HEX, NULL, 0x0,
2967 "File bitmap", HFILL }},
2969 { &hf_afp_req_count,
2970 { "Req count", "afp.req_count",
2971 FT_UINT16, BASE_DEC, NULL, 0x0,
2972 "Maximum number of structures returned", HFILL }},
2974 { &hf_afp_start_index,
2975 { "Start index", "afp.start_index",
2976 FT_UINT16, BASE_DEC, NULL, 0x0,
2977 "First structure returned", HFILL }},
2979 { &hf_afp_max_reply_size,
2980 { "Reply size", "afp.reply_size",
2981 FT_UINT16, BASE_DEC, NULL, 0x0,
2982 "First structure returned", HFILL }},
2984 { &hf_afp_file_flag,
2985 { "Dir", "afp.flag",
2986 FT_BOOLEAN, 8, NULL, 0x80,
2987 "Is a dir", HFILL }},
2989 { &hf_afp_create_flag,
2990 { "Hard create", "afp.create_flag",
2991 FT_BOOLEAN, 8, NULL, 0x80,
2992 "Soft/hard create file", HFILL }},
2994 { &hf_afp_struct_size,
2995 { "Struct size", "afp.struct_size",
2996 FT_UINT8, BASE_DEC, NULL,0,
2997 "Sizeof of struct", HFILL }},
3000 { "From", "afp.flag",
3001 FT_UINT8, BASE_HEX, VALS(flag_vals), 0x80,
3002 "Offset is relative to start/end of the fork", HFILL }},
3005 { "DT ref", "afp.dt_ref",
3006 FT_UINT16, BASE_DEC, NULL, 0x0,
3007 "Desktop database reference num", HFILL }},
3010 { "Fork", "afp.ofork",
3011 FT_UINT16, BASE_DEC, NULL, 0x0,
3012 "Open fork reference number", HFILL }},
3015 { "Offset", "afp.offset",
3016 FT_INT32, BASE_DEC, NULL, 0x0,
3020 { "Count", "afp.rw_count",
3021 FT_INT32, BASE_DEC, NULL, 0x0,
3022 "Number of bytes to be read/written", HFILL }},
3024 { &hf_afp_last_written,
3025 { "Last written", "afp.last_written",
3026 FT_UINT32, BASE_DEC, NULL, 0x0,
3027 "Offset of the last byte written", HFILL }},
3029 { &hf_afp_actual_count,
3030 { "Count", "afp.actual_count",
3031 FT_INT32, BASE_DEC, NULL, 0x0,
3032 "Number of bytes returned by read/write", HFILL }},
3034 { &hf_afp_ofork_len,
3035 { "New length", "afp.ofork_len",
3036 FT_INT32, BASE_DEC, NULL, 0x0,
3037 "New length", HFILL }},
3039 { &hf_afp_path_type,
3040 { "Type", "afp.path_type",
3041 FT_UINT8, BASE_HEX, VALS(path_type_vals), 0,
3042 "Type of names", HFILL }},
3045 { "Len", "afp.path_len",
3046 FT_UINT8, BASE_DEC, NULL, 0x0,
3047 "Path length", HFILL }},
3049 { &hf_afp_path_name,
3050 { "Name", "afp.path_name",
3051 FT_STRING, BASE_NONE, NULL, 0x0,
3052 "Path name", HFILL }},
3054 { &hf_afp_fork_type,
3055 { "Resource fork", "afp.fork_type",
3056 FT_BOOLEAN, 8, NULL, 0x80,
3057 "Data/resource fork", HFILL }},
3059 { &hf_afp_access_mode,
3060 { "Access mode", "afp.access",
3061 FT_UINT8, BASE_HEX, NULL, 0x0,
3062 "Fork access mode", HFILL }},
3064 { &hf_afp_access_read,
3065 { "Read", "afp.access.read",
3066 FT_BOOLEAN, 8, NULL, 1,
3067 "Open for reading", HFILL }},
3069 { &hf_afp_access_write,
3070 { "Write", "afp.access.write",
3071 FT_BOOLEAN, 8, NULL, 2,
3072 "Open for writing", HFILL }},
3074 { &hf_afp_access_deny_read,
3075 { "Deny read", "afp.access.deny_read",
3076 FT_BOOLEAN, 8, NULL, 0x10,
3077 "Deny read", HFILL }},
3079 { &hf_afp_access_deny_write,
3080 { "Deny write", "afp.access.deny_write",
3081 FT_BOOLEAN, 8, NULL, 0x20,
3082 "Deny write", HFILL }},
3085 { "Comment", "afp.comment",
3086 FT_UINT_STRING, BASE_NONE, NULL, 0x0,
3087 "File/folder comment", HFILL }},
3089 { &hf_afp_file_creator,
3090 { "File creator", "afp.file_creator",
3091 FT_STRING, BASE_NONE, NULL, 0x0,
3092 "File creator", HFILL }},
3094 { &hf_afp_file_type,
3095 { "File type", "afp.file_type",
3096 FT_STRING, BASE_NONE, NULL, 0x0,
3097 "File type", HFILL }},
3099 { &hf_afp_icon_type,
3100 { "Icon type", "afp.icon_type",
3101 FT_UINT8, BASE_HEX, NULL , 0,
3102 "Icon type", HFILL }},
3104 { &hf_afp_icon_length,
3105 { "Size", "afp.icon_length",
3106 FT_UINT16, BASE_DEC, NULL, 0x0,
3107 "Size for icon bitmap", HFILL }},
3109 { &hf_afp_icon_index,
3110 { "Index", "afp.icon_index",
3111 FT_UINT16, BASE_DEC, NULL, 0x0,
3112 "Icon index in desktop database", HFILL }},
3115 { "Tag", "afp.icon_tag",
3116 FT_UINT32, BASE_HEX, NULL, 0x0,
3117 "Icon tag", HFILL }},
3119 { &hf_afp_appl_index,
3120 { "Index", "afp.appl_index",
3121 FT_UINT16, BASE_DEC, NULL, 0x0,
3122 "Application index", HFILL }},
3125 { "Tag", "afp.appl_tag",
3126 FT_UINT32, BASE_HEX, NULL, 0x0,
3127 "Application tag", HFILL }},
3130 { "unlock", "afp.lock_op",
3131 FT_BOOLEAN, 8, NULL, 0x1,
3132 "Lock/unlock op", HFILL }},
3134 { &hf_afp_lock_from,
3135 { "End", "afp.lock_from",
3136 FT_BOOLEAN, 8, NULL, 0x80,
3137 "Offset is relative to the end of the fork", HFILL }},
3139 { &hf_afp_lock_offset,
3140 { "Offset", "afp.lock_offset",
3141 FT_INT32, BASE_DEC, NULL, 0x0,
3142 "First byte to be locked", HFILL }},
3145 { "Length", "afp.lock_len",
3146 FT_INT32, BASE_DEC, NULL, 0x0,
3147 "Number of bytes to be locked/unlocked", HFILL }},
3149 { &hf_afp_lock_range_start,
3150 { "Start", "afp.lock_range_start",
3151 FT_INT32, BASE_DEC, NULL, 0x0,
3152 "First byte locked/unlocked", HFILL }},
3155 { "Access rights", "afp.dir_ar",
3156 FT_UINT32, BASE_HEX, NULL, 0x0,
3157 "Directory access rights", HFILL }},
3159 { &hf_afp_dir_ar_o_search,
3160 { "Owner has search access", "afp.dir_ar.o_search",
3161 FT_BOOLEAN, 32, NULL, AR_O_SEARCH,
3162 "Owner has search access", HFILL }},
3164 { &hf_afp_dir_ar_o_read,
3165 { "Owner has read access", "afp.dir_ar.o_read",
3166 FT_BOOLEAN, 32, NULL, AR_O_READ,
3167 "Owner has read access", HFILL }},
3169 { &hf_afp_dir_ar_o_write,
3170 { "Owner has write access", "afp.dir_ar.o_write",
3171 FT_BOOLEAN, 32, NULL, AR_O_WRITE,
3172 "Gwner has write access", HFILL }},
3174 { &hf_afp_dir_ar_g_search,
3175 { "Group has search access", "afp.dir_ar.g_search",
3176 FT_BOOLEAN, 32, NULL, AR_G_SEARCH,
3177 "Group has search access", HFILL }},
3179 { &hf_afp_dir_ar_g_read,
3180 { "Group has read access", "afp.dir_ar.g_read",
3181 FT_BOOLEAN, 32, NULL, AR_G_READ,
3182 "Group has read access", HFILL }},
3184 { &hf_afp_dir_ar_g_write,
3185 { "Group has write access", "afp.dir_ar.g_write",
3186 FT_BOOLEAN, 32, NULL, AR_G_WRITE,
3187 "Group has write access", HFILL }},
3189 { &hf_afp_dir_ar_e_search,
3190 { "Everyone has search access", "afp.dir_ar.e_search",
3191 FT_BOOLEAN, 32, NULL, AR_E_SEARCH,
3192 "Everyone has search access", HFILL }},
3194 { &hf_afp_dir_ar_e_read,
3195 { "Everyone has read access", "afp.dir_ar.e_read",
3196 FT_BOOLEAN, 32, NULL, AR_E_READ,
3197 "Everyone has read access", HFILL }},
3199 { &hf_afp_dir_ar_e_write,
3200 { "Everyone has write access", "afp.dir_ar.e_write",
3201 FT_BOOLEAN, 32, NULL, AR_E_WRITE,
3202 "Everyone has write access", HFILL }},
3204 { &hf_afp_dir_ar_u_search,
3205 { "User has search access", "afp.dir_ar.u_search",
3206 FT_BOOLEAN, 32, NULL, AR_U_SEARCH,
3207 "User has search access", HFILL }},
3209 { &hf_afp_dir_ar_u_read,
3210 { "User has read access", "afp.dir_ar.u_read",
3211 FT_BOOLEAN, 32, NULL, AR_U_READ,
3212 "User has read access", HFILL }},
3214 { &hf_afp_dir_ar_u_write,
3215 { "User has write access", "afp.dir_ar.u_write",
3216 FT_BOOLEAN, 32, NULL, AR_U_WRITE,
3217 "User has write access", HFILL }},
3219 { &hf_afp_dir_ar_blank,
3220 { "Blank access right", "afp.dir_ar.blank",
3221 FT_BOOLEAN, 32, NULL, AR_BLANK,
3222 "Blank access right", HFILL }},
3224 { &hf_afp_dir_ar_u_own,
3225 { "User is the owner", "afp.dir_ar.u_owner",
3226 FT_BOOLEAN, 32, NULL, AR_U_OWN,
3227 "Current user is the directory owner", HFILL }},
3230 static gint *ett[] = {
3232 &ett_afp_vol_bitmap,
3233 &ett_afp_vol_attribute,
3234 &ett_afp_dir_bitmap,
3235 &ett_afp_file_bitmap,
3237 &ett_afp_enumerate_line,
3238 &ett_afp_access_mode,
3239 &ett_afp_dir_attribute,
3240 &ett_afp_file_attribute,
3242 &ett_afp_lock_flags,
3246 proto_afp = proto_register_protocol("AppleTalk Filing Protocol", "AFP", "afp");
3247 proto_register_field_array(proto_afp, hf, array_length(hf));
3248 proto_register_subtree_array(ett, array_length(ett));
3250 register_init_routine( &afp_reinit);
3252 register_dissector("afp", dissect_afp, proto_afp);
3253 data_handle = find_dissector("data");
3257 proto_reg_handoff_afp(void)
3259 data_handle = find_dissector("data");
3262 /* -------------------------------