Added support for HPUX11 NETTL captures for the NS_LS_DRIVER type.
[obnox/wireshark/wip.git] / packet-asap.c
1 /* packet-asap.c
2  * Routines for Aggregate Server Access Protocol
3  * It is hopefully (needs testing) compilant to
4  * http://www.ietf.org/internet-drafts/draft-ietf-rserpool-asap-02.txt
5  *
6  * Copyright 2002, Michael Tuexen <Michael.Tuexen@icn.siemens.de>
7  *
8  * $Id: packet-asap.c,v 1.3 2002/05/02 07:49:43 guy Exp $
9  *
10  * Ethereal - Network traffic analyzer
11  * By Gerald Combs <gerald@ethereal.com>
12  * Copyright 1998 Gerald Combs
13  *
14  * Copied from README.developer
15  * 
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  * 
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * 
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29  */
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <epan/packet.h>
36
37 #define ASAP_PAYLOAD_PROTO_ID 0xFAEEB5D1
38
39 /* Initialize the protocol and registered fields */
40 static int proto_asap = -1;
41 static int hf_asap_message_type = -1;
42 static int hf_asap_message_flags = -1;
43 static int hf_asap_message_length = -1;
44 #ifdef ASAP_UNUSED_HANDLES
45 static int hf_asap_message_value = -1;
46 #endif
47 static int hf_asap_parameter_type = -1;
48 static int hf_asap_parameter_length = -1;
49 static int hf_asap_parameter_value = -1;
50 static int hf_asap_parameter_padding = -1;
51 static int hf_asap_parameter_ipv4_address = -1;
52 static int hf_asap_parameter_ipv6_address = -1;
53 static int hf_asap_parameter_port = -1;
54 static int hf_asap_parameter_number_of_addr = -1;
55 static int hf_asap_parameter_load_policy = -1;
56 static int hf_asap_parameter_load_value = -1;
57 static int hf_asap_parameter_reg_life = -1;
58 static int hf_asap_parameter_pool_handle = -1;
59 static int hf_asap_parameter_signature = -1;
60 static int hf_asap_parameter_action_code = -1;
61 static int hf_asap_parameter_result_code = -1;
62 static int hf_asap_parameter_reserved = -1;
63
64 /* Initialize the subtree pointers */
65 static gint ett_asap = -1;
66 static gint ett_asap_parameter = -1;
67
68 static void
69 dissect_all_asap_parameters(tvbuff_t *, proto_tree *);
70
71 static gint
72 dissect_next_asap_parameters(guint, gint, tvbuff_t *, proto_tree *);
73
74 static guint 
75 nr_of_padding_bytes (guint length)
76 {
77   guint remainder;
78
79   remainder = length % 4;
80
81   if (remainder == 0)
82     return 0;
83   else
84     return 4 - remainder;
85 }
86
87 #define PARAMETER_TYPE_LENGTH   2
88 #define PARAMETER_LENGTH_LENGTH 2
89 #define PARAMETER_HEADER_LENGTH (PARAMETER_TYPE_LENGTH + PARAMETER_LENGTH_LENGTH)
90
91 #define PARAMETER_HEADER_OFFSET 0
92 #define PARAMETER_TYPE_OFFSET   PARAMETER_HEADER_OFFSET
93 #define PARAMETER_LENGTH_OFFSET (PARAMETER_TYPE_OFFSET + PARAMETER_TYPE_LENGTH)
94 #define PARAMETER_VALUE_OFFSET  (PARAMETER_LENGTH_OFFSET + PARAMETER_LENGTH_LENGTH)
95
96 #define IPV4_ADDRESS_LENGTH 4
97 #define IPV4_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
98
99 static void
100 dissect_ipv4_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
101 {
102   guint32 ipv4_address;
103
104   tvb_memcpy(parameter_tvb, (guint8 *)&ipv4_address, IPV4_ADDRESS_OFFSET, IPV4_ADDRESS_LENGTH); 
105   proto_tree_add_ipv4(parameter_tree, hf_asap_parameter_ipv4_address, parameter_tvb, IPV4_ADDRESS_OFFSET, IPV4_ADDRESS_LENGTH, ipv4_address);  
106   proto_item_set_text(parameter_item, "IPV4 address parameter");
107 }
108
109 #define IPV6_ADDRESS_LENGTH 16
110 #define IPV6_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
111
112 static void
113 dissect_ipv6_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
114 {
115   proto_tree_add_ipv6(parameter_tree, hf_asap_parameter_ipv6_address, parameter_tvb, IPV6_ADDRESS_OFFSET, IPV6_ADDRESS_LENGTH,
116                               tvb_get_ptr(parameter_tvb, IPV6_ADDRESS_OFFSET, IPV6_ADDRESS_LENGTH));
117   
118   proto_item_set_text(parameter_item, "IPV6 address parameter");
119 }
120
121 #define PORT_LENGTH                2
122 #define NUMBER_OF_ADDRESSES_LENGTH 2
123 #define LOAD_POLICY_LENGTH         2
124 #define LOAD_VALUE_LENGTH          2
125 #define REGISTRATION_LIFE_LENGTH   4
126
127 #define PORT_OFFSET                PARAMETER_VALUE_OFFSET
128 #define NUMBER_OF_ADDRESSES_OFFSET (PORT_OFFSET + PORT_LENGTH)
129 #define ADDRESS_LIST_OFFSET        (NUMBER_OF_ADDRESSES_OFFSET + NUMBER_OF_ADDRESSES_LENGTH)
130 #define LOAD_POLICY_OFFSET         0
131 #define LOAD_VALUE_OFFSET          (LOAD_POLICY_OFFSET + LOAD_POLICY_LENGTH)
132 #define REGISTRATION_LIFE_OFFSET   (LOAD_VALUE_OFFSET + LOAD_VALUE_LENGTH)
133
134 static void
135 dissect_pool_element_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
136 {
137   guint16 port, number_of_addresses, load_policy, load_value;
138   guint32 reg_life;
139   gint offset;
140   
141   port                = tvb_get_ntohs(parameter_tvb, PORT_OFFSET);
142   number_of_addresses = tvb_get_ntohs(parameter_tvb, NUMBER_OF_ADDRESSES_OFFSET);
143   proto_tree_add_uint(parameter_tree, hf_asap_parameter_port, parameter_tvb, PORT_OFFSET, PORT_LENGTH, port);
144   proto_tree_add_uint(parameter_tree, hf_asap_parameter_number_of_addr, parameter_tvb, NUMBER_OF_ADDRESSES_OFFSET, NUMBER_OF_ADDRESSES_LENGTH, number_of_addresses);
145
146   offset              = dissect_next_asap_parameters(number_of_addresses, ADDRESS_LIST_OFFSET, parameter_tvb, parameter_tree);  
147   load_policy         = tvb_get_ntohs(parameter_tvb, offset + LOAD_POLICY_OFFSET);
148   load_value          = tvb_get_ntohs(parameter_tvb, offset + LOAD_VALUE_OFFSET);
149   reg_life            = tvb_get_ntohs(parameter_tvb, offset + REGISTRATION_LIFE_OFFSET);
150   
151   proto_tree_add_uint(parameter_tree, hf_asap_parameter_load_policy, parameter_tvb, offset + LOAD_POLICY_OFFSET, LOAD_POLICY_LENGTH, load_policy);
152   proto_tree_add_uint(parameter_tree, hf_asap_parameter_load_value, parameter_tvb, offset + LOAD_VALUE_OFFSET, LOAD_VALUE_LENGTH, load_value);
153   proto_tree_add_uint(parameter_tree, hf_asap_parameter_reg_life, parameter_tvb, offset + REGISTRATION_LIFE_OFFSET, REGISTRATION_LIFE_LENGTH, reg_life);
154   proto_item_set_text(parameter_item, "Pool element");
155
156 }
157
158 #define POOL_HANDLE_OFFSET PARAMETER_VALUE_OFFSET
159
160 static void
161 dissect_pool_handle_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
162 {
163   guint16 length, handle_length;
164   char *handle;
165
166   length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
167   
168   handle_length = length - PARAMETER_HEADER_LENGTH;
169   handle        = (char *)tvb_get_ptr(parameter_tvb, POOL_HANDLE_OFFSET, handle_length);
170   proto_tree_add_string(parameter_tree, hf_asap_parameter_pool_handle, parameter_tvb, POOL_HANDLE_OFFSET, handle_length, handle);
171   proto_item_set_text(parameter_item, "Pool handle (%.*s)", handle_length, handle);
172 }
173
174 #define SIGNATURE_OFFSET PARAMETER_VALUE_OFFSET
175
176 static void
177 dissect_authorization_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
178 {
179   guint16 length, signature_length;
180   
181   length           = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
182   signature_length = length - PARAMETER_HEADER_LENGTH;
183
184   if (signature_length > 0) 
185     proto_tree_add_bytes(parameter_tree, hf_asap_parameter_signature, parameter_tvb, SIGNATURE_OFFSET, signature_length,
186                          tvb_get_ptr(parameter_tvb, SIGNATURE_OFFSET, signature_length));
187
188   proto_item_set_text(parameter_item, "Authorization signature (%u byte%s)", signature_length, plurality(signature_length, "", "s"));
189 }
190
191 static void
192 dissect_unknown_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
193 {
194   guint16 type, length, parameter_value_length;
195   
196   type   = tvb_get_ntohs(parameter_tvb, PARAMETER_TYPE_OFFSET);
197   length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
198   
199   parameter_value_length = length - PARAMETER_HEADER_LENGTH;
200
201   if (parameter_value_length > 0)
202     proto_tree_add_bytes(parameter_tree, hf_asap_parameter_value, parameter_tvb, PARAMETER_VALUE_OFFSET, parameter_value_length, 
203                          tvb_get_ptr(parameter_tvb, PARAMETER_VALUE_OFFSET, parameter_value_length));
204
205   proto_item_set_text(parameter_item, "Parameter with type %u and %u byte%s value", type, parameter_value_length, plurality(parameter_value_length, "", "s"));
206 }
207
208 #define IPV4_ADDRESS_PARAMETER_TYPE  0x01
209 #define IPV6_ADDRESS_PARAMETER_TYPE  0x02
210 #define POOL_ELEMENT_PARAMETER_TYPE  0x03
211 #define POOL_HANDLE_PARAMETER_TYPE   0x04
212 #define AUTHORIZATION_PARAMETER_TYPE 0x05
213
214 static const value_string asap_parameter_type_values[] = {
215   { IPV4_ADDRESS_PARAMETER_TYPE,  "IPV4 address" },
216   { IPV6_ADDRESS_PARAMETER_TYPE,  "IPV6 address" },
217   { POOL_ELEMENT_PARAMETER_TYPE,  "Pool element" },
218   { POOL_HANDLE_PARAMETER_TYPE,   "Pool handle" },
219   { AUTHORIZATION_PARAMETER_TYPE, "Authorization parameter" },
220   { 0,                            NULL } };
221
222
223 static void
224 dissect_asap_parameter(tvbuff_t *parameter_tvb, proto_tree *asap_tree)
225 {
226   guint16 type, length, padding_length, total_length;
227   proto_item *parameter_item;
228   proto_tree *parameter_tree;
229
230   /* extract tag and length from the parameter */
231   type           = tvb_get_ntohs(parameter_tvb, PARAMETER_TYPE_OFFSET);
232   length         = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
233
234   /* calculate padding and total length */
235   padding_length = tvb_length(parameter_tvb) - length;
236   total_length   = length + padding_length;
237
238   /* create proto_tree stuff */
239   parameter_item   = proto_tree_add_text(asap_tree, parameter_tvb, PARAMETER_HEADER_OFFSET, total_length, "Incomplete parameter");
240   parameter_tree   = proto_item_add_subtree(parameter_item, ett_asap_parameter);
241
242   /* add tag and length to the asap tree */
243   proto_tree_add_uint(parameter_tree, hf_asap_parameter_type, parameter_tvb, PARAMETER_TYPE_OFFSET, PARAMETER_TYPE_LENGTH, type);
244   proto_tree_add_uint(parameter_tree, hf_asap_parameter_length, parameter_tvb, PARAMETER_LENGTH_OFFSET, PARAMETER_LENGTH_LENGTH, length);
245
246   switch(type) {
247   case IPV4_ADDRESS_PARAMETER_TYPE:
248     dissect_ipv4_parameter(parameter_tvb, parameter_tree, parameter_item);
249     break;
250   case IPV6_ADDRESS_PARAMETER_TYPE:
251     dissect_ipv6_parameter(parameter_tvb, parameter_tree, parameter_item);
252     break;
253   case POOL_ELEMENT_PARAMETER_TYPE:
254     dissect_pool_element_parameter(parameter_tvb, parameter_tree, parameter_item);
255     break;
256   case POOL_HANDLE_PARAMETER_TYPE:
257     dissect_pool_handle_parameter(parameter_tvb, parameter_tree, parameter_item);
258     break;
259   case AUTHORIZATION_PARAMETER_TYPE:
260     dissect_authorization_parameter(parameter_tvb, parameter_tree, parameter_item);
261     break;
262   default:
263     dissect_unknown_parameter(parameter_tvb, parameter_tree, parameter_item);
264     break;
265   };
266
267   if (padding_length > 0)
268     proto_tree_add_bytes(parameter_tree, hf_asap_parameter_padding, parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length, 
269                          tvb_get_ptr(parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length));
270 }
271
272
273 static gint
274 dissect_next_asap_parameters(guint number_of_parameters, gint initial_offset, tvbuff_t *parameters_tvb, proto_tree *asap_tree)
275 {
276   gint offset, length, padding_length, total_length;
277   tvbuff_t *parameter_tvb;
278   guint parameter_number;
279
280   offset = initial_offset;
281   for(parameter_number=1; parameter_number <= number_of_parameters; parameter_number++) {
282     length         = tvb_get_ntohs(parameters_tvb, offset + PARAMETER_LENGTH_OFFSET);
283     padding_length = nr_of_padding_bytes(length);
284     total_length   = length + padding_length;
285     /* create a tvb for the parameter including the padding bytes */
286     parameter_tvb    = tvb_new_subset(parameters_tvb, offset, total_length, total_length);
287     dissect_asap_parameter(parameter_tvb, asap_tree); 
288     /* get rid of the handled parameter */
289     offset += total_length;
290   }
291   return(offset);
292 }
293
294 static void
295 dissect_all_asap_parameters(tvbuff_t *parameters_tvb, proto_tree *asap_tree)
296 {
297   gint offset, length, padding_length, total_length, remaining_length;
298   tvbuff_t *parameter_tvb;
299
300   offset = 0;
301   while((remaining_length = tvb_reported_length_remaining(parameters_tvb, offset))) {
302     length         = tvb_get_ntohs(parameters_tvb, offset + PARAMETER_LENGTH_OFFSET);
303     padding_length = nr_of_padding_bytes(length);
304     if (remaining_length >= length)
305       total_length = MIN(length + padding_length, remaining_length);
306     else
307       total_length = length + padding_length;
308     /* create a tvb for the parameter including the padding bytes */
309     parameter_tvb    = tvb_new_subset(parameters_tvb, offset, total_length, total_length);
310     dissect_asap_parameter(parameter_tvb, asap_tree); 
311     /* get rid of the handled parameter */
312     offset += total_length;
313   }
314 }
315
316 #define ACTION_CODE_LENGTH 1
317 #define RESULT_CODE_LENGTH 1
318 #define RESERVED_LENGTH    2
319
320 #define ACTION_CODE_OFFSET 0
321 #define RESULT_CODE_OFFSET (ACTION_CODE_OFFSET + ACTION_CODE_LENGTH)
322 #define RESERVED_OFFSET    (RESULT_CODE_OFFSET + RESULT_CODE_LENGTH)
323
324 static void
325 dissect_registration_response_message(tvbuff_t *parameters_tvb, proto_tree *asap_tree)
326 {
327   gint offset;
328   guint8 action_code, result_code;
329   guint16 reserved;
330   tvbuff_t *last_parameter_tvb;
331
332   offset      = dissect_next_asap_parameters(2, 0, parameters_tvb, asap_tree);
333   action_code = tvb_get_guint8(parameters_tvb, offset + ACTION_CODE_OFFSET);
334   result_code = tvb_get_guint8(parameters_tvb, offset + RESULT_CODE_OFFSET);
335   reserved    = tvb_get_ntohs(parameters_tvb, offset + RESERVED_OFFSET);
336   proto_tree_add_uint(asap_tree, hf_asap_parameter_action_code, parameters_tvb, offset + ACTION_CODE_OFFSET, ACTION_CODE_LENGTH, action_code);
337   proto_tree_add_uint(asap_tree, hf_asap_parameter_result_code, parameters_tvb, offset + RESULT_CODE_OFFSET, RESULT_CODE_LENGTH, result_code);
338   proto_tree_add_uint(asap_tree, hf_asap_parameter_reserved, parameters_tvb, offset + RESERVED_OFFSET, RESERVED_LENGTH, reserved);
339
340   last_parameter_tvb = tvb_new_subset(parameters_tvb, offset + 4 , -1, -1);
341   dissect_all_asap_parameters(last_parameter_tvb, asap_tree);
342 }
343
344 #define MESSAGE_TYPE_LENGTH   1
345 #define MESSAGE_FLAGS_LENGTH  1
346 #define MESSAGE_LENGTH_LENGTH 2
347
348 #define MESSAGE_TYPE_OFFSET   0
349 #define MESSAGE_FLAGS_OFFSET  (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH)
350 #define MESSAGE_LENGTH_OFFSET (MESSAGE_FLAGS_OFFSET + MESSAGE_FLAGS_LENGTH)
351 #define MESSAGE_VALUE_OFFSET  (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH)
352
353 #define REGISTRATION_MESSAGE_TYPE             0x01
354 #define DEREGISTRATION_MESSAGE_TYPE           0x02
355 #define REGISTRATION_RESPONSE_MESSAGE_TYPE    0x03
356 #define NAME_RESOLUTION_MESSAGE_TYPE          0x04
357 #define NAME_RESOLUTION_RESPONSE_MESSAGE_TYPE 0x05
358 #define NAME_UNKNOWN_MESSAGE_TYPE             0x06
359 #define ENDPOINT_KEEP_ALIVE_MESSAGE_TYPE      0x08
360 #define ENDPOINT_UNREACHABLE_MESSAGE_TYPE     0x09
361 #define SERVER_HUNT_MESSAGE_TYPE              0x0a
362 #define SERVER_HUNT_RESPONSE_MESSAGE_TYPE     0x0b
363
364 static const value_string asap_message_type_values[] = {
365   { REGISTRATION_MESSAGE_TYPE,             "Registration" },
366   { DEREGISTRATION_MESSAGE_TYPE,           "Deregistration" },
367   { REGISTRATION_RESPONSE_MESSAGE_TYPE,    "Registration response" },
368   { NAME_RESOLUTION_MESSAGE_TYPE,          "Name resolution" },
369   { NAME_RESOLUTION_RESPONSE_MESSAGE_TYPE, "Name resolution response" },
370   { NAME_UNKNOWN_MESSAGE_TYPE,             "Name unknown" },
371   { ENDPOINT_KEEP_ALIVE_MESSAGE_TYPE,      "Endpoint keep alive" },
372   { ENDPOINT_UNREACHABLE_MESSAGE_TYPE,     "Endpoint unreachable" },
373   { SERVER_HUNT_MESSAGE_TYPE,              "Server hunt" },
374   { SERVER_HUNT_RESPONSE_MESSAGE_TYPE,     "Server hunt response" },
375   { 0,                           NULL } };
376
377 static void
378 dissect_asap_message(tvbuff_t *message_tvb, proto_tree *asap_tree)
379 {
380   tvbuff_t *parameters_tvb;
381   guint8  type, flags;
382   guint16 length;
383   
384   type   = tvb_get_guint8(message_tvb, MESSAGE_TYPE_OFFSET);
385   flags  = tvb_get_guint8(message_tvb, MESSAGE_FLAGS_OFFSET);
386   length = tvb_get_ntohs (message_tvb, MESSAGE_LENGTH_OFFSET);
387
388   if (asap_tree) {
389     proto_tree_add_uint(asap_tree, hf_asap_message_type,   message_tvb, MESSAGE_TYPE_OFFSET,   MESSAGE_TYPE_LENGTH,   type);
390     proto_tree_add_uint(asap_tree, hf_asap_message_flags,  message_tvb, MESSAGE_FLAGS_OFFSET,  MESSAGE_FLAGS_LENGTH,  flags);
391     proto_tree_add_uint(asap_tree, hf_asap_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, length);
392   }
393   
394   parameters_tvb    = tvb_new_subset(message_tvb, MESSAGE_VALUE_OFFSET, -1, -1);
395   switch(type) {
396   case REGISTRATION_RESPONSE_MESSAGE_TYPE:
397     dissect_registration_response_message(parameters_tvb, asap_tree);
398         break;
399   default:
400     dissect_all_asap_parameters(parameters_tvb, asap_tree);
401     break;
402   }
403         
404 }
405
406 static void
407 dissect_asap(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree)
408 {
409   proto_item *asap_item;
410   proto_tree *asap_tree;
411
412   /* make entry in the Protocol column on summary display */
413   if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
414     col_set_str(pinfo->cinfo, COL_PROTOCOL, "ASAP");
415   
416   /* In the interest of speed, if "tree" is NULL, don't do any work not
417      necessary to generate protocol tree items. */
418   if (tree) {
419     /* create the asap protocol tree */
420     asap_item = proto_tree_add_item(tree, proto_asap, message_tvb, 0, -1, FALSE);
421     asap_tree = proto_item_add_subtree(asap_item, ett_asap);
422   } else {
423     asap_tree = NULL;
424   };
425   /* dissect the message */
426   dissect_asap_message(message_tvb, asap_tree);
427 }
428
429 /* Register the protocol with Ethereal */
430 void
431 proto_register_asap(void)
432 {                 
433
434   /* Setup list of header fields */
435   static hf_register_info hf[] = {
436     { &hf_asap_message_type,
437       { "Type", "asap.message_type",
438             FT_UINT8, BASE_DEC, VALS(asap_message_type_values), 0x0,          
439         "", HFILL }
440     },
441     { &hf_asap_message_flags,
442       { "Flags", "asap.message_flags",
443             FT_UINT8, BASE_HEX, NULL, 0x0,          
444             "", HFILL }
445     }, 
446     { &hf_asap_message_length,
447       { "Length", "asap.message_length",
448         FT_UINT16, BASE_DEC, NULL, 0x0,          
449             "", HFILL }
450     },
451     { &hf_asap_parameter_type,
452       { "Parameter Type", "asap.parameter_type",
453             FT_UINT16, BASE_HEX, VALS(asap_parameter_type_values), 0x0,          
454             "", HFILL }
455     },
456     { &hf_asap_parameter_length,
457       { "Parameter length", "asap.message_length",
458         FT_UINT16, BASE_DEC, NULL, 0x0,          
459             "", HFILL }
460     }, 
461     { &hf_asap_parameter_value,
462       { "Parameter value", "asap.parameter_value",
463             FT_BYTES, BASE_NONE, NULL, 0x0,          
464             "", HFILL }
465     },    
466     { &hf_asap_parameter_padding,
467       { "Padding", "asap.parameter_padding",
468             FT_BYTES, BASE_NONE, NULL, 0x0,          
469             "", HFILL }
470     },    
471     {&hf_asap_parameter_ipv4_address,
472      { "IP Version 4 address", "asap.ipv4_address",
473        FT_IPv4, BASE_NONE, NULL, 0x0,
474        "", HFILL }
475     },
476     {&hf_asap_parameter_ipv6_address,
477      { "IP Version 6 address", "asap.ipv6_address",
478        FT_IPv6, BASE_NONE, NULL, 0x0,
479        "", HFILL }
480     },
481     { &hf_asap_parameter_port,
482       { "SCTP port", "asap.message_port",
483         FT_UINT16, BASE_DEC, NULL, 0x0,          
484             "", HFILL }
485     }, 
486     { &hf_asap_parameter_number_of_addr,
487       { "Number of IP addresses", "asap.message_number_of_addresses",
488         FT_UINT16, BASE_DEC, NULL, 0x0,          
489             "", HFILL }
490     }, 
491     { &hf_asap_parameter_load_policy,
492       { "Load policy", "asap.message_load_policy",
493         FT_UINT16, BASE_DEC, NULL, 0x0,          
494             "", HFILL }
495     }, 
496     { &hf_asap_parameter_load_value,
497       { "Load value", "asap.message_load_value",
498         FT_UINT16, BASE_DEC, NULL, 0x0,          
499             "", HFILL }
500     }, 
501     { &hf_asap_parameter_reg_life,
502       { "Registration life", "asap.message_registration_life",
503         FT_UINT32, BASE_DEC, NULL, 0x0,          
504             "", HFILL }
505     }, 
506     { &hf_asap_parameter_pool_handle,
507       { "Pool handle", "asap.pool_handle",
508             FT_STRING, BASE_DEC, NULL, 0x0,          
509             "", HFILL }
510     }, 
511     { &hf_asap_parameter_signature,
512       { "Signature", "asap.parameter_signature",
513             FT_BYTES, BASE_NONE, NULL, 0x0,          
514             "", HFILL }
515         },
516     { &hf_asap_parameter_action_code,
517       { "Action code", "asap.message_action_code",
518         FT_UINT8, BASE_DEC, NULL, 0x0,          
519             "", HFILL }
520     }, 
521     { &hf_asap_parameter_result_code,
522       { "Result code", "asap.message_result_code",
523         FT_UINT8, BASE_DEC, NULL, 0x0,          
524             "", HFILL }
525     }, 
526     { &hf_asap_parameter_reserved,
527       { "Reserved", "asap.message_reserved",
528         FT_UINT16, BASE_HEX, NULL, 0x0,          
529             "", HFILL }
530     }, 
531   };
532   
533   /* Setup protocol subtree array */
534   static gint *ett[] = {
535     &ett_asap,
536     &ett_asap_parameter,
537   };
538   
539   /* Register the protocol name and description */
540   proto_asap = proto_register_protocol("Aggregate Server Access Protocol", "ASAP",  "asap");
541
542   /* Required function calls to register the header fields and subtrees used */
543   proto_register_field_array(proto_asap, hf, array_length(hf));
544   proto_register_subtree_array(ett, array_length(ett));
545
546 };
547
548 void
549 proto_reg_handoff_asap(void)
550 {
551   dissector_handle_t asap_handle;
552   
553   asap_handle = create_dissector_handle(dissect_asap, proto_asap);
554   dissector_add("sctp.ppi",  ASAP_PAYLOAD_PROTO_ID, asap_handle);
555 }