7e7709dd649555d58234772647cfbd7af43658c5
[obnox/wireshark/wip.git] / packet-afs.c
1 /* packet-afs.c
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. 
10  *
11  * $Id: packet-afs.c,v 1.35 2001/11/03 00:58:49 guy Exp $
12  *
13  * Ethereal - Network traffic analyzer
14  * By Gerald Combs <gerald@ethereal.com>
15  * Copyright 1998 Gerald Combs
16  *
17  * Copied from packet-tftp.c
18  *
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.
23  *
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.
28  *
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.
32  */
33
34 #ifdef HAVE_CONFIG_H
35 # include "config.h"
36 #endif
37
38 #include <stdio.h>
39
40 #ifdef HAVE_SYS_TYPES_H
41 # include <sys/types.h>
42 #endif
43
44 #ifdef HAVE_NETINET_IN_H
45 # include <netinet/in.h>
46 #endif
47
48 #include <string.h>
49 #include <glib.h>
50 #include "packet.h"
51 #include "conversation.h"
52 #include "resolv.h"
53
54 #include "packet-rx.h"
55 #include "packet-afs.h"
56 #include "packet-afs-defs.h"
57 #include "packet-afs-macros.h"
58
59 #define GETSTR tvb_get_ptr(tvb,offset,tvb_length_remaining(tvb,offset))
60
61 #define VALID_OPCODE(opcode) ((opcode >= OPCODE_LOW && opcode <= OPCODE_HIGH) || \
62                 (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) || \
63                 (opcode >= DISK_LOW && opcode <= DISK_HIGH))
64
65 int afs_packet_init_count = 100;
66
67 struct afs_request_key {
68   guint32 conversation, callnumber;
69   guint16 service;
70 };
71
72 struct afs_request_val {
73   guint32 opcode;
74 };
75
76 GHashTable *afs_request_hash = NULL;
77 GMemChunk *afs_request_keys = NULL;
78 GMemChunk *afs_request_vals = NULL;
79
80
81
82 /*
83  * Dissector prototypes
84  */
85 static int dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo, 
86         proto_tree *tree, int offset);
87 static void dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
88         proto_tree *tree, int offset, int opcode);
89 static void dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
90         proto_tree *tree, int offset, int opcode);
91 static void dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
92         proto_tree *tree, int offset, int opcode);
93 static void dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
94         proto_tree *tree, int offset, int opcode);
95 static void dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
96         proto_tree *tree, int offset, int opcode);
97 static void dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
98         proto_tree *tree, int offset, int opcode);
99 static void dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
100         proto_tree *tree, int offset, int opcode);
101 static void dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
102         proto_tree *tree, int offset, int opcode);
103 static void dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
104         proto_tree *tree, int offset, int opcode);
105 static void dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
106         proto_tree *tree, int offset, int opcode);
107 static void dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
108         proto_tree *tree, int offset, int opcode);
109 static void dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
110         proto_tree *tree, int offset, int opcode);
111 static void dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
112         proto_tree *tree, int offset, int opcode);
113 static void dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
114         proto_tree *tree, int offset, int opcode);
115 static void dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
116         proto_tree *tree, int offset, int opcode);
117 static void dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
118         proto_tree *tree, int offset, int opcode);
119 static void dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, 
120         proto_tree *tree, int offset, int opcode);
121 static void dissect_backup_request(tvbuff_t *tvb, struct rxinfo *rxinfo, 
122         proto_tree *tree, int offset, int opcode);
123
124 /*
125  * Hash Functions
126  */
127 static gint
128 afs_equal(gconstpointer v, gconstpointer w)
129 {
130   struct afs_request_key *v1 = (struct afs_request_key *)v;
131   struct afs_request_key *v2 = (struct afs_request_key *)w;
132
133   if (v1 -> conversation == v2 -> conversation &&
134       v1 -> service == v2 -> service &&
135       v1 -> callnumber == v2 -> callnumber ) {
136
137     return 1;
138   }
139
140   return 0;
141 }
142
143 static guint
144 afs_hash (gconstpointer v)
145 {
146         struct afs_request_key *key = (struct afs_request_key *)v;
147         guint val;
148
149         val = key -> conversation + key -> service + key -> callnumber;
150
151         return val;
152 }
153
154 /*
155  * Protocol initialization
156  */
157 static void
158 afs_init_protocol(void)
159 {
160         if (afs_request_hash)
161                 g_hash_table_destroy(afs_request_hash);
162         if (afs_request_keys)
163                 g_mem_chunk_destroy(afs_request_keys);
164         if (afs_request_vals)
165                 g_mem_chunk_destroy(afs_request_vals);
166
167         afs_request_hash = g_hash_table_new(afs_hash, afs_equal);
168         afs_request_keys = g_mem_chunk_new("afs_request_keys",
169                 sizeof(struct afs_request_key),
170                 afs_packet_init_count * sizeof(struct afs_request_key),
171                 G_ALLOC_AND_FREE);
172         afs_request_vals = g_mem_chunk_new("afs_request_vals",
173                 sizeof(struct afs_request_val),
174                 afs_packet_init_count * sizeof(struct afs_request_val),
175                 G_ALLOC_AND_FREE);
176 }
177
178
179
180 /*
181  * Dissection routines
182  */
183
184 static void
185 dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
186 {
187         struct rxinfo *rxinfo = pinfo->private_data;
188         int reply = 0;
189         conversation_t *conversation;
190         struct afs_request_key request_key, *new_request_key;
191         struct afs_request_val *request_val;
192         proto_tree      *afs_tree, *afs_op_tree, *ti;
193         int port, node, typenode, opcode;
194         value_string const *vals;
195         int offset = 0;
196         void (*dissector)(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode);
197
198
199         if (check_col(pinfo->fd, COL_PROTOCOL)) {
200                 col_set_str(pinfo->fd, COL_PROTOCOL, "AFS (RX)");
201         }
202         if (check_col(pinfo->fd, COL_INFO)) {
203                 col_clear(pinfo->fd, COL_INFO);
204         }
205
206         reply = (rxinfo->flags & RX_CLIENT_INITIATED) == 0;
207         port = ((reply == 0) ? pinfo->destport : pinfo->srcport );
208
209         /*
210          * Find out what conversation this packet is part of.
211          * XXX - this should really be done by the transport-layer protocol,
212          * although for connectionless transports, we may not want to do that
213          * unless we know some higher-level protocol will want it - or we
214          * may want to do it, so you can say e.g. "show only the packets in
215          * this UDP 'connection'".
216          *
217          * Note that we don't have to worry about the direction this packet
218          * was going - the conversation code handles that for us, treating
219          * packets from A:X to B:Y as being part of the same conversation as
220          * packets from B:Y to A:X.
221          */
222         conversation = find_conversation(&pinfo->src, &pinfo->dst, pinfo->ptype,
223             pinfo->srcport, pinfo->destport, 0);
224         if (conversation == NULL) {
225                 /* It's not part of any conversation - create a new one. */
226                 conversation = conversation_new(&pinfo->src, &pinfo->dst, 
227                         pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
228         }
229
230         request_key.conversation = conversation->index; 
231         request_key.service = rxinfo->serviceid;
232         request_key.callnumber = rxinfo->callnumber;
233
234         request_val = (struct afs_request_val *) g_hash_table_lookup(
235                 afs_request_hash, &request_key);
236
237         /* only allocate a new hash element when it's a request */
238         opcode = 0;
239         if ( !request_val && !reply) {
240                 new_request_key = g_mem_chunk_alloc(afs_request_keys);
241                 *new_request_key = request_key;
242
243                 request_val = g_mem_chunk_alloc(afs_request_vals);
244                 request_val -> opcode = tvb_get_ntohl(tvb, offset);
245
246                 g_hash_table_insert(afs_request_hash, new_request_key,
247                         request_val);
248         }
249
250         if ( request_val ) {
251                 opcode = request_val->opcode;
252         }
253
254         node = 0;
255         typenode = 0;
256         vals = NULL;
257         dissector = NULL;
258         switch (port) {
259                 case AFS_PORT_FS:
260                         typenode = hf_afs_fs;
261                         node = hf_afs_fs_opcode;
262                         vals = fs_req;
263                         dissector = reply ? dissect_fs_reply : dissect_fs_request;
264                         break;
265                 case AFS_PORT_CB:
266                         typenode = hf_afs_cb;
267                         node = hf_afs_cb_opcode;
268                         vals = cb_req;
269                         dissector = reply ? dissect_cb_reply : dissect_cb_request;
270                         break;
271                 case AFS_PORT_PROT:
272                         typenode = hf_afs_prot;
273                         node = hf_afs_prot_opcode;
274                         vals = prot_req;
275                         dissector = reply ? dissect_prot_reply : dissect_prot_request;
276                         break;
277                 case AFS_PORT_VLDB:
278                         typenode = hf_afs_vldb;
279                         node = hf_afs_vldb_opcode;
280                         vals = vldb_req;
281                         dissector = reply ? dissect_vldb_reply : dissect_vldb_request;
282                         break;
283                 case AFS_PORT_KAUTH:
284                         typenode = hf_afs_kauth;
285                         node = hf_afs_kauth_opcode;
286                         vals = kauth_req;
287                         dissector = reply ? dissect_kauth_reply : dissect_kauth_request;
288                         break;
289                 case AFS_PORT_VOL:
290                         typenode = hf_afs_vol;
291                         node = hf_afs_vol_opcode;
292                         vals = vol_req;
293                         dissector = reply ? dissect_vol_reply : dissect_vol_request;
294                         break;
295                 case AFS_PORT_ERROR:
296                         typenode = hf_afs_error;
297                         node = hf_afs_error_opcode;
298                         /* dissector = reply ? dissect_error_reply : dissect_error_request; */
299                         break;
300                 case AFS_PORT_BOS:
301                         typenode = hf_afs_bos;
302                         node = hf_afs_bos_opcode;
303                         vals = bos_req;
304                         dissector = reply ? dissect_bos_reply : dissect_bos_request;
305                         break;
306                 case AFS_PORT_UPDATE:
307                         typenode = hf_afs_update;
308                         node = hf_afs_update_opcode;
309                         vals = update_req;
310                         /* dissector = reply ? dissect_update_reply : dissect_update_request; */
311                         break;
312                 case AFS_PORT_RMTSYS:
313                         typenode = hf_afs_rmtsys;
314                         node = hf_afs_rmtsys_opcode;
315                         vals = rmtsys_req;
316                         /* dissector = reply ? dissect_rmtsys_reply : dissect_rmtsys_request; */
317                         break;
318                 case AFS_PORT_BACKUP:
319                         typenode = hf_afs_backup;
320                         node = hf_afs_backup_opcode;
321                         vals = backup_req;
322                         dissector = reply ? dissect_backup_reply : dissect_backup_request;
323                         break;
324         }
325
326         if ( (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
327                 (opcode >= DISK_LOW && opcode <= DISK_HIGH) ) {
328                 typenode = hf_afs_ubik;
329                 node = hf_afs_ubik_opcode;
330                 vals = ubik_req;
331                 dissector = reply ? dissect_ubik_reply : dissect_ubik_request;
332         }
333
334
335         if ( VALID_OPCODE(opcode) ) {
336                 if ( vals ) {
337                         if (check_col(pinfo->fd, COL_INFO))
338                                 col_add_fstr(pinfo->fd, COL_INFO, "%s%s %s: %s (%d)",
339                                 typenode == hf_afs_ubik ? "UBIK-" : "",
340                                 val_to_str(port, port_types_short, "Unknown(%d)"),
341                                 reply ? "Reply" : "Request",
342                                 val_to_str(opcode, vals, "Unknown(%d)"), opcode);
343                 } else {
344                         if (check_col(pinfo->fd, COL_INFO))
345                                 col_add_fstr(pinfo->fd, COL_INFO, "%s%s %s: Unknown(%d)",
346                                 typenode == hf_afs_ubik ? "UBIK-" : "",
347                                 val_to_str(port, port_types_short, "Unknown(%d)"),
348                                 reply ? "Reply" : "Request",
349                                 opcode);
350                 }
351         } else {
352                 if (check_col(pinfo->fd, COL_INFO))
353                         col_add_fstr(pinfo->fd, COL_INFO, "Encrypted %s %s",
354                         val_to_str(port, port_types_short, "Unknown(%d)"),
355                         reply ? "Reply" : "Request"
356                         );
357         }
358
359         if (tree) {
360                 ti = proto_tree_add_item(tree, proto_afs, tvb, offset, 
361                                 tvb_length_remaining(tvb, offset), FALSE);
362                 afs_tree = proto_item_add_subtree(ti, ett_afs);
363
364                 proto_tree_add_text(afs_tree, tvb,
365                         offset, tvb_length_remaining(tvb, offset),
366                         "Service: %s%s%s %s",
367                         VALID_OPCODE(opcode) ? "" : "Encrypted ",
368                         typenode == hf_afs_ubik ? "UBIK - " : "",
369                         val_to_str(port, port_types, "Unknown(%d)"),
370                         reply ? "Reply" : "Request");
371
372                 if ( VALID_OPCODE(opcode) ) {
373                         /* until we do cache, can't handle replies */
374                         ti = NULL;
375                         if ( !reply && node != 0 ) {
376                                 ti = proto_tree_add_uint(afs_tree,
377                                         node, tvb, offset, 4, opcode);
378                         } else if ( reply && node != 0 ) {
379                                 /* the opcode isn't in this packet */
380                                 ti = proto_tree_add_uint(afs_tree,
381                                         node, tvb, offset, 0, opcode);
382                         } else {
383                                 ti = proto_tree_add_text(afs_tree, tvb,
384                                         offset, 0, "Operation: Unknown");
385                         }
386         
387                         /* Add the subtree for this particular service */
388                         afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
389         
390                         if ( typenode != 0 ) {
391                                 /* indicate the type of request */
392                                 proto_tree_add_boolean_hidden(afs_tree, typenode, tvb, offset, 0, 1);
393                         }
394         
395                         /* Process the packet according to what service it is */
396                         if ( dissector ) {
397                                 (*dissector)(tvb, rxinfo, afs_op_tree, offset, opcode);
398                         }
399                 }
400         }
401
402         /* if it's the last packet, and it's a reply, remove opcode
403                 from hash */
404         /* ignoring for now, I'm not sure how the chunk deallocation works */
405         if ( rxinfo->flags & RX_LAST_PACKET && reply ){
406
407         }
408 }
409
410
411 /*
412  * Here is a helper routine for adding an AFS acl to the proto tree
413  * This is to be used with FS packets only
414  *
415  * An AFS ACL is a string that has the following format:
416  *
417  * <positive> <negative>
418  * <uid1> <aclbits1>
419  * ....
420  *
421  * "positive" and "negative" are integers which contain the number of
422  * positive and negative ACL's in the string.  The uid/aclbits pair are
423  * ASCII strings containing the UID/PTS record and and a ascii number
424  * representing a logical OR of all the ACL permission bits
425  */
426 /* FIXME: sscanf is probably quite dangerous if we run outside the packet. */
427 static int 
428 dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset)
429 {
430         int old_offset;
431         gint32 bytes;
432         int i, n, pos, neg, acl;
433         char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
434
435         old_offset = offset;
436         bytes = tvb_get_ntohl(tvb, offset);
437         OUT_UINT(hf_afs_fs_acl_datasize);
438
439
440         if (sscanf((char *) GETSTR, "%d %n", &pos, &n) != 1) {
441                 /* does not matter what we return, if this fails, 
442                  * we cant dissect anything else in the packet either.
443                  */
444                 return offset;
445         }
446         proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, tvb, 
447                 offset, n, pos);
448         offset += n;
449
450
451         if (sscanf((char *) GETSTR, "%d %n", &neg, &n) != 1) {
452                 return offset;
453         }
454         proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, tvb, 
455                 offset, n, neg);
456         offset += n;
457
458         /*
459          * This wacky order preserves the order used by the "fs" command
460          */
461         for (i = 0; i < pos; i++) {
462                 if (sscanf((char *) GETSTR, 
463                                 "%127s %d %n", user, &acl, &n) != 2) {
464                         return offset;
465                 }
466                 ACLOUT(user,1,acl,n);
467                 offset += n;
468         }
469         for (i = 0; i < neg; i++) {
470                 if (sscanf((char *) GETSTR, 
471                         "%127s %d %n", user, &acl, &n) != 2) {
472                         return offset;
473                 }
474                 ACLOUT(user,0,acl,n);
475                 offset += n;
476                 if (offset >= old_offset+bytes ) {
477                         return offset;
478                 }
479         }
480
481         return offset;
482 }
483
484 /*
485  * Here are the helper dissection routines
486  */
487
488 static void
489 dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
490 {
491         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
492         {
493                 switch ( opcode )
494                 {
495                         case 130: /* fetch data */
496                                 /* only on first packet */
497                                 if ( rxinfo->seq == 1 )
498                                 {
499                                         OUT_FS_AFSFetchStatus("Status");
500                                         OUT_FS_AFSCallBack();
501                                         OUT_FS_AFSVolSync();
502                                 }
503                                 OUT_BYTES_ALL(hf_afs_fs_data);
504                                 break;
505                         case 131: /* fetch acl */
506                                 offset = dissect_acl(tvb, rxinfo, tree, offset);
507                                 OUT_FS_AFSFetchStatus("Status");
508                                 OUT_FS_AFSVolSync();
509                                 break;
510                         case 132: /* Fetch status */
511                                 OUT_FS_AFSFetchStatus("Status");
512                                 OUT_FS_AFSCallBack();
513                                 OUT_FS_AFSVolSync();
514                                 break;  
515                         case 133: /* Store data */
516                         case 134: /* Store ACL */
517                         case 135: /* Store status */
518                         case 136: /* Remove file */
519                                 OUT_FS_AFSFetchStatus("Status");
520                                 OUT_FS_AFSVolSync();
521                                 break;
522                         case 137: /* create file */
523                         case 141: /* make dir */
524                         case 161: /* lookup */
525                         case 163: /* dfs symlink */
526                                 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
527                                 OUT_FS_AFSFetchStatus("File Status");
528                                 OUT_FS_AFSFetchStatus("Directory Status");
529                                 OUT_FS_AFSCallBack();
530                                 OUT_FS_AFSVolSync();
531                                 break;
532                         case 138: /* rename */
533                                 OUT_FS_AFSFetchStatus("Old Directory Status");
534                                 OUT_FS_AFSFetchStatus("New Directory Status");
535                                 OUT_FS_AFSVolSync();
536                                 break;
537                         case 139: /* symlink */
538                                 OUT_FS_AFSFid("Symlink");
539                         case 140: /* link */
540                                 OUT_FS_AFSFetchStatus("Symlink Status");
541                         case 142: /* rmdir */
542                                 OUT_FS_AFSFetchStatus("Directory Status");
543                                 OUT_FS_AFSVolSync();
544                                 break;
545                         case 143: /* old set lock */
546                         case 144: /* old extend lock */
547                         case 145: /* old release lock */
548                         case 147: /* give up callbacks */
549                         case 150: /* set volume status */
550                         case 152: /* check token */ 
551                                 /* nothing returned */
552                                 break;
553                         case 146: /* get statistics */
554                                 OUT_FS_ViceStatistics();
555                                 break;
556                         case 148: /* get volume info */
557                         case 154: /* n-get-volume-info */
558                                 OUT_FS_VolumeInfo();
559                                 break;
560                         case 149: /* get volume status */
561                                 OUT_FS_AFSFetchVolumeStatus();
562                                 OUT_STRING(hf_afs_fs_volname);
563                                 OUT_STRING(hf_afs_fs_offlinemsg);
564                                 OUT_STRING(hf_afs_fs_motd);
565                                 break;
566                         case 151: /* root volume */
567                                 OUT_STRING(hf_afs_fs_volname);
568                                 break;
569                         case 153: /* get time */
570                                 OUT_TIMESTAMP(hf_afs_fs_timestamp);
571                                 break;
572                         case 155: /* bulk status */
573                                 OUT_FS_AFSBulkStats();
574                                 OUT_FS_AFSCBs();
575                                 OUT_FS_AFSVolSync();
576                                 break;
577                         case 156: /* set lock */
578                         case 157: /* extend lock */
579                         case 158: /* release lock */
580                                 OUT_FS_AFSVolSync();
581                                 break;
582                         case 159: /* x-stats-version */
583                                 OUT_UINT(hf_afs_fs_xstats_version);
584                                 break;
585                         case 160: /* get xstats */
586                                 OUT_UINT(hf_afs_fs_xstats_version);
587                                 OUT_DATE(hf_afs_fs_xstats_timestamp);
588                                 OUT_FS_AFS_CollData();
589                                 break;
590                         case 162: /* flush cps */
591                                 OUT_UINT(hf_afs_fs_cps_spare2);
592                                 OUT_UINT(hf_afs_fs_cps_spare3);
593                                 break;
594                 }
595         }
596         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
597         {
598                 OUT_UINT(hf_afs_fs_errcode);
599         }
600 }
601
602 static void
603 dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
604 {
605         offset += 4;  /* skip the opcode */
606
607         switch ( opcode )
608         {
609                 case 130: /* Fetch data */
610                         OUT_FS_AFSFid("Source");
611                         OUT_UINT(hf_afs_fs_offset);
612                         OUT_UINT(hf_afs_fs_length);
613                         break;
614                 case 131: /* Fetch ACL */
615                         OUT_FS_AFSFid("Target");
616                         break;          
617                 case 132: /* Fetch Status */
618                         OUT_FS_AFSFid("Target");
619                         break;
620                 case 133: /* Store Data */
621                         OUT_FS_AFSFid("Destination");
622                         OUT_FS_AFSStoreStatus("Status");
623                         OUT_UINT(hf_afs_fs_offset);
624                         OUT_UINT(hf_afs_fs_length);
625                         OUT_UINT(hf_afs_fs_flength);
626                         break;
627                 case 134: /* Store ACL */
628                         OUT_FS_AFSFid("Target");
629                         offset = dissect_acl(tvb, rxinfo, tree, offset);
630                         break;
631                 case 135: /* Store Status */
632                         OUT_FS_AFSFid("Target");
633                         OUT_FS_AFSStoreStatus("Status");
634                         break;
635                 case 136: /* Remove File */
636                         OUT_FS_AFSFid("Remove File");
637                         OUT_STRING(hf_afs_fs_name);
638                         break;
639                 case 137: /* Create File */
640                         OUT_FS_AFSFid("Target");
641                         OUT_STRING(hf_afs_fs_name);
642                         OUT_FS_AFSStoreStatus("Status");
643                         break;
644                 case 138: /* Rename file */
645                         OUT_FS_AFSFid("Old");
646                         OUT_STRING(hf_afs_fs_oldname);
647                         OUT_FS_AFSFid("New");
648                         OUT_STRING(hf_afs_fs_newname);
649                         break;
650                 case 139: /* Symlink */
651                         OUT_FS_AFSFid("File");
652                         OUT_STRING(hf_afs_fs_symlink_name);
653                         OUT_STRING(hf_afs_fs_symlink_content);
654                         OUT_FS_AFSStoreStatus("Status");
655                         break;
656                 case 140: /* Link */
657                         OUT_FS_AFSFid("Link To (New File)");
658                         OUT_STRING(hf_afs_fs_name);
659                         OUT_FS_AFSFid("Link From (Old File)");
660                         break;
661                 case 141: /* Make dir */
662                         OUT_FS_AFSFid("Target");
663                         OUT_STRING(hf_afs_fs_name);
664                         OUT_FS_AFSStoreStatus("Status");
665                         break;
666                 case 142: /* Remove dir */
667                         OUT_FS_AFSFid("Target");
668                         OUT_STRING(hf_afs_fs_name);
669                         break;
670                 case 143: /* Old Set Lock */
671                         OUT_FS_AFSFid("Target");
672                         OUT_UINT(hf_afs_fs_vicelocktype);
673                         OUT_FS_AFSVolSync();
674                         break;
675                 case 144: /* Old Extend Lock */
676                         OUT_FS_AFSFid("Target");
677                         OUT_FS_AFSVolSync();
678                         break;
679                 case 145: /* Old Release Lock */
680                         OUT_FS_AFSFid("Target");
681                         OUT_FS_AFSVolSync();
682                         break;
683                 case 146: /* Get statistics */
684                         /* no params */
685                         break;
686                 case 147: /* Give up callbacks */
687                         OUT_FS_AFSCBFids();
688                         OUT_FS_AFSCBs();
689                         break;
690                 case 148: /* Get vol info */
691                         OUT_STRING(hf_afs_fs_volname);
692                         break;
693                 case 149: /* Get vol stats */
694                         OUT_UINT(hf_afs_fs_volid);
695                         break;
696                 case 150: /* Set vol stats */
697                         OUT_UINT(hf_afs_fs_volid);
698                         OUT_FS_AFSStoreVolumeStatus();
699                         OUT_STRING(hf_afs_fs_volname);
700                         OUT_STRING(hf_afs_fs_offlinemsg);
701                         OUT_STRING(hf_afs_fs_motd);
702                         break;
703                 case 151: /* get root volume */
704                         /* no params */
705                         break;
706                 case 152: /* check token */
707                         OUT_UINT(hf_afs_fs_viceid);
708                         OUT_FS_AFSTOKEN();
709                         break;
710                 case 153: /* get time */
711                         /* no params */
712                         break;
713                 case 154: /* new get vol info */
714                         OUT_STRING(hf_afs_fs_volname);
715                         break;
716                 case 155: /* bulk stat */
717                         OUT_FS_AFSCBFids();
718                         break;
719                 case 156: /* Set Lock */
720                         OUT_FS_AFSFid("Target");
721                         OUT_UINT(hf_afs_fs_vicelocktype);
722                         break;
723                 case 157: /* Extend Lock */
724                         OUT_FS_AFSFid("Target");
725                         break;
726                 case 158: /* Release Lock */
727                         OUT_FS_AFSFid("Target");
728                         break;
729                 case 159: /* xstats version */
730                         /* no params */
731                         break;
732                 case 160: /* get xstats */
733                         OUT_UINT(hf_afs_fs_xstats_clientversion);
734                         OUT_UINT(hf_afs_fs_xstats_collnumber);
735                         break;
736                 case 161: /* lookup */
737                         OUT_FS_AFSFid("Target");
738                         OUT_STRING(hf_afs_fs_name);
739                         break;
740                 case 162: /* flush cps */
741                         OUT_FS_ViceIds();
742                         OUT_FS_IPAddrs();
743                         OUT_UINT(hf_afs_fs_cps_spare1);
744                         break;
745                 case 163: /* dfs symlink */
746                         OUT_FS_AFSFid("Target");
747                         OUT_STRING(hf_afs_fs_symlink_name);
748                         OUT_STRING(hf_afs_fs_symlink_content);
749                         OUT_FS_AFSStoreStatus("Symlink Status");
750                         break;
751         }
752 }
753
754 /*
755  * BOS Helpers
756  */
757 static void
758 dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
759 {
760         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
761         {
762                 switch ( opcode )
763                 {
764                         case 80: /* create bnode */
765                                 /* no output */
766                                 break;
767                         case 81: /* delete bnode */
768                                 /* no output */
769                                 break;
770                         case 82: /* set status */
771                                 /* no output */
772                                 break;
773                         case 83: /* get status */
774                                 OUT_INT(hf_afs_bos_status);
775                                 OUT_STRING(hf_afs_bos_statusdesc);
776                                 break;
777                         case 84: /* enumerate instance */
778                                 OUT_STRING(hf_afs_bos_instance);
779                                 break;
780                         case 85: /* get instance info */
781                                 OUT_STRING(hf_afs_bos_type);
782                                 OUT_BOS_STATUS();
783                                 break;
784                         case 86: /* get instance parm */
785                                 OUT_STRING(hf_afs_bos_parm);
786                                 break;
787                         case 87: /* add siperuser */
788                                 /* no output */
789                                 break;
790                         case 88: /* delete superuser */
791                                 /* no output */
792                                 break;
793                         case 89: /* list superusers */
794                                 OUT_STRING(hf_afs_bos_user);
795                                 break;
796                         case 90: /* list keys */
797                                 OUT_UINT(hf_afs_bos_kvno);
798                                 OUT_BOS_KEY();
799                                 OUT_BOS_KEYINFO();
800                                 break;
801                         case 91: /* add key */
802                                 /* no output */
803                                 break;
804                         case 92: /* delete key */
805                                 /* no output */
806                                 break;
807                         case 93: /* set cell name */
808                                 /* no output */
809                                 break;
810                         case 94: /* get cell name */
811                                 OUT_STRING(hf_afs_bos_cell);
812                                 break;
813                         case 95: /* get cell host */
814                                 OUT_STRING(hf_afs_bos_host);
815                                 break;
816                         case 96: /* add cell host */
817                                 /* no output */
818                                 break;
819                         case 97: /* delete cell host */
820                                 /* no output */
821                                 break;
822                         case 98: /* set tstatus */
823                                 /* no output */
824                                 break;
825                         case 99: /* shutdown all */
826                                 /* no output */
827                                 break;
828                         case 100: /* restart all */
829                                 /* no output */
830                                 break;
831                         case 101: /* startup all */
832                                 /* no output */
833                                 break;
834                         case 102: /* set noauth flag */
835                                 /* no output */
836                                 break;
837                         case 103: /* rebozo */
838                                 /* no output */
839                                 break;
840                         case 104: /* restart */
841                                 /* no output */
842                                 break;
843                         case 105: /* install */
844                                 /* no output */
845                                 break;
846                         case 106: /* uninstall */
847                                 /* no output */
848                                 break;
849                         case 107: /* get dates */
850                                 OUT_DATE(hf_afs_bos_newtime);
851                                 OUT_DATE(hf_afs_bos_baktime);
852                                 OUT_DATE(hf_afs_bos_oldtime);
853                                 break;
854                         case 108: /* exec */
855                                 /* no output */
856                                 break;
857                         case 109: /* prune */
858                                 /* no output */
859                                 break;
860                         case 110: /* set restart time */
861                                 /* no output */
862                                 break;
863                         case 111: /* get restart time */
864                                 OUT_BOS_TIME();
865                                 break;
866                         case 112: /* get log */
867                                 /* need to make this dump a big string somehow */
868                                 OUT_BYTES_ALL(hf_afs_bos_data);
869                                 break;
870                         case 113: /* wait all */
871                                 /* no output */
872                                 break;
873                         case 114: /* get instance strings */
874                                 OUT_STRING(hf_afs_bos_error);
875                                 OUT_STRING(hf_afs_bos_spare1);
876                                 OUT_STRING(hf_afs_bos_spare2);
877                                 OUT_STRING(hf_afs_bos_spare3);
878                                 break;
879                 }
880         }
881         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
882         {
883                 OUT_UINT(hf_afs_bos_errcode);
884         }
885 }
886
887 static void
888 dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
889 {
890         offset += 4;  /* skip the opcode */
891
892         switch ( opcode )
893         {
894                 case 80: /* create b node */
895                         OUT_STRING(hf_afs_bos_type);
896                         OUT_STRING(hf_afs_bos_instance);
897                         OUT_STRING(hf_afs_bos_parm);
898                         OUT_STRING(hf_afs_bos_parm);
899                         OUT_STRING(hf_afs_bos_parm);
900                         OUT_STRING(hf_afs_bos_parm);
901                         OUT_STRING(hf_afs_bos_parm);
902                         OUT_STRING(hf_afs_bos_parm);
903                         break;
904                 case 81: /* delete b node */
905                         OUT_STRING(hf_afs_bos_instance);
906                         break;
907                 case 82: /* set status */
908                         OUT_STRING(hf_afs_bos_instance);
909                         OUT_UINT(hf_afs_bos_status);
910                         break;
911                 case 83: /* get status */
912                         OUT_STRING(hf_afs_bos_instance);
913                         break;
914                 case 84: /* enumerate instance */
915                         OUT_UINT(hf_afs_bos_num);
916                         break;
917                 case 85: /* get instance info */
918                         OUT_STRING(hf_afs_bos_instance);
919                         break;
920                 case 86: /* get instance parm */
921                         OUT_STRING(hf_afs_bos_instance);
922                         OUT_UINT(hf_afs_bos_num);
923                         break;
924                 case 87: /* add super user */
925                         OUT_STRING(hf_afs_bos_user);
926                         break;
927                 case 88: /* delete super user */
928                         OUT_STRING(hf_afs_bos_user);
929                         break;
930                 case 89: /* list super users */
931                         OUT_UINT(hf_afs_bos_num);
932                         break;
933                 case 90: /* list keys */
934                         OUT_UINT(hf_afs_bos_num);
935                         break;
936                 case 91: /* add key */
937                         OUT_UINT(hf_afs_bos_num);
938                         OUT_BOS_KEY();
939                         break;
940                 case 92: /* delete key */
941                         OUT_UINT(hf_afs_bos_num);
942                         break;
943                 case 93: /* set cell name */
944                         OUT_STRING(hf_afs_bos_content);
945                         break;
946                 case 95: /* set cell host */
947                         OUT_UINT(hf_afs_bos_num);
948                         break;
949                 case 96: /* add cell host */
950                         OUT_STRING(hf_afs_bos_content);
951                         break;
952                 case 97: /* delete cell host */
953                         OUT_STRING(hf_afs_bos_content);
954                         break;
955                 case 98: /* set t status */
956                         OUT_STRING(hf_afs_bos_content);
957                         OUT_UINT(hf_afs_bos_status);
958                         break;
959                 case 99: /* shutdown all */
960                         /* no params */
961                         break;
962                 case 100: /* restart all */
963                         /* no params */
964                         break;
965                 case 101: /* startup all */
966                         /* no params */
967                         break;
968                 case 102: /* set no-auth flag */
969                         OUT_UINT(hf_afs_bos_flags);
970                         break;
971                 case 103: /* re-bozo? */
972                         /* no params */
973                         break;
974                 case 104: /* restart */
975                         OUT_STRING(hf_afs_bos_instance);
976                         break;
977                 case 105: /* install */
978                         OUT_STRING(hf_afs_bos_path);
979                         OUT_UINT(hf_afs_bos_size);
980                         OUT_UINT(hf_afs_bos_flags);
981                         OUT_UINT(hf_afs_bos_date);
982                         break;
983                 case 106: /* uninstall */
984                         OUT_STRING(hf_afs_bos_path);
985                         break;
986                 case 107: /* get dates */
987                         OUT_STRING(hf_afs_bos_path);
988                         break;
989                 case 108: /* exec */
990                         OUT_STRING(hf_afs_bos_cmd);
991                         break;
992                 case 109: /* prune */
993                         OUT_UINT(hf_afs_bos_flags);
994                         break;
995                 case 110: /* set restart time */
996                         OUT_UINT(hf_afs_bos_num);
997                         OUT_BOS_TIME();
998                         break;
999                 case 111: /* get restart time */
1000                         OUT_UINT(hf_afs_bos_num);
1001                         break;
1002                 case 112: /* get log */
1003                         OUT_STRING(hf_afs_bos_file);
1004                         break;
1005                 case 113: /* wait all */
1006                         /* no params */
1007                         break;
1008                 case 114: /* get instance strings */
1009                         OUT_STRING(hf_afs_bos_content);
1010                         break;
1011         }
1012 }
1013
1014 /*
1015  * VOL Helpers
1016  */
1017 static void
1018 dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1019 {
1020         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1021         {
1022                 switch ( opcode )
1023                 {
1024                         case 121:
1025                                 /* should loop here maybe */
1026                                 OUT_UINT(hf_afs_vol_count);
1027                                 VECOUT(hf_afs_vol_name, 32); /* not sure on  */
1028                                 break;
1029                 }
1030         }
1031         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1032         {
1033                 OUT_UINT(hf_afs_vol_errcode);
1034         }
1035 }
1036
1037 static void
1038 dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1039 {
1040         offset += 4;  /* skip the opcode */
1041
1042         switch ( opcode )
1043         {
1044                 case 121: /* list one vol */
1045                         OUT_UINT(hf_afs_vol_count);
1046                         OUT_UINT(hf_afs_vol_id);
1047                         break;
1048         }
1049 }
1050
1051 /*
1052  * KAUTH Helpers
1053  */
1054 static void
1055 dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1056 {
1057         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1058         {
1059                 switch ( opcode )
1060                 {
1061                 }
1062         }
1063         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1064         {
1065                 OUT_UINT(hf_afs_kauth_errcode);
1066         }
1067 }
1068
1069 static void
1070 dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1071 {
1072         offset += 4;  /* skip the opcode */
1073
1074         switch ( opcode )
1075         {
1076                 case 1: /* authenticate old */
1077                 case 21: /* authenticate */
1078                 case 22: /* authenticate v2 */
1079                 case 2: /* change pw */
1080                 case 5: /* set fields */
1081                 case 6: /* create user */
1082                 case 7: /* delete user */
1083                 case 8: /* get entry */
1084                 case 14: /* unlock */
1085                 case 15: /* lock status */
1086                         OUT_STRING(hf_afs_kauth_princ);
1087                         OUT_STRING(hf_afs_kauth_realm);
1088                         OUT_BYTES_ALL(hf_afs_kauth_data);
1089                         break;
1090                 case 3: /* getticket-old */
1091                 case 23: /* getticket */
1092                         OUT_UINT(hf_afs_kauth_kvno);
1093                         OUT_STRING(hf_afs_kauth_domain);
1094                         OUT_STRING(hf_afs_kauth_data);
1095                         OUT_STRING(hf_afs_kauth_princ);
1096                         OUT_STRING(hf_afs_kauth_realm);
1097                         break;
1098                 case 4: /* set pass */
1099                         OUT_STRING(hf_afs_kauth_princ);
1100                         OUT_STRING(hf_afs_kauth_realm);
1101                         OUT_UINT(hf_afs_kauth_kvno);
1102                         break;
1103                 case 12: /* get pass */
1104                         OUT_STRING(hf_afs_kauth_name);
1105                         break;
1106         }
1107 }
1108
1109 /*
1110  * CB Helpers
1111  */
1112 static void
1113 dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1114 {
1115         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1116         {
1117                 switch ( opcode )
1118                 {
1119                 }
1120         }
1121         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1122         {
1123                 OUT_UINT(hf_afs_cb_errcode);
1124         }
1125 }
1126
1127 static void
1128 dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1129 {
1130         offset += 4;  /* skip the opcode */
1131
1132         switch ( opcode )
1133         {
1134                 case 204: /* callback */
1135                 {
1136                         unsigned int i,j;
1137
1138                         j = tvb_get_ntohl(tvb, offset);
1139                         offset += 4;
1140
1141                         for (i=0; i<j; i++)
1142                         {
1143                                 OUT_CB_AFSFid("Target");
1144                         }
1145
1146                         j = tvb_get_ntohl(tvb, offset);
1147                         offset += 4;
1148                         for (i=0; i<j; i++)
1149                         {
1150                                 OUT_CB_AFSCallBack();
1151                         }
1152                 }
1153         }
1154 }
1155
1156 /*
1157  * PROT Helpers
1158  */
1159 static void
1160 dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1161 {
1162         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1163         {
1164                 switch ( opcode )
1165                 {
1166                         case 504: /* name to id */
1167                                 {
1168                                         unsigned int i, j;
1169
1170                                         j = tvb_get_ntohl(tvb, offset);
1171                                         OUT_UINT(hf_afs_prot_count);
1172
1173                                         for (i=0; i<j; i++)
1174                                         {
1175                                                 OUT_UINT(hf_afs_prot_id);
1176                                         }
1177                                 }
1178                                 break;
1179                         case 505: /* id to name */
1180                                 {
1181                                         unsigned int i, j;
1182
1183                                         j = tvb_get_ntohl(tvb, offset);
1184                                         OUT_UINT(hf_afs_prot_count);
1185
1186                                         for (i=0; i<j; i++)
1187                                         {
1188                                                 VECOUT(hf_afs_prot_name, PRNAMEMAX);
1189                                         }
1190                                 }
1191                                 break;
1192                         case 508: /* get cps */
1193                         case 514: /* list elements */
1194                         case 517: /* list owned */
1195                         case 518: /* get cps2 */
1196                         case 519: /* get host cps */
1197                                 {
1198                                         unsigned int i, j;
1199
1200                                         j = tvb_get_ntohl(tvb, offset);
1201                                         OUT_UINT(hf_afs_prot_count);
1202
1203                                         for (i=0; i<j; i++)
1204                                         {
1205                                                 OUT_UINT(hf_afs_prot_id);
1206                                         }
1207                                 }
1208                                 break;
1209                         case 510: /* list max */
1210                                 OUT_UINT(hf_afs_prot_maxuid);
1211                                 OUT_UINT(hf_afs_prot_maxgid);
1212                                 break;
1213                 }
1214         }
1215         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1216         {
1217                 OUT_UINT(hf_afs_prot_errcode);
1218         }
1219 }
1220
1221 static void
1222 dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1223 {
1224         offset += 4;  /* skip the opcode */
1225
1226         switch ( opcode )
1227         {
1228                 case 500: /* new user */
1229                         OUT_STRING(hf_afs_prot_name);
1230                         OUT_UINT(hf_afs_prot_id);
1231                         OUT_UINT(hf_afs_prot_oldid);
1232                         break;
1233                 case 501: /* where is it */
1234                 case 506: /* delete */
1235                 case 508: /* get cps */
1236                 case 512: /* list entry */
1237                 case 514: /* list elements */
1238                 case 517: /* list owned */
1239                 case 519: /* get host cps */
1240                         OUT_UINT(hf_afs_prot_id);
1241                         break;
1242                 case 502: /* dump entry */
1243                         OUT_UINT(hf_afs_prot_pos);
1244                         break;
1245                 case 503: /* add to group */
1246                 case 507: /* remove from group */
1247                 case 515: /* is a member of? */
1248                         OUT_UINT(hf_afs_prot_uid);
1249                         OUT_UINT(hf_afs_prot_gid);
1250                         break;
1251                 case 504: /* name to id */
1252                         {
1253                                 unsigned int i, j;
1254
1255                                 j = tvb_get_ntohl(tvb, offset);
1256                                 OUT_UINT(hf_afs_prot_count);
1257
1258                                 for (i=0; i<j; i++)
1259                                 {
1260                                         VECOUT(hf_afs_prot_name,PRNAMEMAX);
1261                                 }
1262                         }
1263                         break;
1264                 case 505: /* id to name */
1265                         {
1266                                 unsigned int i, j;
1267
1268                                 j = tvb_get_ntohl(tvb, offset);
1269                                 OUT_UINT(hf_afs_prot_count);
1270
1271                                 for (i=0; i<j; i++)
1272                                 {
1273                                         OUT_UINT(hf_afs_prot_id);
1274                                 }
1275                         }
1276                         break;
1277                 case 509: /* new entry */
1278                         OUT_STRING(hf_afs_prot_name);
1279                         OUT_UINT(hf_afs_prot_flag);
1280                         OUT_UINT(hf_afs_prot_oldid);
1281                         break;
1282                 case 511: /* set max */
1283                         OUT_UINT(hf_afs_prot_id);
1284                         OUT_UINT(hf_afs_prot_flag);
1285                         break;
1286                 case 513: /* change entry */
1287                         OUT_UINT(hf_afs_prot_id);
1288                         OUT_STRING(hf_afs_prot_name);
1289                         OUT_UINT(hf_afs_prot_oldid);
1290                         OUT_UINT(hf_afs_prot_newid);
1291                         break;
1292                 case 520: /* update entry */
1293                         OUT_UINT(hf_afs_prot_id);
1294                         OUT_STRING(hf_afs_prot_name);
1295                         break;
1296         }
1297 }
1298
1299 /*
1300  * VLDB Helpers
1301  */
1302 static void
1303 dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1304 {
1305         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1306         {
1307                 switch ( opcode )
1308                 {
1309                         case 510: /* list entry */
1310                                 OUT_UINT(hf_afs_vldb_count);
1311                                 OUT_UINT(hf_afs_vldb_nextindex);
1312                                 break;
1313                         case 503: /* get entry by id */
1314                         case 504: /* get entry by name */
1315                                 {
1316                                         int nservers,i,j;
1317                                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1318                                         nservers = tvb_get_ntohl(tvb, offset);
1319                                         OUT_UINT(hf_afs_vldb_numservers);
1320                                         for (i=0; i<8; i++)
1321                                         {
1322                                                 if ( i<nservers )
1323                                                 {
1324                                                         OUT_IP(hf_afs_vldb_server);
1325                                                 }
1326                                                 else
1327                                                 {
1328                                                         SKIP(4);
1329                                                 }
1330                                         }
1331                                         for (i=0; i<8; i++)
1332                                         {
1333                                                 char part[8];
1334                                                 j = tvb_get_ntohl(tvb, offset);
1335                                                 strcpy(part, "/vicepa");
1336                                                 if ( i<nservers && j<=25 )
1337                                                 {
1338                                                         part[6] = 'a' + (char) j;
1339                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1340                                                                 offset, 4, part);
1341                                                 }
1342                                                 SKIP(4);
1343                                         }
1344                                         SKIP(8 * sizeof(guint32));
1345                                         OUT_UINT(hf_afs_vldb_rwvol);
1346                                         OUT_UINT(hf_afs_vldb_rovol);
1347                                         OUT_UINT(hf_afs_vldb_bkvol);
1348                                 }
1349                                 break;
1350                         case 505: /* get new volume id */
1351                                 OUT_UINT(hf_afs_vldb_id);
1352                                 break;
1353                         case 521: /* list entry */
1354                         case 529: /* list entry U */
1355                                 OUT_UINT(hf_afs_vldb_count);
1356                                 OUT_UINT(hf_afs_vldb_nextindex);
1357                                 break;
1358                         case 518: /* get entry by id n */
1359                         case 519: /* get entry by name N */
1360                                 {
1361                                         int nservers,i,j;
1362                                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1363                                         nservers = tvb_get_ntohl(tvb, offset);
1364                                         OUT_UINT(hf_afs_vldb_numservers);
1365                                         for (i=0; i<13; i++)
1366                                         {
1367                                                 if ( i<nservers )
1368                                                 {
1369                                                         OUT_IP(hf_afs_vldb_server);
1370                                                 }
1371                                                 else
1372                                                 {
1373                                                         SKIP(4);
1374                                                 }
1375                                         }
1376                                         for (i=0; i<13; i++)
1377                                         {
1378                                                 char part[8];
1379                                                 j = tvb_get_ntohl(tvb, offset);
1380                                                 strcpy(part, "/vicepa");
1381                                                 if ( i<nservers && j<=25 )
1382                                                 {
1383                                                         part[6] = 'a' + (char) j;
1384                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1385                                                                 offset, 4, part);
1386                                                 }
1387                                                 SKIP(4);
1388                                         }
1389                                         SKIP(13 * sizeof(guint32));
1390                                         OUT_UINT(hf_afs_vldb_rwvol);
1391                                         OUT_UINT(hf_afs_vldb_rovol);
1392                                         OUT_UINT(hf_afs_vldb_bkvol);
1393                                 }
1394                                 break;
1395                         case 526: /* get entry by id u */
1396                         case 527: /* get entry by name u */
1397                                 {
1398                                         int nservers,i,j;
1399                                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1400                                         nservers = tvb_get_ntohl(tvb, offset);
1401                                         OUT_UINT(hf_afs_vldb_numservers);
1402                                         for (i=0; i<13; i++)
1403                                         {
1404                                                 if ( i<nservers )
1405                                                 {
1406                                                         OUT_BYTES(hf_afs_vldb_serveruuid, 11*sizeof(guint32));
1407                                                 }
1408                                                 else
1409                                                 {
1410                                                         SKIP(11*sizeof(guint32));
1411                                                 }
1412                                         }
1413                                         for (i=0; i<13; i++)
1414                                         {
1415                                                 char part[8];
1416                                                 j = tvb_get_ntohl(tvb, offset);
1417                                                 strcpy(part, "/vicepa");
1418                                                 if ( i<nservers && j<=25 )
1419                                                 {
1420                                                         part[6] = 'a' + (char) j;
1421                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1422                                                                 offset, 4, part);
1423                                                 }
1424                                                 SKIP(4);
1425                                         }
1426                                         SKIP(13 * sizeof(guint32));
1427                                         OUT_UINT(hf_afs_vldb_rwvol);
1428                                         OUT_UINT(hf_afs_vldb_rovol);
1429                                         OUT_UINT(hf_afs_vldb_bkvol);
1430                                 }
1431                                 break;
1432                 }
1433         }
1434         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1435         {
1436                 OUT_UINT(hf_afs_vldb_errcode);
1437         }
1438 }
1439
1440 static void
1441 dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1442 {
1443         offset += 4;  /* skip the opcode */
1444
1445         switch ( opcode )
1446         {
1447                 case 501: /* create new volume */
1448                 case 517: /* create entry N */
1449                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1450                         break;
1451                 case 502: /* delete entry */
1452                 case 503: /* get entry by id */
1453                 case 507: /* update entry */
1454                 case 508: /* set lock */
1455                 case 509: /* release lock */
1456                 case 518: /* get entry by id */
1457                         OUT_UINT(hf_afs_vldb_id);
1458                         OUT_UINT(hf_afs_vldb_type);
1459                         break;
1460                 case 504: /* get entry by name */
1461                 case 519: /* get entry by name N */
1462                 case 524: /* update entry by name */
1463                 case 527: /* get entry by name U */
1464                         OUT_STRING(hf_afs_vldb_name);
1465                         break;
1466                 case 505: /* get new vol id */
1467                         OUT_UINT(hf_afs_vldb_bump);
1468                         break;
1469                 case 506: /* replace entry */
1470                 case 520: /* replace entry N */
1471                         OUT_UINT(hf_afs_vldb_id);
1472                         OUT_UINT(hf_afs_vldb_type);
1473                         VECOUT(hf_afs_vldb_name, VLNAMEMAX);
1474                         break;
1475                 case 510: /* list entry */
1476                 case 521: /* list entry N */
1477                         OUT_UINT(hf_afs_vldb_index);
1478                         break;
1479         }
1480 }
1481
1482 /*
1483  * UBIK Helpers
1484  */
1485 static void
1486 dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1487 {
1488         switch ( opcode )
1489         {
1490                 case 10000: /* vote-beacon */
1491                         break;
1492                 case 10001: /* vote-debug-old */
1493                         OUT_UBIK_DebugOld();
1494                         break;
1495                 case 10002: /* vote-sdebug-old */
1496                         OUT_UBIK_SDebugOld();
1497                         break;
1498                 case 10003: /* vote-get syncsite */
1499                         break;
1500                 case 10004: /* vote-debug */
1501                         OUT_UBIK_DebugOld();
1502                         OUT_UBIK_InterfaceAddrs();
1503                         break;
1504                 case 10005: /* vote-sdebug */
1505                         OUT_UBIK_SDebugOld();
1506                         OUT_UBIK_InterfaceAddrs();
1507                         break;
1508                 case 10006: /* vote-xdebug */
1509                         OUT_UBIK_DebugOld();
1510                         OUT_UBIK_InterfaceAddrs();
1511                         OUT_UINT(hf_afs_ubik_isclone);
1512                         break;
1513                 case 10007: /* vote-xsdebug */
1514                         OUT_UBIK_SDebugOld();
1515                         OUT_UBIK_InterfaceAddrs();
1516                         OUT_UINT(hf_afs_ubik_isclone);
1517                         break;
1518                 case 20000: /* disk-begin */
1519                         break;
1520                 case 20004: /* get version */
1521                         OUT_UBIKVERSION("DB Version");
1522                         break;
1523                 case 20010: /* disk-probe */
1524                         break;
1525                 case 20012: /* disk-interfaceaddr */
1526                         OUT_UBIK_InterfaceAddrs();
1527                         break;
1528         }
1529 }
1530
1531 static void
1532 dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1533 {
1534         offset += 4;  /* skip the opcode */
1535
1536         switch ( opcode )
1537         {
1538                 case 10000: /* vote-beacon */
1539                         OUT_UINT(hf_afs_ubik_state);
1540                         OUT_DATE(hf_afs_ubik_votestart);
1541                         OUT_UBIKVERSION("DB Version");
1542                         OUT_UBIKVERSION("TID");
1543                         break;
1544                 case 10001: /* vote-debug-old */
1545                         break;
1546                 case 10002: /* vote-sdebug-old */
1547                         OUT_UINT(hf_afs_ubik_site);
1548                         break;
1549                 case 10003: /* vote-get sync site */
1550                         OUT_IP(hf_afs_ubik_site);
1551                         break;
1552                 case 10004: /* vote-debug */
1553                 case 10005: /* vote-sdebug */
1554                         OUT_IP(hf_afs_ubik_site);
1555                         break;
1556                 case 20000: /* disk-begin */
1557                         OUT_UBIKVERSION("TID");
1558                         break;
1559                 case 20001: /* disk-commit */
1560                         OUT_UBIKVERSION("TID");
1561                         break;
1562                 case 20002: /* disk-lock */
1563                         OUT_UBIKVERSION("TID");
1564                         OUT_UINT(hf_afs_ubik_file);
1565                         OUT_UINT(hf_afs_ubik_pos);
1566                         OUT_UINT(hf_afs_ubik_length);
1567                         OUT_UINT(hf_afs_ubik_locktype);
1568                         break;
1569                 case 20003: /* disk-write */
1570                         OUT_UBIKVERSION("TID");
1571                         OUT_UINT(hf_afs_ubik_file);
1572                         OUT_UINT(hf_afs_ubik_pos);
1573                         break;
1574                 case 20004: /* disk-get version */
1575                         break;
1576                 case 20005: /* disk-get file */
1577                         OUT_UINT(hf_afs_ubik_file);
1578                         break;
1579                 case 20006: /* disk-send file */
1580                         OUT_UINT(hf_afs_ubik_file);
1581                         OUT_UINT(hf_afs_ubik_length);
1582                         OUT_UBIKVERSION("DB Version");
1583                         break;
1584                 case 20007: /* disk-abort */
1585                 case 20008: /* disk-release locks */
1586                 case 20010: /* disk-probe */
1587                         break;
1588                 case 20009: /* disk-truncate */
1589                         OUT_UBIKVERSION("TID");
1590                         OUT_UINT(hf_afs_ubik_file);
1591                         OUT_UINT(hf_afs_ubik_length);
1592                         break;
1593                 case 20011: /* disk-writev */
1594                         OUT_UBIKVERSION("TID");
1595                         break;
1596                 case 20012: /* disk-interfaceaddr */
1597                         OUT_UBIK_InterfaceAddrs();
1598                         break;
1599                 case 20013: /* disk-set version */
1600                         OUT_UBIKVERSION("TID");
1601                         OUT_UBIKVERSION("Old DB Version");
1602                         OUT_UBIKVERSION("New DB Version");
1603                         break;
1604         }
1605 }
1606
1607 /*
1608  * BACKUP Helpers
1609  */
1610 static void
1611 dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1612 {
1613         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1614         {
1615                 switch ( opcode )
1616                 {
1617                 }
1618         }
1619         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1620         {
1621                 OUT_UINT(hf_afs_backup_errcode);
1622         }
1623 }
1624
1625 static void
1626 dissect_backup_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1627 {
1628         offset += 4;  /* skip the opcode */
1629
1630         switch ( opcode )
1631         {
1632         }
1633 }
1634
1635 /*
1636  * Registration code for registering the protocol and fields
1637  */
1638
1639 void
1640 proto_register_afs(void)
1641 {
1642         static hf_register_info hf[] = {
1643 #include "packet-afs-register-info.h"
1644         };
1645         static gint *ett[] = {
1646                 &ett_afs,
1647                 &ett_afs_op,
1648                 &ett_afs_acl,
1649                 &ett_afs_fid,
1650                 &ett_afs_callback,
1651                 &ett_afs_ubikver,
1652                 &ett_afs_status,
1653                 &ett_afs_status_mask,
1654                 &ett_afs_volsync,
1655                 &ett_afs_volumeinfo,
1656                 &ett_afs_vicestat,
1657         };
1658
1659         proto_afs = proto_register_protocol("Andrew File System (AFS)",
1660             "AFS (RX)", "afs");
1661         proto_register_field_array(proto_afs, hf, array_length(hf));
1662         proto_register_subtree_array(ett, array_length(ett));
1663         register_init_routine(&afs_init_protocol);
1664
1665         register_dissector("afs", dissect_afs, proto_afs);
1666 }