2 * Routines for Realm Specific IP (RSIP) Protocol dissection
3 * Brian Ginsbach <ginsbach@cray.com>
5 * Copyright (c) 2006, 2010 Cray Inc. All Rights Reserved.
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include <epan/packet.h>
33 #include <epan/to_str.h>
34 #include <epan/ipproto.h>
36 /* Forward declaration we need below */
37 void proto_reg_handoff_rsip(void);
39 /* Initialize the protocol and registered fields */
40 static int proto_rsip
= -1;
41 static int hf_rsip_version
= -1;
42 static int hf_rsip_message_type
= -1;
43 static int hf_rsip_message_length
= -1;
44 static int hf_rsip_parameter_type
= -1;
45 static int hf_rsip_parameter_length
= -1;
46 static int hf_rsip_parameter_value
= -1;
47 static int hf_rsip_parameter_address_type
= -1;
48 static int hf_rsip_parameter_address_ipv4
= -1;
49 static int hf_rsip_parameter_address_ipv4_netmask
= -1;
50 static int hf_rsip_parameter_address_ipv6
= -1;
51 static int hf_rsip_parameter_address_fqdn
= -1;
52 static int hf_rsip_parameter_ports_number
= -1;
53 static int hf_rsip_parameter_ports_port_number
= -1;
54 static int hf_rsip_parameter_lease_time
= -1;
55 static int hf_rsip_parameter_client_id
= -1;
56 static int hf_rsip_parameter_bind_id
= -1;
57 static int hf_rsip_parameter_tunnel_type
= -1;
58 static int hf_rsip_parameter_method
= -1;
59 static int hf_rsip_parameter_error
= -1;
60 static int hf_rsip_parameter_flow_policy_local
= -1;
61 static int hf_rsip_parameter_flow_policy_remote
= -1;
62 static int hf_rsip_parameter_indicator
= -1;
63 static int hf_rsip_parameter_message_counter
= -1;
64 static int hf_rsip_parameter_vendor_specific_vendor_id
= -1;
65 static int hf_rsip_parameter_vendor_specific_subtype
= -1;
66 static int hf_rsip_parameter_vendor_specific_value
= -1;
67 static int hf_rsip_parameter_spi_number
= -1;
68 static int hf_rsip_parameter_spi
= -1;
70 /* Initialize the subtree pointers */
71 static gint ett_rsip
= -1;
72 static gint ett_rsip_param
= -1;
73 static gint ett_rsip_param_val
= -1;
75 #define UDP_PORT_RSIP 4555
76 #define TCP_PORT_RSIP 4555
78 /* Message Types in RFC 3103 Appendix B / RFC 3104 Appendix C style */
79 static const value_string msg_type_appendix_vals
[] = {
80 { 1, "ERROR_RESPONSE" },
81 { 2, "REGISTER_REQUEST" },
82 { 3, "REGISTER_RESPONSE" },
83 { 4, "DE-REGISTER_REQUEST" },
84 { 5, "DE-REGISTER_RESPONSE" },
85 { 6, "ASSIGN_REQUEST_RSA-IP" },
86 { 7, "ASSIGN_RESPONSE_RSA-IP" },
87 { 8, "ASSIGN_REQUEST_RSAP-IP" },
88 { 9, "ASSIGN_RESPONSE_RSAP-IP" },
89 { 10, "EXTEND_REQUEST" },
90 { 11, "EXTEND_RESPONSE" },
91 { 12, "FREE_REQUEST" },
92 { 13, "FREE_RESPONSE" },
93 { 14, "QUERY_REQUEST" },
94 { 15, "QUERY_RESPONSE" },
95 { 16, "LISTEN_REQUEST" },
96 { 17, "LISTEN_RESPONSE" },
97 { 22, "ASSIGN_REQUEST_RSIPSEC" },
98 { 23, "ASSIGN_RESPONSE_RSIPEC" },
102 static const value_string msg_type_vals
[] = {
103 { 1, "Error Response" },
104 { 2, "Register Request" },
105 { 3, "Register Response" },
106 { 4, "Deregister Request" },
107 { 5, "Deregister Response" },
108 { 6, "Assign Request RSA-IP" },
109 { 7, "Assign Response RSA-IP" },
110 { 8, "Assign Request RSAP-IP" },
111 { 9, "Assign Response RSAP-IP" },
112 { 10, "Extend Request" },
113 { 11, "Extend Response" },
114 { 12, "Free Request" },
115 { 13, "Free Response" },
116 { 14, "Query Request" },
117 { 15, "Query Response" },
118 { 16, "Listen Request" },
119 { 17, "Listen Response" },
120 { 22, "Assign Request RSIPsec" },
121 { 23, "Assign Response RSIPsec" },
125 static const value_string param_type_vals
[] = {
131 { 6, "Tunnel Type" },
132 { 7, "RSIP Method" },
134 { 9, "Flow Policy" },
136 { 11, "Message Counter" },
137 { 12, "Vendor Specific" },
142 static const value_string addr_type_vals
[] = {
145 { 2, "IPv4 Netmask" },
147 { 4, "Fully Qualified Doman Name" },
151 static const value_string tunnel_type_vals
[] = {
152 { 1, "IP-IP Tunnel" },
158 static const value_string method_vals
[] = {
165 /* Error Numbers in RFC 3103 Appendix A / RFC 3104 Appendix B style */
166 static const value_string error_number_appendix_vals
[] = {
167 { 101, "UNKNOWN_ERROR" },
169 { 103, "FLOW_POLICY_VIOLATION" },
170 { 104, "INTERNAL_SERVER_ERROR" },
171 { 105, "MESSAGE_COUNTER_REQUIRED" },
172 { 106, "UNSUPPORTED_RSIP_VERSION" },
173 { 201, "MISSING_PARAM" },
174 { 202, "DUPLICATE_PARAM" },
175 { 203, "EXTRA_PARAM" },
176 { 204, "ILLEGAL_PARAM" },
177 { 205, "BAD_PARAM" },
178 { 206, "ILLEGAL_MESSAGE" },
179 { 207, "BAD_MESSAGE" },
180 { 208, "UNSUPPORTED_MESSAGE" },
181 { 301, "REGISTER_FIRST" },
182 { 302, "ALREADY_REGISTERED" },
183 { 303, "ALREADY_UNREGISTERED" },
184 { 304, "REGISTRATION_DENIED" },
185 { 305, "BAD_CLIENT_ID" },
186 { 306, "BAD_BIND_ID" },
187 { 307, "BAD_TUNNEL_TYPE" },
188 { 308, "LOCAL_ADDR_UNAVAILABLE" },
189 { 309, "LOCAL_ADDRPORT_UNAVAILABLE" },
190 { 310, "LOCAL_ADDR_INUSE" },
191 { 311, "LOCAL_ADDRPORT_INUSE" },
192 { 312, "LOCAL_ADDR_UNALlOWED" },
193 { 313, "LOCAL_ADDRPORT_UNALLOWED" },
194 { 314, "REMOTE_ADDR_UNALLOWED" },
195 { 315, "REMOTE_ADDRPORT_UNALLOWED" },
196 { 400, "IPSEC_UNALLOWED" },
197 { 401, "IPSEC_SPI_UNAVAILABLE" },
198 { 402, "IPSEC_SPI_INUSE" },
203 static const value_string error_number_vals
[] = {
204 { 101, "Unknown Error" },
206 { 103, "Flow Policy Violation" },
207 { 104, "Internal Server Error" },
208 { 105, "Message Counter Required" },
209 { 106, "Unsupported RSIP Version" },
210 { 201, "Missing Parameter" },
211 { 202, "Duplicate Parameter" },
212 { 203, "Extra Parameter" },
213 { 204, "Illegal Parameter" },
214 { 205, "Bad Parameter" },
215 { 206, "Illegal Message" },
216 { 207, "Bad Message" },
217 { 208, "Unsupported Message" },
218 { 301, "Register First" },
219 { 302, "Already Registered" },
220 { 303, "Already Unregistered" },
221 { 304, "Registration Denied" },
222 { 305, "Bad Client ID" },
223 { 306, "Bad Bind ID" },
224 { 307, "Bad Tunnel Type" },
225 { 308, "Local Address Unavailable" },
226 { 309, "Local Address Port Unavailable" },
227 { 310, "Local Address Inuse" },
228 { 311, "Local Address Port Inuse" },
229 { 312, "Local Address Unallowed" },
230 { 313, "Local Address Port Unallowed" },
231 { 314, "Remote Address Unallowed" },
232 { 315, "Remote Address Port Unallowed" },
233 { 400, "IPsec Unallowed" },
234 { 401, "IPsec SPI Unavailable" },
235 { 402, "IPsec SPI Inuse" },
239 static const value_string lcl_flow_policy_vals
[] = {
240 { 1, "Macro Flows" },
241 { 2, "Micro Flows " },
245 static const value_string rmt_flow_policy_vals
[] = {
246 { 1, "Macro Flows" },
247 { 2, "Micro Flows" },
252 /* Code to actually dissect the packets */
254 rsip_parameter(tvbuff_t
*tvb
, proto_tree
*rsip_tree
, int off
, int eoff
)
256 int consumed
, i
, paramleft
;
257 guint8 addrtype
, flowpolicy
, method
, number
, paramtype
, tuntype
;
258 guint16 error
, ind
, paramlen
, portnum
;
259 guint32 bid
, cid
, leasetm
, msgc
;
260 proto_tree
*p_tree
, *v_tree
;
261 proto_item
*pti
, *vti
;
262 struct e_in6_addr in6
;
268 paramtype
= tvb_get_guint8(tvb
, off
);
269 paramlen
= tvb_get_ntohs(tvb
, off
+ 1);
271 pti
= proto_tree_add_text(rsip_tree
, tvb
, off
, 3 + paramlen
,
273 val_to_str(paramtype
, param_type_vals
, "Unknown (%d)"));
274 p_tree
= proto_item_add_subtree(pti
, ett_rsip_param
);
276 proto_tree_add_item(p_tree
, hf_rsip_parameter_type
, tvb
,
277 off
, 1, ENC_BIG_ENDIAN
);
278 proto_tree_add_item(p_tree
, hf_rsip_parameter_length
, tvb
,
279 off
+ 1, 2, ENC_BIG_ENDIAN
);
285 vti
= proto_tree_add_item(p_tree
, hf_rsip_parameter_value
,
286 tvb
, off
+ 3, paramlen
, ENC_NA
);
287 v_tree
= proto_item_add_subtree(vti
, ett_rsip_param_val
);
290 case 1: /* Address */
291 proto_tree_add_item(v_tree
, hf_rsip_parameter_address_type
,
292 tvb
, off
+ 3, 1, ENC_BIG_ENDIAN
);
294 addrtype
= tvb_get_guint8(tvb
, off
+ 3);
297 case 0: /* Reserved */
300 if (paramlen
- 1 > 0) {
301 proto_tree_add_item(v_tree
,
302 hf_rsip_parameter_address_ipv4
, tvb
,
303 off
+ 4, paramlen
- 1, ENC_BIG_ENDIAN
);
304 proto_item_append_text(pti
, ": %s",
305 tvb_ip_to_str(tvb
, off
+ 4));
307 proto_item_append_text(pti
,
308 ": Any IPv4 Address");
310 case 2: /* IPv4 netmask */
311 if (paramlen
- 1 > 0) {
312 proto_tree_add_item(v_tree
,
313 hf_rsip_parameter_address_ipv4_netmask
,
314 tvb
, off
+ 4, paramlen
- 1, ENC_BIG_ENDIAN
);
315 proto_item_append_text(pti
, "(netmask): %s",
316 tvb_ip_to_str(tvb
, off
+ 4));
318 proto_item_append_text(pti
,
319 ": Any IPv4 Netmask");
322 if (paramlen
- 1 > 0) {
323 tvb_get_ipv6(tvb
, off
+ 4, &in6
);
324 proto_tree_add_item(v_tree
,
325 hf_rsip_parameter_address_ipv6
, tvb
,
326 off
+ 4, paramlen
- 1, ENC_NA
);
327 proto_item_append_text(pti
, ": %s",
330 proto_item_append_text(pti
,
331 ": Any IPv6 Address");
334 if (paramlen
- 1 > 0) {
335 proto_tree_add_item(v_tree
,
336 hf_rsip_parameter_address_fqdn
, tvb
,
337 off
+ 4, paramlen
- 1, ENC_ASCII
|ENC_NA
);
338 proto_item_append_text(pti
, ": %s",
339 tvb_format_text(tvb
, off
+ 4, paramlen
- 1));
341 proto_item_append_text(pti
,
342 ": Any Fully Qualified Domain Name");
345 proto_tree_add_text(p_tree
, tvb
, off
+ 4,
346 paramlen
- 1, ": Unknown Address Type");
351 proto_tree_add_item(v_tree
, hf_rsip_parameter_ports_number
,
352 tvb
, off
+ 3, 1, ENC_BIG_ENDIAN
);
353 number
= tvb_get_guint8(tvb
, off
+ 3);
357 proto_item_append_text(pti
, ": Unspecified");
360 proto_item_append_text(pti
, ": Any port");
363 proto_item_append_text(pti
, ": Any %d ports",
368 portnum
= tvb_get_ntohs(tvb
, off
+ 4);
370 proto_tree_add_item(v_tree
,
371 hf_rsip_parameter_ports_port_number
,
372 tvb
, off
+ 4, 2, ENC_BIG_ENDIAN
);
374 paramleft
= paramlen
- 1;
375 if (paramleft
== 2) {
376 proto_tree_add_uint_format_value(v_tree
,
377 hf_rsip_parameter_ports_port_number
,
378 tvb
, off
+ 4, 2, portnum
, "%d - %d",
379 portnum
, portnum
+ number
);
380 proto_item_append_text(pti
,
381 ": %d - %d", portnum
,
386 i
+= 2, paramleft
-= 2)
387 proto_tree_add_item(v_tree
,
388 hf_rsip_parameter_ports_port_number
,
389 tvb
, i
, 2, ENC_BIG_ENDIAN
);
390 proto_item_append_text(pti
,
391 ": List of %d Ports", number
);
396 case 3: /* Lease Time */
397 /* XXX if paramlen != 4 we've got a protocol violation */
398 proto_tree_add_item(v_tree
, hf_rsip_parameter_lease_time
,
399 tvb
, off
+ 3, paramlen
, ENC_BIG_ENDIAN
);
400 leasetm
= tvb_get_ntohl(tvb
, off
+ 3);
401 proto_item_append_text(pti
, ": %d seconds", leasetm
);
403 case 4: /* Client ID */
404 /* XXX if paramlen != 4 we've got a protocol violation */
405 proto_tree_add_item(v_tree
, hf_rsip_parameter_client_id
,
406 tvb
, off
+ 3, paramlen
, ENC_BIG_ENDIAN
);
407 cid
= tvb_get_ntohl(tvb
, off
+ 3);
408 proto_item_append_text(pti
, ": %d", cid
);
410 case 5: /* Bind ID */
411 /* XXX if paramlen != 4 we've got a protocol violation */
412 proto_tree_add_item(v_tree
, hf_rsip_parameter_bind_id
,
413 tvb
, off
+ 3, paramlen
, ENC_BIG_ENDIAN
);
414 bid
= tvb_get_ntohl(tvb
, off
+ 3);
415 proto_item_append_text(pti
, ": %d", bid
);
417 case 6: /* Tunnel Type */
418 /* XXX if paramlen != 1 we've got a protocol violation */
419 proto_tree_add_item(v_tree
, hf_rsip_parameter_tunnel_type
,
420 tvb
, off
+ 3, paramlen
, ENC_BIG_ENDIAN
);
421 tuntype
= tvb_get_guint8(tvb
, off
+ 3);
422 proto_item_append_text(pti
, ": %s",
423 val_to_str(tuntype
, tunnel_type_vals
,
424 "Unknown Tunnel Type (%d)"));
426 case 7: /* RSIP Method */
427 /* XXX if paramlen != 1 we've got a protocol violation */
428 proto_tree_add_item(v_tree
, hf_rsip_parameter_method
,
429 tvb
, off
+ 3, paramlen
, ENC_BIG_ENDIAN
);
430 method
= tvb_get_guint8(tvb
, off
+ 3);
431 proto_item_append_text(pti
, ": %s",
432 val_to_str(method
, method_vals
,
433 "Unknown RSIP Method (%d)"));
436 /* XXX if paramlen != 2 we've got a protocol violation */
437 proto_tree_add_item(v_tree
, hf_rsip_parameter_error
,
438 tvb
, off
+ 3, paramlen
, ENC_BIG_ENDIAN
);
439 error
= tvb_get_ntohs(tvb
, off
+ 3);
440 proto_item_append_text(pti
, ": %s",
441 val_to_str(error
, error_number_vals
, "Undefined Error (%d)"));
443 case 9: /* Flow Policy */
444 /* XXX if paramlen != 2 we've got a protocol violation */
445 proto_tree_add_item(v_tree
,
446 hf_rsip_parameter_flow_policy_local
, tvb
, off
+ 3, 1, ENC_BIG_ENDIAN
);
447 flowpolicy
= tvb_get_guint8(tvb
, off
+ 3);
448 proto_item_append_text(pti
, ": %s",
449 val_to_str(flowpolicy
, lcl_flow_policy_vals
,
450 "Undefined Local Flow Policy (%d)"));
451 proto_tree_add_item(v_tree
,
452 hf_rsip_parameter_flow_policy_remote
, tvb
, off
+ 4, 1,
454 flowpolicy
= tvb_get_guint8(tvb
, off
+ 4);
455 proto_item_append_text(pti
, "/%s",
456 val_to_str(flowpolicy
, rmt_flow_policy_vals
,
457 "Undefined Remote Flow Policy (%d)"));
459 case 10: /* Indicator */
460 /* XXX if paramlen != 2 we've got a protocol violation */
461 proto_tree_add_item(v_tree
, hf_rsip_parameter_indicator
, tvb
,
462 off
+ 3, 2, ENC_BIG_ENDIAN
);
463 ind
= tvb_get_ntohs(tvb
, off
+ 3);
464 proto_item_append_text(pti
, ": %d", ind
);
466 case 11: /* Message Counter */
467 /* XXX if paramlen != 4 we've got a protocol violation */
468 proto_tree_add_item(v_tree
, hf_rsip_parameter_message_counter
,
469 tvb
, off
+ 3, 4, ENC_BIG_ENDIAN
);
470 msgc
= tvb_get_ntohl(tvb
, off
+ 3);
471 proto_item_append_text(pti
, ": %d", msgc
);
473 case 12: /* Vendor Specific */
474 proto_tree_add_item(v_tree
,
475 hf_rsip_parameter_vendor_specific_vendor_id
, tvb
, off
+ 3,
477 proto_tree_add_item(v_tree
,
478 hf_rsip_parameter_vendor_specific_subtype
, tvb
, off
+ 5,
480 proto_tree_add_item(v_tree
,
481 hf_rsip_parameter_vendor_specific_value
, tvb
, off
+ 9,
482 paramlen
- 4, ENC_NA
);
485 proto_tree_add_item(v_tree
, hf_rsip_parameter_spi_number
, tvb
,
486 off
+ 3, 2, ENC_BIG_ENDIAN
);
488 proto_tree_add_item(v_tree
, hf_rsip_parameter_spi
, tvb
,
489 off
+ 5, 4, ENC_BIG_ENDIAN
);
495 consumed
+= paramlen
;
501 rsip_message_error_response(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
502 int offset
, int eoffset
)
504 int consumed
, offset_delta
;
507 [Message Counter] UDP required
515 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
516 offset
+= offset_delta
;
517 consumed
+= offset_delta
;
518 } while ((offset_delta
> 0) && (offset
< eoffset
));
524 rsip_message_register_request(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
525 int offset
, int eoffset
)
527 int consumed
, offset_delta
;
529 [Message Counter] UDP required
535 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
536 offset
+= offset_delta
;
537 consumed
+= offset_delta
;
538 } while ((offset_delta
> 0) && (offset
< eoffset
));
544 rsip_message_register_response(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
545 int offset
, int eoffset
)
547 int consumed
, offset_delta
;
552 [Message Counter] UDP required
560 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
561 offset
+= offset_delta
;
562 consumed
+= offset_delta
;
563 } while ((offset_delta
> 0) && (offset
< eoffset
));
569 rsip_message_deregister_request(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
570 int offset
, int eoffset
)
572 int consumed
, offset_delta
;
575 [Message Counter] UDP required
581 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
582 offset
+= offset_delta
;
583 consumed
+= offset_delta
;
584 } while ((offset_delta
> 0) && (offset
< eoffset
));
590 rsip_message_deregister_response(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
591 int offset
, int eoffset
)
593 return rsip_message_deregister_request(tvb
, rsip_tree
, offset
, eoffset
);
597 rsip_message_assign_request_rsaip(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
598 int offset
, int eoffset
)
600 int consumed
, offset_delta
;
606 [Message Counter] UDP required
614 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
615 offset
+= offset_delta
;
616 consumed
+= offset_delta
;
617 } while ((offset_delta
> 0) && (offset
< eoffset
));
623 rsip_message_assign_response_rsaip(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
624 int offset
, int eoffset
)
626 int consumed
, offset_delta
;
635 [Message Counter] UDP required
636 [Address (tunnel endpoint)]
642 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
643 offset
+= offset_delta
;
644 consumed
+= offset_delta
;
645 } while ((offset_delta
> 0) && (offset
< eoffset
));
651 rsip_message_assign_request_rsapip(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
652 int offset
, int eoffset
)
654 int consumed
, offset_delta
;
661 [Message Counter] UDP required
669 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
670 offset
+= offset_delta
;
671 consumed
+= offset_delta
;
672 } while ((offset_delta
> 0) && (offset
< eoffset
));
678 rsip_message_assign_response_rsapip(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
679 int offset
, int eoffset
)
681 int consumed
, offset_delta
;
691 [Address (tunnel endpoint)]
692 [Message Counter] UDP required
698 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
699 offset
+= offset_delta
;
700 consumed
+= offset_delta
;
701 } while ((offset_delta
> 0) && (offset
< eoffset
));
707 rsip_message_extend_request(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
708 int offset
, int eoffset
)
710 int consumed
, offset_delta
;
715 [Message Counter] UDP required
721 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
722 offset
+= offset_delta
;
723 consumed
+= offset_delta
;
724 } while ((offset_delta
> 0) && (offset
< eoffset
));
730 rsip_message_extend_response(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
731 int offset
, int eoffset
)
733 int consumed
, offset_delta
;
738 [Message Counter] UDP required
744 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
745 offset
+= offset_delta
;
746 consumed
+= offset_delta
;
747 } while ((offset_delta
> 0) && (offset
< eoffset
));
753 rsip_message_free_request(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
754 int offset
, int eoffset
)
756 int consumed
, offset_delta
;
760 [Message Counter] UDP required
766 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
767 offset
+= offset_delta
;
768 consumed
+= offset_delta
;
769 } while ((offset_delta
> 0) && (offset
< eoffset
));
775 rsip_message_free_response(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
776 int offset
, int eoffset
)
778 int consumed
, offset_delta
;
782 [Message Counter] UDP required
788 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
789 offset
+= offset_delta
;
790 consumed
+= offset_delta
;
791 } while ((offset_delta
> 0) && (offset
< eoffset
));
797 rsip_message_query_request(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
798 int offset
, int eoffset
)
800 int consumed
, offset_delta
;
803 [Message Counter] UDP required
807 <Address Tuple> ::= <Indicator (address)>
810 <Netwrok Tuple> ::= <Indicator (network)>
818 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
819 offset
+= offset_delta
;
820 consumed
+= offset_delta
;
821 } while ((offset_delta
> 0) && (offset
< eoffset
));
827 rsip_message_query_response(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
828 int offset
, int eoffset
)
830 int consumed
, offset_delta
;
833 [Message Counter] UDP required
834 [Local Address Tuple]...
835 [Local Network Tuple]...
836 [Remote Address Tuple]...
837 [Remote Network Tuple]...
839 <Local Address Tuple> ::= <Indicator (local address)>
842 <Local Network Tuple> ::= <Indicator (local network)>
846 <Remote Address Tuple> ::= <Indicator (remote address)>
849 <Remote Network Tuple> ::= <Indicator (remote network)>
857 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
858 offset
+= offset_delta
;
859 consumed
+= offset_delta
;
860 } while ((offset_delta
> 0) && (offset
< eoffset
));
866 rsip_message_listen_request(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
867 int offset
, int eoffset
)
869 int consumed
, offset_delta
;
876 [Message Counter] UDP required
884 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
885 offset
+= offset_delta
;
886 consumed
+= offset_delta
;
887 } while ((offset_delta
> 0) && (offset
< eoffset
));
893 rsip_message_listen_response(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
894 int offset
, int eoffset
)
896 int consumed
, offset_delta
;
906 [Address (tunnel endpoint)]
907 [Message Counter] UDP required
913 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
914 offset
+= offset_delta
;
915 consumed
+= offset_delta
;
916 } while ((offset_delta
> 0) && (offset
< eoffset
));
922 rsip_message_assign_request_rsipsec(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
923 int offset
, int eoffset
)
925 int consumed
, offset_delta
;
932 [Message Counter] UDP required
940 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
941 offset
+= offset_delta
;
942 consumed
+= offset_delta
;
943 } while ((offset_delta
> 0) && (offset
< eoffset
));
949 rsip_message_assign_response_rsipsec(tvbuff_t
*tvb
, proto_tree
*rsip_tree
,
950 int offset
, int eoffset
)
952 int consumed
, offset_delta
;
962 [Address (tunnel endpoint)]
963 [Message Counter] UDP required
969 rsip_parameter(tvb
, rsip_tree
, offset
, eoffset
);
970 offset
+= offset_delta
;
971 consumed
+= offset_delta
;
972 } while ((offset_delta
> 0) && (offset
< eoffset
));
978 dissect_rsip(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
981 proto_tree
*rsip_tree
;
983 /*gboolean msgcnt_required;*/
986 msgtype
= tvb_get_guint8(tvb
, 1);
988 /*msgcnt_required = (pinfo->ipproto == IP_PROTO_UDP)? TRUE : FALSE;*/
990 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "RSIP");
992 col_add_str(pinfo
->cinfo
, COL_INFO
,
993 val_to_str(msgtype
, msg_type_vals
,
994 "Unknown Message Type (0x%0x)"));
997 ti
= proto_tree_add_item(tree
, proto_rsip
, tvb
, 0, -1, ENC_NA
);
999 rsip_tree
= proto_item_add_subtree(ti
, ett_rsip
);
1001 proto_tree_add_item(rsip_tree
,
1002 hf_rsip_version
, tvb
, 0, 1, ENC_BIG_ENDIAN
);
1003 proto_tree_add_item(rsip_tree
,
1004 hf_rsip_message_type
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
1005 proto_tree_add_item(rsip_tree
,
1006 hf_rsip_message_length
, tvb
, 2, 2, ENC_BIG_ENDIAN
);
1008 eoff
= tvb_reported_length(tvb
);
1011 case 1: /* Error Response */
1012 rsip_message_error_response(tvb
, rsip_tree
, 4, eoff
);
1014 case 2: /* Register Request */
1015 rsip_message_register_request(tvb
, rsip_tree
, 4, eoff
);
1017 case 3: /* Register Response */
1018 rsip_message_register_response(tvb
, rsip_tree
, 4, eoff
);
1020 case 4: /* De-register Request */
1021 rsip_message_deregister_request(tvb
, rsip_tree
, 4, eoff
);
1023 case 5: /* De-register Response */
1024 rsip_message_deregister_response(tvb
, rsip_tree
, 4, eoff
);
1026 case 6: /* Assign Request RSA-IP */
1027 rsip_message_assign_request_rsaip(tvb
, rsip_tree
, 4, eoff
);
1029 case 7: /* Assign Response RSA-IP */
1030 rsip_message_assign_response_rsaip(tvb
, rsip_tree
, 4, eoff
);
1032 case 8: /* Assign Request RSAP-IP */
1033 rsip_message_assign_request_rsapip(tvb
, rsip_tree
, 4, eoff
);
1035 case 9: /* Assign Response RSAP-IP */
1036 rsip_message_assign_response_rsapip(tvb
, rsip_tree
, 4, eoff
);
1038 case 10: /* Extend Request */
1039 rsip_message_extend_request(tvb
, rsip_tree
, 4, eoff
);
1041 case 11: /* Extend Response */
1042 rsip_message_extend_response(tvb
, rsip_tree
, 4, eoff
);
1044 case 12: /* Free Request */
1045 rsip_message_free_request(tvb
, rsip_tree
, 4, eoff
);
1047 case 13: /* Free Response */
1048 rsip_message_free_response(tvb
, rsip_tree
, 4, eoff
);
1050 case 14: /* Query Request */
1051 rsip_message_query_request(tvb
, rsip_tree
, 4, eoff
);
1053 case 15: /* Query Response */
1054 rsip_message_query_response(tvb
, rsip_tree
, 4, eoff
);
1056 case 16: /* Listen Request */
1057 rsip_message_listen_request(tvb
, rsip_tree
, 4, eoff
);
1059 case 17: /* Listen Response */
1060 rsip_message_listen_response(tvb
, rsip_tree
, 4, eoff
);
1062 case 22: /* Assign Request RSIPsec */
1063 rsip_message_assign_request_rsipsec(tvb
, rsip_tree
, 4, eoff
);
1065 case 23: /* Assign Response RSIPsec */
1066 rsip_message_assign_response_rsipsec(tvb
, rsip_tree
, 4, eoff
);
1073 /* Register the protocol with Wireshark */
1075 proto_register_rsip(void)
1078 static hf_register_info hf
[] = {
1080 { "Protocol version", "rsip.version",
1081 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1084 { &hf_rsip_message_type
,
1085 { "Message type", "rsip.message_type",
1086 FT_UINT8
, BASE_DEC
, VALS(msg_type_appendix_vals
), 0x0,
1089 { &hf_rsip_message_length
,
1090 { "Message length", "rsip.message_length",
1091 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1095 { &hf_rsip_parameter_type
,
1096 { "Type", "rsip.parameter.type",
1097 FT_UINT8
, BASE_DEC
, VALS(param_type_vals
), 0x0,
1100 { &hf_rsip_parameter_length
,
1101 { "Length", "rsip.parameter.length",
1102 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1105 { &hf_rsip_parameter_value
,
1106 { "Value", "rsip.parameter.value",
1107 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1110 { &hf_rsip_parameter_address_type
,
1111 { "Address type", "rsip.parameter.address_type",
1112 FT_UINT8
, BASE_DEC
, VALS(addr_type_vals
), 0x0,
1115 { &hf_rsip_parameter_address_ipv4
,
1116 { "IPv4 Address", "rsip.parameter.address",
1117 FT_IPv4
, BASE_NONE
, NULL
, 0x0,
1120 { &hf_rsip_parameter_address_ipv4_netmask
,
1121 { "IPv4 Netmask", "rsip.parameter.netmask",
1122 FT_IPv4
, BASE_NONE
, NULL
, 0x0,
1125 { &hf_rsip_parameter_address_ipv6
,
1126 { "IPv6 Address", "rsip.parameter.address",
1127 FT_IPv6
, BASE_NONE
, NULL
, 0x0,
1130 { &hf_rsip_parameter_address_fqdn
,
1131 { "Fully Qualified Domain Name", "rsip.parameter.fqdn",
1132 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1136 { &hf_rsip_parameter_ports_number
,
1137 { "Number", "rsip.parameter.ports.number",
1138 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1141 { &hf_rsip_parameter_ports_port_number
,
1142 { "Port", "rsip.parameter.ports.port_number",
1143 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1147 { &hf_rsip_parameter_lease_time
,
1148 { "Lease time", "rsip.parameter.lease_time",
1149 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1153 { &hf_rsip_parameter_client_id
,
1154 { "Client ID", "rsip.parameter.client_id",
1155 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1159 { &hf_rsip_parameter_bind_id
,
1160 { "Bind ID", "rsip.parameter.bind_id",
1161 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1165 { &hf_rsip_parameter_tunnel_type
,
1166 { "Tunnel type", "rsip.parameter.tunnel_type",
1167 FT_UINT8
, BASE_DEC
, VALS(tunnel_type_vals
), 0x0,
1171 { &hf_rsip_parameter_method
,
1172 { "Method", "rsip.method_param.method",
1173 FT_UINT8
, BASE_DEC
, VALS(method_vals
), 0x0,
1177 { &hf_rsip_parameter_error
,
1178 { "Error", "rsip.parameter.error",
1179 FT_UINT16
, BASE_DEC
, VALS(error_number_vals
), 0x0,
1183 { &hf_rsip_parameter_flow_policy_local
,
1184 { "Local Flow Policy", "rsip.parameter.local_flow_policy",
1185 FT_UINT8
, BASE_DEC
, VALS(lcl_flow_policy_vals
), 0x0,
1188 { &hf_rsip_parameter_flow_policy_remote
,
1189 { "Remote Flow Policy", "rsip.parameter.remote_flow_policy",
1190 FT_UINT8
, BASE_DEC
, VALS(rmt_flow_policy_vals
), 0x0,
1194 { &hf_rsip_parameter_indicator
,
1195 { "Value", "rsip.parameter.indicator",
1196 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
1200 { &hf_rsip_parameter_message_counter
,
1201 { "Counter", "rsip.parameter.message_counter",
1202 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1206 { &hf_rsip_parameter_vendor_specific_vendor_id
,
1207 { "Vendor ID", "rsip.parameter.vendor_specific.vendor_id",
1208 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1211 { &hf_rsip_parameter_vendor_specific_subtype
,
1212 { "Subtype", "rsip.parameter.vendor_specific.subtype",
1213 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1216 { &hf_rsip_parameter_vendor_specific_value
,
1217 { "Value", "rsip.parameter.vendor_specific.value",
1218 FT_NONE
, BASE_NONE
, NULL
, 0x0,
1222 { &hf_rsip_parameter_spi_number
,
1223 { "Number", "rsip.parameter.spi_number",
1224 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
1227 { &hf_rsip_parameter_spi
,
1228 { "SPI", "rsip.parameter.spi",
1229 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
1234 static gint
*ett
[] = {
1240 proto_rsip
= proto_register_protocol("Realm Specific IP Protocol",
1243 proto_register_field_array(proto_rsip
, hf
, array_length(hf
));
1244 proto_register_subtree_array(ett
, array_length(ett
));
1249 proto_reg_handoff_rsip(void)
1251 static gboolean initialized
= FALSE
;
1252 dissector_handle_t rsip_handle
;
1256 rsip_handle
= create_dissector_handle(dissect_rsip
,
1258 dissector_add_uint("udp.port", UDP_PORT_RSIP
, rsip_handle
);
1259 dissector_add_uint("tcp.port", TCP_PORT_RSIP
, rsip_handle
);