--------------------- PatchSet 8796 Date: 2006/12/04 13:12:21 Author: adri Branch: s26_wccp2 Tag: (none) Log: Break wccp2 structure definitions out of wccp2.c Members: src/wccp2.c:1.26.2.10->1.26.2.11 src/wccp2.h:1.1->1.1.2.1 Index: squid/src/wccp2.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/wccp2.c,v retrieving revision 1.26.2.10 retrieving revision 1.26.2.11 diff -u -r1.26.2.10 -r1.26.2.11 --- squid/src/wccp2.c 4 Dec 2006 08:32:16 -0000 1.26.2.10 +++ squid/src/wccp2.c 4 Dec 2006 13:12:21 -0000 1.26.2.11 @@ -1,6 +1,6 @@ /* - * $Id: wccp2.c,v 1.26.2.10 2006/12/04 08:32:16 adri Exp $ + * $Id: wccp2.c,v 1.26.2.11 2006/12/04 13:12:21 adri Exp $ * * DEBUG: section 80 WCCP Support * AUTHOR: Steven WIlton @@ -36,10 +36,7 @@ #if USE_WCCPv2 #include - -#define WCCP_PORT 2048 -#define WCCP_RESPONSE_SIZE 12448 -#define WCCP_BUCKETS 256 +#include "wccp2.h" static int theWccp2Connection = -1; static int wccp2_connected = 0; @@ -48,315 +45,21 @@ static EVH wccp2HereIam; static EVH wccp2AssignBuckets; -/* KDW WCCP V2 */ -#define WCCP2_HERE_I_AM 10 -#define WCCP2_I_SEE_YOU 11 -#define WCCP2_REDIRECT_ASSIGN 12 -#define WCCP2_REMOVAL_QUERY 13 - -#define WCCP2_VERSION 0x200 - -#define WCCP2_SECURITY_INFO 0 -#define WCCP2_NO_SECURITY 0 -#define WCCP2_MD5_SECURITY 1 - -#define WCCP2_SERVICE_INFO 1 -#define WCCP2_SERVICE_STANDARD 0 -#define WCCP2_SERVICE_DYNAMIC 1 -#define WCCP2_SERVICE_ID_HTTP 0x00 - -#define WCCP2_SERVICE_SRC_IP_HASH 0x1 -#define WCCP2_SERVICE_DST_IP_HASH 0x2 -#define WCCP2_SERVICE_SRC_PORT_HASH 0x4 -#define WCCP2_SERVICE_DST_PORT_HASH 0x8 -#define WCCP2_SERVICE_PORTS_DEFINED 0x10 -#define WCCP2_SERVICE_PORTS_SOURCE 0x20 -#define WCCP2_SERVICE_SRC_IP_ALT_HASH 0x100 -#define WCCP2_SERVICE_DST_IP_ALT_HASH 0x200 -#define WCCP2_SERVICE_SRC_PORT_ALT_HASH 0x400 -#define WCCP2_SERVICE_DST_PORT_ALT_HASH 0x800 - -#define WCCP2_ROUTER_ID_INFO 2 - -#define WCCP2_WC_ID_INFO 3 - -#define WCCP2_RTR_VIEW_INFO 4 - -#define WCCP2_WC_VIEW_INFO 5 - -#define WCCP2_REDIRECT_ASSIGNMENT 6 - -#define WCCP2_QUERY_INFO 7 - -#define WCCP2_CAPABILITY_INFO 8 - -#define WCCP2_ALT_ASSIGNMENT 13 - -#define WCCP2_ASSIGN_MAP 14 - -#define WCCP2_COMMAND_EXTENSION 15 - -#define WCCP2_CAPABILITY_FORWARDING_METHOD 0x01 -#define WCCP2_CAPABILITY_ASSIGNMENT_METHOD 0x02 -#define WCCP2_CAPABILITY_RETURN_METHOD 0x03 - -#define WCCP2_FORWARDING_METHOD_GRE 0x00000001 -#define WCCP2_FORWARDING_METHOD_L2 0x00000002 - -#define WCCP2_ASSIGNMENT_METHOD_HASH 0x00000001 -#define WCCP2_ASSIGNMENT_METHOD_MASK 0x00000002 - -#define WCCP2_PACKET_RETURN_METHOD_GRE 0x00000001 -#define WCCP2_PACKET_RETURN_METHOD_L2 0x00000002 - -#define WCCP2_HASH_ASSIGNMENT 0x00 -#define WCCP2_MASK_ASSIGNMENT 0x01 - -#define WCCP2_NONE_SECURITY_LEN 0 -#define WCCP2_MD5_SECURITY_LEN 16 - -/* Useful defines */ -#define WCCP2_NUMPORTS 8 -#define WCCP2_PASSWORD_LEN 8 - -/* WCCP v2 packet header */ -struct wccp2_here_i_am_header_t { - uint32_t type; - uint16_t version; - uint16_t length; -}; - -/* Security struct for the "no security" option */ -struct wccp2_security_none_t { - uint16_t security_type; - uint16_t security_length; - uint32_t security_option; -}; - -struct wccp2_security_md5_t { - uint16_t security_type; - uint16_t security_length; - uint32_t security_option; - uint8_t security_implementation[WCCP2_MD5_SECURITY_LEN]; -}; - -/* Service info struct */ -struct wccp2_service_info_t { - uint16_t service_type; - uint16_t service_length; - uint8_t service; - uint8_t service_id; - uint8_t service_priority; - uint8_t service_protocol; - uint32_t service_flags; - uint16_t port0; - uint16_t port1; - uint16_t port2; - uint16_t port3; - uint16_t port4; - uint16_t port5; - uint16_t port6; - uint16_t port7; -}; - -struct wccp2_cache_identity_info_t { - struct in_addr addr; - uint16_t hash_revision; - char bits[2]; - char buckets[32]; - uint16_t weight; - uint16_t status; -}; - -/* Web Cache identity info */ -struct wccp2_identity_info_t { - uint16_t cache_identity_type; - uint16_t cache_identity_length; - struct wccp2_cache_identity_info_t cache_identity; -}; static struct wccp2_identity_info_t wccp2_identity_info; -struct wccp2_cache_mask_identity_info_t { - struct in_addr addr; - uint32_t num1; - uint32_t num2; - uint32_t source_ip_mask; - uint32_t dest_ip_mask; - uint16_t source_port_mask; - uint16_t dest_port_mask; - uint32_t num3; - uint32_t num4; -}; - -/* Web Cache identity info */ -struct wccp2_mask_identity_info_t { - uint16_t cache_identity_type; - uint16_t cache_identity_length; - struct wccp2_cache_mask_identity_info_t cache_identity; -}; - -/* View header */ -struct wccp2_cache_view_header_t { - uint16_t cache_view_type; - uint16_t cache_view_length; - uint32_t cache_view_version; -}; - static struct wccp2_cache_view_header_t wccp2_cache_view_header; -/* View info */ -struct wccp2_cache_view_info_t { - uint32_t num_routers; - uint32_t num_caches; -}; - static struct wccp2_cache_view_info_t wccp2_cache_view_info; -/* Router ID element */ -struct wccp2_router_id_element_t { - struct in_addr router_address; - uint32_t received_id; -}; - static struct wccp2_router_id_element_t wccp2_router_id_element; -/* Capability info header */ -struct wccp2_capability_info_header_t { - uint16_t capability_info_type; - uint16_t capability_info_length; -}; - -/* Capability element header */ -struct wccp2_capability_element_header_t { - uint16_t capability_type; - uint16_t capability_length; -}; - -/* Capability element */ -struct wccp2_capability_element_t { - uint16_t capability_type; - uint16_t capability_length; - uint32_t capability_value; -}; - static struct wccp2_capability_element_t wccp2_capability_element; -/* Mask Element */ -struct wccp2_mask_element_t { - uint32_t source_ip_mask; - uint32_t dest_ip_mask; - uint16_t source_port_mask; - uint16_t dest_port_mask; - uint32_t number_values; -}; - -/* Value Element */ -struct wccp2_value_element_t { - uint32_t source_ip_value; - uint32_t dest_ip_value; - uint16_t source_port_value; - uint16_t dest_port_value; - struct in_addr cache_ip; -}; - -/* RECEIVED PACKET STRUCTURE */ -struct wccp2_i_see_you_t { - uint32_t type; - uint16_t version; - uint16_t length; - char data[WCCP_RESPONSE_SIZE]; -}; - -/* Outbound packet */ -struct wccp2_out_packet_t { - struct { - uint32_t type; - uint16_t version; - uint16_t length; - char data[WCCP_RESPONSE_SIZE]; - } p; - char *sec_ofs; - int size; -}; - static struct wccp2_i_see_you_t wccp2_i_see_you; -/* Router ID element */ -struct wccp2_router_assign_element_t { - struct in_addr router_address; - uint32_t received_id; - uint32_t change_number; -}; - -/* Generic header struct */ -struct wccp2_item_header_t { - uint16_t type; - uint16_t length; -}; - -/* Router identity struct */ -struct router_identity_info_t { - struct wccp2_item_header_t header; - struct wccp2_router_id_element_t router_id_element; - struct in_addr router_address; - uint32_t number_caches; -}; - -/* The received packet for a mask assignment is unusual */ -struct cache_mask_info_t { - struct in_addr addr; - uint32_t num1; - uint32_t num2; - uint32_t num3; -}; - -/* assigment key */ -struct assignment_key_t { - struct in_addr master_ip; - uint32_t master_number; -}; - -/* Router view of WCCP */ -struct router_view_t { - struct wccp2_item_header_t header; - uint32_t change_number; - struct assignment_key_t assignment_key; -}; - -/* Lists used to keep track of caches, routers and services */ -struct wccp2_cache_list_t { - struct in_addr cache_ip; - int weight; - struct wccp2_cache_list_t *next; -}; - -struct wccp2_router_list_t { - struct in_addr router_address; - uint32_t received_id; - uint32_t change_number; - struct in_addr local_ip; - struct in_addr router_sendto_address; - int seen; - uint32_t member_change; - uint32_t num_caches; - struct wccp2_cache_list_t cache_list_head; - struct wccp2_router_list_t *next; -}; - static int wccp2_numrouters; -struct wccp2_service_list_t { - struct wccp2_service_info_t info; - struct wccp2_router_list_t router_list_head; - int lowest_ip; - uint32_t change_num; - char *wccp2_identity_info_ptr; - struct wccp2_service_list_t *next; - char wccp_password[WCCP2_PASSWORD_LEN + 1]; /* hold the trailing C-string NUL */ - uint32_t wccp2_security_type; -}; - static struct wccp2_service_list_t *wccp2_service_list_head = NULL; void wccp2_out_packet_begin(struct wccp2_out_packet_t *packet); --- /dev/null Wed Feb 14 01:16:58 2007 +++ squid/src/wccp2.h Wed Feb 14 01:17:40 2007 @@ -0,0 +1,351 @@ + +/* + * $Id: wccp2.h,v 1.1.2.1 2006/12/04 13:12:21 adri Exp $ + * + * DEBUG: section 80 WCCP Support + * AUTHOR: Steven WIlton + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#ifndef __WCCP_H__ +#define __WCCP_H__ + +#define WCCP_PORT 2048 +#define WCCP_RESPONSE_SIZE 12448 +#define WCCP_BUCKETS 256 + +/* KDW WCCP V2 */ +#define WCCP2_HERE_I_AM 10 +#define WCCP2_I_SEE_YOU 11 +#define WCCP2_REDIRECT_ASSIGN 12 +#define WCCP2_REMOVAL_QUERY 13 + +#define WCCP2_VERSION 0x200 + +#define WCCP2_SECURITY_INFO 0 +#define WCCP2_NO_SECURITY 0 +#define WCCP2_MD5_SECURITY 1 + +#define WCCP2_SERVICE_INFO 1 +#define WCCP2_SERVICE_STANDARD 0 +#define WCCP2_SERVICE_DYNAMIC 1 +#define WCCP2_SERVICE_ID_HTTP 0x00 + +#define WCCP2_SERVICE_SRC_IP_HASH 0x1 +#define WCCP2_SERVICE_DST_IP_HASH 0x2 +#define WCCP2_SERVICE_SRC_PORT_HASH 0x4 +#define WCCP2_SERVICE_DST_PORT_HASH 0x8 +#define WCCP2_SERVICE_PORTS_DEFINED 0x10 +#define WCCP2_SERVICE_PORTS_SOURCE 0x20 +#define WCCP2_SERVICE_SRC_IP_ALT_HASH 0x100 +#define WCCP2_SERVICE_DST_IP_ALT_HASH 0x200 +#define WCCP2_SERVICE_SRC_PORT_ALT_HASH 0x400 +#define WCCP2_SERVICE_DST_PORT_ALT_HASH 0x800 + +#define WCCP2_ROUTER_ID_INFO 2 + +#define WCCP2_WC_ID_INFO 3 + +#define WCCP2_RTR_VIEW_INFO 4 + +#define WCCP2_WC_VIEW_INFO 5 + +#define WCCP2_REDIRECT_ASSIGNMENT 6 + +#define WCCP2_QUERY_INFO 7 + +#define WCCP2_CAPABILITY_INFO 8 + +#define WCCP2_ALT_ASSIGNMENT 13 + +#define WCCP2_ASSIGN_MAP 14 + +#define WCCP2_COMMAND_EXTENSION 15 + +#define WCCP2_CAPABILITY_FORWARDING_METHOD 0x01 +#define WCCP2_CAPABILITY_ASSIGNMENT_METHOD 0x02 +#define WCCP2_CAPABILITY_RETURN_METHOD 0x03 + +#define WCCP2_FORWARDING_METHOD_GRE 0x00000001 +#define WCCP2_FORWARDING_METHOD_L2 0x00000002 + +#define WCCP2_ASSIGNMENT_METHOD_HASH 0x00000001 +#define WCCP2_ASSIGNMENT_METHOD_MASK 0x00000002 + +#define WCCP2_PACKET_RETURN_METHOD_GRE 0x00000001 +#define WCCP2_PACKET_RETURN_METHOD_L2 0x00000002 + +#define WCCP2_HASH_ASSIGNMENT 0x00 +#define WCCP2_MASK_ASSIGNMENT 0x01 + +#define WCCP2_NONE_SECURITY_LEN 0 +#define WCCP2_MD5_SECURITY_LEN 16 + +/* Useful defines */ +#define WCCP2_NUMPORTS 8 +#define WCCP2_PASSWORD_LEN 8 + +/* WCCP v2 packet header */ +struct wccp2_here_i_am_header_t { + uint32_t type; + uint16_t version; + uint16_t length; +}; + +/* Security struct for the "no security" option */ +struct wccp2_security_none_t { + uint16_t security_type; + uint16_t security_length; + uint32_t security_option; +}; + +struct wccp2_security_md5_t { + uint16_t security_type; + uint16_t security_length; + uint32_t security_option; + uint8_t security_implementation[WCCP2_MD5_SECURITY_LEN]; +}; + +/* Service info struct */ +struct wccp2_service_info_t { + uint16_t service_type; + uint16_t service_length; + uint8_t service; + uint8_t service_id; + uint8_t service_priority; + uint8_t service_protocol; + uint32_t service_flags; + uint16_t port0; + uint16_t port1; + uint16_t port2; + uint16_t port3; + uint16_t port4; + uint16_t port5; + uint16_t port6; + uint16_t port7; +}; + +struct wccp2_cache_identity_info_t { + struct in_addr addr; + uint16_t hash_revision; + char bits[2]; + char buckets[32]; + uint16_t weight; + uint16_t status; +}; + +/* Web Cache identity info */ +struct wccp2_identity_info_t { + uint16_t cache_identity_type; + uint16_t cache_identity_length; + struct wccp2_cache_identity_info_t cache_identity; +}; + +static struct wccp2_identity_info_t wccp2_identity_info; + +struct wccp2_cache_mask_identity_info_t { + struct in_addr addr; + uint32_t num1; + uint32_t num2; + uint32_t source_ip_mask; + uint32_t dest_ip_mask; + uint16_t source_port_mask; + uint16_t dest_port_mask; + uint32_t num3; + uint32_t num4; +}; + +/* Web Cache identity info */ +struct wccp2_mask_identity_info_t { + uint16_t cache_identity_type; + uint16_t cache_identity_length; + struct wccp2_cache_mask_identity_info_t cache_identity; +}; + +/* View header */ +struct wccp2_cache_view_header_t { + uint16_t cache_view_type; + uint16_t cache_view_length; + uint32_t cache_view_version; +}; + +static struct wccp2_cache_view_header_t wccp2_cache_view_header; + +/* View info */ +struct wccp2_cache_view_info_t { + uint32_t num_routers; + uint32_t num_caches; +}; + +static struct wccp2_cache_view_info_t wccp2_cache_view_info; + +/* Router ID element */ +struct wccp2_router_id_element_t { + struct in_addr router_address; + uint32_t received_id; +}; + +static struct wccp2_router_id_element_t wccp2_router_id_element; + +/* Capability info header */ +struct wccp2_capability_info_header_t { + uint16_t capability_info_type; + uint16_t capability_info_length; +}; + +/* Capability element header */ +struct wccp2_capability_element_header_t { + uint16_t capability_type; + uint16_t capability_length; +}; + +/* Capability element */ +struct wccp2_capability_element_t { + uint16_t capability_type; + uint16_t capability_length; + uint32_t capability_value; +}; + +static struct wccp2_capability_element_t wccp2_capability_element; + +/* Mask Element */ +struct wccp2_mask_element_t { + uint32_t source_ip_mask; + uint32_t dest_ip_mask; + uint16_t source_port_mask; + uint16_t dest_port_mask; + uint32_t number_values; +}; + +/* Value Element */ +struct wccp2_value_element_t { + uint32_t source_ip_value; + uint32_t dest_ip_value; + uint16_t source_port_value; + uint16_t dest_port_value; + struct in_addr cache_ip; +}; + +/* RECEIVED PACKET STRUCTURE */ +struct wccp2_i_see_you_t { + uint32_t type; + uint16_t version; + uint16_t length; + char data[WCCP_RESPONSE_SIZE]; +}; + +/* Outbound packet */ +struct wccp2_out_packet_t { + struct { + uint32_t type; + uint16_t version; + uint16_t length; + char data[WCCP_RESPONSE_SIZE]; + } p; + char *sec_ofs; + int size; +}; + +static struct wccp2_i_see_you_t wccp2_i_see_you; + +/* Router ID element */ +struct wccp2_router_assign_element_t { + struct in_addr router_address; + uint32_t received_id; + uint32_t change_number; +}; + +/* Generic header struct */ +struct wccp2_item_header_t { + uint16_t type; + uint16_t length; +}; + +/* Router identity struct */ +struct router_identity_info_t { + struct wccp2_item_header_t header; + struct wccp2_router_id_element_t router_id_element; + struct in_addr router_address; + uint32_t number_caches; +}; + +/* The received packet for a mask assignment is unusual */ +struct cache_mask_info_t { + struct in_addr addr; + uint32_t num1; + uint32_t num2; + uint32_t num3; +}; + +/* assigment key */ +struct assignment_key_t { + struct in_addr master_ip; + uint32_t master_number; +}; + +/* Router view of WCCP */ +struct router_view_t { + struct wccp2_item_header_t header; + uint32_t change_number; + struct assignment_key_t assignment_key; +}; + +/* Lists used to keep track of caches, routers and services */ +struct wccp2_cache_list_t { + struct in_addr cache_ip; + int weight; + struct wccp2_cache_list_t *next; +}; + +struct wccp2_router_list_t { + struct in_addr router_address; + uint32_t received_id; + uint32_t change_number; + struct in_addr local_ip; + struct in_addr router_sendto_address; + int seen; + uint32_t member_change; + uint32_t num_caches; + struct wccp2_cache_list_t cache_list_head; + struct wccp2_router_list_t *next; +}; + +struct wccp2_service_list_t { + struct wccp2_service_info_t info; + struct wccp2_router_list_t router_list_head; + int lowest_ip; + uint32_t change_num; + char *wccp2_identity_info_ptr; + struct wccp2_service_list_t *next; + char wccp_password[WCCP2_PASSWORD_LEN + 1]; /* hold the trailing C-string NUL */ + uint32_t wccp2_security_type; +}; + + +#endif