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-common-param-01.txt
5 * http://www.ietf.org/internet-drafts/draft-ietf-rserpool-asap-04.txt
7 * Copyright 2002, Michael Tuexen <Michael.Tuexen@icn.siemens.de>
9 * $Id: packet-asap.c,v 1.5 2002/08/28 21:00:07 jmayer Exp $
11 * Ethereal - Network traffic analyzer
12 * By Gerald Combs <gerald@ethereal.com>
13 * Copyright 1998 Gerald Combs
15 * Copied from README.developer
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <epan/packet.h>
38 #define ASAP_PAYLOAD_PROTO_ID 4209948113u /* = 0xFAEEB5D1 */
40 /* Initialize the protocol and registered fields */
41 static int proto_asap = -1;
42 static int hf_cause_code = -1;
43 static int hf_cause_length = -1;
44 static int hf_cause_info = -1;
45 static int hf_cause_padding = -1;
46 static int hf_message_type = -1;
47 static int hf_message_flags = -1;
48 static int hf_message_length = -1;
49 static int hf_parameter_type = -1;
50 static int hf_parameter_length = -1;
51 static int hf_parameter_value = -1;
52 static int hf_parameter_padding = -1;
53 static int hf_parameter_ipv4_address = -1;
54 static int hf_parameter_ipv6_address = -1;
55 static int hf_sctp_port = -1;
56 static int hf_sctp_reserved = -1;
57 static int hf_tcp_port = -1;
58 static int hf_tcp_reserved = -1;
59 static int hf_udp_port = -1;
60 static int hf_udp_reserved = -1;
61 static int hf_policy_type = -1;
62 static int hf_policy_value = -1;
63 static int hf_pool_handle = -1;
64 static int hf_pe_pe_identifier = -1;
65 static int hf_home_enrp_id = -1;
66 static int hf_reg_life = -1;
67 static int hf_server_identifier = -1;
68 static int hf_m_bit = -1;
69 static int hf_reserved = -1;
70 static int hf_cookie = -1;
71 static int hf_pe_identifier = -1;
73 /* Initialize the subtree pointers */
74 static gint ett_asap = -1;
75 static gint ett_asap_parameter = -1;
76 static gint ett_asap_cause = -1;
79 dissect_parameters(tvbuff_t *, proto_tree *);
81 /* Helper functions */
84 nr_of_padding_bytes (guint length)
88 remainder = length % 4;
96 /* Dissectors for error causes */
97 #define CAUSE_CODE_LENGTH 2
98 #define CAUSE_LENGTH_LENGTH 2
99 #define CAUSE_HEADER_LENGTH (CAUSE_CODE_LENGTH + CAUSE_LENGTH_LENGTH)
101 #define CAUSE_HEADER_OFFSET 0
102 #define CAUSE_CODE_OFFSET CAUSE_HEADER_OFFSET
103 #define CAUSE_LENGTH_OFFSET (CAUSE_CODE_OFFSET + CAUSE_CODE_LENGTH)
104 #define CAUSE_INFO_OFFSET (CAUSE_LENGTH_OFFSET + CAUSE_LENGTH_LENGTH)
107 dissect_unknown_cause(tvbuff_t *cause_tvb, proto_tree *cause_tree, proto_item *cause_item)
109 guint16 code, length, cause_info_length;
111 code = tvb_get_ntohs(cause_tvb, CAUSE_CODE_OFFSET);
112 length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET);
113 cause_info_length = length - CAUSE_HEADER_LENGTH;
114 if (cause_info_length > 0)
115 proto_tree_add_bytes(cause_tree, hf_cause_info, cause_tvb, CAUSE_INFO_OFFSET, cause_info_length,
116 tvb_get_ptr(cause_tvb, CAUSE_INFO_OFFSET, cause_info_length));
117 proto_item_set_text(cause_item, "Error cause with code %u and %u byte%s information", code, cause_info_length, plurality(cause_info_length, "", "s"));
120 #define UNRECOGNIZED_PARAMETER_CAUSE_CODE 1
121 #define UNRECONGNIZED_MESSAGE_CAUSE_CODE 2
122 #define AUTHORIZATION_FAILURE_CAUSE_CODE 3 /* This is an error in the ID */
123 #define INVALID_VALUES 4
124 #define NON_UNIQUE_PE_IDENTIFIER 5
125 #define POOLING_POLICY_INCONSISTENT_CAUSE_CODE 6
127 static const value_string cause_code_values[] = {
128 { UNRECOGNIZED_PARAMETER_CAUSE_CODE, "Unrecognized parameter" },
129 { UNRECONGNIZED_MESSAGE_CAUSE_CODE, "Unrecognized message" },
130 { AUTHORIZATION_FAILURE_CAUSE_CODE, "Authorization failure" },
131 { INVALID_VALUES, "Invalid values" },
132 { NON_UNIQUE_PE_IDENTIFIER, "Non-unique PE identifier" },
133 { POOLING_POLICY_INCONSISTENT_CAUSE_CODE, "Pooling policy inconsistent" },
137 dissect_error_cause(tvbuff_t *cause_tvb, proto_tree *parameter_tree)
139 guint16 code, length, padding_length, total_length;
140 proto_item *cause_item;
141 proto_tree *cause_tree;
143 code = tvb_get_ntohs(cause_tvb, CAUSE_CODE_OFFSET);
144 length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET);
145 padding_length = nr_of_padding_bytes(length);
146 total_length = length + padding_length;
148 cause_item = proto_tree_add_text(parameter_tree, cause_tvb, CAUSE_HEADER_OFFSET, total_length, "BAD ERROR CAUSE");
149 cause_tree = proto_item_add_subtree(cause_item, ett_asap_cause);
151 proto_tree_add_uint(cause_tree, hf_cause_code, cause_tvb, CAUSE_CODE_OFFSET, CAUSE_CODE_LENGTH, code);
152 proto_tree_add_uint(cause_tree, hf_cause_length, cause_tvb, CAUSE_LENGTH_OFFSET, CAUSE_LENGTH_LENGTH, length);
156 dissect_unknown_cause(cause_tvb, cause_tree, cause_item);
159 if (padding_length > 0)
160 proto_tree_add_bytes(cause_tree, hf_cause_padding, cause_tvb, CAUSE_HEADER_OFFSET + length, padding_length,
161 tvb_get_ptr(cause_tvb, CAUSE_HEADER_OFFSET + length, padding_length));
165 dissect_error_causes(tvbuff_t *error_causes_tvb, proto_tree *parameter_tree)
167 guint16 length, padding_length, total_length;
169 tvbuff_t *error_cause_tvb;
172 while(tvb_reported_length_remaining(error_causes_tvb, offset)) {
173 length = tvb_get_ntohs(error_causes_tvb, offset + CAUSE_LENGTH_OFFSET);
174 padding_length = nr_of_padding_bytes(length);
175 total_length = length + padding_length;
176 error_cause_tvb = tvb_new_subset(error_causes_tvb, offset , total_length, total_length);
177 dissect_error_cause(error_cause_tvb, parameter_tree);
178 offset += total_length;
182 /* Dissectors for parameters */
184 #define PARAMETER_TYPE_LENGTH 2
185 #define PARAMETER_LENGTH_LENGTH 2
186 #define PARAMETER_HEADER_LENGTH (PARAMETER_TYPE_LENGTH + PARAMETER_LENGTH_LENGTH)
188 #define PARAMETER_HEADER_OFFSET 0
189 #define PARAMETER_TYPE_OFFSET PARAMETER_HEADER_OFFSET
190 #define PARAMETER_LENGTH_OFFSET (PARAMETER_TYPE_OFFSET + PARAMETER_TYPE_LENGTH)
191 #define PARAMETER_VALUE_OFFSET (PARAMETER_LENGTH_OFFSET + PARAMETER_LENGTH_LENGTH)
193 #define IPV4_ADDRESS_LENGTH 4
194 #define IPV4_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
197 dissect_ipv4_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
199 guint32 ipv4_address;
201 tvb_memcpy(parameter_tvb, (guint8 *)&ipv4_address, IPV4_ADDRESS_OFFSET, IPV4_ADDRESS_LENGTH);
202 proto_tree_add_ipv4(parameter_tree, hf_parameter_ipv4_address, parameter_tvb, IPV4_ADDRESS_OFFSET, IPV4_ADDRESS_LENGTH, ipv4_address);
203 proto_item_set_text(parameter_item, "IPV4 address parameter: %s", ip_to_str((const guint8 *)&ipv4_address));
206 #define IPV6_ADDRESS_LENGTH 16
207 #define IPV6_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
210 dissect_ipv6_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
212 guint8 *ip6_address_ptr;
214 ip6_address_ptr = (guint8 *)tvb_get_ptr(parameter_tvb, IPV6_ADDRESS_OFFSET, IPV6_ADDRESS_LENGTH);
215 proto_tree_add_ipv6(parameter_tree, hf_parameter_ipv6_address, parameter_tvb, IPV6_ADDRESS_OFFSET, IPV6_ADDRESS_LENGTH,
216 (const guint8 *)ip6_address_ptr);
218 proto_item_set_text(parameter_item, "IPV6 address parameter: %s", ip6_to_str((struct e_in6_addr *)ip6_address_ptr));
221 #define SCTP_PORT_LENGTH 2
222 #define SCTP_RESERVED_LENGTH 2
223 #define SCTP_PORT_OFFSET PARAMETER_VALUE_OFFSET
224 #define SCTP_RESERVED_OFFSET (SCTP_PORT_OFFSET + SCTP_PORT_LENGTH)
225 #define SCTP_ADDRESS_OFFSET (SCTP_RESERVED_OFFSET + SCTP_RESERVED_LENGTH)
228 dissect_sctp_transport_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
230 tvbuff_t *parameters_tvb;
231 guint16 port, reserved;
233 port = tvb_get_ntohs(parameter_tvb, SCTP_PORT_OFFSET);
234 reserved = tvb_get_ntohs(parameter_tvb, SCTP_RESERVED_OFFSET);
236 proto_tree_add_uint(parameter_tree, hf_sctp_port, parameter_tvb, SCTP_PORT_OFFSET, SCTP_PORT_LENGTH, port);
237 proto_tree_add_uint(parameter_tree, hf_sctp_reserved, parameter_tvb, SCTP_RESERVED_OFFSET, SCTP_RESERVED_LENGTH, reserved);
239 proto_item_set_text(parameter_item, "SCTP transport parameter");
241 parameters_tvb = tvb_new_subset(parameter_tvb, SCTP_ADDRESS_OFFSET, -1, -1);
242 dissect_parameters(parameters_tvb, parameter_tree);
245 #define TCP_PORT_LENGTH 2
246 #define TCP_RESERVED_LENGTH 2
247 #define TCP_PORT_OFFSET PARAMETER_VALUE_OFFSET
248 #define TCP_RESERVED_OFFSET (TCP_PORT_OFFSET + TCP_PORT_LENGTH)
249 #define TCP_ADDRESS_OFFSET (TCP_RESERVED_OFFSET + TCP_RESERVED_LENGTH)
252 dissect_tcp_transport_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
254 tvbuff_t *parameters_tvb;
255 guint16 port, reserved;
257 port = tvb_get_ntohs(parameter_tvb, TCP_PORT_OFFSET);
258 reserved = tvb_get_ntohs(parameter_tvb, TCP_RESERVED_OFFSET);
260 proto_tree_add_uint(parameter_tree, hf_tcp_port, parameter_tvb, TCP_PORT_OFFSET, TCP_PORT_LENGTH, port);
261 proto_tree_add_uint(parameter_tree, hf_tcp_reserved, parameter_tvb, TCP_RESERVED_OFFSET, TCP_RESERVED_LENGTH, reserved);
263 proto_item_set_text(parameter_item, "TCP transport parameter");
265 parameters_tvb = tvb_new_subset(parameter_tvb, TCP_ADDRESS_OFFSET, -1, -1);
266 dissect_parameters(parameters_tvb, parameter_tree);
269 #define UDP_PORT_LENGTH 2
270 #define UDP_RESERVED_LENGTH 2
271 #define UDP_PORT_OFFSET PARAMETER_VALUE_OFFSET
272 #define UDP_RESERVED_OFFSET (UDP_PORT_OFFSET + UDP_PORT_LENGTH)
273 #define UDP_ADDRESS_OFFSET (UDP_RESERVED_OFFSET + UDP_RESERVED_LENGTH)
276 dissect_udp_transport_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
278 tvbuff_t *parameters_tvb;
279 guint16 port, reserved;
281 port = tvb_get_ntohs(parameter_tvb, UDP_PORT_OFFSET);
282 reserved = tvb_get_ntohs(parameter_tvb, UDP_RESERVED_OFFSET);
284 proto_tree_add_uint(parameter_tree, hf_udp_port, parameter_tvb, UDP_PORT_OFFSET, UDP_PORT_LENGTH, port);
285 proto_tree_add_uint(parameter_tree, hf_udp_reserved, parameter_tvb, UDP_RESERVED_OFFSET, UDP_RESERVED_LENGTH, reserved);
287 proto_item_set_text(parameter_item, "UDP transport parameter");
289 parameters_tvb = tvb_new_subset(parameter_tvb, UDP_ADDRESS_OFFSET, -1, -1);
290 dissect_parameters(parameters_tvb, parameter_tree);
293 #define POLICY_TYPE_LENGTH 1
294 #define POLICY_VALUE_LENGTH 3
296 #define POLICY_TYPE_OFFSET PARAMETER_VALUE_OFFSET
297 #define POLICY_VALUE_OFFSET (POLICY_TYPE_OFFSET + POLICY_TYPE_LENGTH)
299 #define ROUND_ROBIN_POLICY 1
300 #define LEAST_USED_POLICY 2
301 #define LEAST_USED_WITH_DEG 3
302 #define WEIGHTED_ROUND_ROBIN 4
304 static const value_string policy_type_values[] = {
305 { ROUND_ROBIN_POLICY, "Round robin" },
306 { LEAST_USED_POLICY, "Least used" },
307 { LEAST_USED_WITH_DEG, "Least used with degradation" },
308 { WEIGHTED_ROUND_ROBIN, "Weighted round robin" },
312 dissect_pool_member_selection_policy_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
317 policy_type = tvb_get_guint8(parameter_tvb, POLICY_TYPE_OFFSET);
318 policy_value = tvb_get_ntoh24(parameter_tvb, POLICY_VALUE_OFFSET);
319 proto_tree_add_uint(parameter_tree, hf_policy_type, parameter_tvb, POLICY_TYPE_OFFSET, POLICY_TYPE_LENGTH, policy_type);
320 proto_tree_add_int(parameter_tree, hf_policy_value, parameter_tvb, POLICY_VALUE_OFFSET, POLICY_VALUE_LENGTH, policy_value);
322 proto_item_set_text(parameter_item, "Pool member selection policy");
326 #define POOL_HANDLE_OFFSET PARAMETER_VALUE_OFFSET
329 dissect_pool_handle_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
331 guint16 length, handle_length;
334 length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
336 handle_length = length - PARAMETER_HEADER_LENGTH;
337 handle_ptr = (char *)tvb_get_ptr(parameter_tvb, POOL_HANDLE_OFFSET, handle_length);
338 proto_tree_add_bytes(parameter_tree, hf_pool_handle, parameter_tvb, POOL_HANDLE_OFFSET, handle_length, handle_ptr);
339 proto_item_set_text(parameter_item, "Pool handle");
342 #define PE_PE_IDENTIFIER_LENGTH 4
343 #define HOME_ENRP_INDENTIFIER_LENGTH 4
344 #define REGISTRATION_LIFE_LENGTH 4
346 #define PE_PE_IDENTIFIER_OFFSET PARAMETER_VALUE_OFFSET
347 #define HOME_ENRP_INDENTIFIER_OFFSET (PE_PE_IDENTIFIER_OFFSET + PE_PE_IDENTIFIER_LENGTH)
348 #define REGISTRATION_LIFE_OFFSET (HOME_ENRP_INDENTIFIER_OFFSET + HOME_ENRP_INDENTIFIER_LENGTH)
349 #define USER_TRANSPORT_PARAMETER_OFFSET (REGISTRATION_LIFE_OFFSET + REGISTRATION_LIFE_LENGTH)
352 dissect_pool_element_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
354 tvbuff_t *parameters_tvb;
355 guint32 pe_identifier, home_enrp_identifier;
358 pe_identifier = tvb_get_ntohl(parameter_tvb, PE_PE_IDENTIFIER_OFFSET);
359 home_enrp_identifier = tvb_get_ntohl(parameter_tvb, HOME_ENRP_INDENTIFIER_OFFSET);
360 reg_life = tvb_get_ntohl(parameter_tvb, REGISTRATION_LIFE_OFFSET);
362 proto_tree_add_uint(parameter_tree, hf_pe_pe_identifier, parameter_tvb, PE_PE_IDENTIFIER_OFFSET, PE_PE_IDENTIFIER_LENGTH, pe_identifier);
363 proto_tree_add_uint(parameter_tree, hf_home_enrp_id, parameter_tvb, HOME_ENRP_INDENTIFIER_OFFSET, HOME_ENRP_INDENTIFIER_LENGTH, home_enrp_identifier);
364 proto_tree_add_int(parameter_tree, hf_reg_life, parameter_tvb, REGISTRATION_LIFE_OFFSET, REGISTRATION_LIFE_LENGTH, reg_life);
366 parameters_tvb = tvb_new_subset(parameter_tvb, USER_TRANSPORT_PARAMETER_OFFSET, -1, -1);
367 dissect_parameters(parameters_tvb, parameter_tree);
369 proto_item_set_text(parameter_item, "Pool element");
372 #define SERVER_ID_LENGTH 4
373 #define RESERVED_LENGTH 4
375 #define SERVER_ID_OFFSET PARAMETER_VALUE_OFFSET
376 #define RESERVED_OFFSET (SERVER_ID_OFFSET + SERVER_ID_LENGTH)
377 #define SERVER_TRANSPORT_OFFSET (RESERVED_OFFSET + RESERVED_LENGTH)
379 #define M_BIT_MASK 0x80000000
380 #define RESERVED_MASK 0x7fffffff
383 dissect_server_information_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
385 tvbuff_t *parameters_tvb;
386 guint32 server_identifier, reserved;
388 server_identifier = tvb_get_ntohl(parameter_tvb, SERVER_ID_OFFSET);
389 reserved = tvb_get_ntohl(parameter_tvb, RESERVED_OFFSET);
391 proto_tree_add_uint(parameter_tree, hf_server_identifier, parameter_tvb, SERVER_ID_OFFSET, SERVER_ID_LENGTH, server_identifier);
392 proto_tree_add_boolean(parameter_tree, hf_m_bit, parameter_tvb, RESERVED_OFFSET, RESERVED_LENGTH, reserved);
393 proto_tree_add_uint(parameter_tree, hf_reserved, parameter_tvb, RESERVED_OFFSET, RESERVED_LENGTH, reserved);
395 proto_item_set_text(parameter_item, "Server information");
397 parameters_tvb = tvb_new_subset(parameter_tvb, SERVER_TRANSPORT_OFFSET, -1, -1);
398 dissect_parameters(parameters_tvb, parameter_tree);
401 #define ERROR_CAUSES_OFFSET PARAMETER_VALUE_OFFSET
404 dissect_operation_error_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
406 tvbuff_t *error_causes_tvb;
408 error_causes_tvb = tvb_new_subset(parameter_tvb, ERROR_CAUSES_OFFSET, -1,-1);
409 dissect_error_causes(error_causes_tvb, parameter_tree);
410 proto_item_set_text(parameter_item, "Operation Error");
413 #define COOKIE_OFFSET PARAMETER_VALUE_OFFSET
416 dissect_cookie_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
418 guint16 cookie_length;
420 cookie_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
421 if (cookie_length > 0)
422 proto_tree_add_bytes(parameter_tree, hf_cookie, parameter_tvb, COOKIE_OFFSET, cookie_length,
423 tvb_get_ptr(parameter_tvb, COOKIE_OFFSET, cookie_length));
424 proto_item_set_text(parameter_item, "Cookie (%u byte%s)", cookie_length, plurality(cookie_length, "", "s"));
427 #define PE_IDENTIFIER_LENGTH 4
428 #define PE_IDENTIFIER_OFFSET PARAMETER_VALUE_OFFSET
431 dissect_pe_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
433 guint32 pe_identifer;
435 pe_identifer = tvb_get_ntohl(parameter_tvb, PE_IDENTIFIER_OFFSET);
436 proto_tree_add_uint(parameter_tree, hf_pe_identifier, parameter_tvb, PE_IDENTIFIER_OFFSET, PE_IDENTIFIER_LENGTH, pe_identifer);
437 proto_item_set_text(parameter_item, "PE identifier: 0x%x", pe_identifer);
441 dissect_unknown_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
443 guint16 type, length, parameter_value_length;
445 type = tvb_get_ntohs(parameter_tvb, PARAMETER_TYPE_OFFSET);
446 length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
448 parameter_value_length = length - PARAMETER_HEADER_LENGTH;
450 if (parameter_value_length > 0)
451 proto_tree_add_bytes(parameter_tree, hf_parameter_value, parameter_tvb, PARAMETER_VALUE_OFFSET, parameter_value_length,
452 tvb_get_ptr(parameter_tvb, PARAMETER_VALUE_OFFSET, parameter_value_length));
454 proto_item_set_text(parameter_item, "Parameter with type %u and %u byte%s value", type, parameter_value_length, plurality(parameter_value_length, "", "s"));
457 #define IPV4_ADDRESS_PARAMETER_TYPE 0x01
458 #define IPV6_ADDRESS_PARAMETER_TYPE 0x02
459 #define SCTP_TRANSPORT_PARAMETER_TYPE 0x03
460 #define TCP_TRANSPORT_PARAMETER_TYPE 0x04
461 #define UDP_TRANSPORT_PARAMETER_TYPE 0x05
462 #define POOL_MEMBER_SELECTION_POLICY_PARAMETER_TYPE 0x06
463 #define POOL_HANDLE_PARAMETER_TYPE 0x07
464 #define POOL_ELEMENT_PARAMETER_TYPE 0x08
465 #define SERVER_INFORMATION_PARAMETER_TYPE 0x09
466 #define OPERATION_ERROR_PARAMETER_TYPE 0x0a
467 #define COOKIE_PARAMETER_TYPE 0x0b
468 #define PE_IDENTIFIER_PARAMETER_TYPE 0x0c
470 static const value_string parameter_type_values[] = {
471 { IPV4_ADDRESS_PARAMETER_TYPE, "IPV4 address" },
472 { IPV6_ADDRESS_PARAMETER_TYPE, "IPV6 address" },
473 { SCTP_TRANSPORT_PARAMETER_TYPE, "SCTP transport address" },
474 { TCP_TRANSPORT_PARAMETER_TYPE, "TCP transport address" },
475 { UDP_TRANSPORT_PARAMETER_TYPE, "UDP transport address" },
476 { POOL_MEMBER_SELECTION_POLICY_PARAMETER_TYPE, "Pool member selection policy" },
477 { POOL_HANDLE_PARAMETER_TYPE, "Pool handle" },
478 { SERVER_INFORMATION_PARAMETER_TYPE, "Server Information" },
479 { OPERATION_ERROR_PARAMETER_TYPE, "Operation error" },
480 { COOKIE_PARAMETER_TYPE, "Cookie" },
481 { PE_IDENTIFIER_PARAMETER_TYPE, "Pool Element identifier" },
486 dissect_asap_parameter(tvbuff_t *parameter_tvb, proto_tree *asap_tree)
488 guint16 type, length, padding_length, total_length;
489 proto_item *parameter_item;
490 proto_tree *parameter_tree;
492 /* extract tag and length from the parameter */
493 type = tvb_get_ntohs(parameter_tvb, PARAMETER_TYPE_OFFSET);
494 length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
496 /* calculate padding and total length */
497 padding_length = tvb_length(parameter_tvb) - length;
498 total_length = length + padding_length;
500 /* create proto_tree stuff */
501 parameter_item = proto_tree_add_text(asap_tree, parameter_tvb, PARAMETER_HEADER_OFFSET, total_length, "Incomplete parameter");
502 parameter_tree = proto_item_add_subtree(parameter_item, ett_asap_parameter);
504 /* add tag and length to the asap tree */
505 proto_tree_add_uint(parameter_tree, hf_parameter_type, parameter_tvb, PARAMETER_TYPE_OFFSET, PARAMETER_TYPE_LENGTH, type);
506 proto_tree_add_uint(parameter_tree, hf_parameter_length, parameter_tvb, PARAMETER_LENGTH_OFFSET, PARAMETER_LENGTH_LENGTH, length);
509 case IPV4_ADDRESS_PARAMETER_TYPE:
510 dissect_ipv4_parameter(parameter_tvb, parameter_tree, parameter_item);
512 case IPV6_ADDRESS_PARAMETER_TYPE:
513 dissect_ipv6_parameter(parameter_tvb, parameter_tree, parameter_item);
515 case SCTP_TRANSPORT_PARAMETER_TYPE:
516 dissect_sctp_transport_parameter(parameter_tvb, parameter_tree, parameter_item);
518 case TCP_TRANSPORT_PARAMETER_TYPE:
519 dissect_tcp_transport_parameter(parameter_tvb, parameter_tree, parameter_item);
521 case UDP_TRANSPORT_PARAMETER_TYPE:
522 dissect_udp_transport_parameter(parameter_tvb, parameter_tree, parameter_item);
524 case POOL_MEMBER_SELECTION_POLICY_PARAMETER_TYPE:
525 dissect_pool_member_selection_policy_parameter(parameter_tvb, parameter_tree, parameter_item);
527 case POOL_HANDLE_PARAMETER_TYPE:
528 dissect_pool_handle_parameter(parameter_tvb, parameter_tree, parameter_item);
530 case POOL_ELEMENT_PARAMETER_TYPE:
531 dissect_pool_element_parameter(parameter_tvb, parameter_tree, parameter_item);
533 case SERVER_INFORMATION_PARAMETER_TYPE:
534 dissect_server_information_parameter(parameter_tvb, parameter_tree, parameter_item);
536 case OPERATION_ERROR_PARAMETER_TYPE:
537 dissect_operation_error_parameter(parameter_tvb, parameter_tree, parameter_item);
539 case COOKIE_PARAMETER_TYPE:
540 dissect_cookie_parameter(parameter_tvb, parameter_tree, parameter_item);
542 case PE_IDENTIFIER_PARAMETER_TYPE:
543 dissect_pe_identifier_parameter(parameter_tvb, parameter_tree, parameter_item);
546 dissect_unknown_parameter(parameter_tvb, parameter_tree, parameter_item);
550 if (padding_length > 0)
551 proto_tree_add_bytes(parameter_tree, hf_parameter_padding, parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length,
552 tvb_get_ptr(parameter_tvb, PARAMETER_HEADER_OFFSET + length, padding_length));
556 dissect_parameters(tvbuff_t *parameters_tvb, proto_tree *tree)
558 gint offset, length, padding_length, total_length, remaining_length;
559 tvbuff_t *parameter_tvb;
562 while((remaining_length = tvb_length_remaining(parameters_tvb, offset))) {
563 length = tvb_get_ntohs(parameters_tvb, offset + PARAMETER_LENGTH_OFFSET);
564 padding_length = nr_of_padding_bytes(length);
565 if (remaining_length >= length)
566 total_length = MIN(length + padding_length, remaining_length);
568 total_length = length + padding_length;
569 /* create a tvb for the parameter including the padding bytes */
570 parameter_tvb = tvb_new_subset(parameters_tvb, offset, total_length, total_length);
571 dissect_asap_parameter(parameter_tvb, tree);
572 /* get rid of the handled parameter */
573 offset += total_length;
577 #define MESSAGE_TYPE_LENGTH 1
578 #define MESSAGE_FLAGS_LENGTH 1
579 #define MESSAGE_LENGTH_LENGTH 2
581 #define MESSAGE_TYPE_OFFSET 0
582 #define MESSAGE_FLAGS_OFFSET (MESSAGE_TYPE_OFFSET + MESSAGE_TYPE_LENGTH)
583 #define MESSAGE_LENGTH_OFFSET (MESSAGE_FLAGS_OFFSET + MESSAGE_FLAGS_LENGTH)
584 #define MESSAGE_VALUE_OFFSET (MESSAGE_LENGTH_OFFSET + MESSAGE_LENGTH_LENGTH)
586 #define REGISTRATION_MESSAGE_TYPE 0x01
587 #define DEREGISTRATION_MESSAGE_TYPE 0x02
588 #define REGISTRATION_RESPONSE_MESSAGE_TYPE 0x03
589 #define DEREGISTRATION_RESPONSE_MESSAGE_TYPE 0x04
590 #define NAME_RESOLUTION_MESSAGE_TYPE 0x05
591 #define NAME_RESOLUTION_RESPONSE_MESSAGE_TYPE 0x06
592 #define NAME_UNKNOWN_MESSAGE_TYPE 0x07
593 #define ENDPOINT_KEEP_ALIVE_MESSAGE_TYPE 0x08
594 #define ENDPOINT_KEEP_ALIVE_ACK_MESSAGE_TYPE 0x09
595 #define ENDPOINT_UNREACHABLE_MESSAGE_TYPE 0x0a
596 #define SERVER_HUNT_MESSAGE_TYPE 0x0b
597 #define SERVER_HUNT_RESPONSE_MESSAGE_TYPE 0x0c
598 #define COOKIE_MESSAGE_TYPE 0x0d
599 #define COOKIE_ECHO_MESSAGE_TYPE 0x0e
601 static const value_string message_type_values[] = {
602 { REGISTRATION_MESSAGE_TYPE, "Registration" },
603 { DEREGISTRATION_MESSAGE_TYPE, "Deregistration" },
604 { REGISTRATION_RESPONSE_MESSAGE_TYPE, "Registration response" },
605 { DEREGISTRATION_RESPONSE_MESSAGE_TYPE, "Deregistration response" },
606 { NAME_RESOLUTION_MESSAGE_TYPE, "Name resolution" },
607 { NAME_RESOLUTION_RESPONSE_MESSAGE_TYPE, "Name resolution response" },
608 { NAME_UNKNOWN_MESSAGE_TYPE, "Name unknown" },
609 { ENDPOINT_KEEP_ALIVE_MESSAGE_TYPE, "Endpoint keep alive" },
610 { ENDPOINT_KEEP_ALIVE_ACK_MESSAGE_TYPE, "Endpoint keep alive acknowledgement" },
611 { ENDPOINT_UNREACHABLE_MESSAGE_TYPE, "Endpoint unreachable" },
612 { SERVER_HUNT_MESSAGE_TYPE, "Server hunt" },
613 { SERVER_HUNT_RESPONSE_MESSAGE_TYPE, "Server hunt response" },
614 { COOKIE_MESSAGE_TYPE, "Cookie" },
615 { COOKIE_ECHO_MESSAGE_TYPE, "Cookie echo" },
619 dissect_asap_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *asap_tree)
621 tvbuff_t *parameters_tvb;
625 type = tvb_get_guint8(message_tvb, MESSAGE_TYPE_OFFSET);
626 flags = tvb_get_guint8(message_tvb, MESSAGE_FLAGS_OFFSET);
627 length = tvb_get_ntohs (message_tvb, MESSAGE_LENGTH_OFFSET);
629 if (check_col(pinfo->cinfo, COL_INFO)) {
630 col_append_str(pinfo->cinfo, COL_INFO, val_to_str(type, message_type_values, "Unknown ASAP type"));
631 col_append_str(pinfo->cinfo, COL_INFO, " ");
634 proto_tree_add_uint(asap_tree, hf_message_type, message_tvb, MESSAGE_TYPE_OFFSET, MESSAGE_TYPE_LENGTH, type);
635 proto_tree_add_uint(asap_tree, hf_message_flags, message_tvb, MESSAGE_FLAGS_OFFSET, MESSAGE_FLAGS_LENGTH, flags);
636 proto_tree_add_uint(asap_tree, hf_message_length, message_tvb, MESSAGE_LENGTH_OFFSET, MESSAGE_LENGTH_LENGTH, length);
637 parameters_tvb = tvb_new_subset(message_tvb, MESSAGE_VALUE_OFFSET, -1, -1);
638 dissect_parameters(parameters_tvb, asap_tree);
643 dissect_asap(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree)
645 proto_item *asap_item;
646 proto_tree *asap_tree;
648 /* make entry in the Protocol column on summary display */
649 if (check_col(pinfo->cinfo, COL_PROTOCOL))
650 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ASAP");
652 /* In the interest of speed, if "tree" is NULL, don't do any work not
653 necessary to generate protocol tree items. */
655 /* create the asap protocol tree */
656 asap_item = proto_tree_add_item(tree, proto_asap, message_tvb, 0, -1, FALSE);
657 asap_tree = proto_item_add_subtree(asap_item, ett_asap);
661 /* dissect the message */
662 dissect_asap_message(message_tvb, pinfo, asap_tree);
665 /* Register the protocol with Ethereal */
667 proto_register_asap(void)
670 /* Setup list of header fields */
671 static hf_register_info hf[] = {
673 { "Type", "asap.message_type",
674 FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0,
678 { "Flags", "asap.message_flags",
679 FT_UINT8, BASE_HEX, NULL, 0x0,
682 { &hf_message_length,
683 { "Length", "asap.message_length",
684 FT_UINT16, BASE_DEC, NULL, 0x0,
688 { "Cause code", "asap.cause.code",
689 FT_UINT16, BASE_HEX, VALS(cause_code_values), 0x0,
693 { "Cause length", "asap.cause.length",
694 FT_UINT16, BASE_DEC, NULL, 0x0,
698 { "Cause info", "asap.cause.info",
699 FT_BYTES, BASE_NONE, NULL, 0x0,
703 { "Padding", "asap.cause.padding",
704 FT_BYTES, BASE_NONE, NULL, 0x0,
707 { &hf_parameter_type,
708 { "Parameter Type", "asap.parameter.type",
709 FT_UINT16, BASE_HEX, VALS(parameter_type_values), 0x0,
712 { &hf_parameter_length,
713 { "Parameter length", "asap.parameter.length",
714 FT_UINT16, BASE_DEC, NULL, 0x0,
717 { &hf_parameter_value,
718 { "Parameter value", "asap.parameter.value",
719 FT_BYTES, BASE_NONE, NULL, 0x0,
722 { &hf_parameter_padding,
723 { "Padding", "asap.parameter.padding",
724 FT_BYTES, BASE_NONE, NULL, 0x0,
727 {&hf_parameter_ipv4_address,
728 { "IP Version 4 address", "asap.ipv4_address.ipv4_address",
729 FT_IPv4, BASE_NONE, NULL, 0x0,
732 {&hf_parameter_ipv6_address,
733 { "IP Version 6 address", "asap.ipv6_address.ipv6_address",
734 FT_IPv6, BASE_NONE, NULL, 0x0,
738 { "Port", "asap.sctp_transport.port",
739 FT_UINT16, BASE_DEC, NULL, 0x0,
743 { "Reserved", "asap.sctp_transport.reserved",
744 FT_UINT16, BASE_DEC, NULL, 0x0,
748 { "Port", "asap.tcp_transport.port",
749 FT_UINT16, BASE_DEC, NULL, 0x0,
753 { "Reserved", "asap.tcp_transport.reserved",
754 FT_UINT16, BASE_DEC, NULL, 0x0,
758 { "Port", "asap.udp_transport.port",
759 FT_UINT16, BASE_DEC, NULL, 0x0,
763 { "Reserved", "asap.udp_transport.reserved",
764 FT_UINT16, BASE_DEC, NULL, 0x0,
768 { "Policy type", "asap.pool_member_slection_policy.type",
769 FT_UINT8, BASE_DEC, VALS(policy_type_values), 0x0,
773 { "Policy value", "asap.pool_member_slection_policy.value",
774 FT_INT24, BASE_DEC, NULL, 0x0,
778 { "Pool handle", "asap.pool_handle.pool_handle",
779 FT_BYTES, BASE_HEX, NULL, 0x0,
782 { &hf_pe_pe_identifier,
783 { "PE identifier", "asap.pool_element.pe_identifier",
784 FT_UINT32, BASE_HEX, NULL, 0x0,
788 { "Home ENRP server identifier", "asap.pool_element.home_enrp_server_identifier",
789 FT_UINT32, BASE_HEX, NULL, 0x0,
793 { "Registration life", "asap.pool_element.registration_life",
794 FT_INT32, BASE_DEC, NULL, 0x0,
797 { &hf_server_identifier,
798 { "Server identifier", "asap.server_information.server_identifier",
799 FT_UINT32, BASE_HEX, NULL, 0x0,
803 { "M-Bit", "asap.server_information.m_bit",
804 FT_BOOLEAN, 32, NULL, M_BIT_MASK,
808 { "Reserved", "asap.server_information.reserved",
809 FT_UINT32, BASE_HEX, NULL, RESERVED_MASK,
813 { "Cookie", "asap.cookie.cookie",
814 FT_BYTES, BASE_HEX, NULL, 0x0,
818 { "PE identifier", "asap.pe_identifier.pe_identifier",
819 FT_UINT32, BASE_HEX, NULL, 0x0,
824 /* Setup protocol subtree array */
825 static gint *ett[] = {
831 /* Register the protocol name and description */
832 proto_asap = proto_register_protocol("Aggregate Server Access Protocol", "ASAP", "asap");
834 /* Required function calls to register the header fields and subtrees used */
835 proto_register_field_array(proto_asap, hf, array_length(hf));
836 proto_register_subtree_array(ett, array_length(ett));
841 proto_reg_handoff_asap(void)
843 dissector_handle_t asap_handle;
845 asap_handle = create_dissector_handle(dissect_asap, proto_asap);
846 dissector_add("sctp.ppi", ASAP_PAYLOAD_PROTO_ID, asap_handle);