Repository: trafficserver
Updated Branches:
  refs/heads/master 9da193122 -> 3710a276c


TS-3002: Add DSCP support to header_rewrite


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

Branch: refs/heads/master
Commit: ada9b727a12abbca291d6afbff922c595bba61fe
Parents: 9da1931
Author: Phil Sorber <[email protected]>
Authored: Mon Aug 11 19:14:07 2014 -0600
Committer: Phil Sorber <[email protected]>
Committed: Mon Aug 11 19:14:07 2014 -0600

----------------------------------------------------------------------
 CHANGES                                     |  2 ++
 doc/reference/plugins/header_rewrite.en.rst |  2 +-
 plugins/header_rewrite/factory.cc           |  2 ++
 plugins/header_rewrite/operators.cc         | 24 ++++++++++++++++++++++++
 plugins/header_rewrite/operators.h          | 19 +++++++++++++++++++
 5 files changed, 48 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ada9b727/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 52cc34b..01e1522 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.1.0
 
+  *) [TS-3002] Add DSCP support to header_rewrite.
+
   *) [TS-2999] Add dscp_remap plugin to experimental plugins.
 
   *) [TS-2564] Cherry pick for full cache compatibility.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ada9b727/doc/reference/plugins/header_rewrite.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/plugins/header_rewrite.en.rst 
b/doc/reference/plugins/header_rewrite.en.rst
index af71ab1..3b69a3a 100644
--- a/doc/reference/plugins/header_rewrite.en.rst
+++ b/doc/reference/plugins/header_rewrite.en.rst
@@ -60,6 +60,7 @@ The following operators are available::
   set-timeout-out <value>               [operator_flags]
   set-status-reason <value>             [operator_flags]
   set-config overridable-config <value> [operator_flags]
+  set-conn-dscp <value>                 [operator_flags]
   counter counter-name                  [operator_flags]
   no-op                                 [operator_flags]
 
@@ -183,4 +184,3 @@ Examples
   rm-header Set-Cookie
   counter plugin.header_rewrite.x-y-foobar-dc1
   cond %{HEADER:X-Y-Foobar} "Some string" [AND,NC]
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ada9b727/plugins/header_rewrite/factory.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/factory.cc 
b/plugins/header_rewrite/factory.cc
index b9e2fa8..1d99ea5 100644
--- a/plugins/header_rewrite/factory.cc
+++ b/plugins/header_rewrite/factory.cc
@@ -57,6 +57,8 @@ operator_factory(const std::string& op)
     o = new OperatorNoOp();
   } else if (op == "counter") {
     o = new OperatorCounter();
+  } else if (op == "set-conn-dscp") {
+    o = new OperatorSetConnDSCP();
   } else {
     TSError("%s: unknown operator: %s", PLUGIN_NAME, op.c_str());
     return NULL;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ada9b727/plugins/header_rewrite/operators.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operators.cc 
b/plugins/header_rewrite/operators.cc
index 22165ff..850b8e3 100644
--- a/plugins/header_rewrite/operators.cc
+++ b/plugins/header_rewrite/operators.cc
@@ -543,3 +543,27 @@ OperatorCounter::exec(const Resources& /* ATS_UNUSED res 
*/) const
   TSDebug(PLUGIN_NAME, "OperatorCounter::exec() invoked on counter %s", 
_counter_name.c_str());
   TSStatIntIncrement(_counter, 1);
 }
+
+//OperatorSetConnDSCP
+void
+OperatorSetConnDSCP::initialize(Parser& p)
+{
+  Operator::initialize(p);
+
+  _ds_value.set_value(p.get_arg());
+}
+
+void
+OperatorSetConnDSCP::initialize_hooks()
+{
+  add_allowed_hook(TS_HTTP_READ_REQUEST_HDR_HOOK);
+  add_allowed_hook(TS_HTTP_SEND_RESPONSE_HDR_HOOK);
+}
+
+void
+OperatorSetConnDSCP::exec(const Resources& res) const
+{
+  if (res.txnp) {
+    TSHttpTxnClientPacketTosSet(res.txnp, _ds_value.get_int_value());
+  }
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ada9b727/plugins/header_rewrite/operators.h
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/operators.h 
b/plugins/header_rewrite/operators.h
index b41fe7f..65c824d 100644
--- a/plugins/header_rewrite/operators.h
+++ b/plugins/header_rewrite/operators.h
@@ -280,4 +280,23 @@ private:
   int _counter;
 };
 
+class OperatorSetConnDSCP : public Operator
+{
+public:
+  OperatorSetConnDSCP()
+  {
+    TSDebug(PLUGIN_NAME_DBG, "Calling CTOR for OperatorSetConnDSCP");
+  }
+  void initialize(Parser& p);
+
+protected:
+  void initialize_hooks();
+  void exec(const Resources& res) const;
+
+private:
+  DISALLOW_COPY_AND_ASSIGN(OperatorSetConnDSCP);
+
+  Value _ds_value;
+};
+
 #endif // __OPERATORS_H

Reply via email to