In the hex dump, generate the offset at the beginning of each line in
[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.47 2002/06/13 06:43:44 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 <epan/packet.h>
51 #include <epan/conversation.h>
52 #include <epan/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_ensure_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 static 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 static GHashTable *afs_request_hash = NULL;
77 static GMemChunk *afs_request_keys = NULL;
78 static 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->cinfo, COL_PROTOCOL)) {
200                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AFS (RX)");
201         }
202         if (check_col(pinfo->cinfo, COL_INFO)) {
203                 col_clear(pinfo->cinfo, 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->cinfo, COL_INFO))
338                                 col_add_fstr(pinfo->cinfo, 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->cinfo, COL_INFO))
345                                 col_add_fstr(pinfo->cinfo, 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->cinfo, COL_INFO))
353                         col_add_fstr(pinfo->cinfo, 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, -1,
361                                 FALSE);
362                 afs_tree = proto_item_add_subtree(ti, ett_afs);
363
364                 proto_tree_add_text(afs_tree, tvb,
365                         offset, -1,
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                                 if ( rxinfo->seq == 1 )
377                                 {
378                                         ti = proto_tree_add_uint(afs_tree,
379                                                 node, tvb, offset, 4, opcode);
380                                 } else {
381                                         ti = proto_tree_add_uint(afs_tree,
382                                                 node, tvb, offset, 0, opcode);
383                                 }
384                         } else if ( reply && node != 0 ) {
385                                 /* the opcode isn't in this packet */
386                                 ti = proto_tree_add_uint(afs_tree,
387                                         node, tvb, offset, 0, opcode);
388                         } else {
389                                 ti = proto_tree_add_text(afs_tree, tvb,
390                                         offset, 0, "Operation: Unknown");
391                         }
392         
393                         /* Add the subtree for this particular service */
394                         afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
395         
396                         if ( typenode != 0 ) {
397                                 /* indicate the type of request */
398                                 proto_tree_add_boolean_hidden(afs_tree, typenode, tvb, offset, 0, 1);
399                         }
400         
401                         /* Process the packet according to what service it is */
402                         if ( dissector ) {
403                                 (*dissector)(tvb, rxinfo, afs_op_tree, offset, opcode);
404                         }
405                 }
406         }
407
408         /* if it's the last packet, and it's a reply, remove opcode
409                 from hash */
410         /* ignoring for now, I'm not sure how the chunk deallocation works */
411         if ( rxinfo->flags & RX_LAST_PACKET && reply ){
412
413         }
414 }
415
416
417 /*
418  * Here is a helper routine for adding an AFS acl to the proto tree
419  * This is to be used with FS packets only
420  *
421  * An AFS ACL is a string that has the following format:
422  *
423  * <positive> <negative>
424  * <uid1> <aclbits1>
425  * ....
426  *
427  * "positive" and "negative" are integers which contain the number of
428  * positive and negative ACL's in the string.  The uid/aclbits pair are
429  * ASCII strings containing the UID/PTS record and and a ascii number
430  * representing a logical OR of all the ACL permission bits
431  */
432 /*
433  * XXX - FIXME:
434  *
435  *      sscanf is probably quite dangerous if we run outside the packet.
436  *
437  *      "GETSTR" doesn't guarantee that the resulting string is
438  *      null-terminated.
439  *
440  * Should this just scan the string itself, rather than using "sscanf()"?
441  */
442 static int 
443 dissect_acl(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset)
444 {
445         int old_offset;
446         gint32 bytes;
447         int i, n, pos, neg, acl;
448         char user[128]; /* Be sure to adjust sscanf()s below if length is changed... */
449
450         old_offset = offset;
451         bytes = tvb_get_ntohl(tvb, offset);
452         OUT_UINT(hf_afs_fs_acl_datasize);
453
454
455         if (sscanf((char *) GETSTR, "%d %n", &pos, &n) != 1) {
456                 /* does not matter what we return, if this fails, 
457                  * we cant dissect anything else in the packet either.
458                  */
459                 return offset;
460         }
461         proto_tree_add_uint(tree, hf_afs_fs_acl_count_positive, tvb, 
462                 offset, n, pos);
463         offset += n;
464
465
466         if (sscanf((char *) GETSTR, "%d %n", &neg, &n) != 1) {
467                 return offset;
468         }
469         proto_tree_add_uint(tree, hf_afs_fs_acl_count_negative, tvb, 
470                 offset, n, neg);
471         offset += n;
472
473         /*
474          * This wacky order preserves the order used by the "fs" command
475          */
476         for (i = 0; i < pos; i++) {
477                 if (sscanf((char *) GETSTR, 
478                                 "%127s %d %n", user, &acl, &n) != 2) {
479                         return offset;
480                 }
481                 ACLOUT(user,1,acl,n);
482                 offset += n;
483         }
484         for (i = 0; i < neg; i++) {
485                 if (sscanf((char *) GETSTR, 
486                         "%127s %d %n", user, &acl, &n) != 2) {
487                         return offset;
488                 }
489                 ACLOUT(user,0,acl,n);
490                 offset += n;
491                 if (offset >= old_offset+bytes ) {
492                         return offset;
493                 }
494         }
495
496         return offset;
497 }
498
499 /*
500  * Here are the helper dissection routines
501  */
502
503 static void
504 dissect_fs_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
505 {
506         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
507         {
508                 switch ( opcode )
509                 {
510                         case 130: /* fetch data */
511                                 /* only on first packet */
512                                 if ( rxinfo->seq == 1 )
513                                 {
514                                         OUT_FS_AFSFetchStatus("Status");
515                                         OUT_FS_AFSCallBack();
516                                         OUT_FS_AFSVolSync();
517                                 }
518                                 OUT_BYTES_ALL(hf_afs_fs_data);
519                                 break;
520                         case 131: /* fetch acl */
521                                 offset = dissect_acl(tvb, rxinfo, tree, offset);
522                                 OUT_FS_AFSFetchStatus("Status");
523                                 OUT_FS_AFSVolSync();
524                                 break;
525                         case 132: /* Fetch status */
526                                 OUT_FS_AFSFetchStatus("Status");
527                                 OUT_FS_AFSCallBack();
528                                 OUT_FS_AFSVolSync();
529                                 break;  
530                         case 133: /* Store data */
531                         case 134: /* Store ACL */
532                         case 135: /* Store status */
533                         case 136: /* Remove file */
534                                 OUT_FS_AFSFetchStatus("Status");
535                                 OUT_FS_AFSVolSync();
536                                 break;
537                         case 137: /* create file */
538                         case 141: /* make dir */
539                         case 161: /* lookup */
540                         case 163: /* dfs symlink */
541                                 OUT_FS_AFSFid((opcode == 137)? "New File" : ((opcode == 141)? "New Directory" : "File"));
542                                 OUT_FS_AFSFetchStatus("File Status");
543                                 OUT_FS_AFSFetchStatus("Directory Status");
544                                 OUT_FS_AFSCallBack();
545                                 OUT_FS_AFSVolSync();
546                                 break;
547                         case 138: /* rename */
548                                 OUT_FS_AFSFetchStatus("Old Directory Status");
549                                 OUT_FS_AFSFetchStatus("New Directory Status");
550                                 OUT_FS_AFSVolSync();
551                                 break;
552                         case 139: /* symlink */
553                                 OUT_FS_AFSFid("Symlink");
554                         case 140: /* link */
555                                 OUT_FS_AFSFetchStatus("Symlink Status");
556                         case 142: /* rmdir */
557                                 OUT_FS_AFSFetchStatus("Directory Status");
558                                 OUT_FS_AFSVolSync();
559                                 break;
560                         case 143: /* old set lock */
561                         case 144: /* old extend lock */
562                         case 145: /* old release lock */
563                         case 147: /* give up callbacks */
564                         case 150: /* set volume status */
565                         case 152: /* check token */ 
566                                 /* nothing returned */
567                                 break;
568                         case 146: /* get statistics */
569                                 OUT_FS_ViceStatistics();
570                                 break;
571                         case 148: /* get volume info */
572                         case 154: /* n-get-volume-info */
573                                 OUT_FS_VolumeInfo();
574                                 break;
575                         case 149: /* get volume status */
576                                 OUT_FS_AFSFetchVolumeStatus();
577                                 OUT_RXString(hf_afs_fs_volname);
578                                 OUT_RXString(hf_afs_fs_offlinemsg);
579                                 OUT_RXString(hf_afs_fs_motd);
580                                 break;
581                         case 151: /* root volume */
582                                 OUT_RXString(hf_afs_fs_volname);
583                                 break;
584                         case 153: /* get time */
585                                 OUT_TIMESTAMP(hf_afs_fs_timestamp);
586                                 break;
587                         case 155: /* bulk status */
588                                 OUT_FS_AFSBulkStats();
589                                 SKIP(4); 
590                                 OUT_FS_AFSCBs();
591                                 OUT_FS_AFSVolSync();
592                                 break;
593                         case 156: /* set lock */
594                         case 157: /* extend lock */
595                         case 158: /* release lock */
596                                 OUT_FS_AFSVolSync();
597                                 break;
598                         case 159: /* x-stats-version */
599                                 OUT_UINT(hf_afs_fs_xstats_version);
600                                 break;
601                         case 160: /* get xstats */
602                                 OUT_UINT(hf_afs_fs_xstats_version);
603                                 OUT_DATE(hf_afs_fs_xstats_timestamp);
604                                 OUT_FS_AFS_CollData();
605                                 break;
606                         case 162: /* flush cps */
607                                 OUT_UINT(hf_afs_fs_cps_spare2);
608                                 OUT_UINT(hf_afs_fs_cps_spare3);
609                                 break;
610                 }
611         }
612         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
613         {
614                 OUT_UINT(hf_afs_fs_errcode);
615         }
616 }
617
618 static void
619 dissect_fs_request(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
620 {
621         /* skip the opcode if this is the first packet in the stream */
622         if ( rxinfo->seq == 1 )
623         {
624                 offset += 4;  /* skip the opcode */
625         }
626
627         switch ( opcode )
628         {
629                 case 130: /* Fetch data */
630                         OUT_FS_AFSFid("Source");
631                         OUT_UINT(hf_afs_fs_offset);
632                         OUT_UINT(hf_afs_fs_length);
633                         break;
634                 case 131: /* Fetch ACL */
635                         OUT_FS_AFSFid("Target");
636                         break;          
637                 case 132: /* Fetch Status */
638                         OUT_FS_AFSFid("Target");
639                         break;
640                 case 133: /* Store Data */
641                         if ( rxinfo->seq == 1 )
642                         {
643                                 OUT_FS_AFSFid("Destination");
644                                 OUT_FS_AFSStoreStatus("Status");
645                                 OUT_UINT(hf_afs_fs_offset);
646                                 OUT_UINT(hf_afs_fs_length);
647                                 OUT_UINT(hf_afs_fs_flength);
648                         }
649                         OUT_BYTES_ALL(hf_afs_fs_data);
650                         break;
651                 case 134: /* Store ACL */
652                         OUT_FS_AFSFid("Target");
653                         offset = dissect_acl(tvb, rxinfo, tree, offset);
654                         break;
655                 case 135: /* Store Status */
656                         OUT_FS_AFSFid("Target");
657                         OUT_FS_AFSStoreStatus("Status");
658                         break;
659                 case 136: /* Remove File */
660                         OUT_FS_AFSFid("Remove File");
661                         OUT_RXString(hf_afs_fs_name);
662                         break;
663                 case 137: /* Create File */
664                         OUT_FS_AFSFid("Target");
665                         OUT_RXString(hf_afs_fs_name);
666                         OUT_FS_AFSStoreStatus("Status");
667                         break;
668                 case 138: /* Rename file */
669                         OUT_FS_AFSFid("Old");
670                         OUT_RXString(hf_afs_fs_oldname);
671                         OUT_FS_AFSFid("New");
672                         OUT_RXString(hf_afs_fs_newname);
673                         break;
674                 case 139: /* Symlink */
675                         OUT_FS_AFSFid("File");
676                         OUT_RXString(hf_afs_fs_symlink_name);
677                         OUT_RXString(hf_afs_fs_symlink_content);
678                         OUT_FS_AFSStoreStatus("Status");
679                         break;
680                 case 140: /* Link */
681                         OUT_FS_AFSFid("Link To (New File)");
682                         OUT_RXString(hf_afs_fs_name);
683                         OUT_FS_AFSFid("Link From (Old File)");
684                         break;
685                 case 141: /* Make dir */
686                         OUT_FS_AFSFid("Target");
687                         OUT_RXString(hf_afs_fs_name);
688                         OUT_FS_AFSStoreStatus("Status");
689                         break;
690                 case 142: /* Remove dir */
691                         OUT_FS_AFSFid("Target");
692                         OUT_RXString(hf_afs_fs_name);
693                         break;
694                 case 143: /* Old Set Lock */
695                         OUT_FS_AFSFid("Target");
696                         OUT_UINT(hf_afs_fs_vicelocktype);
697                         OUT_FS_AFSVolSync();
698                         break;
699                 case 144: /* Old Extend Lock */
700                         OUT_FS_AFSFid("Target");
701                         OUT_FS_AFSVolSync();
702                         break;
703                 case 145: /* Old Release Lock */
704                         OUT_FS_AFSFid("Target");
705                         OUT_FS_AFSVolSync();
706                         break;
707                 case 146: /* Get statistics */
708                         /* no params */
709                         break;
710                 case 147: /* Give up callbacks */
711                         OUT_FS_AFSCBFids();
712                         OUT_FS_AFSCBs();
713                         break;
714                 case 148: /* Get vol info */
715                         OUT_RXString(hf_afs_fs_volname);
716                         break;
717                 case 149: /* Get vol stats */
718                         OUT_UINT(hf_afs_fs_volid);
719                         break;
720                 case 150: /* Set vol stats */
721                         OUT_UINT(hf_afs_fs_volid);
722                         OUT_FS_AFSStoreVolumeStatus();
723                         OUT_RXString(hf_afs_fs_volname);
724                         OUT_RXString(hf_afs_fs_offlinemsg);
725                         OUT_RXString(hf_afs_fs_motd);
726                         break;
727                 case 151: /* get root volume */
728                         /* no params */
729                         break;
730                 case 152: /* check token */
731                         OUT_UINT(hf_afs_fs_viceid);
732                         OUT_FS_AFSTOKEN();
733                         break;
734                 case 153: /* get time */
735                         /* no params */
736                         break;
737                 case 154: /* new get vol info */
738                         OUT_RXString(hf_afs_fs_volname);
739                         break;
740                 case 155: /* bulk stat */
741                         OUT_FS_AFSCBFids();
742                         break;
743                 case 156: /* Set Lock */
744                         OUT_FS_AFSFid("Target");
745                         OUT_UINT(hf_afs_fs_vicelocktype);
746                         break;
747                 case 157: /* Extend Lock */
748                         OUT_FS_AFSFid("Target");
749                         break;
750                 case 158: /* Release Lock */
751                         OUT_FS_AFSFid("Target");
752                         break;
753                 case 159: /* xstats version */
754                         /* no params */
755                         break;
756                 case 160: /* get xstats */
757                         OUT_UINT(hf_afs_fs_xstats_clientversion);
758                         OUT_UINT(hf_afs_fs_xstats_collnumber);
759                         break;
760                 case 161: /* lookup */
761                         OUT_FS_AFSFid("Target");
762                         OUT_RXString(hf_afs_fs_name);
763                         break;
764                 case 162: /* flush cps */
765                         OUT_FS_ViceIds();
766                         OUT_FS_IPAddrs();
767                         OUT_UINT(hf_afs_fs_cps_spare1);
768                         break;
769                 case 163: /* dfs symlink */
770                         OUT_FS_AFSFid("Target");
771                         OUT_RXString(hf_afs_fs_symlink_name);
772                         OUT_RXString(hf_afs_fs_symlink_content);
773                         OUT_FS_AFSStoreStatus("Symlink Status");
774                         break;
775         }
776 }
777
778 /*
779  * BOS Helpers
780  */
781 static void
782 dissect_bos_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
783 {
784         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
785         {
786                 switch ( opcode )
787                 {
788                         case 80: /* create bnode */
789                                 /* no output */
790                                 break;
791                         case 81: /* delete bnode */
792                                 /* no output */
793                                 break;
794                         case 82: /* set status */
795                                 /* no output */
796                                 break;
797                         case 83: /* get status */
798                                 OUT_INT(hf_afs_bos_status);
799                                 OUT_RXString(hf_afs_bos_statusdesc);
800                                 break;
801                         case 84: /* enumerate instance */
802                                 OUT_RXString(hf_afs_bos_instance);
803                                 break;
804                         case 85: /* get instance info */
805                                 OUT_RXString(hf_afs_bos_type);
806                                 OUT_BOS_STATUS();
807                                 break;
808                         case 86: /* get instance parm */
809                                 OUT_RXString(hf_afs_bos_parm);
810                                 break;
811                         case 87: /* add siperuser */
812                                 /* no output */
813                                 break;
814                         case 88: /* delete superuser */
815                                 /* no output */
816                                 break;
817                         case 89: /* list superusers */
818                                 OUT_RXString(hf_afs_bos_user);
819                                 break;
820                         case 90: /* list keys */
821                                 OUT_UINT(hf_afs_bos_kvno);
822                                 OUT_BOS_KEY();
823                                 OUT_BOS_KEYINFO();
824                                 break;
825                         case 91: /* add key */
826                                 /* no output */
827                                 break;
828                         case 92: /* delete key */
829                                 /* no output */
830                                 break;
831                         case 93: /* set cell name */
832                                 /* no output */
833                                 break;
834                         case 94: /* get cell name */
835                                 OUT_RXString(hf_afs_bos_cell);
836                                 break;
837                         case 95: /* get cell host */
838                                 OUT_RXString(hf_afs_bos_host);
839                                 break;
840                         case 96: /* add cell host */
841                                 /* no output */
842                                 break;
843                         case 97: /* delete cell host */
844                                 /* no output */
845                                 break;
846                         case 98: /* set tstatus */
847                                 /* no output */
848                                 break;
849                         case 99: /* shutdown all */
850                                 /* no output */
851                                 break;
852                         case 100: /* restart all */
853                                 /* no output */
854                                 break;
855                         case 101: /* startup all */
856                                 /* no output */
857                                 break;
858                         case 102: /* set noauth flag */
859                                 /* no output */
860                                 break;
861                         case 103: /* rebozo */
862                                 /* no output */
863                                 break;
864                         case 104: /* restart */
865                                 /* no output */
866                                 break;
867                         case 105: /* install */
868                                 /* no output */
869                                 break;
870                         case 106: /* uninstall */
871                                 /* no output */
872                                 break;
873                         case 107: /* get dates */
874                                 OUT_DATE(hf_afs_bos_newtime);
875                                 OUT_DATE(hf_afs_bos_baktime);
876                                 OUT_DATE(hf_afs_bos_oldtime);
877                                 break;
878                         case 108: /* exec */
879                                 /* no output */
880                                 break;
881                         case 109: /* prune */
882                                 /* no output */
883                                 break;
884                         case 110: /* set restart time */
885                                 /* no output */
886                                 break;
887                         case 111: /* get restart time */
888                                 OUT_BOS_TIME();
889                                 break;
890                         case 112: /* get log */
891                                 /* need to make this dump a big string somehow */
892                                 OUT_BYTES_ALL(hf_afs_bos_data);
893                                 break;
894                         case 113: /* wait all */
895                                 /* no output */
896                                 break;
897                         case 114: /* get instance strings */
898                                 OUT_RXString(hf_afs_bos_error);
899                                 OUT_RXString(hf_afs_bos_spare1);
900                                 OUT_RXString(hf_afs_bos_spare2);
901                                 OUT_RXString(hf_afs_bos_spare3);
902                                 break;
903                 }
904         }
905         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
906         {
907                 OUT_UINT(hf_afs_bos_errcode);
908         }
909 }
910
911 static void
912 dissect_bos_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
913 {
914         offset += 4;  /* skip the opcode */
915
916         switch ( opcode )
917         {
918                 case 80: /* create b node */
919                         OUT_RXString(hf_afs_bos_type);
920                         OUT_RXString(hf_afs_bos_instance);
921                         OUT_RXString(hf_afs_bos_parm);
922                         OUT_RXString(hf_afs_bos_parm);
923                         OUT_RXString(hf_afs_bos_parm);
924                         OUT_RXString(hf_afs_bos_parm);
925                         OUT_RXString(hf_afs_bos_parm);
926                         OUT_RXString(hf_afs_bos_parm);
927                         break;
928                 case 81: /* delete b node */
929                         OUT_RXString(hf_afs_bos_instance);
930                         break;
931                 case 82: /* set status */
932                         OUT_RXString(hf_afs_bos_instance);
933                         OUT_UINT(hf_afs_bos_status);
934                         break;
935                 case 83: /* get status */
936                         OUT_RXString(hf_afs_bos_instance);
937                         break;
938                 case 84: /* enumerate instance */
939                         OUT_UINT(hf_afs_bos_num);
940                         break;
941                 case 85: /* get instance info */
942                         OUT_RXString(hf_afs_bos_instance);
943                         break;
944                 case 86: /* get instance parm */
945                         OUT_RXString(hf_afs_bos_instance);
946                         OUT_UINT(hf_afs_bos_num);
947                         break;
948                 case 87: /* add super user */
949                         OUT_RXString(hf_afs_bos_user);
950                         break;
951                 case 88: /* delete super user */
952                         OUT_RXString(hf_afs_bos_user);
953                         break;
954                 case 89: /* list super users */
955                         OUT_UINT(hf_afs_bos_num);
956                         break;
957                 case 90: /* list keys */
958                         OUT_UINT(hf_afs_bos_num);
959                         break;
960                 case 91: /* add key */
961                         OUT_UINT(hf_afs_bos_num);
962                         OUT_BOS_KEY();
963                         break;
964                 case 92: /* delete key */
965                         OUT_UINT(hf_afs_bos_num);
966                         break;
967                 case 93: /* set cell name */
968                         OUT_RXString(hf_afs_bos_content);
969                         break;
970                 case 95: /* set cell host */
971                         OUT_UINT(hf_afs_bos_num);
972                         break;
973                 case 96: /* add cell host */
974                         OUT_RXString(hf_afs_bos_content);
975                         break;
976                 case 97: /* delete cell host */
977                         OUT_RXString(hf_afs_bos_content);
978                         break;
979                 case 98: /* set t status */
980                         OUT_RXString(hf_afs_bos_content);
981                         OUT_UINT(hf_afs_bos_status);
982                         break;
983                 case 99: /* shutdown all */
984                         /* no params */
985                         break;
986                 case 100: /* restart all */
987                         /* no params */
988                         break;
989                 case 101: /* startup all */
990                         /* no params */
991                         break;
992                 case 102: /* set no-auth flag */
993                         OUT_UINT(hf_afs_bos_flags);
994                         break;
995                 case 103: /* re-bozo? */
996                         /* no params */
997                         break;
998                 case 104: /* restart */
999                         OUT_RXString(hf_afs_bos_instance);
1000                         break;
1001                 case 105: /* install */
1002                         OUT_RXString(hf_afs_bos_path);
1003                         OUT_UINT(hf_afs_bos_size);
1004                         OUT_UINT(hf_afs_bos_flags);
1005                         OUT_UINT(hf_afs_bos_date);
1006                         break;
1007                 case 106: /* uninstall */
1008                         OUT_RXString(hf_afs_bos_path);
1009                         break;
1010                 case 107: /* get dates */
1011                         OUT_RXString(hf_afs_bos_path);
1012                         break;
1013                 case 108: /* exec */
1014                         OUT_RXString(hf_afs_bos_cmd);
1015                         break;
1016                 case 109: /* prune */
1017                         OUT_UINT(hf_afs_bos_flags);
1018                         break;
1019                 case 110: /* set restart time */
1020                         OUT_UINT(hf_afs_bos_num);
1021                         OUT_BOS_TIME();
1022                         break;
1023                 case 111: /* get restart time */
1024                         OUT_UINT(hf_afs_bos_num);
1025                         break;
1026                 case 112: /* get log */
1027                         OUT_RXString(hf_afs_bos_file);
1028                         break;
1029                 case 113: /* wait all */
1030                         /* no params */
1031                         break;
1032                 case 114: /* get instance strings */
1033                         OUT_RXString(hf_afs_bos_content);
1034                         break;
1035         }
1036 }
1037
1038 /*
1039  * VOL Helpers
1040  */
1041 static void
1042 dissect_vol_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1043 {
1044         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1045         {
1046                 switch ( opcode )
1047                 {
1048                         case 121:
1049                                 /* should loop here maybe */
1050                                 OUT_UINT(hf_afs_vol_count);
1051                                 OUT_RXStringV(hf_afs_vol_name, 32); /* not sure on  */
1052                                 break;
1053                 }
1054         }
1055         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1056         {
1057                 OUT_UINT(hf_afs_vol_errcode);
1058         }
1059 }
1060
1061 static void
1062 dissect_vol_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1063 {
1064         offset += 4;  /* skip the opcode */
1065
1066         switch ( opcode )
1067         {
1068                 case 121: /* list one vol */
1069                         OUT_UINT(hf_afs_vol_count);
1070                         OUT_UINT(hf_afs_vol_id);
1071                         break;
1072         }
1073 }
1074
1075 /*
1076  * KAUTH Helpers
1077  */
1078 static void
1079 dissect_kauth_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1080 {
1081         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1082         {
1083                 switch ( opcode )
1084                 {
1085                 }
1086         }
1087         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1088         {
1089                 OUT_UINT(hf_afs_kauth_errcode);
1090         }
1091 }
1092
1093 static void
1094 dissect_kauth_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1095 {
1096         offset += 4;  /* skip the opcode */
1097
1098         switch ( opcode )
1099         {
1100                 case 1: /* authenticate old */
1101                 case 21: /* authenticate */
1102                 case 22: /* authenticate v2 */
1103                 case 2: /* change pw */
1104                 case 5: /* set fields */
1105                 case 6: /* create user */
1106                 case 7: /* delete user */
1107                 case 8: /* get entry */
1108                 case 14: /* unlock */
1109                 case 15: /* lock status */
1110                         OUT_RXString(hf_afs_kauth_princ);
1111                         OUT_RXString(hf_afs_kauth_realm);
1112                         OUT_BYTES_ALL(hf_afs_kauth_data);
1113                         break;
1114                 case 3: /* getticket-old */
1115                 case 23: /* getticket */
1116                         OUT_UINT(hf_afs_kauth_kvno);
1117                         OUT_RXString(hf_afs_kauth_domain);
1118                         OUT_BYTES_ALL(hf_afs_kauth_data);
1119                         OUT_RXString(hf_afs_kauth_princ);
1120                         OUT_RXString(hf_afs_kauth_realm);
1121                         break;
1122                 case 4: /* set pass */
1123                         OUT_RXString(hf_afs_kauth_princ);
1124                         OUT_RXString(hf_afs_kauth_realm);
1125                         OUT_UINT(hf_afs_kauth_kvno);
1126                         break;
1127                 case 12: /* get pass */
1128                         OUT_RXString(hf_afs_kauth_name);
1129                         break;
1130         }
1131 }
1132
1133 /*
1134  * CB Helpers
1135  */
1136 static void
1137 dissect_cb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1138 {
1139         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1140         {
1141                 switch ( opcode )
1142                 {
1143                 }
1144         }
1145         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1146         {
1147                 OUT_UINT(hf_afs_cb_errcode);
1148         }
1149 }
1150
1151 static void
1152 dissect_cb_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1153 {
1154         offset += 4;  /* skip the opcode */
1155
1156         switch ( opcode )
1157         {
1158                 case 204: /* callback */
1159                 {
1160                         unsigned int i,j;
1161
1162                         j = tvb_get_ntohl(tvb, offset);
1163                         offset += 4;
1164
1165                         for (i=0; i<j; i++)
1166                         {
1167                                 OUT_CB_AFSFid("Target");
1168                         }
1169
1170                         j = tvb_get_ntohl(tvb, offset);
1171                         offset += 4;
1172                         for (i=0; i<j; i++)
1173                         {
1174                                 OUT_CB_AFSCallBack();
1175                         }
1176                 }
1177         }
1178 }
1179
1180 /*
1181  * PROT Helpers
1182  */
1183 static void
1184 dissect_prot_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1185 {
1186         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1187         {
1188                 switch ( opcode )
1189                 {
1190                         case 504: /* name to id */
1191                                 {
1192                                         unsigned int i, j;
1193
1194                                         j = tvb_get_ntohl(tvb, offset);
1195                                         OUT_UINT(hf_afs_prot_count);
1196
1197                                         for (i=0; i<j; i++)
1198                                         {
1199                                                 OUT_UINT(hf_afs_prot_id);
1200                                         }
1201                                 }
1202                                 break;
1203                         case 505: /* id to name */
1204                                 {
1205                                         unsigned int i, j;
1206
1207                                         j = tvb_get_ntohl(tvb, offset);
1208                                         OUT_UINT(hf_afs_prot_count);
1209
1210                                         for (i=0; i<j; i++)
1211                                         {
1212                                                 OUT_RXStringV(hf_afs_prot_name, PRNAMEMAX);
1213                                         }
1214                                 }
1215                                 break;
1216                         case 508: /* get cps */
1217                         case 514: /* list elements */
1218                         case 517: /* list owned */
1219                         case 518: /* get cps2 */
1220                         case 519: /* get host cps */
1221                                 {
1222                                         unsigned int i, j;
1223
1224                                         j = tvb_get_ntohl(tvb, offset);
1225                                         OUT_UINT(hf_afs_prot_count);
1226
1227                                         for (i=0; i<j; i++)
1228                                         {
1229                                                 OUT_UINT(hf_afs_prot_id);
1230                                         }
1231                                 }
1232                                 break;
1233                         case 510: /* list max */
1234                                 OUT_UINT(hf_afs_prot_maxuid);
1235                                 OUT_UINT(hf_afs_prot_maxgid);
1236                                 break;
1237                 }
1238         }
1239         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1240         {
1241                 OUT_UINT(hf_afs_prot_errcode);
1242         }
1243 }
1244
1245 static void
1246 dissect_prot_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1247 {
1248         offset += 4;  /* skip the opcode */
1249
1250         switch ( opcode )
1251         {
1252                 case 500: /* new user */
1253                         OUT_RXString(hf_afs_prot_name);
1254                         OUT_UINT(hf_afs_prot_id);
1255                         OUT_UINT(hf_afs_prot_oldid);
1256                         break;
1257                 case 501: /* where is it */
1258                 case 506: /* delete */
1259                 case 508: /* get cps */
1260                 case 512: /* list entry */
1261                 case 514: /* list elements */
1262                 case 517: /* list owned */
1263                 case 519: /* get host cps */
1264                         OUT_UINT(hf_afs_prot_id);
1265                         break;
1266                 case 502: /* dump entry */
1267                         OUT_UINT(hf_afs_prot_pos);
1268                         break;
1269                 case 503: /* add to group */
1270                 case 507: /* remove from group */
1271                 case 515: /* is a member of? */
1272                         OUT_UINT(hf_afs_prot_uid);
1273                         OUT_UINT(hf_afs_prot_gid);
1274                         break;
1275                 case 504: /* name to id */
1276                         {
1277                                 unsigned int i, j;
1278
1279                                 j = tvb_get_ntohl(tvb, offset);
1280                                 OUT_UINT(hf_afs_prot_count);
1281
1282                                 for (i=0; i<j; i++)
1283                                 {
1284                                         OUT_RXStringV(hf_afs_prot_name,PRNAMEMAX);
1285                                 }
1286                         }
1287                         break;
1288                 case 505: /* id to name */
1289                         {
1290                                 unsigned int i, j;
1291
1292                                 j = tvb_get_ntohl(tvb, offset);
1293                                 OUT_UINT(hf_afs_prot_count);
1294
1295                                 for (i=0; i<j; i++)
1296                                 {
1297                                         OUT_UINT(hf_afs_prot_id);
1298                                 }
1299                         }
1300                         break;
1301                 case 509: /* new entry */
1302                         OUT_RXString(hf_afs_prot_name);
1303                         OUT_UINT(hf_afs_prot_flag);
1304                         OUT_UINT(hf_afs_prot_oldid);
1305                         break;
1306                 case 511: /* set max */
1307                         OUT_UINT(hf_afs_prot_id);
1308                         OUT_UINT(hf_afs_prot_flag);
1309                         break;
1310                 case 513: /* change entry */
1311                         OUT_UINT(hf_afs_prot_id);
1312                         OUT_RXString(hf_afs_prot_name);
1313                         OUT_UINT(hf_afs_prot_oldid);
1314                         OUT_UINT(hf_afs_prot_newid);
1315                         break;
1316                 case 520: /* update entry */
1317                         OUT_UINT(hf_afs_prot_id);
1318                         OUT_RXString(hf_afs_prot_name);
1319                         break;
1320         }
1321 }
1322
1323 /*
1324  * VLDB Helpers
1325  */
1326 static void
1327 dissect_vldb_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1328 {
1329         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1330         {
1331                 switch ( opcode )
1332                 {
1333                         case 510: /* list entry */
1334                                 OUT_UINT(hf_afs_vldb_count);
1335                                 OUT_UINT(hf_afs_vldb_nextindex);
1336                                 break;
1337                         case 503: /* get entry by id */
1338                         case 504: /* get entry by name */
1339                                 {
1340                                         int nservers,i,j;
1341                                         OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1342                                         SKIP(4);
1343                                         nservers = tvb_get_ntohl(tvb, offset);
1344                                         OUT_UINT(hf_afs_vldb_numservers);
1345                                         for (i=0; i<8; i++)
1346                                         {
1347                                                 if ( i<nservers )
1348                                                 {
1349                                                         OUT_IP(hf_afs_vldb_server);
1350                                                 }
1351                                                 else
1352                                                 {
1353                                                         SKIP(4);
1354                                                 }
1355                                         }
1356                                         for (i=0; i<8; i++)
1357                                         {
1358                                                 char part[8];
1359                                                 j = tvb_get_ntohl(tvb, offset);
1360                                                 strcpy(part, "/vicepa");
1361                                                 if ( i<nservers && j<=25 )
1362                                                 {
1363                                                         part[6] = 'a' + (char) j;
1364                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1365                                                                 offset, 4, part);
1366                                                 }
1367                                                 SKIP(4);
1368                                         }
1369                                         SKIP(8 * sizeof(guint32));
1370                                         OUT_UINT(hf_afs_vldb_rwvol);
1371                                         OUT_UINT(hf_afs_vldb_rovol);
1372                                         OUT_UINT(hf_afs_vldb_bkvol);
1373                                         OUT_UINT(hf_afs_vldb_clonevol);
1374                                         OUT_VLDB_Flags();
1375                                 }
1376                                 break;
1377                         case 505: /* get new volume id */
1378                                 OUT_UINT(hf_afs_vldb_id);
1379                                 break;
1380                         case 521: /* list entry */
1381                         case 529: /* list entry U */
1382                                 OUT_UINT(hf_afs_vldb_count);
1383                                 OUT_UINT(hf_afs_vldb_nextindex);
1384                                 break;
1385                         case 518: /* get entry by id n */
1386                         case 519: /* get entry by name N */
1387                                 {
1388                                         int nservers,i,j;
1389                                         OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1390                                         nservers = tvb_get_ntohl(tvb, offset);
1391                                         OUT_UINT(hf_afs_vldb_numservers);
1392                                         for (i=0; i<13; i++)
1393                                         {
1394                                                 if ( i<nservers )
1395                                                 {
1396                                                         OUT_IP(hf_afs_vldb_server);
1397                                                 }
1398                                                 else
1399                                                 {
1400                                                         SKIP(4);
1401                                                 }
1402                                         }
1403                                         for (i=0; i<13; i++)
1404                                         {
1405                                                 char part[8];
1406                                                 j = tvb_get_ntohl(tvb, offset);
1407                                                 strcpy(part, "/vicepa");
1408                                                 if ( i<nservers && j<=25 )
1409                                                 {
1410                                                         part[6] = 'a' + (char) j;
1411                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1412                                                                 offset, 4, part);
1413                                                 }
1414                                                 SKIP(4);
1415                                         }
1416                                         SKIP(13 * sizeof(guint32));
1417                                         OUT_UINT(hf_afs_vldb_rwvol);
1418                                         OUT_UINT(hf_afs_vldb_rovol);
1419                                         OUT_UINT(hf_afs_vldb_bkvol);
1420                                 }
1421                                 break;
1422                         case 526: /* get entry by id u */
1423                         case 527: /* get entry by name u */
1424                                 {
1425                                         int nservers,i,j;
1426                                         OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1427                                         nservers = tvb_get_ntohl(tvb, offset);
1428                                         OUT_UINT(hf_afs_vldb_numservers);
1429                                         for (i=0; i<13; i++)
1430                                         {
1431                                                 if ( i<nservers )
1432                                                 {
1433                                                         OUT_UUID(hf_afs_vldb_serveruuid);
1434                                                 }
1435                                                 else
1436                                                 {
1437                                                         SKIP_UUID();
1438                                                 }
1439                                         }
1440                                         for (i=0; i<13; i++)
1441                                         {
1442                                                 if ( i<nservers )
1443                                                 {
1444                                                         OUT_UINT(hf_afs_vldb_serveruniq);
1445                                                 }
1446                                                 else
1447                                                 {
1448                                                         SKIP(sizeof(guint32));
1449                                                 }
1450                                         }
1451                                         for (i=0; i<13; i++)
1452                                         {
1453                                                 char part[8];
1454                                                 j = tvb_get_ntohl(tvb, offset);
1455                                                 strcpy(part, "/vicepa");
1456                                                 if ( i<nservers && j<=25 )
1457                                                 {
1458                                                         part[6] = 'a' + (char) j;
1459                                                         proto_tree_add_string(tree, hf_afs_vldb_partition, tvb,
1460                                                                 offset, 4, part);
1461                                                 }
1462                                                 SKIP(4);
1463                                         }
1464                                         for (i=0; i<13; i++)
1465                                         {
1466                                                 if ( i<nservers )
1467                                                 {
1468                                                         OUT_UINT(hf_afs_vldb_serverflags);
1469                                                 }
1470                                                 else
1471                                                 {
1472                                                         SKIP(sizeof(guint32));
1473                                                 }
1474                                         }
1475                                         OUT_UINT(hf_afs_vldb_rwvol);
1476                                         OUT_UINT(hf_afs_vldb_rovol);
1477                                         OUT_UINT(hf_afs_vldb_bkvol);
1478                                         OUT_UINT(hf_afs_vldb_clonevol);
1479                                         OUT_UINT(hf_afs_vldb_flags);
1480                                         OUT_UINT(hf_afs_vldb_spare1);
1481                                         OUT_UINT(hf_afs_vldb_spare2);
1482                                         OUT_UINT(hf_afs_vldb_spare3);
1483                                         OUT_UINT(hf_afs_vldb_spare4);
1484                                         OUT_UINT(hf_afs_vldb_spare5);
1485                                         OUT_UINT(hf_afs_vldb_spare6);
1486                                         OUT_UINT(hf_afs_vldb_spare7);
1487                                         OUT_UINT(hf_afs_vldb_spare8);
1488                                         OUT_UINT(hf_afs_vldb_spare9);
1489                                 }
1490                                 break;
1491                 }
1492         }
1493         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1494         {
1495                 OUT_UINT(hf_afs_vldb_errcode);
1496         }
1497 }
1498
1499 static void
1500 dissect_vldb_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1501 {
1502         offset += 4;  /* skip the opcode */
1503
1504         switch ( opcode )
1505         {
1506                 case 501: /* create new volume */
1507                 case 517: /* create entry N */
1508                         OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1509                         break;
1510                 case 502: /* delete entry */
1511                 case 503: /* get entry by id */
1512                 case 507: /* update entry */
1513                 case 508: /* set lock */
1514                 case 509: /* release lock */
1515                 case 518: /* get entry by id */
1516                         OUT_UINT(hf_afs_vldb_id);
1517                         OUT_UINT(hf_afs_vldb_type);
1518                         break;
1519                 case 504: /* get entry by name */
1520                 case 519: /* get entry by name N */
1521                 case 524: /* update entry by name */
1522                 case 527: /* get entry by name U */
1523                         OUT_RXString(hf_afs_vldb_name);
1524                         break;
1525                 case 505: /* get new vol id */
1526                         OUT_UINT(hf_afs_vldb_bump);
1527                         break;
1528                 case 506: /* replace entry */
1529                 case 520: /* replace entry N */
1530                         OUT_UINT(hf_afs_vldb_id);
1531                         OUT_UINT(hf_afs_vldb_type);
1532                         OUT_RXStringV(hf_afs_vldb_name, VLNAMEMAX);
1533                         break;
1534                 case 510: /* list entry */
1535                 case 521: /* list entry N */
1536                         OUT_UINT(hf_afs_vldb_index);
1537                         break;
1538                 case 532: /* regaddr */
1539                         OUT_UUID(hf_afs_vldb_serveruuid);
1540                         OUT_UINT(hf_afs_vldb_spare1);
1541                         OUT_VLDB_BulkAddr();
1542                         break;
1543         }
1544 }
1545
1546 /*
1547  * UBIK Helpers
1548  */
1549 static void
1550 dissect_ubik_reply(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1551 {
1552         switch ( opcode )
1553         {
1554                 case 10000: /* vote-beacon */
1555                         break;
1556                 case 10001: /* vote-debug-old */
1557                         OUT_UBIK_DebugOld();
1558                         break;
1559                 case 10002: /* vote-sdebug-old */
1560                         OUT_UBIK_SDebugOld();
1561                         break;
1562                 case 10003: /* vote-get syncsite */
1563                         break;
1564                 case 10004: /* vote-debug */
1565                         OUT_UBIK_DebugOld();
1566                         OUT_UBIK_InterfaceAddrs();
1567                         break;
1568                 case 10005: /* vote-sdebug */
1569                         OUT_UBIK_SDebugOld();
1570                         OUT_UBIK_InterfaceAddrs();
1571                         break;
1572                 case 10006: /* vote-xdebug */
1573                         OUT_UBIK_DebugOld();
1574                         OUT_UBIK_InterfaceAddrs();
1575                         OUT_UINT(hf_afs_ubik_isclone);
1576                         break;
1577                 case 10007: /* vote-xsdebug */
1578                         OUT_UBIK_SDebugOld();
1579                         OUT_UBIK_InterfaceAddrs();
1580                         OUT_UINT(hf_afs_ubik_isclone);
1581                         break;
1582                 case 20000: /* disk-begin */
1583                         break;
1584                 case 20004: /* get version */
1585                         OUT_UBIKVERSION("DB Version");
1586                         break;
1587                 case 20010: /* disk-probe */
1588                         break;
1589                 case 20012: /* disk-interfaceaddr */
1590                         OUT_UBIK_InterfaceAddrs();
1591                         break;
1592         }
1593 }
1594
1595 static void
1596 dissect_ubik_request(tvbuff_t *tvb, struct rxinfo *rxinfo _U_, proto_tree *tree, int offset, int opcode)
1597 {
1598         offset += 4;  /* skip the opcode */
1599
1600         switch ( opcode )
1601         {
1602                 case 10000: /* vote-beacon */
1603                         OUT_UINT(hf_afs_ubik_state);
1604                         OUT_DATE(hf_afs_ubik_votestart);
1605                         OUT_UBIKVERSION("DB Version");
1606                         OUT_UBIKVERSION("TID");
1607                         break;
1608                 case 10001: /* vote-debug-old */
1609                         break;
1610                 case 10002: /* vote-sdebug-old */
1611                         OUT_UINT(hf_afs_ubik_site);
1612                         break;
1613                 case 10003: /* vote-get sync site */
1614                         OUT_IP(hf_afs_ubik_site);
1615                         break;
1616                 case 10004: /* vote-debug */
1617                 case 10005: /* vote-sdebug */
1618                         OUT_IP(hf_afs_ubik_site);
1619                         break;
1620                 case 20000: /* disk-begin */
1621                         OUT_UBIKVERSION("TID");
1622                         break;
1623                 case 20001: /* disk-commit */
1624                         OUT_UBIKVERSION("TID");
1625                         break;
1626                 case 20002: /* disk-lock */
1627                         OUT_UBIKVERSION("TID");
1628                         OUT_UINT(hf_afs_ubik_file);
1629                         OUT_UINT(hf_afs_ubik_pos);
1630                         OUT_UINT(hf_afs_ubik_length);
1631                         OUT_UINT(hf_afs_ubik_locktype);
1632                         break;
1633                 case 20003: /* disk-write */
1634                         OUT_UBIKVERSION("TID");
1635                         OUT_UINT(hf_afs_ubik_file);
1636                         OUT_UINT(hf_afs_ubik_pos);
1637                         break;
1638                 case 20004: /* disk-get version */
1639                         break;
1640                 case 20005: /* disk-get file */
1641                         OUT_UINT(hf_afs_ubik_file);
1642                         break;
1643                 case 20006: /* disk-send file */
1644                         OUT_UINT(hf_afs_ubik_file);
1645                         OUT_UINT(hf_afs_ubik_length);
1646                         OUT_UBIKVERSION("DB Version");
1647                         break;
1648                 case 20007: /* disk-abort */
1649                 case 20008: /* disk-release locks */
1650                 case 20010: /* disk-probe */
1651                         break;
1652                 case 20009: /* disk-truncate */
1653                         OUT_UBIKVERSION("TID");
1654                         OUT_UINT(hf_afs_ubik_file);
1655                         OUT_UINT(hf_afs_ubik_length);
1656                         break;
1657                 case 20011: /* disk-writev */
1658                         OUT_UBIKVERSION("TID");
1659                         break;
1660                 case 20012: /* disk-interfaceaddr */
1661                         OUT_UBIK_InterfaceAddrs();
1662                         break;
1663                 case 20013: /* disk-set version */
1664                         OUT_UBIKVERSION("TID");
1665                         OUT_UBIKVERSION("Old DB Version");
1666                         OUT_UBIKVERSION("New DB Version");
1667                         break;
1668         }
1669 }
1670
1671 /*
1672  * BACKUP Helpers
1673  */
1674 static void
1675 dissect_backup_reply(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *tree, int offset, int opcode)
1676 {
1677         if ( rxinfo->type == RX_PACKET_TYPE_DATA )
1678         {
1679                 switch ( opcode )
1680                 {
1681                 }
1682         }
1683         else if ( rxinfo->type == RX_PACKET_TYPE_ABORT )
1684         {
1685                 OUT_UINT(hf_afs_backup_errcode);
1686         }
1687 }
1688
1689 static void
1690 dissect_backup_request(tvbuff_t *tvb _U_, struct rxinfo *rxinfo _U_, proto_tree *tree _U_, int offset, int opcode)
1691 {
1692         offset += 4;  /* skip the opcode */
1693
1694         switch ( opcode )
1695         {
1696         }
1697 }
1698
1699 /*
1700  * Registration code for registering the protocol and fields
1701  */
1702
1703 void
1704 proto_register_afs(void)
1705 {
1706         static hf_register_info hf[] = {
1707 #include "packet-afs-register-info.h"
1708         };
1709         static gint *ett[] = {
1710                 &ett_afs,
1711                 &ett_afs_op,
1712                 &ett_afs_acl,
1713                 &ett_afs_fid,
1714                 &ett_afs_callback,
1715                 &ett_afs_ubikver,
1716                 &ett_afs_status,
1717                 &ett_afs_status_mask,
1718                 &ett_afs_volsync,
1719                 &ett_afs_volumeinfo,
1720                 &ett_afs_vicestat,
1721                 &ett_afs_vldb_flags,
1722         };
1723
1724         proto_afs = proto_register_protocol("Andrew File System (AFS)",
1725             "AFS (RX)", "afs");
1726         proto_register_field_array(proto_afs, hf, array_length(hf));
1727         proto_register_subtree_array(ett, array_length(ett));
1728         register_init_routine(&afs_init_protocol);
1729
1730         register_dissector("afs", dissect_afs, proto_afs);
1731 }