From: Amos Jeffries Date: Wed, 10 Sep 2008 15:22:08 +0000 (+1200) Subject: Friendly WCCPv2 method config X-Git-Tag: SQUID_3_1_0_1~49^2~15^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e313ab0aa78bcb1330577f050cd0f06ba2fdf7c6;p=thirdparty%2Fsquid.git Friendly WCCPv2 method config --- diff --git a/src/cf.data.depend b/src/cf.data.depend index 5c48bc19dc..ec1630c68c 100644 --- a/src/cf.data.depend +++ b/src/cf.data.depend @@ -47,6 +47,7 @@ time_t tristate uri_whitespace ushort +wccp2_method wccp2_service wccp2_service_info wordlist diff --git a/src/cf.data.pre b/src/cf.data.pre index 6a248a69fa..10845cf793 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -3957,7 +3957,17 @@ TYPE: address LOC: Config.Wccp.router DEFAULT: 0.0.0.0 IFDEF: USE_WCCP -DOC_NONE +DOC_START + Use this option to define your WCCP ``home'' router for + Squid. + + wccp_router supports a single WCCP(v1) router + + wccp2_router supports multiple WCCPv2 routers + + only one of the two may be used at the same time and defines + which version of WCCP to use. +DOC_END NAME: wccp2_router TYPE: IPAddress_list @@ -4005,33 +4015,33 @@ DOC_START DOC_END NAME: wccp2_forwarding_method -TYPE: int +TYPE: wccp2_method LOC: Config.Wccp2.forwarding_method -DEFAULT: 1 +DEFAULT: gre IFDEF: USE_WCCPv2 DOC_START WCCP2 allows the setting of forwarding methods between the router/switch and the cache. Valid values are as follows: - 1 - GRE encapsulation (forward the packet in a GRE/WCCP tunnel) - 2 - L2 redirect (forward the packet using Layer 2/MAC rewriting) + gre - GRE encapsulation (forward the packet in a GRE/WCCP tunnel) + l2 - L2 redirect (forward the packet using Layer 2/MAC rewriting) Currently (as of IOS 12.4) cisco routers only support GRE. Cisco switches only support the L2 redirect assignment method. DOC_END NAME: wccp2_return_method -TYPE: int +TYPE: wccp2_method LOC: Config.Wccp2.return_method -DEFAULT: 1 +DEFAULT: gre IFDEF: USE_WCCPv2 DOC_START WCCP2 allows the setting of return methods between the router/switch and the cache for packets that the cache decides not to handle. Valid values are as follows: - 1 - GRE encapsulation (forward the packet in a GRE/WCCP tunnel) - 2 - L2 redirect (forward the packet using Layer 2/MAC rewriting) + gre - GRE encapsulation (forward the packet in a GRE/WCCP tunnel) + l2 - L2 redirect (forward the packet using Layer 2/MAC rewriting) Currently (as of IOS 12.4) cisco routers only support GRE. Cisco switches only support the L2 redirect assignment. diff --git a/src/protos.h b/src/protos.h index b18b0b1449..0b499bab0d 100644 --- a/src/protos.h +++ b/src/protos.h @@ -813,10 +813,13 @@ SQUIDCEXTERN void externalAclShutdown(void); SQUIDCEXTERN char *strtokFile(void); #if USE_WCCPv2 -SQUIDCEXTERN void parse_wccp2_service(void *v); -SQUIDCEXTERN void free_wccp2_service(void *v); +SQUIDCEXTERN void parse_wccp2_method(int *v); +SQUIDCEXTERN void free_wccp2_method(int *v); +SQUIDCEXTERN void dump_wccp2_method(StoreEntry * e, const char *label, int v); +SQUIDCEXTERN void parse_wccp2_service(void *v); +SQUIDCEXTERN void free_wccp2_service(void *v); SQUIDCEXTERN void dump_wccp2_service(StoreEntry * e, const char *label, void *v); SQUIDCEXTERN int check_null_wccp2_service(void *v); diff --git a/src/wccp2.cc b/src/wccp2.cc index 09d5556d96..960906f92a 100644 --- a/src/wccp2.cc +++ b/src/wccp2.cc @@ -1989,6 +1989,54 @@ wccp2AssignBuckets(void *voidnotused) * Configuration option parsing code */ +/** + * Parse wccp2_return_method and wccp2_forwarding_method options + * they can be '1' aka 'gre' or '2' aka 'l2' + * repesenting the integer numeric of the same. + */ +void +parse_wccp2_method(int *method) +{ + char *t; + + /* Snarf the method */ + if ((t = strtok(NULL, w_space)) == NULL) { + debugs(80, 0, "wccp2_*_method: missing setting. Expected: gre or l2"); + self_destruct(); + } + + /* update configuration if its valid */ + if (strcmp(t, "gre") == 0 || strcmp(t, "1") == 0) { + *method = 1; + } else if (strcmp(t, "l2") == 0 || strcmp(t, "2") == 0) { + *method = 2; + } else { + debugs(80, 0, "wccp2_*_method: unknown setting. Expected: gre or l2, (got " << t << ")"); + self_destruct(); + } +} + +void +dump_wccp2_method(StoreEntry * e, const char *label, int v) +{ + switch(v) + { + case 1: + storeAppendPrintf(e, "%s gre\n", label); + break; + case 2: + storeAppendPrintf(e, "%s l2\n", label); + break; + default: + debugs(80, DBG_CRITICAL, "FATAL: WCCPv2 confifigured method (" << v << ") is not valid."); + self_destruct(); + } +} + +void +free_wccp2_method(int *v) +{ } + /* * Format: *