Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-rsip.c
blobae8227fad53e58475a0e48adaa45641949576897
1 /* packet-rsip.c
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.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include "config.h"
16 #include <epan/packet.h>
17 #include <epan/to_str.h>
19 void proto_register_rsip(void);
21 /* Forward declaration we need below */
22 void proto_reg_handoff_rsip(void);
24 static dissector_handle_t rsip_handle;
26 /* Initialize the protocol and registered fields */
27 static int proto_rsip;
28 static int hf_rsip_version;
29 static int hf_rsip_message_type;
30 static int hf_rsip_message_length;
31 static int hf_rsip_parameter_type;
32 static int hf_rsip_parameter_length;
33 static int hf_rsip_parameter_value;
34 static int hf_rsip_parameter_address_type;
35 static int hf_rsip_parameter_address_ipv4;
36 static int hf_rsip_parameter_address_ipv4_netmask;
37 static int hf_rsip_parameter_address_ipv6;
38 static int hf_rsip_parameter_address_fqdn;
39 static int hf_rsip_parameter_ports_number;
40 static int hf_rsip_parameter_ports_port_number;
41 static int hf_rsip_parameter_lease_time;
42 static int hf_rsip_parameter_client_id;
43 static int hf_rsip_parameter_bind_id;
44 static int hf_rsip_parameter_tunnel_type;
45 static int hf_rsip_parameter_method;
46 static int hf_rsip_parameter_error;
47 static int hf_rsip_parameter_flow_policy_local;
48 static int hf_rsip_parameter_flow_policy_remote;
49 static int hf_rsip_parameter_indicator;
50 static int hf_rsip_parameter_message_counter;
51 static int hf_rsip_parameter_vendor_specific_vendor_id;
52 static int hf_rsip_parameter_vendor_specific_subtype;
53 static int hf_rsip_parameter_vendor_specific_value;
54 static int hf_rsip_parameter_spi_number;
55 static int hf_rsip_parameter_spi;
57 /* Initialize the subtree pointers */
58 static int ett_rsip;
59 static int ett_rsip_param;
60 static int ett_rsip_param_val;
62 #define UDP_PORT_RSIP 4555
63 #define TCP_PORT_RSIP 4555
65 /* Message Types in RFC 3103 Appendix B / RFC 3104 Appendix C style */
66 static const value_string msg_type_appendix_vals[] = {
67 { 1, "ERROR_RESPONSE" },
68 { 2, "REGISTER_REQUEST" },
69 { 3, "REGISTER_RESPONSE" },
70 { 4, "DE-REGISTER_REQUEST" },
71 { 5, "DE-REGISTER_RESPONSE" },
72 { 6, "ASSIGN_REQUEST_RSA-IP" },
73 { 7, "ASSIGN_RESPONSE_RSA-IP" },
74 { 8, "ASSIGN_REQUEST_RSAP-IP" },
75 { 9, "ASSIGN_RESPONSE_RSAP-IP" },
76 { 10, "EXTEND_REQUEST" },
77 { 11, "EXTEND_RESPONSE" },
78 { 12, "FREE_REQUEST" },
79 { 13, "FREE_RESPONSE" },
80 { 14, "QUERY_REQUEST" },
81 { 15, "QUERY_RESPONSE" },
82 { 16, "LISTEN_REQUEST" },
83 { 17, "LISTEN_RESPONSE" },
84 { 22, "ASSIGN_REQUEST_RSIPSEC" },
85 { 23, "ASSIGN_RESPONSE_RSIPEC" },
86 { 0, NULL }
89 static const value_string msg_type_vals[] = {
90 { 1, "Error Response" },
91 { 2, "Register Request" },
92 { 3, "Register Response" },
93 { 4, "Deregister Request" },
94 { 5, "Deregister Response" },
95 { 6, "Assign Request RSA-IP" },
96 { 7, "Assign Response RSA-IP" },
97 { 8, "Assign Request RSAP-IP" },
98 { 9, "Assign Response RSAP-IP" },
99 { 10, "Extend Request" },
100 { 11, "Extend Response" },
101 { 12, "Free Request" },
102 { 13, "Free Response" },
103 { 14, "Query Request" },
104 { 15, "Query Response" },
105 { 16, "Listen Request" },
106 { 17, "Listen Response" },
107 { 22, "Assign Request RSIPsec" },
108 { 23, "Assign Response RSIPsec" },
109 { 0, NULL }
112 static const value_string param_type_vals[] = {
113 { 1, "Address" },
114 { 2, "Port" },
115 { 3, "Lease Time" },
116 { 4, "Client ID" },
117 { 5, "Bind ID" },
118 { 6, "Tunnel Type" },
119 { 7, "RSIP Method" },
120 { 8, "Error" },
121 { 9, "Flow Policy" },
122 { 10, "Indicator" },
123 { 11, "Message Counter" },
124 { 12, "Vendor Specific" },
125 { 22, "SPI" },
126 { 0, NULL }
129 static const value_string addr_type_vals[] = {
130 { 0, "Reserved" },
131 { 1, "IPv4" },
132 { 2, "IPv4 Netmask" },
133 { 3, "IPv6" },
134 { 4, "Fully Qualified Domain Name" },
135 { 0, NULL }
138 static const value_string tunnel_type_vals[] = {
139 { 1, "IP-IP Tunnel" },
140 { 2, "GRE Tunnel" },
141 { 3, "L2TP" },
142 { 0, NULL }
145 static const value_string method_vals[] = {
146 { 1, "RSA-IP" },
147 { 2, "RSAP-IP" },
148 { 0, NULL }
151 #if 0
152 /* Error Numbers in RFC 3103 Appendix A / RFC 3104 Appendix B style */
153 static const value_string error_number_appendix_vals[] = {
154 { 101, "UNKNOWN_ERROR" },
155 { 102, "USE_TCP" },
156 { 103, "FLOW_POLICY_VIOLATION" },
157 { 104, "INTERNAL_SERVER_ERROR" },
158 { 105, "MESSAGE_COUNTER_REQUIRED" },
159 { 106, "UNSUPPORTED_RSIP_VERSION" },
160 { 201, "MISSING_PARAM" },
161 { 202, "DUPLICATE_PARAM" },
162 { 203, "EXTRA_PARAM" },
163 { 204, "ILLEGAL_PARAM" },
164 { 205, "BAD_PARAM" },
165 { 206, "ILLEGAL_MESSAGE" },
166 { 207, "BAD_MESSAGE" },
167 { 208, "UNSUPPORTED_MESSAGE" },
168 { 301, "REGISTER_FIRST" },
169 { 302, "ALREADY_REGISTERED" },
170 { 303, "ALREADY_UNREGISTERED" },
171 { 304, "REGISTRATION_DENIED" },
172 { 305, "BAD_CLIENT_ID" },
173 { 306, "BAD_BIND_ID" },
174 { 307, "BAD_TUNNEL_TYPE" },
175 { 308, "LOCAL_ADDR_UNAVAILABLE" },
176 { 309, "LOCAL_ADDRPORT_UNAVAILABLE" },
177 { 310, "LOCAL_ADDR_INUSE" },
178 { 311, "LOCAL_ADDRPORT_INUSE" },
179 { 312, "LOCAL_ADDR_UNALlOWED" },
180 { 313, "LOCAL_ADDRPORT_UNALLOWED" },
181 { 314, "REMOTE_ADDR_UNALLOWED" },
182 { 315, "REMOTE_ADDRPORT_UNALLOWED" },
183 { 400, "IPSEC_UNALLOWED" },
184 { 401, "IPSEC_SPI_UNAVAILABLE" },
185 { 402, "IPSEC_SPI_INUSE" },
186 { 0, NULL }
188 #endif
190 static const value_string error_number_vals[] = {
191 { 101, "Unknown Error" },
192 { 102, "Use TCP" },
193 { 103, "Flow Policy Violation" },
194 { 104, "Internal Server Error" },
195 { 105, "Message Counter Required" },
196 { 106, "Unsupported RSIP Version" },
197 { 201, "Missing Parameter" },
198 { 202, "Duplicate Parameter" },
199 { 203, "Extra Parameter" },
200 { 204, "Illegal Parameter" },
201 { 205, "Bad Parameter" },
202 { 206, "Illegal Message" },
203 { 207, "Bad Message" },
204 { 208, "Unsupported Message" },
205 { 301, "Register First" },
206 { 302, "Already Registered" },
207 { 303, "Already Unregistered" },
208 { 304, "Registration Denied" },
209 { 305, "Bad Client ID" },
210 { 306, "Bad Bind ID" },
211 { 307, "Bad Tunnel Type" },
212 { 308, "Local Address Unavailable" },
213 { 309, "Local Address Port Unavailable" },
214 { 310, "Local Address Inuse" },
215 { 311, "Local Address Port Inuse" },
216 { 312, "Local Address Unallowed" },
217 { 313, "Local Address Port Unallowed" },
218 { 314, "Remote Address Unallowed" },
219 { 315, "Remote Address Port Unallowed" },
220 { 400, "IPsec Unallowed" },
221 { 401, "IPsec SPI Unavailable" },
222 { 402, "IPsec SPI Inuse" },
223 { 0, NULL }
226 static const value_string lcl_flow_policy_vals[] = {
227 { 1, "Macro Flows" },
228 { 2, "Micro Flows " },
229 { 0, NULL }
232 static const value_string rmt_flow_policy_vals[] = {
233 { 1, "Macro Flows" },
234 { 2, "Micro Flows" },
235 { 3, "No Policy" },
236 { 0, NULL }
239 /* Code to actually dissect the packets */
240 static int
241 rsip_parameter(tvbuff_t *tvb, proto_tree *rsip_tree, int off, int eoff)
243 int consumed, i, paramleft;
244 uint8_t addrtype, flowpolicy, method, number, paramtype, tuntype;
245 uint16_t error, ind, paramlen, portnum;
246 uint32_t bid, cid, leasetm, msgc;
247 proto_tree *p_tree, *v_tree;
248 proto_item *pti, *vti;
250 /* XXX */
251 if (off >= eoff)
252 return 0;
254 paramtype = tvb_get_uint8(tvb, off);
255 paramlen = tvb_get_ntohs(tvb, off + 1);
257 p_tree = proto_tree_add_subtree(rsip_tree, tvb, off, 3 + paramlen,
258 ett_rsip_param, &pti,
259 val_to_str(paramtype, param_type_vals, "Unknown (%d)"));
261 proto_tree_add_item(p_tree, hf_rsip_parameter_type, tvb,
262 off, 1, ENC_BIG_ENDIAN);
263 proto_tree_add_item(p_tree, hf_rsip_parameter_length, tvb,
264 off + 1, 2, ENC_BIG_ENDIAN);
265 consumed = 3;
267 if (paramlen == 0)
268 return consumed;
270 vti = proto_tree_add_item(p_tree, hf_rsip_parameter_value,
271 tvb, off + 3, paramlen, ENC_NA);
272 v_tree = proto_item_add_subtree(vti, ett_rsip_param_val);
274 switch (paramtype) {
275 case 1: /* Address */
276 proto_tree_add_item(v_tree, hf_rsip_parameter_address_type,
277 tvb, off + 3, 1, ENC_BIG_ENDIAN);
279 addrtype = tvb_get_uint8(tvb, off + 3);
281 switch (addrtype) {
282 case 0: /* Reserved */
283 break;
284 case 1: /* IPv4 */
285 if (paramlen - 1 > 0) {
286 proto_tree_add_item(v_tree,
287 hf_rsip_parameter_address_ipv4, tvb,
288 off + 4, paramlen - 1, ENC_BIG_ENDIAN);
289 proto_item_append_text(pti, ": %s",
290 tvb_ip_to_str(wmem_packet_scope(), tvb, off + 4));
291 } else
292 proto_item_append_text(pti,
293 ": Any IPv4 Address");
294 break;
295 case 2: /* IPv4 netmask */
296 if (paramlen - 1 > 0) {
297 proto_tree_add_item(v_tree,
298 hf_rsip_parameter_address_ipv4_netmask,
299 tvb, off + 4, paramlen - 1, ENC_BIG_ENDIAN);
300 proto_item_append_text(pti, "(netmask): %s",
301 tvb_ip_to_str(wmem_packet_scope(), tvb, off + 4));
302 } else
303 proto_item_append_text(pti,
304 ": Any IPv4 Netmask");
305 break;
306 case 3: /* IPv6 */
307 if (paramlen - 1 > 0) {
308 proto_tree_add_item(v_tree,
309 hf_rsip_parameter_address_ipv6, tvb,
310 off + 4, paramlen - 1, ENC_NA);
311 proto_item_append_text(pti, ": %s",
312 tvb_ip6_to_str(wmem_packet_scope(), tvb, off + 4));
313 } else
314 proto_item_append_text(pti,
315 ": Any IPv6 Address");
316 break;
317 case 4: /* FQDN */
318 if (paramlen - 1 > 0) {
319 proto_tree_add_item(v_tree,
320 hf_rsip_parameter_address_fqdn, tvb,
321 off + 4, paramlen - 1, ENC_ASCII);
322 proto_item_append_text(pti, ": %s",
323 tvb_format_text(wmem_packet_scope(), tvb, off + 4, paramlen - 1));
324 } else
325 proto_item_append_text(pti,
326 ": Any Fully Qualified Domain Name");
327 break;
328 default:
329 proto_item_append_text(pti, ": Unknown Address Type");
330 break;
332 break;
333 case 2: /* Ports */
334 proto_tree_add_item(v_tree, hf_rsip_parameter_ports_number,
335 tvb, off + 3, 1, ENC_BIG_ENDIAN);
336 number = tvb_get_uint8(tvb, off + 3);
337 if (paramlen == 1) {
338 switch (number) {
339 case 0:
340 proto_item_append_text(pti, ": Unspecified");
341 break;
342 case 1:
343 proto_item_append_text(pti, ": Any port");
344 break;
345 default:
346 proto_item_append_text(pti, ": Any %d ports",
347 number);
348 break;
350 } else {
351 portnum = tvb_get_ntohs(tvb, off + 4);
352 if (number == 1) {
353 proto_tree_add_item(v_tree,
354 hf_rsip_parameter_ports_port_number,
355 tvb, off + 4, 2, ENC_BIG_ENDIAN);
356 } else {
357 paramleft = paramlen - 1;
358 if (paramleft == 2) {
359 proto_tree_add_uint_format_value(v_tree,
360 hf_rsip_parameter_ports_port_number,
361 tvb, off + 4, 2, portnum, "%d - %d",
362 portnum, portnum + number);
363 proto_item_append_text(pti,
364 ": %d - %d", portnum,
365 portnum + number);
366 } else {
367 for (i = off + 4;
368 paramleft > 0;
369 i += 2, paramleft -= 2)
370 proto_tree_add_item(v_tree,
371 hf_rsip_parameter_ports_port_number,
372 tvb, i, 2, ENC_BIG_ENDIAN);
373 proto_item_append_text(pti,
374 ": List of %d Ports", number);
378 break;
379 case 3: /* Lease Time */
380 /* XXX if paramlen != 4 we've got a protocol violation */
381 proto_tree_add_item(v_tree, hf_rsip_parameter_lease_time,
382 tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
383 leasetm = tvb_get_ntohl(tvb, off + 3);
384 proto_item_append_text(pti, ": %d seconds", leasetm);
385 break;
386 case 4: /* Client ID */
387 /* XXX if paramlen != 4 we've got a protocol violation */
388 proto_tree_add_item(v_tree, hf_rsip_parameter_client_id,
389 tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
390 cid = tvb_get_ntohl(tvb, off + 3);
391 proto_item_append_text(pti, ": %d", cid);
392 break;
393 case 5: /* Bind ID */
394 /* XXX if paramlen != 4 we've got a protocol violation */
395 proto_tree_add_item(v_tree, hf_rsip_parameter_bind_id,
396 tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
397 bid = tvb_get_ntohl(tvb, off + 3);
398 proto_item_append_text(pti, ": %d", bid);
399 break;
400 case 6: /* Tunnel Type */
401 /* XXX if paramlen != 1 we've got a protocol violation */
402 proto_tree_add_item(v_tree, hf_rsip_parameter_tunnel_type,
403 tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
404 tuntype = tvb_get_uint8(tvb, off + 3);
405 proto_item_append_text(pti, ": %s",
406 val_to_str(tuntype, tunnel_type_vals,
407 "Unknown Tunnel Type (%d)"));
408 break;
409 case 7: /* RSIP Method */
410 /* XXX if paramlen != 1 we've got a protocol violation */
411 proto_tree_add_item(v_tree, hf_rsip_parameter_method,
412 tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
413 method = tvb_get_uint8(tvb, off + 3);
414 proto_item_append_text(pti, ": %s",
415 val_to_str(method, method_vals,
416 "Unknown RSIP Method (%d)"));
417 break;
418 case 8: /* Error */
419 /* XXX if paramlen != 2 we've got a protocol violation */
420 proto_tree_add_item(v_tree, hf_rsip_parameter_error,
421 tvb, off + 3, paramlen, ENC_BIG_ENDIAN);
422 error = tvb_get_ntohs(tvb, off + 3);
423 proto_item_append_text(pti, ": %s",
424 val_to_str(error, error_number_vals, "Undefined Error (%d)"));
425 break;
426 case 9: /* Flow Policy */
427 /* XXX if paramlen != 2 we've got a protocol violation */
428 proto_tree_add_item(v_tree,
429 hf_rsip_parameter_flow_policy_local, tvb, off + 3, 1, ENC_BIG_ENDIAN);
430 flowpolicy = tvb_get_uint8(tvb, off + 3);
431 proto_item_append_text(pti, ": %s",
432 val_to_str(flowpolicy, lcl_flow_policy_vals,
433 "Undefined Local Flow Policy (%d)"));
434 proto_tree_add_item(v_tree,
435 hf_rsip_parameter_flow_policy_remote, tvb, off + 4, 1,
436 ENC_BIG_ENDIAN);
437 flowpolicy = tvb_get_uint8(tvb, off + 4);
438 proto_item_append_text(pti, "/%s",
439 val_to_str(flowpolicy, rmt_flow_policy_vals,
440 "Undefined Remote Flow Policy (%d)"));
441 break;
442 case 10: /* Indicator */
443 /* XXX if paramlen != 2 we've got a protocol violation */
444 proto_tree_add_item(v_tree, hf_rsip_parameter_indicator, tvb,
445 off + 3, 2, ENC_BIG_ENDIAN);
446 ind = tvb_get_ntohs(tvb, off + 3);
447 proto_item_append_text(pti, ": %d", ind);
448 break;
449 case 11: /* Message Counter */
450 /* XXX if paramlen != 4 we've got a protocol violation */
451 proto_tree_add_item(v_tree, hf_rsip_parameter_message_counter,
452 tvb, off + 3, 4, ENC_BIG_ENDIAN);
453 msgc = tvb_get_ntohl(tvb, off + 3);
454 proto_item_append_text(pti, ": %d", msgc);
455 break;
456 case 12: /* Vendor Specific */
457 proto_tree_add_item(v_tree,
458 hf_rsip_parameter_vendor_specific_vendor_id, tvb, off + 3,
459 2, ENC_BIG_ENDIAN);
460 proto_tree_add_item(v_tree,
461 hf_rsip_parameter_vendor_specific_subtype, tvb, off + 5,
462 2, ENC_BIG_ENDIAN);
463 proto_tree_add_item(v_tree,
464 hf_rsip_parameter_vendor_specific_value, tvb, off + 9,
465 paramlen - 4, ENC_NA);
466 break;
467 case 22: /* SPI */
468 proto_tree_add_item(v_tree, hf_rsip_parameter_spi_number, tvb,
469 off + 3, 2, ENC_BIG_ENDIAN);
470 /* XXX need loop? */
471 proto_tree_add_item(v_tree, hf_rsip_parameter_spi, tvb,
472 off + 5, 4, ENC_BIG_ENDIAN);
473 break;
474 default:
475 break;
478 consumed += paramlen;
480 return consumed;
483 static int
484 rsip_message_error_response(tvbuff_t *tvb, proto_tree *rsip_tree,
485 int offset, int eoffset)
487 int consumed, offset_delta;
489 <Error>
490 [Message Counter] UDP required
491 [Client ID]
492 [Bind ID]
495 consumed = 0;
496 do {
497 offset_delta =
498 rsip_parameter(tvb, rsip_tree, offset, eoffset);
499 offset += offset_delta;
500 consumed += offset_delta;
501 } while ((offset_delta > 0) && (offset < eoffset));
503 return consumed;
506 static int
507 rsip_message_register_request(tvbuff_t *tvb, proto_tree *rsip_tree,
508 int offset, int eoffset)
510 int consumed, offset_delta;
512 [Message Counter] UDP required
515 consumed = 0;
516 do {
517 offset_delta =
518 rsip_parameter(tvb, rsip_tree, offset, eoffset);
519 offset += offset_delta;
520 consumed += offset_delta;
521 } while ((offset_delta > 0) && (offset < eoffset));
523 return consumed;
526 static int
527 rsip_message_register_response(tvbuff_t *tvb, proto_tree *rsip_tree,
528 int offset, int eoffset)
530 int consumed, offset_delta;
532 <Client ID>
533 <Lease Time>
534 <Flow Policy>
535 [Message Counter] UDP required
536 [RSIP Method]...
537 [Tunnel Type]...
540 consumed = 0;
541 do {
542 offset_delta =
543 rsip_parameter(tvb, rsip_tree, offset, eoffset);
544 offset += offset_delta;
545 consumed += offset_delta;
546 } while ((offset_delta > 0) && (offset < eoffset));
548 return consumed;
551 static int
552 rsip_message_deregister_request(tvbuff_t *tvb, proto_tree *rsip_tree,
553 int offset, int eoffset)
555 int consumed, offset_delta;
557 <Client ID>
558 [Message Counter] UDP required
561 consumed = 0;
562 do {
563 offset_delta =
564 rsip_parameter(tvb, rsip_tree, offset, eoffset);
565 offset += offset_delta;
566 consumed += offset_delta;
567 } while ((offset_delta > 0) && (offset < eoffset));
569 return consumed;
572 static int
573 rsip_message_deregister_response(tvbuff_t *tvb, proto_tree *rsip_tree,
574 int offset, int eoffset)
576 return rsip_message_deregister_request(tvb, rsip_tree, offset, eoffset);
579 static int
580 rsip_message_assign_request_rsaip(tvbuff_t *tvb, proto_tree *rsip_tree,
581 int offset, int eoffset)
583 int consumed, offset_delta;
585 <Client ID>
586 <Address (local)>
587 <Address (remote)>
588 <Ports (remote)>
589 [Message Counter] UDP required
590 [Lease Time]
591 [Tunnel Type]
594 consumed = 0;
595 do {
596 offset_delta =
597 rsip_parameter(tvb, rsip_tree, offset, eoffset);
598 offset += offset_delta;
599 consumed += offset_delta;
600 } while ((offset_delta > 0) && (offset < eoffset));
602 return consumed;
605 static int
606 rsip_message_assign_response_rsaip(tvbuff_t *tvb, proto_tree *rsip_tree,
607 int offset, int eoffset)
609 int consumed, offset_delta;
611 <Client ID>
612 <Bind ID>
613 <Address (local)>
614 <Address (remote)>
615 <Ports (remote)>
616 <Lease Time>
617 <Tunnel Type>
618 [Message Counter] UDP required
619 [Address (tunnel endpoint)]
622 consumed = 0;
623 do {
624 offset_delta =
625 rsip_parameter(tvb, rsip_tree, offset, eoffset);
626 offset += offset_delta;
627 consumed += offset_delta;
628 } while ((offset_delta > 0) && (offset < eoffset));
630 return consumed;
633 static int
634 rsip_message_assign_request_rsapip(tvbuff_t *tvb, proto_tree *rsip_tree,
635 int offset, int eoffset)
637 int consumed, offset_delta;
639 <Client ID>
640 <Address (local)>
641 <Ports (local)>
642 <Address (remote)>
643 <Ports (remote)>
644 [Message Counter] UDP required
645 [Lease Time]
646 [Tunnel Type]
649 consumed = 0;
650 do {
651 offset_delta =
652 rsip_parameter(tvb, rsip_tree, offset, eoffset);
653 offset += offset_delta;
654 consumed += offset_delta;
655 } while ((offset_delta > 0) && (offset < eoffset));
657 return consumed;
660 static int
661 rsip_message_assign_response_rsapip(tvbuff_t *tvb, proto_tree *rsip_tree,
662 int offset, int eoffset)
664 int consumed, offset_delta;
666 <Client ID>
667 <Bind ID>
668 <Address (local)>
669 <Ports (local)>
670 <Address (remote)>
671 <Ports (remote)>
672 <Lease Time>
673 <Tunnel Type>
674 [Address (tunnel endpoint)]
675 [Message Counter] UDP required
678 consumed = 0;
679 do {
680 offset_delta =
681 rsip_parameter(tvb, rsip_tree, offset, eoffset);
682 offset += offset_delta;
683 consumed += offset_delta;
684 } while ((offset_delta > 0) && (offset < eoffset));
686 return consumed;
689 static int
690 rsip_message_extend_request(tvbuff_t *tvb, proto_tree *rsip_tree,
691 int offset, int eoffset)
693 int consumed, offset_delta;
695 <Client ID>
696 <Bind ID>
697 [Lease Time]
698 [Message Counter] UDP required
701 consumed = 0;
702 do {
703 offset_delta =
704 rsip_parameter(tvb, rsip_tree, offset, eoffset);
705 offset += offset_delta;
706 consumed += offset_delta;
707 } while ((offset_delta > 0) && (offset < eoffset));
709 return consumed;
712 static int
713 rsip_message_extend_response(tvbuff_t *tvb, proto_tree *rsip_tree,
714 int offset, int eoffset)
716 int consumed, offset_delta;
718 <Client ID>
719 <Bind ID>
720 <Lease Time>
721 [Message Counter] UDP required
724 consumed = 0;
725 do {
726 offset_delta =
727 rsip_parameter(tvb, rsip_tree, offset, eoffset);
728 offset += offset_delta;
729 consumed += offset_delta;
730 } while ((offset_delta > 0) && (offset < eoffset));
732 return consumed;
735 static int
736 rsip_message_free_request(tvbuff_t *tvb, proto_tree *rsip_tree,
737 int offset, int eoffset)
739 int consumed, offset_delta;
741 <Client ID>
742 <Bind ID>
743 [Message Counter] UDP required
746 consumed = 0;
747 do {
748 offset_delta =
749 rsip_parameter(tvb, rsip_tree, offset, eoffset);
750 offset += offset_delta;
751 consumed += offset_delta;
752 } while ((offset_delta > 0) && (offset < eoffset));
754 return consumed;
757 static int
758 rsip_message_free_response(tvbuff_t *tvb, proto_tree *rsip_tree,
759 int offset, int eoffset)
761 int consumed, offset_delta;
763 <Client ID>
764 <Bind ID>
765 [Message Counter] UDP required
768 consumed = 0;
769 do {
770 offset_delta =
771 rsip_parameter(tvb, rsip_tree, offset, eoffset);
772 offset += offset_delta;
773 consumed += offset_delta;
774 } while ((offset_delta > 0) && (offset < eoffset));
776 return consumed;
779 static int
780 rsip_message_query_request(tvbuff_t *tvb, proto_tree *rsip_tree,
781 int offset, int eoffset)
783 int consumed, offset_delta;
785 <Client ID>
786 [Message Counter] UDP required
787 [Address Tuple]...
788 [Network Tuple]...
790 <Address Tuple> ::= <Indicator (address)>
791 <Address>
793 <Network Tuple> ::= <Indicator (network)>
794 <Address (network)>
795 <Address (netmask)>
798 consumed = 0;
799 do {
800 offset_delta =
801 rsip_parameter(tvb, rsip_tree, offset, eoffset);
802 offset += offset_delta;
803 consumed += offset_delta;
804 } while ((offset_delta > 0) && (offset < eoffset));
806 return consumed;
809 static int
810 rsip_message_query_response(tvbuff_t *tvb, proto_tree *rsip_tree,
811 int offset, int eoffset)
813 int consumed, offset_delta;
815 <Client ID>
816 [Message Counter] UDP required
817 [Local Address Tuple]...
818 [Local Network Tuple]...
819 [Remote Address Tuple]...
820 [Remote Network Tuple]...
822 <Local Address Tuple> ::= <Indicator (local address)>
823 <Address>
825 <Local Network Tuple> ::= <Indicator (local network)>
826 <Address (network)>
827 <Address (netmask)>
829 <Remote Address Tuple> ::= <Indicator (remote address)>
830 <Address>
832 <Remote Network Tuple> ::= <Indicator (remote network)>
833 <Address (network)>
834 <Address (netmask)>
837 consumed = 0;
838 do {
839 offset_delta =
840 rsip_parameter(tvb, rsip_tree, offset, eoffset);
841 offset += offset_delta;
842 consumed += offset_delta;
843 } while ((offset_delta > 0) && (offset < eoffset));
845 return consumed;
848 static int
849 rsip_message_listen_request(tvbuff_t *tvb, proto_tree *rsip_tree,
850 int offset, int eoffset)
852 int consumed, offset_delta;
854 <Client ID>
855 <Address (local)>
856 <Ports (local)>
857 <Address (remote)>
858 <Ports (remote)>
859 [Message Counter] UDP required
860 [Lease Time]
861 [Tunnel Type]...
864 consumed = 0;
865 do {
866 offset_delta =
867 rsip_parameter(tvb, rsip_tree, offset, eoffset);
868 offset += offset_delta;
869 consumed += offset_delta;
870 } while ((offset_delta > 0) && (offset < eoffset));
872 return consumed;
875 static int
876 rsip_message_listen_response(tvbuff_t *tvb, proto_tree *rsip_tree,
877 int offset, int eoffset)
879 int consumed, offset_delta;
881 <Client ID>
882 <Bind ID>
883 <Address (local)>
884 <Ports (local)>
885 <Address (remote)>
886 <Ports (remote)>
887 <Tunnel Type>
888 <Lease Time>
889 [Address (tunnel endpoint)]
890 [Message Counter] UDP required
893 consumed = 0;
894 do {
895 offset_delta =
896 rsip_parameter(tvb, rsip_tree, offset, eoffset);
897 offset += offset_delta;
898 consumed += offset_delta;
899 } while ((offset_delta > 0) && (offset < eoffset));
901 return consumed;
904 static int
905 rsip_message_assign_request_rsipsec(tvbuff_t *tvb, proto_tree *rsip_tree,
906 int offset, int eoffset)
908 int consumed, offset_delta;
910 <Client ID>
911 <Address (local)>
912 <Ports (local)>
913 <Address (remote)>
914 <Ports (remote)>
915 [Message Counter] UDP required
916 [Lease Time]
917 [Tunnel Type]...
920 consumed = 0;
921 do {
922 offset_delta =
923 rsip_parameter(tvb, rsip_tree, offset, eoffset);
924 offset += offset_delta;
925 consumed += offset_delta;
926 } while ((offset_delta > 0) && (offset < eoffset));
928 return consumed;
931 static int
932 rsip_message_assign_response_rsipsec(tvbuff_t *tvb, proto_tree *rsip_tree,
933 int offset, int eoffset)
935 int consumed, offset_delta;
937 <Client ID>
938 <Bind ID>
939 <Address (local)>
940 <Ports (local)>
941 <Address (remote)>
942 <Ports (remote)>
943 <Tunnel Type>
944 <Lease Time>
945 [Address (tunnel endpoint)]
946 [Message Counter] UDP required
949 consumed = 0;
950 do {
951 offset_delta =
952 rsip_parameter(tvb, rsip_tree, offset, eoffset);
953 offset += offset_delta;
954 consumed += offset_delta;
955 } while ((offset_delta > 0) && (offset < eoffset));
957 return consumed;
960 static int
961 dissect_rsip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
963 proto_item *ti;
964 proto_tree *rsip_tree;
965 uint8_t msgtype;
966 /*bool msgcnt_required;*/
967 int eoff;
969 msgtype = tvb_get_uint8(tvb, 1);
971 /*msgcnt_required = (pinfo->ipproto == IP_PROTO_UDP)? true : false;*/
973 col_set_str(pinfo->cinfo, COL_PROTOCOL, "RSIP");
975 col_add_str(pinfo->cinfo, COL_INFO,
976 val_to_str(msgtype, msg_type_vals,
977 "Unknown Message Type (0x%0x)"));
979 if (tree) {
980 ti = proto_tree_add_item(tree, proto_rsip, tvb, 0, -1, ENC_NA);
982 rsip_tree = proto_item_add_subtree(ti, ett_rsip);
984 proto_tree_add_item(rsip_tree,
985 hf_rsip_version, tvb, 0, 1, ENC_BIG_ENDIAN);
986 proto_tree_add_item(rsip_tree,
987 hf_rsip_message_type, tvb, 1, 1, ENC_BIG_ENDIAN);
988 proto_tree_add_item(rsip_tree,
989 hf_rsip_message_length, tvb, 2, 2, ENC_BIG_ENDIAN);
991 eoff = tvb_reported_length(tvb);
993 switch (msgtype) {
994 case 1: /* Error Response */
995 rsip_message_error_response(tvb, rsip_tree, 4, eoff);
996 break;
997 case 2: /* Register Request */
998 rsip_message_register_request(tvb, rsip_tree, 4, eoff);
999 break;
1000 case 3: /* Register Response */
1001 rsip_message_register_response(tvb, rsip_tree, 4, eoff);
1002 break;
1003 case 4: /* De-register Request */
1004 rsip_message_deregister_request(tvb, rsip_tree, 4, eoff);
1005 break;
1006 case 5: /* De-register Response */
1007 rsip_message_deregister_response(tvb, rsip_tree, 4, eoff);
1008 break;
1009 case 6: /* Assign Request RSA-IP */
1010 rsip_message_assign_request_rsaip(tvb, rsip_tree, 4, eoff);
1011 break;
1012 case 7: /* Assign Response RSA-IP */
1013 rsip_message_assign_response_rsaip(tvb, rsip_tree, 4, eoff);
1014 break;
1015 case 8: /* Assign Request RSAP-IP */
1016 rsip_message_assign_request_rsapip(tvb, rsip_tree, 4, eoff);
1017 break;
1018 case 9: /* Assign Response RSAP-IP */
1019 rsip_message_assign_response_rsapip(tvb, rsip_tree, 4, eoff);
1020 break;
1021 case 10: /* Extend Request */
1022 rsip_message_extend_request(tvb, rsip_tree, 4, eoff);
1023 break;
1024 case 11: /* Extend Response */
1025 rsip_message_extend_response(tvb, rsip_tree, 4, eoff);
1026 break;
1027 case 12: /* Free Request */
1028 rsip_message_free_request(tvb, rsip_tree, 4, eoff);
1029 break;
1030 case 13: /* Free Response */
1031 rsip_message_free_response(tvb, rsip_tree, 4, eoff);
1032 break;
1033 case 14: /* Query Request */
1034 rsip_message_query_request(tvb, rsip_tree, 4, eoff);
1035 break;
1036 case 15: /* Query Response */
1037 rsip_message_query_response(tvb, rsip_tree, 4, eoff);
1038 break;
1039 case 16: /* Listen Request */
1040 rsip_message_listen_request(tvb, rsip_tree, 4, eoff);
1041 break;
1042 case 17: /* Listen Response */
1043 rsip_message_listen_response(tvb, rsip_tree, 4, eoff);
1044 break;
1045 case 22: /* Assign Request RSIPsec */
1046 rsip_message_assign_request_rsipsec(tvb, rsip_tree, 4, eoff);
1047 break;
1048 case 23: /* Assign Response RSIPsec */
1049 rsip_message_assign_response_rsipsec(tvb, rsip_tree, 4, eoff);
1050 break;
1053 return tvb_captured_length(tvb);
1057 /* Register the protocol with Wireshark */
1058 void
1059 proto_register_rsip(void)
1062 static hf_register_info hf[] = {
1063 { &hf_rsip_version,
1064 { "Protocol version", "rsip.version",
1065 FT_UINT8, BASE_DEC, NULL, 0x0,
1066 NULL, HFILL }
1068 { &hf_rsip_message_type,
1069 { "Message type", "rsip.message_type",
1070 FT_UINT8, BASE_DEC, VALS(msg_type_appendix_vals), 0x0,
1071 NULL, HFILL }
1073 { &hf_rsip_message_length,
1074 { "Message length", "rsip.message_length",
1075 FT_UINT16, BASE_DEC, NULL, 0x0,
1076 NULL, HFILL }
1079 { &hf_rsip_parameter_type,
1080 { "Type", "rsip.parameter.type",
1081 FT_UINT8, BASE_DEC, VALS(param_type_vals), 0x0,
1082 NULL, HFILL }
1084 { &hf_rsip_parameter_length,
1085 { "Length", "rsip.parameter.length",
1086 FT_UINT16, BASE_DEC, NULL, 0x0,
1087 NULL, HFILL }
1089 { &hf_rsip_parameter_value,
1090 { "Value", "rsip.parameter.value",
1091 FT_BYTES, BASE_NONE, NULL, 0x0,
1092 NULL, HFILL }},
1094 { &hf_rsip_parameter_address_type,
1095 { "Address type", "rsip.parameter.address_type",
1096 FT_UINT8, BASE_DEC, VALS(addr_type_vals), 0x0,
1097 NULL, HFILL }
1099 { &hf_rsip_parameter_address_ipv4,
1100 { "IPv4 Address", "rsip.parameter.address",
1101 FT_IPv4, BASE_NONE, NULL, 0x0,
1102 NULL, HFILL }
1104 { &hf_rsip_parameter_address_ipv4_netmask,
1105 { "IPv4 Netmask", "rsip.parameter.netmask",
1106 FT_IPv4, BASE_NETMASK, NULL, 0x0,
1107 NULL, HFILL }
1109 { &hf_rsip_parameter_address_ipv6,
1110 { "IPv6 Address", "rsip.parameter.address.ipv6",
1111 FT_IPv6, BASE_NONE, NULL, 0x0,
1112 NULL, HFILL }
1114 { &hf_rsip_parameter_address_fqdn,
1115 { "Fully Qualified Domain Name", "rsip.parameter.fqdn",
1116 FT_STRING, BASE_NONE, NULL, 0x0,
1117 NULL, HFILL }
1120 { &hf_rsip_parameter_ports_number,
1121 { "Number", "rsip.parameter.ports.number",
1122 FT_UINT8, BASE_DEC, NULL, 0x0,
1123 NULL, HFILL }
1125 { &hf_rsip_parameter_ports_port_number,
1126 { "Port", "rsip.parameter.ports.port_number",
1127 FT_UINT16, BASE_DEC, NULL, 0x0,
1128 NULL, HFILL }
1131 { &hf_rsip_parameter_lease_time,
1132 { "Lease time", "rsip.parameter.lease_time",
1133 FT_UINT32, BASE_DEC, NULL, 0x0,
1134 NULL, HFILL }
1137 { &hf_rsip_parameter_client_id,
1138 { "Client ID", "rsip.parameter.client_id",
1139 FT_UINT32, BASE_DEC, NULL, 0x0,
1140 NULL, HFILL }
1143 { &hf_rsip_parameter_bind_id,
1144 { "Bind ID", "rsip.parameter.bind_id",
1145 FT_UINT32, BASE_DEC, NULL, 0x0,
1146 NULL, HFILL }
1149 { &hf_rsip_parameter_tunnel_type,
1150 { "Tunnel type", "rsip.parameter.tunnel_type",
1151 FT_UINT8, BASE_DEC, VALS(tunnel_type_vals), 0x0,
1152 NULL, HFILL }
1155 { &hf_rsip_parameter_method,
1156 { "Method", "rsip.method_param.method",
1157 FT_UINT8, BASE_DEC, VALS(method_vals), 0x0,
1158 NULL, HFILL }
1161 { &hf_rsip_parameter_error,
1162 { "Error", "rsip.parameter.error",
1163 FT_UINT16, BASE_DEC, VALS(error_number_vals), 0x0,
1164 NULL, HFILL }
1167 { &hf_rsip_parameter_flow_policy_local,
1168 { "Local Flow Policy", "rsip.parameter.local_flow_policy",
1169 FT_UINT8, BASE_DEC, VALS(lcl_flow_policy_vals), 0x0,
1170 NULL, HFILL }
1172 { &hf_rsip_parameter_flow_policy_remote,
1173 { "Remote Flow Policy", "rsip.parameter.remote_flow_policy",
1174 FT_UINT8, BASE_DEC, VALS(rmt_flow_policy_vals), 0x0,
1175 NULL, HFILL }
1178 { &hf_rsip_parameter_indicator,
1179 { "Value", "rsip.parameter.indicator",
1180 FT_UINT16, BASE_HEX, NULL, 0x0,
1181 NULL, HFILL }
1184 { &hf_rsip_parameter_message_counter,
1185 { "Counter", "rsip.parameter.message_counter",
1186 FT_UINT32, BASE_DEC, NULL, 0x0,
1187 NULL, HFILL }
1190 { &hf_rsip_parameter_vendor_specific_vendor_id,
1191 { "Vendor ID", "rsip.parameter.vendor_specific.vendor_id",
1192 FT_UINT16, BASE_DEC, NULL, 0x0,
1193 NULL, HFILL }
1195 { &hf_rsip_parameter_vendor_specific_subtype,
1196 { "Subtype", "rsip.parameter.vendor_specific.subtype",
1197 FT_UINT16, BASE_DEC, NULL, 0x0,
1198 NULL, HFILL }
1200 { &hf_rsip_parameter_vendor_specific_value,
1201 { "Value", "rsip.parameter.vendor_specific.value",
1202 FT_NONE, BASE_NONE, NULL, 0x0,
1203 NULL, HFILL }
1206 { &hf_rsip_parameter_spi_number,
1207 { "Number", "rsip.parameter.spi_number",
1208 FT_UINT16, BASE_DEC, NULL, 0x0,
1209 NULL, HFILL }
1211 { &hf_rsip_parameter_spi,
1212 { "SPI", "rsip.parameter.spi",
1213 FT_UINT32, BASE_HEX, NULL, 0x0,
1214 NULL, HFILL }
1218 static int *ett[] = {
1219 &ett_rsip,
1220 &ett_rsip_param,
1221 &ett_rsip_param_val
1224 proto_rsip = proto_register_protocol("Realm Specific IP Protocol",
1225 "RSIP", "rsip");
1227 proto_register_field_array(proto_rsip, hf, array_length(hf));
1228 proto_register_subtree_array(ett, array_length(ett));
1230 rsip_handle = register_dissector("rsip", dissect_rsip, proto_rsip);
1233 void
1234 proto_reg_handoff_rsip(void)
1236 dissector_add_uint_with_preference("udp.port", UDP_PORT_RSIP, rsip_handle);
1237 dissector_add_uint_with_preference("tcp.port", TCP_PORT_RSIP, rsip_handle);
1241 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1243 * Local variables:
1244 * c-basic-offset: 8
1245 * tab-width: 8
1246 * indent-tabs-mode: t
1247 * End:
1249 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1250 * :indentSize=8:tabSize=8:noTabs=false: