2 * Routines for AFS packet dissection
3 * Copyright 1999, Nathan Neulinger <nneul@umr.edu>
4 * Based on routines from tcpdump patches by
5 * Ken Hornstein <kenh@cmf.nrl.navy.mil>
6 * Portions based on information retrieved from the RX definitions
7 * in Arla, the free AFS client at http://www.stacken.kth.se/project/arla/
8 * Portions based on information/specs retrieved from the OpenAFS sources at
9 * www.openafs.org, Copyright IBM.
11 * $Id: packet-afs.c,v 1.27 2001/03/23 21:42:37 nneul Exp $
13 * Ethereal - Network traffic analyzer
14 * By Gerald Combs <gerald@zing.org>
15 * Copyright 1998 Gerald Combs
17 * Copied from packet-tftp.c
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #ifdef HAVE_SYS_TYPES_H
41 # include <sys/types.h>
44 #ifdef HAVE_NETINET_IN_H
45 # include <netinet/in.h>
51 #include "conversation.h"
54 #include "packet-rx.h"
55 #include "packet-afs.h"
56 #include "packet-afs-defs.h"
57 #include "packet-afs-macros.h"
60 int afs_packet_init_count = 100;
62 struct afs_request_key {
63 guint32 conversation, callnumber;
67 struct afs_request_val {
71 GHashTable *afs_request_hash = NULL;
72 GMemChunk *afs_request_keys = NULL;
73 GMemChunk *afs_request_vals = NULL;
78 * Dissector prototypes
80 static void dissect_fs_request(const u_char *pd,
81 int offset, frame_data *fd, proto_tree *tree, int opcode);
82 static void dissect_fs_reply(const u_char *pd,
83 int offset, frame_data *fd, proto_tree *tree, int opcode);
84 static void dissect_cb_request(const u_char *pd,
85 int offset, frame_data *fd, proto_tree *tree, int opcode);
86 static void dissect_cb_reply(const u_char *pd,
87 int offset, frame_data *fd, proto_tree *tree, int opcode);
88 static void dissect_bos_request(const u_char *pd,
89 int offset, frame_data *fd, proto_tree *tree, int opcode);
90 static void dissect_bos_reply(const u_char *pd,
91 int offset, frame_data *fd, proto_tree *tree, int opcode);
92 static void dissect_vol_request(const u_char *pd,
93 int offset, frame_data *fd, proto_tree *tree, int opcode);
94 static void dissect_vol_reply(const u_char *pd,
95 int offset, frame_data *fd, proto_tree *tree, int opcode);
96 static void dissect_ubik_request(const u_char *pd,
97 int offset, frame_data *fd, proto_tree *tree, int opcode);
98 static void dissect_ubik_reply(const u_char *pd,
99 int offset, frame_data *fd, proto_tree *tree, int opcode);
100 static void dissect_kauth_request(const u_char *pd,
101 int offset, frame_data *fd, proto_tree *tree, int opcode);
102 static void dissect_kauth_reply(const u_char *pd,
103 int offset, frame_data *fd, proto_tree *tree, int opcode);
104 static void dissect_prot_request(const u_char *pd,
105 int offset, frame_data *fd, proto_tree *tree, int opcode);
106 static void dissect_prot_reply(const u_char *pd,
107 int offset, frame_data *fd, proto_tree *tree, int opcode);
108 static void dissect_vldb_request(const u_char *pd,
109 int offset, frame_data *fd, proto_tree *tree, int opcode);
110 static void dissect_vldb_reply(const u_char *pd,
111 int offset, frame_data *fd, proto_tree *tree, int opcode);
112 static void dissect_backup_request(const u_char *pd,
113 int offset, frame_data *fd, proto_tree *tree, int opcode);
114 static void dissect_backup_reply(const u_char *pd,
115 int offset, frame_data *fd, proto_tree *tree, int opcode);
122 afs_equal(gconstpointer v, gconstpointer w)
124 struct afs_request_key *v1 = (struct afs_request_key *)v;
125 struct afs_request_key *v2 = (struct afs_request_key *)w;
127 if (v1 -> conversation == v2 -> conversation &&
128 v1 -> service == v2 -> service &&
129 v1 -> callnumber == v2 -> callnumber ) {
138 afs_hash (gconstpointer v)
140 struct afs_request_key *key = (struct afs_request_key *)v;
143 val = key -> conversation + key -> service + key -> callnumber;
149 * Protocol initialization
152 afs_init_protocol(void)
154 if (afs_request_hash)
155 g_hash_table_destroy(afs_request_hash);
156 if (afs_request_keys)
157 g_mem_chunk_destroy(afs_request_keys);
158 if (afs_request_vals)
159 g_mem_chunk_destroy(afs_request_vals);
161 afs_request_hash = g_hash_table_new(afs_hash, afs_equal);
162 afs_request_keys = g_mem_chunk_new("afs_request_keys",
163 sizeof(struct afs_request_key),
164 afs_packet_init_count * sizeof(struct afs_request_key),
166 afs_request_vals = g_mem_chunk_new("afs_request_vals",
167 sizeof(struct afs_request_val),
168 afs_packet_init_count * sizeof(struct afs_request_val),
175 * Dissection routines
179 dissect_afs(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
181 proto_tree *afs_tree, *afs_op_tree, *ti;
182 struct rx_header *rxh;
183 struct afs_header *afsh;
184 int port, node, typenode, opcode;
185 value_string const *vals;
188 conversation_t *conversation;
189 struct afs_request_key request_key, *new_request_key;
190 struct afs_request_val *request_val;
191 void (*dissector)(const u_char *pd, int offset,
192 frame_data *fd, proto_tree *tree, int opcode);
194 OLD_CHECK_DISPLAY_AS_DATA(proto_afs, pd, offset, fd, tree);
196 /* get at least a full packet structure */
197 if ( !BYTES_ARE_IN_FRAME(offset, sizeof(struct rx_header)) )
200 if (check_col(fd, COL_PROTOCOL))
201 col_set_str(fd, COL_PROTOCOL, "AFS (RX)");
203 rxh = (struct rx_header *) &pd[offset];
204 doffset = offset + sizeof(struct rx_header);
205 afsh = (struct afs_header *) &pd[doffset];
207 reply = (rxh->flags & RX_CLIENT_INITIATED) == 0;
208 port = ((reply == 0) ? pi.destport : pi.srcport );
211 * Find out what conversation this packet is part of.
212 * XXX - this should really be done by the transport-layer protocol,
213 * although for connectionless transports, we may not want to do that
214 * unless we know some higher-level protocol will want it - or we
215 * may want to do it, so you can say e.g. "show only the packets in
216 * this UDP 'connection'".
218 * Note that we don't have to worry about the direction this packet
219 * was going - the conversation code handles that for us, treating
220 * packets from A:X to B:Y as being part of the same conversation as
221 * packets from B:Y to A:X.
223 conversation = find_conversation(&pi.src, &pi.dst, pi.ptype,
224 pi.srcport, pi.destport, 0);
225 if (conversation == NULL) {
226 /* It's not part of any conversation - create a new one. */
227 conversation = conversation_new(&pi.src, &pi.dst, pi.ptype,
228 pi.srcport, pi.destport, NULL, 0);
231 request_key.conversation = conversation->index;
232 request_key.service = pntohs(&rxh->serviceId);
233 request_key.callnumber = pntohl(&rxh->callNumber);
235 request_val = (struct afs_request_val *) g_hash_table_lookup(
236 afs_request_hash, &request_key);
238 /* only allocate a new hash element when it's a request */
240 if ( !request_val && !reply)
242 new_request_key = g_mem_chunk_alloc(afs_request_keys);
243 *new_request_key = request_key;
245 request_val = g_mem_chunk_alloc(afs_request_vals);
246 request_val -> opcode = pntohl(&afsh->opcode);
248 g_hash_table_insert(afs_request_hash, new_request_key,
254 opcode = request_val->opcode;
264 typenode = hf_afs_fs;
265 node = hf_afs_fs_opcode;
267 dissector = reply ? dissect_fs_reply : dissect_fs_request;
270 typenode = hf_afs_cb;
271 node = hf_afs_cb_opcode;
273 dissector = reply ? dissect_cb_reply : dissect_cb_request;
276 typenode = hf_afs_prot;
277 node = hf_afs_prot_opcode;
279 dissector = reply ? dissect_prot_reply : dissect_prot_request;
282 typenode = hf_afs_vldb;
283 node = hf_afs_vldb_opcode;
285 dissector = reply ? dissect_vldb_reply : dissect_vldb_request;
288 typenode = hf_afs_kauth;
289 node = hf_afs_kauth_opcode;
291 dissector = reply ? dissect_kauth_reply : dissect_kauth_request;
294 typenode = hf_afs_vol;
295 node = hf_afs_vol_opcode;
297 dissector = reply ? dissect_vol_reply : dissect_vol_request;
300 typenode = hf_afs_error;
301 node = hf_afs_error_opcode;
302 /* dissector = reply ? dissect_error_reply : dissect_error_request; */
305 typenode = hf_afs_bos;
306 node = hf_afs_bos_opcode;
308 dissector = reply ? dissect_bos_reply : dissect_bos_request;
310 case AFS_PORT_UPDATE:
311 typenode = hf_afs_update;
312 node = hf_afs_update_opcode;
314 /* dissector = reply ? dissect_update_reply : dissect_update_request; */
316 case AFS_PORT_RMTSYS:
317 typenode = hf_afs_rmtsys;
318 node = hf_afs_rmtsys_opcode;
320 /* dissector = reply ? dissect_rmtsys_reply : dissect_rmtsys_request; */
322 case AFS_PORT_BACKUP:
323 typenode = hf_afs_backup;
324 node = hf_afs_backup_opcode;
326 dissector = reply ? dissect_backup_reply : dissect_backup_request;
329 if ( (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
330 (opcode >= DISK_LOW && opcode <= DISK_HIGH) )
332 typenode = hf_afs_ubik;
333 node = hf_afs_ubik_opcode;
335 dissector = reply ? dissect_ubik_reply : dissect_ubik_request;
340 if (check_col(fd, COL_INFO))
341 col_add_fstr(fd, COL_INFO, "%s %s: %s (%d)",
342 val_to_str(port, port_types_short, "Unknown(%d)"),
343 reply ? "Reply" : "Request",
344 val_to_str(opcode, vals, "Unknown(%d)"), opcode);
348 if (check_col(fd, COL_INFO))
349 col_add_fstr(fd, COL_INFO, "%s %s: Unknown(%d)",
350 val_to_str(port, port_types_short, "Unknown(%d)"),
351 reply ? "Reply" : "Request",
356 ti = proto_tree_add_item(tree, proto_afs, NullTVB, doffset, END_OF_FRAME, FALSE);
357 afs_tree = proto_item_add_subtree(ti, ett_afs);
359 if ( !BYTES_ARE_IN_FRAME(offset, sizeof(struct rx_header) +
360 sizeof(struct afs_header)) &&
361 typenode != hf_afs_ubik )
363 proto_tree_add_text(afs_tree, NullTVB, doffset, END_OF_FRAME,
364 "Service: %s %s (Truncated)",
365 val_to_str(port, port_types, "Unknown(%d)"),
366 reply ? "Reply" : "Request");
371 proto_tree_add_text(afs_tree, NullTVB, doffset, END_OF_FRAME,
373 val_to_str(port, port_types, "Unknown(%d)"),
374 reply ? "Reply" : "Request");
377 /* until we do cache, can't handle replies */
379 if ( !reply && node != 0 )
381 ti = proto_tree_add_uint(afs_tree,
382 node, NullTVB, doffset, 4, opcode);
384 else if ( reply && node != 0 )
386 /* the opcode isn't in this packet */
387 ti = proto_tree_add_uint(afs_tree,
388 node, NullTVB, doffset, 0, opcode);
392 ti = proto_tree_add_text(afs_tree, NullTVB,
393 doffset, 0, "Operation: Unknown");
396 /* Add the subtree for this particular service */
397 afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
401 /* indicate the type of request */
402 proto_tree_add_boolean_hidden(afs_tree, typenode, NullTVB, doffset, 0, 1);
405 /* Process the packet according to what service it is */
408 (*dissector)(pd,offset,fd,afs_op_tree,opcode);
412 /* if it's the last packet, and it's a reply, remove opcode
414 /* ignoring for now, I'm not sure how the chunk deallocation works */
415 if ( rxh->flags & RX_LAST_PACKET && reply )
423 * Here is a helper routine for adding an AFS acl to the proto tree
424 * This is to be used with FS packets only
426 * An AFS ACL is a string that has the following format:
428 * <positive> <negative>
432 * "positive" and "negative" are integers which contain the number of
433 * positive and negative ACL's in the string. The uid/aclbits pair are
434 * ASCII strings containing the UID/PTS record and and a ascii number
435 * representing a logical OR of all the ACL permission bits
438 static void dissect_acl(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
444 char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
450 TRUNC(sizeof(guint32));
451 bytes = pntohl(&pd[curoffset]);
452 OUT_UINT(hf_afs_fs_acl_datasize);
457 eoff = curoffset+bytes;
462 if (sscanf((char *) s, "%d %n", &pos, &n) != 1)
466 proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, NullTVB, curoffset, n, pos);
469 if (sscanf((char *) s, "%d %n", &neg, &n) != 1)
473 proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, NullTVB, curoffset, n, neg);
478 * This wacky order preserves the order used by the "fs" command
481 for (i = 0; i < pos; i++) {
482 if (sscanf((char *) s, "%127s %d %n", user, &acl, &n) != 2)
485 ACLOUT(user,1,acl,n);
490 for (i = 0; i < neg; i++) {
491 if (sscanf((char *) s, "%127s %d %n", user, &acl, &n) != 2)
494 ACLOUT(user,0,acl,n);
502 * Here are the helper dissection routines
506 dissect_fs_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
508 struct rx_header *rxh;
510 int doffset, curoffset;
513 rxh = (struct rx_header *) &pd[offset];
514 data = (char *)rxh + sizeof(struct rx_header);
515 doffset = offset + sizeof(struct rx_header);
518 seq = pntohl(&rxh->seq);
520 if ( rxh->type == RX_PACKET_TYPE_DATA )
524 case 130: /* fetch data */
525 if ( seq == 1 ) /* only on first packet */
527 OUT_FS_AFSFetchStatus("Status");
528 OUT_FS_AFSCallBack();
531 OUT_BYTES_ALL(hf_afs_fs_data);
533 case 131: /* fetch acl */
534 dissect_acl(pd,curoffset,fd,tree);
535 OUT_FS_AFSFetchStatus("Status");
538 case 132: /* Fetch status */
539 OUT_FS_AFSFetchStatus("Status");
540 OUT_FS_AFSCallBack();
543 case 133: /* Store data */
544 case 134: /* Store ACL */
545 case 135: /* Store status */
546 case 136: /* Remove file */
547 OUT_FS_AFSFetchStatus("Status");
550 case 137: /* create file */
551 case 141: /* make dir */
552 case 161: /* lookup */
553 case 163: /* dfs symlink */
554 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
555 OUT_FS_AFSFetchStatus("File Status");
556 OUT_FS_AFSFetchStatus("Directory Status");
557 OUT_FS_AFSCallBack();
560 case 138: /* rename */
561 OUT_FS_AFSFetchStatus("Old Directory Status");
562 OUT_FS_AFSFetchStatus("New Directory Status");
565 case 139: /* symlink */
566 OUT_FS_AFSFid("Symlink");
568 OUT_FS_AFSFetchStatus("Symlink Status");
569 case 142: /* rmdir */
570 OUT_FS_AFSFetchStatus("Directory Status");
573 case 143: /* old set lock */
574 case 144: /* old extend lock */
575 case 145: /* old release lock */
576 case 147: /* give up callbacks */
577 case 150: /* set volume status */
578 case 152: /* check token */
579 /* nothing returned */
581 case 146: /* get statistics */
582 OUT_FS_ViceStatistics();
584 case 148: /* get volume info */
585 case 154: /* n-get-volume-info */
588 case 149: /* get volume status */
589 OUT_FS_AFSFetchVolumeStatus();
590 OUT_STRING(hf_afs_fs_volname);
591 OUT_STRING(hf_afs_fs_offlinemsg);
592 OUT_STRING(hf_afs_fs_motd);
594 case 151: /* root volume */
595 OUT_STRING(hf_afs_fs_volname);
597 case 153: /* get time */
598 OUT_TIMESTAMP(hf_afs_fs_timestamp);
600 case 155: /* bulk status */
601 OUT_FS_AFSBulkStats();
605 case 156: /* set lock */
606 case 157: /* extend lock */
607 case 158: /* release lock */
610 case 159: /* x-stats-version */
611 OUT_UINT(hf_afs_fs_xstats_version);
613 case 160: /* get xstats */
614 OUT_UINT(hf_afs_fs_xstats_version);
615 OUT_DATE(hf_afs_fs_xstats_timestamp);
616 OUT_FS_AFS_CollData();
618 case 162: /* flush cps */
619 OUT_UINT(hf_afs_fs_cps_spare2);
620 OUT_UINT(hf_afs_fs_cps_spare3);
624 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
626 OUT_UINT(hf_afs_fs_errcode);
631 dissect_fs_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
633 struct rx_header *rxh;
635 int doffset, curoffset;
637 rxh = (struct rx_header *) &pd[offset];
638 data = (char *)rxh + sizeof(struct rx_header);
639 doffset = offset + sizeof(struct rx_header);
646 case 130: /* Fetch data */
647 OUT_FS_AFSFid("Source");
648 OUT_UINT(hf_afs_fs_offset);
649 OUT_UINT(hf_afs_fs_length);
651 case 131: /* Fetch ACL */
652 OUT_FS_AFSFid("Target");
654 case 132: /* Fetch Status */
655 OUT_FS_AFSFid("Target");
657 case 133: /* Store Data */
658 OUT_FS_AFSFid("Destination");
659 OUT_FS_AFSStoreStatus("Status");
660 OUT_UINT(hf_afs_fs_offset);
661 OUT_UINT(hf_afs_fs_length);
662 OUT_UINT(hf_afs_fs_flength);
664 case 134: /* Store ACL */
665 OUT_FS_AFSFid("Target");
666 dissect_acl(pd,curoffset,fd,tree);
668 case 135: /* Store Status */
669 OUT_FS_AFSFid("Target");
670 OUT_FS_AFSStoreStatus("Status");
672 case 136: /* Remove File */
673 OUT_FS_AFSFid("Remove File");
674 OUT_STRING(hf_afs_fs_name);
676 case 137: /* Create File */
677 OUT_FS_AFSFid("Target");
678 OUT_STRING(hf_afs_fs_name);
679 OUT_FS_AFSStoreStatus("Status");
681 case 138: /* Rename file */
682 OUT_FS_AFSFid("Old");
683 OUT_STRING(hf_afs_fs_oldname);
684 OUT_FS_AFSFid("New");
685 OUT_STRING(hf_afs_fs_newname);
687 case 139: /* Symlink */
688 OUT_FS_AFSFid("File");
689 OUT_STRING(hf_afs_fs_symlink_name);
690 OUT_STRING(hf_afs_fs_symlink_content);
691 OUT_FS_AFSStoreStatus("Status");
694 OUT_FS_AFSFid("Link To (New File)");
695 OUT_STRING(hf_afs_fs_name);
696 OUT_FS_AFSFid("Link From (Old File)");
698 case 141: /* Make dir */
699 OUT_FS_AFSFid("Target");
700 OUT_STRING(hf_afs_fs_name);
701 OUT_FS_AFSStoreStatus("Status");
703 case 142: /* Remove dir */
704 OUT_FS_AFSFid("Target");
705 OUT_STRING(hf_afs_fs_name);
707 case 143: /* Old Set Lock */
708 OUT_FS_AFSFid("Target");
709 OUT_UINT(hf_afs_fs_vicelocktype);
712 case 144: /* Old Extend Lock */
713 OUT_FS_AFSFid("Target");
716 case 145: /* Old Release Lock */
717 OUT_FS_AFSFid("Target");
720 case 146: /* Get statistics */
723 case 147: /* Give up callbacks */
727 case 148: /* Get vol info */
728 OUT_STRING(hf_afs_fs_volname);
730 case 149: /* Get vol stats */
731 OUT_UINT(hf_afs_fs_volid);
733 case 150: /* Set vol stats */
734 OUT_UINT(hf_afs_fs_volid);
735 OUT_FS_AFSStoreVolumeStatus();
736 OUT_STRING(hf_afs_fs_volname);
737 OUT_STRING(hf_afs_fs_offlinemsg);
738 OUT_STRING(hf_afs_fs_motd);
740 case 151: /* get root volume */
743 case 152: /* check token */
744 OUT_UINT(hf_afs_fs_viceid);
747 case 153: /* get time */
750 case 154: /* new get vol info */
751 OUT_STRING(hf_afs_fs_volname);
753 case 155: /* bulk stat */
756 case 156: /* Set Lock */
757 OUT_FS_AFSFid("Target");
758 OUT_UINT(hf_afs_fs_vicelocktype);
760 case 157: /* Extend Lock */
761 OUT_FS_AFSFid("Target");
763 case 158: /* Release Lock */
764 OUT_FS_AFSFid("Target");
766 case 159: /* xstats version */
769 case 160: /* get xstats */
770 OUT_UINT(hf_afs_fs_xstats_clientversion);
771 OUT_UINT(hf_afs_fs_xstats_collnumber);
773 case 161: /* lookup */
774 OUT_FS_AFSFid("Target");
775 OUT_STRING(hf_afs_fs_name);
777 case 162: /* flush cps */
780 OUT_UINT(hf_afs_fs_cps_spare1);
782 case 163: /* dfs symlink */
783 OUT_FS_AFSFid("Target");
784 OUT_STRING(hf_afs_fs_symlink_name);
785 OUT_STRING(hf_afs_fs_symlink_content);
786 OUT_FS_AFSStoreStatus("Symlink Status");
795 dissect_bos_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
797 struct rx_header *rxh;
799 int doffset, curoffset;
801 rxh = (struct rx_header *) &pd[offset];
802 data = (char *)rxh + sizeof(struct rx_header);
803 doffset = offset + sizeof(struct rx_header);
806 if ( rxh->type == RX_PACKET_TYPE_DATA )
810 case 80: /* create bnode */
813 case 81: /* delete bnode */
816 case 82: /* set status */
819 case 83: /* get status */
820 OUT_INT(hf_afs_bos_status);
821 OUT_STRING(hf_afs_bos_statusdesc);
823 case 84: /* enumerate instance */
824 OUT_STRING(hf_afs_bos_instance);
826 case 85: /* get instance info */
827 OUT_STRING(hf_afs_bos_type);
830 case 86: /* get instance parm */
831 OUT_STRING(hf_afs_bos_parm);
833 case 87: /* add siperuser */
836 case 88: /* delete superuser */
839 case 89: /* list superusers */
840 OUT_STRING(hf_afs_bos_user);
842 case 90: /* list keys */
843 OUT_UINT(hf_afs_bos_kvno);
847 case 91: /* add key */
850 case 92: /* delete key */
853 case 93: /* set cell name */
856 case 94: /* get cell name */
857 OUT_STRING(hf_afs_bos_cell);
859 case 95: /* get cell host */
860 OUT_STRING(hf_afs_bos_host);
862 case 96: /* add cell host */
865 case 97: /* delete cell host */
868 case 98: /* set tstatus */
871 case 99: /* shutdown all */
874 case 100: /* restart all */
877 case 101: /* startup all */
880 case 102: /* set noauth flag */
883 case 103: /* rebozo */
886 case 104: /* restart */
889 case 105: /* install */
892 case 106: /* uninstall */
895 case 107: /* get dates */
896 OUT_DATE(hf_afs_bos_newtime);
897 OUT_DATE(hf_afs_bos_baktime);
898 OUT_DATE(hf_afs_bos_oldtime);
903 case 109: /* prune */
906 case 110: /* set restart time */
909 case 111: /* get restart time */
912 case 112: /* get log */
913 /* need to make this dump a big string somehow */
914 OUT_BYTES_ALL(hf_afs_bos_data);
916 case 113: /* wait all */
919 case 114: /* get instance strings */
920 OUT_STRING(hf_afs_bos_error);
921 OUT_STRING(hf_afs_bos_spare1);
922 OUT_STRING(hf_afs_bos_spare2);
923 OUT_STRING(hf_afs_bos_spare3);
927 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
929 OUT_UINT(hf_afs_bos_errcode);
934 dissect_bos_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
936 struct rx_header *rxh;
938 int doffset, curoffset;
940 rxh = (struct rx_header *) &pd[offset];
941 data = (char *)rxh + sizeof(struct rx_header);
942 doffset = offset + sizeof(struct rx_header);
949 case 80: /* create b node */
950 OUT_STRING(hf_afs_bos_type);
951 OUT_STRING(hf_afs_bos_instance);
952 OUT_STRING(hf_afs_bos_parm);
953 OUT_STRING(hf_afs_bos_parm);
954 OUT_STRING(hf_afs_bos_parm);
955 OUT_STRING(hf_afs_bos_parm);
956 OUT_STRING(hf_afs_bos_parm);
957 OUT_STRING(hf_afs_bos_parm);
959 case 81: /* delete b node */
960 OUT_STRING(hf_afs_bos_instance);
962 case 82: /* set status */
963 OUT_STRING(hf_afs_bos_instance);
964 OUT_UINT(hf_afs_bos_status);
966 case 83: /* get status */
967 OUT_STRING(hf_afs_bos_instance);
969 case 84: /* enumerate instance */
970 OUT_UINT(hf_afs_bos_num);
972 case 85: /* get instance info */
973 OUT_STRING(hf_afs_bos_instance);
975 case 86: /* get instance parm */
976 OUT_STRING(hf_afs_bos_instance);
977 OUT_UINT(hf_afs_bos_num);
979 case 87: /* add super user */
980 OUT_STRING(hf_afs_bos_user);
982 case 88: /* delete super user */
983 OUT_STRING(hf_afs_bos_user);
985 case 89: /* list super users */
986 OUT_UINT(hf_afs_bos_num);
988 case 90: /* list keys */
989 OUT_UINT(hf_afs_bos_num);
991 case 91: /* add key */
992 OUT_UINT(hf_afs_bos_num);
995 case 92: /* delete key */
996 OUT_UINT(hf_afs_bos_num);
998 case 93: /* set cell name */
999 OUT_STRING(hf_afs_bos_content);
1001 case 95: /* set cell host */
1002 OUT_UINT(hf_afs_bos_num);
1004 case 96: /* add cell host */
1005 OUT_STRING(hf_afs_bos_content);
1007 case 97: /* delete cell host */
1008 OUT_STRING(hf_afs_bos_content);
1010 case 98: /* set t status */
1011 OUT_STRING(hf_afs_bos_content);
1012 OUT_UINT(hf_afs_bos_status);
1014 case 99: /* shutdown all */
1017 case 100: /* restart all */
1020 case 101: /* startup all */
1023 case 102: /* set no-auth flag */
1024 OUT_UINT(hf_afs_bos_flags);
1026 case 103: /* re-bozo? */
1029 case 104: /* restart */
1030 OUT_STRING(hf_afs_bos_instance);
1032 case 105: /* install */
1033 OUT_STRING(hf_afs_bos_path);
1034 OUT_UINT(hf_afs_bos_size);
1035 OUT_UINT(hf_afs_bos_flags);
1036 OUT_UINT(hf_afs_bos_date);
1038 case 106: /* uninstall */
1039 OUT_STRING(hf_afs_bos_path);
1041 case 107: /* get dates */
1042 OUT_STRING(hf_afs_bos_path);
1044 case 108: /* exec */
1045 OUT_STRING(hf_afs_bos_cmd);
1047 case 109: /* prune */
1048 OUT_UINT(hf_afs_bos_flags);
1050 case 110: /* set restart time */
1051 OUT_UINT(hf_afs_bos_num);
1054 case 111: /* get restart time */
1055 OUT_UINT(hf_afs_bos_num);
1057 case 112: /* get log */
1058 OUT_STRING(hf_afs_bos_file);
1060 case 113: /* wait all */
1063 case 114: /* get instance strings */
1064 OUT_STRING(hf_afs_bos_content);
1073 dissect_vol_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1075 struct rx_header *rxh;
1076 unsigned char *data;
1077 int doffset, curoffset;
1079 rxh = (struct rx_header *) &pd[offset];
1080 data = (char *)rxh + sizeof(struct rx_header);
1081 doffset = offset + sizeof(struct rx_header);
1082 curoffset = doffset;
1084 if ( rxh->type == RX_PACKET_TYPE_DATA )
1089 /* should loop here maybe */
1090 OUT_UINT(hf_afs_vol_count);
1091 VECOUT(hf_afs_vol_name, 32); /* not sure on */
1095 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1097 OUT_UINT(hf_afs_vol_errcode);
1102 dissect_vol_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1104 struct rx_header *rxh;
1105 unsigned char *data;
1106 int doffset, curoffset;
1108 rxh = (struct rx_header *) &pd[offset];
1109 data = (char *)rxh + sizeof(struct rx_header);
1110 doffset = offset + sizeof(struct rx_header);
1111 curoffset = doffset;
1117 case 121: /* list one vol */
1118 OUT_UINT(hf_afs_vol_count);
1119 OUT_UINT(hf_afs_vol_id);
1128 dissect_kauth_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1130 struct rx_header *rxh;
1131 unsigned char *data;
1132 int doffset, curoffset;
1134 rxh = (struct rx_header *) &pd[offset];
1135 data = (char *)rxh + sizeof(struct rx_header);
1136 doffset = offset + sizeof(struct rx_header);
1137 curoffset = doffset;
1139 if ( rxh->type == RX_PACKET_TYPE_DATA )
1145 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1147 OUT_UINT(hf_afs_kauth_errcode);
1152 dissect_kauth_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1154 struct rx_header *rxh;
1155 unsigned char *data;
1156 int doffset, curoffset;
1158 rxh = (struct rx_header *) &pd[offset];
1159 data = (char *)rxh + sizeof(struct rx_header);
1160 doffset = offset + sizeof(struct rx_header);
1161 curoffset = doffset;
1167 case 1: /* authenticate old */
1168 case 21: /* authenticate */
1169 case 22: /* authenticate v2 */
1170 case 2: /* change pw */
1171 case 5: /* set fields */
1172 case 6: /* create user */
1173 case 7: /* delete user */
1174 case 8: /* get entry */
1175 case 14: /* unlock */
1176 case 15: /* lock status */
1177 OUT_STRING(hf_afs_kauth_princ);
1178 OUT_STRING(hf_afs_kauth_realm);
1179 OUT_BYTES_ALL(hf_afs_kauth_data);
1181 case 3: /* getticket-old */
1182 case 23: /* getticket */
1183 OUT_UINT(hf_afs_kauth_kvno);
1184 OUT_STRING(hf_afs_kauth_domain);
1185 OUT_STRING(hf_afs_kauth_data);
1186 OUT_STRING(hf_afs_kauth_princ);
1187 OUT_STRING(hf_afs_kauth_realm);
1189 case 4: /* set pass */
1190 OUT_STRING(hf_afs_kauth_princ);
1191 OUT_STRING(hf_afs_kauth_realm);
1192 OUT_UINT(hf_afs_kauth_kvno);
1194 case 12: /* get pass */
1195 OUT_STRING(hf_afs_kauth_name);
1204 dissect_cb_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1206 struct rx_header *rxh;
1207 unsigned char *data;
1208 int doffset, curoffset;
1210 rxh = (struct rx_header *) &pd[offset];
1211 data = (char *)rxh + sizeof(struct rx_header);
1212 doffset = offset + sizeof(struct rx_header);
1213 curoffset = doffset;
1215 if ( rxh->type == RX_PACKET_TYPE_DATA )
1221 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1223 OUT_UINT(hf_afs_cb_errcode);
1228 dissect_cb_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1230 struct rx_header *rxh;
1231 unsigned char *data;
1232 int doffset, curoffset;
1234 rxh = (struct rx_header *) &pd[offset];
1235 data = (char *)rxh + sizeof(struct rx_header);
1236 doffset = offset + sizeof(struct rx_header);
1237 curoffset = doffset;
1243 case 204: /* callback */
1252 OUT_CB_AFSFid("Target");
1259 OUT_CB_AFSCallBack();
1269 dissect_prot_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1271 struct rx_header *rxh;
1272 unsigned char *data;
1273 int doffset, curoffset;
1275 rxh = (struct rx_header *) &pd[offset];
1276 data = (char *)rxh + sizeof(struct rx_header);
1277 doffset = offset + sizeof(struct rx_header);
1278 curoffset = doffset;
1280 if ( rxh->type == RX_PACKET_TYPE_DATA )
1284 case 504: /* name to id */
1290 OUT_UINT(hf_afs_prot_count);
1294 OUT_UINT(hf_afs_prot_id);
1298 case 505: /* id to name */
1304 OUT_UINT(hf_afs_prot_count);
1308 VECOUT(hf_afs_prot_name, PRNAMEMAX);
1312 case 508: /* get cps */
1313 case 514: /* list elements */
1314 case 517: /* list owned */
1315 case 518: /* get cps2 */
1316 case 519: /* get host cps */
1322 OUT_UINT(hf_afs_prot_count);
1326 OUT_UINT(hf_afs_prot_id);
1330 case 510: /* list max */
1331 OUT_UINT(hf_afs_prot_maxuid);
1332 OUT_UINT(hf_afs_prot_maxgid);
1336 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1338 OUT_UINT(hf_afs_prot_errcode);
1343 dissect_prot_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1345 struct rx_header *rxh;
1346 unsigned char *data;
1347 int doffset, curoffset;
1349 rxh = (struct rx_header *) &pd[offset];
1350 data = (char *)rxh + sizeof(struct rx_header);
1351 doffset = offset + sizeof(struct rx_header);
1352 curoffset = doffset;
1358 case 500: /* new user */
1359 OUT_STRING(hf_afs_prot_name);
1360 OUT_UINT(hf_afs_prot_id);
1361 OUT_UINT(hf_afs_prot_oldid);
1363 case 501: /* where is it */
1364 case 506: /* delete */
1365 case 508: /* get cps */
1366 case 512: /* list entry */
1367 case 514: /* list elements */
1368 case 517: /* list owned */
1369 case 519: /* get host cps */
1370 OUT_UINT(hf_afs_prot_id);
1372 case 502: /* dump entry */
1373 OUT_UINT(hf_afs_prot_pos);
1375 case 503: /* add to group */
1376 case 507: /* remove from group */
1377 case 515: /* is a member of? */
1378 OUT_UINT(hf_afs_prot_uid);
1379 OUT_UINT(hf_afs_prot_gid);
1381 case 504: /* name to id */
1387 OUT_UINT(hf_afs_prot_count);
1391 VECOUT(hf_afs_prot_name,PRNAMEMAX);
1395 case 505: /* id to name */
1401 OUT_UINT(hf_afs_prot_count);
1405 OUT_UINT(hf_afs_prot_id);
1409 case 509: /* new entry */
1410 OUT_STRING(hf_afs_prot_name);
1411 OUT_UINT(hf_afs_prot_flag);
1412 OUT_UINT(hf_afs_prot_oldid);
1414 case 511: /* set max */
1415 OUT_UINT(hf_afs_prot_id);
1416 OUT_UINT(hf_afs_prot_flag);
1418 case 513: /* change entry */
1419 OUT_UINT(hf_afs_prot_id);
1420 OUT_STRING(hf_afs_prot_name);
1421 OUT_UINT(hf_afs_prot_oldid);
1422 OUT_UINT(hf_afs_prot_newid);
1424 case 520: /* update entry */
1425 OUT_UINT(hf_afs_prot_id);
1426 OUT_STRING(hf_afs_prot_name);
1435 dissect_vldb_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1437 struct rx_header *rxh;
1438 unsigned char *data;
1439 int doffset, curoffset;
1441 rxh = (struct rx_header *) &pd[offset];
1442 data = (char *)rxh + sizeof(struct rx_header);
1443 doffset = offset + sizeof(struct rx_header);
1444 curoffset = doffset;
1446 if ( rxh->type == RX_PACKET_TYPE_DATA )
1450 case 510: /* list entry */
1451 OUT_UINT(hf_afs_vldb_count);
1452 OUT_UINT(hf_afs_vldb_nextindex);
1454 case 503: /* get entry by id */
1455 case 504: /* get entry by name */
1458 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1460 nservers = GETINT();
1461 OUT_UINT(hf_afs_vldb_numservers);
1466 OUT_IP(hf_afs_vldb_server);
1478 strcpy(part, "/vicepa");
1479 if ( i<nservers && j<=25 )
1481 part[6] = 'a' + (char) j;
1482 proto_tree_add_string(tree, hf_afs_vldb_partition, NullTVB,
1483 curoffset, 4, part);
1487 SKIP(8 * sizeof(guint32));
1488 OUT_UINT(hf_afs_vldb_rwvol);
1489 OUT_UINT(hf_afs_vldb_rovol);
1490 OUT_UINT(hf_afs_vldb_bkvol);
1493 case 505: /* get new volume id */
1494 OUT_UINT(hf_afs_vldb_id);
1496 case 521: /* list entry */
1497 case 529: /* list entry U */
1498 OUT_UINT(hf_afs_vldb_count);
1499 OUT_UINT(hf_afs_vldb_nextindex);
1501 case 518: /* get entry by id n */
1502 case 519: /* get entry by name N */
1505 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1507 nservers = GETINT();
1508 OUT_UINT(hf_afs_vldb_numservers);
1509 for (i=0; i<13; i++)
1513 OUT_IP(hf_afs_vldb_server);
1520 for (i=0; i<13; i++)
1525 strcpy(part, "/vicepa");
1526 if ( i<nservers && j<=25 )
1528 part[6] = 'a' + (char) j;
1529 proto_tree_add_string(tree, hf_afs_vldb_partition, NullTVB,
1530 curoffset, 4, part);
1534 SKIP(13 * sizeof(guint32));
1535 OUT_UINT(hf_afs_vldb_rwvol);
1536 OUT_UINT(hf_afs_vldb_rovol);
1537 OUT_UINT(hf_afs_vldb_bkvol);
1540 case 526: /* get entry by id u */
1541 case 527: /* get entry by name u */
1544 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1546 nservers = GETINT();
1547 OUT_UINT(hf_afs_vldb_numservers);
1548 for (i=0; i<13; i++)
1552 OUT_BYTES(hf_afs_vldb_serveruuid, 11*sizeof(guint32));
1556 SKIP(11*sizeof(guint32));
1559 for (i=0; i<13; i++)
1564 strcpy(part, "/vicepa");
1565 if ( i<nservers && j<=25 )
1567 part[6] = 'a' + (char) j;
1568 proto_tree_add_string(tree, hf_afs_vldb_partition, NullTVB,
1569 curoffset, 4, part);
1573 SKIP(13 * sizeof(guint32));
1574 OUT_UINT(hf_afs_vldb_rwvol);
1575 OUT_UINT(hf_afs_vldb_rovol);
1576 OUT_UINT(hf_afs_vldb_bkvol);
1581 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1583 OUT_UINT(hf_afs_vldb_errcode);
1588 dissect_vldb_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1590 struct rx_header *rxh;
1591 unsigned char *data;
1592 int doffset, curoffset;
1594 rxh = (struct rx_header *) &pd[offset];
1595 data = (char *)rxh + sizeof(struct rx_header);
1596 doffset = offset + sizeof(struct rx_header);
1597 curoffset = doffset;
1603 case 501: /* create new volume */
1604 case 517: /* create entry N */
1605 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1607 case 502: /* delete entry */
1608 case 503: /* get entry by id */
1609 case 507: /* update entry */
1610 case 508: /* set lock */
1611 case 509: /* release lock */
1612 case 518: /* get entry by id */
1613 OUT_UINT(hf_afs_vldb_id);
1614 OUT_UINT(hf_afs_vldb_type);
1616 case 504: /* get entry by name */
1617 case 519: /* get entry by name N */
1618 case 524: /* update entry by name */
1619 case 527: /* get entry by name U */
1620 OUT_STRING(hf_afs_vldb_name);
1622 case 505: /* get new vol id */
1623 OUT_UINT(hf_afs_vldb_bump);
1625 case 506: /* replace entry */
1626 case 520: /* replace entry N */
1627 OUT_UINT(hf_afs_vldb_id);
1628 OUT_UINT(hf_afs_vldb_type);
1629 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1631 case 510: /* list entry */
1632 case 521: /* list entry N */
1633 OUT_UINT(hf_afs_vldb_index);
1642 dissect_ubik_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1644 struct rx_header *rxh;
1645 unsigned char *data;
1646 int doffset, curoffset;
1648 rxh = (struct rx_header *) &pd[offset];
1649 data = (char *)rxh + sizeof(struct rx_header);
1650 doffset = offset + sizeof(struct rx_header);
1651 curoffset = doffset;
1655 case 10000: /* vote-beacon */
1657 case 10001: /* vote-debug-old */
1658 /* ubik_debug_old */
1660 case 10002: /* vote-sdebug-old */
1661 /* ubik_sdebug_old */
1663 case 10003: /* vote-get syncsite */
1665 case 10004: /* vote-debug */
1668 case 10005: /* vote-sdebug */
1671 case 10006: /* vote-xdebug */
1675 case 10007: /* vote-xsdebug */
1680 case 20000: /* disk-begin */
1682 case 20004: /* get version */
1683 OUT_UBIKVERSION("DB Version");
1685 case 20010: /* disk-probe */
1692 dissect_ubik_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1694 struct rx_header *rxh;
1695 unsigned char *data;
1696 int doffset, curoffset;
1698 rxh = (struct rx_header *) &pd[offset];
1699 data = (char *)rxh + sizeof(struct rx_header);
1700 doffset = offset + sizeof(struct rx_header);
1701 curoffset = doffset;
1707 case 10000: /* vote-beacon */
1708 OUT_UINT(hf_afs_ubik_state);
1709 OUT_DATE(hf_afs_ubik_votestart);
1710 OUT_UBIKVERSION("DB Version");
1711 OUT_UBIKVERSION("TID");
1713 case 10001: /* vote-debug-old */
1715 case 10002: /* vote-sdebug-old */
1716 OUT_UINT(hf_afs_ubik_site);
1718 case 10003: /* vote-get sync site */
1719 OUT_IP(hf_afs_ubik_site);
1721 case 10004: /* vote-debug */
1722 case 10005: /* vote-sdebug */
1723 OUT_IP(hf_afs_ubik_site);
1725 case 20000: /* disk-begin */
1726 OUT_UBIKVERSION("TID");
1728 case 20001: /* disk-commit */
1729 OUT_UBIKVERSION("TID");
1731 case 20002: /* disk-lock */
1732 OUT_UBIKVERSION("TID");
1733 OUT_UINT(hf_afs_ubik_file);
1734 OUT_UINT(hf_afs_ubik_pos);
1735 OUT_UINT(hf_afs_ubik_length);
1736 OUT_UINT(hf_afs_ubik_locktype);
1738 case 20003: /* disk-write */
1739 OUT_UBIKVERSION("TID");
1740 OUT_UINT(hf_afs_ubik_file);
1741 OUT_UINT(hf_afs_ubik_pos);
1743 case 20004: /* disk-get version */
1745 case 20005: /* disk-get file */
1746 OUT_UINT(hf_afs_ubik_file);
1748 case 20006: /* disk-send file */
1749 OUT_UINT(hf_afs_ubik_file);
1750 OUT_UINT(hf_afs_ubik_length);
1751 OUT_UBIKVERSION("DB Version");
1753 case 20007: /* disk-abort */
1754 case 20008: /* disk-release locks */
1755 case 20010: /* disk-probe */
1757 case 20009: /* disk-truncate */
1758 OUT_UBIKVERSION("TID");
1759 OUT_UINT(hf_afs_ubik_file);
1760 OUT_UINT(hf_afs_ubik_length);
1762 case 20011: /* disk-writev */
1763 OUT_UBIKVERSION("TID");
1765 case 20012: /* disk-set version */
1766 OUT_UBIKVERSION("TID");
1767 OUT_UBIKVERSION("Old DB Version");
1768 OUT_UBIKVERSION("New DB Version");
1777 dissect_backup_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1779 struct rx_header *rxh;
1780 unsigned char *data;
1781 int doffset, curoffset;
1783 rxh = (struct rx_header *) &pd[offset];
1784 data = (char *)rxh + sizeof(struct rx_header);
1785 doffset = offset + sizeof(struct rx_header);
1786 curoffset = doffset;
1788 if ( rxh->type == RX_PACKET_TYPE_DATA )
1794 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1796 OUT_UINT(hf_afs_backup_errcode);
1801 dissect_backup_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1803 struct rx_header *rxh;
1804 unsigned char *data;
1805 int doffset, curoffset;
1807 rxh = (struct rx_header *) &pd[offset];
1808 data = (char *)rxh + sizeof(struct rx_header);
1809 doffset = offset + sizeof(struct rx_header);
1810 curoffset = doffset;
1820 * Registration code for registering the protocol and fields
1824 proto_register_afs(void)
1826 static hf_register_info hf[] = {
1827 #include "packet-afs-register-info.h"
1829 static gint *ett[] = {
1837 &ett_afs_status_mask,
1839 &ett_afs_volumeinfo,
1843 proto_afs = proto_register_protocol("Andrew File System (AFS)",
1845 proto_register_field_array(proto_afs, hf, array_length(hf));
1846 proto_register_subtree_array(ett, array_length(ett));
1847 register_init_routine(&afs_init_protocol);