]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Friendly WCCPv2 method config
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 10 Sep 2008 15:22:08 +0000 (03:22 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 10 Sep 2008 15:22:08 +0000 (03:22 +1200)
src/cf.data.depend
src/cf.data.pre
src/protos.h
src/wccp2.cc

index 5c48bc19dc43b8fe8b7dfd11bf2be65b4f0cb5e7..ec1630c68cfbc12243e465a2c2a628c20a346d33 100644 (file)
@@ -47,6 +47,7 @@ time_t
 tristate
 uri_whitespace
 ushort
+wccp2_method
 wccp2_service
 wccp2_service_info
 wordlist
index 6a248a69fac3563d4861b8fd33c88dfe0a93eb0f..10845cf793ad6696971ab9e62986ed50cf1f06d1 100644 (file)
@@ -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.
index b18b0b14499770bd4aac7dac3eca653f46fc10e4..0b499bab0d43abf1592b09f61c926737f1c9e1fa 100644 (file)
@@ -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);
index 09d5556d96452b25c0b0ee57e3fc53750aab52e8..960906f92afceed369cda4fdc30f3705d00be817 100644 (file)
@@ -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:
  *