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.25 2000/11/30 14:09:14 girlich 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;
266 typenode = hf_afs_fs;
267 node = hf_afs_fs_opcode;
269 dissector = reply ? dissect_fs_reply : dissect_fs_request;
272 typenode = hf_afs_cb;
273 node = hf_afs_cb_opcode;
275 dissector = reply ? dissect_cb_reply : dissect_cb_request;
278 typenode = hf_afs_prot;
279 node = hf_afs_prot_opcode;
281 dissector = reply ? dissect_prot_reply : dissect_prot_request;
284 typenode = hf_afs_vldb;
285 node = hf_afs_vldb_opcode;
287 dissector = reply ? dissect_vldb_reply : dissect_vldb_request;
290 typenode = hf_afs_kauth;
291 node = hf_afs_kauth_opcode;
293 dissector = reply ? dissect_kauth_reply : dissect_kauth_request;
296 typenode = hf_afs_vol;
297 node = hf_afs_vol_opcode;
299 dissector = reply ? dissect_vol_reply : dissect_vol_request;
302 typenode = hf_afs_error;
303 node = hf_afs_error_opcode;
304 /* dissector = reply ? dissect_error_reply : dissect_error_request; */
307 typenode = hf_afs_bos;
308 node = hf_afs_bos_opcode;
310 dissector = reply ? dissect_bos_reply : dissect_bos_request;
312 case AFS_PORT_UPDATE:
313 typenode = hf_afs_update;
314 node = hf_afs_update_opcode;
316 /* dissector = reply ? dissect_update_reply : dissect_update_request; */
318 case AFS_PORT_RMTSYS:
319 typenode = hf_afs_rmtsys;
320 node = hf_afs_rmtsys_opcode;
322 /* dissector = reply ? dissect_rmtsys_reply : dissect_rmtsys_request; */
324 case AFS_PORT_BACKUP:
325 typenode = hf_afs_backup;
326 node = hf_afs_backup_opcode;
328 dissector = reply ? dissect_backup_reply : dissect_backup_request;
331 if ( (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
332 (opcode >= DISK_LOW && opcode <= DISK_HIGH) )
334 typenode = hf_afs_ubik;
335 node = hf_afs_ubik_opcode;
337 dissector = reply ? dissect_ubik_reply : dissect_ubik_request;
342 if (check_col(fd, COL_INFO))
343 col_add_fstr(fd, COL_INFO, "%s %s: %s (%d)",
344 val_to_str(port, port_types_short, "Unknown(%d)"),
345 reply ? "Reply" : "Request",
346 val_to_str(opcode, vals, "Unknown(%d)"), opcode);
350 if (check_col(fd, COL_INFO))
351 col_add_fstr(fd, COL_INFO, "%s %s: Unknown(%d)",
352 val_to_str(port, port_types_short, "Unknown(%d)"),
353 reply ? "Reply" : "Request",
358 ti = proto_tree_add_item(tree, proto_afs, NullTVB, doffset, END_OF_FRAME, FALSE);
359 afs_tree = proto_item_add_subtree(ti, ett_afs);
361 if ( !BYTES_ARE_IN_FRAME(offset, sizeof(struct rx_header) +
362 sizeof(struct afs_header)) )
364 proto_tree_add_text(afs_tree, NullTVB, doffset, END_OF_FRAME,
365 "Service: %s %s (Truncated)",
366 val_to_str(port, port_types, "Unknown(%d)"),
367 reply ? "Reply" : "Request");
372 proto_tree_add_text(afs_tree, NullTVB, doffset, END_OF_FRAME,
374 val_to_str(port, port_types, "Unknown(%d)"),
375 reply ? "Reply" : "Request");
378 /* until we do cache, can't handle replies */
380 if ( !reply && node != 0 )
382 ti = proto_tree_add_uint(afs_tree,
383 node, NullTVB, doffset, 4, opcode);
385 else if ( reply && node != 0 )
387 /* the opcode isn't in this packet */
388 ti = proto_tree_add_uint(afs_tree,
389 node, NullTVB, doffset, 0, opcode);
393 ti = proto_tree_add_text(afs_tree, NullTVB,
394 doffset, 0, "Operation: Unknown");
397 /* Add the subtree for this particular service */
398 afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
402 /* indicate the type of request */
403 proto_tree_add_boolean_hidden(afs_tree, typenode, NullTVB, doffset, 0, 1);
406 /* Process the packet according to what service it is */
409 (*dissector)(pd,offset,fd,afs_op_tree,opcode);
413 /* if it's the last packet, and it's a reply, remove opcode
415 /* ignoring for now, I'm not sure how the chunk deallocation works */
416 if ( rxh->flags & RX_LAST_PACKET && reply )
424 * Here is a helper routine for adding an AFS acl to the proto tree
425 * This is to be used with FS packets only
427 * An AFS ACL is a string that has the following format:
429 * <positive> <negative>
433 * "positive" and "negative" are integers which contain the number of
434 * positive and negative ACL's in the string. The uid/aclbits pair are
435 * ASCII strings containing the UID/PTS record and and a ascii number
436 * representing a logical OR of all the ACL permission bits
439 static void dissect_acl(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
445 char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
451 TRUNC(sizeof(guint32));
452 bytes = pntohl(&pd[curoffset]);
453 OUT_UINT(hf_afs_fs_acl_datasize);
458 eoff = curoffset+bytes;
463 if (sscanf((char *) s, "%d %n", &pos, &n) != 1)
467 proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, NullTVB, curoffset, n, pos);
470 if (sscanf((char *) s, "%d %n", &neg, &n) != 1)
474 proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, NullTVB, curoffset, n, neg);
479 * This wacky order preserves the order used by the "fs" command
482 for (i = 0; i < pos; i++) {
483 if (sscanf((char *) s, "%127s %d %n", user, &acl, &n) != 2)
486 ACLOUT(user,1,acl,n);
491 for (i = 0; i < neg; i++) {
492 if (sscanf((char *) s, "%127s %d %n", user, &acl, &n) != 2)
495 ACLOUT(user,0,acl,n);
503 * Here are the helper dissection routines
507 dissect_fs_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
509 struct rx_header *rxh;
511 int doffset, curoffset;
514 rxh = (struct rx_header *) &pd[offset];
515 data = (char *)rxh + sizeof(struct rx_header);
516 doffset = offset + sizeof(struct rx_header);
519 seq = pntohl(&rxh->seq);
521 if ( rxh->type == RX_PACKET_TYPE_DATA )
525 case 130: /* fetch data */
526 if ( seq == 1 ) /* only on first packet */
528 OUT_FS_AFSFetchStatus("Status");
529 OUT_FS_AFSCallBack();
532 OUT_BYTES_ALL(hf_afs_fs_data);
534 case 131: /* fetch acl */
535 dissect_acl(pd,curoffset,fd,tree);
536 OUT_FS_AFSFetchStatus("Status");
539 case 132: /* Fetch status */
540 OUT_FS_AFSFetchStatus("Status");
541 OUT_FS_AFSCallBack();
544 case 133: /* Store data */
545 case 134: /* Store ACL */
546 case 135: /* Store status */
547 case 136: /* Remove file */
548 OUT_FS_AFSFetchStatus("Status");
551 case 137: /* create file */
552 case 141: /* make dir */
553 case 161: /* lookup */
554 case 163: /* dfs symlink */
555 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
556 OUT_FS_AFSFetchStatus("File Status");
557 OUT_FS_AFSFetchStatus("Directory Status");
558 OUT_FS_AFSCallBack();
561 case 138: /* rename */
562 OUT_FS_AFSFetchStatus("Old Directory Status");
563 OUT_FS_AFSFetchStatus("New Directory Status");
566 case 139: /* symlink */
567 OUT_FS_AFSFid("Symlink");
569 OUT_FS_AFSFetchStatus("Symlink Status");
570 case 142: /* rmdir */
571 OUT_FS_AFSFetchStatus("Directory Status");
574 case 143: /* old set lock */
575 case 144: /* old extend lock */
576 case 145: /* old release lock */
577 case 147: /* give up callbacks */
578 case 150: /* set volume status */
579 case 152: /* check token */
580 /* nothing returned */
582 case 146: /* get statistics */
583 OUT_FS_ViceStatistics();
585 case 148: /* get volume info */
586 case 154: /* n-get-volume-info */
589 case 149: /* get volume status */
590 OUT_FS_AFSFetchVolumeStatus();
591 OUT_STRING(hf_afs_fs_volname);
592 OUT_STRING(hf_afs_fs_offlinemsg);
593 OUT_STRING(hf_afs_fs_motd);
595 case 151: /* root volume */
596 OUT_STRING(hf_afs_fs_volname);
598 case 153: /* get time */
599 OUT_TIMESTAMP(hf_afs_fs_timestamp);
601 case 155: /* bulk status */
602 OUT_FS_AFSBulkStats();
606 case 156: /* set lock */
607 case 157: /* extend lock */
608 case 158: /* release lock */
611 case 159: /* x-stats-version */
612 OUT_UINT(hf_afs_fs_xstats_version);
614 case 160: /* get xstats */
615 OUT_UINT(hf_afs_fs_xstats_version);
616 OUT_DATE(hf_afs_fs_xstats_timestamp);
617 OUT_FS_AFS_CollData();
619 case 162: /* flush cps */
620 OUT_UINT(hf_afs_fs_cps_spare2);
621 OUT_UINT(hf_afs_fs_cps_spare3);
625 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
627 OUT_UINT(hf_afs_fs_errcode);
632 dissect_fs_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
634 struct rx_header *rxh;
636 int doffset, curoffset;
638 rxh = (struct rx_header *) &pd[offset];
639 data = (char *)rxh + sizeof(struct rx_header);
640 doffset = offset + sizeof(struct rx_header);
647 case 130: /* Fetch data */
648 OUT_FS_AFSFid("Source");
649 OUT_UINT(hf_afs_fs_offset);
650 OUT_UINT(hf_afs_fs_length);
652 case 131: /* Fetch ACL */
653 OUT_FS_AFSFid("Target");
655 case 132: /* Fetch Status */
656 OUT_FS_AFSFid("Target");
658 case 133: /* Store Data */
659 OUT_FS_AFSFid("Destination");
660 OUT_FS_AFSStoreStatus("Status");
661 OUT_UINT(hf_afs_fs_offset);
662 OUT_UINT(hf_afs_fs_length);
663 OUT_UINT(hf_afs_fs_flength);
665 case 134: /* Store ACL */
666 OUT_FS_AFSFid("Target");
667 dissect_acl(pd,curoffset,fd,tree);
669 case 135: /* Store Status */
670 OUT_FS_AFSFid("Target");
671 OUT_FS_AFSStoreStatus("Status");
673 case 136: /* Remove File */
674 OUT_FS_AFSFid("Remove File");
675 OUT_STRING(hf_afs_fs_name);
677 case 137: /* Create File */
678 OUT_FS_AFSFid("Target");
679 OUT_STRING(hf_afs_fs_name);
680 OUT_FS_AFSStoreStatus("Status");
682 case 138: /* Rename file */
683 OUT_FS_AFSFid("Old");
684 OUT_STRING(hf_afs_fs_oldname);
685 OUT_FS_AFSFid("New");
686 OUT_STRING(hf_afs_fs_newname);
688 case 139: /* Symlink */
689 OUT_FS_AFSFid("File");
690 OUT_STRING(hf_afs_fs_symlink_name);
691 OUT_STRING(hf_afs_fs_symlink_content);
692 OUT_FS_AFSStoreStatus("Status");
695 OUT_FS_AFSFid("Link To (New File)");
696 OUT_STRING(hf_afs_fs_name);
697 OUT_FS_AFSFid("Link From (Old File)");
699 case 141: /* Make dir */
700 OUT_FS_AFSFid("Target");
701 OUT_STRING(hf_afs_fs_name);
702 OUT_FS_AFSStoreStatus("Status");
704 case 142: /* Remove dir */
705 OUT_FS_AFSFid("Target");
706 OUT_STRING(hf_afs_fs_name);
708 case 143: /* Old Set Lock */
709 OUT_FS_AFSFid("Target");
710 OUT_UINT(hf_afs_fs_vicelocktype);
713 case 144: /* Old Extend Lock */
714 OUT_FS_AFSFid("Target");
717 case 145: /* Old Release Lock */
718 OUT_FS_AFSFid("Target");
721 case 146: /* Get statistics */
724 case 147: /* Give up callbacks */
728 case 148: /* Get vol info */
729 OUT_STRING(hf_afs_fs_volname);
731 case 149: /* Get vol stats */
732 OUT_UINT(hf_afs_fs_volid);
734 case 150: /* Set vol stats */
735 OUT_UINT(hf_afs_fs_volid);
736 OUT_FS_AFSStoreVolumeStatus();
737 OUT_STRING(hf_afs_fs_volname);
738 OUT_STRING(hf_afs_fs_offlinemsg);
739 OUT_STRING(hf_afs_fs_motd);
741 case 151: /* get root volume */
744 case 152: /* check token */
745 OUT_UINT(hf_afs_fs_viceid);
748 case 153: /* get time */
751 case 154: /* new get vol info */
752 OUT_STRING(hf_afs_fs_volname);
754 case 155: /* bulk stat */
757 case 156: /* Set Lock */
758 OUT_FS_AFSFid("Target");
759 OUT_UINT(hf_afs_fs_vicelocktype);
761 case 157: /* Extend Lock */
762 OUT_FS_AFSFid("Target");
764 case 158: /* Release Lock */
765 OUT_FS_AFSFid("Target");
767 case 159: /* xstats version */
770 case 160: /* get xstats */
771 OUT_UINT(hf_afs_fs_xstats_clientversion);
772 OUT_UINT(hf_afs_fs_xstats_collnumber);
774 case 161: /* lookup */
775 OUT_FS_AFSFid("Target");
776 OUT_STRING(hf_afs_fs_name);
778 case 162: /* flush cps */
781 OUT_UINT(hf_afs_fs_cps_spare1);
783 case 163: /* dfs symlink */
784 OUT_FS_AFSFid("Target");
785 OUT_STRING(hf_afs_fs_symlink_name);
786 OUT_STRING(hf_afs_fs_symlink_content);
787 OUT_FS_AFSStoreStatus("Symlink Status");
796 dissect_bos_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
798 struct rx_header *rxh;
800 int doffset, curoffset;
802 rxh = (struct rx_header *) &pd[offset];
803 data = (char *)rxh + sizeof(struct rx_header);
804 doffset = offset + sizeof(struct rx_header);
807 if ( rxh->type == RX_PACKET_TYPE_DATA )
811 case 80: /* create bnode */
814 case 81: /* delete bnode */
817 case 82: /* set status */
820 case 83: /* get status */
821 OUT_INT(hf_afs_bos_status);
822 OUT_STRING(hf_afs_bos_statusdesc);
824 case 84: /* enumerate instance */
825 OUT_STRING(hf_afs_bos_instance);
827 case 85: /* get instance info */
828 OUT_STRING(hf_afs_bos_type);
831 case 86: /* get instance parm */
832 OUT_STRING(hf_afs_bos_parm);
834 case 87: /* add siperuser */
837 case 88: /* delete superuser */
840 case 89: /* list superusers */
841 OUT_STRING(hf_afs_bos_user);
843 case 90: /* list keys */
844 OUT_UINT(hf_afs_bos_kvno);
848 case 91: /* add key */
851 case 92: /* delete key */
854 case 93: /* set cell name */
857 case 94: /* get cell name */
858 OUT_STRING(hf_afs_bos_cell);
860 case 95: /* get cell host */
861 OUT_STRING(hf_afs_bos_host);
863 case 96: /* add cell host */
866 case 97: /* delete cell host */
869 case 98: /* set tstatus */
872 case 99: /* shutdown all */
875 case 100: /* restart all */
878 case 101: /* startup all */
881 case 102: /* set noauth flag */
884 case 103: /* rebozo */
887 case 104: /* restart */
890 case 105: /* install */
893 case 106: /* uninstall */
896 case 107: /* get dates */
897 OUT_DATE(hf_afs_bos_newtime);
898 OUT_DATE(hf_afs_bos_baktime);
899 OUT_DATE(hf_afs_bos_oldtime);
904 case 109: /* prune */
907 case 110: /* set restart time */
910 case 111: /* get restart time */
913 case 112: /* get log */
914 /* need to make this dump a big string somehow */
915 OUT_BYTES_ALL(hf_afs_bos_data);
917 case 113: /* wait all */
920 case 114: /* get instance strings */
921 OUT_STRING(hf_afs_bos_error);
922 OUT_STRING(hf_afs_bos_spare1);
923 OUT_STRING(hf_afs_bos_spare2);
924 OUT_STRING(hf_afs_bos_spare3);
928 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
930 OUT_UINT(hf_afs_bos_errcode);
935 dissect_bos_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
937 struct rx_header *rxh;
939 int doffset, curoffset;
941 rxh = (struct rx_header *) &pd[offset];
942 data = (char *)rxh + sizeof(struct rx_header);
943 doffset = offset + sizeof(struct rx_header);
950 case 80: /* create b node */
951 OUT_STRING(hf_afs_bos_type);
952 OUT_STRING(hf_afs_bos_instance);
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);
958 OUT_STRING(hf_afs_bos_parm);
960 case 81: /* delete b node */
961 OUT_STRING(hf_afs_bos_instance);
963 case 82: /* set status */
964 OUT_STRING(hf_afs_bos_instance);
965 OUT_UINT(hf_afs_bos_status);
967 case 83: /* get status */
968 OUT_STRING(hf_afs_bos_instance);
970 case 84: /* enumerate instance */
971 OUT_UINT(hf_afs_bos_num);
973 case 85: /* get instance info */
974 OUT_STRING(hf_afs_bos_instance);
976 case 86: /* get instance parm */
977 OUT_STRING(hf_afs_bos_instance);
978 OUT_UINT(hf_afs_bos_num);
980 case 87: /* add super user */
981 OUT_STRING(hf_afs_bos_user);
983 case 88: /* delete super user */
984 OUT_STRING(hf_afs_bos_user);
986 case 89: /* list super users */
987 OUT_UINT(hf_afs_bos_num);
989 case 90: /* list keys */
990 OUT_UINT(hf_afs_bos_num);
992 case 91: /* add key */
993 OUT_UINT(hf_afs_bos_num);
996 case 92: /* delete key */
997 OUT_UINT(hf_afs_bos_num);
999 case 93: /* set cell name */
1000 OUT_STRING(hf_afs_bos_content);
1002 case 95: /* set cell host */
1003 OUT_UINT(hf_afs_bos_num);
1005 case 96: /* add cell host */
1006 OUT_STRING(hf_afs_bos_content);
1008 case 97: /* delete cell host */
1009 OUT_STRING(hf_afs_bos_content);
1011 case 98: /* set t status */
1012 OUT_STRING(hf_afs_bos_content);
1013 OUT_UINT(hf_afs_bos_status);
1015 case 99: /* shutdown all */
1018 case 100: /* restart all */
1021 case 101: /* startup all */
1024 case 102: /* set no-auth flag */
1025 OUT_UINT(hf_afs_bos_flags);
1027 case 103: /* re-bozo? */
1030 case 104: /* restart */
1031 OUT_STRING(hf_afs_bos_instance);
1033 case 105: /* install */
1034 OUT_STRING(hf_afs_bos_path);
1035 OUT_UINT(hf_afs_bos_size);
1036 OUT_UINT(hf_afs_bos_flags);
1037 OUT_UINT(hf_afs_bos_date);
1039 case 106: /* uninstall */
1040 OUT_STRING(hf_afs_bos_path);
1042 case 107: /* get dates */
1043 OUT_STRING(hf_afs_bos_path);
1045 case 108: /* exec */
1046 OUT_STRING(hf_afs_bos_cmd);
1048 case 109: /* prune */
1049 OUT_UINT(hf_afs_bos_flags);
1051 case 110: /* set restart time */
1052 OUT_UINT(hf_afs_bos_num);
1055 case 111: /* get restart time */
1056 OUT_UINT(hf_afs_bos_num);
1058 case 112: /* get log */
1059 OUT_STRING(hf_afs_bos_file);
1061 case 113: /* wait all */
1064 case 114: /* get instance strings */
1065 OUT_STRING(hf_afs_bos_content);
1074 dissect_vol_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1076 struct rx_header *rxh;
1077 unsigned char *data;
1078 int doffset, curoffset;
1080 rxh = (struct rx_header *) &pd[offset];
1081 data = (char *)rxh + sizeof(struct rx_header);
1082 doffset = offset + sizeof(struct rx_header);
1083 curoffset = doffset;
1085 if ( rxh->type == RX_PACKET_TYPE_DATA )
1090 /* should loop here maybe */
1091 OUT_UINT(hf_afs_vol_count);
1092 VECOUT(hf_afs_vol_name, 32); /* not sure on */
1096 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1098 OUT_UINT(hf_afs_vol_errcode);
1103 dissect_vol_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1105 struct rx_header *rxh;
1106 unsigned char *data;
1107 int doffset, curoffset;
1109 rxh = (struct rx_header *) &pd[offset];
1110 data = (char *)rxh + sizeof(struct rx_header);
1111 doffset = offset + sizeof(struct rx_header);
1112 curoffset = doffset;
1118 case 121: /* list one vol */
1119 OUT_UINT(hf_afs_vol_count);
1120 OUT_UINT(hf_afs_vol_id);
1129 dissect_kauth_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1131 struct rx_header *rxh;
1132 unsigned char *data;
1133 int doffset, curoffset;
1135 rxh = (struct rx_header *) &pd[offset];
1136 data = (char *)rxh + sizeof(struct rx_header);
1137 doffset = offset + sizeof(struct rx_header);
1138 curoffset = doffset;
1140 if ( rxh->type == RX_PACKET_TYPE_DATA )
1146 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1148 OUT_UINT(hf_afs_kauth_errcode);
1153 dissect_kauth_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1155 struct rx_header *rxh;
1156 unsigned char *data;
1157 int doffset, curoffset;
1159 rxh = (struct rx_header *) &pd[offset];
1160 data = (char *)rxh + sizeof(struct rx_header);
1161 doffset = offset + sizeof(struct rx_header);
1162 curoffset = doffset;
1168 case 1: /* authenticate old */
1169 case 21: /* authenticate */
1170 case 22: /* authenticate v2 */
1171 case 2: /* change pw */
1172 case 5: /* set fields */
1173 case 6: /* create user */
1174 case 7: /* delete user */
1175 case 8: /* get entry */
1176 case 14: /* unlock */
1177 case 15: /* lock status */
1178 OUT_STRING(hf_afs_kauth_princ);
1179 OUT_STRING(hf_afs_kauth_realm);
1180 OUT_BYTES_ALL(hf_afs_kauth_data);
1182 case 3: /* getticket-old */
1183 case 23: /* getticket */
1184 OUT_UINT(hf_afs_kauth_kvno);
1185 OUT_STRING(hf_afs_kauth_domain);
1186 OUT_STRING(hf_afs_kauth_data);
1187 OUT_STRING(hf_afs_kauth_princ);
1188 OUT_STRING(hf_afs_kauth_realm);
1190 case 4: /* set pass */
1191 OUT_STRING(hf_afs_kauth_princ);
1192 OUT_STRING(hf_afs_kauth_realm);
1193 OUT_UINT(hf_afs_kauth_kvno);
1195 case 12: /* get pass */
1196 OUT_STRING(hf_afs_kauth_name);
1205 dissect_cb_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1207 struct rx_header *rxh;
1208 unsigned char *data;
1209 int doffset, curoffset;
1211 rxh = (struct rx_header *) &pd[offset];
1212 data = (char *)rxh + sizeof(struct rx_header);
1213 doffset = offset + sizeof(struct rx_header);
1214 curoffset = doffset;
1216 if ( rxh->type == RX_PACKET_TYPE_DATA )
1222 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1224 OUT_UINT(hf_afs_cb_errcode);
1229 dissect_cb_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1231 struct rx_header *rxh;
1232 unsigned char *data;
1233 int doffset, curoffset;
1235 rxh = (struct rx_header *) &pd[offset];
1236 data = (char *)rxh + sizeof(struct rx_header);
1237 doffset = offset + sizeof(struct rx_header);
1238 curoffset = doffset;
1244 case 204: /* callback */
1253 OUT_CB_AFSFid("Target");
1260 OUT_CB_AFSCallBack();
1270 dissect_prot_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1272 struct rx_header *rxh;
1273 unsigned char *data;
1274 int doffset, curoffset;
1276 rxh = (struct rx_header *) &pd[offset];
1277 data = (char *)rxh + sizeof(struct rx_header);
1278 doffset = offset + sizeof(struct rx_header);
1279 curoffset = doffset;
1281 if ( rxh->type == RX_PACKET_TYPE_DATA )
1285 case 504: /* name to id */
1291 OUT_UINT(hf_afs_prot_count);
1295 OUT_UINT(hf_afs_prot_id);
1299 case 505: /* id to name */
1305 OUT_UINT(hf_afs_prot_count);
1309 VECOUT(hf_afs_prot_name, PRNAMEMAX);
1313 case 508: /* get cps */
1314 case 514: /* list elements */
1315 case 517: /* list owned */
1316 case 518: /* get cps2 */
1317 case 519: /* get host cps */
1323 OUT_UINT(hf_afs_prot_count);
1327 OUT_UINT(hf_afs_prot_id);
1331 case 510: /* list max */
1332 OUT_UINT(hf_afs_prot_maxuid);
1333 OUT_UINT(hf_afs_prot_maxgid);
1337 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1339 OUT_UINT(hf_afs_prot_errcode);
1344 dissect_prot_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1346 struct rx_header *rxh;
1347 unsigned char *data;
1348 int doffset, curoffset;
1350 rxh = (struct rx_header *) &pd[offset];
1351 data = (char *)rxh + sizeof(struct rx_header);
1352 doffset = offset + sizeof(struct rx_header);
1353 curoffset = doffset;
1359 case 500: /* new user */
1360 OUT_STRING(hf_afs_prot_name);
1361 OUT_UINT(hf_afs_prot_id);
1362 OUT_UINT(hf_afs_prot_oldid);
1364 case 501: /* where is it */
1365 case 506: /* delete */
1366 case 508: /* get cps */
1367 case 512: /* list entry */
1368 case 514: /* list elements */
1369 case 517: /* list owned */
1370 case 519: /* get host cps */
1371 OUT_UINT(hf_afs_prot_id);
1373 case 502: /* dump entry */
1374 OUT_UINT(hf_afs_prot_pos);
1376 case 503: /* add to group */
1377 case 507: /* remove from group */
1378 case 515: /* is a member of? */
1379 OUT_UINT(hf_afs_prot_uid);
1380 OUT_UINT(hf_afs_prot_gid);
1382 case 504: /* name to id */
1388 OUT_UINT(hf_afs_prot_count);
1392 VECOUT(hf_afs_prot_name,PRNAMEMAX);
1396 case 505: /* id to name */
1402 OUT_UINT(hf_afs_prot_count);
1406 OUT_UINT(hf_afs_prot_id);
1410 case 509: /* new entry */
1411 OUT_STRING(hf_afs_prot_name);
1412 OUT_UINT(hf_afs_prot_flag);
1413 OUT_UINT(hf_afs_prot_oldid);
1415 case 511: /* set max */
1416 OUT_UINT(hf_afs_prot_id);
1417 OUT_UINT(hf_afs_prot_flag);
1419 case 513: /* change entry */
1420 OUT_UINT(hf_afs_prot_id);
1421 OUT_STRING(hf_afs_prot_name);
1422 OUT_UINT(hf_afs_prot_oldid);
1423 OUT_UINT(hf_afs_prot_newid);
1425 case 520: /* update entry */
1426 OUT_UINT(hf_afs_prot_id);
1427 OUT_STRING(hf_afs_prot_name);
1436 dissect_vldb_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1438 struct rx_header *rxh;
1439 unsigned char *data;
1440 int doffset, curoffset;
1442 rxh = (struct rx_header *) &pd[offset];
1443 data = (char *)rxh + sizeof(struct rx_header);
1444 doffset = offset + sizeof(struct rx_header);
1445 curoffset = doffset;
1447 if ( rxh->type == RX_PACKET_TYPE_DATA )
1451 case 510: /* list entry */
1452 OUT_UINT(hf_afs_vldb_count);
1453 OUT_UINT(hf_afs_vldb_nextindex);
1455 case 503: /* get entry by id */
1456 case 504: /* get entry by name */
1459 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1461 nservers = GETINT();
1462 OUT_UINT(hf_afs_vldb_numservers);
1467 OUT_IP(hf_afs_vldb_server);
1479 strcpy(part, "/vicepa");
1480 if ( i<nservers && j<=25 )
1482 part[6] = 'a' + (char) j;
1483 proto_tree_add_string(tree, hf_afs_vldb_partition, NullTVB,
1484 curoffset, 4, part);
1488 SKIP(8 * sizeof(guint32));
1489 OUT_UINT(hf_afs_vldb_rwvol);
1490 OUT_UINT(hf_afs_vldb_rovol);
1491 OUT_UINT(hf_afs_vldb_bkvol);
1494 case 505: /* get new volume id */
1495 OUT_UINT(hf_afs_vldb_id);
1497 case 521: /* list entry */
1498 case 529: /* list entry U */
1499 OUT_UINT(hf_afs_vldb_count);
1500 OUT_UINT(hf_afs_vldb_nextindex);
1502 case 518: /* get entry by id n */
1503 case 519: /* get entry by name N */
1506 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1508 nservers = GETINT();
1509 OUT_UINT(hf_afs_vldb_numservers);
1510 for (i=0; i<13; i++)
1514 OUT_IP(hf_afs_vldb_server);
1521 for (i=0; i<13; i++)
1526 strcpy(part, "/vicepa");
1527 if ( i<nservers && j<=25 )
1529 part[6] = 'a' + (char) j;
1530 proto_tree_add_string(tree, hf_afs_vldb_partition, NullTVB,
1531 curoffset, 4, part);
1535 SKIP(13 * sizeof(guint32));
1536 OUT_UINT(hf_afs_vldb_rwvol);
1537 OUT_UINT(hf_afs_vldb_rovol);
1538 OUT_UINT(hf_afs_vldb_bkvol);
1541 case 526: /* get entry by id u */
1542 case 527: /* get entry by name u */
1545 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1547 nservers = GETINT();
1548 OUT_UINT(hf_afs_vldb_numservers);
1549 for (i=0; i<13; i++)
1553 OUT_BYTES(hf_afs_vldb_serveruuid, 11*sizeof(guint32));
1557 SKIP(11*sizeof(guint32));
1560 for (i=0; i<13; i++)
1565 strcpy(part, "/vicepa");
1566 if ( i<nservers && j<=25 )
1568 part[6] = 'a' + (char) j;
1569 proto_tree_add_string(tree, hf_afs_vldb_partition, NullTVB,
1570 curoffset, 4, part);
1574 SKIP(13 * sizeof(guint32));
1575 OUT_UINT(hf_afs_vldb_rwvol);
1576 OUT_UINT(hf_afs_vldb_rovol);
1577 OUT_UINT(hf_afs_vldb_bkvol);
1582 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1584 OUT_UINT(hf_afs_vldb_errcode);
1589 dissect_vldb_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1591 struct rx_header *rxh;
1592 unsigned char *data;
1593 int doffset, curoffset;
1595 rxh = (struct rx_header *) &pd[offset];
1596 data = (char *)rxh + sizeof(struct rx_header);
1597 doffset = offset + sizeof(struct rx_header);
1598 curoffset = doffset;
1604 case 501: /* create new volume */
1605 case 517: /* create entry N */
1606 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1608 case 502: /* delete entry */
1609 case 503: /* get entry by id */
1610 case 507: /* update entry */
1611 case 508: /* set lock */
1612 case 509: /* release lock */
1613 case 518: /* get entry by id */
1614 OUT_UINT(hf_afs_vldb_id);
1615 OUT_UINT(hf_afs_vldb_type);
1617 case 504: /* get entry by name */
1618 case 519: /* get entry by name N */
1619 case 524: /* update entry by name */
1620 case 527: /* get entry by name U */
1621 OUT_STRING(hf_afs_vldb_name);
1623 case 505: /* get new vol id */
1624 OUT_UINT(hf_afs_vldb_bump);
1626 case 506: /* replace entry */
1627 case 520: /* replace entry N */
1628 OUT_UINT(hf_afs_vldb_id);
1629 OUT_UINT(hf_afs_vldb_type);
1630 VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1632 case 510: /* list entry */
1633 case 521: /* list entry N */
1634 OUT_UINT(hf_afs_vldb_index);
1643 dissect_ubik_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1645 struct rx_header *rxh;
1646 unsigned char *data;
1647 int doffset, curoffset;
1649 rxh = (struct rx_header *) &pd[offset];
1650 data = (char *)rxh + sizeof(struct rx_header);
1651 doffset = offset + sizeof(struct rx_header);
1652 curoffset = doffset;
1654 if ( rxh->type == RX_PACKET_TYPE_DATA )
1658 case 10000: /* beacon */
1659 proto_tree_add_boolean(tree,hf_afs_ubik_votetype, NullTVB,0,0,0);
1661 case 20004: /* get version */
1662 OUT_UBIKVERSION("DB Version");
1666 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1671 proto_tree_add_boolean(tree,hf_afs_ubik_votetype, NullTVB,0,0,1);
1672 OUT_DATE(hf_afs_ubik_voteend);
1675 OUT_UINT(hf_afs_ubik_errcode);
1682 dissect_ubik_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1684 struct rx_header *rxh;
1685 unsigned char *data;
1686 int doffset, curoffset;
1688 rxh = (struct rx_header *) &pd[offset];
1689 data = (char *)rxh + sizeof(struct rx_header);
1690 doffset = offset + sizeof(struct rx_header);
1691 curoffset = doffset;
1697 case 10000: /* beacon */
1698 OUT_UINT(hf_afs_ubik_syncsite);
1699 OUT_DATE(hf_afs_ubik_votestart);
1700 OUT_UBIKVERSION("DB Version");
1701 OUT_UBIKVERSION("TID");
1703 case 10003: /* get sync site */
1704 OUT_IP(hf_afs_ubik_site);
1706 case 20000: /* begin */
1707 case 20001: /* commit */
1708 case 20007: /* abort */
1709 case 20008: /* release locks */
1710 case 20010: /* writev */
1711 OUT_UBIKVERSION("TID");
1713 case 20002: /* lock */
1714 OUT_UBIKVERSION("TID");
1715 OUT_UINT(hf_afs_ubik_file);
1716 OUT_UINT(hf_afs_ubik_pos);
1717 OUT_UINT(hf_afs_ubik_length);
1718 OUT_UINT(hf_afs_ubik_locktype);
1720 case 20003: /* write */
1721 OUT_UBIKVERSION("TID");
1722 OUT_UINT(hf_afs_ubik_file);
1723 OUT_UINT(hf_afs_ubik_pos);
1725 case 20005: /* get file */
1726 OUT_UINT(hf_afs_ubik_file);
1728 case 20006: /* send file */
1729 OUT_UINT(hf_afs_ubik_file);
1730 OUT_UINT(hf_afs_ubik_length);
1731 OUT_UBIKVERSION("DB Version");
1733 case 20009: /* truncate */
1734 OUT_UBIKVERSION("TID");
1735 OUT_UINT(hf_afs_ubik_file);
1736 OUT_UINT(hf_afs_ubik_length);
1738 case 20012: /* set version */
1739 OUT_UBIKVERSION("TID");
1740 OUT_UBIKVERSION("Old DB Version");
1741 OUT_UBIKVERSION("New DB Version");
1750 dissect_backup_reply(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1752 struct rx_header *rxh;
1753 unsigned char *data;
1754 int doffset, curoffset;
1756 rxh = (struct rx_header *) &pd[offset];
1757 data = (char *)rxh + sizeof(struct rx_header);
1758 doffset = offset + sizeof(struct rx_header);
1759 curoffset = doffset;
1761 if ( rxh->type == RX_PACKET_TYPE_DATA )
1767 else if ( rxh->type == RX_PACKET_TYPE_ABORT )
1769 OUT_UINT(hf_afs_backup_errcode);
1774 dissect_backup_request(const u_char *pd, int offset, frame_data *fd, proto_tree *tree, int opcode)
1776 struct rx_header *rxh;
1777 unsigned char *data;
1778 int doffset, curoffset;
1780 rxh = (struct rx_header *) &pd[offset];
1781 data = (char *)rxh + sizeof(struct rx_header);
1782 doffset = offset + sizeof(struct rx_header);
1783 curoffset = doffset;
1793 * Registration code for registering the protocol and fields
1797 proto_register_afs(void)
1799 static hf_register_info hf[] = {
1800 #include "packet-afs-register-info.h"
1802 static gint *ett[] = {
1810 &ett_afs_status_mask,
1812 &ett_afs_volumeinfo,
1816 proto_afs = proto_register_protocol("Andrew File System (AFS)", "afs");
1817 proto_register_field_array(proto_afs, hf, array_length(hf));
1818 proto_register_subtree_array(ett, array_length(ett));
1819 register_init_routine(&afs_init_protocol);