trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shinr...@apache.org
Subject trafficserver git commit: TS-3219: Move tools/wccp_client to cmd/traffic_wccp.
Date Fri, 09 Jan 2015 16:16:53 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master a60d6db62 -> 9859731bf


TS-3219: Move tools/wccp_client to cmd/traffic_wccp.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/9859731b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/9859731b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/9859731b

Branch: refs/heads/master
Commit: 9859731bfdd41daa961b992ff6cc8824cfb15636
Parents: a60d6db
Author: shinrich <shinrich@yahoo-inc.com>
Authored: Fri Jan 9 08:09:00 2015 -0600
Committer: shinrich <shinrich@yahoo-inc.com>
Committed: Fri Jan 9 10:15:06 2015 -0600

----------------------------------------------------------------------
 cmd/Makefile.am                                 |   8 +-
 cmd/traffic_wccp/Makefile.am                    |  36 +++
 cmd/traffic_wccp/readme.txt                     |  42 +++
 cmd/traffic_wccp/service-nogre-example.config   |  66 +++++
 cmd/traffic_wccp/wccp_client.cc                 | 231 +++++++++++++++++
 configure.ac                                    |   1 +
 doc/admin/transparent-proxy.en.rst              |   1 +
 .../wccp-service-config.en.rst                  |  75 ++++++
 doc/reference/commands/index.en.rst             |   2 +-
 doc/reference/commands/traffic_server.en.rst    |   2 +-
 doc/reference/commands/traffic_wccp.en.rst      |  63 +++++
 doc/reference/commands/wccp_client.en.rst       |  74 ------
 tools/Makefile.am                               |  13 -
 tools/wccp_client/Makefile.am                   |  33 ---
 tools/wccp_client/readme.txt                    |  42 ---
 tools/wccp_client/service-nogre-example.config  |  66 -----
 tools/wccp_client/wccp_client.cc                | 256 -------------------
 17 files changed, 524 insertions(+), 487 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/cmd/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
index 5f02dd5..3636cfe 100644
--- a/cmd/Makefile.am
+++ b/cmd/Makefile.am
@@ -22,4 +22,10 @@ SUBDIRS = \
   traffic_line \
   traffic_manager \
   traffic_top \
