]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Support unified EUI format code in external_acl_type
authorSteve Hill <steve@opendium.com>
Tue, 17 May 2016 14:58:50 +0000 (02:58 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 17 May 2016 14:58:50 +0000 (02:58 +1200)
Squid supports %>eui as a logformat specifier, which produces an EUI-48
for IPv4 clients and an EUI-64 for IPv6 clients.  However, This is not
allowed as a format specifier for the external ACLs, and you have to use
%SRCEUI48 and %SRCEUI64 instead.  %SRCEUI48 is only useful for IPv4
clients and %SRCEUI64 is only useful for IPv6 clients, so supporting
both v4 and v6 is a bit messy.

Adds the %>eui specifier for external ACLs and behaves in the same way
as the logformat specifier.

src/external_acl.cc

index b67cfceb5a94c49be63934c9ba1000a8ed7a19bc..4eeb160a1668442dc3b9f151ddaf7af06a8bf4d3 100644 (file)
@@ -356,6 +356,8 @@ parse_externalAclHelper(external_acl ** list)
         else if (strcmp(token, "%SRCPORT") == 0 || strcmp(token, "%>p") == 0)
             format->type = Format::LFT_CLIENT_PORT;
 #if USE_SQUID_EUI
+        else if (strcmp(token, "%>eui") == 0)
+            format->type = Format::LFT_CLIENT_EUI;
         else if (strcmp(token, "%SRCEUI48") == 0)
             format->type = Format::LFT_EXT_ACL_CLIENT_EUI48;
         else if (strcmp(token, "%SRCEUI64") == 0)
@@ -944,6 +946,18 @@ makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data)
             break;
 
 #if USE_SQUID_EUI
+        case Format::LFT_CLIENT_EUI:
+            // TODO make the ACL checklist have a direct link to any TCP details.
+            if (request->clientConnectionManager.valid() && request->clientConnectionManager->clientConnection != NULL)
+            {
+                if (request->clientConnectionManager->clientConnection->remote.isIPv4())
+                    request->clientConnectionManager->clientConnection->remoteEui48.encode(buf, sizeof(buf));
+                else
+                    request->clientConnectionManager->clientConnection->remoteEui64.encode(buf, sizeof(buf));
+                str = buf;
+            }
+           break;
+
         case Format::LFT_EXT_ACL_CLIENT_EUI48:
             if (request->clientConnectionManager.valid() && request->clientConnectionManager->clientConnection != NULL &&
                     request->clientConnectionManager->clientConnection->remoteEui48.encode(buf, sizeof(buf)))