2 * Routines for Web Cache Communication Protocol dissection
3 * Jerry Talkington <jtalkington@users.sourceforge.net>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <epan/packet.h>
32 #include <epan/strutil.h>
33 #include <epan/emem.h>
34 #include <epan/expert.h>
35 #include "packet-wccp.h"
37 static int proto_wccp = -1;
38 static int hf_wccp_message_type = -1; /* the message type */
39 static int hf_wccp_version = -1; /* protocol version */
40 static int hf_wccp2_version = -1;
41 static int hf_hash_revision = -1; /* the version of the hash */
42 static int hf_change_num = -1; /* change number */
43 static int hf_hash_flag = -1;
44 static int hf_hash_flag_u = -1;
45 static int hf_recvd_id = -1;
46 static int hf_num_web_caches = -1;
47 static int hf_cache_ip = -1;
48 static int hf_item_header_length = -1;
49 static int hf_item_type = -1;
50 static int hf_item_length = -1;
51 static int hf_item_data = -1;
52 static int hf_security_option = -1;
53 static int hf_security_md5_checksum = -1;
54 static int hf_service_type = -1;
55 static int hf_service_id = -1;
56 static int hf_service_priority = -1;
57 static int hf_service_protocol = -1;
58 static int hf_service_flags = -1;
59 static int hf_service_flags_src_ip_hash = -1;
60 static int hf_service_flags_dest_ip_hash = -1;
61 static int hf_service_flags_src_port_hash = -1;
62 static int hf_service_flags_dest_port_hash = -1;
63 static int hf_service_flags_ports_defined = -1;
64 static int hf_service_flags_ports_source = -1;
65 static int hf_service_flags_src_ip_alt_hash = -1;
66 static int hf_service_flags_dest_ip_alt_hash = -1;
67 static int hf_service_flags_src_port_alt_hash = -1;
68 static int hf_service_flags_dest_port_alt_hash = -1;
69 static int hf_service_port = -1;
70 static int hf_router_identity_ip = -1;
71 static int hf_router_identity_receive_id = -1;
72 static int hf_router_send_to_ip = -1;
73 static int hf_router_num_recv_ip = -1;
74 static int hf_router_recv_ip = -1;
75 static int hf_web_cache_identity_ip = -1;
76 static int hf_web_cache_identity_hash_rev = -1;
77 static int hf_web_cache_identity_flags = -1;
78 static int hf_web_cache_identity_flag_hash_info = -1;
79 static int hf_web_cache_identity_flag_assign_type = -1;
80 static int hf_web_cache_identity_num_mask = -1;
81 static int hf_web_cache_identity_assign_mask = -1;
82 static int hf_web_cache_identity_assign_weight = -1;
83 static int hf_web_cache_identity_status = -1;
84 static int hf_assignment_key_ip = -1;
85 static int hf_assignment_key_change_num = -1;
86 static int hf_router_view_member_change_num = -1;
87 static int hf_router_router_num = -1;
88 static int hf_router_router_ip = -1;
89 static int hf_wc_view_info_change_num = -1;
90 static int hf_wc_view_router_num = -1;
91 static int hf_wc_view_ip = -1;
92 static int hf_router_assignment_element_ip = -1;
93 static int hf_router_assignment_element_receive_id = -1;
94 static int hf_router_assignment_element_change_num = -1;
95 static int hf_wccp2_assignment_info_router_num = -1;
96 static int hf_wccp2_assignment_info_ip = -1;
97 static int hf_router_query_info_ip = -1;
98 static int hf_router_query_info_receive_id = -1;
99 static int hf_router_query_info_send_to_ip = -1;
100 static int hf_router_query_info_target_ip = -1;
101 static int hf_capability_info_type = -1;
102 static int hf_capability_info_length = -1;
103 static int hf_capability_info_bytes = -1;
104 static int hf_capability_info_value = -1;
105 static int hf_capability_forwarding_method_flag_gre = -1;
106 static int hf_capability_forwarding_method_flag_l2 = -1;
107 static int hf_capability_assignment_method_flag_hash = -1;
108 static int hf_capability_assignment_method_flag_mask = -1;
109 static int hf_capability_return_method_flag_gre = -1;
110 static int hf_capability_return_method_flag_l2 = -1;
111 static int hf_wccp2_value_element_src_ip = -1;
112 static int hf_wccp2_value_element_dest_ip = -1;
113 static int hf_wccp2_value_element_src_port = -1;
114 static int hf_wccp2_value_element_dest_port = -1;
115 static int hf_wccp2_value_element_web_cache_ip = -1;
116 static int hf_wccp2_mask_value_set_element_src_ip = -1;
117 static int hf_wccp2_mask_value_set_element_dest_ip = -1;
118 static int hf_wccp2_mask_value_set_element_src_port = -1;
119 static int hf_wccp2_mask_value_set_element_dest_port = -1;
120 static int hf_wccp2_mask_value_set_element_num = -1;
121 static int hf_alt_assignment_info_assignment_type = -1;
122 static int hf_alt_assignment_info_assignment_length = -1;
123 static int hf_alt_assignment_info_num_routers = -1;
124 static int hf_alt_assignment_info_num_elements = -1;
126 static gint ett_wccp = -1;
127 static gint ett_cache_count = -1;
128 static gint ett_buckets = -1;
129 static gint ett_flags = -1;
130 static gint ett_cache_info = -1;
131 static gint ett_security_info = -1;
132 static gint ett_service_info = -1;
133 static gint ett_service_flags = -1;
134 static gint ett_router_identity_element = -1;
135 static gint ett_router_identity_info = -1;
136 static gint ett_wc_identity_element = -1;
137 static gint ett_wc_identity_info = -1;
138 static gint ett_router_view_info = -1;
139 static gint ett_wc_view_info = -1;
140 static gint ett_router_assignment_element = -1;
141 static gint ett_router_assignment_info = -1;
142 static gint ett_query_info = -1;
143 static gint ett_capabilities_info = -1;
144 static gint ett_capability_element = -1;
145 static gint ett_capability_forwarding_method = -1;
146 static gint ett_capability_assignment_method = -1;
147 static gint ett_capability_return_method = -1;
148 static gint ett_alt_assignment_info = -1;
149 static gint ett_mv_set_element = -1;
150 static gint ett_value_element = -1;
151 static gint ett_unknown_info = -1;
156 * http://www.alternic.org/drafts/drafts-f-g/draft-forster-wrec-wccp-v1-00.html
158 * is a copy of the now-expired Internet-Draft for WCCP 1.0.
162 * http://tools.ietf.org/id/draft-wilson-wrec-wccp-v2-01.txt
164 * is an Internet-Draft for WCCP 2.0.
167 /* This is NOT IANA assigned */
168 #define UDP_PORT_WCCP 2048
171 #define WCCPv2 0x0200
172 #define WCCP_HERE_I_AM 7
173 #define WCCP_I_SEE_YOU 8
174 #define WCCP_ASSIGN_BUCKET 9
175 #define WCCP2_HERE_I_AM 10
176 #define WCCP2_I_SEE_YOU 11
177 #define WCCP2_REDIRECT_ASSIGN 12
178 #define WCCP2_REMOVAL_QUERY 13
180 static const value_string wccp_type_vals[] = {
181 { WCCP_HERE_I_AM, "1.0 Here I am" },
182 { WCCP_I_SEE_YOU, "1.0 I see you" },
183 { WCCP_ASSIGN_BUCKET, "1.0 Assign bucket" },
184 { WCCP2_HERE_I_AM, "2.0 Here I am" },
185 { WCCP2_I_SEE_YOU, "2.0 I see you" },
186 { WCCP2_REDIRECT_ASSIGN, "2.0 Redirect assign" },
187 { WCCP2_REMOVAL_QUERY, "2.0 Removal query" },
191 static const value_string wccp_version_val[] = {
197 const true_false_string tfs_defined_not_defined = { "Defined", "Not defined" };
198 const true_false_string tfs_src_dest_port = { "Source port", "Destination port" };
199 const true_false_string tfs_historical_current = { "Historical", "Current" };
200 const true_false_string tfs_mask_hash = { "Mask", "Hash" };
202 #define HASH_INFO_SIZE (4*(1+8+1))
204 #define WCCP_U_FLAG 0x80000000
205 #define WCCP_T_FLAG 0x4000
207 #define WCCP2_SECURITY_INFO 0
208 #define WCCP2_SERVICE_INFO 1
209 #define WCCP2_ROUTER_ID_INFO 2
210 #define WCCP2_WC_ID_INFO 3
211 #define WCCP2_RTR_VIEW_INFO 4
212 #define WCCP2_WC_VIEW_INFO 5
213 #define WCCP2_REDIRECT_ASSIGNMENT 6
214 #define WCCP2_QUERY_INFO 7
215 #define WCCP2_CAPABILITIES_INFO 8
216 #define WCCP2_ALT_ASSIGNMENT 13
217 #define WCCP2_ASSIGN_MAP 14
218 #define WCCP2_COMMAND_EXTENSION 15
220 static const value_string info_type_vals[] = {
221 { WCCP2_SECURITY_INFO, "Security Info" },
222 { WCCP2_SERVICE_INFO, "Service Info" },
223 { WCCP2_ROUTER_ID_INFO, "Router Identity Info" },
224 { WCCP2_WC_ID_INFO, "Web-Cache Identity Info" },
225 { WCCP2_RTR_VIEW_INFO, "Router View Info" },
226 { WCCP2_WC_VIEW_INFO, "Web-Cache View Info" },
227 { WCCP2_REDIRECT_ASSIGNMENT, "Assignment Info" },
228 { WCCP2_QUERY_INFO, "Query Info" },
229 { WCCP2_CAPABILITIES_INFO, "Capabilities Info" },
230 { WCCP2_ALT_ASSIGNMENT, "Alternate Assignment" },
231 { WCCP2_ASSIGN_MAP, "Assignment Map" },
232 { WCCP2_COMMAND_EXTENSION, "Command Extension" },
236 const value_string service_id_vals[] = {
241 typedef struct capability_flag {
243 const char *short_name;
247 static void dissect_hash_data(tvbuff_t *tvb, int offset,
248 proto_tree *wccp_tree);
249 static void dissect_web_cache_list_entry(tvbuff_t *tvb, int offset,
250 int idx, proto_tree *wccp_tree);
251 static guint32 wccp_bucket_info(guint8 bucket_info, proto_tree *bucket_tree,
252 guint32 start, tvbuff_t *tvb, int offset);
253 static gchar *bucket_name(guint8 bucket);
254 static guint16 dissect_wccp2_header(tvbuff_t *tvb, int offset,
255 proto_tree *wccp_tree);
256 static void dissect_wccp2_info(tvbuff_t *tvb, int offset, guint16 length,
257 packet_info *pinfo, proto_tree *wccp_tree);
258 static gboolean dissect_wccp2_security_info(tvbuff_t *tvb, int offset,
259 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
260 static gboolean dissect_wccp2_service_info(tvbuff_t *tvb, int offset,
261 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
262 static gboolean dissect_wccp2_router_identity_info(tvbuff_t *tvb, int offset,
263 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
264 static gboolean dissect_wccp2_wc_identity_info(tvbuff_t *tvb, int offset,
265 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
266 static gboolean dissect_wccp2_router_view_info(tvbuff_t *tvb, int offset,
267 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
268 static gboolean dissect_wccp2_wc_view_info(tvbuff_t *tvb, int offset,
269 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
270 static gboolean dissect_wccp2_assignment_info(tvbuff_t *tvb, int offset,
271 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
272 static gboolean dissect_wccp2_router_query_info(tvbuff_t *tvb, int offset,
273 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
274 static gboolean dissect_wccp2_capability_info(tvbuff_t *tvb, int offset,
275 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
276 static void dissect_32_bit_capability_flags(tvbuff_t *tvb, int curr_offset,
277 guint16 capability_val_len, packet_info *pinfo, gint ett, const capability_flag *flags,
278 proto_tree *element_tree, proto_item *element_item);
279 static gboolean dissect_wccp2_alt_assignment_info(tvbuff_t *tvb, int offset,
280 int length, packet_info *pinfo, proto_tree *info_tree, proto_item *info_item);
283 dissect_wccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
286 proto_tree *wccp_tree = NULL;
287 proto_item *wccp_tree_item;
288 guint32 wccp_message_type;
294 wccp_message_type = tvb_get_ntohl(tvb, offset);
296 /* Check if this is really a WCCP message */
297 if (match_strval(wccp_message_type, wccp_type_vals) == NULL)
300 col_set_str(pinfo->cinfo, COL_PROTOCOL, "WCCP");
301 col_clear(pinfo->cinfo, COL_INFO);
304 if(check_col(pinfo->cinfo, COL_INFO)) {
305 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(wccp_message_type,
306 wccp_type_vals, "Unknown WCCP message (%u)"));
310 wccp_tree_item = proto_tree_add_item(tree, proto_wccp, tvb, offset,
312 wccp_tree = proto_item_add_subtree(wccp_tree_item, ett_wccp);
314 proto_tree_add_uint(wccp_tree, hf_wccp_message_type, tvb, offset,
315 4, wccp_message_type);
318 switch (wccp_message_type) {
321 proto_tree_add_item(wccp_tree, hf_wccp_version, tvb, offset, 4, ENC_BIG_ENDIAN);
323 dissect_hash_data(tvb, offset, wccp_tree);
324 offset += HASH_INFO_SIZE;
325 proto_tree_add_item(wccp_tree, hf_recvd_id, tvb, offset,
331 proto_tree_add_item(wccp_tree, hf_wccp_version, tvb, offset, 4, ENC_BIG_ENDIAN);
333 proto_tree_add_item(wccp_tree, hf_change_num, tvb, offset, 4, ENC_BIG_ENDIAN);
335 proto_tree_add_item(wccp_tree, hf_recvd_id, tvb, offset, 4, ENC_BIG_ENDIAN);
337 cache_count = tvb_get_ntohl(tvb, offset);
338 proto_tree_add_uint(wccp_tree, hf_num_web_caches, tvb, offset, 4, cache_count);
340 for (i = 0; i < cache_count; i++) {
341 dissect_web_cache_list_entry(tvb, offset, i, wccp_tree);
342 offset += 4 + HASH_INFO_SIZE;
346 case WCCP_ASSIGN_BUCKET:
348 * This hasn't been tested, since I don't have any
349 * traces with this in it.
351 * The V1 spec claims that this does, indeed,
352 * have a Received ID field after the type,
353 * rather than a Version field.
355 proto_tree_add_item(wccp_tree, hf_recvd_id, tvb, offset, 4, ENC_BIG_ENDIAN);
357 cache_count = tvb_get_ntohl(tvb, offset);
358 proto_tree_add_uint(wccp_tree, hf_num_web_caches, tvb, offset, 4, cache_count);
360 for (i = 0; i < cache_count; i++) {
361 ipaddr = tvb_get_ipv4(tvb, offset);
362 proto_tree_add_ipv4_format(wccp_tree,
363 hf_cache_ip, tvb, offset, 4,
365 "Web Cache %d IP Address: %s", i,
366 ip_to_str((guint8 *)&ipaddr));
369 for (i = 0; i < 256; i += 4) {
370 proto_tree_add_text(wccp_tree, tvb, offset, 4,
371 "Buckets %d - %d: %10s %10s %10s %10s",
373 bucket_name(tvb_get_guint8(tvb, offset)),
374 bucket_name(tvb_get_guint8(tvb, offset+1)),
375 bucket_name(tvb_get_guint8(tvb, offset+2)),
376 bucket_name(tvb_get_guint8(tvb, offset+3)));
381 case WCCP2_HERE_I_AM:
382 case WCCP2_I_SEE_YOU:
383 case WCCP2_REMOVAL_QUERY:
384 case WCCP2_REDIRECT_ASSIGN:
385 default: /* assume unknown packets are v2 */
386 length = dissect_wccp2_header(tvb, offset, wccp_tree);
388 dissect_wccp2_info(tvb, offset, length, pinfo, wccp_tree);
393 return(tvb_length(tvb));
397 dissect_hash_data(tvbuff_t *tvb, int offset, proto_tree *wccp_tree)
399 proto_item *bucket_item;
400 proto_tree *bucket_tree;
402 proto_tree *field_tree;
406 proto_tree_add_item(wccp_tree, hf_hash_revision, tvb, offset, 4,
410 bucket_item = proto_tree_add_text(wccp_tree, tvb, offset, 32,
412 bucket_tree = proto_item_add_subtree(bucket_item, ett_buckets);
414 for (i = 0, n = 0; i < 32; i++) {
415 bucket_info = tvb_get_guint8(tvb, offset);
416 n = wccp_bucket_info(bucket_info, bucket_tree, n, tvb, offset);
420 tf = proto_tree_add_item(wccp_tree, hf_hash_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
421 field_tree = proto_item_add_subtree(tf, ett_flags);
422 proto_tree_add_item(field_tree, hf_hash_flag_u, tvb, offset, 4, ENC_BIG_ENDIAN);
426 dissect_web_cache_list_entry(tvbuff_t *tvb, int offset, int idx,
427 proto_tree *wccp_tree)
430 proto_tree *list_entry_tree;
432 tl = proto_tree_add_text(wccp_tree, tvb, offset, 4 + HASH_INFO_SIZE,
433 "Web-Cache List Entry(%d)", idx);
434 list_entry_tree = proto_item_add_subtree(tl, ett_cache_info);
435 proto_tree_add_item(list_entry_tree, hf_cache_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
436 dissect_hash_data(tvb, offset + 4, list_entry_tree);
441 * takes an integer representing a "Hash Information" bitmap, and spits out
442 * the corresponding proto_tree entries, returning the next bucket number.
445 wccp_bucket_info(guint8 bucket_info, proto_tree *bucket_tree, guint32 start,
446 tvbuff_t *tvb, int offset)
450 for(i = 0; i < 8; i++) {
451 proto_tree_add_text(bucket_tree, tvb, offset, sizeof(bucket_info), "Bucket %3d: %s", start, (bucket_info & 1<<i ? "Assigned" : "Not Assigned") );
458 bucket_name(guint8 bucket)
462 if (bucket == 0xff) {
465 cur=ep_strdup_printf("%u", bucket);
471 dissect_wccp2_header(tvbuff_t *tvb, int offset, proto_tree *wccp_tree)
475 proto_tree_add_item(wccp_tree, hf_wccp2_version, tvb, offset, 2, ENC_BIG_ENDIAN);
477 length = tvb_get_ntohs(tvb, offset);
478 proto_tree_add_uint(wccp_tree, hf_item_header_length, tvb, offset, 2, length);
483 dissect_wccp2_info(tvbuff_t *tvb, int offset, guint16 length,
484 packet_info *pinfo, proto_tree *wccp_tree)
489 proto_tree *info_tree;
491 gboolean (*dissector)(tvbuff_t *, int, int, packet_info *, proto_tree *, proto_item *);
493 while (length != 0) {
494 type = tvb_get_ntohs(tvb, offset);
495 item_length = tvb_get_ntohs(tvb, offset+2);
499 case WCCP2_SECURITY_INFO:
500 ett = ett_security_info;
501 dissector = dissect_wccp2_security_info;
504 case WCCP2_SERVICE_INFO:
505 ett = ett_service_info;
506 dissector = dissect_wccp2_service_info;
509 case WCCP2_ROUTER_ID_INFO:
510 ett = ett_router_identity_info;
511 dissector = dissect_wccp2_router_identity_info;
514 case WCCP2_WC_ID_INFO:
515 ett = ett_wc_identity_info;
516 dissector = dissect_wccp2_wc_identity_info;
519 case WCCP2_RTR_VIEW_INFO:
520 ett = ett_router_view_info;
521 dissector = dissect_wccp2_router_view_info;
524 case WCCP2_WC_VIEW_INFO:
525 ett = ett_wc_view_info;
526 dissector = dissect_wccp2_wc_view_info;
529 case WCCP2_REDIRECT_ASSIGNMENT:
530 ett = ett_router_assignment_info;
531 dissector = dissect_wccp2_assignment_info;
534 case WCCP2_QUERY_INFO:
535 ett = ett_query_info;
536 dissector = dissect_wccp2_router_query_info;
539 case WCCP2_CAPABILITIES_INFO:
540 ett = ett_capabilities_info;
541 dissector = dissect_wccp2_capability_info;
544 case WCCP2_ALT_ASSIGNMENT:
545 ett = ett_alt_assignment_info;
546 dissector = dissect_wccp2_alt_assignment_info;
549 case WCCP2_ASSIGN_MAP:
550 case WCCP2_COMMAND_EXTENSION:
552 ett = ett_unknown_info;
557 ti = proto_tree_add_text(wccp_tree, tvb, offset, item_length + 4, "Message Component (%s)",
558 val_to_str(type, info_type_vals, "Unknown info type (%u)"));
559 info_tree = proto_item_add_subtree(ti, ett);
560 proto_tree_add_item(info_tree, hf_item_type, tvb, offset, 2, ENC_BIG_ENDIAN);
561 proto_tree_add_item(info_tree, hf_item_length, tvb, offset+2, 2, ENC_BIG_ENDIAN);
567 * XXX - pass in "length" and check for that as well.
569 if (dissector != NULL) {
570 if (!(*dissector)(tvb, offset, item_length, pinfo, info_tree, ti))
571 return; /* ran out of data */
573 proto_tree_add_item(info_tree, hf_item_data, tvb, offset, item_length, ENC_NA);
575 offset += item_length;
576 length -= item_length;
580 #define SECURITY_INFO_LEN 4
582 #define WCCP2_NO_SECURITY 0
583 #define WCCP2_MD5_SECURITY 1
585 const value_string security_option_vals[] = {
586 { WCCP2_NO_SECURITY, "None" },
587 { WCCP2_MD5_SECURITY, "MD5" },
592 dissect_wccp2_security_info(tvbuff_t *tvb, int offset, int length,
593 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item)
595 guint32 security_option;
597 if (length < SECURITY_INFO_LEN) {
598 expert_add_info_format(pinfo, info_item, PI_PROTOCOL, PI_WARN,
599 "Item length is %u, should be >= %u", length, SECURITY_INFO_LEN);
603 security_option = tvb_get_ntohl(tvb, offset);
604 proto_tree_add_item(info_tree, hf_security_option, tvb, offset, 4, ENC_BIG_ENDIAN);
605 if (security_option == WCCP2_MD5_SECURITY) {
606 proto_tree_add_item(info_tree, hf_security_md5_checksum, tvb, offset+4, length-4, ENC_NA);
612 #define SERVICE_INFO_LEN (4+4+8*2)
614 #define WCCP2_SERVICE_STANDARD 0
615 #define WCCP2_SERVICE_DYNAMIC 1
617 const value_string service_type_vals[] = {
618 { WCCP2_SERVICE_STANDARD, "Well-known service" },
619 { WCCP2_SERVICE_DYNAMIC, "Dynamic service" },
626 #define WCCP2_SI_SRC_IP_HASH 0x0001
627 #define WCCP2_SI_DST_IP_HASH 0x0002
628 #define WCCP2_SI_SRC_PORT_HASH 0x0004
629 #define WCCP2_SI_DST_PORT_HASH 0x0008
630 #define WCCP2_SI_PORTS_DEFINED 0x0010
631 #define WCCP2_SI_PORTS_SOURCE 0x0020
632 #define WCCP2_SI_SRC_IP_ALT_HASH 0x0100
633 #define WCCP2_SI_DST_IP_ALT_HASH 0x0200
634 #define WCCP2_SI_SRC_PORT_ALT_HASH 0x0400
635 #define WCCP2_SI_DST_PORT_ALT_HASH 0x0800
638 dissect_wccp2_service_info(tvbuff_t *tvb, int offset, int length,
639 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item)
646 proto_tree *field_tree;
649 if (length != SERVICE_INFO_LEN) {
650 expert_add_info_format(pinfo, info_item, PI_PROTOCOL, PI_WARN,
651 "Item length is %u, should be %u", length, SERVICE_INFO_LEN);
655 service_type = tvb_get_guint8(tvb, offset);
656 proto_tree_add_item(info_tree, hf_service_type, tvb, offset, 1, ENC_BIG_ENDIAN);
657 switch (service_type) {
659 case WCCP2_SERVICE_STANDARD:
660 proto_tree_add_item(info_tree, hf_service_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
661 tf = proto_tree_add_item(info_tree, hf_service_priority, tvb, offset+2, 1, ENC_BIG_ENDIAN);
662 priority = tvb_get_guint8(tvb, offset+2);
664 expert_add_info_format(pinfo, tf, PI_PROTOCOL, PI_WARN,
665 "The priority must be zero for well-known services.");
666 tf = proto_tree_add_item(info_tree, hf_service_protocol, tvb, offset+3, 1, ENC_BIG_ENDIAN);
667 protocol = tvb_get_guint8(tvb, offset+3);
669 expert_add_info_format(pinfo, tf, PI_PROTOCOL, PI_WARN,
670 "The protocol must be zero for well-known services.");
673 case WCCP2_SERVICE_DYNAMIC:
674 proto_tree_add_item(info_tree, hf_service_id, tvb, offset+1, 1, ENC_BIG_ENDIAN);
675 proto_tree_add_item(info_tree, hf_service_priority, tvb, offset+2, 1, ENC_BIG_ENDIAN);
677 * XXX - does "IP protocol identifier" mean this is a
678 * protocol type of the sort you get in IP headers?
679 * If so, we should get a table of those from the
680 * IP dissector, and use that.
682 proto_tree_add_item(info_tree, hf_service_protocol, tvb, offset+3, 1, ENC_BIG_ENDIAN);
687 flags = tvb_get_ntohl(tvb, offset);
688 tf = proto_tree_add_item(info_tree, hf_service_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
689 field_tree = proto_item_add_subtree(tf, ett_service_flags);
691 proto_tree_add_item(field_tree, hf_service_flags_src_ip_hash, tvb, offset, 4, ENC_BIG_ENDIAN);
692 proto_tree_add_item(field_tree, hf_service_flags_dest_ip_hash, tvb, offset, 4, ENC_BIG_ENDIAN);
693 proto_tree_add_item(field_tree, hf_service_flags_src_port_hash, tvb, offset, 4, ENC_BIG_ENDIAN);
694 proto_tree_add_item(field_tree, hf_service_flags_dest_port_hash, tvb, offset, 4, ENC_BIG_ENDIAN);
695 proto_tree_add_item(field_tree, hf_service_flags_ports_defined, tvb, offset, 4, ENC_BIG_ENDIAN);
696 if (flags & WCCP2_SI_PORTS_DEFINED)
697 proto_tree_add_item(field_tree, hf_service_flags_ports_source, tvb, offset, 4, ENC_BIG_ENDIAN);
698 proto_tree_add_item(field_tree, hf_service_flags_src_ip_alt_hash, tvb, offset, 4, ENC_BIG_ENDIAN);
699 proto_tree_add_item(field_tree, hf_service_flags_dest_ip_alt_hash, tvb, offset, 4, ENC_BIG_ENDIAN);
700 proto_tree_add_item(field_tree, hf_service_flags_src_port_alt_hash, tvb, offset, 4, ENC_BIG_ENDIAN);
701 proto_tree_add_item(field_tree, hf_service_flags_dest_port_alt_hash, tvb, offset, 4, ENC_BIG_ENDIAN);
704 if (flags & WCCP2_SI_PORTS_DEFINED) {
705 for (i = 0; i < 8; i++) {
706 proto_tree_add_item(info_tree, hf_service_port, tvb, offset, 2, ENC_BIG_ENDIAN);
714 #define ROUTER_ID_INFO_MIN_LEN (8+4+4)
717 dissect_wccp2_router_identity_element(tvbuff_t *tvb, int offset,
720 proto_tree_add_item(tree, hf_router_identity_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
721 proto_tree_add_item(tree, hf_router_identity_receive_id, tvb, offset+4, 4, ENC_BIG_ENDIAN);
725 dissect_wccp2_router_identity_info(tvbuff_t *tvb, int offset, int length,
726 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item)
728 guint32 n_received_from;
731 proto_tree *element_tree;
733 if (length < ROUTER_ID_INFO_MIN_LEN) {
734 expert_add_info_format(pinfo, info_item, PI_PROTOCOL, PI_WARN,
735 "Item length is %u, should be >= %u", length, ROUTER_ID_INFO_MIN_LEN);
739 te = proto_tree_add_text(info_tree, tvb, offset, 8,
740 "Router Identity Element: IP address %s",
741 tvb_ip_to_str(tvb, offset));
742 element_tree = proto_item_add_subtree(te, ett_router_identity_element);
743 dissect_wccp2_router_identity_element(tvb, offset, element_tree);
746 proto_tree_add_item(info_tree, hf_router_send_to_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
749 n_received_from = tvb_get_ntohl(tvb, offset);
750 proto_tree_add_item(info_tree, hf_router_num_recv_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
752 for (i = 0; i < n_received_from; i++) {
753 proto_tree_add_ipv4_format_value(info_tree, hf_router_recv_ip, tvb, offset, 4,
754 tvb_get_ipv4(tvb, offset), "Received From IP Address %d: %s", i,
755 tvb_ip_to_str(tvb, offset));
762 #define WC_ID_INFO_LEN (4+4+8*4+4)
765 dissect_wccp2_web_cache_identity_element(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int length)
767 proto_item *bucket_item;
768 proto_tree *bucket_tree;
770 proto_tree *field_tree;
772 guint32 i, n, num_masks;
775 proto_tree_add_item(tree, hf_web_cache_identity_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
777 proto_tree_add_item(tree, hf_web_cache_identity_hash_rev, tvb, offset, 2, ENC_BIG_ENDIAN);
780 flags = tvb_get_ntohs(tvb, offset);
781 tf = proto_tree_add_uint(tree, hf_web_cache_identity_flags, tvb, offset, 2, flags);
782 field_tree = proto_item_add_subtree(tf, ett_flags);
783 proto_tree_add_item(field_tree, hf_web_cache_identity_flag_hash_info, tvb, offset, 2, ENC_BIG_ENDIAN);
784 proto_tree_add_item(field_tree, hf_web_cache_identity_flag_assign_type, tvb, offset, 2, ENC_BIG_ENDIAN);
787 if (flags & WCCP_T_FLAG) {
788 bucket_item = proto_tree_add_text(tree, tvb, offset, 8*4, "Mask Assignment information");
789 bucket_tree = proto_item_add_subtree(bucket_item, ett_buckets);
791 num_masks = tvb_get_ntohl(tvb, offset);
792 proto_tree_add_uint(bucket_tree, hf_web_cache_identity_num_mask, tvb, offset, 4, num_masks);
794 for (i = 0; i < num_masks; i++) {
795 proto_tree_add_item(bucket_tree, hf_web_cache_identity_assign_mask, tvb, offset, 4, ENC_BIG_ENDIAN);
800 if (length != WC_ID_INFO_LEN) {
801 expert_add_info_format(pinfo, tf, PI_PROTOCOL, PI_WARN,
802 "Item length is %u, should be %u", length, WC_ID_INFO_LEN);
806 bucket_item = proto_tree_add_text(tree, tvb, offset, 8*4, "Hash information");
807 bucket_tree = proto_item_add_subtree(bucket_item, ett_buckets);
808 for (i = 0, n = 0; i < 32; i++) {
809 bucket_info = tvb_get_guint8(tvb, offset);
810 n = wccp_bucket_info(bucket_info, bucket_tree, n, tvb, offset);
815 proto_tree_add_item(tree, hf_web_cache_identity_assign_weight, tvb, offset, 2, ENC_BIG_ENDIAN);
817 proto_tree_add_item(tree, hf_web_cache_identity_status, tvb, offset, 2, ENC_BIG_ENDIAN);
822 dissect_wccp2_wc_identity_info(tvbuff_t *tvb, int offset, int length,
823 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item _U_)
826 proto_tree *element_tree;
828 te = proto_tree_add_text(info_tree, tvb, offset, length,
829 "Web-Cache Identity Element: IP address %s",
830 tvb_ip_to_str(tvb, offset));
831 element_tree = proto_item_add_subtree(te, ett_wc_identity_element);
832 if (!dissect_wccp2_web_cache_identity_element(tvb, offset, pinfo, element_tree, length))
833 return FALSE; /* ran out of data */
838 #define ROUTER_VIEW_INFO_MIN_LEN (4+8+4)
841 dissect_wccp2_assignment_key(tvbuff_t *tvb, int offset,
842 proto_tree *info_tree)
844 proto_tree_add_item(info_tree, hf_assignment_key_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
845 proto_tree_add_item(info_tree, hf_assignment_key_change_num, tvb, offset+4, 4, ENC_BIG_ENDIAN);
849 dissect_wccp2_router_view_info(tvbuff_t *tvb, int offset, int length,
850 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item)
853 guint32 n_web_caches;
856 proto_tree *element_tree;
858 if (length < ROUTER_VIEW_INFO_MIN_LEN) {
859 expert_add_info_format(pinfo, info_item, PI_PROTOCOL, PI_WARN,
860 "Item length is %u, should be >= %u", length, ROUTER_VIEW_INFO_MIN_LEN);
864 proto_tree_add_item(info_tree, hf_router_view_member_change_num, tvb, offset, 4, ENC_BIG_ENDIAN);
867 dissect_wccp2_assignment_key(tvb, offset, info_tree);
870 n_routers = tvb_get_ntohl(tvb, offset);
871 proto_tree_add_uint(info_tree, hf_router_router_num, tvb, offset, 4, n_routers);
874 for (i = 0; i < n_routers; i++) {
875 proto_tree_add_ipv4_format_value(info_tree, hf_router_router_ip, tvb, offset, 4,
876 tvb_get_ipv4(tvb, offset), "Router %d IP Address: %s", i,
877 tvb_ip_to_str(tvb, offset));
881 n_web_caches = tvb_get_ntohl(tvb, offset);
882 proto_tree_add_uint(info_tree, hf_num_web_caches, tvb, offset, 4, n_web_caches);
885 for (i = 0; i < n_web_caches; i++) {
886 te = proto_tree_add_text(info_tree, tvb, offset, WC_ID_INFO_LEN,
887 "Web-Cache Identity Element %d: IP address %s", i,
888 tvb_ip_to_str(tvb, offset));
889 element_tree = proto_item_add_subtree(te, ett_wc_identity_element);
890 if (!dissect_wccp2_web_cache_identity_element(tvb, offset, pinfo, element_tree, WC_ID_INFO_LEN))
891 return FALSE; /* ran out of data */
892 offset += WC_ID_INFO_LEN;
898 #define WC_VIEW_INFO_MIN_LEN (4+4)
901 dissect_wccp2_wc_view_info(tvbuff_t *tvb, int offset, int length,
902 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item)
905 guint32 n_web_caches;
908 proto_tree *element_tree;
910 if (length < WC_VIEW_INFO_MIN_LEN) {
911 expert_add_info_format(pinfo, info_item, PI_PROTOCOL, PI_WARN,
912 "Item length is %u, should be >= %u", length, WC_VIEW_INFO_MIN_LEN);
916 proto_tree_add_item(info_tree, hf_wc_view_info_change_num, tvb, offset, 4, ENC_BIG_ENDIAN);
919 n_routers = tvb_get_ntohl(tvb, offset);
920 proto_tree_add_uint(info_tree, hf_wc_view_router_num, tvb, offset, 4, n_routers);
923 for (i = 0; i < n_routers; i++) {
924 te = proto_tree_add_text(info_tree, tvb, offset, 8,
925 "Router %d Identity Element: IP address %s", i,
926 tvb_ip_to_str(tvb, offset));
927 element_tree = proto_item_add_subtree(te, ett_router_identity_element);
928 dissect_wccp2_router_identity_element(tvb, offset, element_tree);
932 n_web_caches = tvb_get_ntohl(tvb, offset);
933 proto_tree_add_uint(info_tree, hf_num_web_caches, tvb, offset, 4, n_web_caches);
936 for (i = 0; i < n_web_caches; i++) {
937 proto_tree_add_ipv4_format_value(info_tree, hf_wc_view_ip, tvb, offset, 4,
938 tvb_get_ipv4(tvb, offset), "Web-Cache %d IP Address: %s", i,
939 tvb_ip_to_str(tvb, offset));
946 #define ASSIGNMENT_INFO_MIN_LEN (8+4)
949 dissect_wccp2_router_assignment_element(tvbuff_t *tvb, int offset,
952 proto_tree_add_item(tree, hf_router_assignment_element_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
953 proto_tree_add_item(tree, hf_router_assignment_element_receive_id, tvb, offset+4, 4, ENC_BIG_ENDIAN);
954 proto_tree_add_item(tree, hf_router_assignment_element_change_num, tvb, offset+8, 4, ENC_BIG_ENDIAN);
958 assignment_bucket_name(guint8 bucket)
962 if (bucket == 0xff) {
965 cur=ep_strdup_printf("%u%s", bucket >> 1,
966 (bucket & 0x01) ? " (Alt)" : "");
972 dissect_wccp2_assignment_info(tvbuff_t *tvb, int offset, int length,
973 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item)
976 guint32 n_web_caches;
979 proto_tree *element_tree;
981 if (length < ASSIGNMENT_INFO_MIN_LEN) {
982 expert_add_info_format(pinfo, info_item, PI_PROTOCOL, PI_WARN,
983 "Item length is %u, should be >= %u", length, ASSIGNMENT_INFO_MIN_LEN);
987 dissect_wccp2_assignment_key(tvb, offset, info_tree);
990 n_routers = tvb_get_ntohl(tvb, offset);
991 proto_tree_add_uint(info_tree, hf_wccp2_assignment_info_router_num, tvb, offset, 4, n_routers);
994 for (i = 0; i < n_routers; i++) {
995 te = proto_tree_add_text(info_tree, tvb, offset, 4,
996 "Router %d Assignment Element: IP address %s", i,
997 tvb_ip_to_str(tvb, offset));
998 element_tree = proto_item_add_subtree(te, ett_router_assignment_element);
999 dissect_wccp2_router_assignment_element(tvb, offset, element_tree);
1003 n_web_caches = tvb_get_ntohl(tvb, offset);
1004 proto_tree_add_uint(info_tree, hf_num_web_caches, tvb, offset, 4, n_web_caches);
1007 for (i = 0; i < n_web_caches; i++) {
1008 proto_tree_add_ipv4_format_value(info_tree, hf_wccp2_assignment_info_ip, tvb, offset, 4,
1009 tvb_get_ipv4(tvb, offset), "Web-Cache %d IP Address: %s", i,
1010 tvb_ip_to_str(tvb, offset));
1014 for (i = 0; i < 256; i += 4) {
1015 proto_tree_add_text(info_tree, tvb, offset, 4,
1016 "Buckets %d - %d: %10s %10s %10s %10s",
1018 assignment_bucket_name(tvb_get_guint8(tvb, offset)),
1019 assignment_bucket_name(tvb_get_guint8(tvb, offset+1)),
1020 assignment_bucket_name(tvb_get_guint8(tvb, offset+2)),
1021 assignment_bucket_name(tvb_get_guint8(tvb, offset+3)));
1028 #define QUERY_INFO_LEN (4+4+4+4)
1031 dissect_wccp2_router_query_info(tvbuff_t *tvb, int offset, int length,
1032 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item)
1034 if (length != QUERY_INFO_LEN) {
1035 expert_add_info_format(pinfo, info_item, PI_PROTOCOL, PI_WARN,
1036 "Item length is %u, should be %u", length, QUERY_INFO_LEN);
1040 proto_tree_add_item(info_tree, hf_router_query_info_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
1041 proto_tree_add_item(info_tree, hf_router_query_info_receive_id, tvb, offset+4, 4, ENC_BIG_ENDIAN);
1042 proto_tree_add_item(info_tree, hf_router_query_info_send_to_ip, tvb, offset+8, 4, ENC_BIG_ENDIAN);
1043 proto_tree_add_item(info_tree, hf_router_query_info_target_ip, tvb, offset+12, 4, ENC_BIG_ENDIAN);
1048 #define WCCP2_FORWARDING_METHOD 0x01
1049 #define WCCP2_ASSIGNMENT_METHOD 0x02
1050 #define WCCP2_PACKET_RETURN_METHOD 0x03
1052 static const value_string capability_type_vals[] = {
1053 { WCCP2_FORWARDING_METHOD, "Forwarding Method" },
1054 { WCCP2_ASSIGNMENT_METHOD, "Assignment Method" },
1055 { WCCP2_PACKET_RETURN_METHOD, "Return Method" },
1059 #define WCCP2_FORWARDING_METHOD_GRE 0x00000001
1060 #define WCCP2_FORWARDING_METHOD_L2 0x00000002
1062 static const capability_flag forwarding_method_flags[] = {
1063 { WCCP2_FORWARDING_METHOD_GRE, "IP-GRE", &hf_capability_forwarding_method_flag_gre },
1064 { WCCP2_FORWARDING_METHOD_L2, "L2", &hf_capability_forwarding_method_flag_l2 },
1068 #define WCCP2_ASSIGNMENT_METHOD_HASH 0x00000001
1069 #define WCCP2_ASSIGNMENT_METHOD_MASK 0x00000002
1071 static const capability_flag assignment_method_flags[] = {
1072 { WCCP2_ASSIGNMENT_METHOD_HASH, "Hash", &hf_capability_assignment_method_flag_hash },
1073 { WCCP2_ASSIGNMENT_METHOD_MASK, "Mask", &hf_capability_assignment_method_flag_mask },
1077 #define WCCP2_PACKET_RETURN_METHOD_GRE 0x00000001
1078 #define WCCP2_PACKET_RETURN_METHOD_L2 0x00000002
1080 static const capability_flag packet_return_method_flags[] = {
1081 { WCCP2_PACKET_RETURN_METHOD_GRE, "IP-GRE", &hf_capability_return_method_flag_gre },
1082 { WCCP2_PACKET_RETURN_METHOD_L2, "L2", &hf_capability_return_method_flag_l2 },
1087 dissect_wccp2_capability_info(tvbuff_t *tvb, int offset, int length,
1088 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item _U_)
1090 guint16 capability_type;
1091 guint16 capability_val_len;
1094 proto_tree *element_tree;
1096 for (curr_offset = offset; curr_offset < (length + offset);
1097 curr_offset += (capability_val_len + 4)) {
1098 capability_type = tvb_get_ntohs(tvb, curr_offset);
1099 capability_val_len = tvb_get_ntohs(tvb, curr_offset + 2);
1101 te = proto_tree_add_item(info_tree, hf_capability_info_type, tvb, curr_offset, 2, ENC_BIG_ENDIAN);
1102 proto_item_set_len(te, capability_val_len + 4);
1103 element_tree = proto_item_add_subtree(te, ett_capability_element);
1104 if (capability_val_len < 4) {
1105 expert_add_info_format(pinfo, te, PI_PROTOCOL, PI_WARN,
1106 "Value Length: %u (illegal, must be >= 4)", capability_val_len);
1110 proto_tree_add_uint(element_tree, hf_capability_info_length, tvb, curr_offset+2, 2, capability_val_len);
1111 switch (capability_type) {
1113 case WCCP2_FORWARDING_METHOD:
1114 dissect_32_bit_capability_flags(tvb, curr_offset,
1115 capability_val_len, pinfo,
1116 ett_capability_forwarding_method,
1117 forwarding_method_flags, element_tree, te);
1120 case WCCP2_ASSIGNMENT_METHOD:
1121 dissect_32_bit_capability_flags(tvb, curr_offset,
1122 capability_val_len, pinfo,
1123 ett_capability_assignment_method,
1124 assignment_method_flags, element_tree, te);
1127 case WCCP2_PACKET_RETURN_METHOD:
1128 dissect_32_bit_capability_flags(tvb, curr_offset,
1129 capability_val_len, pinfo,
1130 ett_capability_return_method,
1131 packet_return_method_flags, element_tree, te);
1135 proto_tree_add_item(element_tree, hf_capability_info_bytes, tvb, curr_offset+4, capability_val_len, ENC_NA);
1144 dissect_32_bit_capability_flags(tvbuff_t *tvb, int curr_offset,
1145 guint16 capability_val_len, packet_info *pinfo, gint ett, const capability_flag *flags,
1146 proto_tree *element_tree, proto_item *element_item)
1148 guint32 capability_val;
1150 proto_tree *method_tree;
1152 gboolean first = TRUE;
1154 if (capability_val_len != 4) {
1155 expert_add_info_format(pinfo, element_item, PI_PROTOCOL, PI_WARN,
1156 "Value Length: %u (illegal, must be >= 4)", capability_val_len);
1160 capability_val = tvb_get_ntohl(tvb, curr_offset + 4);
1161 tm = proto_tree_add_uint(element_tree, hf_capability_info_value, tvb, curr_offset + 4, 4, capability_val);
1163 for (i = 0; flags[i].short_name != NULL; i++) {
1164 if (capability_val & flags[i].value) {
1166 proto_item_append_text( tm, " (%s", flags[i].short_name);
1169 proto_item_append_text( tm, ", %s", flags[i].short_name);
1175 proto_item_append_text( tm, ")");
1177 method_tree = proto_item_add_subtree(tm, ett);
1178 for (i = 0; flags[i].phf != NULL; i++)
1179 proto_tree_add_item(method_tree, *(flags[i].phf), tvb, curr_offset+4, 4, ENC_BIG_ENDIAN);
1183 #define ALT_ASSIGNMENT_INFO_MIN_LEN (4+4)
1185 #define WCCP2_HASH_ASSIGNMENT_TYPE 0x0000
1186 #define WCCP2_MASK_ASSIGNMENT_TYPE 0x0001
1188 static const value_string assignment_type_vals[] = {
1189 { WCCP2_HASH_ASSIGNMENT_TYPE, "Hash" },
1190 { WCCP2_MASK_ASSIGNMENT_TYPE, "Mask" },
1195 dissect_wccp2_value_element(tvbuff_t *tvb, int offset, int idx, proto_tree *info_tree)
1198 proto_tree *element_tree;
1200 tl = proto_tree_add_text(info_tree, tvb, offset, 16, "Value Element(%u)", idx);
1201 element_tree = proto_item_add_subtree(tl, ett_value_element);
1203 proto_tree_add_item(element_tree, hf_wccp2_value_element_src_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
1204 proto_tree_add_item(element_tree, hf_wccp2_value_element_dest_ip, tvb, offset+4, 4, ENC_BIG_ENDIAN);
1205 proto_tree_add_item(element_tree, hf_wccp2_value_element_src_port, tvb, offset+8, 2, ENC_BIG_ENDIAN);
1206 proto_tree_add_item(element_tree, hf_wccp2_value_element_dest_port, tvb, offset+10, 2, ENC_BIG_ENDIAN);
1207 proto_tree_add_item(element_tree, hf_wccp2_value_element_web_cache_ip, tvb, offset+12, 4, ENC_BIG_ENDIAN);
1211 dissect_wccp2_mask_value_set_element(tvbuff_t *tvb, int offset, int idx, proto_tree *info_tree)
1214 proto_tree *element_tree;
1215 guint num_of_val_elements;
1218 tl = proto_tree_add_text(info_tree, tvb, offset, 0, "Mask/Value Set Element(%d)", idx);
1219 element_tree = proto_item_add_subtree(tl, ett_mv_set_element);
1221 proto_tree_add_item(element_tree, hf_wccp2_mask_value_set_element_src_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
1222 proto_tree_add_item(element_tree, hf_wccp2_mask_value_set_element_dest_ip, tvb, offset+4, 4, ENC_BIG_ENDIAN);
1223 proto_tree_add_item(element_tree, hf_wccp2_mask_value_set_element_src_port, tvb, offset+8, 2, ENC_BIG_ENDIAN);
1224 proto_tree_add_item(element_tree, hf_wccp2_mask_value_set_element_dest_port, tvb, offset+10, 2, ENC_BIG_ENDIAN);
1225 proto_tree_add_item(element_tree, hf_wccp2_mask_value_set_element_num, tvb, offset+12, 4, ENC_BIG_ENDIAN);
1226 num_of_val_elements = tvb_get_ntohl(tvb, offset+12);
1229 for (i = 0; i < num_of_val_elements; i++)
1231 dissect_wccp2_value_element(tvb, offset, i, element_tree);
1235 proto_item_set_len(tl, 16+i*16);
1241 dissect_wccp2_alt_assignment_info(tvbuff_t *tvb, int offset, int length,
1242 packet_info *pinfo, proto_tree *info_tree, proto_item *info_item)
1244 guint16 assignment_type;
1245 guint16 assignment_length;
1247 if (length < ALT_ASSIGNMENT_INFO_MIN_LEN) {
1248 expert_add_info_format(pinfo, info_item, PI_PROTOCOL, PI_WARN,
1249 "Item length is %u, should be >= %u", length, ALT_ASSIGNMENT_INFO_MIN_LEN);
1253 assignment_type = tvb_get_ntohs(tvb, offset);
1254 proto_tree_add_item(info_tree, hf_alt_assignment_info_assignment_type, tvb, offset, 2, ENC_BIG_ENDIAN);
1257 assignment_length = tvb_get_ntohs(tvb, offset);
1258 proto_tree_add_item(info_tree, hf_alt_assignment_info_assignment_length, tvb, offset, 2, ENC_BIG_ENDIAN);
1261 switch (assignment_type) {
1262 case WCCP2_HASH_ASSIGNMENT_TYPE:
1263 dissect_wccp2_assignment_info(tvb, offset, assignment_length, pinfo, info_tree, info_item);
1266 case WCCP2_MASK_ASSIGNMENT_TYPE:
1272 dissect_wccp2_assignment_key(tvb, offset, info_tree);
1275 num_of_rtr = tvb_get_ntohl(tvb, offset);
1276 proto_tree_add_uint(info_tree, hf_alt_assignment_info_num_routers, tvb, offset, 4, num_of_rtr);
1278 for (i = 0; i < num_of_rtr; i++)
1280 dissect_wccp2_router_assignment_element(tvb, offset, info_tree);
1284 num_of_elem = tvb_get_ntohl(tvb, offset);
1285 proto_tree_add_uint(info_tree, hf_alt_assignment_info_num_elements, tvb, offset, 4, num_of_elem);
1287 for (i = 0; i < num_of_elem; i++)
1289 offset += dissect_wccp2_mask_value_set_element(tvb, offset, i, info_tree);
1302 proto_register_wccp(void)
1304 static hf_register_info hf[] = {
1305 { &hf_wccp_message_type,
1306 { "WCCP Message Type", "wccp.message", FT_UINT32, BASE_DEC, VALS(wccp_type_vals), 0x0,
1307 "The WCCP message that was sent", HFILL }
1310 { "WCCP Version", "wccp.version", FT_UINT32, BASE_HEX, VALS(wccp_version_val), 0x0,
1311 "The WCCP version", HFILL }
1313 { &hf_wccp2_version,
1314 { "WCCP Version", "wccp.version", FT_UINT16, BASE_HEX, NULL, 0x0,
1315 "The WCCP version", HFILL }
1317 { &hf_hash_revision,
1318 { "Hash Revision", "wccp.hash_revision", FT_UINT32, BASE_DEC, 0x0, 0x0,
1319 "The cache hash revision", HFILL }
1322 { "Change Number", "wccp.change_num", FT_UINT32, BASE_DEC, 0x0, 0x0,
1323 "The Web-Cache list entry change number", HFILL }
1326 { "Flags", "wccp.hash_flag", FT_UINT32, BASE_HEX, 0x0, 0x0,
1330 { "Hash information", "wccp.hash_flag.u", FT_BOOLEAN, 32, TFS(&tfs_historical_current), WCCP_U_FLAG,
1334 { "Received ID", "wccp.recvd_id", FT_UINT32, BASE_DEC, 0x0, 0x0,
1335 "The number of I_SEE_YOU's that have been sent", HFILL }
1337 { &hf_num_web_caches,
1338 { "Number of Web Caches", "wccp.num_web_caches", FT_UINT32, BASE_DEC, 0x0, 0x0,
1342 { "Web Cache IP address", "wccp.cache_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1343 "The IP address of a Web cache", HFILL }
1345 { &hf_item_header_length,
1346 { "Length", "wccp.item_header_length", FT_UINT16, BASE_DEC, 0x0, 0x0,
1350 { "Length", "wccp.item_length", FT_UINT16, BASE_DEC, 0x0, 0x0,
1354 { "Type", "wccp.item_type", FT_UINT16, BASE_DEC, VALS(info_type_vals), 0x0,
1358 { "Data", "wccp.item_data", FT_BYTES, BASE_NONE, 0x0, 0x0,
1361 { &hf_security_option,
1362 { "Security Option", "wccp.security_option", FT_UINT16, BASE_DEC, VALS(security_option_vals), 0x0,
1365 { &hf_security_md5_checksum,
1366 { "MD5 checksum", "wccp.security_md5_checksum", FT_BYTES, BASE_NONE, 0x0, 0x0,
1370 { "Service Type", "wccp.service_type", FT_UINT8, BASE_DEC, VALS(service_type_vals), 0x0,
1374 { "Service ID", "wccp.service_id", FT_UINT8, BASE_DEC, VALS(service_id_vals), 0x0,
1377 { &hf_service_priority,
1378 { "Priority", "wccp.service_priority", FT_UINT8, BASE_DEC, NULL, 0x0,
1381 { &hf_service_protocol,
1382 { "Protocol", "wccp.service_protocol", FT_UINT8, BASE_DEC, NULL, 0x0,
1385 { &hf_service_flags,
1386 { "Flags", "wccp.service_flags", FT_UINT32, BASE_HEX, 0x0, 0x0,
1389 { &hf_service_flags_src_ip_hash,
1390 { "Source IP address in primary hash", "wccp.service_flag.src_ip_hash", FT_BOOLEAN, 32, TFS(&tfs_used_notused), WCCP2_SI_SRC_IP_HASH,
1393 { &hf_service_flags_dest_ip_hash,
1394 { "Destination IP address in primary hash", "wccp.service_flag.dest_ip_hash", FT_BOOLEAN, 32, TFS(&tfs_used_notused), WCCP2_SI_DST_IP_HASH,
1397 { &hf_service_flags_src_port_hash,
1398 { "Source port in primary hash", "wccp.service_flag.src_port_hash", FT_BOOLEAN, 32, TFS(&tfs_used_notused), WCCP2_SI_SRC_PORT_HASH,
1401 { &hf_service_flags_dest_port_hash,
1402 { "Destination port in primary hash", "wccp.service_flag.dest_port_hash", FT_BOOLEAN, 32, TFS(&tfs_used_notused), WCCP2_SI_DST_PORT_HASH,
1405 { &hf_service_flags_ports_defined,
1406 { "Ports", "wccp.service_flag.ports_defined", FT_BOOLEAN, 32, TFS(&tfs_defined_not_defined), WCCP2_SI_PORTS_DEFINED,
1409 { &hf_service_flags_ports_source,
1410 { "Ports refer to", "wccp.service_flag.ports_source", FT_BOOLEAN, 32, TFS(&tfs_src_dest_port), WCCP2_SI_PORTS_SOURCE,
1413 { &hf_service_flags_src_ip_alt_hash,
1414 { "Source IP address in secondary hash", "wccp.service_flag.src_ip_alt_hash", FT_BOOLEAN, 32, TFS(&tfs_used_notused), WCCP2_SI_SRC_IP_ALT_HASH,
1417 { &hf_service_flags_dest_ip_alt_hash,
1418 { "Destination IP address in secondary hash", "wccp.service_flag.dest_ip_alt_hash", FT_BOOLEAN, 32, TFS(&tfs_used_notused), WCCP2_SI_DST_IP_ALT_HASH,
1421 { &hf_service_flags_src_port_alt_hash,
1422 { "Source port in secondary hash", "wccp.service_flag.src_port_alt_hash", FT_BOOLEAN, 32, TFS(&tfs_used_notused), WCCP2_SI_SRC_PORT_ALT_HASH,
1425 { &hf_service_flags_dest_port_alt_hash,
1426 { "Destination port in secondary hash", "wccp.service_flag.dest_port_alt_hash", FT_BOOLEAN, 32, TFS(&tfs_used_notused), WCCP2_SI_DST_PORT_ALT_HASH,
1430 { "Port", "wccp.service_port", FT_UINT16, BASE_DEC, NULL, 0x0,
1433 { &hf_router_identity_ip,
1434 { "IP Address", "wccp.router_identity.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1437 { &hf_router_identity_receive_id,
1438 { "Received ID", "wccp.router_identity.receive_id", FT_UINT32, BASE_DEC, 0x0, 0x0,
1441 { &hf_router_send_to_ip,
1442 { "Sent To IP Address", "wccp.router.send_to_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1445 { &hf_router_num_recv_ip,
1446 { "Number of Received From IP addresses", "wccp.router.num_recv_ip", FT_UINT32, BASE_DEC, 0x0, 0x0,
1449 { &hf_router_recv_ip,
1450 { "Received From IP Address", "wccp.router.recv_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1453 { &hf_web_cache_identity_ip,
1454 { "Web-Cache IP Address", "wccp.web_cache_identity.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1457 { &hf_web_cache_identity_hash_rev,
1458 { "Hash Revision", "wccp.web_cache_identity.hash_rev", FT_UINT16, BASE_DEC, NULL, 0x0,
1461 { &hf_web_cache_identity_flags,
1462 { "Flags", "wccp.web_cache_identity.flags", FT_UINT16, BASE_HEX, NULL, 0x0,
1465 { &hf_web_cache_identity_flag_hash_info,
1466 { "Hash information", "wccp.web_cache_identity.flags.hash_info", FT_BOOLEAN, 16, TFS(&tfs_historical_current), 0x8000,
1469 { &hf_web_cache_identity_flag_assign_type,
1470 { "Assignment Type", "wccp.web_cache_identity.flags.assign_type", FT_BOOLEAN, 16, TFS(&tfs_mask_hash), 0x4000,
1473 { &hf_web_cache_identity_num_mask,
1474 { "Number of Masks", "wccp.web_cache_identity.num_mask", FT_UINT32, BASE_DEC, 0x0, 0x0,
1477 { &hf_web_cache_identity_assign_mask,
1478 { "Mask Element", "wccp.web_cache_identity.assign_mask", FT_UINT32, BASE_HEX, 0x0, 0x0,
1481 { &hf_web_cache_identity_assign_weight,
1482 { "Assignment Weight", "wccp.web_cache_identity.assignment_weight", FT_UINT16, BASE_DEC, NULL, 0x0,
1485 { &hf_web_cache_identity_status,
1486 { "Status", "wccp.web_cache_identity.status", FT_UINT16, BASE_HEX, NULL, 0x0,
1489 { &hf_assignment_key_ip,
1490 { "Assignment Key IP Address", "wccp.assignment_key.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1493 { &hf_assignment_key_change_num,
1494 { "Assignment Key Change Number", "wccp.assignment_key.change_num", FT_UINT32, BASE_DEC, NULL, 0x0,
1497 { &hf_router_view_member_change_num,
1498 { "Member Change Number", "wccp.router_view.member_change_num", FT_UINT32, BASE_DEC, NULL, 0x0,
1501 { &hf_router_router_num,
1502 { "Number of Routers", "wccp.router_view.router_num", FT_UINT32, BASE_DEC, NULL, 0x0,
1505 { &hf_router_router_ip,
1506 { "Router IP Address", "wccp.router_view.router_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1509 { &hf_wc_view_info_change_num,
1510 { "Change Number", "wccp.wc_view.change_num", FT_UINT32, BASE_DEC, NULL, 0x0,
1513 { &hf_wc_view_router_num,
1514 { "Number of Routers", "wccp.wc_view.router_num", FT_UINT32, BASE_DEC, NULL, 0x0,
1518 { "Router IP Address", "wccp.wc_view.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1521 { &hf_router_assignment_element_ip,
1522 { "IP Address", "wccp.router_assignment_element.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1525 { &hf_router_assignment_element_receive_id,
1526 { "Receive ID", "wccp.router_assignment_element.receive_id", FT_UINT32, BASE_DEC, NULL, 0x0,
1529 { &hf_router_assignment_element_change_num,
1530 { "Change Number", "wccp.router_assignment_element.change_num", FT_UINT32, BASE_DEC, NULL, 0x0,
1533 { &hf_wccp2_assignment_info_router_num,
1534 { "Number of Routers", "wccp.assignment_info.router_num", FT_UINT32, BASE_DEC, NULL, 0x0,
1537 { &hf_wccp2_assignment_info_ip,
1538 { "Router IP Address", "wccp.assignment_info.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1541 { &hf_router_query_info_ip,
1542 { "Router IP Address", "wccp.router_query_info.ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1545 { &hf_router_query_info_receive_id,
1546 { "Receive ID", "wccp.router_query_info.receive_id", FT_UINT32, BASE_DEC, NULL, 0x0,
1549 { &hf_router_query_info_send_to_ip,
1550 { "Sent To IP Address", "wccp.router_query_info.send_to_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1553 { &hf_router_query_info_target_ip,
1554 { "Target IP Address", "wccp.router_query_info.target_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1557 { &hf_capability_info_type,
1558 { "Type", "wccp.capability_info.type", FT_UINT16, BASE_DEC, VALS(capability_type_vals), 0x0,
1561 { &hf_capability_info_length,
1562 { "Value Length", "wccp.capability_info.length", FT_UINT16, BASE_DEC, NULL, 0x0,
1565 { &hf_capability_info_bytes,
1566 { "Value", "wccp.capability_info.bytes", FT_BYTES, BASE_NONE, 0x0, 0x0,
1569 { &hf_capability_info_value,
1570 { "Value", "wccp.capability_info.value", FT_UINT32, BASE_HEX, NULL, 0x0,
1573 { &hf_capability_forwarding_method_flag_gre,
1574 { "GRE-encapsulated", "wccp.capability_info.forwarding_method_flag.gre", FT_BOOLEAN, 32, TFS(&tfs_supported_not_supported), WCCP2_FORWARDING_METHOD_GRE,
1577 { &hf_capability_forwarding_method_flag_l2,
1578 { "L2 rewrite", "wccp.capability_info.forwarding_method_flag.l2", FT_BOOLEAN, 32, TFS(&tfs_supported_not_supported), WCCP2_FORWARDING_METHOD_L2,
1581 { &hf_capability_assignment_method_flag_hash,
1582 { "Hash", "wccp.capability_info.assignment_method_flag.hash", FT_BOOLEAN, 32, TFS(&tfs_supported_not_supported), WCCP2_ASSIGNMENT_METHOD_HASH,
1585 { &hf_capability_assignment_method_flag_mask,
1586 { "Mask", "wccp.capability_info.assignment_method_flag.mask", FT_BOOLEAN, 32, TFS(&tfs_supported_not_supported), WCCP2_ASSIGNMENT_METHOD_MASK,
1589 { &hf_capability_return_method_flag_gre,
1590 { "GRE-encapsulated", "wccp.capability_info.return_method_flag.gre", FT_BOOLEAN, 32, TFS(&tfs_supported_not_supported), WCCP2_PACKET_RETURN_METHOD_GRE,
1593 { &hf_capability_return_method_flag_l2,
1594 { "L2 rewrite", "wccp.capability_info.return_method_flag.l2", FT_BOOLEAN, 32, TFS(&tfs_supported_not_supported), WCCP2_PACKET_RETURN_METHOD_L2,
1597 { &hf_wccp2_value_element_src_ip,
1598 { "Source Address", "wccp.value_element.src_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1601 { &hf_wccp2_value_element_dest_ip,
1602 { "Destination Address", "wccp.value_element.dest_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1605 { &hf_wccp2_value_element_src_port,
1606 { "Source Port", "wccp.value_element.src_port", FT_UINT16, BASE_DEC, NULL, 0x0,
1609 { &hf_wccp2_value_element_dest_port,
1610 { "Destination Port", "wccp.value_element.dest_port", FT_UINT16, BASE_DEC, NULL, 0x0,
1613 { &hf_wccp2_value_element_web_cache_ip,
1614 { "Web Cache Address", "wccp.value_element.web_cache_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1617 { &hf_wccp2_mask_value_set_element_src_ip,
1618 { "Source Address Mask", "wccp.mask_value_set_element.src_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1621 { &hf_wccp2_mask_value_set_element_dest_ip,
1622 { "Destination Address Mask", "wccp.mask_value_set_element.dest_ip", FT_IPv4, BASE_NONE, NULL, 0x0,
1625 { &hf_wccp2_mask_value_set_element_src_port,
1626 { "Source Port Mask", "wccp.mask_value_set_element.src_port", FT_UINT16, BASE_DEC, NULL, 0x0,
1629 { &hf_wccp2_mask_value_set_element_dest_port,
1630 { "Destination Port Mask", "wccp.mask_value_set_element.dest_port", FT_UINT16, BASE_DEC, NULL, 0x0,
1633 { &hf_wccp2_mask_value_set_element_num,
1634 { "Number of Value Elements", "wccp.mask_value_set_element.num", FT_UINT32, BASE_DEC, NULL, 0x0,
1637 { &hf_alt_assignment_info_assignment_type,
1638 { "Assignment type", "wccp.alt_assignment_info.assignment_type", FT_UINT16, BASE_DEC, VALS(assignment_type_vals), 0x0,
1641 { &hf_alt_assignment_info_assignment_length,
1642 { "Assignment length", "wccp.alt_assignment_info.assignment_length", FT_UINT16, BASE_DEC, NULL, 0x0,
1645 { &hf_alt_assignment_info_num_routers,
1646 { "Number of routers", "wccp.alt_assignment_info.num_routers", FT_UINT32, BASE_DEC, NULL, 0x0,
1649 { &hf_alt_assignment_info_num_elements,
1650 { "Number of elements", "wccp.alt_assignment_info.num_elements", FT_UINT32, BASE_DEC, NULL, 0x0,
1655 static gint *ett[] = {
1664 &ett_router_identity_element,
1665 &ett_router_identity_info,
1666 &ett_wc_identity_element,
1667 &ett_wc_identity_info,
1668 &ett_router_view_info,
1671 &ett_router_assignment_element,
1672 &ett_router_assignment_info,
1673 &ett_capabilities_info,
1674 &ett_capability_element,
1675 &ett_capability_forwarding_method,
1676 &ett_capability_assignment_method,
1677 &ett_capability_return_method,
1678 &ett_mv_set_element,
1680 &ett_alt_assignment_info,
1684 proto_wccp = proto_register_protocol("Web Cache Communication Protocol",
1686 proto_register_field_array(proto_wccp, hf, array_length(hf));
1687 proto_register_subtree_array(ett, array_length(ett));
1691 proto_reg_handoff_wccp(void)
1693 dissector_handle_t wccp_handle;
1695 wccp_handle = new_create_dissector_handle(dissect_wccp, proto_wccp);
1696 dissector_add_uint("udp.port", UDP_PORT_WCCP, wccp_handle);