-  traffic_via
+  traffic_via 
+
+if BUILD_WCCP 
+
+SUBDIRS += traffic_wccp
+
+endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/cmd/traffic_wccp/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_wccp/Makefile.am b/cmd/traffic_wccp/Makefile.am
new file mode 100644
index 0000000..6adec70
--- /dev/null
+++ b/cmd/traffic_wccp/Makefile.am
@@ -0,0 +1,36 @@
+#
+# Makefile.am for the Enterprise Management module.
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+
+AM_CPPFLAGS = $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib \
+  -I$(top_srcdir)/lib/records \
+  -I$(top_srcdir)/lib/ts \
+  -I$(top_srcdir)/lib/wccp
+
+bin_PROGRAMS = traffic_wccp
+
+traffic_wccp_SOURCES = wccp_client.cc
+
+traffic_wccp_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
+
+traffic_wccp_LDADD = -L$(top_builddir)/lib/tsconfig -ltsconfig \
+  -L$(top_builddir)/lib/wccp -lwccp \
+  -L$(top_builddir)/lib/ts -ltsutil
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/cmd/traffic_wccp/readme.txt
----------------------------------------------------------------------
diff --git a/cmd/traffic_wccp/readme.txt b/cmd/traffic_wccp/readme.txt
new file mode 100644
index 0000000..d86e8c3
--- /dev/null
+++ b/cmd/traffic_wccp/readme.txt
@@ -0,0 +1,42 @@
+Wccp_client is a front end to the wccp client library.  It is a stand
+alone program that speaks the client side of the WCCP cache protocol.
+
+It can be used instead of the built in WCCP feature in Apache traffic server.
+This can be beneficial if you have multiple programs running on the same
+computer that are relying on WCCP to redirect traffic from the router to 
+the computer.
+
+Since it relies on the wccp library, the wccp_client is only build if apache
+traffic server is configured with --enable-wccp.
+
+The overall Apache Traffic Server WCCP configuration documentation is
+at https://docs.trafficserver.apache.org/en/latest/admin/transparent-proxy/wccp-configuration.en.html.
+
+The wccp-client takes the following arguments. 
+--address IP address to bind.
+--router Booststrap IP address for routers.
+--service Path to service group definitions.
+--debug Print debugging information.
+--daemon Run as daemon.
+
+You need to run at least with the --address and the --service arguments. The
+address should be an address assigned to one of your computer's interfaces.
+An example service definition file, service-nogre-example.config, is included
+in this directory.  In this file you define your MD5 security password
+(highly recommended), and you define your service groups.  For each service
+group you define how the service should be recognized (protocol and port),
+the routers you are communicating with, whether you are using GRE or basic L2
+routing to redirect packets.  
+
+In addition, you can specify a proc-name, a path
+to a process pid file.  If the proc-name is present, the wccp client will 
+only advertise the associated service group, if the process is currently 
+up and running.  So if your computer is hosting three services, and one of
+them goes down, the wccp client could stop advertising the service group 
+associated with the down service thus stopping the router from redirecting
+that traffic, but continue to advertise and maintain the redireciton for the
+other two services.
+
+The current WCCP implementation associated with ATS only supports one cache
+client per service group per router.  The cache assignment logic current
+assigns the current cache client to all buckets.  

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/cmd/traffic_wccp/service-nogre-example.config
----------------------------------------------------------------------
diff --git a/cmd/traffic_wccp/service-nogre-example.config b/cmd/traffic_wccp/service-nogre-example.config
new file mode 100644
index 0000000..56152b5
--- /dev/null
+++ b/cmd/traffic_wccp/service-nogre-example.config
@@ -0,0 +1,66 @@
+security = {
+  key = "example-password";
+  option = "MD5";
+};
+
+services = (
+  {
+    name = "WCCP HTTP Client";
+    description = "Capture packets from client";
+    proc-name = "/opt/ats/var/trafficserver/cop.lock";
+    id = 51;
+    type = "DYNAMIC";
+    priority = 240;
+    protocol = 6;
+    primary-hash = ( "src_ip" );
+    ports = ( 80 );
+    assignment = ( "hash" );
+    forward = ( "l2" );
+    return = ( "l2" );
+    routers = ( "10.10.50.1" );
+  },
+  {
+    name = "WCCP HTTP Server";
+    description = "Capture packets from origin server";
+    proc-name = "/opt/ats/var/trafficserver/cop.lock";
+    id = 52;
+    type = "DYNAMIC";
+    priority = 240;
+    protocol = 6;
+    primary-hash = ( "dst_ip" );
+    ports = ( 80 );
+    port-type = "src";
+    assignment = ( "hash" );
+    forward = ( "l2" );
+    return = ( "l2" );
+    routers = ( "10.10.50.1" );
+  },
+  {
+    name = "WCCP RTMP Client";
+    description = "Capture packets from client";
+    id = 53;
+    type = "DYNAMIC";
+    priority = 240;
+    protocol = 6;
+    primary-hash = ( "src_ip" );
+    ports = ( 1935 );
+    assignment = ( "hash" );
+    forward = ( "l2" );
+    return = ( "l2" );
+    routers = ( "10.10.50.1" );
+  },
+  {
+    name = "WCCP RTSP Client";
+    description = "Capture packets from client";
+    id = 55;
+    type = "DYNAMIC";
+    priority = 240;
+    protocol = 6;
+    primary-hash = ( "src_ip" );
+    ports = ( 5544 );
+    assignment = ( "hash" );
+    forward = ( "l2" );
+    return = ( "l2" );
+    routers = ( "10.10.50.1" );
+  },
+);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/cmd/traffic_wccp/wccp_client.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_wccp/wccp_client.cc b/cmd/traffic_wccp/wccp_client.cc
new file mode 100644
index 0000000..4e28032
--- /dev/null
+++ b/cmd/traffic_wccp/wccp_client.cc
@@ -0,0 +1,231 @@
+/** @file
+    WCCP cache client
+
+    @section license License
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <memory.h>
+#include <strings.h>
+#include <iostream>
+#include <iomanip>
+
+#include <getopt.h>
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <poll.h>
+
+#include "ink_memory.h"
+#include "Wccp.h"
+#include "WccpUtil.h"
+#include "tsconfig/TsValue.h"
+#include "ink_lockfile.h"
+
+#define WCCP_LOCK "wccp.pid"
+
+bool do_debug = false;
+bool do_daemon = false;
+
+static char const USAGE_TEXT[] =
+  "%s\n"
+  "--address IP address to bind.\n"
+  "--router Booststrap IP address for routers.\n"
+  "--service Path to service group definitions.\n"
+  "--debug Print debugging information.\n"
+  "--daemon Run as daemon.\n"
+  "--help Print usage and exit.\n"
+  ;
+
+static void
+PrintErrata(ts::Errata const& err) 
+{
+  size_t n;
+  static size_t const SIZE = 4096;
+  char buff[SIZE];
+  if (err.size()) {
+    ts::Errata::Code code = err.top().getCode();
+    if (do_debug || code >=  wccp::LVL_WARN) {
+      n = err.write(buff, SIZE, 1, 0, 2, "> ");
+      // strip trailing newlines.
+      while (n && (buff[n-1] == '\n' || buff[n-1] == '\r'))
+        buff[--n] = 0;
+      printf("%s\n", buff);
+    }
+  }
+}
+
+static void
+Init_Errata_Logging() 
+{
+  ts::Errata::registerSink(&PrintErrata);
+}
+
+static void
+check_lockfile()
+{
+  char lockfile[256];
+  pid_t holding_pid;
+  int err;
+
+  strcpy(lockfile, "/var/run/");
+  strcat(lockfile, WCCP_LOCK);
+
+  Lockfile server_lockfile(lockfile);
+  err = server_lockfile.Get(&holding_pid);
+
+  if (err != 1) {
+    char *reason = strerror(-err);
+    fprintf(stderr, "WARNING: Can't acquire lockfile '%s'", (const char *)lockfile);
+
+    if ((err == 0) && (holding_pid != -1)) {
+      fprintf(stderr, " (Lock file held by process ID %l" PRIu32 ")\n", (long)holding_pid);
+    } else if ((err == 0) && (holding_pid == -1)) {
+      fprintf(stderr, " (Lock file exists, but can't read process ID)\n");
+    } else if (reason) {
+      fprintf(stderr, " (%s)\n", reason);
+    } else {
+      fprintf(stderr, "\n");
+    }
+    _exit(1);
+  }
+}
+
+int
+main(int argc, char** argv) {
+  wccp::Cache wcp;
+
+  // getopt return values. Selected to avoid collisions with
+  // short arguments.
+  static int const OPT_ADDRESS = 257; ///< Bind to IP address option.
+  static int const OPT_HELP = 258; ///< Print help message.
+  static int const OPT_ROUTER = 259; ///< Seeded router IP address.
+  static int const OPT_SERVICE = 260; ///< Service group definition.
+  static int const OPT_DEBUG = 261; ///< Enable debug printing
+  static int const OPT_DAEMON = 262; ///< Disconnect and run as daemon
+
+  static option OPTIONS[] = {
+    { "address", 1, 0, OPT_ADDRESS },
+    { "router", 1, 0, OPT_ROUTER },
+    { "service", 1, 0, OPT_SERVICE },
+    { "debug", 0, 0, OPT_DEBUG },
+    { "daemon", 0, 0, OPT_DAEMON },
+    { "help", 0, 0, OPT_HELP },
+    { 0, 0, 0, 0 } // required terminator.
+  };
+
+  in_addr ip_addr = { INADDR_ANY };
+  in_addr router_addr = { INADDR_ANY };
+
+  int zret; // getopt return.
+  int zidx; // option index.
+  bool fail = false;
+  char const* FAIL_MSG = "";
+
+  while (-1 != (zret = getopt_long_only(argc, argv, "", OPTIONS, &zidx))) {
+    switch (zret) {
+    case OPT_HELP:
+      FAIL_MSG = "Usage:";
+      fail = true;
+      break;
+    case '?':
+      FAIL_MSG = "Invalid option specified.";
+      fail = true;
+      break;
+    case OPT_ADDRESS:
+      if (0 == inet_aton(optarg, &ip_addr)) {
+        FAIL_MSG = "Invalid IP address specified for client.";
+        fail = true;
+      }
+      break;
+    case OPT_ROUTER:
+      if (0 == inet_aton(optarg, &router_addr)) {
+        FAIL_MSG = "Invalid IP address specified for router.";
+        fail = true;
+      }
+      break;
+    case OPT_SERVICE: {
+      ts::Errata status = wcp.loadServicesFromFile(optarg);
+      if (!status) fail = true;
+      break;
+    }
+    case OPT_DEBUG: 
+      do_debug = true;
+      break;
+    case OPT_DAEMON: 
+      do_daemon = true;
+      break;
+    }
+  }
+
+  if (fail) {
+    printf(USAGE_TEXT, FAIL_MSG);
+    return 1;
+  }
+ 
+  if (0 > wcp.open(ip_addr.s_addr)) {
+    fprintf(stderr, "Failed to open or bind socket.\n");
+    return 2;
+  }
+
+  if (do_daemon) {
+    pid_t pid = fork();
+    if (pid > 0) {
+      // Successful, the parent should go away
+      _exit(0);
+    }
+  }
+
+  check_lockfile();
+
+  // Set up erratum support.
+  Init_Errata_Logging();
+
+  static int const POLL_FD_COUNT = 1;
+  pollfd pfa[POLL_FD_COUNT];
+
+  // Poll on the socket.
+  pfa[0].fd = wcp.getSocket();
+  pfa[0].events = POLLIN;
+
+  wcp.housekeeping();
+
+  while (true) {
+    int n = poll(pfa, POLL_FD_COUNT,  1000);
+    if (n < 0) { // error
+      perror("General polling failure");
+      return 5;
+    } else if (n > 0) { // things of interest happened
+      if (pfa[0].revents) {
+        if (pfa[0].revents & POLLIN) {
+          wcp.handleMessage();
+        } else {
+          fprintf(stderr, "Socket failure.\n");
+          return 6;
+        }
+      }
+    } else { // timeout
+      wcp.housekeeping();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 1738613..0e09e12 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1859,6 +1859,7 @@ AC_CONFIG_FILES([
   cmd/traffic_manager/Makefile
   cmd/traffic_top/Makefile
   cmd/traffic_via/Makefile
+  cmd/traffic_wccp/Makefile
   doc/Makefile
   example/Makefile
   iocore/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/doc/admin/transparent-proxy.en.rst
----------------------------------------------------------------------
diff --git a/doc/admin/transparent-proxy.en.rst b/doc/admin/transparent-proxy.en.rst
index 74ae56f..dae102e 100644
--- a/doc/admin/transparent-proxy.en.rst
+++ b/doc/admin/transparent-proxy.en.rst
@@ -27,6 +27,7 @@ Transparent Proxying
    transparent-proxy/bridge.en
    transparent-proxy/router-inline.en
    transparent-proxy/wccp-configuration.en
+   transparent-proxy/wccp-service-config.en
 
 Transparent Proxying is the ability of a proxy (such as ATS) to
 intercept connections between clients and servers without being visible.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/doc/admin/transparent-proxy/wccp-service-config.en.rst
----------------------------------------------------------------------
diff --git a/doc/admin/transparent-proxy/wccp-service-config.en.rst b/doc/admin/transparent-proxy/wccp-service-config.en.rst
new file mode 100644
index 0000000..7726ebe
--- /dev/null
+++ b/doc/admin/transparent-proxy/wccp-service-config.en.rst
@@ -0,0 +1,75 @@
+WCCP Service Configuration
+**************************
+
+.. Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+ 
+   http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+
+.. _wccp-service-configuration:
+
+The service definition file is used by
+:ref:`traffic_wccp` and :ref:`traffic-server` directly.
+The elements in the security definition file are inspired by the `WCCP RFC (8/2012) <http://tools.ietf.org/html/draft-mclaggan-wccp-v2rev1-00>`_.
 There is also an older version of the RFC that shows up commonly in search results, `WCCP
(4/2001) <https://tools.ietf.org/id/draft-wilson-wrec-wccp-v2-01.txt>`_, and was the
RFC reference used in the original WCCP support for Traffic Server several years ago.
+
+A sample service group file is included in the source tree under cmd/traffic_wccp.
+
+Security Section
+================
+
+In the security section, you can define a password shared between the WCCP Client and the
WCCP router.  This password is used to encrypt the WCCP traffic.  It is optional, but highly
recommended.
+
+Attributes in this section
+
+*  option  - Must be set to MD5 if you want to encrypt your WCCP traffic
+
+*  key – The same password that you set with the associated WCCP router.
+
+Services Section
+================
+
+In the services section you can define a list of service groups.  Each top level entry is
a separate service group.  
+
+Service group attributes include
+
+*  name – A name for the service.  Not used in the rest of the WCCP processing.
+
+*  description – A description of the service.  Again, not used in the rest of the WCCP
processing.
+
+*  id - The security group ID.  It must match the service group ID that has been defined
on the associated WCCP router.  This is the true service group identifier from the WCCP perspective.
 
+
+* type – This defines the type of service group either “STANDARD” or “DYNAMIC”.
 There is one standard defined service group, HTTP with the id of 0.  The 4/2001 RFC indicates
that id’s 0-50 are reserved for well known service groups.  But more recent 8/2012 RFC indicates
that values 0 through 254 are valid service id’s for dynamic services.  To avoid differences
with older WCCP routers, you probably want to  avoid dynamic service ID’s 0 through 50.
 
+
+* priority – This is a value from 0 to 255.  The higher number is a higher priority.  Well
known (STANDARD) services are set to a value of 240.  If there are multiple service groups
that could match a given packet, the higher priority service group is applied. RFC  For example,
you have service group 100 defined for packets with destination port 80, and service group
101 defined for packets with source port 1024.  For a packet with destination port set to
80 and source port set to 1024, the priorities of the service groups would need to be compared
to determine which service group applies.
+
+* protocol – This is IP protocol number that should match.  Generally this is set to 6
(TCP) or 17 (UDP).
+
+* assignment – WCCP supports multiple WCCP clients supporting a single service group. 
However, the current WCCP client implementation in Traffic Server assumes there is only a
single WCCP client, and so creates assignment tables that will direct all traffic to that
WCCP client.  The assignment type is either hash or mask, and if it is not set, it defaults
to hash.  If Traffic Server ever supports more than one cache, it will likely only support
a balanced hash assignment.  The mask/value assignment seems to be better suited to situations
where the traffic needs to be more strongly controlled.
+
+* primary-hash – This is the element of the packet that is used to compute the primary
key.  The value options are src_ip, dst_ip, src_port, or  dst_port. This entry is a list,
so multiple values can be specified.  In that case, all the specified packet attributes will
be used to compute the hash bucket.  In the current implementation, the primary hash value
does not matter, since the client always generates a hash table that directs all matching
traffic to it.  But if multiple clients are ever supported, knowledge of the local traffic
distribution could be used to pick a packet attribute that will better spread traffic over
the WCCP clients.
+*  alt-hash – The protocol supports a two level hash.  This attribute is a list with the
same value options as for primary-hash.  Again, since the current Traffic Server implementation
only creates assignment tables to a single client, specifying the alt-hash values does nothing.
 
+
+* ports – This is a list of port values.  Up to 8 port values may be included in a service
group definition.  
+
+* port-type – This attribute can have the value of src or dst.  If not specified, it defaults
to dst.  It indicates whether the port values should be interpreted as source ports or destination
ports.
+
+* forward – This is a list.  The list of the values can be GRE or L2.  This advertises
how the client wants to process WCCP packets.  GRE means that the packets will be delivered
in a GRE tunnel.  This is the default.  L2 means that the client is on the same network and
can get traffic delivered to it from the router by L2 routing (MAC addresses).
+
+* return – The WCCP protocol allows a WCCP client to decline a packet and return it back
to the router.  The current WCCP client implementation never does this.  The value options
are the same as for the forward attribute.
+
+* routers – This is the list of router addresses the WCCP client communicates with.  The
WCCP protocols allows for multiple WCCP routers to be involved in a service group.  The multiple
router scenario has at most been lightly tested in the Traffic Server implementation.
+
+* proc-name – This attribute is only used by traffic_wccp.  It is not used in the traffic_server
WCCP support.  This is the path to a process’ PID file.  The service group is advertised
to the WCCP router if the process identified in the PID file is currently operational.
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/doc/reference/commands/index.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/index.en.rst b/doc/reference/commands/index.en.rst
index 5488d60..633b98d 100644
--- a/doc/reference/commands/index.en.rst
+++ b/doc/reference/commands/index.en.rst
@@ -30,6 +30,6 @@ Command Reference
    traffic_server.en
    traffic_top.en
    traffic_via.en
+   traffic_wccp.en
    tspush.en
    tsxs.en
-   wccp_client.en

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/doc/reference/commands/traffic_server.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/traffic_server.en.rst b/doc/reference/commands/traffic_server.en.rst
index 75c11ea..abbee2a 100644
--- a/doc/reference/commands/traffic_server.en.rst
+++ b/doc/reference/commands/traffic_server.en.rst
@@ -15,7 +15,7 @@
   specific language governing permissions and limitations
   under the License.
 
-.. _traffic_server:
+.. _traffic-server:
 
 ==============
 traffic_server

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/doc/reference/commands/traffic_wccp.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/traffic_wccp.en.rst b/doc/reference/commands/traffic_wccp.en.rst
new file mode 100644
index 0000000..efb1e4d
--- /dev/null
+++ b/doc/reference/commands/traffic_wccp.en.rst
@@ -0,0 +1,63 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+ 
+   http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+
+.. _traffic_wccp:
+
+============
+traffic_wccp
+============
+
+.. program:: traffic_wccp
+
+Description
+===========
+
+Traffic_wccp is a front end to the wccp client library.  It is a stand
+alone program that speaks the client side of the WCCP cache protocol.
+
+It can be used instead of the built in WCCP feature in Apache traffic server.
+This can be beneficial if you have multiple programs running on the same
+computer that are relying on WCCP to redirect traffic from the router to 
+the computer.
+
+Since it relies on the wccp library, traffic_wccp is only built if apache
+traffic server is configured with --enable-wccp.
+
+The overall Apache Traffic Server WCCP configuration documentation is
+at  :ref:`WCCP Configuration <wccp-configuration>`
+
+The wccp-client takes the following arguments. 
+
+.. option:: --address IP address to bind.
+
+.. option:: --router Booststrap IP address for routers.
+
+.. option:: --service Path to service group definitions.
+
+.. option:: --debug Print debugging information.
+
+.. option:: --daemon Run as daemon.
+
+You need to run at least with the --service arguments. 
+An example service definition file, service-nogre-example.config, is included
+in the cmd/traffic_wccp directory.  In this file you define your MD5 security password
+(highly recommended), and you define your service groups.  The details
+of the service file are defined at :ref:`WCCP Service Configuration <wccp-service-configuration>`.
+
+The current WCCP implementation associated with ATS only supports one cache
+client per service group per router.  The cache assignment logic current
+assigns the current cache client to all buckets.  

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/doc/reference/commands/wccp_client.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/wccp_client.en.rst b/doc/reference/commands/wccp_client.en.rst
deleted file mode 100644
index 59e7df0..0000000
--- a/doc/reference/commands/wccp_client.en.rst
+++ /dev/null
@@ -1,74 +0,0 @@
-.. Licensed to the Apache Software Foundation (ASF) under one
-   or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
- 
-   http://www.apache.org/licenses/LICENSE-2.0
- 
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
-
-.. _wccp_client:
-
-===========
-wccp_client
-===========
-
-.. program:: wccp_client
-
-Description
-===========
-
-Wccp_client is a front end to the wccp client library.  It is a stand
-alone program that speaks the client side of the WCCP cache protocol.
-
-It can be used instead of the built in WCCP feature in Apache traffic server.
-This can be beneficial if you have multiple programs running on the same
-computer that are relying on WCCP to redirect traffic from the router to 
-the computer.
-
-Since it relies on the wccp library, the wccp_client is only build if apache
-traffic server is configured with --enable-wccp.
-
-The overall Apache Traffic Server WCCP configuration documentation is
-at  :ref:`WCCP Configuratoin <wccp-configuration>`
-
-The wccp-client takes the following arguments. 
-
-.. option:: --address IP address to bind.
-
-.. option:: --router Booststrap IP address for routers.
-
-.. option:: --service Path to service group definitions.
-
-.. option:: --debug Print debugging information.
-
-.. option:: --daemon Run as daemon.
-
-You need to run at least with the --service arguments. 
-An example service definition file, service-nogre-example.config, is included
-in the tools/wccp_client directory.  In this file you define your MD5 security password
-(highly recommended), and you define your service groups.  For each service
-group you define how the service should be recognized (protocol and port),
-the routers you are communicating with, whether you are using GRE or basic L2
-routing to redirect packets.  
-
-In addition, you can specify a proc-name, a path
-to a process pid file.  If the proc-name is present, the wccp client will 
-only advertise the associated service group, if the process is currently 
-up and running.  So if your computer is hosting three services, and one of
-them goes down, the wccp client could stop advertising the service group 
-associated with the down service thus stopping the router from redirecting
-that traffic, but continue to advertise and maintain the redireciton for the
-other two services.
-
-The current WCCP implementation associated with ATS only supports one cache
-client per service group per router.  The cache assignment logic current
-assigns the current cache client to all buckets.  

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/tools/Makefile.am
----------------------------------------------------------------------
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 4b04473..c053068 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -51,16 +51,3 @@ http_load_http_load_SOURCES =  \
 
 endif
 
-if BUILD_WCCP 
-
-if BUILD_TEST_TOOLS
-bin_PROGRAMS += wccp_client/wccp_client
-else
-bin_PROGRAMS = wccp_client/wccp_client
-endif
-
-wccp_client_wccp_client_SOURCES = wccp_client/wccp_client.cc
-
-wccp_client_wccp_client_LDADD = -L$(top_builddir)/lib/tsconfig -ltsconfig -L$(top_builddir)/lib/wccp
-lwccp -L$(top_builddir)/lib/ts -ltsutil
-
-endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/tools/wccp_client/Makefile.am
----------------------------------------------------------------------
diff --git a/tools/wccp_client/Makefile.am b/tools/wccp_client/Makefile.am
deleted file mode 100644
index 969d67c..0000000
--- a/tools/wccp_client/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Makefile.am for WCCP client
-#
-#  Licensed to the Apache Software Foundation (ASF) under one
-#  or more contributor license agreements.  See the NOTICE file
-#  distributed with this work for additional information
-#  regarding copyright ownership.  The ASF licenses this file
-#  to you under the Apache License, Version 2.0 (the
-#  "License"); you may not use this file except in compliance
-#  with the License.  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-
-AM_CPPFLAGS = \
-  -I$(top_srcdir)/lib \
-  -I$(top_srcdir)/lib/ts \
-  -I$(top_srcdir)/proxy/api/ts
-
-#WCCP_DEFS = @WCCP_DEFS@
-#DEFS += $(WCCP_DEFS)
-
-noinst_PROGRAMS = test-cache 
-
-test_cache_SOURCES = \
-  wccp-test-cache.cc
-
-test_cache_LDADD = $(LDADD) -L$(top_builddir)/lib/tsconfig -ltsconfig -L$(top_builddir)/lib/wccp
-lwccp -L$(top_builddir)/lib/ts -ltsutil

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/tools/wccp_client/readme.txt
----------------------------------------------------------------------
diff --git a/tools/wccp_client/readme.txt b/tools/wccp_client/readme.txt
deleted file mode 100644
index d86e8c3..0000000
--- a/tools/wccp_client/readme.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Wccp_client is a front end to the wccp client library.  It is a stand
-alone program that speaks the client side of the WCCP cache protocol.
-
-It can be used instead of the built in WCCP feature in Apache traffic server.
-This can be beneficial if you have multiple programs running on the same
-computer that are relying on WCCP to redirect traffic from the router to 
-the computer.
-
-Since it relies on the wccp library, the wccp_client is only build if apache
-traffic server is configured with --enable-wccp.
-
-The overall Apache Traffic Server WCCP configuration documentation is
-at https://docs.trafficserver.apache.org/en/latest/admin/transparent-proxy/wccp-configuration.en.html.
-
-The wccp-client takes the following arguments. 
---address IP address to bind.
---router Booststrap IP address for routers.
---service Path to service group definitions.
---debug Print debugging information.
---daemon Run as daemon.
-
-You need to run at least with the --address and the --service arguments. The
-address should be an address assigned to one of your computer's interfaces.
-An example service definition file, service-nogre-example.config, is included
-in this directory.  In this file you define your MD5 security password
-(highly recommended), and you define your service groups.  For each service
-group you define how the service should be recognized (protocol and port),
-the routers you are communicating with, whether you are using GRE or basic L2
-routing to redirect packets.  
-
-In addition, you can specify a proc-name, a path
-to a process pid file.  If the proc-name is present, the wccp client will 
-only advertise the associated service group, if the process is currently 
-up and running.  So if your computer is hosting three services, and one of
-them goes down, the wccp client could stop advertising the service group 
-associated with the down service thus stopping the router from redirecting
-that traffic, but continue to advertise and maintain the redireciton for the
-other two services.
-
-The current WCCP implementation associated with ATS only supports one cache
-client per service group per router.  The cache assignment logic current
-assigns the current cache client to all buckets.  

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/tools/wccp_client/service-nogre-example.config
----------------------------------------------------------------------
diff --git a/tools/wccp_client/service-nogre-example.config b/tools/wccp_client/service-nogre-example.config
deleted file mode 100644
index 56152b5..0000000
--- a/tools/wccp_client/service-nogre-example.config
+++ /dev/null
@@ -1,66 +0,0 @@
-security = {
-  key = "example-password";
-  option = "MD5";
-};
-
-services = (
-  {
-    name = "WCCP HTTP Client";
-    description = "Capture packets from client";
-    proc-name = "/opt/ats/var/trafficserver/cop.lock";
-    id = 51;
-    type = "DYNAMIC";
-    priority = 240;
-    protocol = 6;
-    primary-hash = ( "src_ip" );
-    ports = ( 80 );
-    assignment = ( "hash" );
-    forward = ( "l2" );
-    return = ( "l2" );
-    routers = ( "10.10.50.1" );
-  },
-  {
-    name = "WCCP HTTP Server";
-    description = "Capture packets from origin server";
-    proc-name = "/opt/ats/var/trafficserver/cop.lock";
-    id = 52;
-    type = "DYNAMIC";
-    priority = 240;
-    protocol = 6;
-    primary-hash = ( "dst_ip" );
-    ports = ( 80 );
-    port-type = "src";
-    assignment = ( "hash" );
-    forward = ( "l2" );
-    return = ( "l2" );
-    routers = ( "10.10.50.1" );
-  },
-  {
-    name = "WCCP RTMP Client";
-    description = "Capture packets from client";
-    id = 53;
-    type = "DYNAMIC";
-    priority = 240;
-    protocol = 6;
-    primary-hash = ( "src_ip" );
-    ports = ( 1935 );
-    assignment = ( "hash" );
-    forward = ( "l2" );
-    return = ( "l2" );
-    routers = ( "10.10.50.1" );
-  },
-  {
-    name = "WCCP RTSP Client";
-    description = "Capture packets from client";
-    id = 55;
-    type = "DYNAMIC";
-    priority = 240;
-    protocol = 6;
-    primary-hash = ( "src_ip" );
-    ports = ( 5544 );
-    assignment = ( "hash" );
-    forward = ( "l2" );
-    return = ( "l2" );
-    routers = ( "10.10.50.1" );
-  },
-);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9859731b/tools/wccp_client/wccp_client.cc
----------------------------------------------------------------------
diff --git a/tools/wccp_client/wccp_client.cc b/tools/wccp_client/wccp_client.cc
deleted file mode 100644
index f8215e9..0000000
--- a/tools/wccp_client/wccp_client.cc
+++ /dev/null
@@ -1,256 +0,0 @@
-/** @file
-    WCCP cache simulation for testing.
-
-    @section license License
-
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
- */
-
-# include <stdio.h>
-# include <unistd.h>
-# include <stdarg.h>
-# include <memory.h>
-# include <strings.h>
-# include <iostream>
-# include <iomanip>
-
-# include <getopt.h>
-
-# include <sys/socket.h>
-# include <netinet/in.h>
-# include <arpa/inet.h>
-
-# include <poll.h>
-
-# include "ink_memory.h"
-# include "Wccp.h"
-# include "WccpUtil.h"
-# include "tsconfig/TsValue.h"
-# include "ink_lockfile.h"
-
-#define WCCP_LOCK       "wccp.pid"
-
-bool do_debug = false;
-bool do_daemon = false;
-
-static char const USAGE_TEXT[] =
-  "%s\n"
-  "--address IP address to bind.\n"
-  "--router Booststrap IP address for routers.\n"
-  "--service Path to service group definitions.\n"
-  "--debug Print debugging information.\n"
-  "--daemon Run as daemon.\n"
-  "--help Print usage and exit.\n"
-  ;
-
-void Log(
-  std::ostream& out,
-  ts::Errata const& errata,
-  int indent = 0
-) {
-  for ( ts::Errata::const_iterator spot = errata.begin(), limit = errata.end();
-        spot != limit;
-        ++spot
-  ) {
-    if (spot->m_id) {
-      if (indent) out << std::setw(indent) << std::setfill(' ') << ">
";
-      out << spot->m_id << " [" << spot->m_code << "]: " <<
spot->m_text
-          << std::endl
-        ;
-    }
-    if (spot->getErrata().size()) Log(out, spot->getErrata(), indent+2);
-  }
-}
-
-void LogToStdErr(ts::Errata const& errata) {
-  Log(std::cerr, errata);
-}
-
-static void
-PrintErrata(ts::Errata const& err) {
-  size_t n;
-  static size_t const SIZE = 4096;
-  char buff[SIZE];
-  if (err.size()) {
-    ts::Errata::Code code = err.top().getCode();
-    if (do_debug || code >=  wccp::LVL_WARN) {
-      n = err.write(buff, SIZE, 1, 0, 2, "> ");
-      // strip trailing newlines.
-      while (n && (buff[n-1] == '\n' || buff[n-1] == '\r'))
-        buff[--n] = 0;
-      printf("%s\n", buff);
-    }
-  }
-}
-
-static void
-Init_Errata_Logging() {
-  ts::Errata::registerSink(&PrintErrata);
-}
-
-static void
-check_lockfile()
-{
-  char lockfile[256];
-  pid_t holding_pid;
-  int err;
-
-  strcpy(lockfile, "/var/run/");
-  strcat(lockfile, WCCP_LOCK);
-
-  Lockfile server_lockfile(lockfile);
-  err = server_lockfile.Get(&holding_pid);
-
-  if (err != 1) {
-    char *reason = strerror(-err);
-    fprintf(stderr, "WARNING: Can't acquire lockfile '%s'", (const char *)lockfile);
-
-    if ((err == 0) && (holding_pid != -1)) {
-      fprintf(stderr, " (Lock file held by process ID %ld)\n", (long)holding_pid);
-    } else if ((err == 0) && (holding_pid == -1)) {
-      fprintf(stderr, " (Lock file exists, but can't read process ID)\n");
-    } else if (reason) {
-      fprintf(stderr, " (%s)\n", reason);
-    } else {
-      fprintf(stderr, "\n");
-    }
-    _exit(1);
-  }
-}
-
-int
-main(int argc, char** argv) {
-  wccp::Cache wcp;
-
-
-  // getopt return values. Selected to avoid collisions with
-  // short arguments.
-  static int const OPT_ADDRESS = 257; ///< Bind to IP address option.
-  static int const OPT_HELP = 258; ///< Print help message.
-  static int const OPT_ROUTER = 259; ///< Seeded router IP address.
-  static int const OPT_SERVICE = 260; ///< Service group definition.
-  static int const OPT_DEBUG = 261; ///< Enable debug printing
-  static int const OPT_DAEMON = 262; ///< Disconnect and run as daemon
-
-  static option OPTIONS[] = {
-    { "address", 1, 0, OPT_ADDRESS },
-    { "router", 1, 0, OPT_ROUTER },
-    { "service", 1, 0, OPT_SERVICE },
-    { "debug", 0, 0, OPT_DEBUG },
-    { "daemon", 0, 0, OPT_DAEMON },
-    { "help", 0, 0, OPT_HELP },
-    { 0, 0, 0, 0 } // required terminator.
-  };
-
-  in_addr ip_addr = { INADDR_ANY };
-  in_addr router_addr = { INADDR_ANY };
-
-  int zret; // getopt return.
-  int zidx; // option index.
-  bool fail = false;
-  char const* FAIL_MSG = "";
-
-  while (-1 != (zret = getopt_long_only(argc, argv, "", OPTIONS, &zidx))) {
-    switch (zret) {
-    case OPT_HELP:
-      FAIL_MSG = "Usage:";
-      fail = true;
-      break;
-    case '?':
-      FAIL_MSG = "Invalid option specified.";
-      fail = true;
-      break;
-    case OPT_ADDRESS:
-      if (0 == inet_aton(optarg, &ip_addr)) {
-        FAIL_MSG = "Invalid IP address specified for client.";
-        fail = true;
-      }
-      break;
-    case OPT_ROUTER:
-      if (0 == inet_aton(optarg, &router_addr)) {
-        FAIL_MSG = "Invalid IP address specified for router.";
-        fail = true;
-      }
-      break;
-    case OPT_SERVICE: {
-      ts::Errata status = wcp.loadServicesFromFile(optarg);
-      if (!status) fail = true;
-      break;
-    }
-    case OPT_DEBUG: 
-      do_debug = true;
-      break;
-    case OPT_DAEMON: 
-      do_daemon = true;
-      break;
-    }
-  }
-
-  if (fail) {
-    printf(USAGE_TEXT, FAIL_MSG);
-    return 1;
-  }
- 
-  if (0 > wcp.open(ip_addr.s_addr)) {
-    fprintf(stderr, "Failed to open or bind socket.\n");
-    return 2;
-  }
-
-  if (do_daemon) {
-    pid_t pid = fork();
-    if (pid > 0) {
-      // Successful, the parent should go away
-      _exit(0);
-    }
-  }
-
-  check_lockfile();
-
-  // Set up erratum support.
-  //ts::Errata::registerSink(&LogToStdErr);
-  Init_Errata_Logging();
-
-  static int const POLL_FD_COUNT = 1;
-  pollfd pfa[POLL_FD_COUNT];
-
-  // Poll on the socket.
-  pfa[0].fd = wcp.getSocket();
-  pfa[0].events = POLLIN;
-
-  wcp.housekeeping();
-
-  while (true) {
-    //time_t dt = std::min(wccp::TIME_UNIT, wcp.waitTime());
-    //printf("Waiting %lu milliseconds\n", dt * 1000);
-    int n = poll(pfa, POLL_FD_COUNT,  1000);
-    if (n < 0) { // error
-      perror("General polling failure");
-      return 5;
-    } else if (n > 0) { // things of interest happened
-      if (pfa[0].revents) {
-        if (pfa[0].revents & POLLIN) {
-          wcp.handleMessage();
-        } else {
-          fprintf(stderr, "Socket failure.\n");
-          return 6;
-        }
-      }
-    } else { // timeout
-      wcp.housekeeping();
-    }
-  }
-}


Mime
View raw message