Replace the protocol-specific data in the "packet_info" structure with a
[metze/wireshark/wip.git] / packet-rx.c
1 /* packet-rx.c
2  * Routines for RX 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  *
7  * $Id: packet-rx.c,v 1.24 2001/08/04 04:04:34 guy Exp $
8  *
9  * Ethereal - Network traffic analyzer
10  * By Gerald Combs <gerald@ethereal.com>
11  * Copyright 1998 Gerald Combs
12  *
13  * Copied from packet-tftp.c
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28  */
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <stdio.h>
35
36 #ifdef HAVE_SYS_TYPES_H
37 # include <sys/types.h>
38 #endif
39
40 #ifdef HAVE_NETINET_IN_H
41 # include <netinet/in.h>
42 #endif
43
44 #include <string.h>
45 #include <glib.h>
46 #include "packet.h"
47 #include "packet-rx.h"
48 #include "resolv.h"
49
50 #define UDP_PORT_RX_LOW         7000
51 #define UDP_PORT_RX_HIGH        7009
52 #define UDP_PORT_RX_AFS_BACKUPS 7021
53
54 static const value_string rx_types[] = {
55         { RX_PACKET_TYPE_DATA,          "data" },
56         { RX_PACKET_TYPE_ACK,           "ack" },
57         { RX_PACKET_TYPE_BUSY,          "busy" },
58         { RX_PACKET_TYPE_ABORT,         "abort" },
59         { RX_PACKET_TYPE_ACKALL,        "ackall" },
60         { RX_PACKET_TYPE_CHALLENGE,     "challenge" },
61         { RX_PACKET_TYPE_RESPONSE,      "response" },
62         { RX_PACKET_TYPE_DEBUG,         "debug" },
63         { RX_PACKET_TYPE_PARAMS,        "params" },
64         { RX_PACKET_TYPE_VERSION,       "version" },
65         { 0,                            NULL },
66 };
67
68 static const value_string rx_flags[] = {
69         { RX_CLIENT_INITIATED,  "client-init" },
70         { RX_REQUEST_ACK,       "req-ack" },
71         { RX_LAST_PACKET,       "last-pckt" },
72         { RX_MORE_PACKETS,      "more-pckts" },
73         { RX_FREE_PACKET,       "free-pckt" },
74         { 0,                    NULL }
75 };
76
77 static const value_string rx_reason[] = {
78         { RX_ACK_REQUESTED,             "Ack Requested"         },
79         { RX_ACK_DUPLICATE,             "Duplicate Packet"      },
80         { RX_ACK_OUT_OF_SEQUENCE,       "Out Of Sequence"       },
81         { RX_ACK_EXEEDS_WINDOW,         "Exceeds Window"        },      
82         { RX_ACK_NOSPACE,               "No Space"              },
83         { RX_ACK_PING,                  "Ping"                  },
84         { RX_ACK_PING_RESPONSE,         "Ping Response"         },
85         { RX_ACK_DELAY,                 "Delay"                 },
86         { 0,                            NULL                    }
87 };
88
89 static const value_string rx_ack_type[] = {
90         { RX_ACK_TYPE_NACK,     "NACK"  },
91         { RX_ACK_TYPE_ACK,      "ACK"   },
92         { 0,                    NULL    }
93 };
94
95 static int proto_rx = -1;
96 static int hf_rx_epoch = -1;
97 static int hf_rx_cid = -1;
98 static int hf_rx_seq = -1;
99 static int hf_rx_serial = -1;
100 static int hf_rx_callnumber = -1;
101 static int hf_rx_type = -1;
102 static int hf_rx_flags = -1;
103 static int hf_rx_flags_clientinit = -1;
104 static int hf_rx_flags_request_ack = -1;
105 static int hf_rx_flags_last_packet = -1;
106 static int hf_rx_flags_more_packets = -1;
107 static int hf_rx_flags_free_packet = -1;
108 static int hf_rx_userstatus = -1;
109 static int hf_rx_securityindex = -1;
110 static int hf_rx_spare = -1;
111 static int hf_rx_serviceid = -1;
112 static int hf_rx_bufferspace = -1;
113 static int hf_rx_maxskew = -1;
114 static int hf_rx_first_packet = -1;
115 static int hf_rx_prev_packet = -1;
116 static int hf_rx_reason = -1;
117 static int hf_rx_numacks = -1;
118 static int hf_rx_ack_type = -1;
119 static int hf_rx_ack = -1;
120 static int hf_rx_challenge = -1;
121 static int hf_rx_version = -1;
122 static int hf_rx_nonce = -1;
123 static int hf_rx_inc_nonce = -1;
124 static int hf_rx_min_level = -1;
125 static int hf_rx_level = -1;
126 static int hf_rx_response = -1;
127 static int hf_rx_encrypted = -1;
128 static int hf_rx_kvno = -1;
129 static int hf_rx_ticket_len = -1;
130 static int hf_rx_ticket = -1;
131 static int hf_rx_ifmtu = -1;
132 static int hf_rx_maxmtu = -1;
133 static int hf_rx_rwind = -1;
134 static int hf_rx_maxpackets = -1;
135
136 static gint ett_rx = -1;
137 static gint ett_rx_flags = -1;
138 static gint ett_rx_ack = -1;
139 static gint ett_rx_challenge = -1;
140 static gint ett_rx_response = -1;
141 static gint ett_rx_encrypted = -1;
142
143 static dissector_handle_t afs_handle;
144
145 static int
146 dissect_rx_response_encrypted(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset)
147 {
148         proto_tree *tree;
149         proto_item *item;
150         int old_offset=offset;
151         int i;
152         guint32 callnumber;
153
154         item = proto_tree_add_item(parent_tree, hf_rx_encrypted, tvb, offset, 0, FALSE);
155         tree = proto_item_add_subtree(item, ett_rx_encrypted);
156
157         /* epoch : 4 bytes */
158         {
159                 struct timeval tv;
160                 tv.tv_sec = tvb_get_ntohl(tvb, offset);
161                 tv.tv_usec = 0;
162                 
163                 proto_tree_add_time(tree, hf_rx_epoch, tvb,
164                         offset, 4, &tv);
165                 offset += 4;
166         }
167
168         /* cid : 4 bytes */
169         proto_tree_add_uint(tree, hf_rx_cid, tvb,
170                 offset, 4, tvb_get_ntohl(tvb, offset));
171         offset += 4;
172
173         /*FIXME dont know how to handle this checksum, skipping it */
174         offset += 4;
175
176         /* sequrityindex : 1 byte */
177         proto_tree_add_uint(tree, hf_rx_securityindex, tvb,
178                 offset, 1, tvb_get_guint8(tvb, offset));
179         offset += 4;
180
181         for (i=0; i<RX_MAXCALLS; i++) {
182                 /* callnumber : 4 bytes */
183                 callnumber = tvb_get_ntohl(tvb, offset);
184                 proto_tree_add_uint(tree, hf_rx_callnumber, tvb,
185                         offset, 4, callnumber);
186                 offset += 4;
187         }
188
189         /* inc nonce : 4 bytes */
190         proto_tree_add_uint(tree, hf_rx_inc_nonce, tvb,
191                 offset, 4, tvb_get_ntohl(tvb, offset));
192         offset += 4;
193
194         /* level : 4 bytes */
195         proto_tree_add_uint(tree, hf_rx_level, tvb,
196                 offset, 4, tvb_get_ntohl(tvb, offset));
197         offset += 4;
198         
199         proto_item_set_len(item, offset-old_offset);    
200         return offset;
201 }
202         
203
204 static int
205 dissect_rx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 seq, guint32 callnumber)
206 {
207         proto_tree *tree;
208         proto_item *item;
209         guint32 version, tl;
210         int old_offset=offset;
211
212         if (check_col(pinfo->fd, COL_INFO)) {
213                 col_add_fstr(pinfo->fd, COL_INFO,
214                         "RESPONSE  "
215                         "Seq: %lu  "
216                         "Call: %lu  "
217                         "Source Port: %s  "
218                         "Destination Port: %s  ",
219                         (unsigned long)seq,
220                         (unsigned long)callnumber,
221                         get_udp_port(pinfo->srcport),
222                         get_udp_port(pinfo->destport)
223                 );
224         }
225
226         item = proto_tree_add_item(parent_tree, hf_rx_response, tvb, offset, 0, FALSE);
227         tree = proto_item_add_subtree(item, ett_rx_response);
228
229         version = tvb_get_ntohl(tvb, offset);
230         proto_tree_add_uint(tree, hf_rx_version, tvb,
231                 offset, 4, version);
232         offset += 4;
233
234         if (version==2) {
235                 /* skip unused */
236                 offset += 4;
237
238                 /* encrypted : struct */
239                 offset = dissect_rx_response_encrypted(tvb, pinfo, tree, offset);
240
241                 /* kvno */
242                 proto_tree_add_uint(tree, hf_rx_kvno, tvb,
243                         offset, 4, tvb_get_ntohl(tvb, offset));
244                 offset += 4;
245                 
246                 /* ticket_len */
247                 tl = tvb_get_ntohl(tvb, offset);
248                 proto_tree_add_uint(tree, hf_rx_ticket_len, tvb,
249                         offset, 4, tl);
250                 offset += 4;
251         
252                 proto_tree_add_item(tree, hf_rx_ticket, tvb, offset, tl, FALSE);
253                 offset += tl;   
254         }
255
256         proto_item_set_len(item, offset-old_offset);    
257         return offset;
258 }
259
260 static int
261 dissect_rx_challenge(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 seq, guint32 callnumber)
262 {
263         proto_tree *tree;
264         proto_item *item;
265         guint32 version;
266         int old_offset=offset;
267
268         if (check_col(pinfo->fd, COL_INFO)) {
269                 col_add_fstr(pinfo->fd, COL_INFO,
270                         "CHALLENGE  "
271                         "Seq: %lu  "
272                         "Call: %lu  "
273                         "Source Port: %s  "
274                         "Destination Port: %s  ",
275                         (unsigned long)seq,
276                         (unsigned long)callnumber,
277                         get_udp_port(pinfo->srcport),
278                         get_udp_port(pinfo->destport)
279                 );
280         }
281
282         item = proto_tree_add_item(parent_tree, hf_rx_challenge, tvb, offset, 0, FALSE);
283         tree = proto_item_add_subtree(item, ett_rx_challenge);
284
285         version = tvb_get_ntohl(tvb, offset);
286         proto_tree_add_uint(tree, hf_rx_version, tvb,
287                 offset, 4, version);
288         offset += 4;
289
290         if (version==2) {
291                 proto_tree_add_uint(tree, hf_rx_nonce, tvb,
292                         offset, 4, tvb_get_ntohl(tvb, offset));
293                 offset += 4;
294
295                 proto_tree_add_uint(tree, hf_rx_min_level, tvb,
296                         offset, 4, tvb_get_ntohl(tvb, offset));
297                 offset += 4;
298         }
299
300         proto_item_set_len(item, offset-old_offset);    
301         return offset;
302 }
303
304 static int
305 dissect_rx_acks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, int offset, guint32 seq, guint32 callnumber)
306 {
307         proto_tree *tree;
308         proto_item *item;
309         guint8 num;
310         int old_offset = offset;
311
312         if (check_col(pinfo->fd, COL_INFO)) {
313                 col_add_fstr(pinfo->fd, COL_INFO,
314                         "ACK  "
315                         "Seq: %lu  "
316                         "Call: %lu  "
317                         "Source Port: %s  "
318                         "Destination Port: %s  ",
319                         (unsigned long)seq,
320                         (unsigned long)callnumber,
321                         get_udp_port(pinfo->srcport),
322                         get_udp_port(pinfo->destport)
323                 );
324         }
325
326         item = proto_tree_add_item(parent_tree, hf_rx_ack, tvb, offset, 0, FALSE);
327         tree = proto_item_add_subtree(item, ett_rx_ack);
328
329
330         /* bufferspace: 2 bytes*/
331         proto_tree_add_uint(tree, hf_rx_bufferspace, tvb,
332                 offset, 2, tvb_get_ntohs(tvb, offset));
333         offset += 2;
334         
335         /* maxskew: 2 bytes*/
336         proto_tree_add_uint(tree, hf_rx_maxskew, tvb,
337                 offset, 2, tvb_get_ntohs(tvb, offset));
338         offset += 2;
339         
340         /* first packet: 4 bytes*/
341         proto_tree_add_uint(tree, hf_rx_first_packet, tvb,
342                 offset, 4, tvb_get_ntohl(tvb, offset));
343         offset += 4;
344         
345         /* prev packet: 4 bytes*/
346         proto_tree_add_uint(tree, hf_rx_prev_packet, tvb,
347                 offset, 4, tvb_get_ntohl(tvb, offset));
348         offset += 4;
349
350         /* serial : 4 bytes */  
351         proto_tree_add_uint(tree, hf_rx_serial, tvb,
352                 offset, 4, tvb_get_ntohl(tvb, offset) );
353         offset += 4;
354
355         /* reason : 1 byte */
356         proto_tree_add_uint(tree, hf_rx_reason, tvb,
357                 offset, 1, tvb_get_guint8(tvb, offset) );
358         offset += 1;
359
360         /* nACKs */
361         num = tvb_get_guint8(tvb, offset);
362         proto_tree_add_uint(tree, hf_rx_numacks, tvb,
363                 offset, 1, tvb_get_guint8(tvb, offset) );
364         offset += 1;
365
366         while(num--){
367                 proto_tree_add_uint(tree, hf_rx_ack_type, tvb,
368                         offset, 1, tvb_get_guint8(tvb, offset) );
369                 offset += 1;
370         }
371
372         /* Some implementations adds some extra fields.
373          * As far as I can see, these first add 3 padding bytes and then
374          * up to 4 32-bit values. (0,3,4 have been witnessed)
375          *
376          * RX as a protocol seems to be completely nondefined and seems to lack
377          * any sort of documentation other than "read the source of any of the
378          * (compatible?) implementations.
379          */
380         if (tvb_length_remaining(tvb, offset)>3) {
381                 offset += 3;    /* guess. some implementations adds 3 bytes */
382
383                 if (tvb_length_remaining(tvb, offset) >= 4){
384                         proto_tree_add_uint(tree, hf_rx_ifmtu, tvb, offset, 4,
385                                 tvb_get_ntohl(tvb, offset));
386                         offset += 4;
387                 }
388                 if (tvb_length_remaining(tvb, offset) >= 4){
389                         proto_tree_add_uint(tree, hf_rx_maxmtu, tvb, offset, 4,
390                                 tvb_get_ntohl(tvb, offset));
391                         offset += 4;
392                 }
393                 if (tvb_length_remaining(tvb, offset) >= 4){
394                         proto_tree_add_uint(tree, hf_rx_rwind, tvb, offset, 4,
395                                 tvb_get_ntohl(tvb, offset));
396                         offset += 4;
397                 }
398                 if (tvb_length_remaining(tvb, offset) >= 4){
399                         proto_tree_add_uint(tree, hf_rx_maxpackets, tvb, offset, 4,
400                                 tvb_get_ntohl(tvb, offset));
401                         offset += 4;
402                 }
403         }
404
405         proto_item_set_len(item, offset-old_offset);    
406         return offset;
407 }
408
409
410 static int
411 dissect_rx_flags(tvbuff_t *tvb, struct rxinfo *rxinfo, proto_tree *parent_tree, int offset)
412 {
413         proto_tree *tree;
414         proto_item *item;
415         guint8 flags;
416
417         flags = tvb_get_guint8(tvb, offset);
418         rxinfo->flags = flags;
419
420         item = proto_tree_add_uint(parent_tree, hf_rx_flags, tvb,
421                 offset, 1, flags);
422         tree = proto_item_add_subtree(item, ett_rx_flags);
423
424         proto_tree_add_uint(tree, hf_rx_flags_free_packet, tvb,
425                 offset, 1, flags);
426         proto_tree_add_uint(tree, hf_rx_flags_more_packets, tvb,
427                 offset, 1, flags);
428         proto_tree_add_uint(tree, hf_rx_flags_last_packet, tvb,
429                 offset, 1, flags);
430         proto_tree_add_uint(tree, hf_rx_flags_request_ack, tvb,
431                 offset, 1, flags);
432         proto_tree_add_uint(tree, hf_rx_flags_clientinit, tvb,
433                 offset, 1, flags);
434
435         offset += 1;
436         return offset;
437 }
438
439 static void
440 dissect_rx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
441 {
442         proto_tree *tree;
443         proto_item *item;
444         int offset = 0;
445         struct rxinfo rxinfo;
446         guint8 type;
447         guint32 seq, callnumber;
448         guint16 serviceid;
449
450         if (check_col(pinfo->fd, COL_PROTOCOL))
451                 col_set_str(pinfo->fd, COL_PROTOCOL, "RX");
452         if (check_col(pinfo->fd, COL_INFO))
453                 col_clear(pinfo->fd, COL_INFO);
454
455         item = proto_tree_add_protocol_format(parent_tree, proto_rx, tvb, 
456                 offset, 28, "RX Protocol");
457         tree = proto_item_add_subtree(item, ett_rx);
458
459         /* epoch : 4 bytes */
460         {
461                 struct timeval tv;
462                 tv.tv_sec = tvb_get_ntohl(tvb, offset);
463                 tv.tv_usec = 0;
464                 
465                 proto_tree_add_time(tree, hf_rx_epoch, tvb,
466                         offset, 4, &tv);
467                 offset += 4;
468         }
469
470         /* cid : 4 bytes */
471         proto_tree_add_uint(tree, hf_rx_cid, tvb,
472                 offset, 4, tvb_get_ntohl(tvb, offset));
473         offset += 4;
474
475         /* callnumber : 4 bytes */
476         callnumber = tvb_get_ntohl(tvb, offset);
477         proto_tree_add_uint(tree, hf_rx_callnumber, tvb,
478                 offset, 4, callnumber);
479         offset += 4;
480         rxinfo.callnumber = callnumber;
481
482         /* seq : 4 bytes */
483         seq = tvb_get_ntohl(tvb, offset);
484         proto_tree_add_uint(tree, hf_rx_seq, tvb,
485                 offset, 4, seq);
486         offset += 4;
487         rxinfo.seq = seq;
488
489         /* serial : 4 bytes */
490         proto_tree_add_uint(tree, hf_rx_serial, tvb,
491                 offset, 4, tvb_get_ntohl(tvb, offset));
492         offset += 4;
493
494         /* type : 1 byte */
495         type = tvb_get_guint8(tvb, offset);
496         proto_tree_add_uint(tree, hf_rx_type, tvb,
497                 offset, 1, type);
498         offset += 1;
499         rxinfo.type = type;
500
501         /* flags : 1 byte */
502         offset = dissect_rx_flags(tvb, &rxinfo, tree, offset);
503
504         /* userstatus : 1 byte */
505         proto_tree_add_uint(tree, hf_rx_userstatus, tvb,
506                 offset, 1, tvb_get_guint8(tvb, offset));
507         offset += 1;
508
509         /* sequrityindex : 1 byte */
510         proto_tree_add_uint(tree, hf_rx_securityindex, tvb,
511                 offset, 1, tvb_get_guint8(tvb, offset));
512         offset += 1;
513
514         /* spare */
515         proto_tree_add_uint(tree, hf_rx_spare, tvb,
516                 offset, 2, tvb_get_ntohs(tvb, offset));
517         offset += 2;
518
519         /* service id : 2 bytes */
520         serviceid = tvb_get_ntohs(tvb, offset);
521         proto_tree_add_uint(tree, hf_rx_serviceid, tvb,
522                 offset, 2, serviceid);
523         offset += 2;
524         rxinfo.serviceid = serviceid;
525
526         switch (type) {
527         case RX_PACKET_TYPE_ACK:
528                 /*dissect_rx_acks(tvb, pinfo, parent_tree, offset, 
529                         cant create it in a parallell tree, then ett seasrch
530                         wont work */
531                 dissect_rx_acks(tvb, pinfo, tree, offset, 
532                         seq, callnumber);
533                 break;
534         case RX_PACKET_TYPE_ACKALL:
535                 /* does not contain any payload */
536                 if (check_col(pinfo->fd, COL_INFO)) {
537                         col_add_fstr(pinfo->fd, COL_INFO,
538                                 "ACKALL  "
539                                 "Seq: %lu  "
540                                 "Call: %lu  "
541                                 "Source Port: %s  "
542                                 "Destination Port: %s  ",
543                                 (unsigned long)seq,
544                                 (unsigned long)callnumber,
545                                 get_udp_port(pinfo->srcport),
546                                 get_udp_port(pinfo->destport)
547                         );
548                 }
549                 break;
550         case RX_PACKET_TYPE_CHALLENGE:
551                 dissect_rx_challenge(tvb, pinfo, tree, offset, seq, callnumber);
552                 break;
553         case RX_PACKET_TYPE_RESPONSE:
554                 dissect_rx_response(tvb, pinfo, tree, offset, seq, callnumber);
555                 break;
556         case RX_PACKET_TYPE_DATA: {
557                 tvbuff_t *next_tvb;
558                 pinfo->private = &rxinfo;
559                 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
560                 call_dissector(afs_handle, next_tvb, pinfo, parent_tree);
561                 };
562                 break;
563         }
564
565 }
566
567 void
568 proto_register_rx(void)
569 {
570         static hf_register_info hf[] = {
571                 { &hf_rx_epoch, {
572                         "Epoch", "rx.epoch", FT_ABSOLUTE_TIME, BASE_DEC,
573                         NULL, 0, "Epoch", HFILL }},
574
575                 { &hf_rx_cid, {
576                         "CID", "rx.cid", FT_UINT32, BASE_DEC,
577                         NULL, 0, "CID", HFILL }},
578
579                 { &hf_rx_callnumber, {
580                         "Call Number", "rx.callnumber", FT_UINT32, BASE_DEC,
581                         NULL, 0, "Call Number", HFILL }},
582
583                 { &hf_rx_seq, {
584                         "Sequence Number", "rx.seq", FT_UINT32, BASE_DEC,
585                         NULL, 0, "Sequence Number", HFILL }},
586
587                 { &hf_rx_serial, {
588                         "Serial", "rx.serial", FT_UINT32, BASE_DEC,
589                         NULL, 0, "Serial", HFILL }},
590
591                 { &hf_rx_type, {
592                         "Type", "rx.type", FT_UINT8, BASE_DEC,
593                         VALS(rx_types), 0, "Type", HFILL }},
594
595                 { &hf_rx_flags, {
596                         "Flags", "rx.flags", FT_UINT8, BASE_HEX,
597                         NULL, 0, "Flags", HFILL }},
598
599                 { &hf_rx_flags_clientinit, {
600                         "Client Initiated", "rx.flags.client_init", FT_UINT8, BASE_BIN,
601                         NULL, RX_CLIENT_INITIATED, "Client Initiated", HFILL }},
602
603                 { &hf_rx_flags_request_ack, {
604                         "Request Ack", "rx.flags.request_ack", FT_UINT8, BASE_BIN,
605                         NULL, RX_REQUEST_ACK, "Request Ack", HFILL }},
606
607                 { &hf_rx_flags_last_packet, {
608                         "Last Packet", "rx.flags.last_packet", FT_UINT8, BASE_BIN,
609                         NULL, RX_LAST_PACKET, "Last Packet", HFILL }},
610
611                 { &hf_rx_flags_more_packets, {
612                         "More Packets", "rx.flags.more_packets", FT_UINT8, BASE_BIN,
613                         NULL, RX_MORE_PACKETS, "More Packets", HFILL }},
614
615                 { &hf_rx_flags_free_packet, {
616                         "Free Packet", "rx.flags.free_packet", FT_UINT8, BASE_BIN,
617                         NULL, RX_FREE_PACKET, "Free Packet", HFILL }},
618
619                 { &hf_rx_userstatus, {
620                         "User Status", "rx.userstatus", FT_UINT32, BASE_DEC,
621                         NULL, 0, "User Status", HFILL }},
622
623                 { &hf_rx_securityindex, {
624                         "Security Index", "rx.securityindex", FT_UINT32, BASE_DEC,
625                         NULL, 0, "Security Index", HFILL }},
626
627                 { &hf_rx_spare, {
628                         "Spare/Checksum", "rx.spare", FT_UINT16, BASE_DEC,
629                         NULL, 0, "Spare/Checksum", HFILL }},
630
631                 { &hf_rx_serviceid, {
632                         "Service ID", "rx.serviceid", FT_UINT16, BASE_DEC,
633                         NULL, 0, "Service ID", HFILL }},
634
635                 { &hf_rx_bufferspace, {
636                         "Bufferspace", "rx.bufferspace", FT_UINT16, BASE_DEC,
637                         NULL, 0, "Number Of Packets Available", HFILL }},
638
639                 { &hf_rx_maxskew, {
640                         "Max Skew", "rx.maxskew", FT_UINT16, BASE_DEC,
641                         NULL, 0, "Max Skew", HFILL }},
642
643                 { &hf_rx_first_packet, {
644                         "First Packet", "rx.first", FT_UINT32, BASE_DEC,
645                         NULL, 0, "First Packet", HFILL }},
646
647                 { &hf_rx_prev_packet, {
648                         "Prev Packet", "rx.prev", FT_UINT32, BASE_DEC,
649                         NULL, 0, "Previous Packet", HFILL }},
650
651                 { &hf_rx_reason, {
652                         "Reason", "rx.reason", FT_UINT8, BASE_DEC,
653                         VALS(rx_reason), 0, "Reason For This ACK", HFILL }},
654
655                 { &hf_rx_numacks, {
656                         "Num ACKs", "rx.num_acks", FT_UINT8, BASE_DEC,
657                         NULL, 0, "Number Of ACKs", HFILL }},
658
659                 { &hf_rx_ack_type, {
660                         "ACK Type", "rx.ack_type", FT_UINT8, BASE_DEC,
661                         VALS(rx_ack_type), 0, "Type Of ACKs", HFILL }},
662
663                 { &hf_rx_ack, {
664                         "ACK Packet", "rx.ack", FT_NONE, BASE_NONE,
665                         NULL, 0, "ACK Packet", HFILL }},
666
667                 { &hf_rx_challenge, {
668                         "CHALLENGE Packet", "rx.challenge", FT_NONE, BASE_NONE,
669                         NULL, 0, "CHALLENGE Packet", HFILL }},
670
671                 { &hf_rx_version, {
672                         "Version", "rx.version", FT_UINT32, BASE_DEC,
673                         NULL, 0, "Version Of Challenge/Response", HFILL }},
674
675                 { &hf_rx_nonce, {
676                         "Nonce", "rx.nonce", FT_UINT32, BASE_HEX,
677                         NULL, 0, "Nonce", HFILL }},
678
679                 { &hf_rx_inc_nonce, {
680                         "Inc Nonce", "rx.inc_nonce", FT_UINT32, BASE_HEX,
681                         NULL, 0, "Incremented Nonce", HFILL }},
682
683                 { &hf_rx_min_level, {
684                         "Min Level", "rx.min_level", FT_UINT32, BASE_DEC,
685                         NULL, 0, "Min Level", HFILL }},
686
687                 { &hf_rx_level, {
688                         "Level", "rx.level", FT_UINT32, BASE_DEC,
689                         NULL, 0, "Level", HFILL }},
690
691                 { &hf_rx_response, {
692                         "RESPONSE Packet", "rx.response", FT_NONE, BASE_NONE,
693                         NULL, 0, "RESPONSE Packet", HFILL }},
694
695                 { &hf_rx_encrypted, {
696                         "Encrypted", "rx.encrypted", FT_NONE, BASE_NONE,
697                         NULL, 0, "Encrypted part of response packet", HFILL }},
698
699                 { &hf_rx_kvno, {
700                         "kvno", "rx.kvno", FT_UINT32, BASE_DEC,
701                         NULL, 0, "kvno", HFILL }},
702
703                 { &hf_rx_ticket_len, {
704                         "Ticket len", "rx.ticket_len", FT_UINT32, BASE_DEC,
705                         NULL, 0, "Ticket Length", HFILL }},
706
707                 { &hf_rx_ticket, {
708                         "ticket", "rx.ticket", FT_BYTES, BASE_HEX,
709                         NULL, 0, "Ticket", HFILL }},
710
711                 { &hf_rx_ifmtu, {
712                         "Interface MTU", "rx.if_mtu", FT_UINT32, BASE_DEC,
713                         NULL, 0, "Interface MTU", HFILL }},
714
715                 { &hf_rx_maxmtu, {
716                         "Max MTU", "rx.max_mtu", FT_UINT32, BASE_DEC,
717                         NULL, 0, "Max MTU", HFILL }},
718
719                 { &hf_rx_rwind, {
720                         "rwind", "rx.rwind", FT_UINT32, BASE_DEC,
721                         NULL, 0, "rwind", HFILL }},
722
723                 { &hf_rx_maxpackets, {
724                         "Max Packets", "rx.max_packets", FT_UINT32, BASE_DEC,
725                         NULL, 0, "Max Packets", HFILL }},
726
727         };
728         static gint *ett[] = {
729                 &ett_rx,
730                 &ett_rx_flags,
731                 &ett_rx_ack,
732                 &ett_rx_challenge,
733                 &ett_rx_response,
734                 &ett_rx_encrypted,
735         };
736
737         proto_rx = proto_register_protocol("RX Protocol", "RX", "rx");
738         proto_register_field_array(proto_rx, hf, array_length(hf));
739         proto_register_subtree_array(ett, array_length(ett));
740 }
741
742 void
743 proto_reg_handoff_rx(void)
744 {
745         int port;
746
747         /*
748          * Get handle for the AFS dissector.
749          */
750         afs_handle = find_dissector("afs");
751
752         /* Ports in the range UDP_PORT_RX_LOW to UDP_PORT_RX_HIGH
753            are all used for various AFS services. */
754         for (port = UDP_PORT_RX_LOW; port <= UDP_PORT_RX_HIGH; port++)
755                 dissector_add("udp.port", port, dissect_rx, proto_rx);
756         dissector_add("udp.port", UDP_PORT_RX_AFS_BACKUPS, dissect_rx,
757             proto_rx);
758 }