You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/11/21 19:42:09 UTC

[01/44] git commit: Runtimedir on Gentoo changed from /var/run to /run

Updated Branches:
  refs/heads/5.0.x 3433ea6b1 -> c63666b13


Runtimedir on Gentoo changed from /var/run to /run


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

Branch: refs/heads/5.0.x
Commit: 9dd6348c5a953f922377833ff0109109796f2de9
Parents: b771f6e
Author: Thomas Berger <th...@it.piratenpartei.de>
Authored: Wed Nov 13 09:00:43 2013 +0100
Committer: Thomas Berger <th...@it.piratenpartei.de>
Committed: Wed Nov 13 09:00:43 2013 +0100

----------------------------------------------------------------------
 config.layout | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9dd6348c/config.layout
----------------------------------------------------------------------
diff --git a/config.layout b/config.layout
index 7a208dd..678e677 100644
--- a/config.layout
+++ b/config.layout
@@ -214,7 +214,7 @@
     installbuilddir: ${datadir}/build
     includedir:    ${prefix}/include+
     localstatedir: /var+
-    runtimedir:    /var/run+
+    runtimedir:    /run+
     logdir:        /var/log+
     cachedir:      /var/cache+
 </Layout>


[43/44] git commit: Add a README for Jenkins jobs management

Posted by zw...@apache.org.
Add a README for Jenkins jobs management


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

Branch: refs/heads/5.0.x
Commit: c54477a5a74c6501c20dfdbcd50882f264ff0a5b
Parents: 9214792
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Nov 21 11:26:45 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Nov 21 11:26:45 2013 -0700

----------------------------------------------------------------------
 ci/jenkins/README | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c54477a5/ci/jenkins/README
----------------------------------------------------------------------
diff --git a/ci/jenkins/README b/ci/jenkins/README
new file mode 100644
index 0000000..88056ac
--- /dev/null
+++ b/ci/jenkins/README
@@ -0,0 +1,32 @@
+README
+======
+
+This is a collection of little tidbits on how we manage our Jenkins build
+system. Please update it.
+
+
+
+Update the jobs queue
+---------------------
+
+Step 1: Update the jobs.yaml in ci/jenkins. Don't break it.
+
+Step 2: Create your user config file, e.g.
+
+     [jenkins]
+     user=zwoop
+     password=yep-this-is-it
+     url=https://ci.trafficserver.apache.org
+
+
+Step 3: Make sure you have the jenkins-job command line utility:
+
+     $ pip install jenkins-job-builder
+
+
+Step 4: Run the jenkins-job update, e.g.
+
+     $ jenkins-jobs --conf zwoop.conf update jenkins/ci/jobs.yaml
+
+
+Step 5: Profit.


[21/44] git commit: TS-2350: Enhancements to traffic_top

Posted by zw...@apache.org.
TS-2350: Enhancements to traffic_top


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

Branch: refs/heads/5.0.x
Commit: 6fd9e174476bf8e4f7cf925df6604cb417afcbb7
Parents: 8f75a09
Author: Bryan Call <bc...@apache.org>
Authored: Thu Nov 14 15:59:18 2013 -0800
Committer: Bryan Call <bc...@apache.org>
Committed: Thu Nov 14 15:59:18 2013 -0800

----------------------------------------------------------------------
 CHANGES                        |   1 +
 cmd/traffic_top/stats.h        |  90 ++++++++--
 cmd/traffic_top/traffic_top.cc | 337 +++++++++++++++++++++++-------------
 3 files changed, 291 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6fd9e174/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 56b3d62..1d39202 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2350] Enhancements to traffic_top
 
   *) [TS-2348] Rename tstop to traffic_top.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6fd9e174/cmd/traffic_top/stats.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/stats.h b/cmd/traffic_top/stats.h
index 35295c8..87e27a2 100644
--- a/cmd/traffic_top/stats.h
+++ b/cmd/traffic_top/stats.h
@@ -54,11 +54,33 @@ namespace constant {
   const char end[] = "\",\n";
 };
 
+
 //----------------------------------------------------------------------------
 class Stats {
 public:
-  Stats(const string &host) {
-    _host = host;
+  Stats(const string &url): _url(url) {
+
+    if (url != "") {
+      if (_url.substr(0, 4) != "http") {
+        // looks like it is a host using it the old way
+        _url = "http://" + _url + "/_stats";
+      }
+
+      // set the host
+      int start = _url.find(":");
+      int end = _url.find("/", start + 3);
+      _host = _url.substr(start + 3, end - start - 3);
+      end = _host.find(":");
+      if (end != string::npos) {
+        _host = _host.substr(0, end);
+      }
+    } else {
+      char hostname[25];
+      hostname[sizeof(hostname) - 1] = '\0';
+      gethostname(hostname, sizeof(hostname) - 1);
+      _host = hostname;
+    }
+
     _stats = NULL;
     _old_stats = NULL;
     _absolute = false;
@@ -130,18 +152,51 @@ public:
     lookup_table.insert(make_pair("get", LookupItem("GET", "proxy.process.http.get_requests", 5)));
     lookup_table.insert(make_pair("head", LookupItem("HEAD", "proxy.process.http.head_requests", 5)));
     lookup_table.insert(make_pair("post", LookupItem("POST", "proxy.process.http.post_requests", 5)));
-    lookup_table.insert(make_pair("2xx", LookupItem("2xx", "proxy.process.http.2xx_responses", 5)));
-    lookup_table.insert(make_pair("3xx", LookupItem("3xx", "proxy.process.http.3xx_responses", 5)));
-    lookup_table.insert(make_pair("4xx", LookupItem("4xx", "proxy.process.http.4xx_responses", 5)));
-    lookup_table.insert(make_pair("5xx", LookupItem("5xx", "proxy.process.http.5xx_responses", 5)));
 
+    lookup_table.insert(make_pair("100", LookupItem("100", "proxy.process.http.100_responses", 5)));
+    lookup_table.insert(make_pair("101", LookupItem("101", "proxy.process.http.101_responses", 5)));
+    lookup_table.insert(make_pair("1xx", LookupItem("1xx", "proxy.process.http.1xx_responses", 5)));
     lookup_table.insert(make_pair("200", LookupItem("200", "proxy.process.http.200_responses", 5)));
+    lookup_table.insert(make_pair("201", LookupItem("201", "proxy.process.http.201_responses", 5)));
+    lookup_table.insert(make_pair("202", LookupItem("202", "proxy.process.http.202_responses", 5)));
+    lookup_table.insert(make_pair("203", LookupItem("203", "proxy.process.http.203_responses", 5)));
+    lookup_table.insert(make_pair("204", LookupItem("204", "proxy.process.http.204_responses", 5)));
+    lookup_table.insert(make_pair("205", LookupItem("205", "proxy.process.http.205_responses", 5)));
     lookup_table.insert(make_pair("206", LookupItem("206", "proxy.process.http.206_responses", 5)));
+    lookup_table.insert(make_pair("2xx", LookupItem("2xx", "proxy.process.http.2xx_responses", 5)));
+    lookup_table.insert(make_pair("300", LookupItem("300", "proxy.process.http.300_responses", 5)));
     lookup_table.insert(make_pair("301", LookupItem("301", "proxy.process.http.301_responses", 5)));
     lookup_table.insert(make_pair("302", LookupItem("302", "proxy.process.http.302_responses", 5)));
+    lookup_table.insert(make_pair("303", LookupItem("303", "proxy.process.http.303_responses", 5)));
     lookup_table.insert(make_pair("304", LookupItem("304", "proxy.process.http.304_responses", 5)));
+    lookup_table.insert(make_pair("305", LookupItem("305", "proxy.process.http.305_responses", 5)));
+    lookup_table.insert(make_pair("307", LookupItem("307", "proxy.process.http.307_responses", 5)));
+    lookup_table.insert(make_pair("3xx", LookupItem("3xx", "proxy.process.http.3xx_responses", 5)));
+    lookup_table.insert(make_pair("400", LookupItem("400", "proxy.process.http.400_responses", 5)));
+    lookup_table.insert(make_pair("401", LookupItem("401", "proxy.process.http.401_responses", 5)));
+    lookup_table.insert(make_pair("402", LookupItem("402", "proxy.process.http.402_responses", 5)));
+    lookup_table.insert(make_pair("403", LookupItem("403", "proxy.process.http.403_responses", 5)));
     lookup_table.insert(make_pair("404", LookupItem("404", "proxy.process.http.404_responses", 5)));
+    lookup_table.insert(make_pair("405", LookupItem("405", "proxy.process.http.405_responses", 5)));
+    lookup_table.insert(make_pair("406", LookupItem("406", "proxy.process.http.406_responses", 5)));
+    lookup_table.insert(make_pair("407", LookupItem("407", "proxy.process.http.407_responses", 5)));
+    lookup_table.insert(make_pair("408", LookupItem("408", "proxy.process.http.408_responses", 5)));
+    lookup_table.insert(make_pair("409", LookupItem("409", "proxy.process.http.409_responses", 5)));
+    lookup_table.insert(make_pair("410", LookupItem("410", "proxy.process.http.410_responses", 5)));
+    lookup_table.insert(make_pair("411", LookupItem("411", "proxy.process.http.411_responses", 5)));
+    lookup_table.insert(make_pair("412", LookupItem("412", "proxy.process.http.412_responses", 5)));
+    lookup_table.insert(make_pair("413", LookupItem("413", "proxy.process.http.413_responses", 5)));
+    lookup_table.insert(make_pair("414", LookupItem("414", "proxy.process.http.414_responses", 5)));
+    lookup_table.insert(make_pair("415", LookupItem("415", "proxy.process.http.415_responses", 5)));
+    lookup_table.insert(make_pair("416", LookupItem("416", "proxy.process.http.416_responses", 5)));
+    lookup_table.insert(make_pair("4xx", LookupItem("4xx", "proxy.process.http.4xx_responses", 5)));
+    lookup_table.insert(make_pair("500", LookupItem("500", "proxy.process.http.500_responses", 5)));
+    lookup_table.insert(make_pair("501", LookupItem("501", "proxy.process.http.501_responses", 5)));
     lookup_table.insert(make_pair("502", LookupItem("502", "proxy.process.http.502_responses", 5)));
+    lookup_table.insert(make_pair("503", LookupItem("503", "proxy.process.http.503_responses", 5)));
+    lookup_table.insert(make_pair("504", LookupItem("504", "proxy.process.http.504_responses", 5)));
+    lookup_table.insert(make_pair("505", LookupItem("505", "proxy.process.http.505_responses", 5)));
+    lookup_table.insert(make_pair("5xx", LookupItem("5xx", "proxy.process.http.5xx_responses", 5)));
 
     lookup_table.insert(make_pair("s_100", LookupItem("100 B", "proxy.process.http.response_document_size_100", 5)));
     lookup_table.insert(make_pair("s_1k", LookupItem("1 KB", "proxy.process.http.response_document_size_1K", 5)));
@@ -169,7 +224,7 @@ public:
 
   void getStats() {
 
-    if (_host == "") {
+    if (_url == "") {
       int64_t value = 0;
       if (_old_stats != NULL) {
         delete _old_stats;
@@ -187,7 +242,7 @@ public:
 
         if (item.type == 1 || item.type == 2 || item.type == 5 || item.type == 8) {
           if (strcmp(item.pretty, "Version") == 0) {
-            // special case for Version informaion
+            // special case for Version information
             TSString strValue = NULL;
             assert(TSRecordGetString(item.name, &strValue) == TS_ERR_OKAY);
             string key = item.name;
@@ -211,8 +266,7 @@ public:
 
       curl = curl_easy_init();
       if (curl) {
-        string url = "http://" + _host + "/_stats";
-        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+        curl_easy_setopt(curl, CURLOPT_URL, _url.c_str());
         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
         curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_error);
 
@@ -238,6 +292,9 @@ public:
           _old_time = _now;
           _now = now;
           _time_diff = _now - _old_time;
+        } else {
+          fprintf(stderr, "Can't fetch url %s", _url.c_str());
+          abort();
         }
 
         /* always cleanup */ 
@@ -248,7 +305,9 @@ public:
 
   int64_t getValue(const string &key, const map<string, string> *stats) const {
     map<string, string>::const_iterator stats_it = stats->find(key);
-    assert(stats_it != stats->end());
+    printf("trying to find %s\n", key.c_str());
+    if (stats_it == stats->end())
+      return 0;
     int64_t value = atoll(stats_it->second.c_str());
     return value;
   }
@@ -266,8 +325,10 @@ public:
     const LookupItem &item = lookup_it->second;
     
     map<string, string>::const_iterator stats_it = _stats->find(item.name);
-    assert(stats_it != _stats->end());
-    value = stats_it->second.c_str();
+    if (stats_it == _stats->end())
+      value = "";
+    else
+      value = stats_it->second.c_str();
   }
 
   void getStat(const string &key, double &value, string &prettyName, int &type, int overrideType = 0) {
@@ -371,6 +432,8 @@ public:
     }
   }
 
+  const string& getHost() const { return _host; }
+
   ~Stats() {
     if (_stats != NULL) {
       delete _stats;
@@ -384,6 +447,7 @@ private:
   map<string, string> *_stats;
   map<string, string> *_old_stats;
   map<string, LookupItem> lookup_table;
+  string _url;
   string _host;
   double _old_time;
   double _now;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6fd9e174/cmd/traffic_top/traffic_top.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/traffic_top.cc b/cmd/traffic_top/traffic_top.cc
index a801520..4e4b66e 100644
--- a/cmd/traffic_top/traffic_top.cc
+++ b/cmd/traffic_top/traffic_top.cc
@@ -143,8 +143,69 @@ size_t write_data(void *ptr, size_t size, size_t nmemb, void * /* stream */)
 }
 
 //----------------------------------------------------------------------------
-static void help(const string &host, const string &version) {
+static void response_code_page(Stats &stats) {
+  attron(COLOR_PAIR(colorPair::border));
+  attron(A_BOLD);
+  mvprintw(0, 0, "                              RESPONSE CODES                                   ");
+  attroff(COLOR_PAIR(colorPair::border));
+  attroff(A_BOLD);
+
+  list<string> response1;
+  response1.push_back("100");
+  response1.push_back("101");
+  response1.push_back("1xx");
+  response1.push_back("200");
+  response1.push_back("201");
+  response1.push_back("202");
+  response1.push_back("203");
+  response1.push_back("204");
+  response1.push_back("205");
+  response1.push_back("206");
+  response1.push_back("2xx");
+  response1.push_back("300");
+  response1.push_back("301");
+  response1.push_back("302");
+  response1.push_back("303");
+  response1.push_back("304");
+  response1.push_back("305");
+  response1.push_back("307");
+  response1.push_back("3xx");
+  makeTable(0, 1, response1, stats);
+
+  list<string> response2;
+  response2.push_back("400");
+  response2.push_back("401");
+  response2.push_back("402");
+  response2.push_back("403");
+  response2.push_back("404");
+  response2.push_back("405");
+  response2.push_back("406");
+  response2.push_back("407");
+  response2.push_back("408");
+  response2.push_back("409");
+  response2.push_back("410");
+  response2.push_back("411");
+  response2.push_back("412");
+  response2.push_back("413");
+  response2.push_back("414");
+  response2.push_back("415");
+  response2.push_back("416");
+  response2.push_back("4xx");
+  makeTable(21, 1, response2, stats);
+
+  list<string> response3;
+  response3.push_back("500");
+  response3.push_back("501");
+  response3.push_back("502");
+  response3.push_back("503");
+  response3.push_back("504");
+  response3.push_back("505");
+  response3.push_back("5xx");
+  makeTable(42, 1, response3, stats);
+}
 
+//----------------------------------------------------------------------------
+static void help(const string &host, const string &version) {
   timeout(1000);
 
   while(1) {
@@ -184,11 +245,124 @@ static void help(const string &host, const string &version) {
 
 static void usage()
 {
-  fprintf(stderr, "Usage: traffic_top [-s seconds] hostname|hostname:port\n");
+  fprintf(stderr, "Usage: traffic_top [-s seconds] [URL|hostname|hostname:port]\n");
   exit(1);
 }
 
 //----------------------------------------------------------------------------
+void main_stats_page(Stats &stats)
+{
+  attron(COLOR_PAIR(colorPair::border));
+  attron(A_BOLD);
+  mvprintw(0, 0, "         CACHE INFORMATION             ");
+  mvprintw(0, 40, "       CLIENT REQUEST & RESPONSE        ");
+  mvprintw(16, 0, "             CLIENT                    ");
+  mvprintw(16, 40, "           ORIGIN SERVER                ");
+
+  for (int i = 0; i <= 22; ++i) {
+    mvprintw(i, 39, " ");
+  }
+  attroff(COLOR_PAIR(colorPair::border));
+  attroff(A_BOLD);
+
+  list<string> cache1;
+  cache1.push_back("disk_used");
+  cache1.push_back("disk_total");
+  cache1.push_back("ram_used");
+  cache1.push_back("ram_total");
+  cache1.push_back("lookups");
+  cache1.push_back("cache_writes");
+  cache1.push_back("cache_updates");
+  cache1.push_back("cache_deletes");
+  cache1.push_back("read_active");
+  cache1.push_back("write_active");
+  cache1.push_back("update_active");
+  cache1.push_back("entries");
+  cache1.push_back("avg_size");
+  cache1.push_back("dns_lookups");
+  cache1.push_back("dns_hits");
+  makeTable(0, 1, cache1, stats);
+
+  list<string> cache2;
+  cache2.push_back("ram_ratio");
+  cache2.push_back("fresh");
+  cache2.push_back("reval");
+  cache2.push_back("cold");
+  cache2.push_back("changed");
+  cache2.push_back("not");
+  cache2.push_back("no");
+  cache2.push_back("fresh_time");
+  cache2.push_back("reval_time");
+  cache2.push_back("cold_time");
+  cache2.push_back("changed_time");
+  cache2.push_back("not_time");
+  cache2.push_back("no_time");
+  cache2.push_back("dns_ratio");
+  cache2.push_back("dns_time");
+  makeTable(21, 1, cache2, stats);
+
+  list<string> response1;
+  response1.push_back("get");
+  response1.push_back("head");
+  response1.push_back("post");
+  response1.push_back("2xx");
+  response1.push_back("3xx");
+  response1.push_back("4xx");
+  response1.push_back("5xx");
+  response1.push_back("conn_fail");
+  response1.push_back("other_err");
+  response1.push_back("abort");
+  makeTable(41, 1, response1, stats);
+
+  list<string> response2;
+  response2.push_back("200");
+  response2.push_back("206");
+  response2.push_back("301");
+  response2.push_back("302");
+  response2.push_back("304");
+  response2.push_back("404");
+  response2.push_back("502");
+  response2.push_back("s_100");
+  response2.push_back("s_1k");
+  response2.push_back("s_3k");
+  response2.push_back("s_5k");
+  response2.push_back("s_10k");
+  response2.push_back("s_1m");
+  response2.push_back("s_>1m");
+  makeTable(62, 1, response2, stats);
+
+  list<string> client1;
+  client1.push_back("client_req");
+  client1.push_back("client_req_conn");
+  client1.push_back("client_conn");
+  client1.push_back("client_curr_conn");
+  client1.push_back("client_actv_conn");
+  makeTable(0, 17, client1, stats);
+
+  list<string> client2;
+  client2.push_back("client_head");
+  client2.push_back("client_body");
+  client2.push_back("client_avg_size");
+  client2.push_back("client_net");
+  client2.push_back("client_req_time");
+  makeTable(21, 17, client2, stats);
+
+  list<string> server1;
+  server1.push_back("server_req");
+  server1.push_back("server_req_conn");
+  server1.push_back("server_conn");
+  server1.push_back("server_curr_conn");
+  makeTable(41, 17, server1, stats);
+
+  list<string> server2;
+  server2.push_back("server_head");
+  server2.push_back("server_body");
+  server2.push_back("server_avg_size");
+  server2.push_back("server_net");
+  makeTable(62, 17, server2, stats);
+}
+
+//----------------------------------------------------------------------------
 int main(int argc, char **argv)
 {
   int sleep_time = 5000;
@@ -204,23 +378,18 @@ int main(int argc, char **argv)
     }
   }
 
-  string host = "";
+  string url = "";
   if (optind >= argc) {
     if (TS_ERR_OKAY != TSInit(NULL, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS | TS_MGMT_OPT_NO_SOCK_TESTS))) {
-      fprintf(stderr, "Error: missing hostname on command line or error connecting to the local manager\n");
+      fprintf(stderr, "Error: missing URL on command line or error connecting to the local manager\n");
       usage();
     }
   } else {
-    host = argv[optind];
-  }
-  Stats stats(host);
-
-  if (host == "") {
-    char hostname[25];
-    hostname[sizeof(hostname) - 1] = '\0';
-    gethostname(hostname, sizeof(hostname) - 1);
-    host = hostname;
+    url = argv[optind];
   }
+  Stats stats(url);
+  stats.getStats();
+  const string &host = stats.getHost();
 
   initscr();
   curs_set(0);
@@ -236,140 +405,60 @@ int main(int argc, char **argv)
   init_pair(colorPair::border, COLOR_WHITE, COLOR_BLUE);
   //  mvchgat(0, 0, -1, A_BLINK, 1, NULL);
 
-  stats.getStats();
+
+  enum Page {MAIN_PAGE, RESPONSE_PAGE};
+  Page page = MAIN_PAGE;
+  string page_alt = "(r)esponse";
+
   while(1) {
     attron(COLOR_PAIR(colorPair::border));
     attron(A_BOLD);
-    for (int i = 0; i <= 22; ++i) {
-      mvprintw(i, 39, " ");
-    }
+
     string version;
     time_t now = time(NULL);
     struct tm *nowtm = localtime(&now);
     char timeBuf[32];
     strftime(timeBuf, sizeof(timeBuf), "%H:%M:%S", nowtm);
     stats.getStat("version", version);
-    mvprintw(0, 0, "         CACHE INFORMATION             ");
-    mvprintw(0, 40, "       CLIENT REQUEST & RESPONSE        ");
-    mvprintw(16, 0, "             CLIENT                    ");
-    mvprintw(16, 40, "           ORIGIN SERVER                ");
-    mvprintw(23, 0, "%8.8s - %-10.10s - %-24.24s      (q)uit (h)elp (%c)bsolute  ", timeBuf, version.c_str(), host.c_str(), absolute ? 'A' : 'a');
+
+    mvprintw(23, 0, "%-20.20s   %30s (q)uit (h)elp (%c)bsolute  ", host.c_str(), page_alt.c_str(), absolute ? 'A' : 'a');
     attroff(COLOR_PAIR(colorPair::border));
     attroff(A_BOLD);
 
-    list<string> cache1;
-    cache1.push_back("disk_used");
-    cache1.push_back("disk_total");
-    cache1.push_back("ram_used");
-    cache1.push_back("ram_total");
-    cache1.push_back("lookups");
-    cache1.push_back("cache_writes");
-    cache1.push_back("cache_updates");
-    cache1.push_back("cache_deletes");
-    cache1.push_back("read_active");
-    cache1.push_back("write_active");
-    cache1.push_back("update_active");
-    cache1.push_back("entries");
-    cache1.push_back("avg_size");
-    cache1.push_back("dns_lookups");
-    cache1.push_back("dns_hits");
-    makeTable(0, 1, cache1, stats);
-
-    list<string> cache2;
-    cache2.push_back("ram_ratio");
-    cache2.push_back("fresh");
-    cache2.push_back("reval");
-    cache2.push_back("cold");
-    cache2.push_back("changed");
-    cache2.push_back("not");
-    cache2.push_back("no");
-    cache2.push_back("fresh_time");
-    cache2.push_back("reval_time");
-    cache2.push_back("cold_time");
-    cache2.push_back("changed_time");
-    cache2.push_back("not_time");
-    cache2.push_back("no_time");
-    cache2.push_back("dns_ratio");
-    cache2.push_back("dns_time");
-    makeTable(21, 1, cache2, stats);
-
-    list<string> response1;
-    response1.push_back("get");
-    response1.push_back("head");
-    response1.push_back("post");
-    response1.push_back("2xx");
-    response1.push_back("3xx");
-    response1.push_back("4xx");
-    response1.push_back("5xx");
-    response1.push_back("conn_fail");
-    response1.push_back("other_err");
-    response1.push_back("abort");
-    makeTable(41, 1, response1, stats);
-
-    list<string> response2;
-    response2.push_back("200");
-    response2.push_back("206");
-    response2.push_back("301");
-    response2.push_back("302");
-    response2.push_back("304");
-    response2.push_back("404");
-    response2.push_back("502");
-    response2.push_back("s_100");
-    response2.push_back("s_1k");
-    response2.push_back("s_3k");
-    response2.push_back("s_5k");
-    response2.push_back("s_10k");
-    response2.push_back("s_1m");
-    response2.push_back("s_>1m");
-    makeTable(62, 1, response2, stats);
-
-    list<string> client1;
-    client1.push_back("client_req");
-    client1.push_back("client_req_conn");
-    client1.push_back("client_conn");
-    client1.push_back("client_curr_conn");
-    client1.push_back("client_actv_conn");
-    makeTable(0, 17, client1, stats);
-
-    list<string> client2;
-    client2.push_back("client_head");
-    client2.push_back("client_body");
-    client2.push_back("client_avg_size");
-    client2.push_back("client_net");
-    client2.push_back("client_req_time");
-    makeTable(21, 17, client2, stats);
-
-    list<string> server1;
-    server1.push_back("server_req");
-    server1.push_back("server_req_conn");
-    server1.push_back("server_conn");
-    server1.push_back("server_curr_conn");
-    makeTable(41, 17, server1, stats);
-
-    list<string> server2;
-    server2.push_back("server_head");
-    server2.push_back("server_body");
-    server2.push_back("server_avg_size");
-    server2.push_back("server_net");
-    makeTable(62, 17, server2, stats);
+
+    if (page == MAIN_PAGE) {
+      main_stats_page(stats);
+    } else if (page == RESPONSE_PAGE) {
+      response_code_page(stats);
+    }
 
     curs_set(0);
     refresh();
     timeout(sleep_time);
 
     int x = getch();
-    if (x == 'q')
-      break;
-    if (x == 'h') {
+    switch (x) {
+    case 'h':
       help(host, version);
-    }
-    if (x == 'a') {
+      break;
+    case 'q':
+      goto quit;
+    case 'm':
+      page = MAIN_PAGE;
+      page_alt = "(r)esponse";
+      break;
+    case 'r':
+      page = RESPONSE_PAGE;
+      page_alt = "(m)ain";
+      break;
+    case 'a':
       absolute = stats.toggleAbsolute();
     }
-    if (x == -1)
-      stats.getStats();
+    stats.getStats();
     clear();
   }
+
+quit:
   endwin();
 
   return 0;


[03/44] git commit: Make targets for creating releases+release candidates

Posted by zw...@apache.org.
Make targets for creating releases+release candidates

What this does
==============

* remove the check for .svn: No longer necessary since we moved to git.

* for the `release` target we simply reuse asf-dist-sign, and
additionally create a signed tag of the same name.

* for the `rel-candidate` target, we add a variable `RC` to Makefile.am
with default value of 0. This can be overriden from outside by calling

    make release-candidate RC=14

NOTE: tags are created with `-f`. If a tag of the same name existed on
your system, it will be overwritten. This is considered a feature.

What this does *not* do
=======================

We are not pushing any tags upstream, or uploading any tarballs
anywhere. This is in the responsibility of the Release Manager.

Likewise, we do *not* bump the version in configure.ac


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

Branch: refs/heads/5.0.x
Commit: b21deabafe6b1eb539bcb530132b3fb0339ae563
Parents: 88666ad
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Nov 14 08:28:15 2013 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Nov 14 09:42:08 2013 +0100

----------------------------------------------------------------------
 Makefile.am | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b21deaba/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 9312d4a..c92cdf7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,6 +40,9 @@ DISTCHECK_CONFIGURE_FLAGS=--with-user=${DIST_BUILD_USER} --with-group=${DIST_BUI
 
 EXTRA_DIST=CHANGES INSTALL STATUS NOTICE LAYOUT LICENSE example contrib README-EC2 REVIEWERS
 
+# Default value when creating release candidates
+RC = 0
+
 # igalic can't remember if this is make check or make test and neither should you.
 test: check
 
@@ -54,7 +57,7 @@ doxygen:
 
 asf-distdir:
 	@$(am__remove_distdir)
-	test -d .git && git clone . $(distdir) || svn export . $(distdir)
+	test -d .git && git clone . $(distdir)
 	cd $(distdir) && autoreconf -i
 	rm -rf -- $(distdir)/autom4te.cache $(distdir)/.git $(distdir)/.gitignore $(distdir)/ci
 
@@ -67,6 +70,13 @@ asf-dist-sign: asf-dist
 	sha1sum -b $(distdir).tar.bz2 >$(distdir).tar.bz2.sha1
 	gpg --armor --output $(distdir).tar.bz2.asc  --detach-sig $(distdir).tar.bz2
 
+release: asf-dist-sign
+	git tag -fs -m "Release $(VERSION)" $(VERSION)
+
+rel-candidate:
+	$(MAKE) asf-dist-sign VERSION=$(VERSION)-rc$(RC)
+	git tag -fs -m "Release Candidate $(VERSION)-rc$(RC)" $(VERSION)-rc$(RC)
+
 examples: all
 	@cd example && $(MAKE) $(AM_MAKEFLAGS)
 
@@ -88,6 +98,8 @@ help:
 	echo 'examples         make examples' && \
 	echo 'asf-dist         recreate source package' && \
 	echo 'asf-dist-sign    recreate source package, with checksums and signature' && \
+	echo 'release          recreate a signed release source package and a signed git tag' && \
+	echo 'rel-candidate    recreate a signed relelease candidate source package and a signed git tag' && \
 	echo 'distcheck        verify dist by performing VPATH build and then distclean' && \
 	echo 'rat              produce a RAT licence compliance report of the source' && \
 	echo 'doxygen          generate doxygen docs in doc/html dir' && \


[09/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/UtilCmds.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/UtilCmds.cc b/mgmt/cli/UtilCmds.cc
deleted file mode 100644
index 74ed09e..0000000
--- a/mgmt/cli/UtilCmds.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/****************************************************************
- * Filename: UtilCmds.cc
- * Purpose: This file contains the CLI's utility commands.
- *
- *
- ****************************************************************/
-
-#include "UtilCmds.h"
-#include "createArgument.h"
-#include "CliMgmtUtils.h"
-#include "CliDisplay.h"
-#include "ink_error.h"
-#include "ink_defs.h"
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-////////////////////////////////////////////////////////////////
-// DebugCmd
-//
-// This is the callback function for the "debug" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-DebugCmd(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable, *infoPtr;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  Cli_Debug("DebugCmd\n");
-
-  for (infoPtr = argtable; (infoPtr->parsed_args != 0); infoPtr++) {
-
-    // call appropriate function based on the 1st argument
-
-    switch (infoPtr->parsed_args) {
-    case CMD_DEBUG_ON:
-      Cli_Debug("debug on sub-command\n");
-      return (DebugOn());
-
-    case CMD_DEBUG_OFF:
-      Cli_Debug("debug off sub-command\n");
-      return (DebugOff());
-    }
-  }
-  return CLI_OK;
-}
-
-
-////////////////////////////////////////////////////////////////
-// DebugCmdArgs
-//
-// Register "debug" command arguments with the Tcl interpreter.
-//
-int
-DebugCmdArgs()
-{
-  Cli_Debug("DebugCmdArgs\n");
-
-  createArgument("on", 1, CLI_ARGV_CONSTANT, (char *) NULL, CMD_DEBUG_ON, "Turn Debug Statements ON", (char *) NULL);
-
-  createArgument("off", 1, CLI_ARGV_CONSTANT, (char *) NULL, CMD_DEBUG_OFF, "Turn Debug Statements OFF", (char *) NULL);
-
-  return CLI_OK;
-}
-
-////////////////////////////////////////////////////////////////
-//
-// "debug" sub-command implementations
-//
-////////////////////////////////////////////////////////////////
-
-
-// debug on sub-command
-//   used to turn on debug print statements
-int
-DebugOn()
-{
-  CliPrintLevelT level = Cli_GetPrintLevel();
-  level = (CliPrintLevelT) ((int) level | (int) CLI_PRINT_DEBUG);
-  Cli_SetPrintLevel(level);
-  return CLI_OK;
-}
-
-// debug off sub-command
-//   used to turn off debug print statements
-int
-DebugOff()
-{
-  CliPrintLevelT level = Cli_GetPrintLevel();
-  level = (CliPrintLevelT) ((int) level & ~(int) CLI_PRINT_DEBUG);
-  Cli_SetPrintLevel(level);
-  return CLI_OK;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigRoot
-//
-// This is the callback function for the "config:root" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigRoot(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:root") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  Cli_Debug("Cmd_ConfigRoot\n");
-
-  if (getuid() == 0) {
-    Cli_Printf("Already root user.\n");
-    return CLI_OK;
-
-  }
-  char ts_path[1024];
-  if (GetTSDirectory(ts_path,sizeof(ts_path))) {
-    return CLI_ERROR;
-  }
-
-  char command[1024];
-  snprintf(command, sizeof(command),
-           "/bin/su - root -c \"%s/start_traffic_shell\"", ts_path);
-
-  // start traffic_shell as root user
-  // su will prompt user for root password
-  int pid = fork();
-  if (pid == 0) {
-    if (system(command) == -1)
-      exit(2);
-    else
-      exit(1);
-  }
-
-  waitpid(pid, NULL, 0);
-
-  return CLI_OK;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/UtilCmds.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/UtilCmds.h b/mgmt/cli/UtilCmds.h
deleted file mode 100644
index ad1c705..0000000
--- a/mgmt/cli/UtilCmds.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/****************************************************************
- * Filename: UtilCmds.h
- * Purpose: This file contains the CLI's utility commands.
- *
- *
- ****************************************************************/
-
-
-/* This includes a commited hacked version of tcl which has an external dependancy
-   on cli-specific code and thus, this tcl build cannot be used with other
-   code, and normal non-hacked tcl cannot be used with cli.  Even more beutiful
-   is the fact that the hacks are no-where documented.  I managed to scrape
-   them up and role them into a patch which can be found in
-   $CVSROOT/contrib/tcl-tclx/common/patches for reference in case someone
-   ever should feel like comming up with something a little more well thought out.
-   Oh, did I mention also that apperently, no thought was put toward how to make
-   this work with more than one platform, or is that obvious just by looking
-   at the structure?
-*/
-//#include "inktcl/include/tcl.h"
-/* There is is in all it's glory :( */
-
-
-#include "createArgument.h"
-#include "definitions.h"
-
-#ifndef __UTIL_CMDS_H__
-#define __UTIL_CMDS_H__
-
-// enumerated type which captures all "debug" command options
-typedef enum
-{
-  CMD_DEBUG_ON = 1,
-  CMD_DEBUG_OFF
-} cliDebugCommand;
-
-////////////////////////////////////////////////////////////////
-// DebugCmd
-//
-// This is the callback function for the "debug" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int DebugCmd(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// DebugCmdArgs
-//
-// Register "debug" command arguments with the Tcl interpreter.
-//
-int DebugCmdArgs();
-
-////////////////////////////////////////////////////////////////
-//
-// "debug" sub-command implementations
-//
-////////////////////////////////////////////////////////////////
-
-// debug on sub-command
-int DebugOn();
-
-// debug off sub-command
-int DebugOff();
-
-int Cmd_ConfigRoot(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-#endif // __UTIL_CMDS_H__

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/cliAppInit.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/cliAppInit.cc b/mgmt/cli/cliAppInit.cc
deleted file mode 100644
index 461b9f6..0000000
--- a/mgmt/cli/cliAppInit.cc
+++ /dev/null
@@ -1,165 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/*
- *   cliAppInit.c --
- *
- *
- *    This file initiliazes the application by calling all
- *    the new commands and thier respective arguments
- *
- *
- *
- *    Dated  : 12/13/2000.
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <iostream>
-
-//#include "tclExtend.h"
-#include "tcl.h"
-#include <unistd.h>
-#include <sys/types.h>
-#include "CliMgmtUtils.h"
-#include "createCommand.h"
-#include "hashtable.h"
-#include "createArgument.h"
-#include "definitions.h"
-#include "ShowCmd.h"
-#include "ConfigCmd.h"
-#include "CliCreateCommands.h"
-#include "ink_defs.h"
-
-#if HAVE_EDITLINE_READLINE_H
-#include <editline/readline.h>
-#elif HAVE_READLINE_READLINE_H
-#include <readline/readline.h>
-#if HAVE_READLINE_HISTORY_H
-#include <readline/history.h>
-#endif
-#endif
-
-
-Tcl_Interp *interp;
-extern Tcl_HashTable CommandHashtable;
-
-int
-Tcl_AppInit(Tcl_Interp * app_interp)
-{
-  /*
-   * Intialize the Tcl interpreter.
-   */
-  if (Tcl_Init(app_interp) == TCL_ERROR)
-    return TCL_ERROR;
-
-  interp = app_interp;
-
-#ifdef TCL_MEM_DEBUG
-  Tcl_InitMemory(interp);
-#endif
-
-  cliCreateCommandHashtable();
-
-  // root users are automatically enabled
-  if (getuid() == 0) {
-    enable_restricted_commands = true;
-  }
-
-
-  if (CliCreateCommands() != CLI_OK)
-    return CMD_ERROR;
-
-  Tcl_SetVar(interp, "tcl_rcFileName", "~/.tshellstartup", TCL_GLOBAL_ONLY);
-
-/* Evaluating a application specific tcl script After creating
-   all the commands and sourcing the statup file */
-/* Always this should be at the end of this function. */
-  /*
-   * Parse command-line arguments.  A leading "-file" argument is
-   * ignored (a historical relic from the distant past).  If the
-   * next argument doesn't start with a "-" then strip it off and
-   * use it as the name of a script file to process.
-   */
-
-  const char *fileName = Tcl_GetVar(interp, "argv", TCL_LEAVE_ERR_MSG);
-  /*
-   * Invoke the script specified on the command line, if any.
-   */
-
-  if (fileName[0] != '\0') {
-    int listArgc;
-    const char **listArgv;
-
-    if (Tcl_SplitList(interp, fileName, &listArgc, &listArgv) != TCL_OK) {
-      return TCL_ERROR;
-    }
-    int length = strlen(listArgv[0]);
-    if ((length >= 2) && (strncmp(listArgv[0], "-file", length) == 0)) {
-      for (int index = 1; index < listArgc; index++) {
-        Tcl_ResetResult(interp);
-        if (Tcl_EvalFile(interp, listArgv[index]) != TCL_OK) {
-          Tcl_AddErrorInfo(interp, "");
-          Tcl_DeleteInterp(interp);
-          Tcl_Exit(1);
-        }
-      }
-    }
-    ckfree((char *) listArgv);
-  }
-
-  Tcl_ResetResult(interp);
-
-  return TCL_OK;
-}
-
-#if HAVE_LIBREADLINE
-
-// TCL main read, eval, print loop. We don't use Tcl_Main because we want to
-// use readline to get line editing and command history.
-void Tcl_ReadlineMain(void)
-{
-  char * line;
-
-  for (;;) {
-    line = readline("trafficserver> ");
-    if (line == NULL) {
-      // Received EOF. Bound this into a TCL exit command just like Tcl_Main
-      // does.
-      Tcl_Eval(interp, "exit;");
-    }
-
-    if (*line) {
-      add_history(line);
-      Tcl_Eval(interp, line);
-    }
-
-    free(line);
-  }
-
-  exit(0);
-}
-
-#endif // HAVE_LIBREADLINE
-
-// vim: set ts=2 sw=2 et :

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/cliMain.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/cliMain.cc b/mgmt/cli/cliMain.cc
deleted file mode 100644
index 8da720a..0000000
--- a/mgmt/cli/cliMain.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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 "ink_config.h"
-#include <stdlib.h>
-#include "tcl.h"
-#include <string.h>
-#include "ink_args.h"
-#include "ink_file.h"
-#include "ink_error.h"
-#include "I_Layout.h"
-#include "I_Version.h"
-#include "CliMgmtUtils.h"
-#include "mgmtapi.h"
-
-extern int Tcl_AppInit(Tcl_Interp * interp);
-extern void Tcl_ReadlineMain(void);
-extern int CliDisplayPrintf;
-void eventCallbackFn(char *name, char *msg, int pri, void *data);
-
-// default is that alarms appear in CLI as they occur
-int AlarmCallbackPrint = 1;
-
-// registers an event callback for all events in general
-void register_event_callback(void);
-
-AppVersionInfo appVersionInfo;
-int version_flag = 0;
-
-int
-main(int argc, char *argv[])
-{
-  TSError status;
-
-  // build the application information structure
-  appVersionInfo.setup(PACKAGE_NAME,"traffic_shell", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
-
-  // Before accessing file system initialize Layout engine
-  Layout::create();
-
-  // Argument description table used to describe how to parse command line args,
-  // see 'ink_args.h' for meanings of the various fields
-  ArgumentDescription argument_descriptions[] = {
-    {"version", 'V', "Print Version Id", "T", &version_flag, NULL, NULL}
-  };
-
-  // Process command line arguments and dump into variables
-  process_args(argument_descriptions, countof(argument_descriptions), argv);
-
-  // check for the version number request
-  if (version_flag) {
-    ink_fputln(stderr, appVersionInfo.FullVersionInfoStr);
-    exit(0);
-  }
-
-  // traffic_shell binary should use printf to display information onscreen
-  CliDisplayPrintf = 1;
-
-  // initialize MgmtAPI using TS runtime directory
-  status = TSInit(Layout::get()->runtimedir, TS_MGMT_OPT_DEFAULTS);
-  if (status) {
-    printf("TSInit %d: Failed to initialize MgmtAPI in %s\n", status, Layout::get()->runtimedir);
-  } else {
-    printf("Successfully Initialized MgmtAPI in %s \n", Layout::get()->runtimedir);
-  }
-
-  register_event_callback();
-
-#if HAVE_LIBREADLINE
-  Tcl_SetMainLoop(Tcl_ReadlineMain);
-#endif
-
-  Tcl_Main(argc, argv, Tcl_AppInit);
-  exit(0);
-}
-
-void
-eventCallbackFn(char *name, char * /* msg ATS_UNUSED */, int /* pri ATS_UNUSED */, void * /* data ATS_UNUSED */)
-{
-  if (AlarmCallbackPrint == 1) {
-    printf("\n**********\n" "ALARM SIGNALLED: %s\n" "**********\n", name);
-  }
-
-  return;
-}
-
-// registers an event callback for all events in general
-void
-register_event_callback(void)
-{
-  // TODO: Check return code?
-  TSEventSignalCbRegister(NULL, eventCallbackFn, NULL);
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/cliParseArg.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/cliParseArg.cc b/mgmt/cli/cliParseArg.cc
deleted file mode 100644
index 72e6039..0000000
--- a/mgmt/cli/cliParseArg.cc
+++ /dev/null
@@ -1,457 +0,0 @@
-/** @file
-
-  contains the implementation for parsing CLI arguments
-
-  @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.
-
-  @section Description
-  cliParseArgument(int argc,char **argv,cli_ArgvInfo *argTable)
-  compares the given arguments with the expected arguments and
-  returns error if they are not same
-  If arguments are are valid it converts string arguments to the proper type
- */
-
-#include <tcl.h>
-#include <string.h>
-#include <stdlib.h>
-#include "createArgument.h"
-#include "definitions.h"
-#include "CliDisplay.h"
-#include "ink_string.h"
-#include "ink_defs.h"
-
-int checkintrange(char *range, int value);
-int checkfloatrange(char *range, float value);
-char **findRequired(cli_ArgvInfo * argtable);
-extern Tcl_Interp *interp;
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-static void PrintUsage _ANSI_ARGS_((Tcl_Interp * interp, cli_CommandInfo * commandinfo));
-
-
-
-int
-cliParseArgument(int argc, const char **argv, cli_CommandInfo * commandInfo)
-{
-  cli_ArgvInfo *infoPtr, *prevMatchPtr = NULL, *prevPtr = NULL;
-  cli_parsedArgInfo *parsedInfoPtr, *prev_parsedInfoPtr = NULL;
-  int srcIndex = 1;
-  bool gotMatch = false, gotInt = false;
-  int missing = 0;
-  int length, i;
-  char curArg[256], buf[256];
-  char *endPtr;
-  bool got_required;
-  cli_ArgvInfo *argTable = commandInfo->argtable;
-  char **reqd_args = commandInfo->reqd_args;
-  cli_parsedArgInfo *parsedArgTable = commandInfo->parsedArgTable;
-
-
-
-  argc--;                       /*first argument is command name */
-
-
-/* Special option for help handled here, No need to create an -help */
-  /* I assume that the first thing will always start with - */
-
-  if (argc == 1) {
-    length = strlen(argv[1]);
-    if ((length >= 2) && ((strncmp(argv[1], "-help", length) == 0) || (strncmp(argv[1], "-h", length) == 0))) {
-      PrintUsage(interp, commandInfo);
-      return TCL_OK;
-    } else if (strcmp(argv[1], "----") == 0) {
-      /* Special case with readline options */
-      /* Readline always sends "----" */
-      return TCL_OK;
-    }
-  }
-
-
-  /* check for required arguments */
-  if (reqd_args != (char **) NULL) {
-    missing = 0;
-    for (i = 0; reqd_args[i] != NULL; i++) {
-      got_required = false;
-      srcIndex = 1;
-      while (srcIndex <= argc) {
-        if (!strcmp(reqd_args[i], argv[srcIndex])) {
-          got_required = true;
-          break;
-        }
-        srcIndex++;
-      }
-      if (got_required == false) {
-        missing++;
-        if (missing == 1)
-          Tcl_AppendResult(interp, reqd_args[i], (char *) NULL);
-        else
-          Tcl_AppendResult(interp, " , ", reqd_args[i], (char *) NULL);
-      }
-    }
-
-    if (missing == 1) {
-      Tcl_AppendResult(interp, " is required ", (char *) NULL);
-      return TCL_ERROR;
-    } else if (missing > 1) {
-      Tcl_AppendResult(interp, " are required ", (char *) NULL);
-      return TCL_ERROR;
-    }
-
-  }
-/* Initialise Parsed Argtable */
-  for (i = 0; i < 100; i++) {
-    parsedArgTable[i].parsed_args = CLI_PARSED_ARGV_DATA;
-    parsedArgTable[i].arg_float = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
-    parsedArgTable[i].arg_int = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
-
-    if (parsedArgTable[i].data && (parsedArgTable[i].data != (char *) NULL)) {
-      ats_free(parsedArgTable[i].data);
-      parsedArgTable[i].data = (char *) NULL;
-
-    }
-    if (parsedArgTable[i].arg_string && parsedArgTable[i].arg_string != (char *) NULL) {
-      ats_free(parsedArgTable[i].arg_string);
-      parsedArgTable[i].arg_string = (char *) NULL;
-    }
-  }
-
-/* Error checking for commandline arguments based on createargument options */
-  parsedInfoPtr = parsedArgTable;
-  srcIndex = 1;
-  while (argc > 0) {
-    ink_strlcpy(curArg, argv[srcIndex], sizeof(curArg));
-    argc--;
-    srcIndex++;
-    length = strlen(curArg);
-    gotMatch = false;
-    for (infoPtr = argTable; (infoPtr->key != NULL); infoPtr++) {
-      if (!strcmp(infoPtr->key, curArg)) {
-        gotMatch = true;
-        if (infoPtr->position != CLI_ARGV_NO_POS) {     /* Don't do position checking for
-                                                           CLI_ARGV_NO_POS */
-          /* check if the 1st position argument comes at 1st position */
-          if ((infoPtr->position == CLI_PARENT_ARGV) && (srcIndex - 1) != 1) {
-            Tcl_AppendResult(interp, "\"", curArg, "\" is at wrong place Try ", argv[0], " -help", (char *) NULL);
-            return TCL_ERROR;
-          }
-
-          if (infoPtr->position != CLI_PARENT_ARGV) {
-            if ((srcIndex - 1) == 1) {
-              Tcl_AppendResult(interp, "\"", curArg, "\" is at wrong place Try ", argv[0], " -help", (char *) NULL);
-              return TCL_ERROR;
-            } else {
-              if (prevMatchPtr != NULL) {
-                if (prevMatchPtr->arg_ref != infoPtr->position) {
-                  Tcl_AppendResult(interp, "\"", curArg, "\" is at wrong place Try ", argv[0], " -help", (char *) NULL);
-                  return TCL_ERROR;
-                }
-              }
-
-            }
-          }
-        }
-
-        if (prevMatchPtr != NULL && prevPtr == prevMatchPtr) {
-          if (prevMatchPtr->type == CLI_ARGV_OPTION_NAME_VALUE) {
-            if (prev_parsedInfoPtr->arg_string) {
-              ats_free(prev_parsedInfoPtr->arg_string);
-              prev_parsedInfoPtr->arg_string = NULL;
-            }
-          }
-        }
-
-        parsedInfoPtr->arg_usage = infoPtr->help;
-
-        /* Position checking over check for type */
-
-        switch (infoPtr->type) {
-        case CLI_ARGV_CONSTANT:
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          if (argc != 0) {
-            snprintf(buf, sizeof(buf), "Too many arguments Try %s -help", argv[0]);
-            Tcl_AppendResult(interp, buf, (char *) NULL);
-            return TCL_ERROR;
-          }
-          break;
-        case CLI_ARGV_INT:
-          if (argc <= 0) {
-            Tcl_AppendResult(interp, "\"", curArg, "\" option requires an additional integer argument", "\n",
-                             infoPtr->help, (char *) NULL);
-            return TCL_ERROR;
-          }
-          parsedInfoPtr->arg_int = strtol(argv[srcIndex], &endPtr, 0);
-          if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
-            Tcl_AppendResult(interp, infoPtr->key, " requires integer argument ", "\n", infoPtr->help, (char *) NULL);
-            return TCL_ERROR;
-          }
-          if (infoPtr->range_set == true) {
-            if (parsedInfoPtr->arg_int < infoPtr->l_range.int_r1 || parsedInfoPtr->arg_int > infoPtr->u_range.int_r2) {
-              snprintf(buf, sizeof(buf), "value of %s is out of range %d - %d", infoPtr->key, infoPtr->l_range.int_r1,
-                       infoPtr->u_range.int_r2);
-
-              Tcl_AppendResult(interp, buf, (char *) NULL);
-              return TCL_ERROR;
-            }
-
-          }
-          srcIndex++;
-          argc--;
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          break;
-
-        case CLI_ARGV_OPTION_INT_VALUE:
-          gotInt = 0;
-          if (argc > 0) {
-            parsedInfoPtr->arg_int = strtol(argv[srcIndex], &endPtr, 0);
-            if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
-              parsedInfoPtr->arg_int = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
-              parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-              break;
-            }
-            gotInt = 1;
-            if (infoPtr->range_set == true) {
-              if (parsedInfoPtr->arg_int < infoPtr->l_range.int_r1 || parsedInfoPtr->arg_int > infoPtr->u_range.int_r2) {
-                snprintf(buf, sizeof(buf), "value of %s is out of range %d - %d", infoPtr->key, infoPtr->l_range.int_r1,
-                         infoPtr->u_range.int_r2);
-
-                Tcl_AppendResult(interp, buf, (char *) NULL);
-                return TCL_ERROR;
-              }
-            }
-            srcIndex++;
-            argc--;
-          }
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          break;
-
-        case CLI_ARGV_STRING:
-          if (argc <= 0) {
-            Tcl_AppendResult(interp, "\"", curArg, "\" option requires an additional argument", (char *) NULL);
-            return TCL_ERROR;
-          }
-          parsedInfoPtr->arg_string = ats_strdup(argv[srcIndex]);
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          srcIndex++;
-          argc--;
-          break;
-        case CLI_ARGV_OPTION_NAME_VALUE:
-          if (argc > 0) {
-            parsedInfoPtr->arg_string = ats_strdup(argv[srcIndex]);
-          }
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          break;
-        case CLI_ARGV_FLOAT:
-          if (argc <= 0) {
-            Tcl_AppendResult(interp, "\"", curArg, "\" option requires an additional floating-point argument",
-                             (char *) NULL);
-            return TCL_ERROR;
-          }
-
-          // Solaris is messed up, in that strtod() does not honor C99/SUSv3 mode.
-          parsedInfoPtr->arg_float = strtold(argv[srcIndex], &endPtr);
-          if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
-            Tcl_AppendResult(interp, infoPtr->key, " requires floating-point argument",
-                             "\n", infoPtr->help, (char *) NULL);
-            return TCL_ERROR;
-          }
-          if (infoPtr->range_set == true) {
-            if (parsedInfoPtr->arg_float < infoPtr->l_range.float_r1 ||
-                parsedInfoPtr->arg_float > infoPtr->u_range.float_r2) {
-              snprintf(buf, sizeof(buf), "value of %s out of range %f - %f", infoPtr->key, infoPtr->l_range.float_r1,
-                       infoPtr->u_range.float_r2);
-              Tcl_AppendResult(interp, buf, (char *) NULL);
-              return TCL_ERROR;
-            }
-
-          }
-          srcIndex++;
-          argc--;
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          break;
-
-        case CLI_ARGV_OPTION_FLOAT_VALUE:
-          if (argc > 0) {
-            parsedInfoPtr->arg_float = strtold(argv[srcIndex], &endPtr);
-            if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
-              parsedInfoPtr->arg_float = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
-              parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-              break;
-            }
-            if (infoPtr->range_set == true) {
-              if (parsedInfoPtr->arg_float < infoPtr->l_range.float_r1 ||
-                  parsedInfoPtr->arg_float > infoPtr->u_range.float_r2) {
-                snprintf(buf, sizeof(buf), "value of %s out of range %f - %f", infoPtr->key, infoPtr->l_range.float_r1,
-                         infoPtr->u_range.float_r2);
-                Tcl_AppendResult(interp, buf, (char *) NULL);
-                return TCL_ERROR;
-              }
-
-            }
-            srcIndex++;
-            argc--;
-          }
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          break;
-
-        case CLI_ARGV_FUNC:
-          break;
-
-        case CLI_ARGV_CONST_OPTION:
-
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          break;
-        default:
-          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
-          break;
-
-
-        }
-        prevMatchPtr = infoPtr;
-      }
-      if (gotMatch == true)
-        break;
-
-    }
-    if (gotMatch == false) {
-      if (prevMatchPtr != NULL) {
-        /*if prev argument is of type CLI_ARGV_CONST_OPTION then this has to be valid
-           argument so return error */
-        if (prevMatchPtr->type == CLI_ARGV_CONST_OPTION) {
-          snprintf(buf, sizeof(buf), "unrecognized argument %s\n %s", curArg, prevMatchPtr->help);
-          Tcl_AppendResult(interp, buf, (char *) NULL);
-          return TCL_ERROR;
-        }
-
-        if ((prevPtr == prevMatchPtr) && (prevMatchPtr->type == CLI_ARGV_OPTION_FLOAT_VALUE)) {
-          Tcl_AppendResult(interp, prevMatchPtr->key, " requires floating point argument", "\n", prevMatchPtr->help,
-                           (char *) NULL);
-          return TCL_ERROR;
-        }
-
-        if ((prevPtr == prevMatchPtr) && (prevMatchPtr->type == CLI_ARGV_OPTION_INT_VALUE)) {
-          if (gotInt == 0) {
-            Tcl_AppendResult(interp, prevMatchPtr->key, " requires integer argument", "\n", prevMatchPtr->help,
-                             (char *) NULL);
-            return TCL_ERROR;
-          }
-        }
-
-
-        if (prevMatchPtr->type != CLI_ARGV_OPTION_NAME_VALUE) {
-          parsedInfoPtr->data = ats_strdup(curArg);
-          parsedInfoPtr->parsed_args = CLI_PARSED_ARGV_DATA;
-        } else
-          parsedInfoPtr--;
-
-      } else {
-        parsedInfoPtr->data = ats_strdup(curArg);
-        parsedInfoPtr->parsed_args = CLI_PARSED_ARGV_DATA;
-      }
-    }
-    prev_parsedInfoPtr = parsedInfoPtr;
-    parsedInfoPtr++;
-    prevPtr = infoPtr;
-
-  }
-  parsedInfoPtr->parsed_args = CLI_PARSED_ARGV_END;
-
-  return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * PrintUsage --
- *
- *	Generate a help string describing command-line options.
- *
- * Results:
- *	The interp's result will be modified to hold a help string
- *	describing all the options in argTable, plus all those
- *	in the default table unless CLI_ARGV_NO_DEFAULTS is
- *	specified in flags.
- *
- * Side effects:
- *	None.
- *
- *----------------------------------------------------------------------
- */
-static void
-PrintUsage(Tcl_Interp * /* interp ATS_UNUSED */, cli_CommandInfo * commandInfo)
-{
-  cli_ArgvInfo *infoPtr;
-  cli_ArgvInfo *argTable = commandInfo->argtable;
-  int width, numSpaces;
-
-  /*
-   * First, compute the width of the widest option key, so that we
-   * can make everything line up.
-   */
-  width = 4;
-  char *cmdHelpString = commandInfo->helpString;
-  int length = strlen(commandInfo->command_name);
-
-  if (length > width) {
-    width = length;
-  }
-
-  /* Now for arguments */
-
-  for (infoPtr = argTable; infoPtr->key != NULL; infoPtr++) {
-    length = strlen(infoPtr->key);
-    if (length > width) {
-      width = length;
-    }
-  }
-
-  // display command name
-  Cli_Printf("\n%s", commandInfo->command_name);
-  numSpaces = width + 1 - strlen(commandInfo->command_name);
-
-  while (numSpaces > 0) {
-    Cli_Printf(" ");
-    numSpaces--;
-  }
-
-  // display command help string
-  Cli_Printf("    %s", cmdHelpString);
-
-  for (infoPtr = argTable; infoPtr->key != NULL; infoPtr++) {
-    if (infoPtr->position >= 100) {
-      Cli_Printf("\n    ");
-    } else {
-      Cli_Printf("\n  ");
-    }
-
-    // display option name
-    Cli_Printf("%s", infoPtr->key);
-    numSpaces = width + 1 - strlen(infoPtr->key);
-
-    while (numSpaces > 0) {
-      Cli_Printf(" ");
-      numSpaces--;
-    }
-    // display option parameters
-    Cli_Printf("  %s", infoPtr->help);
-  }
-
-  Cli_Printf("\n\n");
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/cli_detailed_command_list.txt
----------------------------------------------------------------------
diff --git a/mgmt/cli/cli_detailed_command_list.txt b/mgmt/cli/cli_detailed_command_list.txt
deleted file mode 100644
index 54b2776..0000000
--- a/mgmt/cli/cli_detailed_command_list.txt
+++ /dev/null
@@ -1,1623 +0,0 @@
-FEATURE INTRODUCTION
-
-Feature name:
-
-	traffic_shell
-
-Synopsis of Feature:
-
-	traffic_shell is a true "command line interface."  It accepts
-commands in a unix shell-like fashion.  traffic_shell supports command
-completion, command history, man pages, and context sensitive help.
-Not only is this type of interface more familiar to network engineers
-everywhere, but it is also easier to document, maintain, and extend.
-	traffic_shell is TCL-based which simplifies the development of new
-commands.  It also supports scripting which means that a user can
-source and execute a file that contains traffic_shell commands. 
-	traffic_shell currently provides full configuration and monitoring
-functionality for Traffic Server. 
-	traffic_shell is built on the same Management API as the
-Traffic Server WebUI.  The Management API (written in C code) handles
-updating config files and restarting TS or reloading config variables
-for changes to take effect. 
- 
-Configurations of Traffic Server affected:
-
-	Platforms: Linux, Linux for OEMs, Solaris SPARC
-	Configurations: All TS configurations
-
-References on Feature:
-
-	Scroll down to the section of this document titled:
-	  COMPLETE COMMAND SET SPECIFICATION
-        This section contains an exhaustive list of all traffic_shell
-	commands, along with a description of syntax and sample output.
-
-ENGINEERING DESCRIPTION
-
-Modes of operation of Feature:
-
-	No special records.config setup is required.
-
-	The CLI supports the following operation modes.  Note that a
-	"user" can be a person, a script, or some other mechanism for remote
-	control of network devices via command line interface.
-
-   -- Interactive:
-         "traffic_shell"
-         Similar to unix shell, CLI can be the login shell for administrators.
-         User types command at a prompt.
-         CLI processes command and displays the result.
-         User can execute a file which contains a list of commands.
-
-   -- Execute file:
-         "traffic_shell -f filename" where file contains a list of CLI commands.
-         CLI runs commands and sends results to stdout.
-    
-	When entered at the Unix shell prompt, the "traffic_shell -f
-filename" command starts traffic_shell and runs a TCL script
-"filename" which typically contains traffic_shell commands.  Since
-traffic_shell is a TCL interpreter, the script can also contain any
-valid combination of TCL constructs.  If the TCL interpreter
-encounters the "exit" keyword, then control returns to the shell from
-which the user typed "traffic_shell -f <filename>".  If the
-interpreter reaches the end of script execution without encountering
-"exit", then the traffic_shell prompt appears and the user can
-continue to use traffic_shell interactively.
-
-Risk points of feature:
-
-	Certain configuration changes force a reset of Traffic
-	Server.  These restarts are performed by functions in the
-	Management API. 
-
-Effect on SDK/API:
-
-	None.  In the future, traffic_shell may be enhanced to provide
-	configurability of certain plugins.
-
-Module tests, diagnostic output, and statistics on feature
-
-	None.
-
-Engineering description of Feature:
-
-	The CLI is a standalone executable that is part of a Traffic
-	Server installation.  
-
-	The CLI is implemented in a combination of TCL and C++.  The
-	shell and parsing functionality uses TCL.  Commands themselves are
-	typically written in C++.  The CLI uses the traffic_manager Management
-	API to make Traffic Server configuration changes.
-
- The overall CLI architecture is as follows:
-
-  - traffic_shell ---------------------------
- |                                           |
- |  ---------------------------------------  |
- |  Shell and parser implemented in TCL/C++  |
- |  ---------------------------------------  |
- |                  ^                        |
- |  ----------------|-------------------     |
- |  CLI commands implemented in C++ (.a)     |
- |  ------------------------------------     |
- |                  ^                        |
- |          --------|----------              |
- |          Management API (.a)              |
- |          -------------------              |
- |                                           |
-  -------------------------------------------
-
-Notes and comments by developing engineer:
-
-	None.
-
-TESTS DESCRIPTIONS
-
-Test description:
-
-	QA developed expect scripts for each traffic_shell command to
-	simulate commands from user level, and also to check the output
-	of CLI.
-
-	Each script covers one command along with all of its
-	sub-commands and arguments. 
-
-  Each Config Command script has a flow as follows:
-  - Valid test:
-    . Send valid syntax command to CLI.
-    . Check the value of affected variable from either the CLI or 
-      from traffic_line -r <variable>.
-    . Set errors if the output of CLI does not match expected result.
-  - Negative test:
-    . Send commands with invalid arguments to CLI.
-    . CLI should handled unregconized arguments gracefully.
-    . Set error if CLI does not handle invalid arguments correctly.
-
-  Same logic flow for Show commands.
-
-
-   To run the test scripts:
-   ----------------------------
-   There are two files:
-	cli-config-tests.tar for config commands.
-	cli-show-tests.tar for show commands.
-
-Copy these files into a "cli" subdirectory of the traffic_server "bin"
-directory, and untar them.  Start traffic_server and run scripts
-within cli directory.
-
-- For Config, run cli-test.exp + <individual test>
-
-  For example:
-  cli% ./cli-test.exp config-name 
-  This will test config:name command
-      
-- For Show, run show-test.exp + <individual test>
-
-Test development notes:
-
-- These scripts are by no means complete.  Anyone can add more testcases 
-in by copying/modifying existing testcases. These tests are pretty primitive
-for now. 
-
-- When running tests, please make sure you enlarge your terminal as large as
-possible to accomodate the CLI output. The EOL character might affect string
-comparision in expect.
-
-- Some of variables are set to random values. So please be sure to save your
-config directory or install new traffic server after you complete CLI test :-)
-This will be make better in the future.
-
-*******************************************************
-COMPLETE COMMAND SET SPECIFICATION
-*******************************************************
-
-
-
-traffic_shell command set specification
-
-NOTE: This document does not distinguish phase-1 commands and functionality.
-
-There may be some inconsistencies between the command descriptions and the 
-actual implementation.  In particular, column alignment is not exactly specified 
-in this document.  Also, the values below are for example purposes only.
-
-==============
-CLI Features
-==============
-
-   1) CLI supports command completion i.e if the user types first one
-   or two characters of a valid command and presses tab key it completes
-   the command.
-
-   2) CLI supports command abbreviation i.e if user types first one or two
-   characters of a valid command and presses enter CLI will display all
-   the commands whic start with the abbreviation typed by user If there
-   is only one command matching the command abbreviation CLI directly
-   executes the command.
-
-   3) CLI supports history command which shows the history of previously
-   typed commands.
-
-   4) CLI supports up and down arrow keys to see through previous
-   commands.
-
-   5) All CLI commands can be classified in two catogories Show commands
-   and Config commands.  Show Commands display system information. Show
-   Commands can be executed in normal mode.  A list of possible show
-   commands described below can be seen by just typing show on command
-   line.
-
-   6) Config commands let the user configure or set system information
-   and settings Config commands can be executed in  privileged mode
-   enabled by admin password.  A list of possible  config commands
-   described below can be seen by just typing config on command line.
-
-
-================
-Command Overview
-================
-
-Normal mode commands
-  % prompt
-----------------------------
-
-enable		Enable privileged commands
-  Prompt for password.  Password can be blank.
-  syntax: enable
-  args:   none
-
-  ts> enable
-  Password: (no characters displayed)
-  ts#
-
-exit		Exit CLI
-  syntax: exit
-  args:   none
-
-  ts> exit
-
-help		Help
-  Display list of commands with one line description.
-  Or display help for a particular subcommand.
-  syntax: help [ subcommand ]
-  args:   subcommand (optional)
-
-show		Show system information
-
-  See "Show Command" below for list of subcommands.
-  syntax: show:< show-sub-command >
-  args:   show-sub-command = optional subcommand
-  behavior:  If show-sub-command is ommitted, then display the list of
-             possible show-sub-commands.
-
-Enable mode commands
-  includes all Normal mode commands
-  # prompt
-----------------------------
-
-config		Enter configuration mode
-  See "Configure Command" below for list of subcommands.
-  syntax: config:< config-sub-command >
-  args:   config-sub-command = optional subcommand
-  behavior:  If config-sub-command is ommitted, then display the list of
-             possible config-sub-commands.
-
-disable		Disable privileged commands
-  No parameters.  Puts CLI back into Normal Mode.
-  syntax: disable
-  args:   none
-  behavior:  Switch to Normal Mode.
-
-  ts# disable
-  ts>
-
-exit		Exit CLI
-  syntax: exit
-  args:   none
-
-help		Help
-  Same as Normal Mode but includes Configure Command.
-  Display list of commands with one line description.
-  Or display help for a particular subcommand.
-  syntax: help [ subcommand ]
-  args:   subcommand (optional)
-  
-show		Show system information
-  Same as Normal Mode but includes privileged commands.
-  See "Show Command" below for list of subcommands.
-  syntax: show:< show-sub-command >
-  args:   show-sub-command = optional subcommand
-  behavior:  If show-sub-command is ommitted, then display the list of
-             possible show-sub-commands.
-
-
-Show command
-------------
-Parameter		Description
------------------------------------
-status			Proxy status on/off
-  syntax: show:status
-  args:   none
-  behavior:  Display status as follows:
-
-    ts> show:status
-    Proxy -- on
-    ts>
-
-  implementation: Determine whether proxy is up and running.
-
-version			Traffic Server and Traffic Manager version
-  syntax: show:version
-  args:   none
-  behavior:  Display Traffic_Server and Traffic Manager version number as follows:
-
-    ts> show:version
-    traffic_server version --- 5.0.0
-    traffic_manager version -- 5.0.0
-    ts>
-
-security		Security Configuration (only in Enable Mode)
-			(TS IP allow, MGMT allow, Login allow)
-
-  syntax: show:security
-  args:   none
-  behavior:  Display IP address access lists for TS, MGMT, and login.
-
-    ts> show:security
-
-    Traffic Server Access
-    (ip_allow.config contents)
-
-    ts>
-
-  implementation:
-    Traffic Server Access specified in ip_allow.config (use MGMT API)
-
-cluster                Cluster Configuration
-
-   syntax: show:cluster
-   args:   none
-   behavior: Display cluster port
-
-  ts> show:cluster
- 
-      Cluster Port ----------- 14988 (proxy.config.cluster.cluster_port)
-      Cluster RS Port -------- 14990 (proxy.config.cluster.rsport)
-      Cluster MC Port -------- 14991 (proxy.config.cluster.mcport)
-
-http			HTTP Configuration
-			(timeout values, headers, authorization)
-
-  syntax: show:http
-  args:   none
-  behavior:  Display HTTP Configuration
-
-    ts> show:http
-    HTTP Caching ------------------ on      (proxy.config.http.cache.http)
-    HTTP Server Port -------------- 14980   (proxy.config.http.server_port)
-
-    Keep-Alive Timeout Inbound ---- 10 s    (proxy.config.http.keep_alive_no_activity_timeout_in)
-    Keep-Alive Timeout Outbound --- 10 s    (proxy.config.http.keep_alive_no_activity_timeout_out)
-    Inactivity Timeout Inbound ---- 120 s   (proxy.config.http.transaction_no_activity_timeout_in)
-    Inactivity Timeout Outbound --- 120 s   (proxy.config.http.transaction_no_activity_timeout_out)
-    Activity Timeout Inbound ------ 7200 s  (proxy.config.http.transaction_active_timeout_in)
-    Activity Timeout Outbound ----- 7200 s  (proxy.config.http.transaction_active_timeout_out)
-    Maximum Number of Alternates -- 3       (proxy.config.cache.limits.http.max_alts)
-    Remove the following common headers
-      From         (proxy.config.http.anonymize_remove_from)
-      Referer      (proxy.config.http.anonymize_remove_referer)
-      User-Agent   (proxy.config.http.anonymize_remove_user_agent)
-      Cookie       (proxy.config.http.anonymize_remove_cookie)
-    Remove additional headers
-      list         (proxy.config.http.anonymize_other_header_list)
-    Insert or Remove Client IP address
-      Insert       (proxy.config.http.anonymize_insert_client_ip)
-      Remove       (proxy.config.http.anonymize_remove_client_ip)
-    ts>
-    
-icp			ICP Configuration
-			(on/off, rules, port, timeouts)
-  syntax: show:icp [ peers ]
-  args:   optional "peers" argument
-  behavior:  Display ICP Configuration
-
-  ts> show:icp
-  ICP Mode --------------- off   (proxy.config.icp.enabled)
-  ICP Port --------------- 3130  (proxy.config.icp.icp_port)
-  ICP Multicast Enabled -- off   (proxy.config.icp.multicast_enabled)
-  ICP Query Timeout ------ 2 s   (proxy.config.icp.query_timeout)
-  ts>
-
-  ts> show:icp peers
-  icp.config rules
-  ----------------
-  (Display rules from icp.config)
-  ts>
-
-proxy			Proxy Configuration
-
-  syntax: show:proxy
-  args:   none
-  behavior:  Display basic proxy configuration
-
-  ts> show:proxy
-  Name -- foo         (proxy.config.proxy_name)
-  ts>
-
-cache			Cache Configuration
-			(active protocols, bypass, storage, freshness, 
-			expires, variable content, rules)
-  syntax: show:cache [ rules | storage ]
-  args:   optional "rules" or "storage"
-
-  ts> show:cache
-  HTTP Caching ------------------- on    (proxy.config.http.cache.http)
-  Ignore User Requests To Bypass Cluster --- off  (proxy.config.http.cache.cluster_cache_local)
-  Ignore User Requests To Bypass Cache --- off  (proxy.config.http.cache.ignore_client_no_cache)
-  Maximum HTTP Object Size --- NONE        (proxy.config.cache.max_doc_size)
-
-  Freshness
-    Verify Freshness By Checking --   (proxy.config.http.cache.when_to_revalidate)
-      When the object has expired
-    Minimum freshness information for a document to be cacheable --  (proxy.config.http.cache.required_headers)
-      Nothing
-    If object has no expiration date:
-      leave it in cache for at least ---- 3600 s   (proxy.config.http.cache.heuristic_min_lifetime)
-      but no more than ------------------ 86400 s  (proxy.config.http.cache.heuristic_max_lifetime)
-
-  Variable Content
-    Do not cache responses to URLs that contain "?", ";", "cgi" or end in ".asp"  (proxy.config.http.cache.cache_urls_that_look_dynamic value)
-    Alternates ------------ on    (proxy.config.http.cache.enable_default_vary_headers)
-    Vary on HTTP Header Fields:
-      Text ---------------- Cookie  (proxy.config.http.cache.vary_default_text)
-      Images -------------- NULL    (proxy.config.http.cache.vary_default_images)
-      Other --------------- NULL    (proxy.config.http.cache.vary_default_other)
-    Cache responses to requests containing cookies for:  (proxy.config.http.cache.cache_responses_to_cookies)
-      content-types which are not text
-  ts>
-
-  ts> show:cache rules
-  Display rules from cache.config
-  ts>
-
-  ts> show:cache storage
-  Display rules from storage.config
-  ts>
-
-virtual-ip		Virtual IP Address Configuration
-  syntax: show:virtual-ip
-  args:   none
-  behavior:  Display virtual IP configuration
-
-
-  ts_shell>show:virtual-ip 
-
-  2 Elements in Record
-
-  0 1.1.1.1 23 23
-  1 1.1.1.1 23 24
-
-  ts>
-
-
-hostdb			Host Database Configuration
-  syntax: show:hostdb
-  args:   none
-  behavior:  Display Host DB Configuration
-
-  ts> show:hostdb
-  Lookup Timeout ----------- 120 s   (proxy.config.hostdb.lookup_timeout)
-  Foreground Timeout ------- 1440 s  (proxy.config.hostdb.timeout)
-  Background Timeout ------- 720 s   (proxy.config.hostdb.verify_after)
-  Invalid Host Timeout ----- 0 s     (proxy.config.hostdb.fail.timeout)
-  Re-DNS on Reload --------- off     (proxy.config.hostdb.re_dns_on_reload)
-  Resolve Attempt Timeout -- 20 s    (proxy.config.dns.lookup_timeout)
-  Number of Retries -------- 5       (proxy.config.dns.retries)
-  ts>
-
-dns-resolver		DNS Resolver Configuration
-  syntax: show:dns-resolver
-  args:   none
-  behavior:  Display DNS Resolver Configuration
-
-  ts> show:dns-resolver
-  Local Domain Expansion -- on   (proxy.config.dns.search_default_domains)
-  .com Domain Expansion --- on   (proxy.config.http.enable_url_expandomatic)
-  ts>
-
-logging			Logging Configuration
-  syntax: show:logging
-  args: none
-  behavior:  Display Logging Configuration
-
-  ts> show:logging
-  Logging Mode ------------- xxx       (proxy.config.log.logging_enabled)
-
-  Management  
-    Log Space Limit -------- 2000 MB  (proxy.config.log.max_space_mb_for_logs)
-    Log Space Headroom ----- 10 MB    (proxy.config.log.max_space_mb_headroom)
-
-  Log Collation ------------ off      (proxy.local.log.collation_mode)
-    Host ------------------- NULL     (proxy.config.log.collation_host)
-    Port ------------------- 8085     (proxy.config.log.collation_port)
-    Secret ----------------- foobar   (proxy.config.log.collation_secret)
-    Host Tagged ------------ off      (proxy.config.log.collation_host_tagged)
-    Space Limit for Orphan Files -- 25 MB   (proxy.config.log.max_space_mb_for_orphan_logs)
-
-  Squid Format ---- on             (proxy.config.log.squid_log_enabled)
-    File Type ----- ASCII          (proxy.config.log.squid_log_is_ascii)
-    File Name ----- squid          (proxy.config.log.squid_log_name)
-    File Header --- NULL           (proxy.config.log.squid_log_header)
-
-  Netscape Common -- off         (proxy.config.log.common_log_enabled)
-    File Type ------ ASCII       (proxy.config.log.common_log_is_ascii)
-    File Name ------ common      (proxy.config.log.common_log_name)
-    File Header ---- NULL        (proxy.config.log.common_log_header)
-
-  Netscape Extended -- off       (proxy.config.log.extended_log_enabled)
-    File Type -------- ASCII     (proxy.config.log.extended_log_is_ascii)
-    File Name -------- extended  (proxy.config.log.extended_log_name)
-    File Header ------ NULL      (proxy.config.log.extended_log_header)
-
-  Netscape Extended2 -- off       (proxy.config.log.extended2_log_enabled)
-    File Type --------- ASCII     (proxy.config.log.extended2_log_is_ascii)
-    File Name --------- extended2 (proxy.config.log.extended2_log_name)
-    File Header ------- NULL      (proxy.config.log.extended2_log_header)
-
-  Splitting
-    ICP Log Splitting -- off        (proxy.config.log.separate_icp_logs)
-    HTTP Host Log Splitting -- off  (proxy.config.log.separate_host_logs)
-
-  Custom Logs -- off              (proxy.config.log.custom_logs_enabled)
-
-  Rolling -------- on               (proxy.config.log.rolling_enabled)
-    Roll Offset Hour --- 0          (proxy.config.log.rolling_offset_hr)
-    Roll Interval ------ 86400 s               (proxy.config.log.rolling_interval_sec)
-  Auto-delete rolled files when space is low -- on  (proxy.config.log.auto_delete_rolled_files)
-  ts>
-
-ssl			SSL Ports
-  syntax: show:ssl
-  args:   none
-  behavior:  Display SSL Port related configuration.
-
-  ts> show:ssl
-  Restrict CONNECT connections to Ports -- 443 563   (proxy.config.http.connect_ports)
-  ts>
-
-parent			Parent Configuration
-			(on/off, parents, rules)
-  syntax: show:parent
-  args:   none
-  behavior:  Display Parent Configuration.
-
-  ts> show:parent
-  Parent Caching: OFF    (proxy.config.http.parent_proxy_routing_enable)
-  Parent Cache:   NONE   (proxy.config.http.parent_proxies)
-  ts>
-
-  syntax: show:parent rules
-  behavior: Display Parent configuration rules file.
-
-  ts> show:parent rules
-  parent.config rules
-  -------------------
-  Display rules from parent.config
-  ts>
-
-remap			Remap Rules
-  syntax: show:remap
-  args:   none
-  behavior:  Display remap configuration.
-
-  ts> show:remap
-  remap.config rules
-  ------------------
-  (Display rules from remap.config)
-  ts>
-
-socks			SOCKS Configuration
-			(on/off, stats)
-  syntax: show:socks [ rules ]
-  args:   none
-  behavior:  Display SOCKS Configuration.
-
-  ts> show:socks
-  SOCKS -------------------- off      (proxy.config.socks.socks_needed)
-  SOCKS Default Servers ---- x.x.x.x  (proxy.config.socks.default_servers)
-  SOCKS Accept Port -------- 1080     (proxy.config.socks.accept_port)
-  SOCKS HTTP Port ---------- 80       (proxy.config.socks.http_port)
-  SOCKS Timeout ------------ 100 s    (proxy.config.socks.socks_timeout)
-  ts>
-
-  ts> show:socks rules
-  socks.config rules
-  ------------------
-  (Display socks.config rules)
-  ts>
-
-port-tunnels		Port Tunnelling Configuration
-
-  syntax: show:port-tunnels 
-
-  ts# show:port-tunnels
- 
-  server-other-ports -- 7890
-  
-  To view the corresponding rule of the remap.config file in the following format
-      map tunnel://<proxy_ip>:<port_num>/tunnel://<dest_server>:<dest_port>
-      Use show:remap
-
-scheduled-update        Scheduled Update Configuration
-  syntax: show:scheduled-update [ rules ]
-  args:   show update.config file
-  behavior:  Display Scheduled Update Configuration.
-
-  ts> show:scheduled-update
-  Scheduled Update -------------- on   (proxy.config.update.enabled)
-  Update Error Retry Count ------ 10   (proxy.config.update.retry_count)
-  Update Error Retry Interval --- 2 s  (proxy.config.update.retry_interval)
-  Maximum Concurrent Updates ---- 100  (proxy.config.update.concurrent_updates)
-  Force Immediate Update -------- off  (proxy.config.update.force)
-  ts>
-
-  ts> show:scheduled-update rules
-  update.config rules
-  ------------------- 
-  (Display list of rules from update.config)
-  ts>
-
-
-Status subcommands
-------------------
-Parameter		Description
------------------------------------
-proxy-stats		Proxy Vital Stats 
-			oldCLI->root->monitor->node
-			(hit rate, bandwidth savings, open connections)
-  syntax: show:proxy-stats
-  args:   none
-  behavior:  Display statistics related to the overall proxy.
-
-  ts> show:proxy-stats
-  Document Hit Rate ------------ 0% *    (proxy.node.cache_hit_ratio)
-  Bandwidth Savings ------------ 0% *    (proxy.node.bandwidth_hit_ratio)
-  Cache Percent Free ----------- 0%      (proxy.node.cache.percent_free)
-
-  Open Server Connections ------ 0       (proxy.node.current_server_connections)
-  Open Client Connections ------ 0       (proxy.node.current_client_connections)
-  Cache Transfers In Progress -- 0       (proxy.node.current_cache_connections)
-
-  Client Throughput ------------ 0.00 MBit/Sec  (proxy.node.client_throughput_out)
-  Transactions Per Second ------ 0       (proxy.node.user_agent_xacts_per_second)
-
-  * Value represents 10 second average.
-  ts>
-
-http-trans-stats	HTTP Transaction Summary
-			(hits, misses, aborts, other)
-			oldCLI->root->monitor->protocols->http-trans
-  syntax: show:http-trans-state
-  args:   none
-  behavior:  Display statistics related to HTTP transactions.
-
-  ts> show:http-trans-stats
-  HTTP Transaction Frequency and Speeds     (proxy.node.http.transaction_*)
-  Transaction Type              Frequency  Speed (ms)
-  --Hits--
-  Fresh ----------------------- 0%         0    (frac_avg_10s.hit_fresh, 
-                                                 msec_avg_10s.hit_fresh)
-  Stale Revalidated ----------- 0%         0    (frac_avg_10s.hit_revalidated, 
-                                                 msec_avg_10s.hit_revalidated)
-  --Misses--
-  Now Cached ------------------ 0%         0    (frac_avg_10s.miss_cold, 
-                                                 msec_avg_10s.miss_cold)
-  Server No Cache ------------- 0%         0    (frac_avg_10s.miss_not_cacheable, 
-                                                 msec_avg_10s.miss_not_cacheable)
-  Stale Reloaded -------------- 0%         0    (frac_avg_10s.miss_changed, 
-                                                 msec_avg_10s.miss_changed)
-  Client No Cache ------------- 0%         0    (frac_avg_10s.miss_client_no_cache, 
-                                                 msec_avg_10s.miss_client_no_cache)
-  --Errors--
-  Connection Failures --------- 0%         0    (frac_avg_10s.errors.connect_failed,
-                                                 msec_avg_10s.errors.connect_failed)
-  Other Errors ---------------- 0%         0    (frac_avg_10s.errors.other,
-                                                 msec_avg_10s.errors.other)
-  --Aborted Transactions--
-  Client Aborts --------------- 0%         0    (frac_avg_10s.errors.aborts,
-                                                 msec_avg_10s.errors.aborts)
-  Questionable Client Aborts -- 0%         0    (frac_avg_10s.errors.possible_aborts,
-                                                 msec_avg_10s.errors.possible_aborts)
-  Partial Request Hangups ----- 0%         0    (frac_avg_10s.errors.early_hangups,
-                                                 msec_avg_10s.errors.early_hangups)
-  Pre-Request Hangups --------- 0%         0    (frac_avg_10s.errors.empty_hangups,
-                                                 msec_avg_10s.errors.empty_hangups)
-  Pre-Connect Hangups --------- 0%         0    (frac_avg_10s.errors.pre_accept_hangups,
-                                                 msec_avg_10s.errors.pre_accept_hangups)
-  --Other Transactions--
-  Unclassified ---------------- 0%         0    (frac_avg_10s.other.unclassified,
-                                                 msec_avg_10s.other.unclassified)  
-  ts>
-
-http-stats		HTTP Protocol Summary
-			oldCLI->root->monitor->protocols->http
-  syntax: show:http-stats
-  args:   none
-  behavior:  Display HTTP Protocol statistics.
-
-  ts> show:http-stats
-  --Client--                          (proxy.process.http.*)
-  Total Document Bytes ------ 150.5 MB  (user_agent_response_document_total_size)
-  Total Header Bytes -------- 23.5 MB   (user_agent_response_header_total_size)
-  Total Connections --------- 0         (current_client_connections)
-  Transactions In Progress -- 0         (current_client_transactions)
-  --Server--
-  Total Document Bytes ------ 150.4 MB  (origin_server_response_document_total_size)
-  Total Header Bytes -------- 16.3 MB   (origin_server_response_header_total_size)
-  Total Connections --------- 0         (current_server_connections)
-  Transactions In Progress -- 0         (current_server_transactions)
-  ts>
-
-icp-stats		ICP Statistics
-  syntax: show:icp-stats
-  args:   none
-  behavior:  Display ICP statistics.
-
-  ts> show:icp-stats
-  --Queries Originating From This Node--      (proxy.process.icp.*)
-  Query Requests ------------------------------ 0    (icp_query_requests)
-  Query Messages Sent ------------------------- 0    (total_udp_send_queries)
-  Peer Hit Messages Received ------------------ 0    (icp_query_hits)
-  Peer Miss Messages Received ----------------- 0    (icp_query_misses)
-  Total Responses Received -------------------- 0    (icp_remote_responses)
-  Average ICP Message Response Time ----------- 0.00 ms (total_icp_response_time)
-  Average ICP Request Time -------------------- 0.00 ms (total_icp_request_time)
-  --Queries Originating from ICP Peers--
-  Query Messages Received --------------------- 0    (icp_remote_query_requests)
-  Remote Query Hits --------------------------- 0    (cache_lookup_success)
-  Remote Query Misses ------------------------- 0    (cache_lookup_fail)
-  Successful Response Messages Sent to Peers -- 0  (query_response_write)
-  ts>
-
-cache-stats		Overall Cache Statistics
-			oldCLI->root->monitor->cache
-  syntax: show:cache-stats
-  args:   none
-  behavior:  Display overall cache statistics.
-
-  ts> show:cache-stats     (proxy.process.cache.*)
-  Bytes Used --- 42.3 GB     (bytes_used)
-  Cache Size --- 42.4 GB     (bytes_total)
-  --RAM Cache--
-  Bytes -------- 45443072  (ram_cache.bytes)
-  Hits --------- 31339939  (ram_cache.hits)
-  Misses ------- 18382137  (ram_cache.misses)
-  --Lookups--
-  In Progress -- 0           (lookup.active)
-  Hits --------- 0           (lookup.success)
-  Misses ------- 0           (lookup.failure)
-  --Reads--
-  In Progress -- 0           (read.active)
-  Hits --------- 30116923  (read.success)
-  Misses ------- 26817128  (read.failure)
-  --Writes--
-  In Progress -- 1           (write.active)
-  Successes ---- 25354918  (write.success)
-  Failures ----- 75520      (write.failure)
-  --Updates--
-  In Progress -- 0           (update.active)
-  Successes ---- 101888     (update.success)
-  Failures ----- 1753       (update.failure)
-  --Removes--
-  In Progress -- 0           (remove.active)
-  Successes ---- 0           (remove.success)
-  Failures ----- 0           (remove.failure)
-  ts>
-
-hostdb-stats		Host Database Statistics
-  syntax: show:hostdb-stats
-  args:   none
-  behavior:  Display Host Database statistics.
-
-  ts> show:hostdb-stats
-  Host Database Hit Rate -- 100% *  (proxy.node.hostdb.hit_ratio)
-  DNS Lookups Per Second -- 0.00    (proxy.node.dns.lookups_per_second)
-
-  *Value represents 10 second average.
-  ts>
-
-dns-stats		DNS Statistics
-  syntax: show:dns-stats
-  args:   none
-  behavior:  Display DNS statistics.
-
-  ts> show:dns-stats
-  DNS Lookups Per Second -- 0.00    (proxy.node.dns.lookups_per_second)
-  ts>
-
-logging-stats		Logging Statistics
-  syntax: show:logging-stats
-  args:   none
-  behavior:  Display Logging statistics.
-
-  ts> show:logging-stats
-  Currently Open Log Files --------- 0       (proxy.process.log.log_files_open)
-  Space Used For Log Files --------- 0       (proxy.process.log.log_files_space_used)
-  Number of Access Events Logged --- 0       (proxy.process.log.event_log_access)
-  Number of Access Events Skipped -- 0       (proxy.process.log.event_log_access_skip)
-  Number of Error Events Logged ---- 0       (proxy.process.log.event_log_error)
-  ts>
-
-network                Network Settings
-   syntax:  show:network
-   args:    none
-   behavior:  Display information about different Network Parameters
-
-   traffic_shell> show:network 
-
-   Hostname ---------------- foo.example.com
-   Default Gateway --------- 192.168.0.1
-   Search Domain ----------- example.com
-   DNS IP Addresses--------- 192.168.0.2
-
-   NIC eth0
-     Status ---------------- up
-     Start on Boot --------- onboot
-     Start Protocol -------- none
-     IP Address ------------ 192.168.0.10
-     Netmask --------------- 255.255.255.0
-     Gateway --------------- default
-
-   NIC eth1
-     Status ---------------- up
-     Start on Boot --------- onboot
-     Start Protocol -------- none
-     IP Address ------------ 192.168.0.11
-     Netmask --------------- 255.255.255.0
-     Gateway --------------- default
-
-   traffic_shell> 
-
-
-Configure submodes (from Enable mode)
-
-Some config commands require hard restart or restart for changes to take effect.
-In these cases, one of the following messages will appear onscreen.
-
-Restart required.
-  Change will take effect after next Restart.
-  Use the "config:restart" command to restart now.
-
-Hard Restart required.
-  Change will take effect after next Hard Restart.
-  Use the "config:hard-restart" command to restart now.
-
--------------------------------------
-Parameter		Description
------------------------------------
-get			Get records.config variable value
-  syntax: config:get <variable>
-  args:   <variable> = variable from records.config
-  behavior:  Retrieve and display the variable from records.config.
-
-  ts# config:get proxy.config.http.server_port
-  proxy.config.http.server_port = 8080
-  ts#
-
-set			Set records.config variable value
-  syntax: config:set <variable> <value>
-  args:   <variable> = variable from records.config
-          <value> = value of variable
-  behavior:  Set the variable from records.config to the specified value.
-
-  ts# config:set proxy.config.http.server_port 8080
-  +OK
-  ts#
-
-name			Proxy Name
-  syntax: config:name <proxyname>
-  args:   <proxyname> = name of proxy
-  behavior:  Set proxyname to <proxyname>
-
-  ts# config:name config1
-  +OK
-  ts#
-
-  ts# config:name
-  config1
-  ts#
-
-start			Start Proxy Software
-  syntax: config:start
-  args:   none
-  behavior:  Run start_traffic_server.
-
-  ts# config:start
-  +OK
-  ts#
-
-stop			Stop Proxy Software
-  syntax: config:stop
-  args:   none
-  behavior:  Run stop_traffic_server.
-
-  ts# config:stop
-  +OK
-  ts#
-
-write			Write Upgrade File (IFC file)
-  syntax: config:write ifc-head ts-version <ts_version> build-date <date> platform <platform> nodes <no_of_nodes> 
-	  config:write feature <feature-string>
-	  config:write tar <tarfilelist>
-	  config:write tar-info <tarball-name> filelist <filelist>
-	  config:write tar-common <filelist>
-	  config:write bin-dir <dir-file-lists> 
-	  config:write bin-group <filelist>
-	  config:write bin-common <filelist>
-	  config:write lib-dir <dir-file-lists>
-	  config:write lib-group <filelist>
-	  config:write lib-common <filelist> 
-	  config:write config-dir <dir-file-filelists>
-	  config:write config-group <filelist>
-	  config:write config-common <filelist>
-	  config:write common <filelist>
-  args: 
-	<ts_version> = <int>.<int>.<int>
-	<date> = <mm>:<dd>:<yy>
-	<platform> = <string>
-	<no_of_nodes> = -1 (default) | 0 (single node) | n (n+1 nodes)
-	<feature-string> = <string>
-        <filelists> = list of files, separated by ,
-	<dir-file-filelists> =  list of subdirectory, followed by filelists in each subdirectory. Subdirectories are separated by ; and file lists are separated by ,
-	
-behavior: Write the text IFC file according to the current install status.
-
-
-read			Read Update File
-  syntax: config:read path <path> file <filename> 
-  args: <path> = <string>
-	<filename> = <string>
-
-behavior: Read the upgrade file and display it. For debugging purpose only.
-	
-reset-stats		Reset Statistics
-  syntax: config:reset-stats
-  args:   none
-  behavior:  Reset all statistics.
-
-  ts# config:reset-stats
-  +OK
-  ts#
-
-http			HTTP Configuration
-			(timeout values, headers, authorization)
-  syntax: config:http status <on | off>
-  record: (proxy.config.http.cache.http)
-    
-    ts# config:http status on
-    ts#
-
-  syntax: config:http <timeout> <seconds>
-  args:   <timeout> can be one of the following
-          keep-alive-timeout-in    (proxy.config.http.keep_alive_no_activity_timeout_in)
-          keep-alive-timeout-out   (proxy.config.http.keep_alive_no_activity_timeout_out)
-          inactive-timeout-in      (proxy.config.http.transaction_no_activity_timeout_in)
-          inactive-timeout-out     (proxy.config.http.transaction_no_activity_timeout_out)
-          active-timeout-in        (proxy.config.http.transaction_active_timeout_in)
-          active-timeout-out       (proxy.config.http.transaction_active_timeout_out)
-
-    ts# config:http keep-alive-timeout-in 10
-    ts#
-          
-  syntax: config:http <remove-from | remove-referer | remove-user | remove-cookie> <on | off>
-  behavior: remove the specified header
-  args:   <remove-from>            (proxy.config.http.anonymize_remove_from)
-          <remove-referer>         (proxy.config.http.anonymize_remove_referer)
-          <remove-user>            (proxy.config.http.anonymize_remove_user_agent)
-          (remove-cookie>          (proxy.config.http.anonymize_remove_cookie)
-
-    ts# config:http remove-from on
-    ts#
-
-  syntax: config:http remove-header <headers>
-  behavior: remove headers specified in list of headers
-  args:     <headers>              (proxy.config.http.anonymize_other_header_list)
-
-    ts# config:http remove-header "field1 field2"
-    ts#
-
-  syntax: config:http <insert-ip | remove-ip> <on | off>
-  behavior: insert or remove client IP from header
-  args:     <insert-ip>            (proxy.config.http.anonymize_insert_client_ip)
-            <remove-ip>            (proxy.config.http.anonymize_remove_client_ip)
-
-  syntax: config:http proxy <fwd | rev | fwd-rev>
-  behavior: enable http proxying in fwd/rev/fwd-rev modes
-
-    ts# config:http proxy
-    fwd
-    ts# config:http proxy rev
-    ts#
-
-
-ssl			SSL Configuration
-                        (on,off,port)
-  syntax: config:ssl status <on | off>
-  record: (proxy.config.ssl.enabled)
-
-    ts# config:ssl status on
-    ts# config:ssl status off
-
-  syntax: config:ssl port <portnum>
-  record: (proxy.config.ssl.server_port)
-    
-    ts# config:ssl port 1234
-    ts#
-   
-
-icp			ICP Configuration
-			(on/off, rules, port, timeouts)
-  syntax: config:icp mode <receive | send-receive | disabled>
-  record: (proxy.config.icp.enabled value)
-          receive = 1, send-receive = 2, disabled = 0
-
-    ts# config:icp mode receive
-    ts#
-
-  syntax: config:icp port <portnum>
-  record: (proxy.config.icp.icp_port)
-
-    ts# config:icp port 3130
-    ts#
-
-  syntax: config:icp multicast <on | off>
-  record: (proxy.config.icp.multicast_enabled)
-  
-    ts# config:icp multicast on
-    ts#
-
-  syntax: config:icp query-timeout <seconds>
-  record: (proxy.config.icp.query_timeout)
-  
-    ts# config:icp query-timeout 2
-    ts#
-
-  syntax: config:icp peers <url>
-  behavior: Retrieve icp.config file from URL.
-
-    ts# config:icp peers http://example.com/icp.config
-    ts#
-
-cache			Cache Configuration
-			(active protocols, bypass, storage, freshness, 
-                         expires, variable content, rules, clear)
-  syntax: config:cache <protocol> <on | off>
-  args:   <protocol> = <http>
-          <on | off> specifies the given protocol is cached
-  behavior:  Enable/Disable caching of various protocols.
-
-    ts# config:cache http on      (proxy.config.http.cache.http)
-    +OK
-    ts#
-
-    ts# config:cache http
-    on
-    ts#
-
-  syntax: config:cache cluster-bypass <on | off>
-  args:   <on | off> turn cluster-bypass on/off.
-  
-    ts# config:cache cluster-bypass on   (proxy.config.http.cache.cluster_cache_local)
-    +OK
-    ts#
-
-    ts# config:cache cluster-bypass
-    on
-    ts#
-
-  syntax: config:cache ignore-bypass <on | off>
-  args:   <on | off> turn ignore-bypass on/off.
-  
-    ts# config:cache ignore-bypass on   (proxy.config.http.cache.ignore_client_no_cache)
-    +OK
-    ts#
-
-    ts# config:cache ignore-bypass
-    on
-    ts#
-
-  syntax: config:cache max-object-size <bytes>
-  args:   if bytes=0 then there is no maximum
-
-    ts# config:cache max-object-size 0  (proxy.config.cache.max_doc_size)
-    +OK
-    ts#
-
-    ts# config:cache max-object-size
-    0
-    ts#
-
-  syntax: config:cache max-alternates <num>
-  args:   if num=0 then there is no maximum
-
-    ts# config:cache max-alternates 0
-    +OK
-    ts#
-
-    ts# config:cache max-alternates
-    0
-    ts#
-
-  syntax: config:cache file [url]
-  args:   [url] = location of remote cache.config file
-  behavior:  Retrieve and install cache.config file from URL.
-
-    ts# config:cache file http://example.com/cache.config
-    +OK
-    ts#
-
-  syntax: config:cache freshness verify <when-expired | no-date | always | never>
-  records.config: proxy.config.http.cache.when_to_revalidate
-  args: when-expired = 0, no-date=1, always=2, never=3
-
-    ts# config:cache freshness verify when-expired
-    +OK
-    ts#
-
-  syntax: config:cache freshness minimum <explicit | last-modified | nothing>
-  records.config: proxy.config.http.cache.required_headers
-  args:   explicit = 2, last-modified = 1, nothing = 0
-
-    ts# config:cache freshness minimum explicit
-    +OK
-    ts#
-
-  syntax: config:cache freshness no-expire-limit greater-than <seconds> less-than <seconds>
-  records.config: proxy.config.http.cache.heuristic_min_lifetime, heuristic_max_lifetime
-  args:   <seconds> is an integer
-
-    ts# config:cache freshness no-expire-limit greater-than 900 less-than 7200
-    +OK
-    ts#
-
-  syntax: config:cache dynamic <on | off>
-  records: proxy.config.http.cache.cache_urls_that_look_dynamic
-  
-    ts# config:cache dynamic on
-    +OK
-    ts#
-
-  syntax: config:cache alternates <on | off>
-  records: proxy.config.http.cache.enable_default_vary_headers
-
-    ts# config:cache alternates on
-    +OK
-    ts#
-
-  syntax: config:cache vary <text | images | other> <field>
-  records: proxy.config.http.cache.vary_default_(text,images,other)
-  args:   <field> is a string
-
-    ts# config:cache vary text Cookie
-    +OK
-    ts#
-
-  syntax: config:cache cookies <none | all | images | non-text>
-  records: proxy.config.http.cache.cache_responses_to_cookies
-  args: none = 0, all = 1, images = 2, non-text = 3
-
-    ts# config:cache cookies none
-    +OK
-    ts#
-
-  syntax: config:cache clear (clear cache and start traffic server)
-  args: none
-
-   ts# config:cache clear
-   Traffic Server is running.
-   Clear Cache failed.
-   ts# config:cache clear
-   +OK
-
-
-hostdb			Host Database Configuration
-  syntax:  config:hostdb lookup-timeout <seconds>
-  records: proxy.config.hostdb.lookup_timeout
-
-    ts# config:hostdb lookup-timeout 30
-    +OK
-    ts#
-
-  syntax:  config:hostdb foreground-timeout <seconds>
-  records: proxy.config.hostdb.timeout (seconds)
-
-    ts# config:hostdb foreground-timeout 12
-    +OK
-    ts#
-
-  syntax:  config:hostdb background-timeout <seconds>
-  records: proxy.config.hostdb.verify_after 24
-
-    ts# config:hostdb background-timeout 24
-    +OK
-    ts#
-
-  syntax:  config:hostdb invalid-host-timeout <seconds>
-  records: proxy.config.hostdb.fail.timeout
-
-    ts# config:hostdb invalid-host-timeout 30
-    +OK
-    ts#
-
-  syntax:  config:hostdb re-dns-on-reload <on | off>
-  records: proxy.config.hostdb.re_dns_on_reload
-
-    ts# config:hostdb re-dns-on-reload on
-    +OK
-    ts#
-
-  syntax: config:hostdb clear  (clear hostdb and start traffic server)
-  args: none
-
-   ts# config:hostdb clear
-   Traffic Server is running.
-   Clear HostDB failed.
-
-   ts# config:hostdb clear 
-   +OK
-   ts#
-
-dns			DNS Configuration
-  syntax:  config:dns resolve-timeout <seconds>
-  records: proxy.config.dns.lookup_timeout
-
-    ts# config:dns resolve-timeout 10
-    +OK
-    ts#
-
-  syntax:  config:dns retries <number>
-  records: proxy.config.dns.retries
-
-    ts# config:dns retries 3
-    +OK
-    ts#
-
-logging			Logging Configuration
-  syntax:  config:logging event <enabled | trans-only | error-only | disabled>
-  records: proxy.config.log.logging_enabled
-
-    ts# config:logging event enabled
-    +OK
-    ts#
-
-    ts# config:logging event
-    enabled
-    ts#
-
-  syntax:  config:logging mgmt-directory <dir>
-  records: proxy.config.log.logfile_dir
-
-    ts# config:logging mgmt-directory /usr/local/var/log/trafficserver
-    +OK
-    ts#
-
-  syntax:  config:logging space-limit <mb>
-  args:    <mb> = log space limit (MB)
-  records: proxy.config.log.max_space_mb_for_logs
-
-    ts# config:logging space-limit 10
-    +OK
-    ts#
-
-  syntax:  config:logging space-headroom <mb>
-  args:    <mb> = log space headroom (MB)
-  records: proxy.config.log.max_space_mb_headroom
-
-    ts# config:logging space-headroom 100
-    +OK
-    ts#
-
-  syntax:  config:logging collation-status <inactive | host | send-standard | send-custom | send-all>
-  args:    inactive = 0, host = 1, send-standard = 2, send-custom = 3, send-all = 4
-  records: proxy.local.log.collation_mode
-
-    ts# config:logging collation-status inactive
-    +OK
-    ts#
-
-    ts# config:log collation-status send-custom 
-    +OK
-    ts#
-
-  syntax:  config:logging collation-host <host>
-  args:    <host> is a remote collation host
-  records: proxy.config.log.collation_host
-
-    ts# config:log collation-host config1
-    +OK
-    ts#
-
-  syntax:  config:logging collation secret <secret> tagged <on | off> orphan-limit <orphan>
-  args:    <secret> = string
-           <orphan> = size in MB
-  records: <secret> = proxy.config.log.collation_port
-           tagged   = proxy.config.log.collation_host_tagged
-           <orphan> = proxy.config.log.collation_secret
-
-    ts# config:logging collation secret foobar tagged on orphan-limit 10
-    +OK
-    ts#
-
-  syntax:  config:logging format <squid | netscape-common | netscape-ext | netscape-ext2> 
-                  <on | off> type <ascii | binary> file <file> header <header>
-
-  squid
-    args:    <on | off> = proxy.config.log.squid_log_enabled
-             type       = proxy.config.log.squid_log_is_ascii <ascii=1, binary=0>
-             file       = proxy.config.log.squid_log_name
-             header     = proxy.config.log.squid_log_header
-  netscape-common
-    args:    <on | off> = proxy.config.log.common_log_enabled
-             type       = proxy.config.log.common_log_is_ascii <ascii=1, binary=0>
-             file       = proxy.config.log.common_log_name
-             header     = proxy.config.log.common_log_header
-  netscape-ext
-    args:    <on | off> = proxy.config.log.extended_log_enabled
-             type       = proxy.config.log.extended_log_is_ascii <ascii=1, binary=0>
-             file       = proxy.config.log.extended_log_name
-             header     = proxy.config.log.extended_log_header
-  netscape-ext2
-    args:    <on | off> = proxy.config.log.extended2_log_enabled
-             type       = proxy.config.log.extended2_log_is_ascii <ascii=1, binary=0>
-             file       = proxy.config.log.extended2_log_name
-             header     = proxy.config.log.extended2_log_header
-
-    ts# config:log format squid on type ascii file squid.log
-    +OK
-    ts#
-
-  syntax:  config:logging splitting <icp | http> <on | off>
-  records:  proxy.config.log.separate_icp_logs  <icp>
-            proxy.config.log.separate_host_logs <http>
-
-    ts# config:log split icp on
-    +OK
-    ts#
-
-  syntax:  config:logging custom <on | off> format <traditional | xml>
-  records:  proxy.config.log.custom_logs_enabled
-
-    ts# config:logging custom on format xml
-    +OK
-    ts#
-
-  syntax:  config:logging rolling <on | off> offset <hour> interval <num-hours> auto-delete <on | off>
-  records: proxy.config.log.rolling_enabled
-           proxy.config.log.rolling_offset_hr (24hour format)
-           proxy.config.log.rolling_interval_sec (seconds)
-
-    ts# config:logging rolling on offset 0 interval 1 auto-delete off
-    +OK
-    ts#
-
-ssl			SSL Ports
-
-security		Security Configuration
-			(TS IP allow, MGMT allow, Admin Access)
-  syntax: config:security ip-allow <url>
-  
-    ts# config:security ip-allow http://example.com/ip_allow.config
-    ts#
-
-  syntax: config:security admin <url>
-
-    ts# config:parent status on 
-    ts#
-
-    ts# config:parent name parent.example.com
-    ts#
-
-    ts# config:parent rules http://example.com/parent.config
-    ts#
-
-remap			Remap Rules
-  syntax: config:remap <url>
-  args:   <url> = retrieve file and use as remap.config
-
-    ts# config:remap http://example.com/remap.config
-    ts#
-
-ports			Ports used by Traffic Server
-*** config:ports command is not implemented or supported ***
-			(including mgmt port)
-  syntax: config:ports <http-server | http-other | webui | cluster
-                        cluster-rs | cluster-mc |
-                        ssl | socks-server | icp> <port | ports>
-  args:   some variables are single-port while other can be a list of ports
-          <http-server>     (proxy.config.http.server_port) single
-          <cluster>         (proxy.config.cluster_port) single
-          <cluster-rs>      (proxy.config.cluster.rsport) single
-          <cluster-mc>      (proxy.config.cluster.mcport) single
-          <connect>         (proxy.config.http.connect_ports) list
-          <socks-server>    (proxy.config.socks.socks_server_port) single
-          <icp>             (proxy.config.icp.icp_port) single
-
-socks			SOCKS Configuration
-  syntax: config:socks status <on | off> version <int> default-servers <string> 
-                       accept <on | off> accept-port <port> 
-  args:   socks            (proxy.config.socks_socks_needed)
-          version          (proxy.config.socks.socks_version)
-          default-servers  (proxy.config.socks.default_servers)
-          accept           (proxy.config.socks.accept_enabled)
-          accept-port      (proxy.config.socks.accept_port)
-
-  ts# config:socks status on 
-  ts#
-  ts# config:socks version 4
-  ts#
-  ts# config:socks default-servers "s1.example.com:1080;socks2:4080"
-  ts#
-  ts# config:socks accept on
-  ts#
-  ts# config:socks accept-port 1080 
-  ts#
-
-
-
-scheduled-update        Scheduled Update Configuration
-  syntax: config:scheduled-update status <on | off>
-                                  retry-count <int>
-                                  retry-interval <sec>
-				  max-concurrent <value>
-				  force-immediate <on | off>
-				  rules <url>
-
-  args:   config update.config file
-  behavior: Scheduled Update Configuration.
-
-  ts> config:scheduled-update on
-  ts>
-
-  ts> config:scheduled-update retry-count 10 
-  ts>
-
-  ts> config:scheduled-update retry-interval 2
-
-  ts> config:scheduled-update force-immediate off
-  ts>
-
-  ts> config:scheduled-update rules http://example.com
-
-  ts> config:scheduled-update rules
-  update.config rules
-  ------------------- 
-  (Display list of rules from update.config)
-  ts>
-
-
-Appliance-Specific commands (Linux only)
-========================================
-
-Normal Mode
------------
-  ping		Send ICMP ECHO_REQUEST packets to host.
-    syntax: ping <host>
-    args:   hostname
-
-    ts> ping foo
-    foo is alive
-    ts>
-
-  traceroute    Display the route packets take to host.
-    syntax: traceroute <host>
-    args:   hostname
-
-    ts> traceroute foo
-    Traceroute output appears here...
-    ts>
-
-Configure Mode
---------------
-
-config:network	Make System Network configuration changes
-
-   traffic_shell> config:network
-
-   Command Syntax: 
-   config:network hostname <string>
-   config:network defaultrouter <x.x.x.x>
-   config:network search-domain <string>
-   config:network dns [a.a.a.a] [b.b.b.b] [c.c.c.c]
-   config:network int <interface>
-   config:network int <interface> down
-   config:network int <interface> up <onboot | not-onboot>
-                 <static | dhcp> <ip> <netmask> <gateway>
-   config:network int <interface> <onboot | not-onboot>
-   config:network int <interface> <static | dhcp>
-   config:network int <interface> ip <x.x.x.x>
-   config:network int <interface> netmask <x.x.x.x>
-   config:network int <interface> gateway <x.x.x.x | default>
-
-   traffic_shell> 
-
-  hostname      Specify appliance hostname
-    syntax: config:network hostname <name>
-    ts# config:network hostname xxxx
-    ts# config:network hostname
-    xxxx
-    ts#
-
-  defaultrouter  Specify default router
-    syntax: config:network defaultrouter <x.x.x.x>
-
-    ts# config:network defaultrouter x.x.x.x
-    ts# config:network defaultrouter
-    x.x.x.x
-    ts#
-
-  search-domain  Specify DNS search domain
-    syntax: config:network search-domain <x.x.x.x>
-
-    ts# config:network search-domain example.com
-    ts# config:network search-domain
-    example.com
-    ts#
-
-  dns		Specify one or more DNS servers
-    syntax: config:network dns <string of IP addresses>
-
-    ts# config:network dns "192.168.0.2 192.168.0.3"
-    ts# config:network dns
-    192.168.0.2 192.168.0.3
-    ts#
-
-  int		Configure Network Interface Card
-
-	config:network int
-		List network interface cards by name.
-
-	config:network int <interface>
-		Display NIC configuration.
-
-	config:network int <interface> down
-		Bring down the specified interface.
-
-	config:network int <interface> up <onboot | not-onboot>
-			   <static | dhcp> <ip> <netmask> <gateway>
-		Bring up a NIC with the specified parameters.
-
-	config:network int <interface> <onboot | not-onboot>
-		Change the boot start status of a NIC that is already up.
-
-	config:network int <interface> <static | dhcp>
-		Change the static/dhcp status of a NIC that is already up.
-
-	config:network int <interface> ip <x.x.x.x>
-		Change the IP address of a NIC that is already up.
-
-	config:network int <interface> netmask <x.x.x.x>
-		Change the netmask of a NIC that is already up.
-
-	config:network int <interface> gateway <x.x.x.x | default>
-		Change the gateway of a NIC that is already up.
-
-   traffic_shell> config:network int     
-   eth0
-   eth1
-   traffic_shell> config:network int eth0
-
-   NIC eth0
-     Status -------------- up
-     Start on Boot ------- onboot
-     Start Protocol ------ none
-     IP Address ---------- 192.168.0.10
-     Netmask ------------- 255.255.255.0
-     Gateway ------------- default
-
-   traffic_shell> 
-    
-
-  date		Specify system date.
-    syntax: config:clock date <date>
-    args:   <date> = mm/dd/yyyy
-
-    ts# config:clock date 01/01/2001
-    ts# config:clock date
-    01/01/2001
-    ts#
-  
-  time		Specify system time.
-    syntax: config time <time>
-    args:   <time> = hh:mm:ss
-
-    ts# config:clock time 14:00:00
-    ts# config:clock time
-    14:00:03
-    ts#
-
-  timezone	Specify time zone.
-    syntax: config:clock timezone [zone | list]
-    args:   [zone] optional time zone from numbered list
-            if not present, display current time zones
-	    [list] display list of time zone
-
-    ts# config:clock timezone
-    Display numbered current timezones.
-
-    ts# config:clock timezone 3
-    ts#
-    
-    ts# config:clock timezone list
-    Display list of time zone. (85 in total currently)
-
-  halt		Halt appliance.
-    syntax: halt
-
-    ts# halt
-
-  reboot	Reboot appliance.
-    syntax: reboot
-
-    ts# reboot


[34/44] git commit: TS-2327: TSRedirectUrlSet does not perform DNS lookup of redirected OS

Posted by zw...@apache.org.
TS-2327: TSRedirectUrlSet does not perform DNS lookup of redirected OS


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

Branch: refs/heads/5.0.x
Commit: 9f05ebe81f5ceca844ae34bb51691afa198a39db
Parents: 46adeb3
Author: Ron Barber <rb...@yahoo-inc.com>
Authored: Wed Nov 20 19:00:53 2013 -0800
Committer: Bryan Call <bc...@apache.org>
Committed: Wed Nov 20 19:00:53 2013 -0800

----------------------------------------------------------------------
 CHANGES              | 2 ++
 proxy/http/HttpSM.cc | 2 ++
 2 files changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9f05ebe8/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index fdac461..24a9ac5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2327] TSRedirectUrlSet does not perform DNS lookup of redirected OS
+
   *) [TS-1468] Check vary and accept headers on non-200 responses in cache
 
   *) [TS-2352] refine THREAD_ALLOC feature.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9f05ebe8/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index e5751a0..a957bcb 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -7384,6 +7384,8 @@ HttpSM::redirect_request(const char *redirect_url, const int redirect_len)
   t_state.response_received_time = 0;
   t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT;
   t_state.next_action = HttpTransact::REDIRECT_READ;
+  // we have a new OS and need to have DNS lookup the new OS
+  t_state.dns_info.lookup_success = false;
 
   // check to see if the client request passed a host header, if so copy the host and port from the redirect url and
   // make a new host header


[41/44] git commit: Change these two bad boys from DOS line feeds to real one...

Posted by zw...@apache.org.
Change these two bad boys from DOS line feeds to real one...


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

Branch: refs/heads/5.0.x
Commit: 0c8fba41036958085585ebcceac0749a1d6159e5
Parents: 70c70ca
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Nov 21 11:00:59 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Nov 21 11:00:59 2013 -0700

----------------------------------------------------------------------
 README-EC2                                      | 268 +++++-----
 plugins/experimental/mysql_remap/mysql_remap.cc | 498 +++++++++----------
 2 files changed, 383 insertions(+), 383 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c8fba41/README-EC2
----------------------------------------------------------------------
diff --git a/README-EC2 b/README-EC2
index 013e93f..52c8449 100644
--- a/README-EC2
+++ b/README-EC2
@@ -1,134 +1,134 @@
-Apache TrafficServer AMIs for EC2
-Author: Jason Giedymin
-
---TOC--
-1.0 Ubuntu Based Images
-1.1 Ubuntu AMI Details
-1.2 What is installed?
-
-2.0 Fedora Based Images
-2.1 Fedora AMI Details
-2.2 What is installed?
-
-3.0 The ATS Installation
-3.1 Additional Update Functionality
-3.2 User customized settings
-3.3 Script Breakout
-
-4.0 FAQ
-4.1 I use EC2 and I'm still confused!?
-4.2 What is EC2?
-4.3 I don't use EC2 or have an AWS account, can I still use these scripts on 
-    my Virtual Machine or dedicated Ubuntu/Fedora Linux Box?
-4.4 How do I contact you for help?
-4.5 Will these AMIs be updated in the future?
-
--------
-
-1.0 Ubuntu Based Images
-  This is the prefered image as Ubuntu is kept up to date by Canonical.
-
-1.1 Ubuntu AMI Details
-  Name: Amuxbit-Karmic-ApacheTrafficServer-AMI
-  x86_64 AMI: ami-ada24cc4, kernel: aki-fd15f694, Ramdisk: ari-7b739e12
-    i386 AMI: ami-5ba34d32, kernel: aki-5f15f636, Ramdisk: ari-d5709dbc
-
-1.2 What is installed?
-  All packages other than Apache TrafficServer are from the ec2 ubuntu 
-  package repositories.  All software installed should be open source.
-    * Official Canonical Ubuntu Karmic 9.10 EC2 AMI
-    * Dist Upgraded as of 4/1/2010
-    * Apache TrafficServer - Trunk (can be updated at any time)
-    * openjdk-6-jre (for ec2 tools)
-    * ruby (for ec2 tools)
-    * libopenssl-ruby (for ec2 tools)
-    * Apache2 (httpd, used for testing)
-
-2.0 Fedora Based Images
-
-2.1 Fedora AMI Details
-  Name: Amuxbit-Fedora8-ApacheTrafficServer-AMI
-  x86_64 AMI: ami-c3a04eaa, kernel: aki-a3d737ca, Ramdisk: ari-7cb95a15
-    i386 AMI: ami-53a04e3a, kernel: aki-6eaa4907, Ramdisk: ari-42b95a2b
-
-2.2 What is installed?
-  All packages other than Apache TrafficServer are from the ec2 fedora 
-  package repositories.  All software installed should be open source.
-    * Official Fedora Core 8 EC2 AMI
-    * Dist Upgraded as of 4/1/2010
-    * Apache TrafficServer - Trunk (can be updated at any time)
-    * java-1.7.0-icedtea (openjdk for ec2 tools)
-    * openssl-devel (for ec2 tools)
-    * ruby (for ec2 tools)
-    * httpd (Apache web server, used for testing)
-
-3.0 The ATS Installation
-  Apache Traffic Server is installed in: '/ats'.
-  The installation script used to install ATS is contained within the contrib
-  directory, part of the ATS source distribution.  The script is included 
-  within the '/ats' folder for actual use.  
-
-3.1 Additional Update Functionality
-  The EC2 images provided contain additional scripts to maintain freshness 
-  of the install scripts.  At one time the scripts provided 'auto-heal' 
-  functionality but that has been removed.  Running /ats/install_update.sh 
-  will keep the ATS installation up to date.
-
-3.2 User customized settings
-  Any customized settings will be lost if the update/install scripts are run.
-  Upon executing the install/update scripts you may copy your files back into
-  the config directory.  Users should periodically backup your config files, 
-  and keep abrest of any config changes as new versions of ATS are released.
-  The latter reason being why I did not auto-copy configs.  While I've tried 
-  to lessen as much pain for any Sys Admins, ultimately you must take charge 
-  of these critical settings as updates will and do happen frequently to the 
-  ATS source.
-
-  An example script which alters settings can be found in 
-    '/ats/contrib/set_trafficserver.sh'
-  This has been used on the AMIs already provided.
-
-3.3 Script Breakout
-
- ats
- |-- contrib
-     | -- install_trafficserver.sh : installs ATS. Try not to run this directly.
-     | -- set_trafficserver.sh : sample config/testing/benchmark base script. 
-            You may want to learn from/use this script.
-     ` -- update_scripts.sh : used to update install_trafficserver.sh, 
-            and set_trafficserver.sh from trunk.
- |-- install_update.sh : the 'easy button' script to re-install ATS. 
-       Executes update_scripts.sh, then install_trafficserver.sh. 
-       This is what you want to run.
- `-- readme : extra information.
-
-4.0 FAQ
-
-4.1 I use EC2 and I'm still confused!?
-  With your EC2 account, refer to one of the AMIs listed in this doc 
-  (Ubuntu/Fedora).  Image architectures provided are i386, and x86_64.  
-  64bit is offered for those who need to spin up a big high powered instances.
-  Once running (and it may take a while) you will find yourself with a Linux 
-  distribution with Apache Traffic Server already installed.  If you'd like 
-  to re-install ATS against trunk, run '/ats/install_update.sh'.  Note that 
-  you will have to backup and/or optimize your configuration (see 3.2).  
-  To further setup ATS see the TrafficServer wiki @ 
-
-    http://cwiki.apache.org/confluence/display/TS/
-
-4.2 What is EC2?
-  See http://aws.amazon.com/
-
-4.3 I don't use EC2 or have an AWS account, can I still use these scripts on 
-    my Virtual Machine or dedicated Ubuntu/Fedora Linux Box?
-  Absolutely!  The /contrib scripts are actually meant for Ubuntu/Linux 
-  Installs first, EC2 second.  You can find them on the ATS SVN/Git 
-  repository under '/contrib'.
-
-4.4 How do I contact you for help?
-  For mailing lists, and IRC information, visit our web page at
-
-    http://trafficserver.apache.org/
-
-4.5 Will these AMIs be updated in the future?
-  Absolutely!
+Apache TrafficServer AMIs for EC2
+Author: Jason Giedymin
+
+--TOC--
+1.0 Ubuntu Based Images
+1.1 Ubuntu AMI Details
+1.2 What is installed?
+
+2.0 Fedora Based Images
+2.1 Fedora AMI Details
+2.2 What is installed?
+
+3.0 The ATS Installation
+3.1 Additional Update Functionality
+3.2 User customized settings
+3.3 Script Breakout
+
+4.0 FAQ
+4.1 I use EC2 and I'm still confused!?
+4.2 What is EC2?
+4.3 I don't use EC2 or have an AWS account, can I still use these scripts on
+    my Virtual Machine or dedicated Ubuntu/Fedora Linux Box?
+4.4 How do I contact you for help?
+4.5 Will these AMIs be updated in the future?
+
+-------
+
+1.0 Ubuntu Based Images
+  This is the prefered image as Ubuntu is kept up to date by Canonical.
+
+1.1 Ubuntu AMI Details
+  Name: Amuxbit-Karmic-ApacheTrafficServer-AMI
+  x86_64 AMI: ami-ada24cc4, kernel: aki-fd15f694, Ramdisk: ari-7b739e12
+    i386 AMI: ami-5ba34d32, kernel: aki-5f15f636, Ramdisk: ari-d5709dbc
+
+1.2 What is installed?
+  All packages other than Apache TrafficServer are from the ec2 ubuntu
+  package repositories.  All software installed should be open source.
+    * Official Canonical Ubuntu Karmic 9.10 EC2 AMI
+    * Dist Upgraded as of 4/1/2010
+    * Apache TrafficServer - Trunk (can be updated at any time)
+    * openjdk-6-jre (for ec2 tools)
+    * ruby (for ec2 tools)
+    * libopenssl-ruby (for ec2 tools)
+    * Apache2 (httpd, used for testing)
+
+2.0 Fedora Based Images
+
+2.1 Fedora AMI Details
+  Name: Amuxbit-Fedora8-ApacheTrafficServer-AMI
+  x86_64 AMI: ami-c3a04eaa, kernel: aki-a3d737ca, Ramdisk: ari-7cb95a15
+    i386 AMI: ami-53a04e3a, kernel: aki-6eaa4907, Ramdisk: ari-42b95a2b
+
+2.2 What is installed?
+  All packages other than Apache TrafficServer are from the ec2 fedora
+  package repositories.  All software installed should be open source.
+    * Official Fedora Core 8 EC2 AMI
+    * Dist Upgraded as of 4/1/2010
+    * Apache TrafficServer - Trunk (can be updated at any time)
+    * java-1.7.0-icedtea (openjdk for ec2 tools)
+    * openssl-devel (for ec2 tools)
+    * ruby (for ec2 tools)
+    * httpd (Apache web server, used for testing)
+
+3.0 The ATS Installation
+  Apache Traffic Server is installed in: '/ats'.
+  The installation script used to install ATS is contained within the contrib
+  directory, part of the ATS source distribution.  The script is included
+  within the '/ats' folder for actual use.
+
+3.1 Additional Update Functionality
+  The EC2 images provided contain additional scripts to maintain freshness
+  of the install scripts.  At one time the scripts provided 'auto-heal'
+  functionality but that has been removed.  Running /ats/install_update.sh
+  will keep the ATS installation up to date.
+
+3.2 User customized settings
+  Any customized settings will be lost if the update/install scripts are run.
+  Upon executing the install/update scripts you may copy your files back into
+  the config directory.  Users should periodically backup your config files,
+  and keep abrest of any config changes as new versions of ATS are released.
+  The latter reason being why I did not auto-copy configs.  While I've tried
+  to lessen as much pain for any Sys Admins, ultimately you must take charge
+  of these critical settings as updates will and do happen frequently to the
+  ATS source.
+
+  An example script which alters settings can be found in
+    '/ats/contrib/set_trafficserver.sh'
+  This has been used on the AMIs already provided.
+
+3.3 Script Breakout
+
+ ats
+ |-- contrib
+     | -- install_trafficserver.sh : installs ATS. Try not to run this directly.
+     | -- set_trafficserver.sh : sample config/testing/benchmark base script.
+            You may want to learn from/use this script.
+     ` -- update_scripts.sh : used to update install_trafficserver.sh,
+            and set_trafficserver.sh from trunk.
+ |-- install_update.sh : the 'easy button' script to re-install ATS.
+       Executes update_scripts.sh, then install_trafficserver.sh.
+       This is what you want to run.
+ `-- readme : extra information.
+
+4.0 FAQ
+
+4.1 I use EC2 and I'm still confused!?
+  With your EC2 account, refer to one of the AMIs listed in this doc
+  (Ubuntu/Fedora).  Image architectures provided are i386, and x86_64.
+  64bit is offered for those who need to spin up a big high powered instances.
+  Once running (and it may take a while) you will find yourself with a Linux
+  distribution with Apache Traffic Server already installed.  If you'd like
+  to re-install ATS against trunk, run '/ats/install_update.sh'.  Note that
+  you will have to backup and/or optimize your configuration (see 3.2).
+  To further setup ATS see the TrafficServer wiki @
+
+    http://cwiki.apache.org/confluence/display/TS/
+
+4.2 What is EC2?
+  See http://aws.amazon.com/
+
+4.3 I don't use EC2 or have an AWS account, can I still use these scripts on
+    my Virtual Machine or dedicated Ubuntu/Fedora Linux Box?
+  Absolutely!  The /contrib scripts are actually meant for Ubuntu/Linux
+  Installs first, EC2 second.  You can find them on the ATS SVN/Git
+  repository under '/contrib'.
+
+4.4 How do I contact you for help?
+  For mailing lists, and IRC information, visit our web page at
+
+    http://trafficserver.apache.org/
+
+4.5 Will these AMIs be updated in the future?
+  Absolutely!

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c8fba41/plugins/experimental/mysql_remap/mysql_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/mysql_remap/mysql_remap.cc b/plugins/experimental/mysql_remap/mysql_remap.cc
index c93274e..3dcc3fa 100644
--- a/plugins/experimental/mysql_remap/mysql_remap.cc
+++ b/plugins/experimental/mysql_remap/mysql_remap.cc
@@ -1,249 +1,249 @@
-/*
-  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 <ts/ts.h>
-#include <ts/remap.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "mysql/mysql.h"
-#include "lib/iniparser.h"
-#include "default.h"
-
-MYSQL mysql;
-
-typedef struct {
-  char * query;
-} my_data;
-
-bool do_mysql_remap(TSCont contp,TSHttpTxn txnp) {
-  TSMBuffer reqp;
-  TSMLoc hdr_loc, url_loc, field_loc;
-  bool ret_val = false;
-  
-  const char * request_host;
-  int request_host_length = 0;
-  const char * request_scheme;
-  int request_scheme_length = 0;
-  int request_port = 80;
-  char * query;
-  
-  MYSQL_ROW row;
-  MYSQL_RES *res;
-  
-  my_data * data = (my_data*) TSContDataGet(contp);
-  query = data->query;
-  
-  if (TSHttpTxnClientReqGet(txnp, &reqp, &hdr_loc) != TS_SUCCESS) {
-    TSDebug(PLUGIN_NAME,"could not get request data");
-    return false;
-  }
-  
-  TSHttpHdrUrlGet(reqp, hdr_loc,&url_loc);
-  
-  if (!url_loc) {
-    TSDebug(PLUGIN_NAME,"couldn't retrieve request url");
-    goto release_hdr;
-  }
-  
-  field_loc = TSMimeHdrFieldFind(reqp, hdr_loc, TS_MIME_FIELD_HOST, TS_MIME_LEN_HOST);
-  
-  if (!field_loc) {
-      TSDebug(PLUGIN_NAME,"couldn't retrieve request HOST header");
-      goto release_url;
-  }
-  
-  request_host = TSMimeHdrFieldValueStringGet (reqp, hdr_loc, field_loc, -1, &request_host_length);
-  if (!request_host_length) {
-    TSDebug(PLUGIN_NAME,"couldn't find request HOST header");
-    goto release_field;
-  }
-  
-  request_scheme = TSUrlSchemeGet(reqp,url_loc,&request_scheme_length);
-  request_port   = TSUrlPortGet(reqp,url_loc);
-
-  TSDebug(PLUGIN_NAME,"      +++++MYSQL REMAP+++++      ");
-
-  TSDebug(PLUGIN_NAME,"\nINCOMING REQUEST ->\n ::: from_scheme_desc: %.*s\n ::: from_hostname: %.*s\n ::: from_port: %d",\
-    request_scheme_length,\
-    request_scheme,\
-    request_host_length,\
-    request_host,\
-    request_port
-  );
-  
-  snprintf(query,QSIZE," \
-    SELECT \
-        t_scheme.scheme_desc, \
-        t_host.hostname, \
-        to_port \
-      FROM map \
-        INNER JOIN scheme as t_scheme ON (map.to_scheme_id = t_scheme.id) \
-        INNER JOIN scheme as f_scheme ON (map.from_scheme_id = f_scheme.id) \
-        INNER JOIN hostname as t_host ON (map.to_hostname_id = t_host.id) \
-        INNER JOIN hostname as f_host ON (map.from_hostname_id = f_host.id) \
-      WHERE \
-        is_enabled=1 \
-        AND f_host.hostname = '%.*s' \
-        AND f_scheme.id = %d \
-        AND from_port = %d \
-      LIMIT 1", \
-    request_host_length, \
-    request_host, \
-    (strcmp(request_scheme,"https") == 0) ? 2:1, \
-    request_port \
-  );
-  
-  mysql_real_query(&mysql,query,(unsigned int)strlen(query));
-  res = mysql_use_result(&mysql);
-  
-  if (!res) goto not_found; //TODO: define a fallback
-  
-  do { 
-    row = mysql_fetch_row(res);
-    if (!row) goto not_found;
-    TSDebug(PLUGIN_NAME,"\nOUTGOING REQUEST ->\n ::: to_scheme_desc: %s\n ::: to_hostname: %s\n ::: to_port: %s",row[0],row[1],row[2]);
-    TSMimeHdrFieldValueStringSet(reqp, hdr_loc, field_loc, 0,row[1],-1);
-    TSUrlHostSet(reqp,url_loc,row[1],-1);
-    TSUrlSchemeSet(reqp,url_loc,row[0],-1);
-    TSUrlPortSet(reqp,url_loc,atoi(row[2]));
-  } while(0);
-  
-  ret_val = true;
-
-not_found:
-  if (!ret_val) {
-    //lets build up a nice 404 message for someone
-    TSHttpHdrStatusSet(reqp,hdr_loc,TS_HTTP_STATUS_NOT_FOUND);
-    TSHttpTxnSetHttpRetStatus(txnp,TS_HTTP_STATUS_NOT_FOUND);
-  }
-  if (res)
-    mysql_free_result(res);
-#if (TS_VERSION_NUMBER < 2001005)
-  if (request_host)
-    TSHandleStringRelease(reqp, hdr_loc, request_host);
-  if (request_scheme)
-    TSHandleStringRelease(reqp, hdr_loc, request_scheme);
-#endif
-release_field:
-  if (field_loc)
-    TSHandleMLocRelease(reqp, hdr_loc, field_loc);
-release_url:
-  if (url_loc)
-    TSHandleMLocRelease(reqp, hdr_loc, url_loc);
-release_hdr:
-  if (hdr_loc)
-    TSHandleMLocRelease(reqp, TS_NULL_MLOC, hdr_loc);
-  
-  return ret_val;
-}
-
-static int
-mysql_remap (TSCont contp, TSEvent event, void *edata) {
-  TSHttpTxn txnp = (TSHttpTxn) edata;
-  TSEvent reenable = TS_EVENT_HTTP_CONTINUE;
-  
-  switch(event) {
-    case TS_EVENT_HTTP_READ_REQUEST_HDR:
-      TSDebug(PLUGIN_NAME,"Reading Request");
-      TSSkipRemappingSet(txnp,1);
-      if (!do_mysql_remap(contp,txnp)) {
-        reenable = TS_EVENT_HTTP_ERROR;
-      }
-      break;
-    default:
-      break;
-  }
-  
-  TSHttpTxnReenable(txnp, reenable);
-  return 1;
-}
-
-void
-TSPluginInit(int argc, const char *argv[]) {
-  dictionary * ini;
-  const char * host;
-  int port;
-  const char * username;
-  const char * password;
-  const char * db;
-  
-  my_data * data = (my_data*) malloc(1*sizeof(my_data));
-  
-  TSPluginRegistrationInfo info;
-  my_bool reconnect = 1;
-  
-  info.plugin_name   = const_cast<char*>(PLUGIN_NAME);
-  info.vendor_name   = const_cast<char*>("Apache Software Foundation");
-  info.support_email = const_cast<char*>("dev@trafficserver.apache.org");
-
-  if (TSPluginRegister(TS_SDK_VERSION_2_0 , &info) != TS_SUCCESS) {
-    TSError("mysql_remap: plugin registration failed.\n"); 
-  }
-
-  if (argc != 2) {
-    TSError( "usage: %s /path/to/sample.ini\n", argv[0] );
-    return;
-  }
-  
-  ini = iniparser_load(argv[1]);
-  if (!ini) {
-    TSError("Error with ini file (1)");
-    TSDebug(PLUGIN_NAME,"Error parsing ini file(1)");
-    return;
-  }
-  
-  host     = iniparser_getstring(ini, "mysql_remap:mysql_host", (char*)"localhost");
-  port     =    iniparser_getint(ini,"mysql_remap:mysql_port",3306);
-  username = iniparser_getstring(ini, "mysql_remap:mysql_username", NULL);
-  password = iniparser_getstring(ini, "mysql_remap:mysql_password", NULL);
-  db       = iniparser_getstring(ini, "mysql_remap:mysql_database", (char*)"mysql_remap");
-  
-  if (mysql_library_init(0, NULL, NULL)) {
-    TSError("Error initializing mysql client library");
-    TSDebug(PLUGIN_NAME,"Error initializing mysql client library");
-    return;
-  }
-  
-  if (!mysql_init(&mysql)) {
-    TSError("Could not initialize MySQL");
-    TSDebug(PLUGIN_NAME,"Could not initialize MySQL");
-    return;
-  }
-  
-  mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
-  
-  if (!mysql_real_connect(&mysql,host,username,password,db,port,NULL,0)) {
-    TSError("Could not connect to mysql");
-    TSDebug(PLUGIN_NAME,"Could not connect to mysql: %s",mysql_error(&mysql));
-    return;
-  }
-  
-  data->query = (char*)TSmalloc(QSIZE * sizeof(char)); //TODO: malloc smarter sizes
-      
-  TSDebug(PLUGIN_NAME, "h: %s; u: %s; p: %s; p:%d; d:%s",host,username,password,port,db);
-  TSCont cont = TSContCreate(mysql_remap, TSMutexCreate());
-  
-  TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont);
-
-  TSContDataSet (cont, (void *)data);
-  
-  TSDebug(PLUGIN_NAME, "plugin is successfully initialized [plugin mode]");
-  iniparser_freedict(ini);
-  return;
-}
+/*
+  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 <ts/ts.h>
+#include <ts/remap.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "mysql/mysql.h"
+#include "lib/iniparser.h"
+#include "default.h"
+
+MYSQL mysql;
+
+typedef struct {
+  char * query;
+} my_data;
+
+bool do_mysql_remap(TSCont contp,TSHttpTxn txnp) {
+  TSMBuffer reqp;
+  TSMLoc hdr_loc, url_loc, field_loc;
+  bool ret_val = false;
+
+  const char * request_host;
+  int request_host_length = 0;
+  const char * request_scheme;
+  int request_scheme_length = 0;
+  int request_port = 80;
+  char * query;
+
+  MYSQL_ROW row;
+  MYSQL_RES *res;
+
+  my_data * data = (my_data*) TSContDataGet(contp);
+  query = data->query;
+
+  if (TSHttpTxnClientReqGet(txnp, &reqp, &hdr_loc) != TS_SUCCESS) {
+    TSDebug(PLUGIN_NAME,"could not get request data");
+    return false;
+  }
+
+  TSHttpHdrUrlGet(reqp, hdr_loc,&url_loc);
+
+  if (!url_loc) {
+    TSDebug(PLUGIN_NAME,"couldn't retrieve request url");
+    goto release_hdr;
+  }
+
+  field_loc = TSMimeHdrFieldFind(reqp, hdr_loc, TS_MIME_FIELD_HOST, TS_MIME_LEN_HOST);
+
+  if (!field_loc) {
+      TSDebug(PLUGIN_NAME,"couldn't retrieve request HOST header");
+      goto release_url;
+  }
+
+  request_host = TSMimeHdrFieldValueStringGet (reqp, hdr_loc, field_loc, -1, &request_host_length);
+  if (!request_host_length) {
+    TSDebug(PLUGIN_NAME,"couldn't find request HOST header");
+    goto release_field;
+  }
+
+  request_scheme = TSUrlSchemeGet(reqp,url_loc,&request_scheme_length);
+  request_port   = TSUrlPortGet(reqp,url_loc);
+
+  TSDebug(PLUGIN_NAME,"      +++++MYSQL REMAP+++++      ");
+
+  TSDebug(PLUGIN_NAME,"\nINCOMING REQUEST ->\n ::: from_scheme_desc: %.*s\n ::: from_hostname: %.*s\n ::: from_port: %d",\
+    request_scheme_length,\
+    request_scheme,\
+    request_host_length,\
+    request_host,\
+    request_port
+  );
+
+  snprintf(query,QSIZE," \
+    SELECT \
+        t_scheme.scheme_desc, \
+        t_host.hostname, \
+        to_port \
+      FROM map \
+        INNER JOIN scheme as t_scheme ON (map.to_scheme_id = t_scheme.id) \
+        INNER JOIN scheme as f_scheme ON (map.from_scheme_id = f_scheme.id) \
+        INNER JOIN hostname as t_host ON (map.to_hostname_id = t_host.id) \
+        INNER JOIN hostname as f_host ON (map.from_hostname_id = f_host.id) \
+      WHERE \
+        is_enabled=1 \
+        AND f_host.hostname = '%.*s' \
+        AND f_scheme.id = %d \
+        AND from_port = %d \
+      LIMIT 1", \
+    request_host_length, \
+    request_host, \
+    (strcmp(request_scheme,"https") == 0) ? 2:1, \
+    request_port \
+  );
+
+  mysql_real_query(&mysql,query,(unsigned int)strlen(query));
+  res = mysql_use_result(&mysql);
+
+  if (!res) goto not_found; //TODO: define a fallback
+
+  do {
+    row = mysql_fetch_row(res);
+    if (!row) goto not_found;
+    TSDebug(PLUGIN_NAME,"\nOUTGOING REQUEST ->\n ::: to_scheme_desc: %s\n ::: to_hostname: %s\n ::: to_port: %s",row[0],row[1],row[2]);
+    TSMimeHdrFieldValueStringSet(reqp, hdr_loc, field_loc, 0,row[1],-1);
+    TSUrlHostSet(reqp,url_loc,row[1],-1);
+    TSUrlSchemeSet(reqp,url_loc,row[0],-1);
+    TSUrlPortSet(reqp,url_loc,atoi(row[2]));
+  } while(0);
+
+  ret_val = true;
+
+not_found:
+  if (!ret_val) {
+    //lets build up a nice 404 message for someone
+    TSHttpHdrStatusSet(reqp,hdr_loc,TS_HTTP_STATUS_NOT_FOUND);
+    TSHttpTxnSetHttpRetStatus(txnp,TS_HTTP_STATUS_NOT_FOUND);
+  }
+  if (res)
+    mysql_free_result(res);
+#if (TS_VERSION_NUMBER < 2001005)
+  if (request_host)
+    TSHandleStringRelease(reqp, hdr_loc, request_host);
+  if (request_scheme)
+    TSHandleStringRelease(reqp, hdr_loc, request_scheme);
+#endif
+release_field:
+  if (field_loc)
+    TSHandleMLocRelease(reqp, hdr_loc, field_loc);
+release_url:
+  if (url_loc)
+    TSHandleMLocRelease(reqp, hdr_loc, url_loc);
+release_hdr:
+  if (hdr_loc)
+    TSHandleMLocRelease(reqp, TS_NULL_MLOC, hdr_loc);
+
+  return ret_val;
+}
+
+static int
+mysql_remap (TSCont contp, TSEvent event, void *edata) {
+  TSHttpTxn txnp = (TSHttpTxn) edata;
+  TSEvent reenable = TS_EVENT_HTTP_CONTINUE;
+
+  switch(event) {
+    case TS_EVENT_HTTP_READ_REQUEST_HDR:
+      TSDebug(PLUGIN_NAME,"Reading Request");
+      TSSkipRemappingSet(txnp,1);
+      if (!do_mysql_remap(contp,txnp)) {
+        reenable = TS_EVENT_HTTP_ERROR;
+      }
+      break;
+    default:
+      break;
+  }
+
+  TSHttpTxnReenable(txnp, reenable);
+  return 1;
+}
+
+void
+TSPluginInit(int argc, const char *argv[]) {
+  dictionary * ini;
+  const char * host;
+  int port;
+  const char * username;
+  const char * password;
+  const char * db;
+
+  my_data * data = (my_data*) malloc(1*sizeof(my_data));
+
+  TSPluginRegistrationInfo info;
+  my_bool reconnect = 1;
+
+  info.plugin_name   = const_cast<char*>(PLUGIN_NAME);
+  info.vendor_name   = const_cast<char*>("Apache Software Foundation");
+  info.support_email = const_cast<char*>("dev@trafficserver.apache.org");
+
+  if (TSPluginRegister(TS_SDK_VERSION_2_0 , &info) != TS_SUCCESS) {
+    TSError("mysql_remap: plugin registration failed.\n");
+  }
+
+  if (argc != 2) {
+    TSError( "usage: %s /path/to/sample.ini\n", argv[0] );
+    return;
+  }
+
+  ini = iniparser_load(argv[1]);
+  if (!ini) {
+    TSError("Error with ini file (1)");
+    TSDebug(PLUGIN_NAME,"Error parsing ini file(1)");
+    return;
+  }
+
+  host     = iniparser_getstring(ini, "mysql_remap:mysql_host", (char*)"localhost");
+  port     =    iniparser_getint(ini,"mysql_remap:mysql_port",3306);
+  username = iniparser_getstring(ini, "mysql_remap:mysql_username", NULL);
+  password = iniparser_getstring(ini, "mysql_remap:mysql_password", NULL);
+  db       = iniparser_getstring(ini, "mysql_remap:mysql_database", (char*)"mysql_remap");
+
+  if (mysql_library_init(0, NULL, NULL)) {
+    TSError("Error initializing mysql client library");
+    TSDebug(PLUGIN_NAME,"Error initializing mysql client library");
+    return;
+  }
+
+  if (!mysql_init(&mysql)) {
+    TSError("Could not initialize MySQL");
+    TSDebug(PLUGIN_NAME,"Could not initialize MySQL");
+    return;
+  }
+
+  mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
+
+  if (!mysql_real_connect(&mysql,host,username,password,db,port,NULL,0)) {
+    TSError("Could not connect to mysql");
+    TSDebug(PLUGIN_NAME,"Could not connect to mysql: %s",mysql_error(&mysql));
+    return;
+  }
+
+  data->query = (char*)TSmalloc(QSIZE * sizeof(char)); //TODO: malloc smarter sizes
+
+  TSDebug(PLUGIN_NAME, "h: %s; u: %s; p: %s; p:%d; d:%s",host,username,password,port,db);
+  TSCont cont = TSContCreate(mysql_remap, TSMutexCreate());
+
+  TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, cont);
+
+  TSContDataSet (cont, (void *)data);
+
+  TSDebug(PLUGIN_NAME, "plugin is successfully initialized [plugin mode]");
+  iniparser_freedict(ini);
+  return;
+}


[39/44] convert CRLF->LF, make sure it never happens again

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/cache-arch.en.rst
----------------------------------------------------------------------
diff --git a/doc/arch/cache/cache-arch.en.rst b/doc/arch/cache/cache-arch.en.rst
old mode 100755
new mode 100644
index 179e5a4..7fefc09
--- a/doc/arch/cache/cache-arch.en.rst
+++ b/doc/arch/cache/cache-arch.en.rst
@@ -1,798 +1,798 @@
-.. 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.
-
-Cache Architecture
-******************
-
-.. include:: common.defs
-
-Introduction
-~~~~~~~~~~~~
-
-In addition to an HTTP proxy, |ATS| is also an HTTP cache. |TS| can cache any octet stream although it currently
-supports only those octet streams delivered by the HTTP protocol. When such a stream is cached (along with the HTTP
-protocol headers) it is termed an *object* in the cache. Each object is identified by a globally unique value called a
-*cache key*. By default this is generated by taking the `MD5 hash <http://www.openssl.org/docs/crypto/md5.html>`_ of the
-URI used to retrieve the content from the origin server.
-
-The purpose of this document is to describe the basic structure and implementation details of the |TS| cache.
-Configuration of the cache will be discussed only to the extent needed to understand the internal mechanisms. This
-document will be useful primarily to |TS| developers working on the |TS| codebase or plugins for |TS|. It is assumed the
-reader is already familiar with the :ref:`admin-guide` and specifically with :ref:`http-proxy-caching` and
-:ref:`configuring-the-cache` along with the associated configuration files and values.
-
-Unfortunately the internal terminology is not particularly consistent so this document will frequently use terms in
-different ways than they are used in the code in an attempt to create some consistency.
-
-Cache Layout
-~~~~~~~~~~~~
-
-The first step in understanding cache operations is to understand the data structures and layout of the cache.
-
-Cache storage
-=============
-
-The raw storage for the |TS| cache is configured in :file:`storage.config`. Each line in the file defines a :term:`cache span` which is treated as an undifferentiated unit of storage.
-
-.. figure:: images/cache-spans.png
-   :align: center
-
-   Two cache spans
-
-This storage organized in to a set of :term:`cache volume`\ s which are defined in :file:`volume.config`. Cache volumes
-can be defined by a percentage of the total storage or an absolute amount of storage. By default each cache volume is spread across all of the cache spans for robustness. The intersection of a cache volume and a cache span is a :term:`cache stripe`. Each cache span is divided in to cache stripes and each cache volume is a collection of those stripes.
-
-If the cache volumes for the example cache spans were defined as
-
-.. image:: images/ats-cache-volume-definition.png
-   :align: center
-
-then the actual layout would look like
-
-.. image:: images/cache-span-layout.png
-   :align: center
-
-A cached object is stored entirely in a single stripe, and therefore in a single cache span - objects are never split
-across cache volumes. Objects are assigned to a stripe (and hence to a cache volume) automatically based on a hash of
-the URI used to retrieve the object from the origin server. It is possible to configure this to a limited extent in
-:file:`hosting.config` which supports content from specific host or domain to be stored on specific volumes. In
-addition, as of version 4.0.1 it is possible to control which cache spans (and hence, which cache stripes) are contained
-in a specific cache volume.
-
-The layout and structure of the cache spans, the cache volumes, and the cache stripes that compose them are derived
-entirely from the :file:`storage.config` and :file:`cache.config` and is recomputed from scratch when the
-:process:`traffic_server` is started. Therefore any change to those files can (and almost always will) invalidate the
-existing cache in its entirety.
-
-Stripe Structure
-================
-
-|TS| treats the storage associated with a cache stripe as an undifferentiated span of bytes. Internally each stripe is
-treated almost entirely independently. The data structures described in this section are duplicated for each stripe.
-Internally the term "volume" is used for these stripes and implemented primarily in :cpp:class:`Vol`. What a user thinks
-of as a volume (what this document calls a "cache volume") is represented by :cpp:class:`CacheVol`.
-
-.. note::
-
-   Stripe assignment must be done before working with an object because the directory is local to the stripe. Any cached
-   objects for which the stripe assignment is changed are effectively lost as their directory data will not be found in
-   the new stripe.
-
-.. index:: cache directory
-.. _cache-directory:
-
-Cache Directory
----------------
-
-.. index:: directory entry
-.. index:: fragment
-.. index:: cache ID
-
-.. _fragment:
-
-Content in a stripe is tracked via a directory. We call each element of the directory a "directory entry" and each is
-represented by :cpp:class:`Dir`. Each entry refers to a chunk of contiguous storage in the cache. These are referred to
-variously as "fragments", "segments", "docs" / "documents", and a few other things. This document will use the term
-"fragment" as that is the most common reference in the code. The term "Doc" (for :cpp:class:`Doc`) will be used to refer
-to the header data for a fragment. Overall the directory is treated as a hash with a "cache ID" as the key. A cache ID
-is a 128 bit (16 byte) value generated in various ways depending on context. This ID is reduced and used as an index in
-to the directory to locate an entry in the standard way.
-
-The directory is used as a memory resident structure which means a directory entry is as small as possible (currently 10
-bytes). This forces some compromises on the data that can be stored there. On the other hand this means that most cache
-misses do not require disk I/O which has a large performance benefit.
-
-An additional point is the directory is always fully sized. Once a stripe is initialized the directory size is
-fixed and never changed. This size is related (roughly linearly) to the size of the stripe. It is for this reason the
-memory footprint of |TS| depends strongly on the size of the disk cache. Because the directory size does not change,
-neither does this memory requirement so |TS| does not consume more memory as more content is stored in the cache. If
-there is enough memory to run |TS| with an empty cache there is enough to run it with a full cache.
-
-.. figure:: images/cache-directory-structure.png
-   :align: center
-
-Each entry stores an offset in the stripe and a size. The size stored in the directory entry is an :ref:`approximate
-size <dir-size>` which is at least as big as the actual data. Exact size data is stored in the fragment header on disk.
-
-.. note::
-
-   Data in HTTP headers cannot be examined without disk I/O. This includes the original URL for the object. The original
-   source of the cache ID is not stored anywhere.
-
-.. _dir-segment:
-.. _dir-bucket:
-
-The entries in a directory are grouped. The first level grouping is a *bucket*. This is a fixed number (currently 4 -
-defined as ``DIR_DEPTH``) of entries. The index generated from a cache ID is used as a bucket index (not an entry index).
-Buckets are grouped in to *segments*. All segments in a stripe have the same number of buckets. The number of segments
-in a stripe is chosen so that each segment has as many buckets as possible without exceeeding 65535 (2\ :sup:`16`\ -1)
-entries in a segment. Note that all segments in the same stripe will have the same number of buckets.
-
-.. figure:: images/dir-segment-bucket.png
-   :align: center
-
-Each entry has a previous and next index value which is used to link the entries in the same segment. The index size is
-16 bits which suffices to index any entry in the same segment. The stripe header contains an array of entry indices
-which are used as the roots of a free list. When a stripe is initialized the first entry in each bucket is zeroed
-(marked unused) and all other entries are put in the corresponding segment free list rooted in the stripe header. In
-essence the first element of each fixed bucket is used as a root for that bucket. The other entries in the fixed bucker
-are preferentially preferred for adding to that bucket but this is not required. The segment free lists are initialized
-such that the extra bucket entries are added in order - all the seconds, then the thirds, then the fourths. Because the
-free lists are FIFOs this means extra entries will be selected from the fourth entries across all the buckets first,
-then the thirds, etc. This maximizes locality for bucket searching.
-
-.. figure:: images/dir-bucket-assign.png
-   :align: center
-
-Entries are removed from the free list when used and returned when no longer in use. When a fragment needs to be put in
-to the directory the cache ID is used to locate a bucket (which also determines the segment). If the first entry in the
-bucket is marked unused, it is used. If not then the other entries in the bucket are searched and if any are on the free
-list, that entry is used. If none are available then the first entry on the segment free list is used. This entry is
-attached to the bucket via the same next and previous indices used for the free list so that it can be found when doing
-a lookup of a cache ID.
-
-Storage Layout
---------------
-
-The storage layout is the stripe metadata followed by cached content. The metadata consists of three parts - the stripe
-header, the directory, and the stripe footer. The metadata is stored twice. The header and the footer are instances of
-:cpp:class:`VolHeaderFooter`. This is a stub structure which can have a trailing variable sized array. This array is
-used as the segment free list roots in the directory. Each contains the segment index of the first element of the free
-list for the segment. The footer is a copy of the header without the segment free lists. This makes the size of the
-header dependent on the directory but not that of the footer.
-
-.. figure:: images/cache-stripe-layout.png
-   :align: center
-
-Each stripe has several values that describe its basic layout.
-
-skip
-   The start of stripe data. This represents either space reserved at the start of a physical device to avoid problems
-   with the host operating system, or an offset representing use of space in the cache span by other stripes.
-
-start
-   The offset for the start of the content, after the stripe metadata.
-
-length
-   Total number of bytes in the stripe. :cpp:member:`Vol::len`.
-
-data length
-   Total number of blocks in the stripe available for content storage. :cpp:member:`Vol::data_blocks`.
-
-.. note:: Great care must be taken with sizes and lengths in the cache code because there are at least three different metrics (bytes, cache blocks, store blocks) used in various places.
-
-The total size of the directory (the number of entries) is computed by taking the size of the stripe and dividing by the
-average object size. The directory always consumes this amount of memory which has the effect that if cache size is
-increased so is the memory requirement for |TS|. The average object size defaults to 8000 bytes but can be configured
-using :ts:cv:`proxy.config.cache.min_average_object_size`. Increasing the average object size will reduce the memory
-footprint of the directory at the expense of reducing the number of distinct objects that can be stored in the cache
-[#]_.
-
-.. index: write cursor
-.. _write-cursor:
-
-The content area stores the actual objects and is used as a circular buffer where new objects overwrite the least
-recently cached objects. The location in a stripe where new cache data is written is called the *write cursor*. This
-means that objects can be de facto evicted from cache even if they have not expired if the data is overwritten by the
-write cursor. If an object is overwritten this is not detected at that time and the directory is not updated. Instead it
-will be noted if the object is accessed in the future and the disk read of the fragment fails.
-
-.. figure:: images/ats-cache-write-cursor.png
-   :align: center
-
-   The write cursor and documents in the cache.
-
-.. note:: Cache data on disk is never updated.
-
-This is a key thing to keep in mind. What appear to be updates (such as doing a refresh on stale content and getting
-back a 304) are actually new copies of data being written at the write cursor. The originals are left as "dead" space
-which will be consumed when the write cursor arrives at that disk location. Once the stripe directory is updated (in
-memory!) the original fragment in the cache is effectively destroyed. This is the general space management techinque
-used in other cases as well. If an object needs to removed from cache, only the directory needs to be changed. No other
-work (and *particularly* no disk I/O) needs to be done.
-
-Object Structure
-================
-
-Objects are stored as two types of data, metadata and content data. Metadata is all the data about the object and the
-content and includes the HTTP headers. The content data is the content of the object, the octet stream delivered to the
-client as the object.
-
-Objects are rooted in a :cpp:class:`Doc` structure stored in the cache. :cpp:class:`Doc` serves as the header data for a
-fragment and is contained at the start of every fragment. The first fragment for an object is termed the "first ``Doc``"
-and always contains the object metadata. Any operation on the object will read this fragment first. The fragment is
-located by converting the cache key for the object to a cache ID and then doing a lookup for a directory entry with that
-key. The directory entry has the offset and approximate size of the first fragment which is then read from the disk.
-This fragment will contain the request header and response along with overall object properties (such as content
-length).
-
-.. index:: alternate
-
-|TS| supports `varying content <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44>`_ for objects. These
-are called *alternates*. All metadata for all alternates is stored in the first fragment including the set of alternates
-and the HTTP headers for them. This enables `alternate selection
-<http://trafficserver.apache.org/docs/trunk/sdk/http-hooks-and-transactions/http-alternate-selection.en.html>`_ to be
-done after the first ``Doc`` is read from disk. An object that has more than one alternate will have the alternate
-content stored separately from the first fragment. For objects with only one alternate the content may or may not be in
-the same (first) fragment as the metadata. Each separate alternate content is allocated a directory entry and the key
-for that entry is stored in the first fragment metadata.
-
-Prior to version 4.0.1 the header data was stored in the :cpp:class:`CacheHTTPInfoVector` class which was marshaled to a
-variable length area of the on disk image, followed by information about additional fragments if needed to store the
-object.
-
-.. figure:: images/cache-doc-layout-3-2-0.png
-   :align: center
-
-   ``Doc`` layout 3.2.0
-
-This had the problem that with only one fragment table it could not be reliable for objects with more than one alternate
-[#]_. Therefore the fragment data was moved from being a separate variable length section of the metadata to being
-directly incorporated in to the :cpp:class:`CacheHTTPInfoVector`, yielding a layout of the following form.
-
-.. figure:: images/cache-doc-layout-4-0-1.png
-   :align: center
-
-   ``Doc`` layout 4.0.1
-
-Each element in the vector contains for each alternate, in addition to the HTTP headers and the fragment table (if any),
-a cache key. This cache key identifies a directory entry that is referred to as the "earliest ``Doc``". This is the
-location where the content for the alternate begins.
-
-When the object is first cached, it will have a single alternate and that will be stored (if not too large) in first
-``Doc``. This is termed a *resident alternate* in the code. This can only happen on the initial store of the object. If
-the metadata is updated (such as a ``304`` response to an ``If-Modified-Since`` request) then unless the object is
-small, the object data will be left in the original fragment and a new fragment written as the first fragment, making
-the alternate non-resident. "Small" is defined as a length smaller than :ts:cv:`proxy.config.cache.alt_rewrite_max_size`.
-
-.. note::
-
-   The :cpp:class:`CacheHTTPInfoVector` is stored only in the first ``Doc``. Subsequent ``Doc`` instances for the
-   object, including the earliest ``Doc``, should have an ``hlen`` of zero and if not, it is ignored.
-
-Large objects are split in to multiple fragments when written to the cache. This is indicated by a total document length
-that is longer than the content in first ``Doc`` or an earliest ``Doc``. In such a case a fragment offset table is
-stored. This contains the byte offset in the object content of the first byte of content data for each fragment past the
-first (as the offset for the first is always zero). This allows range requests to be serviced much more efficiently for
-large objects, as intermediate fragments that do not contain data in the range can be skipped. The last fragment in the
-sequence is detected by the fragment size and offset reaching the end of the total size of the object, there is no
-explicit end mark. Each fragment is computationally chained from the previous in that the cache key for fragment N is
-computed by::
-
-   key_for_N_plus_one = next_key(key_for_N);
-
-where ``next_key`` is a global function that deterministically computes a new cache key from an existing cache key.
-
-Objects with multiple fragments are laid out such that the data fragments (including the earliest ``Doc``) are written
-first and the first ``Doc`` is written last. When read from disk, both the first and earliest ``Doc`` are validated
-(tested to ensure that they haven't been overwritten by the write cursor) to verify that the entire document is present
-on disk (as they bookend the other fragments - the write cursor cannot overwrite them without overwriting at leastone of
-the verified ``Doc`` instances). Note that while the fragments of a single object are ordered they are not necessarily
-contiguous as data from different objects are interleaved as the data arrives in |TS|.
-
-.. figure:: images/cache-multi-fragment.png
-   :align: center
-
-   Multi-alternate and multi-fragment object storage
-
-.. index:: pinned
-
-Documents which are "pinned" into the cache must not be overwritten so they are "evacuated" from in front of the write
-cursor. Each fragment is read and rewritten. There is a special lookup mechanism for objects that are being evacuated so
-that they can be found in memory rather than the potentially unreliable disk regions. The cache scans ahead of the write
-cursor to discover pinned objects as there is a dead zone immediately before the write cursor from which data cannot be
-evacuated. Evacuated data is read from disk and placed in the write queue and written as its turn comes up.
-
-It appears that objects can only be pinned via the :file:`cache.config` file and if the
-:ts:cv:`proxy.config.cache.permit.pinning` is set to non-zero (it is zero by default). Objects which are in use when the
-write cursor is near use the same underlying evacuation mechanism but are handled automatically and not via the explicit
-``pinned`` bit in :cpp:class:`Dir`.
-
-.. [#] It could, under certain circumstances, be accurate for none of the alternates.
-
-Additional Notes
-====================
-
-Some general observations on the data structures.
-
-Cyclone buffer
---------------
-
-Because the cache is a cyclone cache objects are not preserved for an indefinite time. Even if the object is not stale
-it can be overwritten as the cache cycles through its volume. Marking an object as ``pinned`` preserves the object
-through the passage of the write cursor but this is done by copying the object across the gap, in effect re-storing it
-in the cache. Pinning large objects or a large number objects can lead to a excessive disk activity. The original
-purpose of pinning seems to have been for small, frequently used objects explicitly marked by the administrator.
-
-This means the purpose of expiration data on objects is simply to prevent them from being served to clients. They are
-not in the standard sense deleted or cleaned up. The space can't be immediately reclaimed in any event because writing
-only happens at the write cursor. Deleting an object consists only of removing the directory entries in the volume
-directory which suffices to (eventually) free the space and render the document inaccessible.
-
-Historically the cache is designed this way because web content was relatively small and not particularly consistent.
-The design also provides high performance and low consistency requirements. There are no fragmentation issues for the
-storage, and both cache misses and object deletions require no disk I/O. It does not deal particularly well with long
-term storage of large objects. See the :ref:`volume tagging` appendix for details on some work in this area.
-
-Disk Failure
-------------
-
-The cache is designed to be relatively resistant to disk failures. Because each storage unit in each volume is mostly independent the loss of a disk simply means that the corresponding :cpp:class:`Vol` instances (one per cache volume that uses the storage unit) becomes unusable. The primary issue is updating the volume assignment table to both preserve assignments for objects on still operational volumes while distributing the assignments from the failed disk to those operational volumes. This mostly done in::
-
-   AIO_Callback_handler::handle_disk_failure
-
-Restoring a disk to active duty is quite a bit more difficult task. Changing the volume assignment of a cache key renders any currently cached data inaccessible. This is obviouly not a problem when a disk has failed, but is a bit trickier to decide which cached objects are to be de facto evicted if a new storage unit is added to a running system. The mechanism for this, if any, is still under investigation.
-
-Implementation Details
-======================
-
-Stripe Directory
-----------------
-
-.. _directory-entry:
-
-The in memory volume directory entries are defined as described below.
-
-.. cpp:class:: Dir
-
-   Defined in |P-CacheDir.h|_.
-
-   =========== =================== ===================================================
-   Name        Type                Use
-   =========== =================== ===================================================
-   offset      unsigned int:24     Offset of first byte of metadata (volume relative)
-   big         unsigned in:2       Size multiplier
-   size        unsigned int:6      Size
-   tag         unsigned int:12     Partial key (fast collision check)
-   phase       unsigned int:1      Unknown
-   head        unsigned int:1      Flag: first fragment in an object
-   pinned      unsigned int:1      Flag: document is pinned
-   token       unsigned int:1      Flag: Unknown
-   next        unsigned int:16     Segment local index of next entry.
-   offset_high inku16              High order offset bits
-   =========== =================== ===================================================
-
-   The stripe directory is an array of ``Dir`` instances. Each entry refers to a span in the volume which contains a cached object. Because every object in the cache has at least one directory entry this data has been made as small as possible.
-
-   The offset value is the starting byte of the object in the volume. It is 40 bits long split between the *offset* (lower 24 bits) and *offset_high* (upper 16 bits) members. Note that since there is a directory for every storage unit in a cache volume, this is the offset in to the slice of a storage unit attached to that volume.
-
-.. _dir-size:
-
-   The *size* and *big* values are used to calculate the approximate size of the span which contains the object. This value is used as the number of bytes to read from storage at the offset value. The exact size is contained in the object metadata in :cpp:class:`Doc` which is consulted once the read has completed. For this reason the approximate size needs to be at least as large as the actual size but can be larger, at the cost of reading the extraneous bytes.
-
-   The computation of the approximate size of the fragment is defined as::
-
-      ( *size* + 1 ) * 2 ^ ( ``CACHE_BLOCK_SHIFT`` + 3 * *big* )
-
-   where ``CACHE_BLOCK_SHIFT`` is the bit width of the size of a basic cache block (9, corresponding to a sector size of 512). Therefore the value with current defines is::
-
-      ( *size* + 1 ) * 2 ^ (9 + 3 * *big*)
-
-   Because *big* is 2 bits the values for the multiplier of *size* are
-
-   .. _big-mult:
-
-   ===== ===============   ========================
-   *big* Multiplier        Maximum Size
-   ===== ===============   ========================
-     0   512 (2^9)         32768 (2^15)
-     1   4096 (2^12)       262144 (2^18)
-     2   32768 (2^15)      2097152 (2^21)
-     3   262144 (2^18)     16777216 (2^24)
-   ===== ===============   ========================
-
-   Note also that *size* is effectively offset by one, so a value of 0 indicates a single unit of the multiplier.
-
-.. _target-fragment-size:
-
-The target fragment size can set with the :file:`records.config` value
-
-   ``proxy.config.cache.target_fragment_size``
-
-This value should be chosen so that it is a multiple of a :ref:`cache entry multiplier <big-mult>`. It is not necessary
-to make it a power of 2 [#]_. Larger fragments increase I/O efficiency but lead to more wasted space. The default size
-(1M, 2^20) is a reasonable choice in most circumstances altough in very specific cases there can be benefit from tuning
-this parameter. |TS| imposes an internal maximum of a 4194232 bytes which is 4M (2^22) less the size of a struct
-:cpp:class:`Doc`. In practice then the largest reasonable target fragment size is 4M - 262144 = 3932160.
-
-When a fragment is stored to disk the size data in the cache index entry is set to the finest granularity permitted by
-the size of the fragment. To determine this consult the :ref:`cache entry multipler <big-mult>` table, find the smallest
-maximum size that is at least as large as the fragment. That will indicate the value of *big* selected and therefore the
-granularity of the approximate size. That represents the largest possible amount of wasted disk I/O when the fragment is
-read from disk.
-
-.. note:: The cache index entry size is used only for reading the fragment from disk. The actual size on disk, and the
-amount of cache space consumed, is the actual size of the content rounded up to the disk sector size (default 512
-bytes).
-
-.. index:: DIR_DEPTH, index segment, index buckets
-
-The set of index entries for a volume are grouped in to *segments*. The number of segments for an index is selected so
-that there are as few segments as possible such that no segment has more than 2^16 entries. Intra-segment references can
-therefore use a 16 bit value to refer to any other entry in the segment.
-
-Index entries in a segment are grouped *buckets* each of ``DIR_DEPTH`` (currently 4) entries. These are handled in the
-standard hash table way, giving somewhat less than 2^14 buckets per segment.
-
-.. [#] The comment in :file:`records.config` is simply wrong.
-
-.. _dir-probe:
-
-Directory Probing
------------------
-
-Directory probing is locating a specific directory entry in the stripe directory based on a cache ID. This is handled
-primarily by the function :cpp:func:`dir_probe()`. This is passed the cache ID (:arg:`key`), a stripe (:arg:`d`), and a
-last collision (:arg:`last_collision`). The last of these is an in and out parameter, updated as useful during the
-probe.
-
-Given an ID, the top half (64 bits) is used as a :ref:`segment <dir-segment>` index, taken modulo the number of segments in
-the directory. The bottom half is used as a :ref:`bucket <dir-bucket>` index, taken modulo the number of buckets per
-segment. The :arg:`last_collision` value is used to mark the last matching entry returned by `dir_probe`.
-
-After computing the appropriate bucket, the entries in that bucket are searched to find a match. In this case a match is
-detected by comparison of the bottom 12 bits of the cache ID (the *cache tag*). The search starts at the base entry for
-the bucket and then proceeds via the linked list of entries from that first entry. If a tag match is found and there is
-no :arg:`collision` then that entry is returned and :arg:`last_collision` is updated to that entry. If :arg:`collision`
-is set, then if it isn't the current match the search continues down the linked list, otherwise :arg:`collision` is
-cleared and the search continues. The effect of this is that matches are skipped until the last returned match
-(:arg:`last_collision`) is found, after which the next match (if any) is returned. If the search falls off the end of
-the linked list then a miss result is returned (if no last collision), otherwise the probe is restarted after clearing
-the collision on the presumption that the entry for the collision has been removed from the bucket. This can lead to
-repeats among the returned values but guarantees that no valid entry will be skipped.
-
-Last collision can therefore be used to restart a probe at a later time. This is important because the match returned
-may not be the actual object - although the hashing of the cache ID to a bucket and the tag matching is unlikely to
-create false positives, that is possible. When a fragment is read the full cache ID is available and checked and if
-wrong, that read can be discarded and the next possible match from the directory found because the cache virtual
-connection tracks the last collision value.
-
-----------------
-Cache Operations
-----------------
-
-Cache activity starts after the HTTP request header has been parsed and remapped. Tunneled transactions do not interact with the cache because the headers are never parsed.
-
-To understand the logic we must introduce the term "cache valid" which means something that is directly related to an object that is valid to be put in the cache (e.g. a ``DELETE`` which refers to a URL that is cache valid but cannot be cached itself). This is important because |TS| computes cache validity several times during a transaction and only performs cache operations for cache valid results. The criteria used changes during the course of the transaction as well. This is done to avoid the cost of cache activity for objects that cannot be in the cache.
-
-The three basic cache operations are lookup, read, and write. We will take deleting entries as a special case of writing where only the volume directory is updated.
-
-After the client request header is parsed and is determined to be potentially cacheable, a `cache lookup`_ is done. If successful a `cache read`_ is attempted. If either the lookup or the read fails and the content is considered cacheable then a `cache write`_ is attempted.
-
-Cacheability
-============
-
-The first thing done with a request with respect to cache is to determine whether it is potentially a valid object for the cache. After initial parsing and remapping this check is done primarily to detect a negative result because if so all further cache processing is skipped -- it will not be put in to the cache nor will a cache lookup be done. There are a number of prerequisites along with configuration options to change them. Additional cacheability checks are done later in the process when more is known about the transaction (such as plugin operations and the origin server response). Those checks are described as appropriate in the sections on the relevant operations.
-
-The set of things which can affect cacheability are
-
-* Built in constraints
-* Settings in :file:`records.config`
-* Settings in :file:`cache.config`
-* Plugin operations
-
-The initial internal checks, along with their :file:`records.config` overrides[#]_, are done in::
-
-   HttpTransact::is_request_cache_lookupable
-
-The checks that are done are
-
-   Cacheable Method
-      The request must be one of ``GET``, ``HEAD``, ``POST``, ``DELETE``, ``PUT``.
-
-      See ``HttpTransact::is_method_cache_lookupable()``.
-
-   Dynamic URL
-      |TS| tries to avoid caching dynamic content because it's dynamic. A URL is considered dynamic if it
-
-      *  is not ``HTTP`` or ``HTTPS``
-      *  has query parameters
-      *  ends in ``asp``
-      *  has ``cgi`` in the path
-
-      This check can be disabled by setting a non-zero value for::
-
-         proxy.config.http.cache.cache_urls_that_look_dynamic
-
-      In addition if a TTL is set for rule that matches in :file:`cache.config` then this check is not done.
-
-   Range Request
-      Cache valid only if :ts:cv:`proxy.config.http.cache.range.lookup` in :file:`records.config` is non-zero. This does not mean the range request can be cached, only that it might be satisfiable from the cache.
-
-A plugin can call :c:func:`TSHttpTxnReqCacheableSet()` to force the request to be viewed as cache valid.
-
-.. [#] The code appears to check :file:`cache.config` in this logic by setting the ``does_config_permit_lookup`` in the ``cache_info.directives`` of the state machine instance but I can find no place where the value is used. The directive ``does_config_permit_storing`` is set and later checked so the directive (from the administrator point of view) is effective in preventing caching of the object.
-
-Cache Lookup
-============
-
-If the initial request is not determined to be cache invalid then a lookup is done. Cache lookup determines if an object is in the cache and if so, where it is located. In some cases the lookup proceeds to read the first ``Doc`` from disk to verify the object is still present in the cache.
-
-There are three basic steps to a cache lookup.
-
-#. The cache key is computed.
-
-   This is normally computed using the request URL but it can be overridden :ref:`by a plugin <cache-key>` . As far as I can tell the cache index string is not stored anywhere, it presumed computable from the client request header.
-
-#. The cache stripe is determined (based on the cache key).
-
-   The cache key is used as a hash key in to an array of :cpp:class:`Vol` instances. The construction and arrangement of this array is the essence of how volumes are assigned.
-
-#. The cache stripe directory :ref:`is probed <dir-probe>` using the index key computed from the cache key.
-
-   Various other lookaside directories are checked as well, such as the :ref:`aggregation buffer <aggregation-buffer>`.
-
-#. If the directory entry is found the first ``Doc`` is read from disk and checked for validity.
-
-   This is done in :cpp:func:`CacheVC::openReadStartHead()` or :cpp:func:`CacheVC::openReadStartEarliest()` which are tightly coupled methods.
-
-If the lookup succeeds then a more detailed directory entry (struct :cpp:class:`OpenDir`) is created. Note that the directory probe includes a check for an already extant ``OpenDir`` which if found is returned without additional work.
-
-Cache Read
-==========
-
-Cache read starts after a successful `cache lookup`_. At this point the first ``Doc`` has been loaded in to memory and can be consulted for additional information. This will always contain the HTTP headers for all alternates of the object.
-
-.. sidebar:: Read while write
-
-   There is provision in the code to support "read while write", that is serving an object from cache in one transaction while it is being written in another. It is unclear to me if this actually works. It must specifically enabled in :file:`records.config` and if not, a cache read will fail if the object is currently be written or updated.
-
-At this point an alternate for the object is selected. This is done by comparing the client request to the stored response headers, but it can be controlled by a plugin using ``TS_HTTP_ALT_SELECT_HOOK``.
-
-The content can now be checked to see if it is stale by calculating the "freshness" of the object. This is essential checking how old the object is by looking at the headers and possibly other metadata (note the headers can't be checked until we've selected an alternate).
-
-Most of this work is done in::
-
-   HttpTransact::what_is_document_freshness
-
-First the TTL (time to live) value which can be set in:file:`cache.config` is checked if the request matches the configuration file line. This is done based on when the object was placed in cache, not on any data in the headers.
-
-Next an internal flag ("needs-revalidate-once") is checked if the :file:`cache.config` value "revalidate-after" is not set, and if set the object is marked "stale".
-
-After these checks the object age is calculated by::
-
-   HttpTransactHeaders::calculate_document_age
-
-and then any configured fuzzing is applied. The limits to this age based on available data is calculated by::
-
-   HttpTransact::calculate_document_freshness_limit
-
-How this age is used is determined by the :file:`records.config` value::
-
-   proxy.config.http.cache.when_to_revalidate
-
-If this is zero then the built caclulations are used which compare the freshness limits with document age, modified by any of the client supplied cache control values ``max-age``, ``min-fresh``, ``max-stale`` unless explicitly overridden in :file:`cache.config`.
-
-If the object is not stale then it is served to the client. If stale the client request may be changed to an ``If Modified Since`` request to revalidate.
-
-The request is served using a standard virtual connection tunnel (``HttpTunnel``) with the :cpp:class:`CacheVC` acting
-as the producer and the client ``NetVC`` acting as the sink. If the request is a range request this can be modified with
-a transform to select the appropriate parts of the object or, if the request contains a single range, it can use the
-range acceleration.
-
-Range acceleration is done by consulting a fragment offset table attached to the earliest ``Doc`` which contains offsets
-for all fragments past the first. This allows loading the fragment containing the first requested byte immediately
-rather than performing reads on the intermediate fragments.
-
-Cache Write
-===========
-
-Writing to cache is handled by an instance of the class :cpp:class:`CacheVC`. This is a virtual connection which
-receives data and writes it to cache, acting as a sink. For a standard transaction data transfers between virtual
-connections (*VConns*) are handled by :cpp:class:HttpTunnel. Writing to cache is done by attaching a ``CacheVC``
-instance as a tunnel consumer. It therefore operates in parallel with the virtual connection that transfers data to the
-client. The data does not flow to the cache and then to the client, it is split and goes both directions in parallel.
-This avoids any data synchronization issues between the two.
-
-.. sidebar:: Writing to disk
-
-   The actual write to disk is handled in a separate thread dedicated to I/O operations, the AIO threads. The cache
-   logic marshals the data and then hands the operation off to the AIO thread which signals back once the operation
-   completes.
-
-While each ``CacheVC`` handles its transactions independently, they do interact at the volume level as each ``CacheVC``
-makes calls to the volume object to write its data to the volume content. The ``CacheVC`` accumulates data internally
-until either the transaction is complete or the amount of data to write exceeds the target fragment size. In the former
-case the entire object is submitted to the volume to be written. In the latter case a target fragment size amount of
-data is submitted and the ``CacheVC`` continues to operate on subsequent data. The volume in turn places these write
-requests in an holding area called the `aggregation buffer`_.
-
-For objects under the target fragment size there is no consideration of order, the object is simply written to the
-volume content. For larger objects the earliest ``Doc`` is written first and the first ``Doc`` written last. This
-provides some detection ability should the object be overwritten. Because of the nature of the write cursor no fragment
-after the first fragment (in the earliest ``Doc``) can be overwritten without also overwriting that first fragment
-(since we know at the time the object was finalized in the cache the write cursor was at the position of the first
-``Doc``).
-
-.. note:: It is the responsibility of the ``CacheVC`` to not submit writes that exceed the target fragment size.
-
-.. how does the write logic know if it's an original object write or an update to an existing object?
-
-Update
-------
-
-Cache write also covers the case where an existing object in the cache is modified. This occurs when
-
-* A conditional request is made to the origin server and a ``304 - Not Modified`` response is received.
-* An alternate of the object is retrieved from an origin server and added to the object.
-* An alternate of the object is removed (e.g., due to a ``DELETE`` request).
-
-In every case the metadata for the object must be modified. Because |TS| never updates data already in the cache this
-means the first ``Doc`` will be written to the cache again and the volume directory entry updated. Because a client
-request has already been processed the first ``Doc`` has been read from cache and is in memory. The alternate vector is
-updated as appropriate (an entry added or removed, or changed to contain the new HTTP headers), and then written to
-disk. It is possible for multiple alternates to be updated by different ``CacheVC`` instances at the same time. The only
-contention is the first ``Doc``, the rest of the data for each alternate is completely independent.
-
-.. _aggregation-buffer:
-
-Aggregation Buffer
-------------------
-
-Disk writes to cache are handled through an *aggregation buffer*. There is one for each :cpp:class:`Vol` instance. To
-minimize the number of system calls data is written to disk in units of roughly :ref:`target fragment size
-<target-fragment-size>` bytes. The algorithm used is simple - data is piled up in the aggregation buffer until no more
-will fit without going over the targer fragment size, at which point the buffer is written to disk and the volume
-directory entries for objects with data in the buffer are updated with the actual disk locations for those objects
-(which are determined by the write to disk action). After the buffer is written it is cleared and process repeats. There
-is a special lookup table for the aggregation buffer so that object lookup can find cache data in that memory.
-
-Because data in the aggregation buffer is visible to other parts of the cache, particularly `cache lookup`_, there is no
-need to push a partial filled aggregation buffer to disk. In effect any such data is effectively memory cached until
-enough additional cache content arrives to fill the buffer.
-
-The target fragment size has little effect on small objects because the fragment sized is used only to parcel out disk
-write operations. For larger objects the effect very significant as it causes those objects to be broken up in to
-fragments at different locations on in the volume. Each fragment write has its own entry in the volume directory which
-are computational chained (each cache key is computed from the previous one). If possible a fragment table is
-accumulated in the earliest ``Doc`` which has the offsets of the first byte for each fragment.
-
-Evacuation Mechanics
---------------------
-
-By default the write cursor will overwrite (de facto evict from cache) objects as it proceeds once it has gone around
-the cache stripe at least once. In some cases this is not acceptable and the object is *evacuated* by reading it from
-the cache and then writing it back to cache which moves the physical storage of the object from in front of the write
-cursor to behind the write cursor. Objects that are evacuated are handled in this way based on data in stripe data
-structures (attached to the :cpp:class:`Vol` instance).
-
-Evacuation data structures are defined by dividing up the volume content in to a disjoint and contiguous set of regions
-of ``EVACUATION_BUCKET_SIZE`` bytes. The :cpp:member:`Vol::evacuate` member is an array with an element for each
-evacuation region. Each element is a doubly linked list of :cpp:class:`EvacuationBlock` instances. Each instance
-contains a :cpp:class:`Dir` that specifies the fragment to evacuate. It is assumed that an evacuation block is placed in
-the evacuation bucket (array element) that corresponds to the evacuation region in which the fragment is located
-although no ordering per bucket is enforced in the linked list (this sorting is handled during evacuation). Objects are
-evacuated by specifying the first or earliest fragment in the evactuation block. The evactuation operation will then
-continue the evacuation for subsequent fragments in the object by adding those fragments in evacuation blocks. Note that
-the actual evacuation of those fragments is delayed until the write cursor reaches the fragments, it is not ncessarily
-done at the time the first / earliest fragment is evacuated.
-
-There are two types of evacuations, reader based and forced. The ``EvacuationBlock`` has a reader count to track this.
-If the reader count is zero, then it is a forced evacuation and the the target, if it exists, will be evacuated when the
-write cursor gets close. If the reader value is non-zero then it is a count of entities that are currently expecting to
-be able to read the object. Readers increment the count when they require read access to the object, or create the
-``EvacuationBlock`` with a count of 1. When a reader is finished with the object it decrements the count and removes the
-``EvacuationBlock`` if the count goes to zero. If the ``EvacuationBlock`` already exists with a count of zero, the count
-is not modified and the number of readers is not tracked, so the evacuation is valid as long as the object exists.
-
-Evacuation is driven by cache writes, essentially in :cpp:member:`Vol::aggWrite`. This method processes the pending
-cache virtual connections that are trying to write to the stripe. Some of these may be evacuation virtual connections.
-If so then the completion callback for that virtual connection is called as the data is put in to the aggregation
-buffer.
-
-When no more cache virtual connections can be processed (due to an empty queue or the aggregation buffer filling) then
-:cpp:member:`Vol::evac_range` is called to clear the range to be overwritten plus an additional
-:ts:const:`EVACUATION_SIZE` range. The buckets covering that range are checked. If there are any items in the buckets a
-new cache virtual connection (a "doc evacuator") is created and used to read the evacuation item closest to the write
-cursor (i.e. with the smallest offset in the stripe) instead of the aggregation write proceeding. When the read
-completes it is checked for validity and if valid, the cache virtual connection for it is placed at the front of the
-write queue for the stripe and the write aggregation resumed.
-
-Before doing a write, the method :cpp:func:`Vol::evac_range()` is called to start an evacuation. If any fragments are
-found in the buckets in the range the earliest such fragment (smallest offset, closest to the write cursor) is selected
-and read from disk and the aggregation buffer write is suspended. The read is done via a cache virtual connection which
-also effectively serves as the read buffer. Once the read is complete, that cache virtual connection instance (the "doc
-evacuator") is place at the front of the stripe write queue and written out in turn. Because the fragment data is now in
-memory it is acceptable to overwrite the disk image.
-
-Note that when normal stripe writing is resumed, this same check is done again, each time evauating (if needed) a
-fragment and queuing them for writing in turn.
-
-Updates to the directory are done when the write for the evacuated fragment completes. Multi-fragment objects are
-detected after the read completes for a fragment. If it is not the first fragment then the next fragment is marked for
-evacuation (which in turn, when it is read, will pull the subsequent fragment). The logic doesn't seem to check the
-length and presumes that the end of the alternate is when the next key is not in the directory.
-
-This interacts with the "one at a time" strategy of the aggregation write logic. If a fragment is close to the fragment being evacuated it may end up in the same evacuation bucket. Because the aggregation write checks every time for the "next" fragment to evacuate it will find that next fragment and evacuate it before it is overwritten.
-
-.. note
-
-   I do not understand the extra key list that is present in an evacuation block. It is labeled as needed for
-   "collisions" but I am unclear on what might be colliding. The bucket entries are stored and matched by stripe offset
-   but if two fragments collide on their offset, only one can be valid. Based on how :ref:`directory probing
-   <dir-probe>` works and the logic of :cpp:func:`evacuate_fragments()` it appears that rather than determine which
-   entry in a directory bucket is the correct one, all of them are marked for evacuation (thereby handling
-   "collisions"). However, each one could have a distinct fragment size and that is set for all of the reads by the
-   first fragment found in the directory. The intent seems to be to read all fragments that collide at the same starting
-   offset and then figure out which one was really on the disk after the read by looking through the key list. However,
-   this seems to presume those fragments will all be the same size, which seems unreasonable. I would think it would
-   also be necessary to update the size in the :cpp:class:`Dir` instance in the evacuation block to the be largest size
-   found among the collisions.
-
-Evacuation Operation
---------------------
-
-The primary source of fragments to be evacuated are active fragments. That is fragments which are currently open, to be read or written. This is tracked by the reader value in the evacuation blocks noted above.
-
-If object pinning is enabled then a scan is done on a regular basis as the write cursor moves to detected pinned objects and mark them for evacuation.
-
-Fragments can also be evacuated through *hit evacuation*. This is configured by :ts:cv:`proxy.config.cache.hit_evacuate_percent` and :ts:cv:`proxy.config.cache.hit_evacuate_size_limit`. When a fragment is read it is checked to see if it is close and in front of the write cursor, close being less than the specified percent of the size of the stripe. If set at the default value of 10, then if the fragment is withing 10% of the size of the stripe it is marked for evacuation. This is cleared if the write cursor passes through the fragment while it remains open (as all open objects are evacuated). If when the object is closed the fragment is still marked then it is placed in the appropriate evacuation bucket.
-
-Initialization
-==============
-
-Initialization starts with an instance of :cpp:class:`Store` reading the storage configuration file, by default
-:file:`storage.config`. For each valid element in the file an instance of :cpp:class:`Span` is created. These are of
-basically four types,
-
-* File
-* Directory
-* Disk
-* Raw device
-
-After setting all the `Span` instances they are grouped by device id to internal linked lists attached to the
-:cpp:member:`Store::disk` array [#]_. Spans that refer to the same directory, disk, or raw device are coalesced in to a
-single span. Spans that refer to the same file with overlapping offsets are also coalesced [#]_. This is all done in :c:func:`ink_cache_init()` called during startup.
-
-After configuration initialization the cache processor is started by calling :ccp:func:`CacheProcessor::start()`. This
-does a number of things.
-
-For each valid span, an instance of :cpp:class:`CacheDisk` is created. This class is a continuation and so can be used
-to perform potentially blocking operations on the span. This what is passed to the AIO threads to be called when an I/O
-operation completes. These are then dispatched to AIO threads to perform storage unit initialization. After all of those
-have completed, the resulting storage is distributed across the volumes in :c:func:`cplist_reconfigure`. The :cpp:class:`CacheVol` instances are created at this time.
-
-.. rubric:: Footnotes
-
-.. [#] `Work is under way <https://issues.apache.org/jira/browse/TS-2020>`_ on extending this to include objects that
-   are in the ram cache.
-
-.. [#] This linked list is mostly ignored in later processing, causing all but one file or directory storage units on
-   the same device to be ignored. See `TS-1869 <https://issues.apache.org/jira/browse/TS-1869>`_.
-
-.. [#] It is unclear to me how that can happen, as the offsets are computed later and should all be zero at the time the
-   spans are coalesced, and as far as I can tell the sort / coalesce is only done during initialization.
+.. 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.
+
+Cache Architecture
+******************
+
+.. include:: common.defs
+
+Introduction
+~~~~~~~~~~~~
+
+In addition to an HTTP proxy, |ATS| is also an HTTP cache. |TS| can cache any octet stream although it currently
+supports only those octet streams delivered by the HTTP protocol. When such a stream is cached (along with the HTTP
+protocol headers) it is termed an *object* in the cache. Each object is identified by a globally unique value called a
+*cache key*. By default this is generated by taking the `MD5 hash <http://www.openssl.org/docs/crypto/md5.html>`_ of the
+URI used to retrieve the content from the origin server.
+
+The purpose of this document is to describe the basic structure and implementation details of the |TS| cache.
+Configuration of the cache will be discussed only to the extent needed to understand the internal mechanisms. This
+document will be useful primarily to |TS| developers working on the |TS| codebase or plugins for |TS|. It is assumed the
+reader is already familiar with the :ref:`admin-guide` and specifically with :ref:`http-proxy-caching` and
+:ref:`configuring-the-cache` along with the associated configuration files and values.
+
+Unfortunately the internal terminology is not particularly consistent so this document will frequently use terms in
+different ways than they are used in the code in an attempt to create some consistency.
+
+Cache Layout
+~~~~~~~~~~~~
+
+The first step in understanding cache operations is to understand the data structures and layout of the cache.
+
+Cache storage
+=============
+
+The raw storage for the |TS| cache is configured in :file:`storage.config`. Each line in the file defines a :term:`cache span` which is treated as an undifferentiated unit of storage.
+
+.. figure:: images/cache-spans.png
+   :align: center
+
+   Two cache spans
+
+This storage organized in to a set of :term:`cache volume`\ s which are defined in :file:`volume.config`. Cache volumes
+can be defined by a percentage of the total storage or an absolute amount of storage. By default each cache volume is spread across all of the cache spans for robustness. The intersection of a cache volume and a cache span is a :term:`cache stripe`. Each cache span is divided in to cache stripes and each cache volume is a collection of those stripes.
+
+If the cache volumes for the example cache spans were defined as
+
+.. image:: images/ats-cache-volume-definition.png
+   :align: center
+
+then the actual layout would look like
+
+.. image:: images/cache-span-layout.png
+   :align: center
+
+A cached object is stored entirely in a single stripe, and therefore in a single cache span - objects are never split
+across cache volumes. Objects are assigned to a stripe (and hence to a cache volume) automatically based on a hash of
+the URI used to retrieve the object from the origin server. It is possible to configure this to a limited extent in
+:file:`hosting.config` which supports content from specific host or domain to be stored on specific volumes. In
+addition, as of version 4.0.1 it is possible to control which cache spans (and hence, which cache stripes) are contained
+in a specific cache volume.
+
+The layout and structure of the cache spans, the cache volumes, and the cache stripes that compose them are derived
+entirely from the :file:`storage.config` and :file:`cache.config` and is recomputed from scratch when the
+:process:`traffic_server` is started. Therefore any change to those files can (and almost always will) invalidate the
+existing cache in its entirety.
+
+Stripe Structure
+================
+
+|TS| treats the storage associated with a cache stripe as an undifferentiated span of bytes. Internally each stripe is
+treated almost entirely independently. The data structures described in this section are duplicated for each stripe.
+Internally the term "volume" is used for these stripes and implemented primarily in :cpp:class:`Vol`. What a user thinks
+of as a volume (what this document calls a "cache volume") is represented by :cpp:class:`CacheVol`.
+
+.. note::
+
+   Stripe assignment must be done before working with an object because the directory is local to the stripe. Any cached
+   objects for which the stripe assignment is changed are effectively lost as their directory data will not be found in
+   the new stripe.
+
+.. index:: cache directory
+.. _cache-directory:
+
+Cache Directory
+---------------
+
+.. index:: directory entry
+.. index:: fragment
+.. index:: cache ID
+
+.. _fragment:
+
+Content in a stripe is tracked via a directory. We call each element of the directory a "directory entry" and each is
+represented by :cpp:class:`Dir`. Each entry refers to a chunk of contiguous storage in the cache. These are referred to
+variously as "fragments", "segments", "docs" / "documents", and a few other things. This document will use the term
+"fragment" as that is the most common reference in the code. The term "Doc" (for :cpp:class:`Doc`) will be used to refer
+to the header data for a fragment. Overall the directory is treated as a hash with a "cache ID" as the key. A cache ID
+is a 128 bit (16 byte) value generated in various ways depending on context. This ID is reduced and used as an index in
+to the directory to locate an entry in the standard way.
+
+The directory is used as a memory resident structure which means a directory entry is as small as possible (currently 10
+bytes). This forces some compromises on the data that can be stored there. On the other hand this means that most cache
+misses do not require disk I/O which has a large performance benefit.
+
+An additional point is the directory is always fully sized. Once a stripe is initialized the directory size is
+fixed and never changed. This size is related (roughly linearly) to the size of the stripe. It is for this reason the
+memory footprint of |TS| depends strongly on the size of the disk cache. Because the directory size does not change,
+neither does this memory requirement so |TS| does not consume more memory as more content is stored in the cache. If
+there is enough memory to run |TS| with an empty cache there is enough to run it with a full cache.
+
+.. figure:: images/cache-directory-structure.png
+   :align: center
+
+Each entry stores an offset in the stripe and a size. The size stored in the directory entry is an :ref:`approximate
+size <dir-size>` which is at least as big as the actual data. Exact size data is stored in the fragment header on disk.
+
+.. note::
+
+   Data in HTTP headers cannot be examined without disk I/O. This includes the original URL for the object. The original
+   source of the cache ID is not stored anywhere.
+
+.. _dir-segment:
+.. _dir-bucket:
+
+The entries in a directory are grouped. The first level grouping is a *bucket*. This is a fixed number (currently 4 -
+defined as ``DIR_DEPTH``) of entries. The index generated from a cache ID is used as a bucket index (not an entry index).
+Buckets are grouped in to *segments*. All segments in a stripe have the same number of buckets. The number of segments
+in a stripe is chosen so that each segment has as many buckets as possible without exceeeding 65535 (2\ :sup:`16`\ -1)
+entries in a segment. Note that all segments in the same stripe will have the same number of buckets.
+
+.. figure:: images/dir-segment-bucket.png
+   :align: center
+
+Each entry has a previous and next index value which is used to link the entries in the same segment. The index size is
+16 bits which suffices to index any entry in the same segment. The stripe header contains an array of entry indices
+which are used as the roots of a free list. When a stripe is initialized the first entry in each bucket is zeroed
+(marked unused) and all other entries are put in the corresponding segment free list rooted in the stripe header. In
+essence the first element of each fixed bucket is used as a root for that bucket. The other entries in the fixed bucker
+are preferentially preferred for adding to that bucket but this is not required. The segment free lists are initialized
+such that the extra bucket entries are added in order - all the seconds, then the thirds, then the fourths. Because the
+free lists are FIFOs this means extra entries will be selected from the fourth entries across all the buckets first,
+then the thirds, etc. This maximizes locality for bucket searching.
+
+.. figure:: images/dir-bucket-assign.png
+   :align: center
+
+Entries are removed from the free list when used and returned when no longer in use. When a fragment needs to be put in
+to the directory the cache ID is used to locate a bucket (which also determines the segment). If the first entry in the
+bucket is marked unused, it is used. If not then the other entries in the bucket are searched and if any are on the free
+list, that entry is used. If none are available then the first entry on the segment free list is used. This entry is
+attached to the bucket via the same next and previous indices used for the free list so that it can be found when doing
+a lookup of a cache ID.
+
+Storage Layout
+--------------
+
+The storage layout is the stripe metadata followed by cached content. The metadata consists of three parts - the stripe
+header, the directory, and the stripe footer. The metadata is stored twice. The header and the footer are instances of
+:cpp:class:`VolHeaderFooter`. This is a stub structure which can have a trailing variable sized array. This array is
+used as the segment free list roots in the directory. Each contains the segment index of the first element of the free
+list for the segment. The footer is a copy of the header without the segment free lists. This makes the size of the
+header dependent on the directory but not that of the footer.
+
+.. figure:: images/cache-stripe-layout.png
+   :align: center
+
+Each stripe has several values that describe its basic layout.
+
+skip
+   The start of stripe data. This represents either space reserved at the start of a physical device to avoid problems
+   with the host operating system, or an offset representing use of space in the cache span by other stripes.
+
+start
+   The offset for the start of the content, after the stripe metadata.
+
+length
+   Total number of bytes in the stripe. :cpp:member:`Vol::len`.
+
+data length
+   Total number of blocks in the stripe available for content storage. :cpp:member:`Vol::data_blocks`.
+
+.. note:: Great care must be taken with sizes and lengths in the cache code because there are at least three different metrics (bytes, cache blocks, store blocks) used in various places.
+
+The total size of the directory (the number of entries) is computed by taking the size of the stripe and dividing by the
+average object size. The directory always consumes this amount of memory which has the effect that if cache size is
+increased so is the memory requirement for |TS|. The average object size defaults to 8000 bytes but can be configured
+using :ts:cv:`proxy.config.cache.min_average_object_size`. Increasing the average object size will reduce the memory
+footprint of the directory at the expense of reducing the number of distinct objects that can be stored in the cache
+[#]_.
+
+.. index: write cursor
+.. _write-cursor:
+
+The content area stores the actual objects and is used as a circular buffer where new objects overwrite the least
+recently cached objects. The location in a stripe where new cache data is written is called the *write cursor*. This
+means that objects can be de facto evicted from cache even if they have not expired if the data is overwritten by the
+write cursor. If an object is overwritten this is not detected at that time and the directory is not updated. Instead it
+will be noted if the object is accessed in the future and the disk read of the fragment fails.
+
+.. figure:: images/ats-cache-write-cursor.png
+   :align: center
+
+   The write cursor and documents in the cache.
+
+.. note:: Cache data on disk is never updated.
+
+This is a key thing to keep in mind. What appear to be updates (such as doing a refresh on stale content and getting
+back a 304) are actually new copies of data being written at the write cursor. The originals are left as "dead" space
+which will be consumed when the write cursor arrives at that disk location. Once the stripe directory is updated (in
+memory!) the original fragment in the cache is effectively destroyed. This is the general space management techinque
+used in other cases as well. If an object needs to removed from cache, only the directory needs to be changed. No other
+work (and *particularly* no disk I/O) needs to be done.
+
+Object Structure
+================
+
+Objects are stored as two types of data, metadata and content data. Metadata is all the data about the object and the
+content and includes the HTTP headers. The content data is the content of the object, the octet stream delivered to the
+client as the object.
+
+Objects are rooted in a :cpp:class:`Doc` structure stored in the cache. :cpp:class:`Doc` serves as the header data for a
+fragment and is contained at the start of every fragment. The first fragment for an object is termed the "first ``Doc``"
+and always contains the object metadata. Any operation on the object will read this fragment first. The fragment is
+located by converting the cache key for the object to a cache ID and then doing a lookup for a directory entry with that
+key. The directory entry has the offset and approximate size of the first fragment which is then read from the disk.
+This fragment will contain the request header and response along with overall object properties (such as content
+length).
+
+.. index:: alternate
+
+|TS| supports `varying content <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44>`_ for objects. These
+are called *alternates*. All metadata for all alternates is stored in the first fragment including the set of alternates
+and the HTTP headers for them. This enables `alternate selection
+<http://trafficserver.apache.org/docs/trunk/sdk/http-hooks-and-transactions/http-alternate-selection.en.html>`_ to be
+done after the first ``Doc`` is read from disk. An object that has more than one alternate will have the alternate
+content stored separately from the first fragment. For objects with only one alternate the content may or may not be in
+the same (first) fragment as the metadata. Each separate alternate content is allocated a directory entry and the key
+for that entry is stored in the first fragment metadata.
+
+Prior to version 4.0.1 the header data was stored in the :cpp:class:`CacheHTTPInfoVector` class which was marshaled to a
+variable length area of the on disk image, followed by information about additional fragments if needed to store the
+object.
+
+.. figure:: images/cache-doc-layout-3-2-0.png
+   :align: center
+
+   ``Doc`` layout 3.2.0
+
+This had the problem that with only one fragment table it could not be reliable for objects with more than one alternate
+[#]_. Therefore the fragment data was moved from being a separate variable length section of the metadata to being
+directly incorporated in to the :cpp:class:`CacheHTTPInfoVector`, yielding a layout of the following form.
+
+.. figure:: images/cache-doc-layout-4-0-1.png
+   :align: center
+
+   ``Doc`` layout 4.0.1
+
+Each element in the vector contains for each alternate, in addition to the HTTP headers and the fragment table (if any),
+a cache key. This cache key identifies a directory entry that is referred to as the "earliest ``Doc``". This is the
+location where the content for the alternate begins.
+
+When the object is first cached, it will have a single alternate and that will be stored (if not too large) in first
+``Doc``. This is termed a *resident alternate* in the code. This can only happen on the initial store of the object. If
+the metadata is updated (such as a ``304`` response to an ``If-Modified-Since`` request) then unless the object is
+small, the object data will be left in the original fragment and a new fragment written as the first fragment, making
+the alternate non-resident. "Small" is defined as a length smaller than :ts:cv:`proxy.config.cache.alt_rewrite_max_size`.
+
+.. note::
+
+   The :cpp:class:`CacheHTTPInfoVector` is stored only in the first ``Doc``. Subsequent ``Doc`` instances for the
+   object, including the earliest ``Doc``, should have an ``hlen`` of zero and if not, it is ignored.
+
+Large objects are split in to multiple fragments when written to the cache. This is indicated by a total document length
+that is longer than the content in first ``Doc`` or an earliest ``Doc``. In such a case a fragment offset table is
+stored. This contains the byte offset in the object content of the first byte of content data for each fragment past the
+first (as the offset for the first is always zero). This allows range requests to be serviced much more efficiently for
+large objects, as intermediate fragments that do not contain data in the range can be skipped. The last fragment in the
+sequence is detected by the fragment size and offset reaching the end of the total size of the object, there is no
+explicit end mark. Each fragment is computationally chained from the previous in that the cache key for fragment N is
+computed by::
+
+   key_for_N_plus_one = next_key(key_for_N);
+
+where ``next_key`` is a global function that deterministically computes a new cache key from an existing cache key.
+
+Objects with multiple fragments are laid out such that the data fragments (including the earliest ``Doc``) are written
+first and the first ``Doc`` is written last. When read from disk, both the first and earliest ``Doc`` are validated
+(tested to ensure that they haven't been overwritten by the write cursor) to verify that the entire document is present
+on disk (as they bookend the other fragments - the write cursor cannot overwrite them without overwriting at leastone of
+the verified ``Doc`` instances). Note that while the fragments of a single object are ordered they are not necessarily
+contiguous as data from different objects are interleaved as the data arrives in |TS|.
+
+.. figure:: images/cache-multi-fragment.png
+   :align: center
+
+   Multi-alternate and multi-fragment object storage
+
+.. index:: pinned
+
+Documents which are "pinned" into the cache must not be overwritten so they are "evacuated" from in front of the write
+cursor. Each fragment is read and rewritten. There is a special lookup mechanism for objects that are being evacuated so
+that they can be found in memory rather than the potentially unreliable disk regions. The cache scans ahead of the write
+cursor to discover pinned objects as there is a dead zone immediately before the write cursor from which data cannot be
+evacuated. Evacuated data is read from disk and placed in the write queue and written as its turn comes up.
+
+It appears that objects can only be pinned via the :file:`cache.config` file and if the
+:ts:cv:`proxy.config.cache.permit.pinning` is set to non-zero (it is zero by default). Objects which are in use when the
+write cursor is near use the same underlying evacuation mechanism but are handled automatically and not via the explicit
+``pinned`` bit in :cpp:class:`Dir`.
+
+.. [#] It could, under certain circumstances, be accurate for none of the alternates.
+
+Additional Notes
+====================
+
+Some general observations on the data structures.
+
+Cyclone buffer
+--------------
+
+Because the cache is a cyclone cache objects are not preserved for an indefinite time. Even if the object is not stale
+it can be overwritten as the cache cycles through its volume. Marking an object as ``pinned`` preserves the object
+through the passage of the write cursor but this is done by copying the object across the gap, in effect re-storing it
+in the cache. Pinning large objects or a large number objects can lead to a excessive disk activity. The original
+purpose of pinning seems to have been for small, frequently used objects explicitly marked by the administrator.
+
+This means the purpose of expiration data on objects is simply to prevent them from being served to clients. They are
+not in the standard sense deleted or cleaned up. The space can't be immediately reclaimed in any event because writing
+only happens at the write cursor. Deleting an object consists only of removing the directory entries in the volume
+directory which suffices to (eventually) free the space and render the document inaccessible.
+
+Historically the cache is designed this way because web content was relatively small and not particularly consistent.
+The design also provides high performance and low consistency requirements. There are no fragmentation issues for the
+storage, and both cache misses and object deletions require no disk I/O. It does not deal particularly well with long
+term storage of large objects. See the :ref:`volume tagging` appendix for details on some work in this area.
+
+Disk Failure
+------------
+
+The cache is designed to be relatively resistant to disk failures. Because each storage unit in each volume is mostly independent the loss of a disk simply means that the corresponding :cpp:class:`Vol` instances (one per cache volume that uses the storage unit) becomes unusable. The primary issue is updating the volume assignment table to both preserve assignments for objects on still operational volumes while distributing the assignments from the failed disk to those operational volumes. This mostly done in::
+
+   AIO_Callback_handler::handle_disk_failure
+
+Restoring a disk to active duty is quite a bit more difficult task. Changing the volume assignment of a cache key renders any currently cached data inaccessible. This is obviouly not a problem when a disk has failed, but is a bit trickier to decide which cached objects are to be de facto evicted if a new storage unit is added to a running system. The mechanism for this, if any, is still under investigation.
+
+Implementation Details
+======================
+
+Stripe Directory
+----------------
+
+.. _directory-entry:
+
+The in memory volume directory entries are defined as described below.
+
+.. cpp:class:: Dir
+
+   Defined in |P-CacheDir.h|_.
+
+   =========== =================== ===================================================
+   Name        Type                Use
+   =========== =================== ===================================================
+   offset      unsigned int:24     Offset of first byte of metadata (volume relative)
+   big         unsigned in:2       Size multiplier
+   size        unsigned int:6      Size
+   tag         unsigned int:12     Partial key (fast collision check)
+   phase       unsigned int:1      Unknown
+   head        unsigned int:1      Flag: first fragment in an object
+   pinned      unsigned int:1      Flag: document is pinned
+   token       unsigned int:1      Flag: Unknown
+   next        unsigned int:16     Segment local index of next entry.
+   offset_high inku16              High order offset bits
+   =========== =================== ===================================================
+
+   The stripe directory is an array of ``Dir`` instances. Each entry refers to a span in the volume which contains a cached object. Because every object in the cache has at least one directory entry this data has been made as small as possible.
+
+   The offset value is the starting byte of the object in the volume. It is 40 bits long split between the *offset* (lower 24 bits) and *offset_high* (upper 16 bits) members. Note that since there is a directory for every storage unit in a cache volume, this is the offset in to the slice of a storage unit attached to that volume.
+
+.. _dir-size:
+
+   The *size* and *big* values are used to calculate the approximate size of the span which contains the object. This value is used as the number of bytes to read from storage at the offset value. The exact size is contained in the object metadata in :cpp:class:`Doc` which is consulted once the read has completed. For this reason the approximate size needs to be at least as large as the actual size but can be larger, at the cost of reading the extraneous bytes.
+
+   The computation of the approximate size of the fragment is defined as::
+
+      ( *size* + 1 ) * 2 ^ ( ``CACHE_BLOCK_SHIFT`` + 3 * *big* )
+
+   where ``CACHE_BLOCK_SHIFT`` is the bit width of the size of a basic cache block (9, corresponding to a sector size of 512). Therefore the value with current defines is::
+
+      ( *size* + 1 ) * 2 ^ (9 + 3 * *big*)
+
+   Because *big* is 2 bits the values for the multiplier of *size* are
+
+   .. _big-mult:
+
+   ===== ===============   ========================
+   *big* Multiplier        Maximum Size
+   ===== ===============   ========================
+     0   512 (2^9)         32768 (2^15)
+     1   4096 (2^12)       262144 (2^18)
+     2   32768 (2^15)      2097152 (2^21)
+     3   262144 (2^18)     16777216 (2^24)
+   ===== ===============   ========================
+
+   Note also that *size* is effectively offset by one, so a value of 0 indicates a single unit of the multiplier.
+
+.. _target-fragment-size:
+
+The target fragment size can set with the :file:`records.config` value
+
+   ``proxy.config.cache.target_fragment_size``
+
+This value should be chosen so that it is a multiple of a :ref:`cache entry multiplier <big-mult>`. It is not necessary
+to make it a power of 2 [#]_. Larger fragments increase I/O efficiency but lead to more wasted space. The default size
+(1M, 2^20) is a reasonable choice in most circumstances altough in very specific cases there can be benefit from tuning
+this parameter. |TS| imposes an internal maximum of a 4194232 bytes which is 4M (2^22) less the size of a struct
+:cpp:class:`Doc`. In practice then the largest reasonable target fragment size is 4M - 262144 = 3932160.
+
+When a fragment is stored to disk the size data in the cache index entry is set to the finest granularity permitted by
+the size of the fragment. To determine this consult the :ref:`cache entry multipler <big-mult>` table, find the smallest
+maximum size that is at least as large as the fragment. That will indicate the value of *big* selected and therefore the
+granularity of the approximate size. That represents the largest possible amount of wasted disk I/O when the fragment is
+read from disk.
+
+.. note:: The cache index entry size is used only for reading the fragment from disk. The actual size on disk, and the
+amount of cache space consumed, is the actual size of the content rounded up to the disk sector size (default 512
+bytes).
+
+.. index:: DIR_DEPTH, index segment, index buckets
+
+The set of index entries for a volume are grouped in to *segments*. The number of segments for an index is selected so
+that there are as few segments as possible such that no segment has more than 2^16 entries. Intra-segment references can
+therefore use a 16 bit value to refer to any other entry in the segment.
+
+Index entries in a segment are grouped *buckets* each of ``DIR_DEPTH`` (currently 4) entries. These are handled in the
+standard hash table way, giving somewhat less than 2^14 buckets per segment.
+
+.. [#] The comment in :file:`records.config` is simply wrong.
+
+.. _dir-probe:
+
+Directory Probing
+-----------------
+
+Directory probing is locating a specific directory entry in the stripe directory based on a cache ID. This is handled
+primarily by the function :cpp:func:`dir_probe()`. This is passed the cache ID (:arg:`key`), a stripe (:arg:`d`), and a
+last collision (:arg:`last_collision`). The last of these is an in and out parameter, updated as useful during the
+probe.
+
+Given an ID, the top half (64 bits) is used as a :ref:`segment <dir-segment>` index, taken modulo the number of segments in
+the directory. The bottom half is used as a :ref:`bucket <dir-bucket>` index, taken modulo the number of buckets per
+segment. The :arg:`last_collision` value is used to mark the last matching entry returned by `dir_probe`.
+
+After computing the appropriate bucket, the entries in that bucket are searched to find a match. In this case a match is
+detected by comparison of the bottom 12 bits of the cache ID (the *cache tag*). The search starts at the base entry for
+the bucket and then proceeds via the linked list of entries from that first entry. If a tag match is found and there is
+no :arg:`collision` then that entry is returned and :arg:`last_collision` is updated to that entry. If :arg:`collision`
+is set, then if it isn't the current match the search continues down the linked list, otherwise :arg:`collision` is
+cleared and the search continues. The effect of this is that matches are skipped until the last returned match
+(:arg:`last_collision`) is found, after which the next match (if any) is returned. If the search falls off the end of
+the linked list then a miss result is returned (if no last collision), otherwise the probe is restarted after clearing
+the collision on the presumption that the entry for the collision has been removed from the bucket. This can lead to
+repeats among the returned values but guarantees that no valid entry will be skipped.
+
+Last collision can therefore be used to restart a probe at a later time. This is important because the match returned
+may not be the actual object - although the hashing of the cache ID to a bucket and the tag matching is unlikely to
+create false positives, that is possible. When a fragment is read the full cache ID is available and checked and if
+wrong, that read can be discarded and the next possible match from the directory found because the cache virtual
+connection tracks the last collision value.
+
+----------------
+Cache Operations
+----------------
+
+Cache activity starts after the HTTP request header has been parsed and remapped. Tunneled transactions do not interact with the cache because the headers are never parsed.
+
+To understand the logic we must introduce the term "cache valid" which means something that is directly related to an object that is valid to be put in the cache (e.g. a ``DELETE`` which refers to a URL that is cache valid but cannot be cached itself). This is important because |TS| computes cache validity several times during a transaction and only performs cache operations for cache valid results. The criteria used changes during the course of the transaction as well. This is done to avoid the cost of cache activity for objects that cannot be in the cache.
+
+The three basic cache operations are lookup, read, and write. We will take deleting entries as a special case of writing where only the volume directory is updated.
+
+After the client request header is parsed and is determined to be potentially cacheable, a `cache lookup`_ is done. If successful a `cache read`_ is attempted. If either the lookup or the read fails and the content is considered cacheable then a `cache write`_ is attempted.
+
+Cacheability
+============
+
+The first thing done with a request with respect to cache is to determine whether it is potentially a valid object for the cache. After initial parsing and remapping this check is done primarily to detect a negative result because if so all further cache processing is skipped -- it will not be put in to the cache nor will a cache lookup be done. There are a number of prerequisites along with configuration options to change them. Additional cacheability checks are done later in the process when more is known about the transaction (such as plugin operations and the origin server response). Those checks are described as appropriate in the sections on the relevant operations.
+
+The set of things which can affect cacheability are
+
+* Built in constraints
+* Settings in :file:`records.config`
+* Settings in :file:`cache.config`
+* Plugin operations
+
+The initial internal checks, along with their :file:`records.config` overrides[#]_, are done in::
+
+   HttpTransact::is_request_cache_lookupable
+
+The checks that are done are
+
+   Cacheable Method
+      The request must be one of ``GET``, ``HEAD``, ``POST``, ``DELETE``, ``PUT``.
+
+      See ``HttpTransact::is_method_cache_lookupable()``.
+
+   Dynamic URL
+      |TS| tries to avoid caching dynamic content because it's dynamic. A URL is considered dynamic if it
+
+      *  is not ``HTTP`` or ``HTTPS``
+      *  has query parameters
+      *  ends in ``asp``
+      *  has ``cgi`` in the path
+
+      This check can be disabled by setting a non-zero value for::
+
+         proxy.config.http.cache.cache_urls_that_look_dynamic
+
+      In addition if a TTL is set for rule that matches in :file:`cache.config` then this check is not done.
+
+   Range Request
+      Cache valid only if :ts:cv:`proxy.config.http.cache.range.lookup` in :file:`records.config` is non-zero. This does not mean the range request can be cached, only that it might be satisfiable from the cache.
+
+A plugin can call :c:func:`TSHttpTxnReqCacheableSet()` to force the request to be viewed as cache valid.
+
+.. [#] The code appears to check :file:`cache.config` in this logic by setting the ``does_config_permit_lookup`` in the ``cache_info.directives`` of the state machine instance but I can find no place where the value is used. The directive ``does_config_permit_storing`` is set and later checked so the directive (from the administrator point of view) is effective in preventing caching of 

<TRUNCATED>

[17/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/ConfigCmd.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ConfigCmd.h b/cmd/traffic_shell/ConfigCmd.h
new file mode 100644
index 0000000..42ed681
--- /dev/null
+++ b/cmd/traffic_shell/ConfigCmd.h
@@ -0,0 +1,865 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/****************************************************************
+ * Filename: ConfigCmd.h
+ * Purpose: This file contains the CLI's "config" command definitions.
+ *
+ *
+ ****************************************************************/
+
+#include "mgmtapi.h"
+#include <tcl.h>
+#include "createArgument.h"
+#include "definitions.h"
+
+#ifndef __CONFIG_CMD_H__
+#define __CONFIG_CMD_H__
+
+
+// enumerated type which captures all "config" commands
+typedef enum
+{
+  CMD_CONFIG_GET = 100,
+  CMD_CONFIG_SET,
+  CMD_CONFIG_SET_VALUE,
+  CMD_ENABLE_STATUS,
+  CMD_CONFIG_NAME,
+  CMD_CONFIG_RESTART_CLUSTER,
+  CMD_CONFIG_PORTS,
+  CMD_CONFIG_PORTS_HTTP_SERVER,
+  CMD_CONFIG_PORTS_CLUSTER,
+  CMD_CONFIG_PORTS_CLUSTER_RS,
+  CMD_CONFIG_PORTS_CLUSTER_MC,
+  CMD_CONFIG_PORTS_CONNECT,
+  CMD_CONFIG_PORTS_SOCKS_SERVER,
+  CMD_CONFIG_PORTS_ICP,
+  CMD_CONFIG_DATE,
+  CMD_CONFIG_TIME,
+  CMD_CONFIG_TIMEZONE,
+  CMD_CONFIG_TIMEZONE_LIST,
+  CMD_HALT,
+  CMD_REBOOT,
+  CMD_CONFIG_START,
+  CMD_CONFIG_STOP,
+  CMD_CONFIG_WRITE,
+  CMD_CONFIG_WRITE_IFC_HEAD,
+  CMD_CONFIG_WRITE_TS_VERSION,
+  CMD_CONFIG_WRITE_BUILD_DATE,
+  CMD_CONFIG_WRITE_PLATFORM,
+  CMD_CONFIG_WRITE_NODES,
+  CMD_CONFIG_WRITE_FEATURE,
+  CMD_CONFIG_WRITE_TAR,
+  CMD_CONFIG_WRITE_TAR_INFO,
+  CMD_CONFIG_WRITE_FILELIST,
+  CMD_CONFIG_WRITE_TAR_COMMON,
+  CMD_CONFIG_WRITE_BIN_DIR,
+  CMD_CONFIG_WRITE_BIN_GROUP,
+  CMD_CONFIG_WRITE_BIN_COMMON,
+  CMD_CONFIG_WRITE_LIB_DIR,
+  CMD_CONFIG_WRITE_LIB_GROUP,
+  CMD_CONFIG_WRITE_LIB_COMMON,
+  CMD_CONFIG_WRITE_CONFIG_DIR,
+  CMD_CONFIG_WRITE_CONFIG_GROUP,
+  CMD_CONFIG_WRITE_CONFIG_COMMON,
+  CMD_CONFIG_WRITE_COMMON_FILE,
+  CMD_CONFIG_READ,
+  CMD_CONFIG_READ_IFC_HEAD,
+  CMD_CONFIG_UPGRADE_READ_URL,
+  CMD_CONFIG_READ_FEATURE,
+  CMD_CONFIG_READ_TAR,
+  CMD_CONFIG_READ_TAR_INFO,
+  CMD_CONFIG_READ_TAR_COMMON,
+  CMD_CONFIG_READ_BIN_DIR,
+  CMD_CONFIG_READ_BIN_GROUP,
+  CMD_CONFIG_READ_BIN_COMMON,
+  CMD_CONFIG_READ_LIB_DIR,
+  CMD_CONFIG_READ_LIB_GROUP,
+  CMD_CONFIG_READ_LIB_COMMON,
+  CMD_CONFIG_READ_CONFIG_DIR,
+  CMD_CONFIG_READ_CONFIG_GROUP,
+  CMD_CONFIG_READ_CONFIG_COMMON,
+  CMD_CONFIG_READ_COMMON_FILE,
+  CMD_CONFIG_FILTER,
+  CMD_CONFIG_SECURITY,
+  CMD_CONFIG_SECURITY_IP,
+  CMD_CONFIG_SECURITY_PASSWORD,
+  CMD_CONFIG_PARENTS_STATUS,
+  CMD_CONFIG_PARENTS_CACHE,
+  CMD_CONFIG_PARENTS_CONFIG_FILE,
+  CMD_CONFIG_REMAP,
+  CMD_CONFIG_HTTP_STATUS,
+  CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_IN,
+  CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_OUT,
+  CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_IN,
+  CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_OUT,
+  CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_IN,
+  CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_OUT,
+  CMD_CONFIG_HTTP_REMOVE_FROM,
+  CMD_CONFIG_HTTP_REMOVE_REFERER,
+  CMD_CONFIG_HTTP_REMOVE_USER,
+  CMD_CONFIG_HTTP_REMOVE_COOKIE,
+  CMD_CONFIG_HTTP_REMOVE_HEADER,
+  CMD_CONFIG_HTTP_GLOBAL_USER_AGENT,
+  CMD_CONFIG_HTTP_INSERT_IP,
+  CMD_CONFIG_HTTP_REMOVE_IP,
+  CMD_CONFIG_HTTP_PROXY,
+  CMD_CONFIG_HTTP_FWD,
+  CMD_CONFIG_HTTP_REV,
+  CMD_CONFIG_HTTP_FWD_REV,
+  CMD_CONFIG_ICP,
+  CMD_CONFIG_ICP_MODE,
+  CMD_CONFIG_ICP_MODE_RECEIVE,
+  CMD_CONFIG_ICP_MODE_SENDRECEIVE,
+  CMD_CONFIG_ICP_MODE_DISABLED,
+  CMD_CONFIG_ICP_PORT,
+  CMD_CONFIG_ICP_MCAST,
+  CMD_CONFIG_ICP_QTIMEOUT,
+  CMD_CONFIG_ICP_PEERS,
+  CMD_CONFIG_PORT_TUNNELS_SERVER_OTHER_PORTS,
+  CMD_CONFIG_SCHEDULED_UPDATE_STATUS,
+  CMD_CONFIG_SCHEDULED_UPDATE_RETRY_COUNT,
+  CMD_CONFIG_SCHEDULED_UPDATE_RETRY_INTERVAL,
+  CMD_CONFIG_SCHEDULED_UPDATE_MAX_CONCURRENT,
+  CMD_CONFIG_SCHEDULED_UPDATE_FORCE_IMMEDIATE,
+  CMD_CONFIG_SCHEDULED_UPDATE_RULES,
+  CMD_CONFIG_SOCKS_STATUS,
+  CMD_CONFIG_SOCKS_VERSION,
+  CMD_CONFIG_SOCKS_DEFAULT_SERVERS,
+  CMD_CONFIG_SOCKS_ACCEPT,
+  CMD_CONFIG_SOCKS_ACCEPT_PORT,
+  CMD_CONFIG_CACHE,
+  CMD_CONFIG_CACHE_ON,
+  CMD_CONFIG_CACHE_OFF,
+  CMD_CONFIG_CACHE_HTTP,
+  CMD_CONFIG_CACHE_CLUSTER_BYPASS,
+  CMD_CONFIG_CACHE_IGNORE_BYPASS,
+  CMD_CONFIG_CACHE_MAX_OBJECT_SIZE,
+  CMD_CONFIG_CACHE_MAX_ALTERNATES,
+  CMD_CONFIG_CACHE_FILE,
+  CMD_CONFIG_CACHE_FRESHNESS,
+  CMD_CONFIG_CACHE_FRESHNESS_VERIFY,
+  CMD_CONFIG_CACHE_FRESHNESS_VERIFY_WHEN_EXPIRED,
+  CMD_CONFIG_CACHE_FRESHNESS_VERIFY_NO_DATE,
+  CMD_CONFIG_CACHE_FRESHNESS_VERIFY_ALWALYS,
+  CMD_CONFIG_CACHE_FRESHNESS_VERIFY_NEVER,
+  CMD_CONFIG_CACHE_FRESHNESS_MINIMUM,
+  CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_EXPLICIT,
+  CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_LAST_MODIFIED,
+  CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_NOTHING,
+  CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT,
+  CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_GREATER_THAN,
+  CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_LESS_THAN,
+  CMD_CONFIG_CACHE_DYNAMIC,
+  CMD_CONFIG_CACHE_ALTERNATES,
+  CMD_CONFIG_CACHE_VARY,
+  CMD_CONFIG_CACHE_VARY_TEXT,
+  CMD_CONFIG_CACHE_VARY_COOKIES_IMAGES,
+  CMD_CONFIG_CACHE_VARY_OTHER,
+  CMD_CONFIG_CACHE_COOKIES,
+  CMD_CONFIG_CACHE_COOKIES_NONE,
+  CMD_CONFIG_CACHE_COOKIES_ALL,
+  CMD_CONFIG_CACHE_COOKIES_NON_TEXT,
+  CMD_CONFIG_CACHE_COOKIES_NON_TEXT_EXT,
+  CMD_CONFIG_CACHE_CLEAR,
+  CMD_CONFIG_HOSTDB,
+  CMD_CONFIG_HOSTDB_LOOKUP_TIMEOUT,
+  CMD_CONFIG_HOSTDB_FOREGROUND_TIMEOUT,
+  CMD_CONFIG_HOSTDB_BACKGROUND_TIMEOUT,
+  CMD_CONFIG_HOSTDB_INVALID_HOST_TIMEOUT,
+  CMD_CONFIG_HOSTDB_RE_DNS_ON_RELOAD,
+  CMD_CONFIG_HOSTDB_CLEAR,
+  CMD_CONFIG_DNS,
+  CMD_CONFIG_DNS_RESOLVE_TIMEOUT,
+  CMD_CONFIG_DNS_RETRIES,
+  CMD_CONFIG_VIRTUALIP,
+  CMD_CONFIG_VIRTUALIP_STATUS,
+  CMD_CONFIG_VIRTUALIP_LIST,
+  CMD_CONFIG_VIRTUALIP_ADD,
+  CMD_CONFIG_VIRTUALIP_ADD_IP,
+  CMD_CONFIG_VIRTUALIP_ADD_DEVICE,
+  CMD_CONFIG_VIRTUALIP_ADD_SUBINTERFACE,
+  CMD_CONFIG_VIRTUALIP_DELETE,
+  CMD_CONFIG_LOGGING_ON,
+  CMD_CONFIG_LOGGING_OFF,
+  CMD_CONFIG_LOGGING_EVENT,
+  CMD_CONFIG_LOGGING_EVENT_ENABLED,
+  CMD_CONFIG_LOGGING_EVENT_TRANS_ONLY,
+  CMD_CONFIG_LOGGING_EVENT_ERROR_ONLY,
+  CMD_CONFIG_LOGGING_EVENT_DISABLED,
+  CMD_CONFIG_LOGGING_MGMT_DIRECTORY,
+  CMD_CONFIG_LOGGING_SPACE_LIMIT,
+  CMD_CONFIG_LOGGING_SPACE_HEADROOM,
+  CMD_CONFIG_LOGGING_COLLATION_STATUS,
+  CMD_CONFIG_LOGGING_COLLATION_STATUS_INACTIVE,
+  CMD_CONFIG_LOGGING_COLLATION_STATUS_HOST,
+  CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_STANDARD,
+  CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_CUSTOM,
+  CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_ALL,
+  CMD_CONFIG_LOGGING_COLLATION_HOST,
+  CMD_CONFIG_LOGGING_COLLATION,
+  CMD_CONFIG_LOGGING_COLLATION_SECRET,
+  CMD_CONFIG_LOGGING_COLLATION_TAGGED,
+  CMD_CONFIG_LOGGING_COLLATION_ORPHAN_LIMIT,
+  CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT,
+  CMD_CONFIG_LOGGING_FORMAT_SQUID,
+  CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_COMMON,
+  CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_EXT,
+  CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_EXT2,
+  CMD_CONFIG_LOGGING_TYPE,
+  CMD_CONFIG_LOGGING_TYPE_ASCII,
+  CMD_CONFIG_LOGGING_TYPE_BINARY,
+  CMD_CONFIG_LOGGING_FILE,
+  CMD_CONFIG_LOGGING_HEADER,
+  CMD_CONFIG_LOGGING_SPLITTING,
+  CMD_CONFIG_LOGGING_SPLITTING_ICP,
+  CMD_CONFIG_LOGGING_SPLITTING_HTTP,
+  CMD_CONFIG_LOGGING_CUSTOM,
+  CMD_CONFIG_LOGGING_ROLLING,
+  CMD_CONFIG_LOGGING_OFFSET,
+  CMD_CONFIG_LOGGING_INTERVAL,
+  CMD_CONFIG_LOGGING_AUTO_DELETE,
+  CMD_CONFIG_SSL,
+  CMD_CONFIG_SSL_STATUS,
+  CMD_CONFIG_SSL_PORT,
+  CMD_CONFIG_IP_ADDRESS,
+  CMD_CONFIG_HOSTNAME,
+  CMD_CONFIG_NETMASK,
+  CMD_CONFIG_DOMAIN,
+  CMD_CONFIG_DNS_IP,
+  CMD_CONFIG_DEFAULT_ROUTER,
+  CMD_CONFIG_NETWORK_INT,
+  CMD_CONFIG_NETWORK_STATUS,
+  CMD_CONFIG_NETWORK_START,
+  CMD_CONFIG_NETWORK_PROTOCOL,
+  CMD_CONFIG_GATEWAY,
+  CMD_CONFIG_ALARM_RESOLVE_NAME,
+  CMD_CONFIG_ALARM_RESOLVE_NUMBER,
+  CMD_CONFIG_ALARM_RESOLVE_ALL,
+  CMD_CONFIG_ALARM_NOTIFY
+} cliConfigCommand;
+
+typedef struct DateTime
+{
+  char str_hh[16];
+  char str_min[16];
+  char str_ss[16];
+  char str_dd[16];
+  char str_mm[16];
+  char str_yy[16];
+} DateTime;
+
+////////////////////////////////////////////////////////////////
+// ConfigCmd
+//
+// This is the callback function for the "config" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_Config(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// ConfigCmdArgs
+//
+// Register "config" command arguments with the Tcl interpreter.
+//
+int CmdArgs_Config();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigGet
+//
+// This is the callback function for the "config:get" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigGet(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigSet
+//
+// This is the callback function for the "config:set" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigSet(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigName
+//
+// This is the callback function for the "config:name" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigName(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigStart
+//
+// This is the callback function for the "config:start" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigStart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigStop
+//
+// This is the callback function for the "config:stop" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigStop(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+int Cmd_ConfigHardRestart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+int Cmd_ConfigRestart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int CmdArgs_ConfigRestart();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigParents
+//
+// This is the callback function for the "config:parents" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigParents(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigParents
+//
+// Register "config:parents" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigParents();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigRemap
+//
+// This is the callback function for the "config:remap" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigRemap(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigPorts
+//
+// This is the callback function for the "config:ports" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigPorts(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigPorts
+//
+// Register "config:ports" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigPorts();
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigPortTunnles
+//
+// Register "config:PortTunnles" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigPortTunnels();
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigScheduledUpdate
+//
+// This is the callback function for the "config:scheduled-update" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigScheduledUpdate(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigScheduled-Update
+//
+// Register "config:Scheduled-Update" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigScheduledUpdate();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigSocks
+//
+// This is the callback function for the "config:scheduled-update" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigSocks(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigSocks
+//
+// Register "config:socks" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigSocks();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigClock
+//
+// This is the callback function for the "config:clock" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigClock(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigClock
+//
+// Register "config:clock" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigClock();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigSecurity
+//
+// This is the callback function for the "config:security" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigSecurity(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigSecurity
+//
+// Register "config:security" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigSecurity();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigHttp
+//
+// This is the callback function for the "config:http" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigHttp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigHttp
+//
+// Register "config:http" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigHttp();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigIcp
+//
+// This is the callback function for the "config:icp" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigIcp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigIcp
+//
+// Register "config:Icp" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigIcp();
+
+////////////////////////////////////////////////////////////////
+//
+// Cmd_ConfigHostdb
+// This is the callback function for the "config:hostdb" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigCache
+//
+// This is the callback function for the "config:cache" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigCache(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigCache
+//
+// Register "config:cache" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigCache();
+
+
+int Cmd_ConfigHostdb(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigHostdb
+//
+// Register "config:hostdb" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigHostdb();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigDns
+//
+// This is the callback function for the "config:dns" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigDns(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigDns
+//
+// Register "config:dns" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigDns();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigVirtualip
+//
+// This is the callback function for the "config:virtualip" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigVirtualip(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigVirtualip
+//
+// Register "config:virtualip" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigVirtualip();
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigLogging
+//
+// This is the callback function for the "config:logging" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigLogging(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigLogging
+//
+// Register "config:logging" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigLogging();
+// Cmd_ConfigSsl
+//
+// This is the callback function for the "config:ssl" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigSsl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigSsl
+//
+// Register "config:ssl" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigSsl();
+
+////////////////////////////////////////////////////////////////
+// Functions to implement network settings
+//
+int IsValidHostname(char *str);
+int IsValidFQHostname(char *str);
+int IsValidDomainname(char *str);
+int IsValidIpAddress(char *str);
+#if defined(solaris)
+int getnetmask(char *mask);
+#endif
+char *pos_after_string(char const *haystack, char const *needle);
+int StartBinary(char *abs_bin_path, char *bin_options, int isScript);
+int getrouter(char *router, int len);
+int getnameserver(char *nameserver, int len);
+int setnameserver(char *nameserver);
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigAlarm
+//
+// This is the callback function for the "config:alarm" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigAlarm(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigAlarm
+//
+// Register "config:alarm" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigAlarm();
+
+////////////////////////////////////////////////////////////////
+// Cmd_Enable
+//
+// This is the callback function for the "enable" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_Enable(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigParents
+//
+// Register "config:parents" arguments with the Tcl interpreter.
+//
+int CmdArgs_Enable();
+
+int cliCheckIfEnabled(char *command);
+
+////////////////////////////////////////////////////////////////
+// Cmd_Disable
+//
+// This is the callback function for the "enable" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_Disable(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// Cmd_Help
+//
+// This is the callback function for the "help" command. It displays the
+// online help for the requested topic(s).
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_Help(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+
+////////////////////////////////////////////////////////////////
+//
+// "config" sub-command implementations
+//
+////////////////////////////////////////////////////////////////
+
+// config start sub-command
+int ConfigStart();
+
+// config stop sub-command
+int ConfigStop();
+
+// config get sub-command
+int ConfigGet(const char *rec_name);
+
+// config set sub-command
+int ConfigSet(const char *rec_name, const char *rec_value);
+
+// config name sub-command
+int ConfigName(const char *proxy_name);
+
+// config ports sub-command
+int ConfigPortsSet(int arg_ref, void *valuePtr);
+int ConfigPortsGet(int arg_ref);
+
+// config Date sub-command
+int ConfigDate(char *datestr);
+
+// config Time sub-command
+int ConfigTime(char *timestr);
+
+// config Timezone sub-command
+int ConfigTimezone(int, int);
+
+//config Timezone List
+int ConfigTimezoneList();
+
+// config security password sub-command
+int ConfigSecurityPasswd();
+
+// config remap sub-command
+int ConfigRemap(const char *url);
+
+// config http proxy sub-command
+int ConfigHttpProxy(int arg_ref, int setvar);
+
+// config icp mode sub-command
+int ConfigIcpMode(int arg_ref, int setvar);
+
+// config Cache Freshness Verify sub-command
+int ConfigCacheFreshnessVerify(int arg_ref, int setvar);
+
+// config Cache Freshness Minimum sub-command
+int ConfigCacheFreshnessMinimum(int arg_ref, int setvar);
+
+// config Cache FreshnessNoExpireLimit
+int ConfigCacheFreshnessNoExpireLimit(TSInt min, TSInt max, int setvar);
+
+// config Cache Vary sub-command
+int ConfigCacheVary(int arg_ref, char *field, int setvar);
+
+// config Cache Cookies sub-command
+int ConfigCacheCookies(int arg_ref, int setvar);
+
+// config Cache Clear sub-command
+int ConfigCacheClear();
+
+// config HostDB Clear sub-command
+int ConfigHostdbClear();
+
+//config virtualip list
+int ConfigVirtualIpList();
+
+//config virtualip add
+int ConfigVirtualipAdd(char *ip, char *device, int subinterface, int set_var);
+
+//config virtualip delete
+int ConfigVirtualipDelete(int ip_no, int set_var);
+
+// config Logging Event sub-command
+int ConfigLoggingEvent(int arg_ref, int setvar);
+
+// config Logging collation status sub-command
+int ConfigLoggingCollationStatus(int arg_ref, int setvar);
+
+// config Logging collation sub-command
+int ConfigLoggingCollation(TSString secret, int arg_ref, TSInt orphan, int setvar);
+
+// config Logging Format Type File sub-command
+int ConfigLoggingFormatTypeFile(int arg_ref_format, int arg_ref,
+                                int arg_ref_type, TSString file, TSString header, int setvar);
+
+// config Logging splitting sub-command
+int ConfigLoggingSplitting(int arg_ref_protocol, int arg_ref_on_off, int setvar);
+
+// config Logging Custom Format sub-command
+int ConfigLoggingCustomFormat(int arg_ref_on_off, int arg_ref_format, int setvar);
+
+// config Logging rolling offset interval autodelete sub-command
+int ConfigLoggingRollingOffsetIntervalAutodelete(int arg_ref_rolling, TSInt offset, TSInt num_hours,
+                                                 int arg_ref_auto_delete, int setvar);
+
+// config icp peers sub-command
+int ConfigIcpPeers(char *url);
+
+// config:alarm resolve-name
+int ConfigAlarmResolveName(char *name);
+
+// config:alarm resolve-number
+int ConfigAlarmResolveNumber(int number);
+
+// config:alarm resolve-all
+int ConfigAlarmResolveAll();
+
+// config:alarm notify
+int ConfigAlarmNotify(char *stringval);
+
+#endif // __CONFIG_CMD_H__

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/ConfigUpgradeCmd.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ConfigUpgradeCmd.cc b/cmd/traffic_shell/ConfigUpgradeCmd.cc
new file mode 100644
index 0000000..a16615e
--- /dev/null
+++ b/cmd/traffic_shell/ConfigUpgradeCmd.cc
@@ -0,0 +1,634 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/****************************************************************
+ * Filename: ConfigUpgradeCmd.cc
+ * Purpose: This file contains the CLI's "config:write/read/install/upgrade"
+   command implementation.
+ *
+ ****************************************************************/
+
+
+#include <ConfigCmd.h>
+#include <CliDisplay.h>
+#include <CliMgmtUtils.h>
+#include <CliDisplay.h>
+#include <CliMgmtUtils.h>
+#include <ConfigUpgradeCmd.h>
+#include <string.h>
+
+
+CIFCEntry::CIFCEntry(char *keyword, int counton, const char *string, ...)
+{
+
+  char Buffer[CONFIG_UPGRADE_BUF_SIZE];
+
+  KeyWord = new char[strlen(keyword) + 1];
+  sprintf(KeyWord, keyword);
+  CountOn = counton;
+
+  va_start(ap, string);
+  vsprintf(Buffer, string, ap);
+  va_end(ap);
+  Input = new char[strlen(Buffer) + 1];
+  sprintf(Input, Buffer);
+
+  Version = NULL;
+  FileName = NULL;
+
+}
+
+CIFCEntry::~CIFCEntry()
+{
+
+  if (Version != NULL)
+    delete[]Version;
+  if (FileName != NULL)
+    delete[]FileName;
+  if (KeyWord != NULL)
+    delete[]KeyWord;
+  if (Input != NULL)
+    delete[]Input;
+
+}
+
+// check IFCVERSION IFCPATH and IFCFILENAME setup
+INKError
+CIFCEntry::ConfigWriteCheckIFCEnv()
+{
+
+  char *pathPtr;
+  char *filenamePtr;
+  char *versionPtr;
+
+
+  pathPtr = getenv("IFCPATH");
+  filenamePtr = getenv("IFCFILENAME");
+  versionPtr = getenv("IFCVERSION");
+
+  if (pathPtr == NULL || filenamePtr == NULL || versionPtr == NULL ||
+      strlen(pathPtr) == 0 || strlen(filenamePtr) == 0 || strlen(versionPtr) == 0) {
+    return INK_ERR_READ_FILE;
+  }
+
+  FileName = new char[strlen(pathPtr) + strlen(filenamePtr) + 1];
+  sprintf(FileName, "%s%s", pathPtr, filenamePtr);
+
+  Version = new char[strlen(versionPtr) + 1];
+  sprintf(Version, "%s", versionPtr);
+
+  return INK_ERR_OKAY;
+}
+
+INKError
+CIFCEntry::Cli_NewIFCFile()
+{
+
+  FILE *Fptr;
+
+  Fptr = fopen(FileName, "r+");
+  if (Fptr != NULL) {
+    fclose(Fptr);
+    return INK_ERR_OKAY;
+  } else {                      /* need to create new file */
+    Fptr = fopen(FileName, "w");
+    if (Fptr == NULL) {
+      Cli_Error("Error in creating new IFC file\n");
+      return INK_ERR_WRITE_FILE;
+    }
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#IFCHEAD FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<TRAFFIC SERVER VERSION>\n");
+    fprintf(Fptr, "#<BUILD DATE>\n");
+    fprintf(Fptr, "#<PLATFORM>\n");
+    fprintf(Fptr, "#<NUMBER OF NODES>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "IfcHead\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#FEATURE FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<FEATURE STRING LIST>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "Feature\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#TAR FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<NUMBER OF TAR FILES>\n");
+    fprintf(Fptr, "#<LIST OF TAR FILES>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "Tar\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#COMMONTAR FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<NUMBER OF TAR FILES>\n");
+    fprintf(Fptr, "#<LIST OF TAR FILES>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "CommonTar\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#TAR INFO FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<TAR FILE NAME>:<LIST OF FILES>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "TarInfo\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#BIN GROUP FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<NUMBER OF FILES>\n");
+    fprintf(Fptr, "#<LIST OF FILES>\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "BinGroup\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#BIN DIR FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of SubDirectories>\n");
+    fprintf(Fptr, "#<SubDirectory>:<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "BinDir\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#BIN COMMON FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of Files>\n");
+    fprintf(Fptr, "#<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "BinCommon\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#LIB GROUP FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of Files>\n");
+    fprintf(Fptr, "#<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "LibGroup\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#LIB DIR FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of SubDirectories>\n");
+    fprintf(Fptr, "#<SubDirectory>:<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "LibDir\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#LIB COMMON FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of Files>\n");
+    fprintf(Fptr, "#<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "LibCommon\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#CONFIG GROUP FORMAT>\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of Files>\n");
+    fprintf(Fptr, "#<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "ConfigGroup\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#CONFIG DIR FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of SubDirectories>\n");
+    fprintf(Fptr, "#<SubDirectory>:<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "ConfigDir\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#CONFIG COMMON FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of Files>\n");
+    fprintf(Fptr, "#<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "ConfigCommon\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fprintf(Fptr, "############################\n");
+    fprintf(Fptr, "#COMMON FORMAT\n");
+    fprintf(Fptr, "#\n");
+    fprintf(Fptr, "#<Number of Files>\n");
+    fprintf(Fptr, "#<List of Files>\n");
+    fprintf(Fptr, "\n");
+    fprintf(Fptr, "CommonFile\n");
+    fprintf(Fptr, "0\n");
+    fprintf(Fptr, "\n");
+
+    fclose(Fptr);
+    return INK_ERR_OKAY;
+  }
+
+}
+
+
+int
+CIFCEntry::ConfigWriteIFC()
+{
+
+  FILE *Fptr;
+  char *filebuffer, *in_buffer;
+  char *p1;
+  char OldCountString[CONFIG_UPGRADE_INT_STRING_SIZE];
+  int Count = -1;
+  long size, amount_read, addsize;
+
+  if (ConfigWriteCheckIFCEnv() == INK_ERR_READ_FILE) {
+    Cli_Error("Set $IFCVERSION, $IFCPATH and $IFCFILENAME First\n");
+    return CLI_ERROR;
+  }
+  if (Cli_NewIFCFile() == INK_ERR_WRITE_FILE) {
+    return CLI_ERROR;
+  }
+  if ((Fptr = fopen(FileName, "r")) == NULL) {
+    Cli_Error("ERROR Open IFC File to read\n");
+    return CLI_ERROR;
+  }
+
+  fseek(Fptr, 0, SEEK_END);
+  size = ftell(Fptr);
+  if (size <= 0) {
+    fclose(Fptr);
+    Cli_Error("Error Reading IFC File\n");
+    return CLI_ERROR;
+  }
+
+  filebuffer = new char[size + 1];
+  fseek(Fptr, 0, SEEK_SET);
+  amount_read = fread((void *) filebuffer, sizeof(char), size, Fptr);
+  fclose(Fptr);
+  filebuffer[size] = '\0';
+
+  if (size * (int) sizeof(char) != amount_read) {
+    Cli_Error("Error Reading IFC File\n");
+    delete[]filebuffer;
+    return CLI_ERROR;
+  }
+  // look for KeyWord
+  if ((p1 = strstr(filebuffer, KeyWord)) == NULL) {
+    delete[]filebuffer;
+    Cli_Error("Error Finding Keyword\n");
+    return CLI_ERROR;
+  }
+
+  p1 += strlen(KeyWord);
+  p1++;
+
+  // writeback
+  Fptr = fopen(FileName, "r+");
+  fseek(Fptr, p1 - filebuffer, SEEK_SET);
+
+  switch (CountOn) {
+  case 1:
+
+    // coverity[secure_coding]
+    sscanf(p1, "%d\n", &Count);
+    sprintf(OldCountString, "%d", Count);
+    p1 += (strlen(OldCountString) + 1);
+    Count++;
+    addsize = strlen(Input) + CONFIG_UPGRADE_INT_STRING_SIZE + 2;
+    in_buffer = new char[addsize + 1];
+    sprintf(in_buffer, "%d\n%s\n", Count, Input);
+    in_buffer[addsize] = '\0';
+    fwrite(in_buffer, sizeof(char), strlen(in_buffer), Fptr);
+    delete[]in_buffer;
+    break;
+
+  case 0:
+
+    fwrite(Input, sizeof(char), strlen(Input), Fptr);
+    fwrite("\n", sizeof(char), strlen("\n"), Fptr);
+    break;
+
+  default:
+
+    Cli_Error("Unexpected Value of CountOn\n");
+    fclose(Fptr);
+    delete[]filebuffer;
+    return CLI_ERROR;
+  }
+
+  fwrite(p1, sizeof(char), size - (p1 - filebuffer), Fptr);
+  fclose(Fptr);
+  delete[]filebuffer;
+  return CLI_OK;
+
+}
+
+//config read subcommand
+int
+CIFCEntry::ConfigReadIFC()
+{
+
+  FILE *Fptr;
+  char *filebuffer;
+  long size, amount_read;
+  INKError CLI_CHECK;
+
+  if (ConfigWriteCheckIFCEnv() == INK_ERR_READ_FILE) {
+    Cli_Error("Set $IFCVERSION, $IFCPATH and $IFCFILENAME First\n");
+    return CLI_ERROR;
+  }
+
+  if ((Fptr = fopen(FileName, "r")) == NULL) {
+    Cli_Printf("ERROR Opening IFC file for read\n");
+    return CLI_ERROR;
+  }
+
+  fseek(Fptr, 0, SEEK_END);
+  size = ftell(Fptr);
+  if (size <= 0) {
+    Cli_Error("Error Empty IFC FILE\n", FileName);
+    fclose(Fptr);
+    return CLI_ERROR;
+  }
+
+  filebuffer = new char[size + 1];
+  fseek(Fptr, 0, SEEK_SET);
+  amount_read = fread((void *) filebuffer, (int) sizeof(char), size, Fptr);
+
+  if (size * (int) sizeof(char) != amount_read) {
+    Cli_Error("Error Reading IFC File\n");
+    delete[]filebuffer;
+    return CLI_ERROR;
+  }
+
+  filebuffer[amount_read] = '\0';
+  fclose(Fptr);
+
+  printf("%s\n", filebuffer);
+  delete[]filebuffer;
+  return CLI_OK;
+}
+
+void
+CIFCEntry::PrintEle()
+{
+  printf("%s:%d:%s\n", KeyWord, CountOn, Input);
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigWrite
+//
+// This is the callback function for the "config:write" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigWrite(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[])
+{
+  CIFCEntry *EntryPtr;
+  int CLI_RETURN;
+
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:write") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable, *infoPtr;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+  infoPtr = argtable;
+  Cli_Debug("Cmd_ConfigWrite argc %d\n", argc);
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_WRITE_IFC_HEAD:
+      EntryPtr = new CIFCEntry("IfcHead", 0, "%s\n%s\n%s\n%d", argtable[1].arg_string, argtable[2].arg_string,
+                               argtable[3].arg_string, argtable[4].arg_int);
+      break;
+    case CMD_CONFIG_WRITE_FEATURE:
+      EntryPtr = new CIFCEntry("Feature", 0, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_TAR:
+      EntryPtr = new CIFCEntry("Tar", 1, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_TAR_INFO:
+      EntryPtr = new CIFCEntry("TarInfo", 0, "%s:%s", argtable[0].arg_string, argtable[1].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_TAR_COMMON:
+      EntryPtr = new CIFCEntry("CommonTar", 1, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_BIN_DIR:
+      EntryPtr = new CIFCEntry("BinDir", 1, "%s:%s", argtable[0].arg_string, argtable[1].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_BIN_GROUP:
+      EntryPtr = new CIFCEntry("BinGroup", 1, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_BIN_COMMON:
+      EntryPtr = new CIFCEntry("BinCommon", 1, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_LIB_DIR:
+      EntryPtr = new CIFCEntry("LibDir", 1, "%s:%s", argtable[0].arg_string, argtable[1].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_LIB_GROUP:
+      EntryPtr = new CIFCEntry("LibGroup", 1, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_LIB_COMMON:
+      EntryPtr = new CIFCEntry("LibCommon", 1, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_CONFIG_DIR:
+      EntryPtr = new CIFCEntry("ConfigDir", 1, "%s:%s", argtable[0].arg_string, argtable[1].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_CONFIG_GROUP:
+      EntryPtr = new CIFCEntry("ConfigGroup", 1, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_CONFIG_COMMON:
+      EntryPtr = new CIFCEntry("ConfigCommon", 1, argtable[0].arg_string);
+      break;
+    case CMD_CONFIG_WRITE_COMMON_FILE:
+      EntryPtr = new CIFCEntry("CommonFile", 1, argtable[0].arg_string);
+    }
+
+    if (EntryPtr == NULL) {
+      Cli_Error("Error Allocate Memory\n");
+      return CLI_ERROR;
+    } else {
+      CLI_RETURN = EntryPtr->ConfigWriteIFC();
+      delete EntryPtr;
+      return CLI_RETURN;
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigWrite
+//
+// Register "config:write" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigWrite()
+{
+
+  createArgument("ifc-head", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_WRITE_IFC_HEAD, "Specify the head information of ifc file", (char *) NULL);
+  createArgument("ts-version", CMD_CONFIG_WRITE_IFC_HEAD, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_TS_VERSION, "Specify the version of Traffic Server installed",
+                 (char *) NULL);
+  createArgument("build-date", CMD_CONFIG_WRITE_TS_VERSION, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_BUILD_DATE, "Specify date of the Traffic Server Build", (char *) NULL);
+  createArgument("platform", CMD_CONFIG_WRITE_BUILD_DATE, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_PLATFORM, "Specify the platform of installation", (char *) NULL);
+  createArgument("nodes", CMD_CONFIG_WRITE_PLATFORM, CLI_ARGV_INT,
+                 (char *) NULL, CMD_CONFIG_WRITE_NODES, "Specify the number of node in the cluster", (char *) NULL);
+  createArgument("feature", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_FEATURE, "Specify the feature string", (char *) NULL);
+  createArgument("tar", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_TAR, "Specify the tar file list", (char *) NULL);
+  createArgument("tar-common", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_TAR_COMMON, "Specify the MUST-HAVE tar files", (char *) NULL);
+  createArgument("tar-info", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_TAR_INFO, "Specify the file contained in this named tar file",
+                 (char *) NULL);
+  createArgument("filelist", CLI_ARGV_NO_POS, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_FILELIST, "Specify the filelist contained in this named tar file",
+                 (char *) NULL);
+  createArgument("bin-dir", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_BIN_DIR,
+                 "Specify the subdirectories and the files in each of them in bin directory", (char *) NULL);
+  createArgument("bin-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_BIN_GROUP,
+                 "Specify the file listed in the bin directory", (char *) NULL);
+  createArgument("bin-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_BIN_COMMON,
+                 "Specify the MUST-HAVE bin files", (char *) NULL);
+  createArgument("lib-dir", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_DIR,
+                 "Specify the subdirectories and the files in each of them in lib directory", (char *) NULL);
+  createArgument("lib-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_GROUP,
+                 "Specify the file listed in the lib directory", (char *) NULL);
+  createArgument("lib-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_COMMON,
+                 "Specify the MUST-HAVE lib files", (char *) NULL);
+  createArgument("config-dir", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_DIR,
+                 "Specify the subdirectories and the files in each of them in the config directory", (char *) NULL);
+  createArgument("config-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_GROUP,
+                 "Specify the file listed in the config directory", (char *) NULL);
+  createArgument("config-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_COMMON,
+                 "Specify the MUST-HAVE config files", (char *) NULL);
+  createArgument("common-file", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_COMMON_FILE,
+                 "Specify the MUST-HAVE files", (char *) NULL);
+
+  return CLI_OK;
+}
+
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigRead
+//
+// This is the callback function for the "config:read" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigRead(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[])
+{
+
+  CIFCEntry *EntryPtr;
+  int CLI_RETURN;
+
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:read") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable, *infoPtr;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+  infoPtr = argtable;
+  Cli_Debug("Cmd_ConfigRead argc %d\n", argc);
+
+  if (argtable->parsed_args == CLI_PARSED_ARGV_END) {
+    EntryPtr = new CIFCEntry("", 0, "");
+    if (EntryPtr == NULL) {
+      Cli_Error("Error Allocate Memory\n");
+      return CLI_ERROR;
+    } else {
+      CLI_RETURN = EntryPtr->ConfigReadIFC();
+      delete EntryPtr;
+      return CLI_RETURN;
+    }
+  }
+
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/ConfigUpgradeCmd.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ConfigUpgradeCmd.h b/cmd/traffic_shell/ConfigUpgradeCmd.h
new file mode 100644
index 0000000..d75472d
--- /dev/null
+++ b/cmd/traffic_shell/ConfigUpgradeCmd.h
@@ -0,0 +1,252 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/************C****************************************************
+ * Filename: ConfigUpgradeCmd.h
+ * Purpose: This file contains the CLI's "config:" command definitions.
+ ****************************************************************/
+
+
+
+#include <tcl.h>
+#include <stdlib.h>
+#include <createArgument.h>
+#include <definitions.h>
+
+
+
+#ifndef __CONFIG_UPGRADE_CMD_H__
+#define __CONFIG_UPGRADE_CMD_H__
+
+
+#define CONFIG_UPGRADE_INT_STRING_SIZE 5
+#define CONFIG_UPGRADE_STRING_SIZE 256
+#define CONFIG_UPGRADE_BUF_SIZE 10240
+
+
+#define IFC_BEGIN         "Begin"
+#define IFC_HEAD          "IfcHead"
+#define IFC_FEATURE       "Feature"
+#define IFC_TAR           "Tar"
+#define IFC_COMMON_TAR    "CommonTar"
+#define IFC_TAR_INFO      "TarInfo"
+#define IFC_BIN_GROUP     "BinGroup"
+#define IFC_BIN_DIR       "BinDir"
+#define IFC_BIN_COMMON    "BinCommon"
+#define IFC_LIB_GROUP     "LibGroup"
+#define IFC_LIB_DIR       "LibDir"
+#define IFC_LIB_COMMON    "LibCommon"
+#define IFC_CONFIG_GROUP  "ConfigGroup"
+#define IFC_CONFIG_DIR    "ConfigDir"
+#define IFC_CONFIG_COMMON "ConfigCommon"
+#define IFC_COMMON_FILE   "CommonFile"
+#define IFC_END           "End"
+#define IFC_LIST_BEGIN    "{"
+#define IFC_LIST_END      "}"
+
+typedef enum
+{
+  IFC_KEY_IFCHEAD = 10,
+  IFC_KEY_FEATURE,
+  IFC_KEY_TAR,
+  IFC_KEY_COMMON_TAR,
+  IFC_KEY_TAR_INFO,
+  IFC_KEY_BIN_GROUP,
+  IFC_KEY_BIN_DIR,
+  IFC_KEY_BIN_COMMON,
+  IFC_KEY_LIB_GROUP,
+  IFC_KEY_LIB_DIR,
+  IFC_KEY_LIB_COMMON,
+  IFC_KEY_CONFIG_GROUP,
+  IFC_KEY_CONFIG_DIR,
+  IFC_KEY_CONFIG_COMMON,
+  IFC_KEY_COMMON_FILE,
+  IFC_KEY_END
+} IfcKeyWord;
+
+class CIFCWriteEntry
+{
+
+  char FileName[CONFIG_UPGRADE_STRING_SIZE];
+  char Version[CONFIG_UPGRADE_STRING_SIZE];
+  char KeyWord[CONFIG_UPGRADE_STRING_SIZE];
+  char Input[CONFIG_UPGRADE_BUF_SIZE];
+  int CountOn;
+
+  // write IFC file
+  int ConfigWriteIFCEle();
+
+public:
+
+    CIFCWriteEntry();
+   ~CIFCWriteEntry();
+
+  // PrintOut the Element of this Entry
+  void PrintEle();
+
+  TSError Cli_NewIFCFile();
+
+  static TSError ConfigWriteCheckIFCEnv();
+
+  int ConfigWriteIFCHead(char *ts_version, char *build_date, char *platform, int nodes);
+
+  int ConfigWriteIFCFeature(char *input);
+
+  int ConfigWriteIFCTar(char *input);
+
+  int ConfigWriteIFCCommonTar(char *input);
+
+  int ConfigWriteIFCTarInfo(char *tar, char *filelist);
+
+  int ConfigWriteIFCBinCommon(char *input);
+
+  int ConfigWriteIFCBinGroup(char *input);
+
+  int ConfigWriteIFCBinDir(char *subdir, char *filelist);
+
+  int ConfigWriteIFCLibCommon(char *input);
+
+  int ConfigWriteIFCLibGroup(char *input);
+
+  int ConfigWriteIFCLibDir(char *subdir, char *filelist);
+
+  int ConfigWriteIFCConfigCommon(char *input);
+
+  int ConfigWriteIFCConfigGroup(char *input);
+
+  int ConfigWriteIFCConfigDir(char *subdir, char *filelist);
+
+  int ConfigWriteIFCCommonFile(char *input);
+
+};
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigWrite
+//
+// This is the callback function for the "config:write" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigWrite(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigWrite
+//
+// Register "config:write" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigWrite();
+
+
+class CIFCReadEntry
+{
+
+  char FileName[CONFIG_UPGRADE_STRING_SIZE];
+  char Version[CONFIG_UPGRADE_STRING_SIZE];
+  char KeyWord[CONFIG_UPGRADE_STRING_SIZE];
+  char Output[CONFIG_UPGRADE_BUF_SIZE];
+  int CountOn;
+  int Count;
+
+  // read IFC file
+  int ConfigReadIFCEle();
+
+  int ConfigReadPrintIFCEle();
+
+public:
+
+    CIFCReadEntry();
+   ~CIFCReadEntry();
+
+  static TSError ConfigReadCheckIFCEnv();
+
+  int ConfigReadIFCHead();
+
+  int ConfigReadIFCFeature();
+
+  int ConfigReadIFCTar();
+
+  int ConfigReadIFCCommonTar();
+
+  int ConfigReadIFCTarInfo();
+
+  int ConfigReadIFCBinCommon();
+
+  int ConfigReadIFCBinGroup();
+
+  int ConfigReadIFCBinDir();
+
+  int ConfigReadIFCLibCommon();
+
+  int ConfigReadIFCLibGroup();
+
+  int ConfigReadIFCLibDir();
+
+  int ConfigReadIFCConfigCommon();
+
+  int ConfigReadIFCConfigGroup();
+
+  int ConfigReadIFCConfigDir();
+
+  int ConfigReadIFCCommonFile();
+
+};
+
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigRead
+//
+// This is the callback function for the "config:read" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int Cmd_ConfigRead(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigRead
+//
+// Register "config:read" arguments with the Tcl interpreter.
+//
+int CmdArgs_ConfigRead();
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigSaveUrl
+//
+// Register "config:save-url" arguments with the Tcl interpreter.
+//
+
+int Cmd_ConfigSaveUrl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+int CmdArgs_ConfigSaveUrl();
+
+
+#endif /* __CONFIG_UPGRADE_CMD_H__ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/ConfigUpgradeReadCmd.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ConfigUpgradeReadCmd.cc b/cmd/traffic_shell/ConfigUpgradeReadCmd.cc
new file mode 100644
index 0000000..e5d922f
--- /dev/null
+++ b/cmd/traffic_shell/ConfigUpgradeReadCmd.cc
@@ -0,0 +1,498 @@
+/** @file
+
+  This file contains the CLI's "config:read" command implementation
+
+  @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 "libts.h"
+#include <ConfigCmd.h>
+#include <CliDisplay.h>
+#include <CliMgmtUtils.h>
+#include <ConfigUpgradeCmd.h>
+#include <string.h>
+#include <mgmtapi.h>
+
+
+extern Tcl_Interp *interp;
+CIFCReadEntry::CIFCReadEntry():
+CountOn(0), Count(0)
+{
+  KeyWord[0] = 0;
+  Output[0] = 0;
+  const char *pathPtr = getenv("IFCPATH");
+  const char *filenamePtr = getenv("IFCFILENAME");
+  const char *versionPtr = getenv("IFCVERSION");
+
+  snprintf(FileName, sizeof(FileName), "%s%s", pathPtr, filenamePtr);
+  snprintf(Version, sizeof(Version), "%s", versionPtr);
+}
+
+CIFCReadEntry::~CIFCReadEntry()
+{
+}
+
+// check IFCVERSION IFCPATH and IFCFILENAME setup
+TSError
+CIFCReadEntry::ConfigReadCheckIFCEnv()
+{
+  char *pathPtr;
+  char *filenamePtr;
+  char *versionPtr;
+
+  pathPtr = getenv("IFCPATH");
+  filenamePtr = getenv("IFCFILENAME");
+  versionPtr = getenv("IFCVERSION");
+
+  if (pathPtr == NULL || filenamePtr == NULL || versionPtr == NULL ||
+      strlen(pathPtr) == 0 || strlen(filenamePtr) == 0 || strlen(versionPtr) == 0) {
+    return TS_ERR_READ_FILE;
+  }
+
+  return TS_ERR_OKAY;
+}
+
+
+int
+CIFCReadEntry::ConfigReadPrintIFCEle()
+{
+  Tcl_AppendResult(interp, Output, (char *) NULL);
+  return CLI_OK;
+}
+
+int
+CIFCReadEntry::ConfigReadIFCEle()
+{
+  FILE *Fptr;
+  char *filebuffer;
+  char *p1, *p2;
+  char CountString[CONFIG_UPGRADE_INT_STRING_SIZE];
+  long size, amount_read;
+
+  if ((Fptr = fopen(FileName, "r")) == NULL) {
+    Cli_Error("ERROR Open IFC File to read\n");
+    return CLI_ERROR;
+  }
+
+  fseek(Fptr, 0, SEEK_END);
+  size = ftell(Fptr);
+  if (size <= 0) {
+    fclose(Fptr);
+    Cli_Error("Error Reading IFC File\n");
+    return CLI_ERROR;
+  }
+
+  filebuffer = new char[size + 1];
+  fseek(Fptr, 0, SEEK_SET);
+  amount_read = fread((void *) filebuffer, sizeof(char), size, Fptr);
+  fclose(Fptr);
+  Fptr = NULL;
+  filebuffer[size] = '\0';
+
+  if (size * (int) sizeof(char) != amount_read) {
+    Cli_Error("Error Reading IFC File\n");
+    delete[]filebuffer;
+    return CLI_ERROR;
+  }
+  // look for KeyWord
+  if ((p1 = strstr(filebuffer, KeyWord)) == NULL) {
+    delete[]filebuffer;
+    Cli_Error("Error Finding Keyword\n");
+    return CLI_ERROR;
+  }
+
+  p1 += strlen(KeyWord);
+  p1++;
+
+  // look for the end tag
+  if ((p2 = strstr(p1, IFC_LIST_END)) == NULL) {
+    delete[]filebuffer;
+    Cli_Error("Error Finding End Keyword\n");
+    return CLI_ERROR;
+  }
+
+  switch (CountOn) {
+  case 1:
+
+    // coverity[secure_coding]
+    sscanf(p1, "%d\n", &Count);
+    snprintf(CountString, sizeof(CountString), "%d", Count);
+    p1 += (strlen(CountString));
+    //fall through
+
+  case 0:
+    p1++;
+    snprintf(Output, p2 - p1, "%s", p1);
+    //memset(Output + (p2-p1), 1, 0);
+    delete[]filebuffer;
+    return (ConfigReadPrintIFCEle());
+
+  default:
+
+    Cli_Error("Unexpected Value of CountOn\n");
+    delete[]filebuffer;
+    return CLI_ERROR;
+  }
+}
+
+
+int
+CIFCReadEntry::ConfigReadIFCHead()
+{
+  ink_strlcpy(KeyWord, IFC_HEAD, sizeof(KeyWord));
+  CountOn = 0;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCFeature()
+{
+  ink_strlcpy(KeyWord, IFC_FEATURE, sizeof(KeyWord));
+  CountOn = 0;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCTar()
+{
+  ink_strlcpy(KeyWord, IFC_TAR, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCCommonTar()
+{
+  ink_strlcpy(KeyWord, IFC_COMMON_TAR, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCTarInfo()
+{
+  ink_strlcpy(KeyWord, IFC_TAR_INFO, sizeof(KeyWord));
+  CountOn = 0;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCBinGroup()
+{
+  ink_strlcpy(KeyWord, IFC_BIN_GROUP, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCBinDir()
+{
+  ink_strlcpy(KeyWord, IFC_BIN_DIR, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCBinCommon()
+{
+  ink_strlcpy(KeyWord, IFC_BIN_COMMON, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCLibGroup()
+{
+  ink_strlcpy(KeyWord, IFC_LIB_GROUP, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCLibDir()
+{
+  ink_strlcpy(KeyWord, IFC_LIB_DIR, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCLibCommon()
+{
+  ink_strlcpy(KeyWord, IFC_LIB_COMMON, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCConfigGroup()
+{
+  ink_strlcpy(KeyWord, IFC_CONFIG_GROUP, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCConfigDir()
+{
+  ink_strlcpy(KeyWord, IFC_CONFIG_DIR, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+int
+CIFCReadEntry::ConfigReadIFCConfigCommon()
+{
+  ink_strlcpy(KeyWord, IFC_CONFIG_COMMON, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+
+int
+CIFCReadEntry::ConfigReadIFCCommonFile()
+{
+  ink_strlcpy(KeyWord, IFC_COMMON_FILE, sizeof(KeyWord));
+  CountOn = 1;
+  return (ConfigReadIFCEle());
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigRead
+//
+// This is the callback function for the "config:read" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigRead(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  /*   if(cliCheckIfEnabled("config:read") == CLI_ERROR) {
+     return CMD_ERROR;
+     }
+   */
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+  Cli_Debug("Cmd_ConfigRead argc %d\n", argc);
+
+  if (CIFCWriteEntry::ConfigWriteCheckIFCEnv() == TS_ERR_READ_FILE) {
+    Cli_Error("Set $IFCVERSION, $IFCPATH and $IFCFILENAME First\n");
+    return CLI_ERROR;
+  }
+
+  CIFCReadEntry Entry;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+
+    switch (argtable->parsed_args) {
+
+    case CMD_CONFIG_READ_IFC_HEAD:
+      return (Entry.ConfigReadIFCHead());
+
+    case CMD_CONFIG_READ_FEATURE:
+      return (Entry.ConfigReadIFCFeature());
+
+    case CMD_CONFIG_READ_TAR:
+      return (Entry.ConfigReadIFCTar());
+
+    case CMD_CONFIG_READ_TAR_INFO:
+      return (Entry.ConfigReadIFCTarInfo());
+
+    case CMD_CONFIG_READ_TAR_COMMON:
+      return (Entry.ConfigReadIFCCommonTar());
+
+    case CMD_CONFIG_READ_BIN_DIR:
+      return (Entry.ConfigReadIFCBinDir());
+
+    case CMD_CONFIG_READ_BIN_GROUP:
+      return (Entry.ConfigReadIFCBinGroup());
+
+    case CMD_CONFIG_READ_BIN_COMMON:
+      return (Entry.ConfigReadIFCBinCommon());
+
+    case CMD_CONFIG_READ_LIB_DIR:
+      return (Entry.ConfigReadIFCLibDir());
+
+    case CMD_CONFIG_READ_LIB_GROUP:
+      return (Entry.ConfigReadIFCLibGroup());
+
+    case CMD_CONFIG_READ_LIB_COMMON:
+      return (Entry.ConfigReadIFCLibCommon());
+
+    case CMD_CONFIG_READ_CONFIG_DIR:
+      return (Entry.ConfigReadIFCConfigDir());
+
+    case CMD_CONFIG_READ_CONFIG_GROUP:
+      return (Entry.ConfigReadIFCConfigGroup());
+
+    case CMD_CONFIG_READ_CONFIG_COMMON:
+      return (Entry.ConfigReadIFCConfigCommon());
+
+    case CMD_CONFIG_READ_COMMON_FILE:
+      return (Entry.ConfigReadIFCCommonFile());
+    }
+  }
+
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigRead
+//
+// Register "config:read" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigRead()
+{
+  createArgument("ifc-head", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_READ_IFC_HEAD, "Read the head information of ifc file", (char *) NULL);
+  createArgument("feature", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_READ_FEATURE, "Read the feature string", (char *) NULL);
+  createArgument("tar", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_READ_TAR, "Read the tar file list", (char *) NULL);
+  createArgument("tar-common", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_READ_TAR_COMMON, "Read the MUST-HAVE tar files", (char *) NULL);
+  createArgument("tar-info", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_READ_TAR_INFO, "Read the file contained in this named tar file",
+                 (char *) NULL);
+  createArgument("bin-dir", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_READ_BIN_DIR,
+                 "Read the subdirectories and the files in each of them in bin directory", (char *) NULL);
+  createArgument("bin-group", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_BIN_GROUP,
+                 "Read the file listed in the bin directory", (char *) NULL);
+  createArgument("bin-common", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_BIN_COMMON,
+                 "Read the MUST-HAVE bin files", (char *) NULL);
+  createArgument("lib-dir", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_LIB_DIR,
+                 "Read the subdirectories and the files in each of them in lib directory", (char *) NULL);
+  createArgument("lib-group", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_LIB_GROUP,
+                 "Read the file listed in the lib directory", (char *) NULL);
+  createArgument("lib-common", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_LIB_COMMON,
+                 "Read the MUST-HAVE lib files", (char *) NULL);
+  createArgument("config-dir", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_CONFIG_DIR,
+                 "Read the subdirectories and the files in each of them in the config directory", (char *) NULL);
+  createArgument("config-group", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_CONFIG_GROUP,
+                 "Read the file listed in the config directory", (char *) NULL);
+  createArgument("config-common", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_CONFIG_COMMON,
+                 "Read the MUST-HAVE config files", (char *) NULL);
+  createArgument("common-file", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_COMMON_FILE,
+                 "Read the MUST-HAVE files", (char *) NULL);
+
+  return CLI_OK;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigSaveUrl
+//
+// This is the callback function for the "config:saveUrl" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigSaveUrl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* Call to processArgForCommand must appear at the beginning
+     of each command's cb function.
+   */
+
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+/*   if(cliCheckIfEnabled("config:save-url") == CLI_ERROR) {
+     return CMD_ERROR;
+   }
+*/
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable, *infoPtr;
+  char *Url = NULL;
+  char *outputFile = NULL;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+  Cli_Debug("Cmd_ConfigSaveUrl argc %d\n", argc);
+  char **header = 0;            /* lv: useless variable - never changed */
+  int headerSize;
+  char **body = 0;              /* lv: useless variable - never changed */
+  int bodySize;
+
+  for (infoPtr = argtable; infoPtr->parsed_args != CLI_PARSED_ARGV_END; infoPtr++) {
+    switch (infoPtr->parsed_args) {
+
+    case CMD_CONFIG_UPGRADE_READ_URL:
+      Url = argtable->arg_string;
+      infoPtr++;
+      outputFile = argtable->arg_string;
+      break;
+    }
+  }
+  if (Url == NULL || outputFile == NULL) {
+    return CMD_ERROR;
+  } else {
+    if (TSReadFromUrl(Url, header, &headerSize, body, &bodySize) == TS_ERR_FAIL) {
+      return CMD_ERROR;
+    }
+
+  }
+
+  return CMD_OK;
+}
+
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigSaveUrl
+//
+// Register "config:read" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigSaveUrl()
+{
+  createArgument("url", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_UPGRADE_READ_URL, "Read the url", (char *) NULL);
+
+  return CMD_OK;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/ConfigUpgradeWriteCmd.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ConfigUpgradeWriteCmd.cc b/cmd/traffic_shell/ConfigUpgradeWriteCmd.cc
new file mode 100644
index 0000000..153ba50
--- /dev/null
+++ b/cmd/traffic_shell/ConfigUpgradeWriteCmd.cc
@@ -0,0 +1,517 @@
+/** @file
+
+  This file contains the CLI's "config:write" command implementation
+
+  @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 "libts.h"
+#include <ConfigCmd.h>
+#include <CliDisplay.h>
+#include <CliMgmtUtils.h>
+#include <CliDisplay.h>
+#include <CliMgmtUtils.h>
+#include <ConfigUpgradeCmd.h>
+#include <string.h>
+
+
+CIFCWriteEntry::CIFCWriteEntry():CountOn(0)
+{
+  char *pathPtr;
+  char *filenamePtr;
+  char *versionPtr;
+
+  pathPtr = getenv("IFCPATH");
+  filenamePtr = getenv("IFCFILENAME");
+  versionPtr = getenv("IFCVERSION");
+
+  snprintf(FileName, sizeof(FileName), "%s%s", pathPtr, filenamePtr);
+  snprintf(Version, sizeof(Version), "%s", versionPtr);
+
+  KeyWord[0] = '\0';
+  Input[0] = '\0';
+}
+
+CIFCWriteEntry::~CIFCWriteEntry()
+{
+}
+
+// check IFCVERSION IFCPATH and IFCFILENAME setup
+TSError
+CIFCWriteEntry::ConfigWriteCheckIFCEnv()
+{
+  char *pathPtr;
+  char *filenamePtr;
+  char *versionPtr;
+
+  pathPtr = getenv("IFCPATH");
+  filenamePtr = getenv("IFCFILENAME");
+  versionPtr = getenv("IFCVERSION");
+
+  if (pathPtr == NULL || filenamePtr == NULL || versionPtr == NULL ||
+      strlen(pathPtr) == 0 || strlen(filenamePtr) == 0 || strlen(versionPtr) == 0) {
+    return TS_ERR_READ_FILE;
+  }
+
+  return TS_ERR_OKAY;
+}
+
+TSError
+CIFCWriteEntry::Cli_NewIFCFile()
+{
+  FILE *Fptr;
+
+  Fptr = fopen(FileName, "r+");
+  if (Fptr != NULL) {
+    fclose(Fptr);
+    return TS_ERR_OKAY;
+  } else {                      /* need to create new file */
+    Fptr = fopen(FileName, "w");
+    if (Fptr == NULL) {
+      Cli_Error("Error in creating new IFC file\n");
+      return TS_ERR_WRITE_FILE;
+    }
+
+    fprintf(Fptr, "%s\n\n", IFC_BEGIN);
+    fprintf(Fptr, "%s%s\n%s\n\n", IFC_HEAD, IFC_LIST_BEGIN, IFC_LIST_END);
+    fprintf(Fptr, "%s%s\n%s\n\n", IFC_FEATURE, IFC_LIST_BEGIN, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_TAR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s\n%s\n\n", IFC_TAR_INFO, IFC_LIST_BEGIN, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_COMMON_TAR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_BIN_GROUP, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_BIN_DIR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_BIN_COMMON, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_LIB_GROUP, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_LIB_DIR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_LIB_COMMON, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_CONFIG_GROUP, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_CONFIG_DIR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_CONFIG_COMMON, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_COMMON_FILE, IFC_LIST_BEGIN, 0, IFC_LIST_END);
+    fprintf(Fptr, "%s\n\n", IFC_END);
+
+    fclose(Fptr);
+
+    return TS_ERR_OKAY;
+  }
+}
+
+
+int
+CIFCWriteEntry::ConfigWriteIFCEle()
+{
+  FILE *Fptr;
+  char *filebuffer, *in_buffer;
+  char *p1;
+  char OldCountString[CONFIG_UPGRADE_INT_STRING_SIZE];
+  int Count = -1;
+  long size, amount_read, addsize;
+
+  if ((Fptr = fopen(FileName, "r")) == NULL) {
+    Cli_Error("ERROR Open IFC File to read\n");
+    return CLI_ERROR;
+  }
+
+  fseek(Fptr, 0, SEEK_END);
+  size = ftell(Fptr);
+  if (size <= 0) {
+    fclose(Fptr);
+    Cli_Error("Error Reading IFC File\n");
+    return CLI_ERROR;
+  }
+
+  filebuffer = new char[size + 1];
+  fseek(Fptr, 0, SEEK_SET);
+  amount_read = fread((void *) filebuffer, sizeof(char), size, Fptr);
+  fclose(Fptr);
+  filebuffer[size] = '\0';
+
+  if (size * (int) sizeof(char) != amount_read) {
+    Cli_Error("Error Reading IFC File\n");
+    fclose(Fptr);
+    delete[]filebuffer;
+    return CLI_ERROR;
+  }
+  // look for KeyWord
+  if ((p1 = strstr(filebuffer, KeyWord)) == NULL) {
+    delete[]filebuffer;
+    fclose(Fptr);
+    Cli_Error("Error Finding Keyword\n");
+    return CLI_ERROR;
+  }
+
+  p1 += strlen(KeyWord);
+  p1++;
+
+  // writeback
+  Fptr = fopen(FileName, "r+");
+  fseek(Fptr, p1 - filebuffer, SEEK_SET);
+
+  switch (CountOn) {
+  case 1:
+    {
+      // coverity[secure_coding]
+      sscanf(p1, "%d\n", &Count);
+      snprintf(OldCountString, sizeof(OldCountString), "%d", Count);
+      p1 += (strlen(OldCountString) + 1);
+      Count++;
+      addsize = strlen(Input) + CONFIG_UPGRADE_INT_STRING_SIZE + 2;
+      const size_t in_buffer_size = addsize + 1;
+      in_buffer = new char[in_buffer_size];
+      snprintf(in_buffer, in_buffer_size, "%d\n%s\n", Count, Input);
+      in_buffer[addsize] = '\0';
+      if (fwrite(in_buffer, sizeof(char), strlen(in_buffer), Fptr) != strlen(in_buffer)) {
+        Cli_Error("Unable to fwrite() buffer\n");
+        delete[]in_buffer;
+        delete[]filebuffer;
+        fclose(Fptr);
+        return CLI_ERROR;
+      }
+      delete[]in_buffer;
+      break;
+    }
+  case 0:
+    if ((fwrite("\n", sizeof(char), 1, Fptr) != 1) ||
+        (fwrite(Input, sizeof(char), strlen(Input), Fptr) != strlen(Input))) {
+      Cli_Error("Unable to fwrite() buffer\n");
+      fclose(Fptr);
+      delete[]filebuffer;
+      return CLI_ERROR;
+    }
+    break;
+
+  default:
+    Cli_Error("Unexpected Value of CountOn\n");
+    fclose(Fptr);
+    delete[]filebuffer;
+    return CLI_ERROR;
+  }
+
+  if (fwrite(p1, sizeof(char), size - (p1 - filebuffer), Fptr) != (size_t)(size - (p1 - filebuffer))) {
+    Cli_Error("Unable to fwrite() buffer\n");
+    fclose(Fptr);
+    delete[]filebuffer;
+    return CLI_ERROR;
+  }
+  fclose(Fptr);
+  delete[]filebuffer;
+  return CLI_OK;
+
+}
+
+
+void
+CIFCWriteEntry::PrintEle()
+{
+  printf("%s:%d:%s\n", KeyWord, CountOn, Input);
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCHead(char *ts_version, char *build_date, char *platform, int nodes)
+{
+  ink_strlcpy(KeyWord, IFC_HEAD, sizeof(KeyWord));
+  snprintf(Input, sizeof(Input), "%s\n%s\n%s\n%d", ts_version, build_date, platform, nodes);
+  CountOn = 0;
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCFeature(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_FEATURE, sizeof(KeyWord));
+  CountOn = 0;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCTar(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_TAR, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCCommonTar(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_COMMON_TAR, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCTarInfo(char *tar, char *filelist)
+{
+  ink_strlcpy(KeyWord, IFC_TAR_INFO, sizeof(KeyWord));
+  CountOn = 0;
+  snprintf(Input, sizeof(Input), "%s:\n%s", tar, filelist);
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCBinGroup(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_BIN_GROUP, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCBinDir(char *subdir, char *filelist)
+{
+  ink_strlcpy(KeyWord, IFC_BIN_DIR, sizeof(KeyWord));
+  CountOn = 1;
+  snprintf(Input, sizeof(Input), "%s:%s", subdir, filelist);
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCBinCommon(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_BIN_COMMON, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCLibGroup(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_LIB_GROUP, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCLibDir(char *subdir, char *filelist)
+{
+  ink_strlcpy(KeyWord, IFC_LIB_DIR, sizeof(KeyWord));
+  CountOn = 1;
+  snprintf(Input, sizeof(Input), "%s:%s", subdir, filelist);
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCLibCommon(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_LIB_COMMON, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCConfigGroup(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_CONFIG_GROUP, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCConfigDir(char *subdir, char *filelist)
+{
+  ink_strlcpy(KeyWord, IFC_CONFIG_DIR, sizeof(KeyWord));
+  CountOn = 1;
+  snprintf(Input, sizeof(Input), "%s:%s", subdir, filelist);
+  return (ConfigWriteIFCEle());
+}
+
+int
+CIFCWriteEntry::ConfigWriteIFCConfigCommon(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_CONFIG_COMMON, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+
+int
+CIFCWriteEntry::ConfigWriteIFCCommonFile(char *input)
+{
+  ink_strlcpy(KeyWord, IFC_COMMON_FILE, sizeof(KeyWord));
+  CountOn = 1;
+  ink_strlcpy(Input, input, sizeof(Input));
+  return (ConfigWriteIFCEle());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigWrite
+//
+// This is the callback function for the "config:write" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigWrite(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  /*if(cliCheckIfEnabled("config:write") == CLI_ERROR)
+     {
+     return CMD_ERROR;
+     } */
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+  Cli_Debug("Cmd_ConfigWrite argc %d\n", argc);
+
+  if (CIFCWriteEntry::ConfigWriteCheckIFCEnv() == TS_ERR_READ_FILE) {
+    Cli_Error("Set $IFCVERSION, $IFCPATH and $IFCFILENAME First\n");
+    return CLI_ERROR;
+  }
+
+  CIFCWriteEntry Entry;
+
+  if (Entry.Cli_NewIFCFile() == TS_ERR_WRITE_FILE) {
+    return CLI_ERROR;
+  }
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_WRITE_IFC_HEAD:
+      return (Entry.ConfigWriteIFCHead(argtable[1].arg_string,
+                                       argtable[2].arg_string, argtable[3].arg_string, argtable[4].arg_int));
+
+    case CMD_CONFIG_WRITE_FEATURE:
+      return (Entry.ConfigWriteIFCFeature(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_TAR:
+      return (Entry.ConfigWriteIFCTar(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_TAR_INFO:
+      return (Entry.ConfigWriteIFCTarInfo(argtable[0].arg_string, argtable[1].arg_string));
+
+    case CMD_CONFIG_WRITE_TAR_COMMON:
+      return (Entry.ConfigWriteIFCCommonTar(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_BIN_DIR:
+      return (Entry.ConfigWriteIFCBinDir(argtable[0].arg_string, argtable[1].arg_string));
+
+    case CMD_CONFIG_WRITE_BIN_GROUP:
+      return (Entry.ConfigWriteIFCBinGroup(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_BIN_COMMON:
+      return (Entry.ConfigWriteIFCBinCommon(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_LIB_DIR:
+      return (Entry.ConfigWriteIFCLibDir(argtable[0].arg_string, argtable[1].arg_string));
+
+    case CMD_CONFIG_WRITE_LIB_GROUP:
+      return (Entry.ConfigWriteIFCLibGroup(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_LIB_COMMON:
+      return (Entry.ConfigWriteIFCLibCommon(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_CONFIG_DIR:
+      return (Entry.ConfigWriteIFCConfigDir(argtable[0].arg_string, argtable[1].arg_string));
+
+    case CMD_CONFIG_WRITE_CONFIG_GROUP:
+      return (Entry.ConfigWriteIFCConfigGroup(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_CONFIG_COMMON:
+      return (Entry.ConfigWriteIFCConfigCommon(argtable[0].arg_string));
+
+    case CMD_CONFIG_WRITE_COMMON_FILE:
+      return (Entry.ConfigWriteIFCCommonFile(argtable[0].arg_string));
+    }
+  }
+
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigWrite0
+//
+// Register "config:write" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigWrite()
+{
+  createArgument("ifc-head", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_WRITE_IFC_HEAD, "Specify the head information of ifc file", (char *) NULL);
+  createArgument("ts-version", CMD_CONFIG_WRITE_IFC_HEAD, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_TS_VERSION, "Specify the version of Traffic Server installed",
+                 (char *) NULL);
+  createArgument("build-date", CMD_CONFIG_WRITE_TS_VERSION, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_BUILD_DATE, "Specify date of the Traffic Server Build", (char *) NULL);
+  createArgument("platform", CMD_CONFIG_WRITE_BUILD_DATE, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_PLATFORM, "Specify the platform of installation", (char *) NULL);
+  createArgument("nodes", CMD_CONFIG_WRITE_PLATFORM, CLI_ARGV_INT,
+                 (char *) NULL, CMD_CONFIG_WRITE_NODES, "Specify the number of node in the cluster", (char *) NULL);
+  createArgument("feature", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_FEATURE, "Specify the feature string", (char *) NULL);
+  createArgument("tar", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_TAR, "Specify the tar file list", (char *) NULL);
+  createArgument("tar-common", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_TAR_COMMON, "Specify the MUST-HAVE tar files", (char *) NULL);
+  createArgument("tar-info", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_TAR_INFO, "Specify the file contained in this named tar file",
+                 (char *) NULL);
+  createArgument("filelist", CLI_ARGV_NO_POS, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_FILELIST, "Specify the filelist contained in this named tar file",
+                 (char *) NULL);
+  createArgument("bin-dir", 1, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_WRITE_BIN_DIR,
+                 "Specify the subdirectories and the files in each of them in bin directory", (char *) NULL);
+  createArgument("bin-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_BIN_GROUP,
+                 "Specify the file listed in the bin directory", (char *) NULL);
+  createArgument("bin-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_BIN_COMMON,
+                 "Specify the MUST-HAVE bin files", (char *) NULL);
+  createArgument("lib-dir", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_DIR,
+                 "Specify the subdirectories and the files in each of them in lib directory", (char *) NULL);
+  createArgument("lib-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_GROUP,
+                 "Specify the file listed in the lib directory", (char *) NULL);
+  createArgument("lib-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_COMMON,
+                 "Specify the MUST-HAVE lib files", (char *) NULL);
+  createArgument("config-dir", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_DIR,
+                 "Specify the subdirectories and the files in each of them in the config directory", (char *) NULL);
+  createArgument("config-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_GROUP,
+                 "Specify the file listed in the config directory", (char *) NULL);
+  createArgument("config-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_COMMON,
+                 "Specify the MUST-HAVE config files", (char *) NULL);
+  createArgument("common-file", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_COMMON_FILE,
+                 "Specify the MUST-HAVE files", (char *) NULL);
+
+  return CLI_OK;
+}


[22/44] git commit: Revert "TS-2082: fix build with --enable-standalone-iocore"

Posted by zw...@apache.org.
Revert "TS-2082: fix build with --enable-standalone-iocore"

This reverts commit 94215bf293d76d27a88a0fc9e35356321310fbf5.

This broke some cache regression tests and we are reverting it until
those can be addressed.


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

Branch: refs/heads/5.0.x
Commit: b9b1bdc81fa1b7e3b1edb54de938d1ea0aec2d7a
Parents: 6fd9e17
Author: Phil Sorber <so...@apache.org>
Authored: Fri Nov 15 09:59:43 2013 -0700
Committer: Phil Sorber <so...@apache.org>
Committed: Fri Nov 15 09:59:43 2013 -0700

----------------------------------------------------------------------
 CHANGES                          |  2 --
 iocore/cache/Cache.cc            | 30 ++++++++++++++-------------
 iocore/cache/CacheHttp.cc        | 16 +++++++-------
 iocore/cache/CacheRead.cc        | 10 +--------
 iocore/cache/CacheWrite.cc       |  4 ----
 iocore/cache/I_CacheDefs.h       |  2 +-
 iocore/cache/Makefile.am         |  3 ---
 iocore/cache/P_CacheInternal.h   | 11 +++++-----
 iocore/dns/DNS.cc                |  3 +--
 iocore/dns/Makefile.am           |  4 ----
 iocore/dns/P_DNSProcessor.h      | 26 -----------------------
 iocore/dns/P_SplitDNSProcessor.h | 27 ++++++++++++++++++++++++
 iocore/hostdb/HostDB.cc          |  2 +-
 iocore/hostdb/Makefile.am        |  3 ---
 iocore/hostdb/MultiCache.cc      |  1 -
 iocore/net/Makefile.am           |  4 ----
 iocore/net/Socks.cc              |  2 +-
 lib/records/RecMessage.cc        |  6 ++----
 proxy/Initialize.cc              | 39 ++++-------------------------------
 proxy/Initialize.h               |  2 +-
 proxy/shared/UglyLogStubs.cc     |  1 -
 21 files changed, 69 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 1d39202..d6327c2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -27,8 +27,6 @@ Changes with Apache Traffic Server 4.2.0
   *) [TS-2303] Incorrect docs for negative_caching_enabled.
     Author: Thomas Jackson <ja...@gmail.com>
 
-  *) [TS-2082] fix build with --enable-standalone-iocore.
-
   *) [TS-2712] Explicitly use subdir-objects in automake init.
 
   *) [TS-2309] Allow mod_generator plugin for lighttpd to accept "SI" postfixes.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/cache/Cache.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index da63ec4..e903a90 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -123,6 +123,20 @@ CacheKey zero_key(0, 0);
 #if TS_USE_INTERIM_CACHE == 1
 ClassAllocator<MigrateToInterimCache> migrateToInterimCacheAllocator("migrateToInterimCache");
 #endif
+void verify_cache_api() {
+  ink_assert((int)TS_EVENT_CACHE_OPEN_READ == (int)CACHE_EVENT_OPEN_READ);
+  ink_assert((int)TS_EVENT_CACHE_OPEN_READ_FAILED == (int)CACHE_EVENT_OPEN_READ_FAILED);
+  ink_assert((int)TS_EVENT_CACHE_OPEN_WRITE == (int)CACHE_EVENT_OPEN_WRITE);
+  ink_assert((int)TS_EVENT_CACHE_OPEN_WRITE_FAILED == (int)CACHE_EVENT_OPEN_WRITE_FAILED);
+  ink_assert((int)TS_EVENT_CACHE_REMOVE == (int)CACHE_EVENT_REMOVE);
+  ink_assert((int)TS_EVENT_CACHE_REMOVE_FAILED == (int)CACHE_EVENT_REMOVE_FAILED);
+  ink_assert((int)TS_EVENT_CACHE_SCAN == (int)CACHE_EVENT_SCAN);
+  ink_assert((int)TS_EVENT_CACHE_SCAN_FAILED == (int)CACHE_EVENT_SCAN_FAILED);
+  ink_assert((int)TS_EVENT_CACHE_SCAN_OBJECT == (int)CACHE_EVENT_SCAN_OBJECT);
+  ink_assert((int)TS_EVENT_CACHE_SCAN_OPERATION_BLOCKED == (int)CACHE_EVENT_SCAN_OPERATION_BLOCKED);
+  ink_assert((int)TS_EVENT_CACHE_SCAN_OPERATION_FAILED == (int)CACHE_EVENT_SCAN_OPERATION_FAILED);
+  ink_assert((int)TS_EVENT_CACHE_SCAN_DONE == (int)CACHE_EVENT_SCAN_DONE);
+}
 
 struct VolInitInfo
 {
@@ -206,6 +220,7 @@ ConfigVolumes config_volumes;
 
 #if TS_HAS_TESTS
 void force_link_CacheTestCaller() {
+  force_link_CacheTest();
 }
 #endif
 
@@ -294,14 +309,12 @@ CacheVC::CacheVC():alternate_index(CACHE_ALT_INDEX_DEFAULT)
   //coverity[uninit_member]
 }
 
-#ifdef HTTP_CACHE
 HTTPInfo::FragOffset*
 CacheVC::get_frag_table()
 {
   ink_assert(alternate.valid());
   return alternate.valid() ? alternate.get_frag_table() : 0;
 }
-#endif
 
 VIO *
 CacheVC::do_io_read(Continuation *c, int64_t nbytes, MIOBuffer *abuf)
@@ -581,18 +594,7 @@ int
 CacheProcessor::start_internal(int flags)
 {
 #ifdef NON_MODULAR
-  ink_assert((int)TS_EVENT_CACHE_OPEN_READ == (int)CACHE_EVENT_OPEN_READ);
-  ink_assert((int)TS_EVENT_CACHE_OPEN_READ_FAILED == (int)CACHE_EVENT_OPEN_READ_FAILED);
-  ink_assert((int)TS_EVENT_CACHE_OPEN_WRITE == (int)CACHE_EVENT_OPEN_WRITE);
-  ink_assert((int)TS_EVENT_CACHE_OPEN_WRITE_FAILED == (int)CACHE_EVENT_OPEN_WRITE_FAILED);
-  ink_assert((int)TS_EVENT_CACHE_REMOVE == (int)CACHE_EVENT_REMOVE);
-  ink_assert((int)TS_EVENT_CACHE_REMOVE_FAILED == (int)CACHE_EVENT_REMOVE_FAILED);
-  ink_assert((int)TS_EVENT_CACHE_SCAN == (int)CACHE_EVENT_SCAN);
-  ink_assert((int)TS_EVENT_CACHE_SCAN_FAILED == (int)CACHE_EVENT_SCAN_FAILED);
-  ink_assert((int)TS_EVENT_CACHE_SCAN_OBJECT == (int)CACHE_EVENT_SCAN_OBJECT);
-  ink_assert((int)TS_EVENT_CACHE_SCAN_OPERATION_BLOCKED == (int)CACHE_EVENT_SCAN_OPERATION_BLOCKED);
-  ink_assert((int)TS_EVENT_CACHE_SCAN_OPERATION_FAILED == (int)CACHE_EVENT_SCAN_OPERATION_FAILED);
-  ink_assert((int)TS_EVENT_CACHE_SCAN_DONE == (int)CACHE_EVENT_SCAN_DONE);
+  verify_cache_api();
 #endif
 
 #if AIO_MODE == AIO_MODE_NATIVE

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/cache/CacheHttp.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheHttp.cc b/iocore/cache/CacheHttp.cc
index e07698c..36db36a 100644
--- a/iocore/cache/CacheHttp.cc
+++ b/iocore/cache/CacheHttp.cc
@@ -274,7 +274,7 @@ CacheHTTPInfoVector::~CacheHTTPInfoVector()
   -------------------------------------------------------------------------*/
 
 int
-CacheHTTPInfoVector::insert(CacheHTTPInfo */* info ATS_UNUSED */, int index)
+CacheHTTPInfoVector::insert(CacheHTTPInfo * info, int index)
 {
   ink_assert(0);
   return index;
@@ -285,7 +285,7 @@ CacheHTTPInfoVector::insert(CacheHTTPInfo */* info ATS_UNUSED */, int index)
 
 
 void
-CacheHTTPInfoVector::detach(int /* idx ATS_UNUSED */, CacheHTTPInfo */* r ATS_UNUSED */)
+CacheHTTPInfoVector::detach(int idx, CacheHTTPInfo * r)
 {
   ink_assert(0);
 }
@@ -294,7 +294,7 @@ CacheHTTPInfoVector::detach(int /* idx ATS_UNUSED */, CacheHTTPInfo */* r ATS_UN
   -------------------------------------------------------------------------*/
 
 void
-CacheHTTPInfoVector::remove(int /* idx ATS_UNUSED */, bool /* destroy ATS_UNUSED */)
+CacheHTTPInfoVector::remove(int idx, bool destroy)
 {
   ink_assert(0);
 }
@@ -303,7 +303,7 @@ CacheHTTPInfoVector::remove(int /* idx ATS_UNUSED */, bool /* destroy ATS_UNUSED
   -------------------------------------------------------------------------*/
 
 void
-CacheHTTPInfoVector::clear(bool /* destroy ATS_UNUSED */)
+CacheHTTPInfoVector::clear(bool destroy)
 {
 }
 
@@ -311,7 +311,7 @@ CacheHTTPInfoVector::clear(bool /* destroy ATS_UNUSED */)
   -------------------------------------------------------------------------*/
 
 void
-CacheHTTPInfoVector::print(char */* buffer ATS_UNUSED */, size_t /* buf_size ATS_UNUSED */, bool /* temps ATS_UNUSED */)
+CacheHTTPInfoVector::print(char *buffer, size_t buf_size, bool temps)
 {
   ink_assert(0);
 }
@@ -329,14 +329,14 @@ CacheHTTPInfoVector::marshal_length()
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 int
-CacheHTTPInfoVector::marshal(char */* buf ATS_UNUSED */, int length)
+CacheHTTPInfoVector::marshal(char *buf, int length)
 {
   ink_assert(0);
   return length;
 }
 
 int
-CacheHTTPInfoVector::unmarshal(const char */* buf ATS_UNUSED */, int /* length ATS_UNUSED */, RefCountObj */* block_ptr ATS_UNUSED */)
+CacheHTTPInfoVector::unmarshal(const char *buf, int length, RefCountObj * block_ptr)
 {
   ink_assert(0);
   return 0;
@@ -346,7 +346,7 @@ CacheHTTPInfoVector::unmarshal(const char */* buf ATS_UNUSED */, int /* length A
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 uint32_t
-CacheHTTPInfoVector::get_handles(const char */* buf ATS_UNUSED */, int /* length ATS_UNUSED */, RefCountObj */* block_ptr ATS_UNUSED */)
+CacheHTTPInfoVector::get_handles(const char *buf, int length, RefCountObj * block_ptr)
 {
   ink_assert(0);
   return 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/cache/CacheRead.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc
index 6121668..f11aee4 100644
--- a/iocore/cache/CacheRead.cc
+++ b/iocore/cache/CacheRead.cc
@@ -632,7 +632,6 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
       vio.ndone = doc_len;
       return calluser(VC_EVENT_EOS);
     }
-#ifdef HTTP_CACHE
     HTTPInfo::FragOffset* frags = alternate.get_frag_table();
     if (is_debug_tag_set("cache_seek")) {
       char b[33], c[33];
@@ -700,7 +699,6 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
       key.toHexStr(target_key_str);
       Debug("cache_seek", "Read # %d @ %" PRId64"/%d for %" PRId64, fragment, doc_pos, doc->len, bytes);
     }
-#endif
   }
   if (ntodo <= 0)
     return EVENT_CONT;
@@ -1125,13 +1123,7 @@ CacheVC::openReadStartHead(int event, Event * e)
       Debug("cache_read", "CacheReadStartHead - read %s target %s - %s %d of %" PRId64" bytes, %d fragments",
             doc->key.toHexStr(xt), key.toHexStr(yt),
             f.single_fragment ? "single" : "multi",
-            doc->len, doc->total_len,
-#ifdef HTTP_CACHE
-            alternate.get_frag_offset_count()
-#else
-            0
-#endif
-            );
+            doc->len, doc->total_len, alternate.get_frag_offset_count());
     }
     // the first fragment might have been gc'ed. Make sure the first
     // fragment is there before returning CACHE_EVENT_OPEN_READ

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/cache/CacheWrite.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc
index ee2160f..1a35b3f 100644
--- a/iocore/cache/CacheWrite.cc
+++ b/iocore/cache/CacheWrite.cc
@@ -1223,13 +1223,11 @@ CacheVC::openWriteCloseDataDone(int event, Event *e)
     if (!fragment) {
       ink_assert(key == earliest_key);
       earliest_dir = dir;
-#ifdef HTTP_CACHE
     } else {
       // Store the offset only if there is a table.
       // Currently there is no alt (and thence no table) for non-HTTP.
       if (alternate.valid())
         alternate.push_frag_offset(write_pos);
-#endif
     }
     fragment++;
     write_pos += write_len;
@@ -1320,13 +1318,11 @@ CacheVC::openWriteWriteDone(int event, Event *e)
     if (!fragment) {
       ink_assert(key == earliest_key);
       earliest_dir = dir;
-#ifdef HTTP_CACHE
     } else {
       // Store the offset only if there is a table.
       // Currently there is no alt (and thence no table) for non-HTTP.
       if (alternate.valid())
         alternate.push_frag_offset(write_pos);
-#endif
     }
     ++fragment;
     write_pos += write_len;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/cache/I_CacheDefs.h
----------------------------------------------------------------------
diff --git a/iocore/cache/I_CacheDefs.h b/iocore/cache/I_CacheDefs.h
index 6b25873..96337de 100644
--- a/iocore/cache/I_CacheDefs.h
+++ b/iocore/cache/I_CacheDefs.h
@@ -63,7 +63,7 @@ enum CacheType {
 };
 
 // NOTE: All the failures are ODD, and one greater than the success
-//       Some of these must match those in <ts/ts.h>
+//       Some of these must match those in <ts/ts.h> (tested in verify_cache_api())
 enum CacheEventType
 {
   CACHE_EVENT_LOOKUP = CACHE_EVENT_EVENTS_START + 0,

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/cache/Makefile.am
----------------------------------------------------------------------
diff --git a/iocore/cache/Makefile.am b/iocore/cache/Makefile.am
index c4faaa1..2b89d81 100644
--- a/iocore/cache/Makefile.am
+++ b/iocore/cache/Makefile.am
@@ -19,9 +19,6 @@
 if STANDALONE_IOCORE
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/mgmt \
-  -I$(top_srcdir)/mgmt/utils \
-  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/lib/ts
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/cache/P_CacheInternal.h
----------------------------------------------------------------------
diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h
index 929cac5..3c180ac 100644
--- a/iocore/cache/P_CacheInternal.h
+++ b/iocore/cache/P_CacheInternal.h
@@ -357,11 +357,6 @@ struct CacheVC: public CacheVConnection
 #ifdef HTTP_CACHE
   virtual void set_http_info(CacheHTTPInfo *info);
   virtual void get_http_info(CacheHTTPInfo ** info);
-  /** Get the fragment table.
-      @return The address of the start of the fragment table,
-      or @c NULL if there is no fragment table.
-  */
-  virtual HTTPInfo::FragOffset* get_frag_table();
 #endif
   virtual bool is_pread_capable();
   virtual bool set_pin_in_cache(time_t time_pin);
@@ -369,6 +364,12 @@ struct CacheVC: public CacheVConnection
   virtual bool set_disk_io_priority(int priority);
   virtual int get_disk_io_priority();
 
+  /** Get the fragment table.
+      @return The address of the start of the fragment table,
+      or @c NULL if there is no fragment table.
+  */
+  virtual HTTPInfo::FragOffset* get_frag_table();
+
   // offsets from the base stat
 #define CACHE_STAT_ACTIVE  0
 #define CACHE_STAT_SUCCESS 1

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/dns/DNS.cc
----------------------------------------------------------------------
diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
index ba24a8c..a84c8c0 100644
--- a/iocore/dns/DNS.cc
+++ b/iocore/dns/DNS.cc
@@ -194,12 +194,10 @@ DNSProcessor::start(int, size_t stacksize) {
 
   dns_failover_try_period = dns_timeout + 1;    // Modify the "default" accordingly
 
-#ifndef STANDALONE_IOCORE
   if (SplitDNSConfig::gsplit_dns_enabled) {
     //reconfigure after threads start
     SplitDNSConfig::reconfigure();
   }
-#endif
 
   // Setup the default DNSHandler, it's used both by normal DNS, and SplitDNS (for PTR lookups etc.)
   dns_init();
@@ -375,6 +373,7 @@ DNSEntry::init(const char *x, int len, int qtype_arg, Continuation* acont,
     dnsH = dnsProcessor.handler;
   }
 #else
+  INK_NOWARN(adnsH);
   dnsH = dnsProcessor.handler;
 #endif // SPLIT_DNS
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/dns/Makefile.am
----------------------------------------------------------------------
diff --git a/iocore/dns/Makefile.am b/iocore/dns/Makefile.am
index 3d5e59f..507add1 100644
--- a/iocore/dns/Makefile.am
+++ b/iocore/dns/Makefile.am
@@ -19,10 +19,6 @@
 if STANDALONE_IOCORE
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I. \
-  -I$(top_srcdir)/mgmt \
-  -I$(top_srcdir)/mgmt/utils \
-  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/lib/ts
 else

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/dns/P_DNSProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/dns/P_DNSProcessor.h b/iocore/dns/P_DNSProcessor.h
index 7df7e10..e5b79f8 100644
--- a/iocore/dns/P_DNSProcessor.h
+++ b/iocore/dns/P_DNSProcessor.h
@@ -292,32 +292,6 @@ private:
   void validate_ip();
 };
 
-/* --------------------------------------------------------------
-   **                struct DNSServer
-
-   A record for an single server
-   -------------------------------------------------------------- */
-struct DNSServer
-{
-  IpEndpoint x_server_ip[MAXNS];
-  char x_dns_ip_line[MAXDNAME * 2];
-
-  char x_def_domain[MAXDNAME];
-  char x_domain_srch_list[MAXDNAME];
-
-  DNSHandler *x_dnsH;
-
-  DNSServer()
-  : x_dnsH(NULL)
-  {
-    memset(x_server_ip, 0, sizeof(x_server_ip));
-
-    memset(x_def_domain, 0, MAXDNAME);
-    memset(x_domain_srch_list, 0, MAXDNAME);
-    memset(x_dns_ip_line, 0, MAXDNAME * 2);
-  }
-};
-
 
 TS_INLINE DNSHandler::DNSHandler()
  : Continuation(NULL), n_con(0), options(0), in_flight(0), name_server(0), in_write_dns(0),

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/dns/P_SplitDNSProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/dns/P_SplitDNSProcessor.h b/iocore/dns/P_SplitDNSProcessor.h
index b2559ad..6785db1 100644
--- a/iocore/dns/P_SplitDNSProcessor.h
+++ b/iocore/dns/P_SplitDNSProcessor.h
@@ -129,6 +129,33 @@ TS_INLINE bool SplitDNSConfig::isSplitDNSEnabled()
 
 
 /* --------------------------------------------------------------
+   **                struct DNSServer
+
+   A record for an single server
+   -------------------------------------------------------------- */
+struct DNSServer
+{
+  IpEndpoint x_server_ip[MAXNS];
+  char x_dns_ip_line[MAXDNAME * 2];
+
+  char x_def_domain[MAXDNAME];
+  char x_domain_srch_list[MAXDNAME];
+
+  DNSHandler *x_dnsH;
+
+  DNSServer()
+  : x_dnsH(NULL)
+  {
+    memset(x_server_ip, 0, sizeof(x_server_ip));
+
+    memset(x_def_domain, 0, MAXDNAME);
+    memset(x_domain_srch_list, 0, MAXDNAME);
+    memset(x_dns_ip_line, 0, MAXDNAME * 2);
+  }
+};
+
+
+/* --------------------------------------------------------------
    **                class DNSRequestData
 
    A record for an single server

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/hostdb/HostDB.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index e421475..0b114b4 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -2460,7 +2460,7 @@ run_HostDBTest()
   if (is_action_tag_set("hostdb_test_rr"))
     eventProcessor.schedule_every(new HostDBTestRR, HRTIME_SECONDS(1), ET_NET);
   if (is_action_tag_set("hostdb_test_reverse")) {
-    eventProcessor.schedule_imm(new HostDBTestReverse, ET_CALL);
+    eventProcessor.schedule_imm(new HostDBTestReverse, ET_CACHE);
   }
 }
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/hostdb/Makefile.am
----------------------------------------------------------------------
diff --git a/iocore/hostdb/Makefile.am b/iocore/hostdb/Makefile.am
index 90381d7..e1edef6 100644
--- a/iocore/hostdb/Makefile.am
+++ b/iocore/hostdb/Makefile.am
@@ -19,9 +19,6 @@
 if STANDALONE_IOCORE
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/mgmt \
-  -I$(top_srcdir)/mgmt/utils \
-  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/lib/ts
 else

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/hostdb/MultiCache.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/MultiCache.cc b/iocore/hostdb/MultiCache.cc
index bd0fdb0..a9a6ceb 100644
--- a/iocore/hostdb/MultiCache.cc
+++ b/iocore/hostdb/MultiCache.cc
@@ -34,7 +34,6 @@
 #include "P_HostDB.h"
 #else
 //extern const char *system_config_directory;
-extern int hostdb_sync_frequency;
 #endif
 
 #include "P_MultiCache.h"

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/net/Makefile.am
----------------------------------------------------------------------
diff --git a/iocore/net/Makefile.am b/iocore/net/Makefile.am
index b19c36b..266da46 100644
--- a/iocore/net/Makefile.am
+++ b/iocore/net/Makefile.am
@@ -19,9 +19,6 @@
 if STANDALONE_IOCORE
 AM_CPPFLAGS = \
   $(iocore_include_dirs) \
-  -I$(top_srcdir)/mgmt \
-  -I$(top_srcdir)/mgmt/utils \
-  -I$(top_srcdir)/lib \
   -I$(top_srcdir)/lib/records \
   -I$(top_srcdir)/lib/ts
 else
@@ -32,7 +29,6 @@ AM_CPPFLAGS = \
   -I$(top_srcdir)/lib/ts \
   -I$(top_srcdir)/proxy \
   -I$(top_srcdir)/proxy/hdrs \
-  -I$(top_srcdir)/proxy/shared \
   -I$(top_srcdir)/mgmt \
   -I$(top_srcdir)/mgmt/preparse \
   -I$(top_srcdir)/mgmt/utils

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/iocore/net/Socks.cc
----------------------------------------------------------------------
diff --git a/iocore/net/Socks.cc b/iocore/net/Socks.cc
index 88b22e5..5f37919 100644
--- a/iocore/net/Socks.cc
+++ b/iocore/net/Socks.cc
@@ -122,7 +122,7 @@ SocksEntry::findServer()
 #else
   if (nattempts > netProcessor.socks_conf_stuff->connection_attempts)
     memset(&server_addr, 0, sizeof(server_addr));
-  else ats_ip_copy(&server_addr, &g_socks_conf_stuff->server_addr);
+  else ats_ip_copy(server_addr, g_socks_conf_stuff->socks_server);
 #endif // SOCKS_WITH_TS
 
   char buff[INET6_ADDRSTRLEN];

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/lib/records/RecMessage.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecMessage.cc b/lib/records/RecMessage.cc
index 8c84c8b..87c59ca 100644
--- a/lib/records/RecMessage.cc
+++ b/lib/records/RecMessage.cc
@@ -39,8 +39,6 @@ static void *g_recv_cookie = NULL;
 //-------------------------------------------------------------------------
 #if defined (REC_BUILD_STAND_ALONE)
 
-extern RecModeT g_mode_type;
-
 static LLQ *g_send_llq = NULL;
 static LLQ *g_recv_llq = NULL;
 
@@ -73,7 +71,7 @@ send_thr(void *data)
 static void *
 recv_thr(void *data)
 {
-  int msg_size = 0;
+  int msg_size;
   RecMessageHdr msg_hdr;
   RecMessage *msg;
   RecHandle h_pipe = (RecHandle)(intptr_t)data;
@@ -147,7 +145,7 @@ RecMessageInit()
   g_send_llq = create_queue();
   g_recv_llq = create_queue();
 
-  switch (g_mode_type) {
+  switch (mode_type) {
   case RECM_CLIENT:
     h_pipe = RecPipeConnect(Layout::get()->runtimedir, REC_PIPE_NAME);
     if (h_pipe == REC_HANDLE_INVALID) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/proxy/Initialize.cc
----------------------------------------------------------------------
diff --git a/proxy/Initialize.cc b/proxy/Initialize.cc
index be296b2..c74b0f5 100644
--- a/proxy/Initialize.cc
+++ b/proxy/Initialize.cc
@@ -37,9 +37,7 @@
 #include "I_Version.h"
 
 #include "Initialize.h" // TODO: move to I_Initialize.h ???
-#include "ink_sys_control.h"
 
-extern char* admin_user;
 
 //
 // Initialize operating system related information/services
@@ -63,7 +61,7 @@ init_system_settings(void)
 #endif
 
 static int
-set_core_size(const char */* name ATS_UNUSED */, RecDataT /* data_type ATS_UNUSED */, RecData data, void */* opaque_token ATS_UNUSED */)
+set_core_size(const char *name, RecDataT data_type, RecData data, void *opaque_token)
 {
 
   RecInt size = data.rec_int;
@@ -239,35 +237,6 @@ init_system_reconfigure_diags(void)
 
 }
 
-void
-chown_file_to_user(const char *file, const char *user)
-{
-  struct passwd *pwd = NULL;
-
-  if (user && *user) {
-    if (*user == '#') {
-      int uid = atoi(user + 1);
-      if (uid == -1) {
-        // XXX: Can this call hapen after setuid?
-        uid = (int)geteuid();
-      }
-      pwd = getpwuid((uid_t)uid);
-    } else {
-      pwd = getpwnam(user);
-    }
-    if (pwd) {
-      if (chown(file, pwd->pw_uid, pwd->pw_gid) < 0) {
-          diags->print(NULL, DL_Warning, __FILE__, __FUNCTION__, __LINE__, "cop couldn't chown the  file: '%s' [%d] %s\n",
-         file, errno, strerror(errno)
-       );
-      }
-    } else {
-        diags->print(NULL, DL_Warning, __FILE__, __FUNCTION__, __LINE__, "can't get passwd entry for the admin user '%s' - [%d] %s\n", user, errno, strerror(errno));
-    }
-  } else {
-      diags->print(NULL, DL_Warning, __FILE__, __FUNCTION__, __LINE__, "Admin user was the empty string.\n");
-  }
-}
 
 void
 init_system_diags(char *bdt, char *bat)
@@ -281,7 +250,7 @@ init_system_diags(char *bdt, char *bat)
   diags_log_fp = fopen(diags_logpath, "w");
   if (diags_log_fp) {
     int status;
-    chown_file_to_user(diags_logpath, admin_user);
+    chown_file_to_user(diag_logpath,admin_user);
     status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
     if (status != 0) {
       fclose(diags_log_fp);
@@ -293,10 +262,10 @@ init_system_diags(char *bdt, char *bat)
   if (diags_log_fp == NULL) {
     SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
 
-    diags->print(NULL, DL_Warning, __FILE__, __FUNCTION__, __LINE__,
+    diags->print(NULL, DL_Warning, NULL, &loc,
                  "couldn't open diags log file '%s', " "will not log to this file", diags_logpath);
   } else {
-    diags->print(NULL, DL_Status, "STATUS", NULL, 0, "opened %s", diags_logpath);
+    diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
   }
 
   init_system_reconfigure_diags();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/proxy/Initialize.h
----------------------------------------------------------------------
diff --git a/proxy/Initialize.h b/proxy/Initialize.h
index 556f251..485f8e7 100644
--- a/proxy/Initialize.h
+++ b/proxy/Initialize.h
@@ -49,7 +49,7 @@ void init_system_syslog_log_configure(void);
 //void init_system_logging();
 void init_system_reconfigure_diags(void);
 void init_system_diags(char *bdt, char *bat);
-void chown_file_to_user(const char *file, const char *user);
+
 void init_system_adjust_num_of_net_threads(void);
 
 //void initialize_standalone();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b9b1bdc8/proxy/shared/UglyLogStubs.cc
----------------------------------------------------------------------
diff --git a/proxy/shared/UglyLogStubs.cc b/proxy/shared/UglyLogStubs.cc
index 9690571..0a048e8 100644
--- a/proxy/shared/UglyLogStubs.cc
+++ b/proxy/shared/UglyLogStubs.cc
@@ -196,7 +196,6 @@ UnixNetProcessor::freeThread(UnixNetVConnection * /* vc ATS_UNUSED */, EThread *
 // For Intel ICC
 int cache_config_mutex_retry_delay = 2;
 
-#include "I_SplitDNSProcessor.h"
 void
 SplitDNSConfig::reconfigure()
 {


[07/44] git commit: TS-2349: Move traffic_line to the cmd subdirectory

Posted by zw...@apache.org.
TS-2349: Move traffic_line to the cmd subdirectory


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

Branch: refs/heads/5.0.x
Commit: c83e1d847086c2b9ed4cf7b953409d24e9929bf4
Parents: 6917d8e
Author: James Peach <jp...@apache.org>
Authored: Sat Nov 9 20:51:12 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Nov 14 12:30:41 2013 -0800

----------------------------------------------------------------------
 cmd/Makefile.am                  |   2 +-
 cmd/traffic_line/Makefile.am     |  35 ++++++
 cmd/traffic_line/traffic_line.cc | 218 ++++++++++++++++++++++++++++++++++
 configure.ac                     |   1 +
 mgmt/cli/Makefile.am             |  12 +-
 mgmt/cli/TrafficLine.cc          | 218 ----------------------------------
 6 files changed, 256 insertions(+), 230 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c83e1d84/cmd/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
index 4d30867..58a8a68 100644
--- a/cmd/Makefile.am
+++ b/cmd/Makefile.am
@@ -15,4 +15,4 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-SUBDIRS = traffic_top traffic_cop
+SUBDIRS = traffic_top traffic_cop traffic_line

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c83e1d84/cmd/traffic_line/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_line/Makefile.am b/cmd/traffic_line/Makefile.am
new file mode 100644
index 0000000..6a2aec3
--- /dev/null
+++ b/cmd/traffic_line/Makefile.am
@@ -0,0 +1,35 @@
+#
+# 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/ts \
+  -I$(top_srcdir)/mgmt/api/include
+
+bin_PROGRAMS = traffic_line
+
+traffic_line_SOURCES = \
+  traffic_line.cc
+
+traffic_line_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
+traffic_line_LDADD = \
+  $(top_builddir)/mgmt/api/libtsmgmt.la \
+  $(top_builddir)/lib/ts/libtsutil.la \
+  @LIBRESOLV@ @LIBTCL@ @LIBSSL@

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c83e1d84/cmd/traffic_line/traffic_line.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_line/traffic_line.cc b/cmd/traffic_line/traffic_line.cc
new file mode 100644
index 0000000..7f99f5b
--- /dev/null
+++ b/cmd/traffic_line/traffic_line.cc
@@ -0,0 +1,218 @@
+/** @file
+
+  A brief file description
+
+  @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 "libts.h"
+
+#include "ink_args.h"
+#include "I_Version.h"
+#include "Tokenizer.h"
+#include "TextBuffer.h"
+#include "mgmtapi.h"
+
+static const char *programName;
+
+static char ReadVar[1024];
+static char SetVar[1024];
+static char VarValue[1024];
+static int ReRead;
+static int Shutdown;
+static int BounceCluster;
+static int BounceLocal;
+static int QueryDeadhosts;
+static int Startup;
+static int ShutdownMgmtCluster;
+static int ShutdownMgmtLocal;
+static int ClearCluster;
+static int ClearNode;
+static char ZeroCluster[1024];
+static char ZeroNode[1024];
+static int VersionFlag;
+
+static TSError
+handleArgInvocation()
+{
+  if (ReRead == 1) {
+    return TSReconfigure();
+  } else if (ShutdownMgmtCluster == 1) {
+    return TSRestart(true);
+  } else if (ShutdownMgmtLocal == 1) {
+    return TSRestart(false);
+  } else if (Shutdown == 1) {
+    return TSProxyStateSet(TS_PROXY_OFF, TS_CACHE_CLEAR_OFF);
+  } else if (BounceCluster == 1) {
+    return TSBounce(true);
+  } else if (BounceLocal == 1) {
+    return TSBounce(false);
+  } else if (Startup == 1) {
+    return TSProxyStateSet(TS_PROXY_ON, TS_CACHE_CLEAR_OFF);
+  } else if (ClearCluster == 1) {
+    return TSStatsReset(true);
+  } else if (ClearNode == 1) {
+    return TSStatsReset(false);
+  } else if (*ZeroNode != '\0' || *ZeroCluster != '\0') {
+    TSError err;
+    TSRecordEle *rec_ele = TSRecordEleCreate();
+    char *name = *ZeroNode ? ZeroNode : ZeroCluster;
+    if ((err = TSRecordGet(name, rec_ele)) != TS_ERR_OKAY) {
+      fprintf(stderr, "%s: %s\n", programName, TSGetErrorMessage(err));
+      TSRecordEleDestroy(rec_ele);
+      return err;
+    }
+    TSRecordEleDestroy(rec_ele);
+    return TSStatsReset(*ZeroCluster ? true : false, name);
+  } else if (QueryDeadhosts == 1) {
+    fprintf(stderr, "Query Deadhosts is not implemented, it requires support for congestion control.\n");
+    fprintf(stderr, "For more details, examine the old code in cli/CLI.cc: QueryDeadhosts()\n");
+    return TS_ERR_FAIL;
+  } else if (*ReadVar != '\0') {        // Handle a value read
+    if (*SetVar != '\0' || *VarValue != '\0') {
+      fprintf(stderr, "%s: Invalid Argument Combination: Can not read and set values at the same time\n", programName);
+      return TS_ERR_FAIL;
+    } else {
+      TSError err;
+      TSRecordEle *rec_ele = TSRecordEleCreate();
+
+      if ((err = TSRecordGet(ReadVar, rec_ele)) != TS_ERR_OKAY) {
+        fprintf(stderr, "%s: %s\n", programName, TSGetErrorMessage(err));
+      } else {
+        switch (rec_ele->rec_type) {
+        case TS_REC_INT:
+          printf("%" PRId64 "\n", rec_ele->int_val);
+          break;
+        case TS_REC_COUNTER:
+          printf("%" PRId64 "\n", rec_ele->counter_val);
+          break;
+        case TS_REC_FLOAT:
+          printf("%f\n", rec_ele->float_val);
+          break;
+        case TS_REC_STRING:
+          printf("%s\n", rec_ele->string_val);
+          break;
+        default:
+          fprintf(stderr, "%s: unknown record type (%d)\n", programName, rec_ele->rec_type);
+          err = TS_ERR_FAIL;
+          break;
+        }
+      }
+      TSRecordEleDestroy(rec_ele);
+      return err;
+    }
+  } else if (*SetVar != '\0') { // Setting a variable
+    if (*VarValue == '\0') {
+      fprintf(stderr, "%s: Set requires a -v argument\n", programName);
+      return TS_ERR_FAIL;
+    } else {
+      TSError err;
+      TSActionNeedT action;
+
+      if ((err = TSRecordSet(SetVar, VarValue, &action)) != TS_ERR_OKAY)
+        fprintf(stderr, "%s: Please correct your variable name and|or value\n", programName);
+      return err;
+    }
+  } else if (*VarValue != '\0') {       // We have a value but no variable to set
+    fprintf(stderr, "%s: Must specify variable to set with -s when using -v\n", programName);
+    return TS_ERR_FAIL;
+  }
+
+  fprintf(stderr, "%s: No arguments specified\n", programName);
+  return TS_ERR_FAIL;
+}
+
+int
+main(int /* argc ATS_UNUSED */, char **argv)
+{
+  AppVersionInfo appVersionInfo;
+  TSError status;
+
+  programName = argv[0];
+
+  ReadVar[0] = '\0';
+  SetVar[0] = '\0';
+  VarValue[0] = '\0';
+  ReRead = 0;
+  Shutdown = 0;
+  BounceCluster = 0;
+  BounceLocal = 0;
+  QueryDeadhosts = 0;
+  Startup = 0;
+  ShutdownMgmtCluster = 0;
+  ShutdownMgmtLocal = 0;
+  ClearCluster = 0;
+  ClearNode = 0;
+  ZeroCluster[0] = '\0';
+  ZeroNode[0] = '\0';
+  VersionFlag = 0;
+
+  // build the application information structure
+  appVersionInfo.setup(PACKAGE_NAME,"traffic_line", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
+
+/* Argument description table used to describe how to parse command line args, */
+/* see 'ink_args.h' for meanings of the various fields */
+  ArgumentDescription argument_descriptions[] = {
+    {"query_deadhosts", 'q', "Query congested sites", "F", &QueryDeadhosts, NULL, NULL},
+    {"read_var", 'r', "Read Variable", "S1024", &ReadVar, NULL, NULL},
+    {"set_var", 's', "Set Variable (requires -v option)", "S1024", &SetVar, NULL, NULL},
+    {"value", 'v', "Set Value (used with -s option)", "S1024", &VarValue, NULL, NULL},
+    {"help", 'h', "Help", NULL, NULL, NULL, usage},
+    {"reread_config", 'x', "Reread Config Files", "F", &ReRead, NULL, NULL},
+    {"restart_cluster", 'M', "Restart traffic_manager (cluster wide)", "F", &ShutdownMgmtCluster, NULL, NULL},
+    {"restart_local", 'L', "Restart traffic_manager (local node)", "F", &ShutdownMgmtLocal, NULL, NULL},
+    {"shutdown", 'S', "Shutdown traffic_server (local node)", "F", &Shutdown, NULL, NULL},
+    {"startup", 'U', "Start traffic_server (local node)", "F", &Startup, NULL, NULL},
+    {"bounce_cluster", 'B', "Bounce traffic_server (cluster wide)", "F", &BounceCluster, NULL, NULL},
+    {"bounce_local", 'b', "Bounce local traffic_server", "F", &BounceLocal, NULL, NULL},
+    {"clear_cluster", 'C', "Clear Statistics (cluster wide)", "F", &ClearCluster, NULL, NULL},
+    {"clear_node", 'c', "Clear Statistics (local node)", "F", &ClearNode, NULL, NULL},
+    {"zero_cluster", 'Z', "Zero Specific Statistic (cluster wide)", "S1024", &ZeroCluster, NULL, NULL},
+    {"zero_node", 'z', "Zero Specific Statistic (local node)", "S1024", &ZeroNode, NULL, NULL},
+    {"version", 'V', "Print Version Id", "T", &VersionFlag, NULL, NULL},
+  };
+
+  // Process command line arguments and dump into variables
+  process_args(argument_descriptions, countof(argument_descriptions), argv);
+
+  // check for the version number request
+  if (VersionFlag) {
+    ink_fputln(stderr, appVersionInfo.FullVersionInfoStr);
+    exit(0);
+  }
+
+  // Connect to Local Manager and do it.
+  if (TS_ERR_OKAY != TSInit(NULL, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS | TS_MGMT_OPT_NO_SOCK_TESTS))) {
+    fprintf(stderr, "error: could not connect to management port, make sure traffic_manager is running\n");
+    exit(1);
+  }
+    
+  status = handleArgInvocation();
+
+  // Done with the mgmt API.
+  TSTerminate();
+
+  if (TS_ERR_OKAY != status) {
+    if (ReadVar[0] == '\0' && SetVar[0] == '\0')
+      fprintf(stderr, "error: the requested command failed\n");
+    exit(1);
+  }
+
+  exit(0);
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c83e1d84/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index ef218c3..fe77e8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1843,6 +1843,7 @@ AC_CONFIG_FILES([
   Makefile
   cmd/Makefile
   cmd/traffic_cop/Makefile
+  cmd/traffic_line/Makefile
   cmd/traffic_top/Makefile
   doc/Doxyfile
   doc/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c83e1d84/mgmt/cli/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/cli/Makefile.am b/mgmt/cli/Makefile.am
index 14c893e..b92caa2 100644
--- a/mgmt/cli/Makefile.am
+++ b/mgmt/cli/Makefile.am
@@ -25,8 +25,7 @@ AM_CPPFLAGS = \
   -I$(top_srcdir)/lib/ts \
   -I$(top_srcdir)/mgmt/api/include
 
-
-bin_PROGRAMS = traffic_shell traffic_line
+bin_PROGRAMS = traffic_shell
 traffic_shell_SOURCES = \
   cliAppInit.cc \
   CliCreateCommands.h \
@@ -39,9 +38,6 @@ traffic_shell_SOURCES = \
   hashtable.h \
   ShowCmd.h
 
-traffic_line_SOURCES = \
-  TrafficLine.cc
-
 noinst_LIBRARIES = libtrafficshell.a
 libtrafficshell_a_SOURCES = \
   CliCreateCommands.cc \
@@ -80,9 +76,3 @@ traffic_shell_LDADD = \
   @LIBRESOLV@ @LIBEXPAT@ @LIBSSL@ \
   @LIBPCRE@ @LIBREADLINE@ \
   -lm
-
-traffic_line_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
-traffic_line_LDADD = \
-  $(top_builddir)/mgmt/api/libtsmgmt.la \
-  $(top_builddir)/lib/ts/libtsutil.la \
-  @LIBRESOLV@ @LIBTCL@ @LIBSSL@

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c83e1d84/mgmt/cli/TrafficLine.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/TrafficLine.cc b/mgmt/cli/TrafficLine.cc
deleted file mode 100644
index 7f99f5b..0000000
--- a/mgmt/cli/TrafficLine.cc
+++ /dev/null
@@ -1,218 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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 "libts.h"
-
-#include "ink_args.h"
-#include "I_Version.h"
-#include "Tokenizer.h"
-#include "TextBuffer.h"
-#include "mgmtapi.h"
-
-static const char *programName;
-
-static char ReadVar[1024];
-static char SetVar[1024];
-static char VarValue[1024];
-static int ReRead;
-static int Shutdown;
-static int BounceCluster;
-static int BounceLocal;
-static int QueryDeadhosts;
-static int Startup;
-static int ShutdownMgmtCluster;
-static int ShutdownMgmtLocal;
-static int ClearCluster;
-static int ClearNode;
-static char ZeroCluster[1024];
-static char ZeroNode[1024];
-static int VersionFlag;
-
-static TSError
-handleArgInvocation()
-{
-  if (ReRead == 1) {
-    return TSReconfigure();
-  } else if (ShutdownMgmtCluster == 1) {
-    return TSRestart(true);
-  } else if (ShutdownMgmtLocal == 1) {
-    return TSRestart(false);
-  } else if (Shutdown == 1) {
-    return TSProxyStateSet(TS_PROXY_OFF, TS_CACHE_CLEAR_OFF);
-  } else if (BounceCluster == 1) {
-    return TSBounce(true);
-  } else if (BounceLocal == 1) {
-    return TSBounce(false);
-  } else if (Startup == 1) {
-    return TSProxyStateSet(TS_PROXY_ON, TS_CACHE_CLEAR_OFF);
-  } else if (ClearCluster == 1) {
-    return TSStatsReset(true);
-  } else if (ClearNode == 1) {
-    return TSStatsReset(false);
-  } else if (*ZeroNode != '\0' || *ZeroCluster != '\0') {
-    TSError err;
-    TSRecordEle *rec_ele = TSRecordEleCreate();
-    char *name = *ZeroNode ? ZeroNode : ZeroCluster;
-    if ((err = TSRecordGet(name, rec_ele)) != TS_ERR_OKAY) {
-      fprintf(stderr, "%s: %s\n", programName, TSGetErrorMessage(err));
-      TSRecordEleDestroy(rec_ele);
-      return err;
-    }
-    TSRecordEleDestroy(rec_ele);
-    return TSStatsReset(*ZeroCluster ? true : false, name);
-  } else if (QueryDeadhosts == 1) {
-    fprintf(stderr, "Query Deadhosts is not implemented, it requires support for congestion control.\n");
-    fprintf(stderr, "For more details, examine the old code in cli/CLI.cc: QueryDeadhosts()\n");
-    return TS_ERR_FAIL;
-  } else if (*ReadVar != '\0') {        // Handle a value read
-    if (*SetVar != '\0' || *VarValue != '\0') {
-      fprintf(stderr, "%s: Invalid Argument Combination: Can not read and set values at the same time\n", programName);
-      return TS_ERR_FAIL;
-    } else {
-      TSError err;
-      TSRecordEle *rec_ele = TSRecordEleCreate();
-
-      if ((err = TSRecordGet(ReadVar, rec_ele)) != TS_ERR_OKAY) {
-        fprintf(stderr, "%s: %s\n", programName, TSGetErrorMessage(err));
-      } else {
-        switch (rec_ele->rec_type) {
-        case TS_REC_INT:
-          printf("%" PRId64 "\n", rec_ele->int_val);
-          break;
-        case TS_REC_COUNTER:
-          printf("%" PRId64 "\n", rec_ele->counter_val);
-          break;
-        case TS_REC_FLOAT:
-          printf("%f\n", rec_ele->float_val);
-          break;
-        case TS_REC_STRING:
-          printf("%s\n", rec_ele->string_val);
-          break;
-        default:
-          fprintf(stderr, "%s: unknown record type (%d)\n", programName, rec_ele->rec_type);
-          err = TS_ERR_FAIL;
-          break;
-        }
-      }
-      TSRecordEleDestroy(rec_ele);
-      return err;
-    }
-  } else if (*SetVar != '\0') { // Setting a variable
-    if (*VarValue == '\0') {
-      fprintf(stderr, "%s: Set requires a -v argument\n", programName);
-      return TS_ERR_FAIL;
-    } else {
-      TSError err;
-      TSActionNeedT action;
-
-      if ((err = TSRecordSet(SetVar, VarValue, &action)) != TS_ERR_OKAY)
-        fprintf(stderr, "%s: Please correct your variable name and|or value\n", programName);
-      return err;
-    }
-  } else if (*VarValue != '\0') {       // We have a value but no variable to set
-    fprintf(stderr, "%s: Must specify variable to set with -s when using -v\n", programName);
-    return TS_ERR_FAIL;
-  }
-
-  fprintf(stderr, "%s: No arguments specified\n", programName);
-  return TS_ERR_FAIL;
-}
-
-int
-main(int /* argc ATS_UNUSED */, char **argv)
-{
-  AppVersionInfo appVersionInfo;
-  TSError status;
-
-  programName = argv[0];
-
-  ReadVar[0] = '\0';
-  SetVar[0] = '\0';
-  VarValue[0] = '\0';
-  ReRead = 0;
-  Shutdown = 0;
-  BounceCluster = 0;
-  BounceLocal = 0;
-  QueryDeadhosts = 0;
-  Startup = 0;
-  ShutdownMgmtCluster = 0;
-  ShutdownMgmtLocal = 0;
-  ClearCluster = 0;
-  ClearNode = 0;
-  ZeroCluster[0] = '\0';
-  ZeroNode[0] = '\0';
-  VersionFlag = 0;
-
-  // build the application information structure
-  appVersionInfo.setup(PACKAGE_NAME,"traffic_line", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
-
-/* Argument description table used to describe how to parse command line args, */
-/* see 'ink_args.h' for meanings of the various fields */
-  ArgumentDescription argument_descriptions[] = {
-    {"query_deadhosts", 'q', "Query congested sites", "F", &QueryDeadhosts, NULL, NULL},
-    {"read_var", 'r', "Read Variable", "S1024", &ReadVar, NULL, NULL},
-    {"set_var", 's', "Set Variable (requires -v option)", "S1024", &SetVar, NULL, NULL},
-    {"value", 'v', "Set Value (used with -s option)", "S1024", &VarValue, NULL, NULL},
-    {"help", 'h', "Help", NULL, NULL, NULL, usage},
-    {"reread_config", 'x', "Reread Config Files", "F", &ReRead, NULL, NULL},
-    {"restart_cluster", 'M', "Restart traffic_manager (cluster wide)", "F", &ShutdownMgmtCluster, NULL, NULL},
-    {"restart_local", 'L', "Restart traffic_manager (local node)", "F", &ShutdownMgmtLocal, NULL, NULL},
-    {"shutdown", 'S', "Shutdown traffic_server (local node)", "F", &Shutdown, NULL, NULL},
-    {"startup", 'U', "Start traffic_server (local node)", "F", &Startup, NULL, NULL},
-    {"bounce_cluster", 'B', "Bounce traffic_server (cluster wide)", "F", &BounceCluster, NULL, NULL},
-    {"bounce_local", 'b', "Bounce local traffic_server", "F", &BounceLocal, NULL, NULL},
-    {"clear_cluster", 'C', "Clear Statistics (cluster wide)", "F", &ClearCluster, NULL, NULL},
-    {"clear_node", 'c', "Clear Statistics (local node)", "F", &ClearNode, NULL, NULL},
-    {"zero_cluster", 'Z', "Zero Specific Statistic (cluster wide)", "S1024", &ZeroCluster, NULL, NULL},
-    {"zero_node", 'z', "Zero Specific Statistic (local node)", "S1024", &ZeroNode, NULL, NULL},
-    {"version", 'V', "Print Version Id", "T", &VersionFlag, NULL, NULL},
-  };
-
-  // Process command line arguments and dump into variables
-  process_args(argument_descriptions, countof(argument_descriptions), argv);
-
-  // check for the version number request
-  if (VersionFlag) {
-    ink_fputln(stderr, appVersionInfo.FullVersionInfoStr);
-    exit(0);
-  }
-
-  // Connect to Local Manager and do it.
-  if (TS_ERR_OKAY != TSInit(NULL, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS | TS_MGMT_OPT_NO_SOCK_TESTS))) {
-    fprintf(stderr, "error: could not connect to management port, make sure traffic_manager is running\n");
-    exit(1);
-  }
-    
-  status = handleArgInvocation();
-
-  // Done with the mgmt API.
-  TSTerminate();
-
-  if (TS_ERR_OKAY != status) {
-    if (ReadVar[0] == '\0' && SetVar[0] == '\0')
-      fprintf(stderr, "error: the requested command failed\n");
-    exit(1);
-  }
-
-  exit(0);
-}


[35/44] git commit: TS-2374: abort the producer to avoid httpsm hung if none of it`s consumer is alive.

Posted by zw...@apache.org.
TS-2374: abort the producer to avoid httpsm hung if none of it`s
consumer is alive.


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

Branch: refs/heads/5.0.x
Commit: ae51d4ed7b1bf4e162b2c26819b5a88c5cf9ece4
Parents: 9f05ebe
Author: weijin <ta...@taobao.com>
Authored: Thu Nov 21 11:18:42 2013 +0800
Committer: weijin <ta...@taobao.com>
Committed: Thu Nov 21 11:23:25 2013 +0800

----------------------------------------------------------------------
 CHANGES              | 2 ++
 proxy/http/HttpSM.cc | 3 +++
 2 files changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ae51d4ed/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 24a9ac5..445a6c3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2374] Abort the producer if the none of it`s consumers is alive.
+
   *) [TS-2327] TSRedirectUrlSet does not perform DNS lookup of redirected OS
 
   *) [TS-1468] Check vary and accept headers on non-200 responses in cache

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ae51d4ed/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index a957bcb..503ac9b 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -3249,6 +3249,9 @@ HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer * c)
 
     HTTP_INCREMENT_TRANS_STAT(http_cache_write_errors);
     DebugSM("http", "[%" PRId64 "] aborting cache write due %s event from cache", sm_id, HttpDebugNames::get_event_name(event));
+    // abort the producer if the cache_writevc is the only consumer.
+    if (c->producer->alive && c->producer->num_consumers == 1)
+      tunnel.chain_abort_all(c->producer);
     break;
   case VC_EVENT_WRITE_COMPLETE:
     // if we've never initiated a cache write


[40/44] git commit: convert CRLF->LF, make sure it never happens again

Posted by zw...@apache.org.
convert CRLF->LF, make sure it never happens again

we add a git attributes to make sure that text files are stored
git-internally as LF. This way we avoid conflicts betweent Unix and
Windows (yes, some of our developers sometimes use Windows).

Additionally, I remove the executable flag from files that don't need to
be executed.


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

Branch: refs/heads/5.0.x
Commit: 70c70cafe6c7d11504a5fb08e72a1947a0a87f55
Parents: 0c6c25e
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Nov 21 18:01:47 2013 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Nov 21 18:07:02 2013 +0100

----------------------------------------------------------------------
 .gitattributes                                  |    1 +
 doc/arch/cache/cache-api.en.rst                 |   84 +-
 doc/arch/cache/cache-appendix.en.rst            |  194 +--
 doc/arch/cache/cache-arch.en.rst                | 1596 +++++++++---------
 doc/arch/cache/cache-data-structures.en.rst     |  328 ++--
 .../cache/images/ats-cache-write-cursor.png     |  Bin
 .../cache/images/cache-directory-structure.png  |  Bin
 .../cache/images/cache-doc-layout-3-2-0.png     |  Bin
 .../cache/images/cache-doc-layout-4-0-1.png     |  Bin
 doc/arch/cache/images/cache-multi-fragment.png  |  Bin
 doc/arch/cache/images/cache-stripe-layout.png   |  Bin
 doc/arch/cache/images/dir-bucket-assign.png     |  Bin
 doc/arch/cache/images/dir-segment-bucket.png    |  Bin
 doc/arch/cache/tier-storage.en.rst              |  236 +--
 14 files changed, 1220 insertions(+), 1219 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/.gitattributes
----------------------------------------------------------------------
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/cache-api.en.rst
----------------------------------------------------------------------
diff --git a/doc/arch/cache/cache-api.en.rst b/doc/arch/cache/cache-api.en.rst
old mode 100755
new mode 100644
index ebdf372..7a9963e
--- a/doc/arch/cache/cache-api.en.rst
+++ b/doc/arch/cache/cache-api.en.rst
@@ -1,42 +1,42 @@
-.. 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:: common.defs
-
-===========================
-Cache Related API functions
-===========================
-
-.. c:function:: void TSHttpTxnReqCacheableSet(TSHttpTxn txnp, int flag)
-
-   Set a *flag* that marks a request as cacheable. This is a positive override only, setting *flag* to 0 restores the default behavior, it does not force the request to be uncacheable.
-
-.. c:function:: TSReturnCode TSCacheUrlSet(TSHttpTxn txnp, char const* url, int length)
-
-  Set the cache key for the transaction *txnp* as the string pointed at by *url* of *length* characters. It need not be ``null`` terminated. This should be called from ``TS_HTTP_READ_REQUEST_HDR_HOOK`` which is before cache lookup but late enough that the HTTP request header is available.
-
-===============
-Cache Internals
-===============
-
-.. cpp:function::    int DIR_SIZE_WITH_BLOCK(int big)
-
-   A preprocessor macro which computes the maximum size of a fragment based on the value of *big*. This is computed as if the argument where the value of the *big* field in a struct :cpp:class:`Dir`.
-
-.. cpp:function::    int DIR_BLOCK_SIZE(int big)
-
-   A preprocessor macro which computes the block size multiplier for a struct :cpp:class:`Dir` where *big* is the *big* field value.
+.. 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:: common.defs
+
+===========================
+Cache Related API functions
+===========================
+
+.. c:function:: void TSHttpTxnReqCacheableSet(TSHttpTxn txnp, int flag)
+
+   Set a *flag* that marks a request as cacheable. This is a positive override only, setting *flag* to 0 restores the default behavior, it does not force the request to be uncacheable.
+
+.. c:function:: TSReturnCode TSCacheUrlSet(TSHttpTxn txnp, char const* url, int length)
+
+  Set the cache key for the transaction *txnp* as the string pointed at by *url* of *length* characters. It need not be ``null`` terminated. This should be called from ``TS_HTTP_READ_REQUEST_HDR_HOOK`` which is before cache lookup but late enough that the HTTP request header is available.
+
+===============
+Cache Internals
+===============
+
+.. cpp:function::    int DIR_SIZE_WITH_BLOCK(int big)
+
+   A preprocessor macro which computes the maximum size of a fragment based on the value of *big*. This is computed as if the argument where the value of the *big* field in a struct :cpp:class:`Dir`.
+
+.. cpp:function::    int DIR_BLOCK_SIZE(int big)
+
+   A preprocessor macro which computes the block size multiplier for a struct :cpp:class:`Dir` where *big* is the *big* field value.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/cache-appendix.en.rst
----------------------------------------------------------------------
diff --git a/doc/arch/cache/cache-appendix.en.rst b/doc/arch/cache/cache-appendix.en.rst
old mode 100755
new mode 100644
index a4c247b..9a27d43
--- a/doc/arch/cache/cache-appendix.en.rst
+++ b/doc/arch/cache/cache-appendix.en.rst
@@ -1,97 +1,97 @@
-.. 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:: common.defs
-
-Cache Tools
-~~~~~~~~~~~
-
-Tools and techniques for cache monitoring and inspection.
-
-* :ref:`The cache inspector <inspecting-the-cache>`.
-
-Topics to be done
-~~~~~~~~~~~~~~~~~
-
-* Resident alternates
-* Object refresh
-
-Cache Consistency
-~~~~~~~~~~~~~~~~~
-
-The cache is completely consistent, up to and including kicking the power cord out, if the write buffer on consumer disk drives is disabled. You need to use::
-
-  hdparm -W0
-
-The cache validates that all the data for the document is available and will silently mark a partial document as a "miss" on read. There is no "gentle" shutdown for traffic server, you just kill the process, so the "recovery" code (fsck) is run every time traffic server starts up.
-
-On startup the two versions of the index are checked, and the last valid one is read into memory. Then traffic server moves forward from the last snapped write cursor and reads all the fragments written to disk, and updates the directory (as in a log-based file system). It stops reading at the write before the last valid write header it sees (as a write is not necessarily atomic because of sector reordering). Then the new updated index is written to the invalid version (in case of a crash during startup) and the system starts.
-
-.. _volume tagging:
-
-Volume Tagging
-~~~~~~~~~~~~~~
-
-Currently cache volumes are allocated somewhat arbitrarily from storage elements. `This enhancement <https://issues.apache.org/jira/browse/TS-1728>`__ allows the :file:`storage.config` file to assign storage units to specific volumes although the volumes must still be listed in :file:`volume.config` in general and in particular to map domains to specific volumes. A primary use case for this is to be able to map specific types of content to different storage elements. This could to have different storage devices for the content (SSD vs. rotational).
-
----------------
-Version Upgrade
----------------
-
-It is currently the case that any change to the cache format will clear the cache. This is an issue when upgrading the |TS| version and should be kept in mind.
-
-.. cache-key:
-
--------------------------
-Controlling the cache key
--------------------------
-
-The cache key is by default the URL of the request. There are two possible choices, the original ("pristine") URL and the remapped URL. Which of these is used is determined by the configuration value  :ts:cv:`proxy.config.url_remap.pristine_host_hdr`.
-
-This is an ``INT`` value. If set to ``0`` (disabled) then the remapped URL is used, and if it is not ``0`` (enabled) then the original URL is used. This setting also controls the value of the ``HOST`` header that is placed in the request sent to the origin server, using hostname from the original URL if non-``0`` and the host name from the remapped URL if ``0``. It has no other effects.
-
-For caching, this setting is irrelevant if no remapping is done or there is a one to one mapping between the original and remapped URLs.
-
-It becomes significant if multiple original URLs are mapped to the same remapped URL. If pristine headers are enabled requests to different original URLs will be stored as distinct objects in the cache. If disabled the remapped URL will be used and there may be collisions. This is bad if the contents different but quite useful if they are the same (e.g., the original URLs are just aliases for the same underlying server).
-
-This is also an issue if a remapping is changed because it is effectively a time axis version of the previous case. If an original URL is remapped to a different server address then the setting determines if existing cached objects will be served for new requests (enabled) or not (disabled). Similarly if the original URL mapped to a particular URL is changed then cached objects from the initial original URL will be served from the updated original URL if pristine headers is disabled.
-
-These collisions are not of themselves good or bad. An administrator needs to decide which is appropriate for his situation and set the value correspondingly.
-
-If a greater degree of control is desired a plugin must used to invoke the API call :c:func:`TSCacheUrlSet()` to provide a specific cache key.
-
-A plugin that changes the cache key *must* do so consistently for both cache hit and cache miss requests because two different requests that map to the same cache key will be considered equivalent by the cache. Use of the URL directly provides this and so must any substitute. This is entirely the responsibility of the plugin, there is no way for the |TS| core to detect such an occurrence.
-
-It is a requirement that the string be syntactically a URL but otherwise it is completely arbitrary and need not have any path. For instance if the company Network Geographics wanted to store certain content under its own cache key, using a document GUID as part of the key, it could use a cache key like ::
-
-   ngeo://W39WaGTPnvg
-
-The scheme ``ngeo`` was picked because it is *not* a valid URL scheme and so will not collide with any valid URL.
-
-This can be useful if the URL encodes both important and unimportant data. Instead of storing potentially identical content under different URLs (because they differ on the unimportant parts) a url containing only the important parts could be created and used.
-
-For example, suppose the URL for Network Geographics content encoded both the document GUID and a referral key. ::
-
-   http://network-geographics-farm-1.com/doc/W39WaGTPnvg.2511635.UQB_zCc8B8H
-
-We don't want to the same content for every possible referrer. Instead we could use a plugin to convert this to the previous example and requests that differed only in the referrer key would all reference the same cache entry. Note that we would also map ::
-
-   http://network-geographics-farm-56.com/doc/W39WaGTPnvg.2511635.UQB_zCc8B8H
-
-to the same cache key. This can be handy for "sharing" content between servers when that content is identical. Note also the plugin can change the cache key or not depending on any data in the request header, for instance not changing the cache key if the request is not in the ``doc`` directory. If distinguishing servers is important that can easily be pulled from the request URL and used in the synthetic cache key. The implementor is free to extract all relevant elements for use in the cache key.
-
-While there is explicit no requirement that the synthetic cache key be based on the HTTP request header, in practice it is generally necessary due to the consistency requirement. Because cache lookup happens before attempting to connect to the origin server no data from the HTTP response header is available, leaving only the request header. The most common case is the one described above where the goal is to elide elements of the URL that do not affect the content to minimize cache footprint and improve cache hit rates.
+.. 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:: common.defs
+
+Cache Tools
+~~~~~~~~~~~
+
+Tools and techniques for cache monitoring and inspection.
+
+* :ref:`The cache inspector <inspecting-the-cache>`.
+
+Topics to be done
+~~~~~~~~~~~~~~~~~
+
+* Resident alternates
+* Object refresh
+
+Cache Consistency
+~~~~~~~~~~~~~~~~~
+
+The cache is completely consistent, up to and including kicking the power cord out, if the write buffer on consumer disk drives is disabled. You need to use::
+
+  hdparm -W0
+
+The cache validates that all the data for the document is available and will silently mark a partial document as a "miss" on read. There is no "gentle" shutdown for traffic server, you just kill the process, so the "recovery" code (fsck) is run every time traffic server starts up.
+
+On startup the two versions of the index are checked, and the last valid one is read into memory. Then traffic server moves forward from the last snapped write cursor and reads all the fragments written to disk, and updates the directory (as in a log-based file system). It stops reading at the write before the last valid write header it sees (as a write is not necessarily atomic because of sector reordering). Then the new updated index is written to the invalid version (in case of a crash during startup) and the system starts.
+
+.. _volume tagging:
+
+Volume Tagging
+~~~~~~~~~~~~~~
+
+Currently cache volumes are allocated somewhat arbitrarily from storage elements. `This enhancement <https://issues.apache.org/jira/browse/TS-1728>`__ allows the :file:`storage.config` file to assign storage units to specific volumes although the volumes must still be listed in :file:`volume.config` in general and in particular to map domains to specific volumes. A primary use case for this is to be able to map specific types of content to different storage elements. This could to have different storage devices for the content (SSD vs. rotational).
+
+---------------
+Version Upgrade
+---------------
+
+It is currently the case that any change to the cache format will clear the cache. This is an issue when upgrading the |TS| version and should be kept in mind.
+
+.. cache-key:
+
+-------------------------
+Controlling the cache key
+-------------------------
+
+The cache key is by default the URL of the request. There are two possible choices, the original ("pristine") URL and the remapped URL. Which of these is used is determined by the configuration value  :ts:cv:`proxy.config.url_remap.pristine_host_hdr`.
+
+This is an ``INT`` value. If set to ``0`` (disabled) then the remapped URL is used, and if it is not ``0`` (enabled) then the original URL is used. This setting also controls the value of the ``HOST`` header that is placed in the request sent to the origin server, using hostname from the original URL if non-``0`` and the host name from the remapped URL if ``0``. It has no other effects.
+
+For caching, this setting is irrelevant if no remapping is done or there is a one to one mapping between the original and remapped URLs.
+
+It becomes significant if multiple original URLs are mapped to the same remapped URL. If pristine headers are enabled requests to different original URLs will be stored as distinct objects in the cache. If disabled the remapped URL will be used and there may be collisions. This is bad if the contents different but quite useful if they are the same (e.g., the original URLs are just aliases for the same underlying server).
+
+This is also an issue if a remapping is changed because it is effectively a time axis version of the previous case. If an original URL is remapped to a different server address then the setting determines if existing cached objects will be served for new requests (enabled) or not (disabled). Similarly if the original URL mapped to a particular URL is changed then cached objects from the initial original URL will be served from the updated original URL if pristine headers is disabled.
+
+These collisions are not of themselves good or bad. An administrator needs to decide which is appropriate for his situation and set the value correspondingly.
+
+If a greater degree of control is desired a plugin must used to invoke the API call :c:func:`TSCacheUrlSet()` to provide a specific cache key.
+
+A plugin that changes the cache key *must* do so consistently for both cache hit and cache miss requests because two different requests that map to the same cache key will be considered equivalent by the cache. Use of the URL directly provides this and so must any substitute. This is entirely the responsibility of the plugin, there is no way for the |TS| core to detect such an occurrence.
+
+It is a requirement that the string be syntactically a URL but otherwise it is completely arbitrary and need not have any path. For instance if the company Network Geographics wanted to store certain content under its own cache key, using a document GUID as part of the key, it could use a cache key like ::
+
+   ngeo://W39WaGTPnvg
+
+The scheme ``ngeo`` was picked because it is *not* a valid URL scheme and so will not collide with any valid URL.
+
+This can be useful if the URL encodes both important and unimportant data. Instead of storing potentially identical content under different URLs (because they differ on the unimportant parts) a url containing only the important parts could be created and used.
+
+For example, suppose the URL for Network Geographics content encoded both the document GUID and a referral key. ::
+
+   http://network-geographics-farm-1.com/doc/W39WaGTPnvg.2511635.UQB_zCc8B8H
+
+We don't want to the same content for every possible referrer. Instead we could use a plugin to convert this to the previous example and requests that differed only in the referrer key would all reference the same cache entry. Note that we would also map ::
+
+   http://network-geographics-farm-56.com/doc/W39WaGTPnvg.2511635.UQB_zCc8B8H
+
+to the same cache key. This can be handy for "sharing" content between servers when that content is identical. Note also the plugin can change the cache key or not depending on any data in the request header, for instance not changing the cache key if the request is not in the ``doc`` directory. If distinguishing servers is important that can easily be pulled from the request URL and used in the synthetic cache key. The implementor is free to extract all relevant elements for use in the cache key.
+
+While there is explicit no requirement that the synthetic cache key be based on the HTTP request header, in practice it is generally necessary due to the consistency requirement. Because cache lookup happens before attempting to connect to the origin server no data from the HTTP response header is available, leaving only the request header. The most common case is the one described above where the goal is to elide elements of the URL that do not affect the content to minimize cache footprint and improve cache hit rates.


[10/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/cli/Makefile.am b/mgmt/cli/Makefile.am
deleted file mode 100644
index b92caa2..0000000
--- a/mgmt/cli/Makefile.am
+++ /dev/null
@@ -1,78 +0,0 @@
-#
-# 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.
-
-SUFFIXES = .java .class .jar .my .def .stb .html
-
-AM_CPPFLAGS = \
-  $(iocore_include_dirs) \
-  -I$(top_srcdir)/lib \
-  -I$(top_srcdir)/lib/ts \
-  -I$(top_srcdir)/mgmt/api/include
-
-bin_PROGRAMS = traffic_shell
-traffic_shell_SOURCES = \
-  cliAppInit.cc \
-  CliCreateCommands.h \
-  cliMain.cc \
-  CliMgmtUtils.h \
-  ConfigCmd.h \
-  createArgument.h \
-  createCommand.h \
-  definitions.h \
-  hashtable.h \
-  ShowCmd.h
-
-noinst_LIBRARIES = libtrafficshell.a
-libtrafficshell_a_SOURCES = \
-  CliCreateCommands.cc \
-  CliCreateCommands.h \
-  CliDisplay.cc \
-  CliDisplay.h \
-  CliMgmtUtils.cc \
-  CliMgmtUtils.h \
-  cliParseArg.cc \
-  commandOptions.h \
-  ConfigCmd.cc \
-  ConfigCmd.h \
-  ConfigUpgradeCmd.h \
-  ConfigUpgradeReadCmd.cc \
-  ConfigUpgradeWriteCmd.cc \
-  createArgument.cc \
-  createArgument.h \
-  createCommand.cc \
-  createCommand.h \
-  definitions.h \
-  hashtable.cc \
-  hashtable.h \
-  processArgument.cc \
-  ShowCmd.cc \
-  ShowCmd.h \
-  UtilCmds.cc \
-  UtilCmds.h
-
-traffic_shell_LDFLAGS =	@EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
-traffic_shell_LDADD = \
-  libtrafficshell.a \
-  $(top_builddir)/mgmt/api/libtsmgmt.la \
-  $(top_builddir)/mgmt/utils/libutils_lm.a \
-  $(top_builddir)/lib/ts/libtsutil.la \
-  $(LIBTCL) $(LIBREADLINE) \
-  @LIBRESOLV@ @LIBEXPAT@ @LIBSSL@ \
-  @LIBPCRE@ @LIBREADLINE@ \
-  -lm

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/ShowCmd.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/ShowCmd.cc b/mgmt/cli/ShowCmd.cc
deleted file mode 100644
index ed71560..0000000
--- a/mgmt/cli/ShowCmd.cc
+++ /dev/null
@@ -1,2322 +0,0 @@
-/** @file
-
-  This file contains the "show" command implementation.
-
-  @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 <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include "ShowCmd.h"
-#include "ConfigCmd.h"
-#include "createArgument.h"
-#include "CliMgmtUtils.h"
-#include "CliDisplay.h"
-#include "ink_defs.h"
-#include "ink_string.h"
-
-////////////////////////////////////////////////////////////////
-// Cmd_Show
-//
-// This is the callback function for the "show" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_Show(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  char *cmdinfo, *temp;
-  int i = 0;
-  Cli_Debug("Cmd_Show\n");
-  Tcl_Eval(interp, "info commands show* ");
-
-  int cmdinfo_size = sizeof(char) * (strlen(Tcl_GetStringResult(interp)) + 2);
-  cmdinfo = (char *)alloca(cmdinfo_size);
-  ink_strlcpy(cmdinfo, Tcl_GetStringResult(interp), cmdinfo_size);
-  int temp_size = sizeof(char) * (strlen(cmdinfo) + 20);
-  temp = (char *)alloca(temp_size);
-  ink_strlcpy(temp, "lsort \"", temp_size);
-  ink_strlcat(temp, cmdinfo, temp_size);
-  ink_strlcat(temp, "\"", temp_size);
-  Tcl_Eval(interp, temp);
-  ink_strlcpy(cmdinfo, Tcl_GetStringResult(interp), cmdinfo_size);
-  i = i + strlen("show ");
-  while (cmdinfo[i] != 0) {
-    if (cmdinfo[i] == ' ') {
-      cmdinfo[i] = '\n';
-    }
-    i++;
-  }
-  cmdinfo[i] = '\n';
-  i++;
-  cmdinfo[i] = 0;
-  Cli_Printf("Following are the available show commands\n");
-  Cli_Printf(cmdinfo + strlen("show "));
-
-  return 0;
-
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowStatus
-//
-// This is the callback function for the "show:status" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowStatus(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowStatus\n");
-
-  return (ShowStatus());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowVersion
-//
-// This is the callback function for the "show:version" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowVersion(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowVersion\n");
-
-  return (ShowVersion());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowPorts
-//
-// This is the callback function for the "show:ports" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowPorts(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowPorts\n");
-
-  return (ShowPorts());
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowCluster
-//
-// This is the callback function for the "show:security" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowCluster(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowCluster\n");
-
-  return (ShowCluster());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowSecurity
-//
-// This is the callback function for the "show:security" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowSecurity(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowSecurity\n");
-
-  return (ShowSecurity());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowHttp
-//
-// This is the callback function for the "show:http" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowHttp(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowHttp\n");
-
-  return (ShowHttp());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowIcp
-//
-// This is the callback function for the "show:icp" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowIcp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowIcp argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
-    if (argtable[0].parsed_args == CMD_SHOW_ICP_PEER) {
-      return (ShowIcpPeer());
-    }
-    Cli_Error(ERR_INVALID_COMMAND);
-    return CMD_ERROR;
-  }
-  return (ShowIcp());
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ShowIcp
-//
-// Register "show:icp" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ShowIcp()
-{
-  createArgument("peers", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_SHOW_ICP_PEER, "ICP Peer Configuration", (char *) NULL);
-
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowProxy
-//
-// This is the callback function for the "show:proxy" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowProxy(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowProxy\n");
-
-  return (ShowProxy());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowCache
-//
-// This is the callback function for the "show:cache" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowCache(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowCache\n");
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
-    if (argtable[0].parsed_args == CMD_SHOW_CACHE_RULES) {
-      return (ShowCacheRules());
-    } else if (argtable[0].parsed_args == CMD_SHOW_CACHE_STORAGE) {
-      return (ShowCacheStorage());
-    }
-
-    Cli_Error(ERR_INVALID_COMMAND);
-    return CMD_ERROR;
-  }
-  return (ShowCache());
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ShowCache
-//
-// Register "show:cache" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ShowCache()
-{
-  createArgument("rules", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_SHOW_CACHE_RULES, "Rules from cache.config", (char *) NULL);
-  createArgument("storage", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_SHOW_CACHE_STORAGE, "Rules from storage.config", (char *) NULL);
-
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowVirtualIp
-//
-// This is the callback function for the "show:virtual-ip" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowVirtualIp(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowVirtualIp\n");
-
-  return (ShowVirtualIp());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowHostDb
-//
-// This is the callback function for the "show:hostdb" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowHostDb(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowHostDb\n");
-
-  return (ShowHostDb());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowDnsResolver
-//
-// This is the callback function for the "show:dns-resolver" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowDnsResolver(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowDnsResolver\n");
-
-  return (ShowDnsResolver());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowLogging
-//
-// This is the callback function for the "show:logging" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowLogging(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowLogging\n");
-
-  return (ShowLogging());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowSsl
-//
-// This is the callback function for the "show:ssl" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowSsl(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowSsl\n");
-
-  return (ShowSsl());
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowParents
-//
-// This is the callback function for the "show:parents" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowParents(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowParents\n");
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
-    if (argtable[0].parsed_args == CMD_SHOW_PARENT_RULES) {
-      return (ShowParentRules());
-    }
-
-    Cli_Error(ERR_INVALID_COMMAND);
-    return CMD_ERROR;
-  }
-
-  return (ShowParents());
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ShowParents
-//
-// Register "show:parents" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ShowParents()
-{
-  createArgument("rules", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_SHOW_PARENT_RULES, "Display parent.config rules file", (char *) NULL);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowRemap
-//
-// This is the callback function for the "show:remap" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowRemap(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowRemap\n");
-
-  return (ShowRemap());
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowSocks
-//
-// This is the callback function for the "show:socks" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowSocks(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowSocks\n");
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
-    if (argtable[0].parsed_args == CMD_SHOW_SOCKS_RULES) {
-      return (ShowSocksRules());
-    }
-
-    Cli_Error(ERR_INVALID_COMMAND);
-    return CMD_ERROR;
-  }
-
-  return (ShowSocks());
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ShowSocks
-//
-// Register "show:socks" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ShowSocks()
-{
-  createArgument("rules", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_SHOW_SOCKS_RULES, "Display socks.config rules file", (char *) NULL);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowScheduledUpdate
-//
-// This is the callback function for the "show:scheduled-update" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowScheduledUpdate(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowScheduledUpdate\n");
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
-    if (argtable[0].parsed_args == CMD_SHOW_UPDATE_RULES) {
-      return (ShowScheduledUpdateRules());
-    }
-
-    Cli_Error(ERR_INVALID_COMMAND);
-    return CMD_ERROR;
-  }
-
-  return (ShowScheduledUpdate());
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ShowScheduledUpdate
-//
-// Register "show:scheduled-update" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ShowScheduledUpdate()
-{
-  createArgument("rules", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_SHOW_UPDATE_RULES, "Display update.config rules file", (char *) NULL);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowProxyStats
-//
-// This is the callback function for the "show:proxy-stats" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowProxyStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowProxyStats\n");
-
-  return (ShowProxyStats());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowHttpTransStats
-//
-// This is the callback function for the "show:http-trans-stats" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowHttpTransStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowHttpTransStats\n");
-
-  return (ShowHttpTransStats());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowHttpStats
-//
-// This is the callback function for the "show:http-stats" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowHttpStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowHttpStats\n");
-
-  return (ShowHttpStats());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowIcpStats
-//
-// This is the callback function for the "show:icp-stats" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowIcpStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowIcpStats\n");
-
-  return (ShowIcpStats());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowCacheStats
-//
-// This is the callback function for the "show:cache-stats" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowCacheStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowCacheStats\n");
-
-  return (ShowCacheStats());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowHostDbStats
-//
-// This is the callback function for the "show:hostdb-stats" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowHostDbStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowHostDbStats\n");
-
-  return (ShowHostDbStats());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowDnsStats
-//
-// This is the callback function for the "show:dns-stats" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowDnsStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowDnsStats\n");
-
-  return (ShowDnsStats());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowLoggingStats
-//
-// This is the callback function for the "show:logging-stats" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowLoggingStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowLoggingStats\n");
-
-  return (ShowLoggingStats());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ShowAlarms
-//
-// This is the callback function for the "show:alarms" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ShowAlarms(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  Cli_Debug("Cmd_ShowAlarms\n");
-
-  return (ShowAlarms());
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_None
-//
-// Register a command with no arguments with the Tcl interpreter.
-//
-int
-CmdArgs_None()
-{
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-//
-// "show" sub-command implementations
-//
-////////////////////////////////////////////////////////////////
-
-
-// show status sub-command
-int
-ShowStatus()
-{
-  TSProxyStateT state = TSProxyStateGet();
-  Cli_Printf("\n");
-  switch (state) {
-  case TS_PROXY_ON:
-    Cli_Printf("Proxy -- on\n");
-    break;
-  case TS_PROXY_OFF:
-    Cli_Printf("Proxy -- off\n");
-    break;
-  case TS_PROXY_UNDEFINED:
-    Cli_Printf("Proxy status undefined\n");
-    break;
-  }
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show version sub-command
-int
-ShowVersion()
-{
-  TSError status = TS_ERR_OKAY;
-  TSString ts_version = NULL;
-  TSString tm_version = NULL;
-
-  status = Cli_RecordGetString("proxy.process.version.server.short", &ts_version);
-  status = Cli_RecordGetString("proxy.node.version.manager.short", &tm_version);
-
-  Cli_Printf("\n");
-  Cli_Printf("traffic_server version --- %s\n" "traffic_manager version -- %s\n", ts_version, tm_version);
-  Cli_Printf("\n");
-
-  return status;
-}
-
-// show ports sub-command
-int
-ShowPorts()
-{
-  TSString http_ports = NULL;
-  TSInt cluster = -1;
-  TSInt cluster_rs = -1;
-  TSInt cluster_mc = -1;
-  TSInt socks_server = -1;
-  TSInt icp = -1;
-  TSString connect = NULL;
-
-  // retrieve values
-
-  Cli_RecordGetString("proxy.config.http.server_ports", &http_ports);
-  Cli_RecordGetInt("proxy.config.cluster.cluster_port", &cluster);
-  Cli_RecordGetInt("proxy.config.cluster.rsport", &cluster_rs);
-  Cli_RecordGetInt("proxy.config.cluster.mcport", &cluster_mc);
-  Cli_RecordGetString("proxy.config.http.connect_ports", &connect);
-  Cli_RecordGetInt("proxy.config.socks.socks_server_port", &socks_server);
-  Cli_RecordGetInt("proxy.config.icp.icp_port", &icp);
-
-  // display results
-  Cli_Printf("\n");
-  Cli_Printf("HTTP Ports ------------- %s\n", (http_ports != NULL) ? http_ports : "none");
-  Cli_Printf("Cluster Port ----------- %d\n", cluster);
-  Cli_Printf("Cluster RS Port -------- %d\n", cluster_rs);
-  Cli_Printf("Cluster MC Port -------- %d\n", cluster_mc);
-  Cli_Printf("Allowed CONNECT Ports -- %s\n", (connect != NULL) ? connect : "none");
-  Cli_Printf("SOCKS Server Port ------ %d\n", socks_server);
-  Cli_Printf("ICP Port --------------- %d\n", icp);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show cluster sub-command
-int
-ShowCluster()
-{
-  TSInt cluster = -1;
-  TSInt cluster_rs = -1;
-  TSInt cluster_mc = -1;
-
-  Cli_RecordGetInt("proxy.config.cluster.cluster_port", &cluster);
-  Cli_RecordGetInt("proxy.config.cluster.rsport", &cluster_rs);
-  Cli_RecordGetInt("proxy.config.cluster.mcport", &cluster_mc);
-
-  Cli_Printf("\n");
-  Cli_Printf("Cluster Port ----------- %d\n", cluster);
-  Cli_Printf("Cluster RS Port -------- %d\n", cluster_rs);
-  Cli_Printf("Cluster MC Port -------- %d\n", cluster_mc);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show security sub-command
-int
-ShowSecurity()
-{
-  Cli_Printf("\n");
-  Cli_Printf("Traffic Server Access\n" "-------------------\n");
-  TSError status = Cli_DisplayRules(TS_FNAME_IP_ALLOW);
-
-  return status;
-}
-
-// show http sub-command
-int
-ShowHttp()
-{
-  // declare and initialize variables
-
-  TSInt http_enabled = -1;
-  TSInt keepalive_timeout_in = -1;
-  TSInt keepalive_timeout_out = -1;
-  TSInt inactivity_timeout_in = -1;
-  TSInt inactivity_timeout_out = -1;
-  TSInt activity_timeout_in = -1;
-  TSInt activity_timeout_out = -1;
-  TSInt max_alts = -1;
-  TSInt remove_from = -1;
-  TSInt remove_referer = -1;
-  TSInt remove_user_agent = -1;
-  TSInt remove_cookie = -1;
-  TSString other_header_list = NULL;
-  TSInt insert_client_ip = -1;
-  TSInt remove_client_ip = -1;
-  TSInt http_server = -1;
-  TSString http_other = NULL;
-  TSString global_user_agent = NULL;
-
-  // retrieve values
-
-  Cli_RecordGetInt("proxy.config.http.cache.http", &http_enabled);
-  Cli_RecordGetInt("proxy.config.http.keep_alive_no_activity_timeout_in", &keepalive_timeout_in);
-  Cli_RecordGetInt("proxy.config.http.keep_alive_no_activity_timeout_out", &keepalive_timeout_out);
-  Cli_RecordGetInt("proxy.config.http.transaction_no_activity_timeout_in", &inactivity_timeout_in);
-  Cli_RecordGetInt("proxy.config.http.transaction_no_activity_timeout_out", &inactivity_timeout_out);
-  Cli_RecordGetInt("proxy.config.http.transaction_active_timeout_in", &activity_timeout_in);
-  Cli_RecordGetInt("proxy.config.http.transaction_active_timeout_out", &activity_timeout_out);
-  Cli_RecordGetInt("proxy.config.cache.limits.http.max_alts", &max_alts);
-  Cli_RecordGetInt("proxy.config.http.anonymize_remove_from", &remove_from);
-  Cli_RecordGetInt("proxy.config.http.anonymize_remove_referer", &remove_referer);
-  Cli_RecordGetInt("proxy.config.http.anonymize_remove_user_agent", &remove_user_agent);
-  Cli_RecordGetInt("proxy.config.http.anonymize_remove_cookie", &remove_cookie);
-  Cli_RecordGetString("proxy.config.http.anonymize_other_header_list", &other_header_list);
-  Cli_RecordGetInt("proxy.config.http.anonymize_insert_client_ip", &insert_client_ip);
-  Cli_RecordGetInt("proxy.config.http.anonymize_remove_client_ip", &remove_client_ip);
-  Cli_RecordGetInt("proxy.config.http.server_port", &http_server);
-
-  Cli_RecordGetString("proxy.config.http.global_user_agent_header", &global_user_agent);
-
-  // display results
-  Cli_Printf("\n");
-  Cli_Printf("HTTP Caching ------------------ %s\n", (http_enabled == 1) ? "on" : "off");
-  Cli_Printf("HTTP Server Port -------------- %d\n", http_server);
-  Cli_Printf("HTTP Other Ports -------------- %s\n", (http_other != NULL) ? http_other : "none");
-  Cli_Printf("Keep-Alive Timeout Inbound ---- %d s\n", keepalive_timeout_in);
-  Cli_Printf("Keep-Alive Timeout Outbound --- %d s\n", keepalive_timeout_out);
-  Cli_Printf("Inactivity Timeout Inbound ---- %d s\n", inactivity_timeout_in);
-  Cli_Printf("Inactivity Timeout Outbound --- %d s\n", inactivity_timeout_out);
-  Cli_Printf("Activity Timeout Inbound ------ %d s\n", activity_timeout_in);
-  Cli_Printf("Activity Timeout Outbound ----- %d s\n", activity_timeout_out);
-  Cli_Printf("Maximum Number of Alternates -- %d\n", max_alts);
-
-  if (remove_from == 1 || remove_referer == 1 || remove_user_agent == 1 || remove_cookie == 1) {
-    Cli_Printf("Remove the following common headers -- \n");
-    if (remove_from == 1) {
-      Cli_Printf("From\n");
-    }
-    if (remove_referer == 1) {
-      Cli_Printf("Referer\n");
-    }
-    if (remove_user_agent == 1) {
-      Cli_Printf("User-Agent\n");
-    }
-    if (remove_cookie == 1) {
-      Cli_Printf("Cookie\n");
-    }
-  }
-  if (other_header_list != NULL && strlen(other_header_list)) {
-    Cli_Printf("Remove additional headers ----- " "%s\n", other_header_list);
-  }
-  if (insert_client_ip == 1) {
-    Cli_Printf("Insert Client IP Address into Header\n");
-  }
-  if (remove_client_ip == 1) {
-    Cli_Printf("Remove Client IP Address from Header\n");
-  }
-  if (global_user_agent) {
-    Cli_Printf("Set User-Agent header to %s\n", global_user_agent);
-  }
-
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show icp sub-command
-int
-ShowIcp()
-{
-  // declare and initialize variables
-
-  TSInt icp_enabled = 0;
-  TSInt icp_port = -1;
-  TSInt multicast_enabled = 0;
-  TSInt query_timeout = 2;
-
-  // retrieve value
-
-  Cli_RecordGetInt("proxy.config.icp.enabled", &icp_enabled);
-  Cli_RecordGetInt("proxy.config.icp.icp_port", &icp_port);
-  Cli_RecordGetInt("proxy.config.icp.multicast_enabled", &multicast_enabled);
-  Cli_RecordGetInt("proxy.config.icp.query_timeout", &query_timeout);
-
-  // display results
-  Cli_Printf("\n");
-
-  Cli_PrintEnable("ICP Mode Enabled ------- ", icp_enabled);
-  Cli_Printf("ICP Port --------------- %d\n", icp_port);
-  Cli_PrintEnable("ICP Multicast Enabled -- ", multicast_enabled);
-  Cli_Printf("ICP Query Timeout ------ %d s\n", query_timeout);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show icp peer sub-command
-int
-ShowIcpPeer()
-{
-  // display rules from icp.config
-  Cli_Printf("\n");
-  Cli_Printf("icp.config Rules\n" "-------------------\n");
-  TSError status = Cli_DisplayRules(TS_FNAME_ICP_PEER);
-  Cli_Printf("\n");
-
-  return status;
-}
-
-// show proxy sub-command
-int
-ShowProxy()
-{
-
-  TSString proxy_name = NULL;
-
-  Cli_RecordGetString("proxy.config.proxy_name", &proxy_name);
-  Cli_Printf("\n");
-  Cli_Printf("Name -- %s\n", proxy_name);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show cache sub-command
-int
-ShowCache()
-{
-  // declare and initialize variables
-
-  TSInt cache_http = -1;
-  TSInt cache_bypass = -1;
-  TSInt max_doc_size = -1;
-  TSInt when_to_reval = -1;
-  TSInt reqd_headers = -1;
-  TSInt min_life = -1;
-  TSInt max_life = -1;
-  TSInt dynamic_urls = -1;
-  TSInt alternates = -1;
-  const char *vary_def_text = "NONE";
-  const char *vary_def_image = "NONE";
-  const char *vary_def_other = "NONE";
-  TSInt cookies = -1;
-
-  // retrieve values
-
-  Cli_RecordGetInt("proxy.config.http.cache.http", &cache_http);
-  Cli_RecordGetInt("proxy.config.cache.max_doc_size", &max_doc_size);
-  Cli_RecordGetInt("proxy.config.http.cache.when_to_revalidate", &when_to_reval);
-  Cli_RecordGetInt("proxy.config.http.cache.required_headers", &reqd_headers);
-  Cli_RecordGetInt("proxy.config.http.cache.heuristic_min_lifetime", &min_life);
-  Cli_RecordGetInt("proxy.config.http.cache.heuristic_max_lifetime", &max_life);
-  Cli_RecordGetInt("proxy.config.http.cache.cache_urls_that_look_dynamic", &dynamic_urls);
-  Cli_RecordGetInt("proxy.config.http.cache.enable_default_vary_headers", &alternates);
-  Cli_RecordGetString("proxy.config.http.cache.vary_default_text", (char**)&vary_def_text);
-  Cli_RecordGetString("proxy.config.http.cache.vary_default_images", (char**)&vary_def_image);
-  Cli_RecordGetString("proxy.config.http.cache.vary_default_other", (char**)&vary_def_other);
-
-  Cli_RecordGetInt("proxy.config.http.cache.cache_responses_to_cookies", &cookies);
-
-
-  // display results
-  Cli_Printf("\n");
-
-  Cli_PrintEnable("HTTP Caching --------------------------- ", cache_http);
-
-  Cli_PrintEnable("Ignore User Requests To Bypass Cache --- ", cache_bypass);
-
-  if (max_doc_size == 0)
-    Cli_Printf("Maximum HTTP Object Size ----------- NONE\n");
-  else
-    Cli_Printf("Maximum HTTP Object Size ----------- %d\n", max_doc_size);
-
-  Cli_Printf("Freshness\n");
-  Cli_Printf("  Verify Freshness By Checking --------- ");
-
-  switch (when_to_reval) {
-  case 0:
-    Cli_Printf("When The Object Has Expired\n");
-    break;
-  case 1:
-    Cli_Printf("When The Object Has No Expiry Date\n");
-    break;
-  case 2:
-    Cli_Printf("Always\n");
-    break;
-  case 3:
-    Cli_Printf("Never\n");
-    break;
-  default:
-    Cli_Printf("unknown\n");
-    break;
-  }
-
-  Cli_Printf("  Minimum Information to be Cacheable -- ");
-
-  switch (reqd_headers) {
-  case 0:
-    Cli_Printf("Nothing\n");
-    break;
-  case 1:
-    Cli_Printf("A Last Modified Time\n");
-    break;
-  case 2:
-    Cli_Printf("An Explicit Lifetime\n");
-    break;
-  default:
-    Cli_Printf("unknown\n");
-    break;
-  }
-
-  Cli_Printf("  If Object has no Expiration Date: \n" "    Leave it in Cache for at least ----- %d s\n", min_life);
-  Cli_Printf("    but no more than ------------------- %d s\n", max_life);
-
-  Cli_Printf("Variable Content\n");
-
-  Cli_PrintEnable("  Cache Responses to URLs that contain\n    \"?\",\";\",\"cgi\" or end in \".asp\" ----- ",
-                  dynamic_urls);
-
-  Cli_PrintEnable("  Alternates Enabled ------------------- ", alternates);
-
-  Cli_Printf("  Vary on HTTP Header Fields: \n");
-  Cli_Printf("    Text ------------------------------- %s\n", vary_def_text);
-  Cli_Printf("    Images ----------------------------- %s\n", vary_def_image);
-  Cli_Printf("    Other ------------------------------ %s\n", vary_def_other);
-
-  Cli_Printf("  Cache responses to requests containing cookies for:\n");
-
-  switch (cookies) {
-  case 0:
-    Cli_Printf("    No Content-types\n");
-    break;
-  case 1:
-    Cli_Printf("    All Content-types\n");
-    break;
-  case 2:
-    Cli_Printf("    Only Image-content Types\n");
-    break;
-  case 3:
-    Cli_Printf("    Content Types which are not Text\n");
-    break;
-  case 4:
-    Cli_Printf("    Content Types which are not Text with some exceptions\n");
-    break;
-  }
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show cache rules sub-command
-int
-ShowCacheRules()
-{
-  // display rules from cache.config
-  Cli_Printf("\n");
-
-  Cli_Printf("cache.config rules\n" "-------------------\n");
-  TSError status = Cli_DisplayRules(TS_FNAME_CACHE_OBJ);
-
-  Cli_Printf("\n");
-
-  return status;
-}
-
-// show cache storage sub-command
-int
-ShowCacheStorage()
-{
-  // display rules from storage.config
-  Cli_Printf("storage.config rules\n");
-
-  TSError status = Cli_DisplayRules(TS_FNAME_STORAGE);
-
-  return status;
-}
-
-
-// show virtual-ip sub-command
-int
-ShowVirtualIp()
-{
-  TSCfgContext VipCtx;
-  int EleCount, i;
-  TSVirtIpAddrEle *VipElePtr;
-
-  VipCtx = TSCfgContextCreate(TS_FNAME_VADDRS);
-  if (TSCfgContextGet(VipCtx) != TS_ERR_OKAY)
-    Cli_Printf("ERROR READING FILE\n");
-  EleCount = TSCfgContextGetCount(VipCtx);
-  Cli_Printf("\n");
-  Cli_Printf("%d Elements in Record\n", EleCount);
-  Cli_Printf("\n");
-  for (i = 0; i < EleCount; i++) {
-    VipElePtr = (TSVirtIpAddrEle *) TSCfgContextGetEleAt(VipCtx, i);
-    Cli_Printf("%d %s %s %d\n", i, VipElePtr->ip_addr, VipElePtr->intr, VipElePtr->sub_intr);
-  }
-  Cli_Printf("\n");
-  return CLI_OK;
-}
-
-// show hostdb sub-command
-int
-ShowHostDb()
-{
-
-  // declare and initialize variables
-
-  TSInt lookup_timeout = -1;
-  TSInt timeout = -1;
-  TSInt verify_after = -1;
-  TSInt fail_timeout = -1;
-  TSInt re_dns_on_reload = 0;
-  TSInt dns_lookup_timeout = -1;
-  TSInt dns_retries = -1;
-
-  // retrieve value
-
-  Cli_RecordGetInt("proxy.config.hostdb.lookup_timeout", &lookup_timeout);
-  Cli_RecordGetInt("proxy.config.hostdb.timeout", &timeout);
-  Cli_RecordGetInt("proxy.config.hostdb.verify_after", &verify_after);
-  Cli_RecordGetInt("proxy.config.hostdb.fail.timeout", &fail_timeout);
-  Cli_RecordGetInt("proxy.config.hostdb.re_dns_on_reload", &re_dns_on_reload);
-  Cli_RecordGetInt("proxy.config.dns.lookup_timeout", &dns_lookup_timeout);
-  Cli_RecordGetInt("proxy.config.dns.retries", &dns_retries);
-
-  // display results
-  Cli_Printf("\n");
-
-  Cli_Printf("Lookup Timeout ----------- %d s\n", lookup_timeout);
-  Cli_Printf("Foreground Timeout ------- %d s\n", timeout);
-  Cli_Printf("Background Timeout ------- %d s\n", verify_after);
-  Cli_Printf("Invalid Host Timeout ----- %d s\n", fail_timeout);
-  if (Cli_PrintEnable("Re-DNS on Reload --------- ", re_dns_on_reload) == CLI_ERROR) {
-    return CLI_ERROR;
-  }
-  Cli_Printf("Resolve Attempt Timeout -- %d s\n", dns_lookup_timeout);
-  Cli_Printf("Number of retries -------- %d \n", dns_retries);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show dns-resolver sub-command
-int
-ShowDnsResolver()
-{
-  // declare and initialize variables
-
-  TSInt dns_search_default_domains = 0;
-  TSInt http_enable_url_expandomatic = 0;
-
-  // retrieve value
-
-  Cli_RecordGetInt("proxy.config.dns.search_default_domains", &dns_search_default_domains);
-  Cli_RecordGetInt("proxy.config.http.enable_url_expandomatic", &http_enable_url_expandomatic);
-
-  // display results
-  Cli_Printf("\n");
-
-  if (Cli_PrintEnable("Local Domain Expansion -- ", dns_search_default_domains) == CLI_ERROR) {
-    return CLI_ERROR;
-  }
-  if (Cli_PrintEnable(".com Domain Expansion --- ", http_enable_url_expandomatic) == CLI_ERROR) {
-    return CLI_ERROR;
-  }
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show logging sub-command
-int
-ShowLogging()
-{
-  // declare and initialize variables
-
-  TSInt logging_enabled = 0;
-  TSInt log_space = -1;
-  TSInt headroom_space = -1;
-  TSInt collation_mode = 0;
-  const char *collation_host = "None";
-  TSInt collation_port = -1;
-  TSString collation_secret = NULL;
-  TSInt host_tag = 0;
-  TSInt preproc_threads = 0;
-  TSInt orphan_space = -1;
-
-  TSInt squid_log = 0;
-  TSInt is_ascii = 1;
-  TSString file_name = NULL;
-  TSString file_header = NULL;
-
-  TSInt common_log = 0;
-  TSInt common_is_ascii = 0;
-  TSString common_file_name = NULL;
-  TSString common_file_header = NULL;
-
-  TSInt extended_log = 0;
-  TSInt extended_is_ascii = 0;
-  TSString extended_file_name = NULL;
-  TSString extended_file_header = NULL;
-
-  TSInt extended2_log = 0;
-  TSInt extended2_is_ascii = 0;
-  TSString extended2_file_name = NULL;
-  TSString extended2_file_header = NULL;
-
-  TSInt icp_log = 0;
-  TSInt http_host_log = 0;
-  TSInt custom_log = 0;
-  TSInt xml_log = 0;
-  TSInt rolling = 0;
-  TSInt roll_offset_hr = -1;
-  TSInt roll_interval = -1;
-  TSInt auto_delete = 0;
-  // retrieve value
-
-  Cli_RecordGetInt("proxy.config.log.logging_enabled", &logging_enabled);
-  Cli_RecordGetInt("proxy.config.log.max_space_mb_for_logs", &log_space);
-  Cli_RecordGetInt("proxy.config.log.max_space_mb_headroom", &headroom_space);
-  Cli_RecordGetInt("proxy.local.log.collation_mode", &collation_mode);
-  Cli_RecordGetString("proxy.config.log.collation_host", (char**)&collation_host);
-  Cli_RecordGetInt("proxy.config.log.collation_port", &collation_port);
-  Cli_RecordGetString("proxy.config.log.collation_secret", &collation_secret);
-  Cli_RecordGetInt("proxy.config.log.collation_host_tagged", &host_tag);
-  Cli_RecordGetInt("proxy.config.log.max_space_mb_for_orphan_logs", &orphan_space);
-  Cli_RecordGetInt("proxy.config.log.collation_preproc_threads", &preproc_threads);
-
-  Cli_RecordGetInt("proxy.config.log.squid_log_enabled", &squid_log);
-  Cli_RecordGetInt("proxy.config.log.squid_log_is_ascii", &is_ascii);
-  Cli_RecordGetString("proxy.config.log.squid_log_name", &file_name);
-  Cli_RecordGetString("proxy.config.log.squid_log_header", &file_header);
-
-  Cli_RecordGetInt("proxy.config.log.common_log_enabled", &common_log);
-  Cli_RecordGetInt("proxy.config.log.common_log_is_ascii", &common_is_ascii);
-  Cli_RecordGetString("proxy.config.log.common_log_name", &common_file_name);
-  Cli_RecordGetString("proxy.config.log.common_log_header", &common_file_header);
-
-  Cli_RecordGetInt("proxy.config.log.extended_log_enabled", &extended_log);
-  Cli_RecordGetInt("proxy.config.log.extended_log_is_ascii", &extended_is_ascii);
-  Cli_RecordGetString("proxy.config.log.extended_log_name", &extended_file_name);
-  Cli_RecordGetString("proxy.config.log.extended_log_header", &extended_file_header);
-
-  Cli_RecordGetInt("proxy.config.log.extended2_log_enabled", &extended2_log);
-  Cli_RecordGetInt("proxy.config.log.extended2_log_is_ascii", &extended2_is_ascii);
-  Cli_RecordGetString("proxy.config.log.extended2_log_name", &extended2_file_name);
-  Cli_RecordGetString("proxy.config.log.extended2_log_header", &extended2_file_header);
-
-  Cli_RecordGetInt("proxy.config.log.separate_icp_logs", &icp_log);
-  Cli_RecordGetInt("proxy.config.log.separate_host_logs", &http_host_log);
-  Cli_RecordGetInt("proxy.config.log.separate_host_logs", &custom_log);
-
-  Cli_RecordGetInt("proxy.config.log.rolling_enabled", &rolling);
-  Cli_RecordGetInt("proxy.config.log.rolling_offset_hr", &roll_offset_hr);
-  Cli_RecordGetInt("proxy.config.log.rolling_interval_sec", &roll_interval);
-  Cli_RecordGetInt("proxy.config.log.auto_delete_rolled_files", &auto_delete);
-
-  // display results
-  Cli_Printf("\n");
-
-  Cli_Printf("Logging Mode ----------------------------- ");
-  switch (logging_enabled) {
-  case 0:
-    Cli_Printf("no logging\n");
-    break;
-  case 1:
-    Cli_Printf("errors only\n");
-    break;
-  case 2:
-    Cli_Printf("transactions only\n");
-    break;
-  case 3:
-    Cli_Printf("errors and transactions\n");
-    break;
-  default:
-    Cli_Printf("invalid mode\n");
-    break;
-  }
-
-  Cli_Printf("\nManagement\n");
-  Cli_Printf("  Log Space Limit ------------------------ %d MB\n", log_space);
-  Cli_Printf("  Log Space Headroom --------------------- %d MB\n", headroom_space);
-
-  Cli_PrintEnable("\nLog Collation ---------------------------- ", collation_mode);
-  Cli_Printf("  Host ----------------------------------- %s\n", collation_host);
-  Cli_Printf("  Port ----------------------------------- %d\n", collation_port);
-  Cli_Printf("  Secret --------------------------------- %s\n", collation_secret);
-  Cli_PrintEnable("  Host Tagged ---------------------------- ", host_tag);
-  Cli_PrintEnable("  Preproc Threads ------------------------ ", preproc_threads);
-  Cli_Printf("  Space Limit for Orphan Files ----------- %d MB\n", orphan_space);
-
-  Cli_PrintEnable("\nSquid Format ----------------------------- ", squid_log);
-  if (is_ascii == 1)
-    Cli_Printf("  File Type ------------------------------ %s\n", "ASCII");
-  else if (is_ascii == 0)
-    Cli_Printf("  File Type ------------------------------ %s\n", "BINARY");
-  else
-    Cli_Debug(ERR_INVALID_PARAMETER);
-  Cli_Printf("  File Name ------------------------------ %s\n", file_name);
-  Cli_Printf("  File Header ---------------------------- %s\n", file_header);
-
-  Cli_PrintEnable("\nNetscape Common -------------------------- ", common_log);
-  if (common_is_ascii == 1)
-    Cli_Printf("  File Type ------------------------------ %s\n", "ASCII");
-  else if (common_is_ascii == 0)
-    Cli_Printf("  File Type ------------------------------ %s\n", "BINARY");
-  else
-    Cli_Debug(ERR_INVALID_PARAMETER);
-  Cli_Printf("  File Name ------------------------------ %s\n", common_file_name);
-  Cli_Printf("  File Header ---------------------------- %s\n", common_file_header);
-
-  Cli_PrintEnable("\nNetscape Extended ------------------------ ", extended_log);
-  if (extended_is_ascii == 1)
-    Cli_Printf("  File Type ------------------------------ %s\n", "ASCII");
-  else if (extended_is_ascii == 0)
-    Cli_Printf("  File Type ------------------------------ %s\n", "BINARY");
-  else
-    Cli_Debug(ERR_INVALID_PARAMETER);
-  Cli_Printf("  File Name ------------------------------ %s\n", extended_file_name);
-  Cli_Printf("  File Header ---------------------------- %s\n", extended_file_header);
-
-  Cli_PrintEnable("\nNetscape Extended2 ----------------------- ", extended2_log);
-  if (extended2_is_ascii == 1)
-    Cli_Printf("  File Type ------------------------------ %s\n", "ASCII");
-  else if (extended2_is_ascii == 0)
-    Cli_Printf("  File Type ------------------------------ %s\n", "BINARY");
-  else
-    Cli_Debug(ERR_INVALID_PARAMETER);
-  Cli_Printf("  File Name   ---------------------------- %s\n", extended2_file_name);
-  Cli_Printf("  File Header ---------------------------- %s\n", extended2_file_header);
-
-  Cli_Printf("\nSplitting\n");
-  Cli_PrintEnable("  ICP Log Splitting ---------------------- ", icp_log);
-  Cli_PrintEnable("  HTTP Host Log Splitting ---------------- ", http_host_log);
-  Cli_PrintEnable("\nCustom Logs ------------------------------ ", custom_log);
-  if (xml_log == 0)
-    Cli_Printf("Custom Log Definition Format ------------- %s\n", "Traditional");
-  Cli_PrintEnable("\nRolling ---------------------------------- ", rolling);
-  Cli_Printf("  Roll Offset Hour ----------------------- %d\n", roll_offset_hr);
-  Cli_Printf("  Roll Interval -------------------------- %d s\n", roll_interval);
-  Cli_PrintEnable("  Auto-delete rolled files (low space) --- ", auto_delete);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show ssl sub-command
-int
-ShowSsl()
-{
-  // declare and initialize variables
-
-  TSString connect_ports = NULL;
-
-  // retrieve value
-
-  Cli_RecordGetString("proxy.config.http.connect_ports", &connect_ports);
-
-  // display results
-  Cli_Printf("\n");
-  Cli_Printf("Restrict CONNECT connections to Ports -- %s\n", connect_ports);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-
-// show parents sub-command
-int
-ShowParents()
-{
-  TSError status = TS_ERR_OKAY;
-  TSInt parent_enabled = -1;
-  TSString parent_cache = NULL;
-
-  Cli_RecordGetInt("proxy.config.http.parent_proxy_routing_enable", &parent_enabled);
-  Cli_RecordGetString("proxy.config.http.parent_proxies", &parent_cache);
-  Cli_Printf("\n");
-  Cli_Printf("Parent Caching -- %s\n", (parent_enabled == 1) ? "on" : "off");
-  Cli_Printf("Parent Cache ---- %s\n", parent_cache);
-  Cli_Printf("\n");
-
-  return status;
-}
-
-// show:parent rules sub-command
-int
-ShowParentRules()
-{
-  // display rules from parent.config
-  Cli_Printf("\n");
-
-  Cli_Printf("parent.config rules\n" "-------------------\n");
-  TSError status = Cli_DisplayRules(TS_FNAME_PARENT_PROXY);
-  Cli_Printf("\n");
-
-  return status;
-}
-
-// show remap sub-command
-int
-ShowRemap()
-{
-  // display rules from remap.config
-  Cli_Printf("\n");
-
-  Cli_Printf("remap.config rules\n" "-------------------\n");
-  TSError status = Cli_DisplayRules(TS_FNAME_REMAP);
-  Cli_Printf("\n");
-
-  return status;
-}
-
-// show socks sub-command
-int
-ShowSocks()
-{
-  // declare and initialize variables
-
-  TSInt socks_enabled = 0;
-  TSInt version = -1;
-  TSString default_servers = NULL;
-  TSInt accept_enabled = -1;
-  TSInt accept_port = -1;
-
-  // retrieve values
-  Cli_RecordGetInt("proxy.config.socks.socks_needed", &socks_enabled);
-  Cli_RecordGetInt("proxy.config.socks.socks_version", &version);
-  Cli_RecordGetString("proxy.config.socks.default_servers", &default_servers);
-  Cli_RecordGetInt("proxy.config.socks.accept_enabled", &accept_enabled);
-  Cli_RecordGetInt("proxy.config.socks.accept_port", &accept_port);
-
-  // display results
-  Cli_Printf("\n");
-  Cli_PrintEnable("SOCKS -------------------- ", socks_enabled);
-  Cli_Printf("SOCKS Version ------------ %d\n", version);
-  Cli_Printf("SOCKS Default Servers ---- %s\n", default_servers);
-  Cli_PrintEnable("SOCKS Accept Enabled ----- ", accept_enabled);
-  Cli_Printf("SOCKS Accept Port -------- %d\n", accept_port);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show:socks rules sub-command
-int
-ShowSocksRules()
-{
-  // display rules from socks.config
-  Cli_Printf("\n");
-
-  Cli_Printf("socks.config rules\n" "-------------------\n");
-  TSError status = Cli_DisplayRules(TS_FNAME_SOCKS);
-  Cli_Printf("\n");
-
-  return status;
-}
-
-// show scheduled-update sub-command
-int
-ShowScheduledUpdate()
-{
-  // variable declaration
-  TSInt enabled = 0;
-  TSInt force = 0;
-  TSInt retry_count = -1;
-  TSInt retry_interval = -1;
-  TSInt concurrent_updates = 0;
-
-  // get value
-  Cli_RecordGetInt("proxy.config.update.enabled", &enabled);
-  Cli_RecordGetInt("proxy.config.update.retry_count", &retry_count);
-  Cli_RecordGetInt("proxy.config.update.retry_interval", &retry_interval);
-  Cli_RecordGetInt("proxy.config.update.concurrent_updates", &concurrent_updates);
-  Cli_RecordGetInt("proxy.config.update.force", &force);
-  //display values
-
-  // display rules from socks.config
-  Cli_Printf("\n");
-
-  if (Cli_PrintEnable("Scheduled Update ------------- ", enabled) == CLI_ERROR) {
-    return CLI_ERROR;
-  }
-
-  Cli_Printf("Update Error Retry Count ----- %d\n", retry_count);
-  Cli_Printf("Update Error Retry Interval -- %d s\n", retry_interval);
-  Cli_Printf("Maximum Concurrent Updates --- %d\n", concurrent_updates);
-
-  if (Cli_PrintEnable("Force Immediate Update ------- ", force) == CLI_ERROR) {
-    return CLI_ERROR;
-  }
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show:scheduled-update rules sub-command
-int
-ShowScheduledUpdateRules()
-{
-  Cli_Printf("\n");
-
-  Cli_Printf("update.config rules\n" "-------------------\n");
-  TSError status = Cli_DisplayRules(TS_FNAME_UPDATE_URL);
-  Cli_Printf("\n");
-
-  return status;
-}
-
-////////////////////////////////////////////////////////////////
-// statistics sub-commands
-//
-
-// show proxy-stats sub-command
-int
-ShowProxyStats()
-{
-
-  TSFloat cache_hit_ratio = -1.0;
-  TSFloat cache_hit_mem_ratio = -1.0;
-  TSFloat bandwidth_hit_ratio = -1.0;
-  TSFloat percent_free = -1.0;
-  TSInt current_server_connection = -1;
-  TSInt current_client_connection = -1;
-  TSInt current_cache_connection = -1;
-  TSFloat client_throughput_out = -1.0;
-  TSFloat xacts_per_second = -1.0;
-
-
-  //get value
-  Cli_RecordGetFloat("proxy.node.cache_hit_ratio", &cache_hit_ratio);
-  Cli_RecordGetFloat("proxy.node.cache_hit_mem_ratio", &cache_hit_mem_ratio);
-  Cli_RecordGetFloat("proxy.node.bandwidth_hit_ratio", &bandwidth_hit_ratio);
-  Cli_RecordGetFloat("proxy.node.cache.percent_free", &percent_free);
-  Cli_RecordGetInt("proxy.node.current_server_connections", &current_server_connection);
-  Cli_RecordGetInt("proxy.node.current_client_connections", &current_client_connection);
-  Cli_RecordGetInt("proxy.node.current_cache_connections", &current_cache_connection);
-  Cli_RecordGetFloat("proxy.node.client_throughput_out", &client_throughput_out);
-  Cli_RecordGetFloat("proxy.node.user_agent_xacts_per_second", &xacts_per_second);
-
-
-  //display values
-  Cli_Printf("\n");
-
-  Cli_Printf("Document Hit Rate -------- %f %%\t *\n", 100 * cache_hit_ratio);
-  Cli_Printf("Ram cache Hit Rate ------- %f %%\t *\n", 100 * cache_hit_mem_ratio);
-  Cli_Printf("Bandwidth Saving --------- %f %%\t *\n", 100 * bandwidth_hit_ratio);
-  Cli_Printf("Cache Percent Free ------- %f %%\n", 100 * percent_free);
-  Cli_Printf("Open Server Connections -- %d\n", current_server_connection);
-  Cli_Printf("Open Client Connections -- %d\n", current_client_connection);
-  Cli_Printf("Open Cache Connections --- %d\n", current_cache_connection);
-  Cli_Printf("Client Throughput -------- %f MBit/Sec\n", client_throughput_out);
-  Cli_Printf("Transaction Per Second --- %f\n", xacts_per_second);
-  Cli_Printf("\n* Value represents 10 second average.\n");
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show http-trans-stats sub-command
-int
-ShowHttpTransStats()
-{
-  //varialbles
-  TSFloat frac_avg_10s_hit_fresh = -1.0;
-  TSInt msec_avg_10s_hit_fresh = -1;
-  TSFloat frac_avg_10s_hit_revalidated = -1.0;
-  TSInt msec_avg_10s_hit_revalidated = -1;
-  TSFloat frac_avg_10s_miss_cold = -1.0;
-  TSInt msec_avg_10s_miss_cold = -1;
-  TSFloat frac_avg_10s_miss_not_cachable = -1.0;
-  TSInt msec_avg_10s_miss_not_cachable = -1;
-  TSFloat frac_avg_10s_miss_changed = -1.0;
-  TSInt msec_avg_10s_miss_changed = -1;
-  TSFloat frac_avg_10s_miss_client_no_cache = -1.0;
-  TSInt msec_avg_10s_miss_client_no_cache = -1;
-  TSFloat frac_avg_10s_errors_connect_failed = -1.0;
-  TSInt msec_avg_10s_errors_connect_failed = -1;
-  TSFloat frac_avg_10s_errors_other = -1.0;
-  TSInt msec_avg_10s_errors_other = -1;
-  TSFloat frac_avg_10s_errors_aborts = -1.0;
-  TSInt msec_avg_10s_errors_aborts = -1;
-  TSFloat frac_avg_10s_errors_possible_aborts = -1.0;
-  TSInt msec_avg_10s_errors_possible_aborts = -1;
-  TSFloat frac_avg_10s_errors_early_hangups = -1.0;
-  TSInt msec_avg_10s_errors_early_hangups = -1;
-  TSFloat frac_avg_10s_errors_empty_hangups = -1.0;
-  TSInt msec_avg_10s_errors_empty_hangups = -1;
-  TSFloat frac_avg_10s_errors_pre_accept_hangups = -1.0;
-  TSInt msec_avg_10s_errors_pre_accept_hangups = -1;
-  TSFloat frac_avg_10s_other_unclassified = -1.0;
-  TSInt msec_avg_10s_other_unclassified = -1;
-
-  //get values
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.hit_fresh", &frac_avg_10s_hit_fresh);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.hit_revalidated", &frac_avg_10s_hit_revalidated);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.miss_cold", &frac_avg_10s_miss_cold);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.miss_not_cacheable", &frac_avg_10s_miss_not_cachable);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.miss_changed", &frac_avg_10s_miss_changed);
-
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.miss_client_no_cache",
-                     &frac_avg_10s_miss_client_no_cache);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.connect_failed",
-                     &frac_avg_10s_errors_connect_failed);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.other", &frac_avg_10s_errors_other);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.aborts", &frac_avg_10s_errors_aborts);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.possible_aborts",
-                     &frac_avg_10s_errors_possible_aborts);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.early_hangups",
-                     &frac_avg_10s_errors_early_hangups);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.empty_hangups",
-                     &frac_avg_10s_errors_empty_hangups);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.pre_accept_hangups",
-                     &frac_avg_10s_errors_pre_accept_hangups);
-  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.other.unclassified", &frac_avg_10s_other_unclassified);
-
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.hit_fresh", &msec_avg_10s_hit_fresh);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.hit_revalidated", &msec_avg_10s_hit_revalidated);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.miss_cold", &msec_avg_10s_miss_cold);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.miss_not_cacheable", &msec_avg_10s_miss_not_cachable);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.miss_changed", &msec_avg_10s_miss_changed);
-
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.miss_client_no_cache", &msec_avg_10s_miss_client_no_cache);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.connect_failed",
-                   &msec_avg_10s_errors_connect_failed);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.other", &msec_avg_10s_errors_other);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.aborts", &msec_avg_10s_errors_aborts);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.possible_aborts",
-                   &msec_avg_10s_errors_possible_aborts);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.early_hangups", &msec_avg_10s_errors_early_hangups);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.empty_hangups", &msec_avg_10s_errors_empty_hangups);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.pre_accept_hangups",
-                   &msec_avg_10s_errors_pre_accept_hangups);
-  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.other.unclassified", &msec_avg_10s_other_unclassified);
-
-  //display
-  Cli_Printf("\n");
-  Cli_Printf("HTTP Transaction Frequency and Speeds\n");
-  Cli_Printf("Transaction Type              Frequency   Speed(ms)\n");
-  Cli_Printf("--Hits--\n");
-  Cli_Printf("Fresh ----------------------- %f %%  %d\n", 100 * frac_avg_10s_hit_fresh, msec_avg_10s_hit_fresh);
-  Cli_Printf("Stale Revalidated ----------- %f %%  %d\n", 100 * frac_avg_10s_hit_revalidated,
-             msec_avg_10s_hit_revalidated);
-  Cli_Printf("--Misses--\n");
-  Cli_Printf("Now Cached ------------------ %f %%  %d\n", 100 * frac_avg_10s_miss_cold, msec_avg_10s_miss_cold);
-  Cli_Printf("Server No Cache ------------- %f %%  %d\n", 100 * frac_avg_10s_miss_not_cachable,
-             msec_avg_10s_miss_not_cachable);
-  Cli_Printf("Stale Reloaded -------------- %f %%  %d\n", 100 * frac_avg_10s_miss_changed, msec_avg_10s_miss_changed);
-  Cli_Printf("Client No Cache ------------- %f %%  %d\n", 100 * frac_avg_10s_miss_client_no_cache,
-             msec_avg_10s_miss_client_no_cache);
-  Cli_Printf("--Errors--\n");
-  Cli_Printf("Connection Failures --------- %f %%  %d\n", 100 * frac_avg_10s_errors_connect_failed,
-             msec_avg_10s_errors_connect_failed);
-  Cli_Printf("Other Errors ---------------- %f %%  %d\n", 100 * frac_avg_10s_errors_other, msec_avg_10s_errors_other);
-  Cli_Printf("--Aborted Transactions--\n");
-  Cli_Printf("Client Aborts --------------- %f %%  %d\n", 100 * frac_avg_10s_errors_aborts, msec_avg_10s_errors_aborts);
-  Cli_Printf("Questionable Client Aborts -- %f %%  %d\n", 100 * frac_avg_10s_errors_possible_aborts,
-             msec_avg_10s_errors_possible_aborts);
-  Cli_Printf("Partial Request Hangups ----- %f %%  %d\n", 100 * frac_avg_10s_errors_early_hangups,
-             msec_avg_10s_errors_possible_aborts);
-  Cli_Printf("Pre-Request Hangups --------- %f %%  %d\n", 100 * frac_avg_10s_errors_empty_hangups,
-             msec_avg_10s_errors_empty_hangups);
-  Cli_Printf("Pre-Connect Hangups --------- %f %%  %d\n", 100 * frac_avg_10s_errors_pre_accept_hangups,
-             msec_avg_10s_errors_pre_accept_hangups);
-  Cli_Printf("--Other Transactions--\n");
-  Cli_Printf("Unclassified ---------------- %f %%  %d\n", 100 * frac_avg_10s_other_unclassified,
-             msec_avg_10s_other_unclassified);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show http-stats sub-command
-int
-ShowHttpStats()
-{
-  //variable declaration
-  TSInt user_agent_response_document_total_size = -1;
-  TSInt user_agent_response_header_total_size = -1;
-  TSInt current_client_connections = -1;
-  TSInt current_client_transactions = -1;
-  TSInt origin_server_response_document_total_size = -1;
-  TSInt origin_server_response_header_total_size = -1;
-  TSInt current_server_connections = -1;
-  TSInt current_server_transactions = -1;
-  //get value
-  Cli_RecordGetInt("proxy.process.http.user_agent_response_document_total_size",
-                   &user_agent_response_document_total_size);
-  Cli_RecordGetInt("proxy.process.http.user_agent_response_header_total_size", &user_agent_response_header_total_size);
-  Cli_RecordGetInt("proxy.process.http.current_client_connections", &current_client_connections);
-  Cli_RecordGetInt("proxy.process.http.current_client_transactions", &current_client_transactions);
-  Cli_RecordGetInt("proxy.process.http.origin_server_response_document_total_size",
-                   &origin_server_response_document_total_size);
-  Cli_RecordGetInt("proxy.process.http.origin_server_response_header_total_size",
-                   &origin_server_response_header_total_size);
-  Cli_RecordGetInt("proxy.process.http.current_server_connections", &current_server_connections);
-  Cli_RecordGetInt("proxy.process.http.current_server_transactions", &current_server_transactions);
-
-  //display value
-  Cli_Printf("\n");
-  Cli_Printf("--Client--\n");
-  Cli_Printf("Total Document Bytes ----- %d MB\n", user_agent_response_document_total_size / (1024 * 1024));
-  Cli_Printf("Total Header Bytes ------- %d MB\n", user_agent_response_header_total_size / (1024 * 1024));
-  Cli_Printf("Total Connections -------- %d\n", current_client_connections);
-  Cli_Printf("Transactins In Progress -- %d\n", current_client_transactions);
-  Cli_Printf("--Server--\n");
-  Cli_Printf("Total Document Bytes ----- %d MB\n", origin_server_response_document_total_size / (1024 * 1024));
-  Cli_Printf("Total Header Bytes ------- %d MB\n", origin_server_response_header_total_size / (1024 * 1024));
-  Cli_Printf("Total Connections -------- %d\n", current_server_connections);
-  Cli_Printf("Transactins In Progress -- %d\n", current_server_transactions);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show proxy-stats sub-command
-int
-ShowIcpStats()
-{
-  //variable declaration
-
-  TSInt icp_query_requests = -1;
-  TSInt total_udp_send_queries = -1;
-  TSInt icp_query_hits = -1;
-  TSInt icp_query_misses = -1;
-  TSInt icp_remote_responses = -1;
-  TSFloat total_icp_response_time = -1.0;
-  TSFloat total_icp_request_time = -1.0;
-  TSInt icp_remote_query_requests = -1;
-  TSInt cache_lookup_success = -1;
-  TSInt cache_lookup_fail = -1;
-  TSInt query_response_write = -1;
-
-  //get values
-  Cli_RecordGetInt("proxy.process.icp.icp_query_requests", &icp_query_requests);
-  Cli_RecordGetInt("proxy.process.icp.total_udp_send_queries", &total_udp_send_queries);
-  Cli_RecordGetInt("proxy.process.icp.icp_query_hits", &icp_query_hits);
-  Cli_RecordGetInt("proxy.process.icp.icp_query_misses", &icp_query_misses);
-  Cli_RecordGetInt("proxy.process.icp.icp_remote_responses", &icp_remote_responses);
-  Cli_RecordGetFloat("proxy.process.icp.total_icp_response_time", &total_icp_response_time);
-  Cli_RecordGetFloat("proxy.process.icp.total_icp_request_time", &total_icp_request_time);
-  Cli_RecordGetInt("proxy.process.icp.icp_remote_query_requests", &icp_remote_query_requests);
-  Cli_RecordGetInt("proxy.process.icp.cache_lookup_success", &cache_lookup_success);
-  Cli_RecordGetInt("proxy.process.icp.cache_lookup_fail", &cache_lookup_fail);
-  Cli_RecordGetInt("proxy.process.icp.query_response_write", &query_response_write);
-
-  //display values
-  Cli_Printf("\n");
-  Cli_Printf("--Queries Originating From This Node--\n");
-  Cli_Printf("Query Requests ----------------------------- %d\n", icp_query_requests);
-  Cli_Printf("Query Messages Sent ------------------------ %d\n", total_udp_send_queries);
-  Cli_Printf("Peer Hit Messages Received ----------------- %d\n", icp_query_hits);
-  Cli_Printf("Peer Miss Messages Received ---------------- %d\n", icp_query_misses);
-  Cli_Printf("Total Responses Received ------------------- %d\n", icp_remote_responses);
-  Cli_Printf("Average ICP Message Response Time ---------- %f ms\n", total_icp_response_time);
-  Cli_Printf("Average ICP Request Time ------------------- %f ms\n", total_icp_request_time);
-  Cli_Printf("\n");
-  Cli_Printf("--Queries Originating from ICP Peers--\n");
-  Cli_Printf("Query Messages Received -------------------- %d\n", icp_remote_query_requests);
-  Cli_Printf("Remote Query Hits -------------------------- %d\n", cache_lookup_success);
-  Cli_Printf("Remote Query Misses ------------------------ %d\n", cache_lookup_fail);
-  Cli_Printf("Successful Response Message Sent to Peers -- %d\n", query_response_write);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show proxy-stats sub-command
-int
-ShowCacheStats()
-{
-  //variable delaration
-  TSInt bytes_used = -1;
-  TSInt bytes_total = -1;
-  TSInt ram_cache_total_bytes = -1;
-  TSInt ram_cache_bytes_used = -1;
-  TSInt ram_cache_hits = -1;
-  TSInt ram_cache_misses = -1;
-  TSInt lookup_active = -1;
-  TSInt lookup_success = -1;
-  TSInt lookup_failure = -1;
-  TSInt read_active = -1;
-  TSInt read_success = -1;
-  TSInt read_failure = -1;
-  TSInt write_active = -1;
-  TSInt write_success = -1;
-  TSInt write_failure = -1;
-  TSInt update_active = -1;
-  TSInt update_success = -1;
-  TSInt update_failure = -1;
-  TSInt remove_active = -1;
-  TSInt remove_success = -1;
-  TSInt remove_failure = -1;
-
-  //get values
-
-  Cli_RecordGetInt("proxy.process.cache.bytes_used", &bytes_used);
-  Cli_RecordGetInt("proxy.process.cache.bytes_total", &bytes_total);
-  Cli_RecordGetInt("proxy.process.cache.ram_cache.total_bytes", &ram_cache_total_bytes);
-  Cli_RecordGetInt("proxy.process.cache.ram_cache.bytes_used", &ram_cache_bytes_used);
-  Cli_RecordGetInt("proxy.process.cache.ram_cache.hits", &ram_cache_hits);
-  Cli_RecordGetInt("proxy.process.cache.ram_cache.misses", &ram_cache_misses);
-  Cli_RecordGetInt("proxy.process.cache.lookup.active", &lookup_active);
-  Cli_RecordGetInt("proxy.process.cache.lookup.success", &lookup_success);
-  Cli_RecordGetInt("proxy.process.cache.lookup.failure", &lookup_failure);
-  Cli_RecordGetInt("proxy.process.cache.read.active", &read_active);
-  Cli_RecordGetInt("proxy.process.cache.read.success", &read_success);
-  Cli_RecordGetInt("proxy.process.cache.read.failure", &read_failure);
-  Cli_RecordGetInt("proxy.process.cache.write.active", &write_active);
-  Cli_RecordGetInt("proxy.process.cache.write.success", &write_success);
-  Cli_RecordGetInt("proxy.process.cache.write.failure", &write_failure);
-  Cli_RecordGetInt("proxy.process.cache.update.active", &update_active);
-  Cli_RecordGetInt("proxy.process.cache.update.success", &update_success);
-  Cli_RecordGetInt("proxy.process.cache.update.failure", &update_failure);
-  Cli_RecordGetInt("proxy.process.cache.remove.active", &remove_active);
-  Cli_RecordGetInt("proxy.process.cache.remove.success", &remove_success);
-  Cli_RecordGetInt("proxy.process.cache.remove.failure", &remove_failure);
-
-  //display values
-  Cli_Printf("\n");
-  Cli_Printf("Bytes Used --- %d GB\n", bytes_used / (1024 * 1024 * 1024));
-  Cli_Printf("Cache Size --- %d GB\n", bytes_total / (1024 * 1024 * 1024));
-  Cli_Printf("--RAM Cache--\n");
-  Cli_Printf("Total Bytes -- %" PRId64 "\n", ram_cache_total_bytes);
-  Cli_Printf("Bytes Used --- %" PRId64 "\n", ram_cache_bytes_used);
-  Cli_Printf("Hits --------- %d\n", ram_cache_hits);
-  Cli_Printf("Misses ------- %d\n", ram_cache_misses);
-  Cli_Printf("--Lookups--\n");
-  Cli_Printf("In Progress -- %d\n", lookup_active);
-  Cli_Printf("Hits --------- %d\n", lookup_success);
-  Cli_Printf("Misses ------- %d\n", lookup_failure);
-  Cli_Printf("--Reads--\n");
-  Cli_Printf("In Progress -- %d\n", read_active);
-  Cli_Printf("Hits --------- %d\n", read_success);
-  Cli_Printf("Misses ------- %d\n", read_failure);
-  Cli_Printf("--Writes--\n");
-  Cli_Printf("In Progress -- %d\n", write_active);
-  Cli_Printf("Hits --------- %d\n", write_success);
-  Cli_Printf("Misses ------- %d\n", write_failure);
-  Cli_Printf("--Updates--\n");
-  Cli_Printf("In Progress -- %d\n", update_active);
-  Cli_Printf("Hits --------- %d\n", update_success);
-  Cli_Printf("Misses ------- %d\n", update_failure);
-  Cli_Printf("--Removes--\n");
-  Cli_Printf("In Progress -- %d\n", remove_active);
-  Cli_Printf("Hits --------- %d\n", remove_success);
-  Cli_Printf("Misses ------- %d\n", remove_failure);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show proxy-stats sub-command
-int
-ShowHostDbStats()
-{
-  //variables
-  TSFloat hit_ratio = -1.0;
-  TSFloat lookups_per_second = -1.0;
-
-  //get values
-  Cli_RecordGetFloat("proxy.node.hostdb.hit_ratio", &hit_ratio);
-  Cli_RecordGetFloat("proxy.node.dns.lookups_per_second", &lookups_per_second);
-
-  //display values
-  Cli_Printf("\n");
-  Cli_Printf("Host Database hit Rate -- %f %% *\n", 100 * hit_ratio);
-  Cli_Printf("DNS Lookups Per Second -- %f\n", lookups_per_second);
-  Cli_Printf("\n* Value reprensents 10 second average.\n");
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show proxy-stats sub-command
-int
-ShowDnsStats()
-{
-  TSFloat lookups_per_second = -1.0;
-
-  Cli_RecordGetFloat("proxy.node.dns.lookups_per_second", &lookups_per_second);
-  Cli_Printf("\n");
-  Cli_Printf("DNS Lookups Per Second -- %f\n", lookups_per_second);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show proxy-stats sub-command
-int
-ShowLoggingStats()
-{
-  TSCounter log_file_open = -1;
-  TSInt log_files_space_used = -1;
-  TSCounter event_log_access = -1;
-  TSCounter event_log_access_skip = -1;
-  TSCounter event_log_error = -1;
-
-  Cli_RecordGetCounter("proxy.process.log.log_files_open", &log_file_open);
-  Cli_RecordGetInt("proxy.process.log.log_files_space_used", &log_files_space_used);
-  Cli_RecordGetCounter("proxy.process.log.event_log_access", &event_log_access);
-  Cli_RecordGetCounter("proxy.process.log.event_log_access_skip", &event_log_access_skip);
-  Cli_RecordGetCounter("proxy.process.log.event_log_error", &event_log_error);
-
-  Cli_Printf("\n");
-  Cli_Printf("Current Open Log Files ----------- %d\n", log_file_open);
-  Cli_Printf("Space Used For Log Files --------- %d\n", log_files_space_used);
-  Cli_Printf("Number of Access Events Logged --- %d\n", event_log_access);
-  Cli_Printf("Number of Access Events Skipped -- %d\n", event_log_access_skip);
-  Cli_Printf("Number of Error Events Logged ---- %d\n", event_log_error);
-  Cli_Printf("\n");
-
-  return CLI_OK;
-}
-
-// show:alarms sub-command
-int
-ShowAlarms()
-{
-  TSList events;
-  int count, i;
-  char *name;
-
-  events = TSListCreate();
-  TSError status = TSActiveEventGetMlt(events);
-  if (status != TS_ERR_OKAY) {
-    if (events) {
-      TSListDestroy(events);
-    }
-    Cli_Error(ERR_ALARM_LIST);
-    return CLI_ERROR;
-  }
-
-  count = TSListLen(events);
-  if (count > 0) {
-    Cli_Printf("\nActive Alarms\n");
-    for (i = 0; i < count; i++) {
-      name = (char *) TSListDequeue(events);
-      Cli_Printf("  %d. %s\n", i + 1, name);
-    }
-    Cli_Printf("\n");
-  } else {
-    Cli_Printf("\nNo active alarms.\n\n");
-  }
-
-  TSListDestroy(events);
-
-  return CLI_OK;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/ShowCmd.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/ShowCmd.h b/mgmt/cli/ShowCmd.h
deleted file mode 100644
index ab9a8c6..0000000
--- a/mgmt/cli/ShowCmd.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/****************************************************************
- * Filename: ShowCmd.h
- * Purpose: This file contains the CLI's "show" command definitions.
- *
- *
- ****************************************************************/
-
-#include <tcl.h>
-#include "createArgument.h"
-#include "definitions.h"
-
-#ifndef __SHOW_CMD_H__
-#define __SHOW_CMD_H__
-
-// enumerated type which captures all "show" commands
-typedef enum
-{
-  CMD_SHOW_STATUS = 1,
-  CMD_SHOW_VERSION,
-  CMD_SHOW_PORTS,
-  CMD_SHOW_CLUSTER,
-  CMD_SHOW_SECURITY,
-  CMD_SHOW_HTTP,
-  CMD_SHOW_ICP,
-  CMD_SHOW_ICP_PEER,
-  CMD_SHOW_PROXY,
-  CMD_SHOW_CACHE,
-  CMD_SHOW_CACHE_RULES,
-  CMD_SHOW_CACHE_STORAGE,
-  CMD_SHOW_VIRTUAL_IP,
-  CMD_SHOW_HOSTDB,
-  CMD_SHOW_DNS_RESOLVER,
-  CMD_SHOW_LOGGING,
-  CMD_SHOW_SSL,
-  CMD_SHOW_FILTER,
-  CMD_SHOW_PARENTS,
-  CMD_SHOW_PARENT_RULES,
-  CMD_SHOW_REMAP,
-  CMD_SHOW_SOCKS,
-  CMD_SHOW_SOCKS_RULES,
-  CMD_SHOW_PORT_TUNNELS,
-  CMD_SHOW_SCHEDULED_UPDATE,
-  CMD_SHOW_UPDATE_RULES,
-  CMD_SHOW_PROXY_STATS,
-  CMD_SHOW_HTTP_TRANS_STATS,
-  CMD_SHOW_HTTP_STATS,
-  CMD_SHOW_ICP_STATS,
-  CMD_SHOW_CACHE_STATS,
-  CMD_SHOW_HOSTDB_STATS,
-  CMD_SHOW_DNS_STATS,
-  CMD_SHOW_LOGGING_STATS
-} cliShowCommand;
-
-////////////////////////////////////////////////////////////////
-// ShowCmd
-//
-// This is the callback function for the "show" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int ShowCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// ShowCmdArgs
-//
-// Register "show" command arguments with the Tcl interpreter.
-//
-int ShowCmdArgs();
-
-int Cmd_Show(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowStatus(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowVersion(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowPorts(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowCluster(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowSecurity(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowHttp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowIcp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int CmdArgs_ShowIcp();
-int Cmd_ShowProxy(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowCache(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int CmdArgs_ShowCache();
-int Cmd_ShowVirtualIp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowHostDb(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowDnsResolver(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowLogging(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowSsl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowParents(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int CmdArgs_ShowParents();
-int Cmd_ShowRemap(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowSocks(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int CmdArgs_ShowSocks();
-int Cmd_ShowScheduledUpdate(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int CmdArgs_ShowScheduledUpdate();
-int Cmd_ShowProxyStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowHttpTransStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowHttpStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowIcpStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowCacheStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowHostDbStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowDnsStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowLoggingStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowAlarms(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowRadius(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowNtlm(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int Cmd_ShowNtlmStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int CmdArgs_None();
-
-int getnameserver(char *nameserver, int len);
-int getrouter(char *router, int len);
-
-////////////////////////////////////////////////////////////////
-//
-// "show" sub-command implementations
-//
-////////////////////////////////////////////////////////////////
-
-// show status sub-command
-int ShowStatus();
-
-// show version sub-command
-int ShowVersion();
-
-// show ports sub-command
-int ShowPorts();
-
-// show cluster sub-command
-int ShowCluster();
-
-// show security sub-command
-int ShowSecurity();
-
-// show http sub-command
-int ShowHttp();
-
-// show icp sub-command
-int ShowIcp();
-
-// show icp peer sub-command
-int ShowIcpPeer();
-
-// show proxy sub-command
-int ShowProxy();
-
-// show cache sub-command
-int ShowCache();
-
-// show cache rules sub-command
-int ShowCacheRules();
-
-// show cache storage sub-command
-int ShowCacheStorage();
-
-// show virtual-ip sub-command
-int ShowVirtualIp();
-
-// show hostdb sub-command
-int ShowHostDb();
-
-// show dns-resolver sub-command
-int ShowDnsResolver();
-
-// show logging sub-command
-int ShowLogging();
-
-// show ssl sub-command
-int ShowSsl();
-
-// show parents sub-command
-int ShowParents();
-
-// show:parent rules sub-command
-int ShowParentRules();
-
-// show remap sub-command
-int ShowRemap();
-
-// show socks sub-command
-int ShowSocks();
-
-// show:socks rules sub-command
-int ShowSocksRules();
-
-// show scheduled-update sub-command
-int ShowScheduledUpdate();
-
-// show:scheduled-update rules sub-command
-int ShowScheduledUpdateRules();
-
-////////////////////////////////////////////////////////////////
-// statistics sub-commands
-//
-
-// show proxy-stats sub-command
-int ShowProxyStats();
-
-// show proxy-stats sub-command
-int ShowHttpTransStats();
-
-// show proxy-stats sub-command
-int ShowHttpStats();
-
-// show proxy-stats sub-command
-int ShowIcpStats();
-
-// show proxy-stats sub-command
-int ShowCacheStats();
-
-// show proxy-stats sub-command
-int ShowHostDbStats();
-
-// show proxy-stats sub-command
-int ShowDnsStats();
-
-// show proxy-stats sub-command
-int ShowLoggingStats();
-
-// show:alarms sub-command
-int ShowAlarms();
-
-#endif // __SHOW_CMD_H__


[18/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/ConfigCmd.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ConfigCmd.cc b/cmd/traffic_shell/ConfigCmd.cc
new file mode 100644
index 0000000..a40da20
--- /dev/null
+++ b/cmd/traffic_shell/ConfigCmd.cc
@@ -0,0 +1,4626 @@
+/** @file
+
+  This file contains the CLI's "config" command implementation.
+
+  @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.
+ 
+  @section description createArgument("timezone",1,CLI_ARGV_OPTION_INT_VALUE,
+		  (char*)NULL, CMD_CONFIG_TIMEZONE, "Time Zone",
+                  (char*)NULL);
+ */
+
+
+#include "libts.h"
+#include "I_Layout.h"
+#include "mgmtapi.h"
+#include "ShowCmd.h"
+#include "ConfigCmd.h"
+#include "createArgument.h"
+#include "CliMgmtUtils.h"
+#include "CliDisplay.h"
+// TODO: Remove all those system defines
+//       and protecect them via #ifdef HAVE_FOO_H
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <termios.h>
+#include <stdarg.h>
+#include <sys/ioctl.h>
+#include <time.h>
+#include <sys/time.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+
+bool enable_restricted_commands = false;
+
+static int find_value(const char *pathname, const char *key, char *value, int value_len, const char *delim, int no);
+
+int
+u_getch(void)
+{
+  static signed int returned = (-1), fd;
+  static struct termios new_io_settings, old_io_settings;
+  fd = fileno(stdin);
+  tcgetattr(fd, &old_io_settings);
+  new_io_settings = old_io_settings;
+  new_io_settings.c_lflag &= ~(ICANON | ECHO);
+  tcsetattr(fd, TCSANOW, &new_io_settings);
+  returned = getchar();
+  tcsetattr(fd, TCSANOW, &old_io_settings);
+  return returned;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_Enable
+//
+// This is the callback
+// function for the "enable" command.
+// TODO: This currently doesn't do anything, these commands are
+//       always available.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_Enable(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable, *infoPtr;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+  infoPtr = argtable;
+
+  /* Add "enable status" to check the status of enable/disable */
+  if (argc == 2) {
+    switch (infoPtr->parsed_args) {
+    case CMD_ENABLE_STATUS:
+      if (enable_restricted_commands == true) {
+        Cli_Printf("on\n");
+        return CMD_OK;
+      } else {
+        Cli_Printf("off\n");
+        return CMD_ERROR;
+      }
+    default:
+      Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+      return CMD_ERROR;
+    }
+  }
+
+  if (enable_restricted_commands == true) {
+    Cli_Printf("Already Enabled\n");
+    return CMD_OK;
+  }
+
+  // TODO: replace this assert with appropriate authentication
+  ink_release_assert(enable_restricted_commands);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_Enable
+//
+// Register "enable" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_Enable()
+{
+
+  createArgument("status", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_ENABLE_STATUS, "Check Enable Status", (char *) NULL);
+  return CLI_OK;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_Disable
+//
+// This is the callback
+// function for the "disable" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_Disable(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (getuid() == 0) {
+    Cli_Printf("root user cannot \"disable\"\n");
+    return 0;
+  }
+
+  enable_restricted_commands = false;
+  return 0;
+}
+
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_Config
+//
+// This is the callback function for the "config" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_Config(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  char *cmdinfo, *temp;
+  int i = 0;
+
+  Cli_Debug("Cmd_Config\n");
+  Tcl_Eval(interp, "info commands config* ");
+
+  size_t cmdinfo_len = strlen(Tcl_GetStringResult(interp)) + 2;
+  cmdinfo = (char *)alloca(sizeof(char) * cmdinfo_len);
+  ink_strlcpy(cmdinfo, Tcl_GetStringResult(interp), cmdinfo_len);
+  size_t temp_len = strlen(cmdinfo) + 20;
+  temp = (char *)alloca(sizeof(char) * temp_len);
+  ink_strlcpy(temp, "lsort \"", temp_len);
+  ink_strlcat(temp, cmdinfo, temp_len);
+  ink_strlcat(temp, "\"", temp_len);
+
+  Tcl_Eval(interp, temp);
+  ink_strlcpy(cmdinfo, Tcl_GetStringResult(interp), cmdinfo_len);
+  i = i + strlen("config ");
+  while (cmdinfo[i] != 0) {
+    if (cmdinfo[i] == ' ') {
+      cmdinfo[i] = '\n';
+    }
+    i++;
+  }
+  cmdinfo[i] = '\n';
+  i++;
+  cmdinfo[i] = 0;
+  Cli_Printf("Following are the available config commands\n");
+  Cli_Printf(cmdinfo + strlen("config "));
+
+  return CLI_OK;
+
+}
+
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_Config
+//
+// Register "config" command arguments with the Tcl interpreter.
+//
+int
+CmdArgs_Config()
+{
+  Cli_Debug("CmdArgs_Config\n");
+
+  return CLI_OK;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigGet
+//
+// This is the callback function for the "config:get" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigGet(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:get") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+
+  Cli_Debug("Cmd_ConfigGet argc %d\n", argc);
+
+  if (argc == 2) {
+    return (ConfigGet(argv[1]));
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigSet
+//
+// This is the callback function for the "config:set" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigSet(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:set") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+
+  Cli_Debug("Cmd_ConfigSet argc %d\n", argc);
+
+  if (argc == 3) {
+    return (ConfigSet(argv[1], argv[2]));
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigName
+//
+// This is the callback function for the "config:name" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigName(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:name") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+
+  Cli_Debug("Cmd_ConfigName argc %d\n", argc);
+
+  return (ConfigName(argv[1]));
+
+  // coverity[unreachable]
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigStart
+//
+// This is the callback function for the "config:start" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigStart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:start") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+
+  Cli_Debug("Cmd_ConfigStart argc %d\n", argc);
+
+  if (argc == 1) {
+    return (ConfigStart());
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigStop
+//
+// This is the callback function for the "config:stop" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigStop(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+  if (cliCheckIfEnabled("config:stop") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  Cli_Debug("Cmd_ConfigStop argc %d\n", argc);
+
+  if (argc == 1) {
+    return (ConfigStop());
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigHardRestart
+//
+// This is the callback function for the "config:hard-restart" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigHardRestart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+  if (cliCheckIfEnabled("config:hard-restart") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  Cli_Debug("Cmd_ConfigHardRestart argc %d\n", argc);
+
+  if (argc == 1) {
+    return (TSHardRestart());
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigRestart
+//
+// This is the callback function for the "config:restart" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigRestart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+  if (cliCheckIfEnabled("config:restart") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+  Cli_Debug("Cmd_ConfigRestart argc %d\n", argc);
+
+  if (argc == 1) {
+    return (TSRestart(false));
+  } else if (argc == 2) {
+    if (argtable[0].parsed_args == CMD_CONFIG_RESTART_CLUSTER) {
+      return (TSRestart(true));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigRestart
+//
+// Register "config:restart" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigRestart()
+{
+  createArgument("cluster", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_RESTART_CLUSTER, "Restart the entire cluster", (char *) NULL);
+
+  return 0;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigParents
+//
+// This is the callback function for the "config:parents" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigParents(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:parents") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigParents argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable, *infoPtr;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+  infoPtr = argtable;
+
+  if (argc == 1) {
+    Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+    return CMD_ERROR;
+  }
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (infoPtr->parsed_args) {
+    case CMD_CONFIG_PARENTS_STATUS:
+      return (Cli_RecordOnOff_Action((argc == 3),
+                                     "proxy.config.http.parent_proxy_routing_enable", argtable->arg_string));
+
+    case CMD_CONFIG_PARENTS_CACHE:
+      return (Cli_RecordString_Action((argc == 3), "proxy.config.http.parent_proxies", argtable->arg_string));
+
+    case CMD_CONFIG_PARENTS_CONFIG_FILE:
+      return (Cli_ConfigFileURL_Action(TS_FNAME_PARENT_PROXY, "parent.config", argtable->arg_string));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigParents
+//
+// Register "config:parents" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigParents()
+{
+
+  createArgument("status", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_PARENTS_STATUS, "Parenting <on|off>", (char *) NULL);
+  createArgument("name", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_PARENTS_CACHE, "Specify cache parent", (char *) NULL);
+  createArgument("rules", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_PARENTS_CONFIG_FILE, "Specify config file", (char *) NULL);
+  return CLI_OK;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigRemap
+//
+// This is the callback function for the "config:remap" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigRemap(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:remap") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  Cli_Debug("Cmd_ConfigRemap argc %d\n", argc);
+
+  if (argc == 2) {
+    return (ConfigRemap(argv[1]));
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigPorts
+//
+// This is the callback function for the "config:ports" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigPorts(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:ports") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  Cli_Debug("Cmd_ConfigPorts argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  Cli_Debug("Cmd_ConfigPorts argc %d\n", argc);
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+
+    if (argc == 2) {            // get
+      return (ConfigPortsGet(argtable[0].parsed_args));
+    } else {                    // set
+      switch (argtable->parsed_args) {
+      case CMD_CONFIG_PORTS_CONNECT:
+        return (ConfigPortsSet(argtable[0].parsed_args, argtable[0].data));
+        break;
+      case CMD_CONFIG_PORTS_HTTP_SERVER:
+      case CMD_CONFIG_PORTS_CLUSTER:
+      case CMD_CONFIG_PORTS_CLUSTER_RS:
+      case CMD_CONFIG_PORTS_CLUSTER_MC:
+      case CMD_CONFIG_PORTS_SOCKS_SERVER:
+      case CMD_CONFIG_PORTS_ICP:
+        return (ConfigPortsSet(argtable[0].parsed_args, &argtable[0].arg_int));
+      }
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX,
+            "\n\nconfig:ports <http-server | http-other | webui | cluster-rs | cluster-mc | \n  ssl | \n socks-server | icp > \n <port | ports list>\n");
+  return CMD_ERROR;
+
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigPorts
+//
+// Register "config:ports" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigPorts()
+{
+  createArgument("http-server", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_PORTS_HTTP_SERVER, "Set Ports for http-server", (char *) NULL);
+  createArgument("cluster", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_PORTS_CLUSTER, "Set Ports for cluster", (char *) NULL);
+  createArgument("cluster-rs", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_PORTS_CLUSTER_RS, "Set Ports for cluster-rs", (char *) NULL);
+  createArgument("cluster-mc", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_PORTS_CLUSTER_MC, "Set Ports for cluster-mc", (char *) NULL);
+  createArgument("connect", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_PORTS_CONNECT, "Set Ports for allowed CONNECT", (char *) NULL);
+  createArgument("socks-server", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_PORTS_SOCKS_SERVER, "Set Ports for socks-server", (char *) NULL);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigClock
+//
+// This is the callback function for the "config:clock" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigClock(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  int setvar = 0;
+
+  if (cliCheckIfEnabled("config:clock") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigClock argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  Cli_PrintArg(0, argtable);
+  Cli_PrintArg(1, argtable);
+
+  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable[0].parsed_args) {
+    case CMD_CONFIG_DATE:
+      return (ConfigDate(argtable->arg_string));
+    case CMD_CONFIG_TIME:
+      return (ConfigTime(argtable->arg_string));
+    case CMD_CONFIG_TIMEZONE:
+      if (argc == 3) {
+        setvar = 1;
+      }
+      if (argtable[1].parsed_args == CMD_CONFIG_TIMEZONE_LIST) {
+        return (ConfigTimezoneList());
+      } else {
+        return (ConfigTimezone(argtable->arg_int, setvar));
+      }
+    }
+  }
+
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigClock
+//
+// Register "config:clock" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigClock()
+{
+  createArgument("date", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_DATE, "System Date <mm/dd/yyyy>", (char *) NULL);
+
+  createArgument("time", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_TIME, "System Time <hh:mm:ss>", (char *) NULL);
+
+  createArgument("timezone", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_TIMEZONE, "Time Zone", (char *) NULL);
+
+  createArgument("list", CMD_CONFIG_TIMEZONE, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_TIMEZONE_LIST, "Display Time Zone List", (char *) NULL);
+
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigSecurity
+//
+// This is the callback function for the "config:security" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigSecurity(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:security") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigSecurity argc %d\n", argc);
+
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable[0].parsed_args) {
+    case CMD_CONFIG_SECURITY_IP:
+      return (Cli_ConfigFileURL_Action(TS_FNAME_IP_ALLOW, "ip_allow.config", argtable->arg_string));
+
+    case CMD_CONFIG_SECURITY_PASSWORD:
+      return (ConfigSecurityPasswd());
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigSecurity
+//
+// Register "config:security" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigSecurity()
+{
+  createArgument("ip-allow", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_SECURITY_IP, "Clients allowed to connect to proxy <url>", (char *) NULL);
+  createArgument("password", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_SECURITY_PASSWORD, "Change Admin Password", (char *) NULL);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigHttp
+//
+// This is the callback function for the "config:http" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigHttp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  int setvar = 0;
+  if (cliCheckIfEnabled("config:http") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  Cli_Debug("Cmd_ConfigHttp argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  if (argc == 3) {
+    setvar = 1;
+  }
+
+  if (argc > 3) {
+    Cli_Error("Too many arguments\n");
+    Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+    return CMD_ERROR;
+  }
+
+  Cli_PrintArg(0, argtable);
+  Cli_PrintArg(1, argtable);
+
+  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_HTTP_STATUS:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.http.cache.http", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_IN:
+      return (Cli_RecordInt_Action(action, "proxy.config.http.keep_alive_no_activity_timeout_in", argtable->arg_int));
+
+    case CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_OUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.http.keep_alive_no_activity_timeout_out", argtable->arg_int));
+
+    case CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_IN:
+      return (Cli_RecordInt_Action(action, "proxy.config.http.transaction_no_activity_timeout_in", argtable->arg_int));
+
+    case CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_OUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.http.transaction_no_activity_timeout_out", argtable->arg_int));
+
+    case CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_IN:
+      return (Cli_RecordInt_Action(action, "proxy.config.http.transaction_active_timeout_in", argtable->arg_int));
+
+    case CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_OUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.http.transaction_active_timeout_out", argtable->arg_int));
+
+    case CMD_CONFIG_HTTP_REMOVE_FROM:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_from", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_REMOVE_REFERER:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_referer", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_REMOVE_USER:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_user_agent", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_REMOVE_COOKIE:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_cookie", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_REMOVE_HEADER:
+      return (Cli_RecordString_Action(action, "proxy.config.http.anonymize_other_header_list", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_GLOBAL_USER_AGENT:
+      return (Cli_RecordString_Action(action, "proxy.config.http.global_user_agent_header", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_INSERT_IP:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_insert_client_ip", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_REMOVE_IP:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_client_ip", argtable->arg_string));
+
+    case CMD_CONFIG_HTTP_PROXY:
+      return (ConfigHttpProxy(argtable[1].parsed_args, setvar));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigHttp
+//
+// Register "config:http" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigHttp()
+{
+  createArgument("status", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_STATUS, "HTTP proxying <on | off>", (char *) NULL);
+
+  createArgument("keep-alive-timeout-in", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_IN, "Keep alive timeout inbound <seconds>",
+                 (char *) NULL);
+  createArgument("keep-alive-timeout-out", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_OUT, "Keep alive timeout outbound <seconds>",
+                 (char *) NULL);
+  createArgument("inactive-timeout-in", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_IN, "Inactive timeout inbound <seconds>",
+                 (char *) NULL);
+  createArgument("inactive-timeout-out", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_OUT, "Inactive timeout outbound <seconds>",
+                 (char *) NULL);
+  createArgument("active-timeout-in", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_IN, "Active timeout inbound <seconds>", (char *) NULL);
+  createArgument("active-timeout-out", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_OUT, "Active timeout outbound <seconds>", (char *) NULL);
+
+  createArgument("remove-from", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_FROM, "Remove \"From:\" header <on|off>", (char *) NULL);
+  createArgument("remove-referer", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_REFERER, "Remove \"Referer:\" header <on|off>", (char *) NULL);
+  createArgument("remove-user", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_USER, "Remove \"User:\" header <on|off>", (char *) NULL);
+  createArgument("remove-cookie", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_COOKIE, "Remove \"Cookie:\" header <on|off>", (char *) NULL);
+  createArgument("remove-header", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_HEADER, "String of headers to be removed <string>",
+                 (char *) NULL);
+
+  createArgument("global-user-agent", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_GLOBAL_USER_AGENT, "User-Agent to send to Origin <string>",
+                 (char *) NULL);
+
+  createArgument("insert-ip", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_INSERT_IP, "Insert client IP into header <on|off>", (char *) NULL);
+  createArgument("remove-ip", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_IP, "Remove client IP from header <on|off>", (char *) NULL);
+  createArgument("proxy", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_HTTP_PROXY, "Proxy Mode <fwd | rev | fwd-rev>", (char *) NULL);
+  createArgument("fwd", CMD_CONFIG_HTTP_PROXY, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_HTTP_FWD, "Specify proxy mode to be forward", (char *) NULL);
+  createArgument("rev", CMD_CONFIG_HTTP_PROXY, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_HTTP_REV, "Specify proxy mode to be reverse", (char *) NULL);
+  createArgument("fwd-rev", CMD_CONFIG_HTTP_PROXY, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_HTTP_FWD_REV, "Specify proxy mode to be both", (char *) NULL);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigIcp
+//
+// This is the callback function for the "config:icp" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigIcp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:icp") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigIcp argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_ICP_MODE:
+      return (ConfigIcpMode(argtable[1].parsed_args, action));
+
+    case CMD_CONFIG_ICP_PORT:
+      return (Cli_RecordInt_Action(action, "proxy.config.icp.icp_port", argtable->arg_int));
+
+    case CMD_CONFIG_ICP_MCAST:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.icp.multicast_enabled", argtable->arg_string));
+
+    case CMD_CONFIG_ICP_QTIMEOUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.icp.query_timeout", argtable->arg_int));
+
+    case CMD_CONFIG_ICP_PEERS:
+      return (Cli_ConfigFileURL_Action(TS_FNAME_ICP_PEER, "icp.config", argtable->arg_string));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigIcp
+//
+// Register "config:Icp" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigIcp()
+{
+  createArgument("mode", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_ICP_MODE, "Mode <disabled | receive | send-receive>", (char *) NULL);
+
+  createArgument("receive", CMD_CONFIG_ICP_MODE, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_ICP_MODE_RECEIVE, "Specify receive mode for icp", (char *) NULL);
+
+  createArgument("send-receive", CMD_CONFIG_ICP_MODE, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_ICP_MODE_SENDRECEIVE, "Specify send & receive mode for icp", (char *) NULL);
+
+  createArgument("disabled", CMD_CONFIG_ICP_MODE, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_ICP_MODE_DISABLED, "icp mode disabled", (char *) NULL);
+
+  createArgument("port", 1, CLI_ARGV_OPTION_INT_VALUE, (char *) NULL, CMD_CONFIG_ICP_PORT, "Port <int>", (char *) NULL);
+  createArgument("multicast", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_ICP_MCAST, "Multicast <on|off>", (char *) NULL);
+  createArgument("query-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_ICP_QTIMEOUT, "Query Timeout <seconds>", (char *) NULL);
+  createArgument("peers", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_ICP_PEERS, "URL for ICP Peers config file <url>", (char *) NULL);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigPortTunnles
+//
+// Register "config:PortTunnles" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigPortTunnels()
+{
+
+  createArgument("server-other-ports", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_PORT_TUNNELS_SERVER_OTHER_PORTS, "Set the tunnel port number <int>",
+                 (char *) NULL);
+  return 0;
+}
+
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigScheduledUpdate
+//
+// This is the callback function for the "config:scheduled-update" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigScheduledUpdate(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:scheduled-update") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigScheduledUpdate argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_SCHEDULED_UPDATE_STATUS:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.update.enabled", argtable->arg_string));
+
+    case CMD_CONFIG_SCHEDULED_UPDATE_RETRY_COUNT:
+      return (Cli_RecordInt_Action(action, "proxy.config.update.retry_count", argtable->arg_int));
+
+    case CMD_CONFIG_SCHEDULED_UPDATE_RETRY_INTERVAL:
+      return (Cli_RecordInt_Action(action, "proxy.config.update.retry_interval", argtable->arg_int));
+
+    case CMD_CONFIG_SCHEDULED_UPDATE_MAX_CONCURRENT:
+      return (Cli_RecordInt_Action(action, "proxy.config.update.concurrent_updates", argtable->arg_int));
+
+    case CMD_CONFIG_SCHEDULED_UPDATE_FORCE_IMMEDIATE:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.update.force", argtable->arg_string));
+
+    case CMD_CONFIG_SCHEDULED_UPDATE_RULES:
+      return (Cli_ConfigFileURL_Action(TS_FNAME_UPDATE_URL, "update.config", argtable->arg_string));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigScheduled-Update
+//
+// Register "config:Scheduled-Update" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigScheduledUpdate()
+{
+  createArgument("status", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_STATUS, "Set scheduled-update status <on | off>",
+                 (char *) NULL);
+  createArgument("retry-count", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_RETRY_COUNT, "Set retry-count <int>", (char *) NULL);
+  createArgument("retry-interval", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_RETRY_INTERVAL, "Set retry-interval <sec>", (char *) NULL);
+  createArgument("max-concurrent", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_MAX_CONCURRENT, "Set maximum concurrent updates",
+                 (char *) NULL);
+  createArgument("force-immediate", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_FORCE_IMMEDIATE, "Set force-immediate <on | off>",
+                 (char *) NULL);
+  createArgument("rules", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_RULES, "Update update.config file from url <string>",
+                 (char *) NULL);
+
+  return 0;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigSocks
+//
+// This is the callback function for the "config:scheduled-update" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigSocks(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:socks") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigSocks argc %d\n", argc);
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_SOCKS_STATUS:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.socks.socks_needed", argtable->arg_string));
+
+    case CMD_CONFIG_SOCKS_VERSION:
+      return (Cli_RecordInt_Action(action, "proxy.config.socks.socks_version", argtable->arg_int));
+
+    case CMD_CONFIG_SOCKS_DEFAULT_SERVERS:
+      return (Cli_RecordString_Action(action, "proxy.config.socks.default_servers", argtable->arg_string));
+
+    case CMD_CONFIG_SOCKS_ACCEPT:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.socks.accept_enabled", argtable->arg_string));
+
+    case CMD_CONFIG_SOCKS_ACCEPT_PORT:
+      return (Cli_RecordInt_Action(action, "proxy.config.socks.accept_port", argtable->arg_int));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigScheduled-Update
+//
+// Register "config:Scheduled-Update" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigSocks()
+{
+  createArgument("status", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_SOCKS_STATUS, "Set socks status <on | off>", (char *) NULL);
+
+  createArgument("version", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_SOCKS_VERSION, "Set version <int>", (char *) NULL);
+
+  createArgument("default-servers", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_SOCKS_DEFAULT_SERVERS, "Set default-servers <string>", (char *) NULL);
+
+  createArgument("accept", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_SOCKS_ACCEPT, "Set accept <on | off>", (char *) NULL);
+
+  createArgument("accept-port", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_SOCKS_ACCEPT_PORT, "Set server accept-port <int>", (char *) NULL);
+
+  return 0;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigCache
+//
+// This is the callback function for the "config:cache" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigCache(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:cache") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigCache argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int action = 0;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_CACHE_HTTP:
+      return (Cli_RecordOnOff_Action((argc == 3), "proxy.config.http.cache.http", argtable->arg_string));
+
+    case CMD_CONFIG_CACHE_CLUSTER_BYPASS:
+      return (Cli_RecordOnOff_Action((argc == 3),
+                                     "proxy.config.http.cache.cluster_cache_local", argtable->arg_string));
+    case CMD_CONFIG_CACHE_IGNORE_BYPASS:
+      return (Cli_RecordOnOff_Action((argc == 3),
+                                     "proxy.config.http.cache.ignore_client_no_cache", argtable->arg_string));
+
+    case CMD_CONFIG_CACHE_MAX_OBJECT_SIZE:
+      return (Cli_RecordInt_Action((argc == 3), "proxy.config.cache.max_doc_size", argtable->arg_int));
+
+    case CMD_CONFIG_CACHE_MAX_ALTERNATES:
+      return (Cli_RecordInt_Action((argc == 3), "proxy.config.cache.limits.http.max_alts", argtable->arg_int));
+
+    case CMD_CONFIG_CACHE_FILE:
+      return (Cli_ConfigFileURL_Action(TS_FNAME_CACHE_OBJ, "cache.config", argtable->arg_string));
+
+    case CMD_CONFIG_CACHE_FRESHNESS:
+      if (argtable[1].parsed_args != CLI_PARSED_ARGV_END) {
+        switch (argtable[1].parsed_args) {
+        case CMD_CONFIG_CACHE_FRESHNESS_VERIFY:
+          if (argc == 4) {
+            action = RECORD_SET;
+          }
+          return (ConfigCacheFreshnessVerify(argtable[2].parsed_args, action));
+
+        case CMD_CONFIG_CACHE_FRESHNESS_MINIMUM:
+          if (argc == 4) {
+            action = RECORD_SET;
+          }
+          return (ConfigCacheFreshnessMinimum(argtable[2].parsed_args, action));
+
+        case CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT:
+          if (argtable[2].parsed_args != CLI_PARSED_ARGV_END) {
+            if ((argtable[2].parsed_args ==
+                 CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_GREATER_THAN) &&
+                (argtable[3].parsed_args == CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_LESS_THAN) && (argc == 7)) {
+              action = RECORD_SET;
+            } else {
+              Cli_Printf("\n config:cache freshness no-expire-limit greater-than <value> less-than<value>\n");
+              return CMD_ERROR;
+            }
+          }
+          Cli_Debug("greater than %d, less than %d \n", argtable[2].arg_int, argtable[3].arg_int);
+          return (ConfigCacheFreshnessNoExpireLimit(argtable[2].arg_int, argtable[3].arg_int, action));
+
+        }
+      }
+      Cli_Printf("\n config:cache freshness <verify | minimum | no-expire-limit> \n");
+      return CMD_ERROR;
+    case CMD_CONFIG_CACHE_DYNAMIC:
+      return (Cli_RecordOnOff_Action((argc == 3),
+                                     "proxy.config.http.cache.cache_urls_that_look_dynamic", argtable->arg_string));
+
+    case CMD_CONFIG_CACHE_ALTERNATES:
+      return (Cli_RecordOnOff_Action((argc == 3),
+                                     "proxy.config.http.cache.enable_default_vary_headers", argtable->arg_string));
+
+    case CMD_CONFIG_CACHE_VARY:
+      if (argtable[1].arg_string) {
+        action = RECORD_SET;
+      }
+      return (ConfigCacheVary(argtable[1].parsed_args, argtable[1].arg_string, action));
+
+    case CMD_CONFIG_CACHE_COOKIES:
+      if (argc == 3) {
+        action = RECORD_SET;
+      }
+      return (ConfigCacheCookies(argtable[1].parsed_args, action));
+    case CMD_CONFIG_CACHE_CLEAR:
+      return (ConfigCacheClear());
+    }
+  }
+
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigCache
+//
+// Register "config:cache" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigCache()
+{
+  createArgument("http", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_HTTP, "HTTP Protocol caching <on|off>", (char *) NULL);
+  createArgument("ignore-bypass", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_IGNORE_BYPASS, "Ignore Bypass <on|off>", (char *) NULL);
+  createArgument("max-object-size", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_MAX_OBJECT_SIZE, "Maximum object size <bytes>", (char *) NULL);
+  createArgument("max-alternates", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_MAX_ALTERNATES, "Maximum alternates <int>", (char *) NULL);
+  createArgument("file", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_FILE, "Load cache.config file from url <string>", (char *) NULL);
+  createArgument("freshness", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS, "Freshness parameters <verify | minimum | no-expire-limit>",
+                 (char *) NULL);
+  createArgument("verify", CMD_CONFIG_CACHE_FRESHNESS, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY,
+                 "Freshness verify <when-expired | no-date | always | never> ", (char *) NULL);
+
+  createArgument("when-expired", CMD_CONFIG_CACHE_FRESHNESS_VERIFY, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY_WHEN_EXPIRED,
+                 "Set freshness verify to be when-expired", (char *) NULL);
+
+  createArgument("no-date", CMD_CONFIG_CACHE_FRESHNESS_VERIFY, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY_NO_DATE,
+                 "Set freshness verify to be no-date", (char *) NULL);
+
+  createArgument("always", CMD_CONFIG_CACHE_FRESHNESS_VERIFY, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY_ALWALYS,
+                 "Set freshness verify to be always", (char *) NULL);
+
+  createArgument("never", CMD_CONFIG_CACHE_FRESHNESS_VERIFY, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY_NEVER,
+                 "Set the freshness verify to be never", (char *) NULL);
+
+  createArgument("minimum", CMD_CONFIG_CACHE_FRESHNESS, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_MINIMUM,
+                 "Set freshness minimum <explicit | last-modified | nothing>", (char *) NULL);
+
+  createArgument("explicit", CMD_CONFIG_CACHE_FRESHNESS_MINIMUM, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_EXPLICIT,
+                 "Set the Freshness Minimum to be explicit", (char *) NULL);
+
+  createArgument("last-modified", CMD_CONFIG_CACHE_FRESHNESS_MINIMUM, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_LAST_MODIFIED,
+                 "Set the Freshness Minimum to be last modified", (char *) NULL);
+
+  createArgument("nothing", CMD_CONFIG_CACHE_FRESHNESS_MINIMUM, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_NOTHING,
+                 "Specify the Freshness minimum to be nothing", (char *) NULL);
+
+  createArgument("no-expire-limit", CMD_CONFIG_CACHE_FRESHNESS, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT,
+                 "Set the Freshness no-expire-limit time", (char *) NULL);
+
+  createArgument("greater-than", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_GREATER_THAN,
+                 "Set the minimum Freshness no-expire-limit time", (char *) NULL);
+
+  createArgument("less-than", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_LESS_THAN,
+                 "Set the maximum Freshness no-expire-limit time", (char *) NULL);
+
+  createArgument("dynamic", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_DYNAMIC, "Set Dynamic <on|off>", (char *) NULL);
+
+  createArgument("alternates", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_ALTERNATES, "Set Alternates <on|off>", (char *) NULL);
+  createArgument("vary", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_CACHE_VARY, "Set vary <text | images | other> <field>", (char *) NULL);
+  createArgument("text", CMD_CONFIG_CACHE_VARY, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_VARY_TEXT, "Set vary text's value", (char *) NULL);
+  createArgument("images", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_VARY_COOKIES_IMAGES, "Set vary images' value", (char *) NULL);
+  createArgument("other", CMD_CONFIG_CACHE_VARY, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_CACHE_VARY_OTHER, "Set vary other's value", (char *) NULL);
+
+  createArgument("cookies", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES, "Set cookies <none | all | images | non-text | non-text-ext>",
+                 (char *) NULL);
+  createArgument("none", CMD_CONFIG_CACHE_COOKIES, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES_NONE, "No cookies", (char *) NULL);
+  createArgument("all", CMD_CONFIG_CACHE_COOKIES, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES_ALL, "All cookies", (char *) NULL);
+  createArgument("non-text", CMD_CONFIG_CACHE_COOKIES, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES_NON_TEXT, "Non-text cookies", (char *) NULL);
+  createArgument("non-text-ext", CMD_CONFIG_CACHE_COOKIES, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES_NON_TEXT_EXT, "Non-text-ext cookies", (char *) NULL);
+  createArgument("clear", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_CACHE_CLEAR, "Clear the cache and start Traffic Server", (char *) NULL);
+  return 0;
+}
+
+
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigHostdb
+//
+// This is the callback function for the "config:hostdb" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigHostdb(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:hostdb") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigHostdb argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_HOSTDB_LOOKUP_TIMEOUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.hostdb.lookup_timeout", argtable->arg_int));
+
+    case CMD_CONFIG_HOSTDB_FOREGROUND_TIMEOUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.hostdb.timeout", argtable->arg_int));
+
+    case CMD_CONFIG_HOSTDB_BACKGROUND_TIMEOUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.hostdb.verify_after", argtable->arg_int));
+
+    case CMD_CONFIG_HOSTDB_INVALID_HOST_TIMEOUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.hostdb.fail.timeout", argtable->arg_int));
+
+    case CMD_CONFIG_HOSTDB_RE_DNS_ON_RELOAD:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.hostdb.re_dns_on_reload", argtable->arg_string));
+    case CMD_CONFIG_HOSTDB_CLEAR:
+      return (ConfigHostdbClear());
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigHostdb
+//
+// Register "config:Hostdb" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigHostdb()
+{
+  createArgument("lookup-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HOSTDB_LOOKUP_TIMEOUT, "Lookup Timeout <seconds>", (char *) NULL);
+  createArgument("foreground-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HOSTDB_FOREGROUND_TIMEOUT, "Foreground Timeout <minutes>", (char *) NULL);
+  createArgument("background-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HOSTDB_BACKGROUND_TIMEOUT, "Background Timeout <minutes>", (char *) NULL);
+  createArgument("invalid-host-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_HOSTDB_INVALID_HOST_TIMEOUT, "Invalid Host Timeout <minutes>",
+                 (char *) NULL);
+  createArgument("re-dns-on-reload", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_HOSTDB_RE_DNS_ON_RELOAD, "Re-DNS on Reload Timeout <on|off>", (char *) NULL);
+  createArgument("clear", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_HOSTDB_CLEAR, "Clear the HostDB and start Traffic Server", (char *) NULL);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigDns
+//
+// This is the callback function for the "config:dns" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigDns(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:dns") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigDns argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_DNS_RESOLVE_TIMEOUT:
+      return (Cli_RecordInt_Action(action, "proxy.config.dns.lookup_timeout", argtable->arg_int));
+
+    case CMD_CONFIG_DNS_RETRIES:
+      return (Cli_RecordInt_Action(action, "proxy.config.dns.retries", argtable->arg_int));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigDns
+//
+// Register "config:dns" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigDns()
+{
+  createArgument("resolve-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_DNS_RESOLVE_TIMEOUT, "Resolve timeout <int>", (char *) NULL);
+  createArgument("retries", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_DNS_RETRIES, "Number of retries <int>", (char *) NULL);
+
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigVirtualip
+//
+// This is the callback function for the "config:virtualip" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigVirtualip(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:virtualip") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigCache argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int setvar = 0;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_VIRTUALIP_STATUS:
+      return (Cli_RecordOnOff_Action((argc == 3), "proxy.config.vmap.enabled", argtable->arg_string));
+
+    case CMD_CONFIG_VIRTUALIP_LIST:
+      return (ConfigVirtualIpList());
+
+    case CMD_CONFIG_VIRTUALIP_ADD:
+      if (argc == 8) {
+        setvar = 1;
+      }
+      Cli_PrintArg(0, argtable);
+      Cli_PrintArg(1, argtable);
+      Cli_PrintArg(2, argtable);
+      Cli_PrintArg(3, argtable);
+      if (ConfigVirtualipAdd(argtable[1].arg_string, argtable[2].arg_string, argtable[3].arg_int, setvar) == CLI_OK) {
+        return CMD_OK;
+      } else {
+        return CMD_ERROR;
+      }
+
+    case CMD_CONFIG_VIRTUALIP_DELETE:
+      if (argc == 3) {
+        setvar = 1;
+      }
+      if (ConfigVirtualipDelete(argtable[0].arg_int, setvar) == CLI_OK) {
+        return CMD_OK;
+      } else {
+        return CMD_ERROR;
+      }
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigVirtualip
+//
+// Register "config:virtualip" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigVirtualip()
+{
+
+  createArgument("status", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_VIRTUALIP_STATUS, "Virtual IP <on | off>", (char *) NULL);
+  createArgument("list", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_VIRTUALIP_LIST, "List virtual IP addresses", (char *) NULL);
+  createArgument("add", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_VIRTUALIP_ADD, "add ip <x.x.x.x> device <string> sub-intf <int>",
+                 (char *) NULL);
+  createArgument("ip", CMD_CONFIG_VIRTUALIP_ADD, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_VIRTUALIP_ADD_IP, "Virtual IP Address <x.x.x.x>", (char *) NULL);
+  createArgument("device", CMD_CONFIG_VIRTUALIP_ADD_IP, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_VIRTUALIP_ADD_DEVICE, "Virtual IP device <string>", (char *) NULL);
+  createArgument("sub-intf", CMD_CONFIG_VIRTUALIP_ADD_DEVICE, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_VIRTUALIP_ADD_SUBINTERFACE, "Virtual IP sub interface <integer>",
+                 (char *) NULL);
+  createArgument("delete", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_VIRTUALIP_DELETE, "Delete Virtual IP <integer>", (char *) NULL);
+  return CLI_OK;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigLogging
+//
+// This is the callback function for the "config:logging" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigLogging(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:logging") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigCache argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int setvar = 0;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_LOGGING_EVENT:
+      if (argc == 3) {
+        setvar = 1;
+      }
+      return (ConfigLoggingEvent(argtable[1].parsed_args, setvar));
+    case CMD_CONFIG_LOGGING_MGMT_DIRECTORY:
+      return (Cli_RecordString_Action((argc == 3), "proxy.config.log.logfile_dir", argtable->arg_string));
+
+    case CMD_CONFIG_LOGGING_SPACE_LIMIT:
+      return (Cli_RecordInt_Action((argc == 3), "proxy.config.log.max_space_mb_for_logs", argtable->arg_int));
+
+    case CMD_CONFIG_LOGGING_SPACE_HEADROOM:
+      return (Cli_RecordInt_Action((argc == 3), "proxy.config.log.max_space_mb_headroom", argtable->arg_int));
+
+    case CMD_CONFIG_LOGGING_COLLATION_STATUS:
+      if (argc == 3) {
+        setvar = 1;
+      }
+      return (ConfigLoggingCollationStatus(argtable[1].parsed_args, setvar));
+    case CMD_CONFIG_LOGGING_COLLATION_HOST:
+      return (Cli_RecordString_Action((argc == 3), "proxy.config.log.collation_host", argtable->arg_string));
+
+    case CMD_CONFIG_LOGGING_COLLATION:
+      if (argc == 8) {
+        setvar = 1;
+      }
+      Cli_PrintArg(1, argtable);
+      Cli_PrintArg(2, argtable);
+      Cli_PrintArg(3, argtable);
+      Cli_PrintArg(4, argtable);
+      return (ConfigLoggingCollation(argtable[1].arg_string, argtable[3].parsed_args, argtable[4].arg_int, setvar));
+    case CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT:
+      if (argc == 10) {
+        setvar = 1;
+      }
+      Cli_PrintArg(1, argtable);
+      Cli_PrintArg(2, argtable);
+      Cli_PrintArg(3, argtable);
+      Cli_PrintArg(4, argtable);
+      Cli_PrintArg(5, argtable);
+      Cli_PrintArg(6, argtable);
+      return (ConfigLoggingFormatTypeFile(argtable[1].parsed_args,
+                                          argtable[2].parsed_args,
+                                          argtable[4].parsed_args,
+                                          argtable[5].arg_string, argtable[6].arg_string, setvar));
+    case CMD_CONFIG_LOGGING_SPLITTING:
+      if (argc == 4) {
+        setvar = 1;
+      }
+      Cli_PrintArg(1, argtable);
+      Cli_PrintArg(2, argtable);
+      return (ConfigLoggingSplitting(argtable[1].parsed_args, argtable[2].parsed_args, setvar));
+
+    case CMD_CONFIG_LOGGING_CUSTOM:
+      if (argc == 5) {
+        setvar = 1;
+      }
+      Cli_PrintArg(1, argtable);
+      Cli_PrintArg(2, argtable);
+      Cli_PrintArg(3, argtable);
+      return (ConfigLoggingCustomFormat(argtable[1].parsed_args, argtable[3].parsed_args, setvar));
+
+    case CMD_CONFIG_LOGGING_ROLLING:
+      if (argc == 9) {
+        setvar = 1;
+      }
+      Cli_PrintArg(1, argtable);
+      Cli_PrintArg(2, argtable);
+      Cli_PrintArg(3, argtable);
+      Cli_PrintArg(4, argtable);
+      Cli_PrintArg(5, argtable);
+      return (ConfigLoggingRollingOffsetIntervalAutodelete(argtable[1].parsed_args,
+                                                           argtable[2].arg_int,
+                                                           argtable[3].arg_int, argtable[5].parsed_args, setvar));
+
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigLogging
+//
+// Register "config:logging" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigLogging()
+{
+
+  createArgument("on", CLI_ARGV_NO_POS, CLI_ARGV_REQUIRED,
+                 (char *) NULL, CMD_CONFIG_LOGGING_ON, "Enable logging", (char *) NULL);
+  createArgument("off", CLI_ARGV_NO_POS, CLI_ARGV_REQUIRED,
+                 (char *) NULL, CMD_CONFIG_LOGGING_OFF, "Disable logging", (char *) NULL);
+  createArgument("event", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT, "Events <enabled | trans-only | error-only | disabled>",
+                 (char *) NULL);
+  createArgument("enabled", CMD_CONFIG_LOGGING_EVENT, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT_ENABLED, "Event logging enabled", (char *) NULL);
+  createArgument("trans-only", CMD_CONFIG_LOGGING_EVENT, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT_TRANS_ONLY, "Event logging for transactions only",
+                 (char *) NULL);
+  createArgument("error-only", CMD_CONFIG_LOGGING_EVENT, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT_ERROR_ONLY, "Event logging for errors only", (char *) NULL);
+  createArgument("disabled", CMD_CONFIG_LOGGING_EVENT, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT_DISABLED, "Event logging is disabled", (char *) NULL);
+  createArgument("mgmt-directory", 1, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_LOGGING_MGMT_DIRECTORY, "Logging MGMT directory <string>", (char *) NULL);
+  createArgument("space-limit", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_LOGGING_SPACE_LIMIT, "Space limit for logs <mb>", (char *) NULL);
+  createArgument("space-headroom", 1, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_LOGGING_SPACE_HEADROOM, "Space for headroom <mb>", (char *) NULL);
+  createArgument("collation-status", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_STATUS,
+                 "Collation status <inactive | host | send-standard |\n" "                   send-custom | send-all>",
+                 (char *) NULL);
+  createArgument("inactive", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_CONSTANT, (char *) NULL,
+                 CMD_CONFIG_LOGGING_COLLATION_STATUS_INACTIVE, "No collation", (char *) NULL);
+  createArgument("host", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_CONSTANT, (char *) NULL,
+                 CMD_CONFIG_LOGGING_COLLATION_STATUS_HOST, "Be a collation host (receiver)", (char *) NULL);
+  createArgument("send-standard", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL,
+                 CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_STANDARD, "Send standard logs", (char *) NULL);
+  createArgument("send-custom", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL,
+                 CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_CUSTOM, "Send custom logs", (char *) NULL);
+  createArgument("send-all", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL,
+                 CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_ALL, "Send all logs", (char *) NULL);
+  createArgument("collation-host", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_HOST,
+                 "Specify the collation host <string>", (char *) NULL);
+
+  createArgument("collation", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION, "Collation parameters secret <secret> tagged <on | off>\n"
+                 "                   orphan-limit <orphan>", (char *) NULL);
+
+  createArgument("secret", CMD_CONFIG_LOGGING_COLLATION, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_SECRET, "Collation secret is <string>", (char *) NULL);
+
+  createArgument("tagged", CLI_ARGV_NO_POS, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_TAGGED, "Collation tagged is <on | off>", (char *) NULL);
+
+  createArgument("orphan-limit", CLI_ARGV_NO_POS, CLI_ARGV_INT,
+                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_ORPHAN_LIMIT,
+                 "Collation orphan limit size <mb>", (char *) NULL);
+
+  createArgument("format", CLI_ARGV_NO_POS, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT,
+                 "Logging format <squid | netscape-common | netscape-ext |\n"
+                 "                   netscape-ext2>", (char *) NULL);
+
+  createArgument("squid", CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_FORMAT_SQUID, "Squid <on | off>", (char *) NULL);
+  createArgument("netscape-common", CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_COMMON, "Netscape Common <on | off>", (char *) NULL);
+  createArgument("netscape-ext", CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_EXT, "Netscape Extended <on | off>", (char *) NULL);
+  createArgument("netscape-ext2", CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_EXT2,
+                 "Netscape Extended 2 <on | off>", (char *) NULL);
+
+  createArgument("type", CLI_ARGV_NO_POS, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_TYPE, "Logging type <ascii | binary>", (char *) NULL);
+  createArgument("ascii", CMD_CONFIG_LOGGING_TYPE, CLI_ARGV_REQUIRED,
+                 (char *) NULL, CMD_CONFIG_LOGGING_TYPE_ASCII, "ASCII log files", (char *) NULL);
+  createArgument("binary", CMD_CONFIG_LOGGING_TYPE, CLI_ARGV_REQUIRED,
+                 (char *) NULL, CMD_CONFIG_LOGGING_TYPE_BINARY, "Binary log files", (char *) NULL);
+
+  createArgument("file", CLI_ARGV_NO_POS, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_LOGGING_FILE, "Log file name <string>", (char *) NULL);
+
+  createArgument("header", CLI_ARGV_NO_POS, CLI_ARGV_STRING,
+                 (char *) NULL, CMD_CONFIG_LOGGING_HEADER, "Log file header <string>", (char *) NULL);
+
+  createArgument("splitting", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_SPLITTING,
+                 "Splitting of logs for protocols <icp | http>", (char *) NULL);
+  createArgument("icp", CMD_CONFIG_LOGGING_SPLITTING, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_SPLITTING_ICP, "Split ICP <on | off>", (char *) NULL);
+  createArgument("http", CMD_CONFIG_LOGGING_SPLITTING, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_SPLITTING_HTTP, "Split of HTTP <on | off>", (char *) NULL);
+
+  createArgument("custom", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_CUSTOM,
+                 "Custom Logging <on | off>", (char *) NULL);
+
+  createArgument("rolling", 1, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_ROLLING,
+                 "Log file rolling <on | off> offset <hour>\n"
+                 "                   interval <num-hours> auto-delete <on | off>", (char *) NULL);
+
+  createArgument("offset", CLI_ARGV_NO_POS, CLI_ARGV_INT,
+                 (char *) NULL, CMD_CONFIG_LOGGING_OFFSET, "Rolling offset <hour> (24hour format)", (char *) NULL);
+
+  createArgument("interval", CLI_ARGV_NO_POS, CLI_ARGV_INT,
+                 (char *) NULL, CMD_CONFIG_LOGGING_INTERVAL, "Rolling interval <seconds>", (char *) NULL);
+  createArgument("auto-delete", CLI_ARGV_NO_POS, CLI_ARGV_CONST_OPTION,
+                 (char *) NULL, CMD_CONFIG_LOGGING_AUTO_DELETE, "Auto delete <on | off>", (char *) NULL);
+  return 0;
+
+
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigSsl
+//
+// This is the callback function for the "config:ssl" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigSsl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:ssl") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigSsl argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_SSL_STATUS:
+      return (Cli_RecordOnOff_Action(action, "proxy.config.ssl.enabled", argtable->arg_string));
+
+    case CMD_CONFIG_SSL_PORT:
+      return (Cli_RecordInt_Action(action, "proxy.config.ssl.server_port", argtable->arg_int));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigSsl
+//
+// Register "config:ssl" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigSsl()
+{
+  createArgument("status", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_SSL_STATUS, "SSL <on | off>", (char *) NULL);
+
+  createArgument("ports", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_SSL_PORT, "SSL port <int>", (char *) NULL);
+  return 0;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigAlarm
+//
+// This is the callback function for the "config:alarm" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigAlarm(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:alarm") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+  Cli_Debug("Cmd_ConfigAlarm argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
+    switch (argtable->parsed_args) {
+    case CMD_CONFIG_ALARM_RESOLVE_NAME:
+      if (argc < 3) {
+        return (ShowAlarms());
+      }
+      return (ConfigAlarmResolveName(argtable->arg_string));
+    case CMD_CONFIG_ALARM_RESOLVE_NUMBER:
+      if (argc < 3) {
+        return (ShowAlarms());
+      }
+      return (ConfigAlarmResolveNumber(argtable->arg_int));
+    case CMD_CONFIG_ALARM_RESOLVE_ALL:
+      return (ConfigAlarmResolveAll());
+    case CMD_CONFIG_ALARM_NOTIFY:
+      Cli_Debug("Cmd_ConfigAlarm \"%s\"\n", argtable->arg_string);
+      return (ConfigAlarmNotify(argtable->arg_string));
+    }
+  }
+  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
+  return CMD_ERROR;
+}
+
+
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ConfigAlarm
+//
+// Register "config:alarm" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ConfigAlarm()
+{
+  createArgument("resolve-name", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_ALARM_RESOLVE_NAME, "Resolve by name <string>", (char *) NULL);
+
+  createArgument("resolve-number", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_INT_VALUE,
+                 (char *) NULL, CMD_CONFIG_ALARM_RESOLVE_NUMBER, "Resolve by number from list <int>", (char *) NULL);
+
+  createArgument("resolve-all", CLI_ARGV_NO_POS, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_CONFIG_ALARM_RESOLVE_ALL, "Resolve all alarms", (char *) NULL);
+
+  createArgument("notify", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
+                 (char *) NULL, CMD_CONFIG_ALARM_NOTIFY, "Alarm notification <on | off>", (char *) NULL);
+  return CLI_OK;
+}
+
+
+////////////////////////////////////////////////////////////////
+//
+// "config" sub-command implementations
+//
+////////////////////////////////////////////////////////////////
+
+
+// config start sub-command
+int
+ConfigStart()
+{
+  TSProxyStateT state = TSProxyStateGet();
+
+  switch (state) {
+  case TS_PROXY_ON:
+    // do nothing, proxy is already on
+    Cli_Error(ERR_PROXY_STATE_ALREADY, "on");
+    break;
+  case TS_PROXY_OFF:
+  case TS_PROXY_UNDEFINED:
+    if (TSProxyStateSet(TS_PROXY_ON, TS_CACHE_CLEAR_OFF)) {
+      Cli_Error(ERR_PROXY_STATE_SET, "on");
+      return CLI_ERROR;
+    }
+    break;
+  }
+  return CLI_OK;
+}
+
+// config stop sub-command
+int
+ConfigStop()
+{
+  TSProxyStateT state = TSProxyStateGet();
+
+  switch (state) {
+  case TS_PROXY_OFF:
+    // do nothing, proxy is already off
+    Cli_Error(ERR_PROXY_STATE_ALREADY, "off");
+    break;
+  case TS_PROXY_ON:
+  case TS_PROXY_UNDEFINED:
+    if (TSProxyStateSet(TS_PROXY_OFF, TS_CACHE_CLEAR_OFF)) {
+      Cli_Error(ERR_PROXY_STATE_SET, "off");
+      return CLI_ERROR;
+    }
+    break;
+  }
+  return CLI_OK;
+}
+
+// config get sub-command
+//   used to get the value of any config variable in records.config
+int
+ConfigGet(const char *rec_name)
+{
+  Cli_Debug("ConfigGet: rec_name %s\n", rec_name);
+
+  TSError status;
+  TSRecordEle rec_val;
+
+  status = Cli_RecordGet(rec_name, &rec_val);
+
+  if (status) {
+    return status;
+  }
+  // display the result
+
+  switch (rec_val.rec_type) {
+  case TS_REC_INT:            // TS64 aka "long long"
+    Cli_Printf("%s = %d\n", rec_name, (int) rec_val.int_val);
+    break;
+  case TS_REC_COUNTER:        // TS64 aka "long long"
+    Cli_Printf("%s = %d\n", rec_name, (int) rec_val.counter_val);
+    break;
+  case TS_REC_FLOAT:          // float
+    Cli_Printf("%s = %f\n", rec_name, rec_val.float_val);
+    break;
+  case TS_REC_STRING:         // char*
+    Cli_Printf("%s = \"%s\"\n", rec_name, rec_val.string_val);
+    break;
+  case TS_REC_UNDEFINED:      // what's this???
+    Cli_Printf("%s = UNDEFINED\n", rec_name);
+    break;
+  }
+
+  return CLI_OK;
+}
+
+// config set sub-command
+//   used to set the value of any variable in records.config
+
+int
+ConfigSet(const char *rec_name, const char *value)
+{
+  Cli_Debug("ConfigSet: rec_name %s value %s\n", rec_name, value);
+
+  TSError status;
+  TSActionNeedT action_need;
+
+  status = Cli_RecordSet(rec_name, value, &action_need);
+  if (status) {
+    return status;
+  }
+
+  return (Cli_ConfigEnactChanges(action_need));
+}
+
+// config name sub-command
+//   used to set or display the value of proxy.config.proxy_name
+
+int
+ConfigName(const char *proxy_name)
+{
+  TSError status = TS_ERR_OKAY;
+  TSString str_val = NULL;
+  TSActionNeedT action_need;
+
+  if (proxy_name) {             // set the name
+
+    Cli_Debug("ConfigName: set name proxy_name %s\n", proxy_name);
+
+    status = Cli_RecordSetString("proxy.config.proxy_name", (TSString) proxy_name, &action_need);
+
+    if (status) {
+      return status;
+    }
+
+    return (Cli_ConfigEnactChanges(action_need));
+
+  }
+
+  else {                        // display the name
+    Cli_Debug("ConfigName: get name\n");
+
+    status = Cli_RecordGetString("proxy.config.proxy_name", &str_val);
+    if (status) {
+      return status;
+    }
+
+    if (str_val) {
+      Cli_Printf("%s\n", str_val);
+    } else {
+      Cli_Printf("none\n");
+    }
+  }
+
+  return CLI_OK;
+
+}
+
+// config ports sub-command
+//   used to set the value of port(s)
+
+int
+ConfigPortsSet(int arg_ref, void *valuePtr)
+{
+
+  switch (arg_ref) {
+  case CMD_CONFIG_PORTS_CONNECT:
+    Cli_Debug("ConfigPortsSet: arg_ref %d value %s\n", arg_ref, (char *) valuePtr);
+    break;
+  default:
+    Cli_Debug("ConfigPortsSet: arg_ref %d value %d\n", arg_ref, *(TSInt *) valuePtr);
+  }
+
+  TSError status = TS_ERR_OKAY;
+  TSActionNeedT action_need = TS_ACTION_UNDEFINED;
+
+  Cli_Debug("ConfigPorts: set\n");
+  switch (arg_ref) {
+  case CMD_CONFIG_PORTS_HTTP_SERVER:
+    status = Cli_RecordSetInt("proxy.config.http.server_port", *(TSInt *) valuePtr, &action_need);
+    break;
+  case CMD_CONFIG_PORTS_CLUSTER:
+    status = Cli_RecordSetInt("proxy.config.cluster.cluster_port", *(TSInt *) valuePtr, &action_need);
+    break;
+  case CMD_CONFIG_PORTS_CLUSTER_RS:
+    status = Cli_RecordSetInt("proxy.config.cluster.rsport", *(TSInt *) valuePtr, &action_need);
+    break;
+  case CMD_CONFIG_PORTS_CLUSTER_MC:
+    status = Cli_RecordSetInt("proxy.config.cluster.mcport", *(TSInt *) valuePtr, &action_need);
+    break;
+  case CMD_CONFIG_PORTS_CONNECT:
+    status = Cli_RecordSetString("proxy.config.http.connect_ports", (TSString) valuePtr, &action_need);
+    break;
+  case CMD_CONFIG_PORTS_SOCKS_SERVER:
+    status = Cli_RecordSetInt("proxy.config.socks.socks_server_port", *(TSInt *) valuePtr, &action_need);
+    break;
+  case CMD_CONFIG_PORTS_ICP:
+    status = Cli_RecordSetInt("proxy.config.icp.icp_port", *(TSInt *) valuePtr, &action_need);
+    break;
+  }
+
+  if (status) {
+    return status;
+  }
+
+  return (Cli_ConfigEnactChanges(action_need));
+
+}
+
+// config ports sub-command
+//   used to display the value of port(s)
+
+int
+ConfigPortsGet(int arg_ref)
+{
+  TSError status = TS_ERR_OKAY;
+  TSInt int_val = -1;
+  TSString str_val = NULL;
+
+  Cli_Debug("ConfigPortsGet: get\n");
+
+  switch (arg_ref) {
+  case CMD_CONFIG_PORTS_HTTP_SERVER:
+    status = Cli_RecordGetInt("proxy.config.http.server_port", &int_val);
+    if (status) {
+      return status;
+    }
+    Cli_Printf("%d\n", int_val);
+    break;
+  case CMD_CONFIG_PORTS_CLUSTER:
+    status = Cli_RecordGetInt("proxy.config.cluster.cluster_port", &int_val);
+    if (status) {
+      return status;
+    }
+    Cli_Printf("%d\n", i

<TRUNCATED>

[11/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/ConfigCmd.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/ConfigCmd.h b/mgmt/cli/ConfigCmd.h
deleted file mode 100644
index 42ed681..0000000
--- a/mgmt/cli/ConfigCmd.h
+++ /dev/null
@@ -1,865 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/****************************************************************
- * Filename: ConfigCmd.h
- * Purpose: This file contains the CLI's "config" command definitions.
- *
- *
- ****************************************************************/
-
-#include "mgmtapi.h"
-#include <tcl.h>
-#include "createArgument.h"
-#include "definitions.h"
-
-#ifndef __CONFIG_CMD_H__
-#define __CONFIG_CMD_H__
-
-
-// enumerated type which captures all "config" commands
-typedef enum
-{
-  CMD_CONFIG_GET = 100,
-  CMD_CONFIG_SET,
-  CMD_CONFIG_SET_VALUE,
-  CMD_ENABLE_STATUS,
-  CMD_CONFIG_NAME,
-  CMD_CONFIG_RESTART_CLUSTER,
-  CMD_CONFIG_PORTS,
-  CMD_CONFIG_PORTS_HTTP_SERVER,
-  CMD_CONFIG_PORTS_CLUSTER,
-  CMD_CONFIG_PORTS_CLUSTER_RS,
-  CMD_CONFIG_PORTS_CLUSTER_MC,
-  CMD_CONFIG_PORTS_CONNECT,
-  CMD_CONFIG_PORTS_SOCKS_SERVER,
-  CMD_CONFIG_PORTS_ICP,
-  CMD_CONFIG_DATE,
-  CMD_CONFIG_TIME,
-  CMD_CONFIG_TIMEZONE,
-  CMD_CONFIG_TIMEZONE_LIST,
-  CMD_HALT,
-  CMD_REBOOT,
-  CMD_CONFIG_START,
-  CMD_CONFIG_STOP,
-  CMD_CONFIG_WRITE,
-  CMD_CONFIG_WRITE_IFC_HEAD,
-  CMD_CONFIG_WRITE_TS_VERSION,
-  CMD_CONFIG_WRITE_BUILD_DATE,
-  CMD_CONFIG_WRITE_PLATFORM,
-  CMD_CONFIG_WRITE_NODES,
-  CMD_CONFIG_WRITE_FEATURE,
-  CMD_CONFIG_WRITE_TAR,
-  CMD_CONFIG_WRITE_TAR_INFO,
-  CMD_CONFIG_WRITE_FILELIST,
-  CMD_CONFIG_WRITE_TAR_COMMON,
-  CMD_CONFIG_WRITE_BIN_DIR,
-  CMD_CONFIG_WRITE_BIN_GROUP,
-  CMD_CONFIG_WRITE_BIN_COMMON,
-  CMD_CONFIG_WRITE_LIB_DIR,
-  CMD_CONFIG_WRITE_LIB_GROUP,
-  CMD_CONFIG_WRITE_LIB_COMMON,
-  CMD_CONFIG_WRITE_CONFIG_DIR,
-  CMD_CONFIG_WRITE_CONFIG_GROUP,
-  CMD_CONFIG_WRITE_CONFIG_COMMON,
-  CMD_CONFIG_WRITE_COMMON_FILE,
-  CMD_CONFIG_READ,
-  CMD_CONFIG_READ_IFC_HEAD,
-  CMD_CONFIG_UPGRADE_READ_URL,
-  CMD_CONFIG_READ_FEATURE,
-  CMD_CONFIG_READ_TAR,
-  CMD_CONFIG_READ_TAR_INFO,
-  CMD_CONFIG_READ_TAR_COMMON,
-  CMD_CONFIG_READ_BIN_DIR,
-  CMD_CONFIG_READ_BIN_GROUP,
-  CMD_CONFIG_READ_BIN_COMMON,
-  CMD_CONFIG_READ_LIB_DIR,
-  CMD_CONFIG_READ_LIB_GROUP,
-  CMD_CONFIG_READ_LIB_COMMON,
-  CMD_CONFIG_READ_CONFIG_DIR,
-  CMD_CONFIG_READ_CONFIG_GROUP,
-  CMD_CONFIG_READ_CONFIG_COMMON,
-  CMD_CONFIG_READ_COMMON_FILE,
-  CMD_CONFIG_FILTER,
-  CMD_CONFIG_SECURITY,
-  CMD_CONFIG_SECURITY_IP,
-  CMD_CONFIG_SECURITY_PASSWORD,
-  CMD_CONFIG_PARENTS_STATUS,
-  CMD_CONFIG_PARENTS_CACHE,
-  CMD_CONFIG_PARENTS_CONFIG_FILE,
-  CMD_CONFIG_REMAP,
-  CMD_CONFIG_HTTP_STATUS,
-  CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_IN,
-  CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_OUT,
-  CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_IN,
-  CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_OUT,
-  CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_IN,
-  CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_OUT,
-  CMD_CONFIG_HTTP_REMOVE_FROM,
-  CMD_CONFIG_HTTP_REMOVE_REFERER,
-  CMD_CONFIG_HTTP_REMOVE_USER,
-  CMD_CONFIG_HTTP_REMOVE_COOKIE,
-  CMD_CONFIG_HTTP_REMOVE_HEADER,
-  CMD_CONFIG_HTTP_GLOBAL_USER_AGENT,
-  CMD_CONFIG_HTTP_INSERT_IP,
-  CMD_CONFIG_HTTP_REMOVE_IP,
-  CMD_CONFIG_HTTP_PROXY,
-  CMD_CONFIG_HTTP_FWD,
-  CMD_CONFIG_HTTP_REV,
-  CMD_CONFIG_HTTP_FWD_REV,
-  CMD_CONFIG_ICP,
-  CMD_CONFIG_ICP_MODE,
-  CMD_CONFIG_ICP_MODE_RECEIVE,
-  CMD_CONFIG_ICP_MODE_SENDRECEIVE,
-  CMD_CONFIG_ICP_MODE_DISABLED,
-  CMD_CONFIG_ICP_PORT,
-  CMD_CONFIG_ICP_MCAST,
-  CMD_CONFIG_ICP_QTIMEOUT,
-  CMD_CONFIG_ICP_PEERS,
-  CMD_CONFIG_PORT_TUNNELS_SERVER_OTHER_PORTS,
-  CMD_CONFIG_SCHEDULED_UPDATE_STATUS,
-  CMD_CONFIG_SCHEDULED_UPDATE_RETRY_COUNT,
-  CMD_CONFIG_SCHEDULED_UPDATE_RETRY_INTERVAL,
-  CMD_CONFIG_SCHEDULED_UPDATE_MAX_CONCURRENT,
-  CMD_CONFIG_SCHEDULED_UPDATE_FORCE_IMMEDIATE,
-  CMD_CONFIG_SCHEDULED_UPDATE_RULES,
-  CMD_CONFIG_SOCKS_STATUS,
-  CMD_CONFIG_SOCKS_VERSION,
-  CMD_CONFIG_SOCKS_DEFAULT_SERVERS,
-  CMD_CONFIG_SOCKS_ACCEPT,
-  CMD_CONFIG_SOCKS_ACCEPT_PORT,
-  CMD_CONFIG_CACHE,
-  CMD_CONFIG_CACHE_ON,
-  CMD_CONFIG_CACHE_OFF,
-  CMD_CONFIG_CACHE_HTTP,
-  CMD_CONFIG_CACHE_CLUSTER_BYPASS,
-  CMD_CONFIG_CACHE_IGNORE_BYPASS,
-  CMD_CONFIG_CACHE_MAX_OBJECT_SIZE,
-  CMD_CONFIG_CACHE_MAX_ALTERNATES,
-  CMD_CONFIG_CACHE_FILE,
-  CMD_CONFIG_CACHE_FRESHNESS,
-  CMD_CONFIG_CACHE_FRESHNESS_VERIFY,
-  CMD_CONFIG_CACHE_FRESHNESS_VERIFY_WHEN_EXPIRED,
-  CMD_CONFIG_CACHE_FRESHNESS_VERIFY_NO_DATE,
-  CMD_CONFIG_CACHE_FRESHNESS_VERIFY_ALWALYS,
-  CMD_CONFIG_CACHE_FRESHNESS_VERIFY_NEVER,
-  CMD_CONFIG_CACHE_FRESHNESS_MINIMUM,
-  CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_EXPLICIT,
-  CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_LAST_MODIFIED,
-  CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_NOTHING,
-  CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT,
-  CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_GREATER_THAN,
-  CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_LESS_THAN,
-  CMD_CONFIG_CACHE_DYNAMIC,
-  CMD_CONFIG_CACHE_ALTERNATES,
-  CMD_CONFIG_CACHE_VARY,
-  CMD_CONFIG_CACHE_VARY_TEXT,
-  CMD_CONFIG_CACHE_VARY_COOKIES_IMAGES,
-  CMD_CONFIG_CACHE_VARY_OTHER,
-  CMD_CONFIG_CACHE_COOKIES,
-  CMD_CONFIG_CACHE_COOKIES_NONE,
-  CMD_CONFIG_CACHE_COOKIES_ALL,
-  CMD_CONFIG_CACHE_COOKIES_NON_TEXT,
-  CMD_CONFIG_CACHE_COOKIES_NON_TEXT_EXT,
-  CMD_CONFIG_CACHE_CLEAR,
-  CMD_CONFIG_HOSTDB,
-  CMD_CONFIG_HOSTDB_LOOKUP_TIMEOUT,
-  CMD_CONFIG_HOSTDB_FOREGROUND_TIMEOUT,
-  CMD_CONFIG_HOSTDB_BACKGROUND_TIMEOUT,
-  CMD_CONFIG_HOSTDB_INVALID_HOST_TIMEOUT,
-  CMD_CONFIG_HOSTDB_RE_DNS_ON_RELOAD,
-  CMD_CONFIG_HOSTDB_CLEAR,
-  CMD_CONFIG_DNS,
-  CMD_CONFIG_DNS_RESOLVE_TIMEOUT,
-  CMD_CONFIG_DNS_RETRIES,
-  CMD_CONFIG_VIRTUALIP,
-  CMD_CONFIG_VIRTUALIP_STATUS,
-  CMD_CONFIG_VIRTUALIP_LIST,
-  CMD_CONFIG_VIRTUALIP_ADD,
-  CMD_CONFIG_VIRTUALIP_ADD_IP,
-  CMD_CONFIG_VIRTUALIP_ADD_DEVICE,
-  CMD_CONFIG_VIRTUALIP_ADD_SUBINTERFACE,
-  CMD_CONFIG_VIRTUALIP_DELETE,
-  CMD_CONFIG_LOGGING_ON,
-  CMD_CONFIG_LOGGING_OFF,
-  CMD_CONFIG_LOGGING_EVENT,
-  CMD_CONFIG_LOGGING_EVENT_ENABLED,
-  CMD_CONFIG_LOGGING_EVENT_TRANS_ONLY,
-  CMD_CONFIG_LOGGING_EVENT_ERROR_ONLY,
-  CMD_CONFIG_LOGGING_EVENT_DISABLED,
-  CMD_CONFIG_LOGGING_MGMT_DIRECTORY,
-  CMD_CONFIG_LOGGING_SPACE_LIMIT,
-  CMD_CONFIG_LOGGING_SPACE_HEADROOM,
-  CMD_CONFIG_LOGGING_COLLATION_STATUS,
-  CMD_CONFIG_LOGGING_COLLATION_STATUS_INACTIVE,
-  CMD_CONFIG_LOGGING_COLLATION_STATUS_HOST,
-  CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_STANDARD,
-  CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_CUSTOM,
-  CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_ALL,
-  CMD_CONFIG_LOGGING_COLLATION_HOST,
-  CMD_CONFIG_LOGGING_COLLATION,
-  CMD_CONFIG_LOGGING_COLLATION_SECRET,
-  CMD_CONFIG_LOGGING_COLLATION_TAGGED,
-  CMD_CONFIG_LOGGING_COLLATION_ORPHAN_LIMIT,
-  CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT,
-  CMD_CONFIG_LOGGING_FORMAT_SQUID,
-  CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_COMMON,
-  CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_EXT,
-  CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_EXT2,
-  CMD_CONFIG_LOGGING_TYPE,
-  CMD_CONFIG_LOGGING_TYPE_ASCII,
-  CMD_CONFIG_LOGGING_TYPE_BINARY,
-  CMD_CONFIG_LOGGING_FILE,
-  CMD_CONFIG_LOGGING_HEADER,
-  CMD_CONFIG_LOGGING_SPLITTING,
-  CMD_CONFIG_LOGGING_SPLITTING_ICP,
-  CMD_CONFIG_LOGGING_SPLITTING_HTTP,
-  CMD_CONFIG_LOGGING_CUSTOM,
-  CMD_CONFIG_LOGGING_ROLLING,
-  CMD_CONFIG_LOGGING_OFFSET,
-  CMD_CONFIG_LOGGING_INTERVAL,
-  CMD_CONFIG_LOGGING_AUTO_DELETE,
-  CMD_CONFIG_SSL,
-  CMD_CONFIG_SSL_STATUS,
-  CMD_CONFIG_SSL_PORT,
-  CMD_CONFIG_IP_ADDRESS,
-  CMD_CONFIG_HOSTNAME,
-  CMD_CONFIG_NETMASK,
-  CMD_CONFIG_DOMAIN,
-  CMD_CONFIG_DNS_IP,
-  CMD_CONFIG_DEFAULT_ROUTER,
-  CMD_CONFIG_NETWORK_INT,
-  CMD_CONFIG_NETWORK_STATUS,
-  CMD_CONFIG_NETWORK_START,
-  CMD_CONFIG_NETWORK_PROTOCOL,
-  CMD_CONFIG_GATEWAY,
-  CMD_CONFIG_ALARM_RESOLVE_NAME,
-  CMD_CONFIG_ALARM_RESOLVE_NUMBER,
-  CMD_CONFIG_ALARM_RESOLVE_ALL,
-  CMD_CONFIG_ALARM_NOTIFY
-} cliConfigCommand;
-
-typedef struct DateTime
-{
-  char str_hh[16];
-  char str_min[16];
-  char str_ss[16];
-  char str_dd[16];
-  char str_mm[16];
-  char str_yy[16];
-} DateTime;
-
-////////////////////////////////////////////////////////////////
-// ConfigCmd
-//
-// This is the callback function for the "config" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_Config(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// ConfigCmdArgs
-//
-// Register "config" command arguments with the Tcl interpreter.
-//
-int CmdArgs_Config();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigGet
-//
-// This is the callback function for the "config:get" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigGet(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigSet
-//
-// This is the callback function for the "config:set" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigSet(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigName
-//
-// This is the callback function for the "config:name" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigName(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigStart
-//
-// This is the callback function for the "config:start" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigStart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigStop
-//
-// This is the callback function for the "config:stop" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigStop(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-int Cmd_ConfigHardRestart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-int Cmd_ConfigRestart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-int CmdArgs_ConfigRestart();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigParents
-//
-// This is the callback function for the "config:parents" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigParents(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigParents
-//
-// Register "config:parents" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigParents();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigRemap
-//
-// This is the callback function for the "config:remap" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigRemap(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigPorts
-//
-// This is the callback function for the "config:ports" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigPorts(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigPorts
-//
-// Register "config:ports" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigPorts();
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigPortTunnles
-//
-// Register "config:PortTunnles" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigPortTunnels();
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigScheduledUpdate
-//
-// This is the callback function for the "config:scheduled-update" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigScheduledUpdate(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigScheduled-Update
-//
-// Register "config:Scheduled-Update" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigScheduledUpdate();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigSocks
-//
-// This is the callback function for the "config:scheduled-update" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigSocks(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigSocks
-//
-// Register "config:socks" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigSocks();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigClock
-//
-// This is the callback function for the "config:clock" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigClock(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigClock
-//
-// Register "config:clock" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigClock();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigSecurity
-//
-// This is the callback function for the "config:security" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigSecurity(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigSecurity
-//
-// Register "config:security" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigSecurity();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigHttp
-//
-// This is the callback function for the "config:http" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigHttp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigHttp
-//
-// Register "config:http" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigHttp();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigIcp
-//
-// This is the callback function for the "config:icp" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigIcp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigIcp
-//
-// Register "config:Icp" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigIcp();
-
-////////////////////////////////////////////////////////////////
-//
-// Cmd_ConfigHostdb
-// This is the callback function for the "config:hostdb" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigCache
-//
-// This is the callback function for the "config:cache" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigCache(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigCache
-//
-// Register "config:cache" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigCache();
-
-
-int Cmd_ConfigHostdb(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigHostdb
-//
-// Register "config:hostdb" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigHostdb();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigDns
-//
-// This is the callback function for the "config:dns" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigDns(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigDns
-//
-// Register "config:dns" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigDns();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigVirtualip
-//
-// This is the callback function for the "config:virtualip" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigVirtualip(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigVirtualip
-//
-// Register "config:virtualip" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigVirtualip();
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigLogging
-//
-// This is the callback function for the "config:logging" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigLogging(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigLogging
-//
-// Register "config:logging" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigLogging();
-// Cmd_ConfigSsl
-//
-// This is the callback function for the "config:ssl" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigSsl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigSsl
-//
-// Register "config:ssl" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigSsl();
-
-////////////////////////////////////////////////////////////////
-// Functions to implement network settings
-//
-int IsValidHostname(char *str);
-int IsValidFQHostname(char *str);
-int IsValidDomainname(char *str);
-int IsValidIpAddress(char *str);
-#if defined(solaris)
-int getnetmask(char *mask);
-#endif
-char *pos_after_string(char const *haystack, char const *needle);
-int StartBinary(char *abs_bin_path, char *bin_options, int isScript);
-int getrouter(char *router, int len);
-int getnameserver(char *nameserver, int len);
-int setnameserver(char *nameserver);
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigAlarm
-//
-// This is the callback function for the "config:alarm" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigAlarm(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigAlarm
-//
-// Register "config:alarm" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigAlarm();
-
-////////////////////////////////////////////////////////////////
-// Cmd_Enable
-//
-// This is the callback function for the "enable" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_Enable(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigParents
-//
-// Register "config:parents" arguments with the Tcl interpreter.
-//
-int CmdArgs_Enable();
-
-int cliCheckIfEnabled(char *command);
-
-////////////////////////////////////////////////////////////////
-// Cmd_Disable
-//
-// This is the callback function for the "enable" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_Disable(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// Cmd_Help
-//
-// This is the callback function for the "help" command. It displays the
-// online help for the requested topic(s).
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_Help(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-
-////////////////////////////////////////////////////////////////
-//
-// "config" sub-command implementations
-//
-////////////////////////////////////////////////////////////////
-
-// config start sub-command
-int ConfigStart();
-
-// config stop sub-command
-int ConfigStop();
-
-// config get sub-command
-int ConfigGet(const char *rec_name);
-
-// config set sub-command
-int ConfigSet(const char *rec_name, const char *rec_value);
-
-// config name sub-command
-int ConfigName(const char *proxy_name);
-
-// config ports sub-command
-int ConfigPortsSet(int arg_ref, void *valuePtr);
-int ConfigPortsGet(int arg_ref);
-
-// config Date sub-command
-int ConfigDate(char *datestr);
-
-// config Time sub-command
-int ConfigTime(char *timestr);
-
-// config Timezone sub-command
-int ConfigTimezone(int, int);
-
-//config Timezone List
-int ConfigTimezoneList();
-
-// config security password sub-command
-int ConfigSecurityPasswd();
-
-// config remap sub-command
-int ConfigRemap(const char *url);
-
-// config http proxy sub-command
-int ConfigHttpProxy(int arg_ref, int setvar);
-
-// config icp mode sub-command
-int ConfigIcpMode(int arg_ref, int setvar);
-
-// config Cache Freshness Verify sub-command
-int ConfigCacheFreshnessVerify(int arg_ref, int setvar);
-
-// config Cache Freshness Minimum sub-command
-int ConfigCacheFreshnessMinimum(int arg_ref, int setvar);
-
-// config Cache FreshnessNoExpireLimit
-int ConfigCacheFreshnessNoExpireLimit(TSInt min, TSInt max, int setvar);
-
-// config Cache Vary sub-command
-int ConfigCacheVary(int arg_ref, char *field, int setvar);
-
-// config Cache Cookies sub-command
-int ConfigCacheCookies(int arg_ref, int setvar);
-
-// config Cache Clear sub-command
-int ConfigCacheClear();
-
-// config HostDB Clear sub-command
-int ConfigHostdbClear();
-
-//config virtualip list
-int ConfigVirtualIpList();
-
-//config virtualip add
-int ConfigVirtualipAdd(char *ip, char *device, int subinterface, int set_var);
-
-//config virtualip delete
-int ConfigVirtualipDelete(int ip_no, int set_var);
-
-// config Logging Event sub-command
-int ConfigLoggingEvent(int arg_ref, int setvar);
-
-// config Logging collation status sub-command
-int ConfigLoggingCollationStatus(int arg_ref, int setvar);
-
-// config Logging collation sub-command
-int ConfigLoggingCollation(TSString secret, int arg_ref, TSInt orphan, int setvar);
-
-// config Logging Format Type File sub-command
-int ConfigLoggingFormatTypeFile(int arg_ref_format, int arg_ref,
-                                int arg_ref_type, TSString file, TSString header, int setvar);
-
-// config Logging splitting sub-command
-int ConfigLoggingSplitting(int arg_ref_protocol, int arg_ref_on_off, int setvar);
-
-// config Logging Custom Format sub-command
-int ConfigLoggingCustomFormat(int arg_ref_on_off, int arg_ref_format, int setvar);
-
-// config Logging rolling offset interval autodelete sub-command
-int ConfigLoggingRollingOffsetIntervalAutodelete(int arg_ref_rolling, TSInt offset, TSInt num_hours,
-                                                 int arg_ref_auto_delete, int setvar);
-
-// config icp peers sub-command
-int ConfigIcpPeers(char *url);
-
-// config:alarm resolve-name
-int ConfigAlarmResolveName(char *name);
-
-// config:alarm resolve-number
-int ConfigAlarmResolveNumber(int number);
-
-// config:alarm resolve-all
-int ConfigAlarmResolveAll();
-
-// config:alarm notify
-int ConfigAlarmNotify(char *stringval);
-
-#endif // __CONFIG_CMD_H__

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/ConfigUpgradeCmd.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/ConfigUpgradeCmd.cc b/mgmt/cli/ConfigUpgradeCmd.cc
deleted file mode 100644
index a16615e..0000000
--- a/mgmt/cli/ConfigUpgradeCmd.cc
+++ /dev/null
@@ -1,634 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/****************************************************************
- * Filename: ConfigUpgradeCmd.cc
- * Purpose: This file contains the CLI's "config:write/read/install/upgrade"
-   command implementation.
- *
- ****************************************************************/
-
-
-#include <ConfigCmd.h>
-#include <CliDisplay.h>
-#include <CliMgmtUtils.h>
-#include <CliDisplay.h>
-#include <CliMgmtUtils.h>
-#include <ConfigUpgradeCmd.h>
-#include <string.h>
-
-
-CIFCEntry::CIFCEntry(char *keyword, int counton, const char *string, ...)
-{
-
-  char Buffer[CONFIG_UPGRADE_BUF_SIZE];
-
-  KeyWord = new char[strlen(keyword) + 1];
-  sprintf(KeyWord, keyword);
-  CountOn = counton;
-
-  va_start(ap, string);
-  vsprintf(Buffer, string, ap);
-  va_end(ap);
-  Input = new char[strlen(Buffer) + 1];
-  sprintf(Input, Buffer);
-
-  Version = NULL;
-  FileName = NULL;
-
-}
-
-CIFCEntry::~CIFCEntry()
-{
-
-  if (Version != NULL)
-    delete[]Version;
-  if (FileName != NULL)
-    delete[]FileName;
-  if (KeyWord != NULL)
-    delete[]KeyWord;
-  if (Input != NULL)
-    delete[]Input;
-
-}
-
-// check IFCVERSION IFCPATH and IFCFILENAME setup
-INKError
-CIFCEntry::ConfigWriteCheckIFCEnv()
-{
-
-  char *pathPtr;
-  char *filenamePtr;
-  char *versionPtr;
-
-
-  pathPtr = getenv("IFCPATH");
-  filenamePtr = getenv("IFCFILENAME");
-  versionPtr = getenv("IFCVERSION");
-
-  if (pathPtr == NULL || filenamePtr == NULL || versionPtr == NULL ||
-      strlen(pathPtr) == 0 || strlen(filenamePtr) == 0 || strlen(versionPtr) == 0) {
-    return INK_ERR_READ_FILE;
-  }
-
-  FileName = new char[strlen(pathPtr) + strlen(filenamePtr) + 1];
-  sprintf(FileName, "%s%s", pathPtr, filenamePtr);
-
-  Version = new char[strlen(versionPtr) + 1];
-  sprintf(Version, "%s", versionPtr);
-
-  return INK_ERR_OKAY;
-}
-
-INKError
-CIFCEntry::Cli_NewIFCFile()
-{
-
-  FILE *Fptr;
-
-  Fptr = fopen(FileName, "r+");
-  if (Fptr != NULL) {
-    fclose(Fptr);
-    return INK_ERR_OKAY;
-  } else {                      /* need to create new file */
-    Fptr = fopen(FileName, "w");
-    if (Fptr == NULL) {
-      Cli_Error("Error in creating new IFC file\n");
-      return INK_ERR_WRITE_FILE;
-    }
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#IFCHEAD FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<TRAFFIC SERVER VERSION>\n");
-    fprintf(Fptr, "#<BUILD DATE>\n");
-    fprintf(Fptr, "#<PLATFORM>\n");
-    fprintf(Fptr, "#<NUMBER OF NODES>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "IfcHead\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#FEATURE FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<FEATURE STRING LIST>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "Feature\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#TAR FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<NUMBER OF TAR FILES>\n");
-    fprintf(Fptr, "#<LIST OF TAR FILES>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "Tar\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#COMMONTAR FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<NUMBER OF TAR FILES>\n");
-    fprintf(Fptr, "#<LIST OF TAR FILES>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "CommonTar\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#TAR INFO FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<TAR FILE NAME>:<LIST OF FILES>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "TarInfo\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#BIN GROUP FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<NUMBER OF FILES>\n");
-    fprintf(Fptr, "#<LIST OF FILES>\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "BinGroup\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#BIN DIR FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of SubDirectories>\n");
-    fprintf(Fptr, "#<SubDirectory>:<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "BinDir\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#BIN COMMON FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of Files>\n");
-    fprintf(Fptr, "#<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "BinCommon\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#LIB GROUP FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of Files>\n");
-    fprintf(Fptr, "#<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "LibGroup\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#LIB DIR FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of SubDirectories>\n");
-    fprintf(Fptr, "#<SubDirectory>:<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "LibDir\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#LIB COMMON FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of Files>\n");
-    fprintf(Fptr, "#<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "LibCommon\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#CONFIG GROUP FORMAT>\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of Files>\n");
-    fprintf(Fptr, "#<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "ConfigGroup\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#CONFIG DIR FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of SubDirectories>\n");
-    fprintf(Fptr, "#<SubDirectory>:<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "ConfigDir\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#CONFIG COMMON FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of Files>\n");
-    fprintf(Fptr, "#<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "ConfigCommon\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fprintf(Fptr, "############################\n");
-    fprintf(Fptr, "#COMMON FORMAT\n");
-    fprintf(Fptr, "#\n");
-    fprintf(Fptr, "#<Number of Files>\n");
-    fprintf(Fptr, "#<List of Files>\n");
-    fprintf(Fptr, "\n");
-    fprintf(Fptr, "CommonFile\n");
-    fprintf(Fptr, "0\n");
-    fprintf(Fptr, "\n");
-
-    fclose(Fptr);
-    return INK_ERR_OKAY;
-  }
-
-}
-
-
-int
-CIFCEntry::ConfigWriteIFC()
-{
-
-  FILE *Fptr;
-  char *filebuffer, *in_buffer;
-  char *p1;
-  char OldCountString[CONFIG_UPGRADE_INT_STRING_SIZE];
-  int Count = -1;
-  long size, amount_read, addsize;
-
-  if (ConfigWriteCheckIFCEnv() == INK_ERR_READ_FILE) {
-    Cli_Error("Set $IFCVERSION, $IFCPATH and $IFCFILENAME First\n");
-    return CLI_ERROR;
-  }
-  if (Cli_NewIFCFile() == INK_ERR_WRITE_FILE) {
-    return CLI_ERROR;
-  }
-  if ((Fptr = fopen(FileName, "r")) == NULL) {
-    Cli_Error("ERROR Open IFC File to read\n");
-    return CLI_ERROR;
-  }
-
-  fseek(Fptr, 0, SEEK_END);
-  size = ftell(Fptr);
-  if (size <= 0) {
-    fclose(Fptr);
-    Cli_Error("Error Reading IFC File\n");
-    return CLI_ERROR;
-  }
-
-  filebuffer = new char[size + 1];
-  fseek(Fptr, 0, SEEK_SET);
-  amount_read = fread((void *) filebuffer, sizeof(char), size, Fptr);
-  fclose(Fptr);
-  filebuffer[size] = '\0';
-
-  if (size * (int) sizeof(char) != amount_read) {
-    Cli_Error("Error Reading IFC File\n");
-    delete[]filebuffer;
-    return CLI_ERROR;
-  }
-  // look for KeyWord
-  if ((p1 = strstr(filebuffer, KeyWord)) == NULL) {
-    delete[]filebuffer;
-    Cli_Error("Error Finding Keyword\n");
-    return CLI_ERROR;
-  }
-
-  p1 += strlen(KeyWord);
-  p1++;
-
-  // writeback
-  Fptr = fopen(FileName, "r+");
-  fseek(Fptr, p1 - filebuffer, SEEK_SET);
-
-  switch (CountOn) {
-  case 1:
-
-    // coverity[secure_coding]
-    sscanf(p1, "%d\n", &Count);
-    sprintf(OldCountString, "%d", Count);
-    p1 += (strlen(OldCountString) + 1);
-    Count++;
-    addsize = strlen(Input) + CONFIG_UPGRADE_INT_STRING_SIZE + 2;
-    in_buffer = new char[addsize + 1];
-    sprintf(in_buffer, "%d\n%s\n", Count, Input);
-    in_buffer[addsize] = '\0';
-    fwrite(in_buffer, sizeof(char), strlen(in_buffer), Fptr);
-    delete[]in_buffer;
-    break;
-
-  case 0:
-
-    fwrite(Input, sizeof(char), strlen(Input), Fptr);
-    fwrite("\n", sizeof(char), strlen("\n"), Fptr);
-    break;
-
-  default:
-
-    Cli_Error("Unexpected Value of CountOn\n");
-    fclose(Fptr);
-    delete[]filebuffer;
-    return CLI_ERROR;
-  }
-
-  fwrite(p1, sizeof(char), size - (p1 - filebuffer), Fptr);
-  fclose(Fptr);
-  delete[]filebuffer;
-  return CLI_OK;
-
-}
-
-//config read subcommand
-int
-CIFCEntry::ConfigReadIFC()
-{
-
-  FILE *Fptr;
-  char *filebuffer;
-  long size, amount_read;
-  INKError CLI_CHECK;
-
-  if (ConfigWriteCheckIFCEnv() == INK_ERR_READ_FILE) {
-    Cli_Error("Set $IFCVERSION, $IFCPATH and $IFCFILENAME First\n");
-    return CLI_ERROR;
-  }
-
-  if ((Fptr = fopen(FileName, "r")) == NULL) {
-    Cli_Printf("ERROR Opening IFC file for read\n");
-    return CLI_ERROR;
-  }
-
-  fseek(Fptr, 0, SEEK_END);
-  size = ftell(Fptr);
-  if (size <= 0) {
-    Cli_Error("Error Empty IFC FILE\n", FileName);
-    fclose(Fptr);
-    return CLI_ERROR;
-  }
-
-  filebuffer = new char[size + 1];
-  fseek(Fptr, 0, SEEK_SET);
-  amount_read = fread((void *) filebuffer, (int) sizeof(char), size, Fptr);
-
-  if (size * (int) sizeof(char) != amount_read) {
-    Cli_Error("Error Reading IFC File\n");
-    delete[]filebuffer;
-    return CLI_ERROR;
-  }
-
-  filebuffer[amount_read] = '\0';
-  fclose(Fptr);
-
-  printf("%s\n", filebuffer);
-  delete[]filebuffer;
-  return CLI_OK;
-}
-
-void
-CIFCEntry::PrintEle()
-{
-  printf("%s:%d:%s\n", KeyWord, CountOn, Input);
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigWrite
-//
-// This is the callback function for the "config:write" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigWrite(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[])
-{
-  CIFCEntry *EntryPtr;
-  int CLI_RETURN;
-
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:write") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable, *infoPtr;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-  infoPtr = argtable;
-  Cli_Debug("Cmd_ConfigWrite argc %d\n", argc);
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_WRITE_IFC_HEAD:
-      EntryPtr = new CIFCEntry("IfcHead", 0, "%s\n%s\n%s\n%d", argtable[1].arg_string, argtable[2].arg_string,
-                               argtable[3].arg_string, argtable[4].arg_int);
-      break;
-    case CMD_CONFIG_WRITE_FEATURE:
-      EntryPtr = new CIFCEntry("Feature", 0, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_TAR:
-      EntryPtr = new CIFCEntry("Tar", 1, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_TAR_INFO:
-      EntryPtr = new CIFCEntry("TarInfo", 0, "%s:%s", argtable[0].arg_string, argtable[1].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_TAR_COMMON:
-      EntryPtr = new CIFCEntry("CommonTar", 1, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_BIN_DIR:
-      EntryPtr = new CIFCEntry("BinDir", 1, "%s:%s", argtable[0].arg_string, argtable[1].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_BIN_GROUP:
-      EntryPtr = new CIFCEntry("BinGroup", 1, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_BIN_COMMON:
-      EntryPtr = new CIFCEntry("BinCommon", 1, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_LIB_DIR:
-      EntryPtr = new CIFCEntry("LibDir", 1, "%s:%s", argtable[0].arg_string, argtable[1].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_LIB_GROUP:
-      EntryPtr = new CIFCEntry("LibGroup", 1, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_LIB_COMMON:
-      EntryPtr = new CIFCEntry("LibCommon", 1, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_CONFIG_DIR:
-      EntryPtr = new CIFCEntry("ConfigDir", 1, "%s:%s", argtable[0].arg_string, argtable[1].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_CONFIG_GROUP:
-      EntryPtr = new CIFCEntry("ConfigGroup", 1, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_CONFIG_COMMON:
-      EntryPtr = new CIFCEntry("ConfigCommon", 1, argtable[0].arg_string);
-      break;
-    case CMD_CONFIG_WRITE_COMMON_FILE:
-      EntryPtr = new CIFCEntry("CommonFile", 1, argtable[0].arg_string);
-    }
-
-    if (EntryPtr == NULL) {
-      Cli_Error("Error Allocate Memory\n");
-      return CLI_ERROR;
-    } else {
-      CLI_RETURN = EntryPtr->ConfigWriteIFC();
-      delete EntryPtr;
-      return CLI_RETURN;
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigWrite
-//
-// Register "config:write" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigWrite()
-{
-
-  createArgument("ifc-head", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_WRITE_IFC_HEAD, "Specify the head information of ifc file", (char *) NULL);
-  createArgument("ts-version", CMD_CONFIG_WRITE_IFC_HEAD, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_TS_VERSION, "Specify the version of Traffic Server installed",
-                 (char *) NULL);
-  createArgument("build-date", CMD_CONFIG_WRITE_TS_VERSION, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_BUILD_DATE, "Specify date of the Traffic Server Build", (char *) NULL);
-  createArgument("platform", CMD_CONFIG_WRITE_BUILD_DATE, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_PLATFORM, "Specify the platform of installation", (char *) NULL);
-  createArgument("nodes", CMD_CONFIG_WRITE_PLATFORM, CLI_ARGV_INT,
-                 (char *) NULL, CMD_CONFIG_WRITE_NODES, "Specify the number of node in the cluster", (char *) NULL);
-  createArgument("feature", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_FEATURE, "Specify the feature string", (char *) NULL);
-  createArgument("tar", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_TAR, "Specify the tar file list", (char *) NULL);
-  createArgument("tar-common", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_TAR_COMMON, "Specify the MUST-HAVE tar files", (char *) NULL);
-  createArgument("tar-info", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_TAR_INFO, "Specify the file contained in this named tar file",
-                 (char *) NULL);
-  createArgument("filelist", CLI_ARGV_NO_POS, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_FILELIST, "Specify the filelist contained in this named tar file",
-                 (char *) NULL);
-  createArgument("bin-dir", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_BIN_DIR,
-                 "Specify the subdirectories and the files in each of them in bin directory", (char *) NULL);
-  createArgument("bin-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_BIN_GROUP,
-                 "Specify the file listed in the bin directory", (char *) NULL);
-  createArgument("bin-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_BIN_COMMON,
-                 "Specify the MUST-HAVE bin files", (char *) NULL);
-  createArgument("lib-dir", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_DIR,
-                 "Specify the subdirectories and the files in each of them in lib directory", (char *) NULL);
-  createArgument("lib-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_GROUP,
-                 "Specify the file listed in the lib directory", (char *) NULL);
-  createArgument("lib-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_COMMON,
-                 "Specify the MUST-HAVE lib files", (char *) NULL);
-  createArgument("config-dir", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_DIR,
-                 "Specify the subdirectories and the files in each of them in the config directory", (char *) NULL);
-  createArgument("config-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_GROUP,
-                 "Specify the file listed in the config directory", (char *) NULL);
-  createArgument("config-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_COMMON,
-                 "Specify the MUST-HAVE config files", (char *) NULL);
-  createArgument("common-file", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_COMMON_FILE,
-                 "Specify the MUST-HAVE files", (char *) NULL);
-
-  return CLI_OK;
-}
-
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigRead
-//
-// This is the callback function for the "config:read" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigRead(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[])
-{
-
-  CIFCEntry *EntryPtr;
-  int CLI_RETURN;
-
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:read") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable, *infoPtr;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-  infoPtr = argtable;
-  Cli_Debug("Cmd_ConfigRead argc %d\n", argc);
-
-  if (argtable->parsed_args == CLI_PARSED_ARGV_END) {
-    EntryPtr = new CIFCEntry("", 0, "");
-    if (EntryPtr == NULL) {
-      Cli_Error("Error Allocate Memory\n");
-      return CLI_ERROR;
-    } else {
-      CLI_RETURN = EntryPtr->ConfigReadIFC();
-      delete EntryPtr;
-      return CLI_RETURN;
-    }
-  }
-
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/ConfigUpgradeCmd.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/ConfigUpgradeCmd.h b/mgmt/cli/ConfigUpgradeCmd.h
deleted file mode 100644
index d75472d..0000000
--- a/mgmt/cli/ConfigUpgradeCmd.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/************C****************************************************
- * Filename: ConfigUpgradeCmd.h
- * Purpose: This file contains the CLI's "config:" command definitions.
- ****************************************************************/
-
-
-
-#include <tcl.h>
-#include <stdlib.h>
-#include <createArgument.h>
-#include <definitions.h>
-
-
-
-#ifndef __CONFIG_UPGRADE_CMD_H__
-#define __CONFIG_UPGRADE_CMD_H__
-
-
-#define CONFIG_UPGRADE_INT_STRING_SIZE 5
-#define CONFIG_UPGRADE_STRING_SIZE 256
-#define CONFIG_UPGRADE_BUF_SIZE 10240
-
-
-#define IFC_BEGIN         "Begin"
-#define IFC_HEAD          "IfcHead"
-#define IFC_FEATURE       "Feature"
-#define IFC_TAR           "Tar"
-#define IFC_COMMON_TAR    "CommonTar"
-#define IFC_TAR_INFO      "TarInfo"
-#define IFC_BIN_GROUP     "BinGroup"
-#define IFC_BIN_DIR       "BinDir"
-#define IFC_BIN_COMMON    "BinCommon"
-#define IFC_LIB_GROUP     "LibGroup"
-#define IFC_LIB_DIR       "LibDir"
-#define IFC_LIB_COMMON    "LibCommon"
-#define IFC_CONFIG_GROUP  "ConfigGroup"
-#define IFC_CONFIG_DIR    "ConfigDir"
-#define IFC_CONFIG_COMMON "ConfigCommon"
-#define IFC_COMMON_FILE   "CommonFile"
-#define IFC_END           "End"
-#define IFC_LIST_BEGIN    "{"
-#define IFC_LIST_END      "}"
-
-typedef enum
-{
-  IFC_KEY_IFCHEAD = 10,
-  IFC_KEY_FEATURE,
-  IFC_KEY_TAR,
-  IFC_KEY_COMMON_TAR,
-  IFC_KEY_TAR_INFO,
-  IFC_KEY_BIN_GROUP,
-  IFC_KEY_BIN_DIR,
-  IFC_KEY_BIN_COMMON,
-  IFC_KEY_LIB_GROUP,
-  IFC_KEY_LIB_DIR,
-  IFC_KEY_LIB_COMMON,
-  IFC_KEY_CONFIG_GROUP,
-  IFC_KEY_CONFIG_DIR,
-  IFC_KEY_CONFIG_COMMON,
-  IFC_KEY_COMMON_FILE,
-  IFC_KEY_END
-} IfcKeyWord;
-
-class CIFCWriteEntry
-{
-
-  char FileName[CONFIG_UPGRADE_STRING_SIZE];
-  char Version[CONFIG_UPGRADE_STRING_SIZE];
-  char KeyWord[CONFIG_UPGRADE_STRING_SIZE];
-  char Input[CONFIG_UPGRADE_BUF_SIZE];
-  int CountOn;
-
-  // write IFC file
-  int ConfigWriteIFCEle();
-
-public:
-
-    CIFCWriteEntry();
-   ~CIFCWriteEntry();
-
-  // PrintOut the Element of this Entry
-  void PrintEle();
-
-  TSError Cli_NewIFCFile();
-
-  static TSError ConfigWriteCheckIFCEnv();
-
-  int ConfigWriteIFCHead(char *ts_version, char *build_date, char *platform, int nodes);
-
-  int ConfigWriteIFCFeature(char *input);
-
-  int ConfigWriteIFCTar(char *input);
-
-  int ConfigWriteIFCCommonTar(char *input);
-
-  int ConfigWriteIFCTarInfo(char *tar, char *filelist);
-
-  int ConfigWriteIFCBinCommon(char *input);
-
-  int ConfigWriteIFCBinGroup(char *input);
-
-  int ConfigWriteIFCBinDir(char *subdir, char *filelist);
-
-  int ConfigWriteIFCLibCommon(char *input);
-
-  int ConfigWriteIFCLibGroup(char *input);
-
-  int ConfigWriteIFCLibDir(char *subdir, char *filelist);
-
-  int ConfigWriteIFCConfigCommon(char *input);
-
-  int ConfigWriteIFCConfigGroup(char *input);
-
-  int ConfigWriteIFCConfigDir(char *subdir, char *filelist);
-
-  int ConfigWriteIFCCommonFile(char *input);
-
-};
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigWrite
-//
-// This is the callback function for the "config:write" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigWrite(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigWrite
-//
-// Register "config:write" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigWrite();
-
-
-class CIFCReadEntry
-{
-
-  char FileName[CONFIG_UPGRADE_STRING_SIZE];
-  char Version[CONFIG_UPGRADE_STRING_SIZE];
-  char KeyWord[CONFIG_UPGRADE_STRING_SIZE];
-  char Output[CONFIG_UPGRADE_BUF_SIZE];
-  int CountOn;
-  int Count;
-
-  // read IFC file
-  int ConfigReadIFCEle();
-
-  int ConfigReadPrintIFCEle();
-
-public:
-
-    CIFCReadEntry();
-   ~CIFCReadEntry();
-
-  static TSError ConfigReadCheckIFCEnv();
-
-  int ConfigReadIFCHead();
-
-  int ConfigReadIFCFeature();
-
-  int ConfigReadIFCTar();
-
-  int ConfigReadIFCCommonTar();
-
-  int ConfigReadIFCTarInfo();
-
-  int ConfigReadIFCBinCommon();
-
-  int ConfigReadIFCBinGroup();
-
-  int ConfigReadIFCBinDir();
-
-  int ConfigReadIFCLibCommon();
-
-  int ConfigReadIFCLibGroup();
-
-  int ConfigReadIFCLibDir();
-
-  int ConfigReadIFCConfigCommon();
-
-  int ConfigReadIFCConfigGroup();
-
-  int ConfigReadIFCConfigDir();
-
-  int ConfigReadIFCCommonFile();
-
-};
-
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigRead
-//
-// This is the callback function for the "config:read" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int Cmd_ConfigRead(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigRead
-//
-// Register "config:read" arguments with the Tcl interpreter.
-//
-int CmdArgs_ConfigRead();
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigSaveUrl
-//
-// Register "config:save-url" arguments with the Tcl interpreter.
-//
-
-int Cmd_ConfigSaveUrl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
-
-int CmdArgs_ConfigSaveUrl();
-
-
-#endif /* __CONFIG_UPGRADE_CMD_H__ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/ConfigUpgradeReadCmd.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/ConfigUpgradeReadCmd.cc b/mgmt/cli/ConfigUpgradeReadCmd.cc
deleted file mode 100644
index d539c00..0000000
--- a/mgmt/cli/ConfigUpgradeReadCmd.cc
+++ /dev/null
@@ -1,498 +0,0 @@
-/** @file
-
-  This file contains the CLI's "config:read" command implementation
-
-  @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 "libts.h"
-#include <ConfigCmd.h>
-#include <CliDisplay.h>
-#include <CliMgmtUtils.h>
-#include <ConfigUpgradeCmd.h>
-#include <string.h>
-#include "../api/include/mgmtapi.h"
-
-
-extern Tcl_Interp *interp;
-CIFCReadEntry::CIFCReadEntry():
-CountOn(0), Count(0)
-{
-  KeyWord[0] = 0;
-  Output[0] = 0;
-  const char *pathPtr = getenv("IFCPATH");
-  const char *filenamePtr = getenv("IFCFILENAME");
-  const char *versionPtr = getenv("IFCVERSION");
-
-  snprintf(FileName, sizeof(FileName), "%s%s", pathPtr, filenamePtr);
-  snprintf(Version, sizeof(Version), "%s", versionPtr);
-}
-
-CIFCReadEntry::~CIFCReadEntry()
-{
-}
-
-// check IFCVERSION IFCPATH and IFCFILENAME setup
-TSError
-CIFCReadEntry::ConfigReadCheckIFCEnv()
-{
-  char *pathPtr;
-  char *filenamePtr;
-  char *versionPtr;
-
-  pathPtr = getenv("IFCPATH");
-  filenamePtr = getenv("IFCFILENAME");
-  versionPtr = getenv("IFCVERSION");
-
-  if (pathPtr == NULL || filenamePtr == NULL || versionPtr == NULL ||
-      strlen(pathPtr) == 0 || strlen(filenamePtr) == 0 || strlen(versionPtr) == 0) {
-    return TS_ERR_READ_FILE;
-  }
-
-  return TS_ERR_OKAY;
-}
-
-
-int
-CIFCReadEntry::ConfigReadPrintIFCEle()
-{
-  Tcl_AppendResult(interp, Output, (char *) NULL);
-  return CLI_OK;
-}
-
-int
-CIFCReadEntry::ConfigReadIFCEle()
-{
-  FILE *Fptr;
-  char *filebuffer;
-  char *p1, *p2;
-  char CountString[CONFIG_UPGRADE_INT_STRING_SIZE];
-  long size, amount_read;
-
-  if ((Fptr = fopen(FileName, "r")) == NULL) {
-    Cli_Error("ERROR Open IFC File to read\n");
-    return CLI_ERROR;
-  }
-
-  fseek(Fptr, 0, SEEK_END);
-  size = ftell(Fptr);
-  if (size <= 0) {
-    fclose(Fptr);
-    Cli_Error("Error Reading IFC File\n");
-    return CLI_ERROR;
-  }
-
-  filebuffer = new char[size + 1];
-  fseek(Fptr, 0, SEEK_SET);
-  amount_read = fread((void *) filebuffer, sizeof(char), size, Fptr);
-  fclose(Fptr);
-  Fptr = NULL;
-  filebuffer[size] = '\0';
-
-  if (size * (int) sizeof(char) != amount_read) {
-    Cli_Error("Error Reading IFC File\n");
-    delete[]filebuffer;
-    return CLI_ERROR;
-  }
-  // look for KeyWord
-  if ((p1 = strstr(filebuffer, KeyWord)) == NULL) {
-    delete[]filebuffer;
-    Cli_Error("Error Finding Keyword\n");
-    return CLI_ERROR;
-  }
-
-  p1 += strlen(KeyWord);
-  p1++;
-
-  // look for the end tag
-  if ((p2 = strstr(p1, IFC_LIST_END)) == NULL) {
-    delete[]filebuffer;
-    Cli_Error("Error Finding End Keyword\n");
-    return CLI_ERROR;
-  }
-
-  switch (CountOn) {
-  case 1:
-
-    // coverity[secure_coding]
-    sscanf(p1, "%d\n", &Count);
-    snprintf(CountString, sizeof(CountString), "%d", Count);
-    p1 += (strlen(CountString));
-    //fall through
-
-  case 0:
-    p1++;
-    snprintf(Output, p2 - p1, "%s", p1);
-    //memset(Output + (p2-p1), 1, 0);
-    delete[]filebuffer;
-    return (ConfigReadPrintIFCEle());
-
-  default:
-
-    Cli_Error("Unexpected Value of CountOn\n");
-    delete[]filebuffer;
-    return CLI_ERROR;
-  }
-}
-
-
-int
-CIFCReadEntry::ConfigReadIFCHead()
-{
-  ink_strlcpy(KeyWord, IFC_HEAD, sizeof(KeyWord));
-  CountOn = 0;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCFeature()
-{
-  ink_strlcpy(KeyWord, IFC_FEATURE, sizeof(KeyWord));
-  CountOn = 0;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCTar()
-{
-  ink_strlcpy(KeyWord, IFC_TAR, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCCommonTar()
-{
-  ink_strlcpy(KeyWord, IFC_COMMON_TAR, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCTarInfo()
-{
-  ink_strlcpy(KeyWord, IFC_TAR_INFO, sizeof(KeyWord));
-  CountOn = 0;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCBinGroup()
-{
-  ink_strlcpy(KeyWord, IFC_BIN_GROUP, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCBinDir()
-{
-  ink_strlcpy(KeyWord, IFC_BIN_DIR, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCBinCommon()
-{
-  ink_strlcpy(KeyWord, IFC_BIN_COMMON, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCLibGroup()
-{
-  ink_strlcpy(KeyWord, IFC_LIB_GROUP, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCLibDir()
-{
-  ink_strlcpy(KeyWord, IFC_LIB_DIR, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCLibCommon()
-{
-  ink_strlcpy(KeyWord, IFC_LIB_COMMON, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCConfigGroup()
-{
-  ink_strlcpy(KeyWord, IFC_CONFIG_GROUP, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCConfigDir()
-{
-  ink_strlcpy(KeyWord, IFC_CONFIG_DIR, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-int
-CIFCReadEntry::ConfigReadIFCConfigCommon()
-{
-  ink_strlcpy(KeyWord, IFC_CONFIG_COMMON, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-
-int
-CIFCReadEntry::ConfigReadIFCCommonFile()
-{
-  ink_strlcpy(KeyWord, IFC_COMMON_FILE, sizeof(KeyWord));
-  CountOn = 1;
-  return (ConfigReadIFCEle());
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigRead
-//
-// This is the callback function for the "config:read" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigRead(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  /*   if(cliCheckIfEnabled("config:read") == CLI_ERROR) {
-     return CMD_ERROR;
-     }
-   */
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-  Cli_Debug("Cmd_ConfigRead argc %d\n", argc);
-
-  if (CIFCWriteEntry::ConfigWriteCheckIFCEnv() == TS_ERR_READ_FILE) {
-    Cli_Error("Set $IFCVERSION, $IFCPATH and $IFCFILENAME First\n");
-    return CLI_ERROR;
-  }
-
-  CIFCReadEntry Entry;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-
-    switch (argtable->parsed_args) {
-
-    case CMD_CONFIG_READ_IFC_HEAD:
-      return (Entry.ConfigReadIFCHead());
-
-    case CMD_CONFIG_READ_FEATURE:
-      return (Entry.ConfigReadIFCFeature());
-
-    case CMD_CONFIG_READ_TAR:
-      return (Entry.ConfigReadIFCTar());
-
-    case CMD_CONFIG_READ_TAR_INFO:
-      return (Entry.ConfigReadIFCTarInfo());
-
-    case CMD_CONFIG_READ_TAR_COMMON:
-      return (Entry.ConfigReadIFCCommonTar());
-
-    case CMD_CONFIG_READ_BIN_DIR:
-      return (Entry.ConfigReadIFCBinDir());
-
-    case CMD_CONFIG_READ_BIN_GROUP:
-      return (Entry.ConfigReadIFCBinGroup());
-
-    case CMD_CONFIG_READ_BIN_COMMON:
-      return (Entry.ConfigReadIFCBinCommon());
-
-    case CMD_CONFIG_READ_LIB_DIR:
-      return (Entry.ConfigReadIFCLibDir());
-
-    case CMD_CONFIG_READ_LIB_GROUP:
-      return (Entry.ConfigReadIFCLibGroup());
-
-    case CMD_CONFIG_READ_LIB_COMMON:
-      return (Entry.ConfigReadIFCLibCommon());
-
-    case CMD_CONFIG_READ_CONFIG_DIR:
-      return (Entry.ConfigReadIFCConfigDir());
-
-    case CMD_CONFIG_READ_CONFIG_GROUP:
-      return (Entry.ConfigReadIFCConfigGroup());
-
-    case CMD_CONFIG_READ_CONFIG_COMMON:
-      return (Entry.ConfigReadIFCConfigCommon());
-
-    case CMD_CONFIG_READ_COMMON_FILE:
-      return (Entry.ConfigReadIFCCommonFile());
-    }
-  }
-
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigRead
-//
-// Register "config:read" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigRead()
-{
-  createArgument("ifc-head", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_READ_IFC_HEAD, "Read the head information of ifc file", (char *) NULL);
-  createArgument("feature", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_READ_FEATURE, "Read the feature string", (char *) NULL);
-  createArgument("tar", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_READ_TAR, "Read the tar file list", (char *) NULL);
-  createArgument("tar-common", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_READ_TAR_COMMON, "Read the MUST-HAVE tar files", (char *) NULL);
-  createArgument("tar-info", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_READ_TAR_INFO, "Read the file contained in this named tar file",
-                 (char *) NULL);
-  createArgument("bin-dir", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_READ_BIN_DIR,
-                 "Read the subdirectories and the files in each of them in bin directory", (char *) NULL);
-  createArgument("bin-group", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_BIN_GROUP,
-                 "Read the file listed in the bin directory", (char *) NULL);
-  createArgument("bin-common", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_BIN_COMMON,
-                 "Read the MUST-HAVE bin files", (char *) NULL);
-  createArgument("lib-dir", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_LIB_DIR,
-                 "Read the subdirectories and the files in each of them in lib directory", (char *) NULL);
-  createArgument("lib-group", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_LIB_GROUP,
-                 "Read the file listed in the lib directory", (char *) NULL);
-  createArgument("lib-common", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_LIB_COMMON,
-                 "Read the MUST-HAVE lib files", (char *) NULL);
-  createArgument("config-dir", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_CONFIG_DIR,
-                 "Read the subdirectories and the files in each of them in the config directory", (char *) NULL);
-  createArgument("config-group", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_CONFIG_GROUP,
-                 "Read the file listed in the config directory", (char *) NULL);
-  createArgument("config-common", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_CONFIG_COMMON,
-                 "Read the MUST-HAVE config files", (char *) NULL);
-  createArgument("common-file", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_READ_COMMON_FILE,
-                 "Read the MUST-HAVE files", (char *) NULL);
-
-  return CLI_OK;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigSaveUrl
-//
-// This is the callback function for the "config:saveUrl" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigSaveUrl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* Call to processArgForCommand must appear at the beginning
-     of each command's cb function.
-   */
-
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-/*   if(cliCheckIfEnabled("config:save-url") == CLI_ERROR) {
-     return CMD_ERROR;
-   }
-*/
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable, *infoPtr;
-  char *Url = NULL;
-  char *outputFile = NULL;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-  Cli_Debug("Cmd_ConfigSaveUrl argc %d\n", argc);
-  char **header = 0;            /* lv: useless variable - never changed */
-  int headerSize;
-  char **body = 0;              /* lv: useless variable - never changed */
-  int bodySize;
-
-  for (infoPtr = argtable; infoPtr->parsed_args != CLI_PARSED_ARGV_END; infoPtr++) {
-    switch (infoPtr->parsed_args) {
-
-    case CMD_CONFIG_UPGRADE_READ_URL:
-      Url = argtable->arg_string;
-      infoPtr++;
-      outputFile = argtable->arg_string;
-      break;
-    }
-  }
-  if (Url == NULL || outputFile == NULL) {
-    return CMD_ERROR;
-  } else {
-    if (TSReadFromUrl(Url, header, &headerSize, body, &bodySize) == TS_ERR_FAIL) {
-      return CMD_ERROR;
-    }
-
-  }
-
-  return CMD_OK;
-}
-
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigSaveUrl
-//
-// Register "config:read" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigSaveUrl()
-{
-  createArgument("url", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_UPGRADE_READ_URL, "Read the url", (char *) NULL);
-
-  return CMD_OK;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/ConfigUpgradeWriteCmd.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/ConfigUpgradeWriteCmd.cc b/mgmt/cli/ConfigUpgradeWriteCmd.cc
deleted file mode 100644
index 153ba50..0000000
--- a/mgmt/cli/ConfigUpgradeWriteCmd.cc
+++ /dev/null
@@ -1,517 +0,0 @@
-/** @file
-
-  This file contains the CLI's "config:write" command implementation
-
-  @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 "libts.h"
-#include <ConfigCmd.h>
-#include <CliDisplay.h>
-#include <CliMgmtUtils.h>
-#include <CliDisplay.h>
-#include <CliMgmtUtils.h>
-#include <ConfigUpgradeCmd.h>
-#include <string.h>
-
-
-CIFCWriteEntry::CIFCWriteEntry():CountOn(0)
-{
-  char *pathPtr;
-  char *filenamePtr;
-  char *versionPtr;
-
-  pathPtr = getenv("IFCPATH");
-  filenamePtr = getenv("IFCFILENAME");
-  versionPtr = getenv("IFCVERSION");
-
-  snprintf(FileName, sizeof(FileName), "%s%s", pathPtr, filenamePtr);
-  snprintf(Version, sizeof(Version), "%s", versionPtr);
-
-  KeyWord[0] = '\0';
-  Input[0] = '\0';
-}
-
-CIFCWriteEntry::~CIFCWriteEntry()
-{
-}
-
-// check IFCVERSION IFCPATH and IFCFILENAME setup
-TSError
-CIFCWriteEntry::ConfigWriteCheckIFCEnv()
-{
-  char *pathPtr;
-  char *filenamePtr;
-  char *versionPtr;
-
-  pathPtr = getenv("IFCPATH");
-  filenamePtr = getenv("IFCFILENAME");
-  versionPtr = getenv("IFCVERSION");
-
-  if (pathPtr == NULL || filenamePtr == NULL || versionPtr == NULL ||
-      strlen(pathPtr) == 0 || strlen(filenamePtr) == 0 || strlen(versionPtr) == 0) {
-    return TS_ERR_READ_FILE;
-  }
-
-  return TS_ERR_OKAY;
-}
-
-TSError
-CIFCWriteEntry::Cli_NewIFCFile()
-{
-  FILE *Fptr;
-
-  Fptr = fopen(FileName, "r+");
-  if (Fptr != NULL) {
-    fclose(Fptr);
-    return TS_ERR_OKAY;
-  } else {                      /* need to create new file */
-    Fptr = fopen(FileName, "w");
-    if (Fptr == NULL) {
-      Cli_Error("Error in creating new IFC file\n");
-      return TS_ERR_WRITE_FILE;
-    }
-
-    fprintf(Fptr, "%s\n\n", IFC_BEGIN);
-    fprintf(Fptr, "%s%s\n%s\n\n", IFC_HEAD, IFC_LIST_BEGIN, IFC_LIST_END);
-    fprintf(Fptr, "%s%s\n%s\n\n", IFC_FEATURE, IFC_LIST_BEGIN, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_TAR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s\n%s\n\n", IFC_TAR_INFO, IFC_LIST_BEGIN, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_COMMON_TAR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_BIN_GROUP, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_BIN_DIR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_BIN_COMMON, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_LIB_GROUP, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_LIB_DIR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_LIB_COMMON, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_CONFIG_GROUP, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_CONFIG_DIR, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_CONFIG_COMMON, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s%s%d\n%s\n\n", IFC_COMMON_FILE, IFC_LIST_BEGIN, 0, IFC_LIST_END);
-    fprintf(Fptr, "%s\n\n", IFC_END);
-
-    fclose(Fptr);
-
-    return TS_ERR_OKAY;
-  }
-}
-
-
-int
-CIFCWriteEntry::ConfigWriteIFCEle()
-{
-  FILE *Fptr;
-  char *filebuffer, *in_buffer;
-  char *p1;
-  char OldCountString[CONFIG_UPGRADE_INT_STRING_SIZE];
-  int Count = -1;
-  long size, amount_read, addsize;
-
-  if ((Fptr = fopen(FileName, "r")) == NULL) {
-    Cli_Error("ERROR Open IFC File to read\n");
-    return CLI_ERROR;
-  }
-
-  fseek(Fptr, 0, SEEK_END);
-  size = ftell(Fptr);
-  if (size <= 0) {
-    fclose(Fptr);
-    Cli_Error("Error Reading IFC File\n");
-    return CLI_ERROR;
-  }
-
-  filebuffer = new char[size + 1];
-  fseek(Fptr, 0, SEEK_SET);
-  amount_read = fread((void *) filebuffer, sizeof(char), size, Fptr);
-  fclose(Fptr);
-  filebuffer[size] = '\0';
-
-  if (size * (int) sizeof(char) != amount_read) {
-    Cli_Error("Error Reading IFC File\n");
-    fclose(Fptr);
-    delete[]filebuffer;
-    return CLI_ERROR;
-  }
-  // look for KeyWord
-  if ((p1 = strstr(filebuffer, KeyWord)) == NULL) {
-    delete[]filebuffer;
-    fclose(Fptr);
-    Cli_Error("Error Finding Keyword\n");
-    return CLI_ERROR;
-  }
-
-  p1 += strlen(KeyWord);
-  p1++;
-
-  // writeback
-  Fptr = fopen(FileName, "r+");
-  fseek(Fptr, p1 - filebuffer, SEEK_SET);
-
-  switch (CountOn) {
-  case 1:
-    {
-      // coverity[secure_coding]
-      sscanf(p1, "%d\n", &Count);
-      snprintf(OldCountString, sizeof(OldCountString), "%d", Count);
-      p1 += (strlen(OldCountString) + 1);
-      Count++;
-      addsize = strlen(Input) + CONFIG_UPGRADE_INT_STRING_SIZE + 2;
-      const size_t in_buffer_size = addsize + 1;
-      in_buffer = new char[in_buffer_size];
-      snprintf(in_buffer, in_buffer_size, "%d\n%s\n", Count, Input);
-      in_buffer[addsize] = '\0';
-      if (fwrite(in_buffer, sizeof(char), strlen(in_buffer), Fptr) != strlen(in_buffer)) {
-        Cli_Error("Unable to fwrite() buffer\n");
-        delete[]in_buffer;
-        delete[]filebuffer;
-        fclose(Fptr);
-        return CLI_ERROR;
-      }
-      delete[]in_buffer;
-      break;
-    }
-  case 0:
-    if ((fwrite("\n", sizeof(char), 1, Fptr) != 1) ||
-        (fwrite(Input, sizeof(char), strlen(Input), Fptr) != strlen(Input))) {
-      Cli_Error("Unable to fwrite() buffer\n");
-      fclose(Fptr);
-      delete[]filebuffer;
-      return CLI_ERROR;
-    }
-    break;
-
-  default:
-    Cli_Error("Unexpected Value of CountOn\n");
-    fclose(Fptr);
-    delete[]filebuffer;
-    return CLI_ERROR;
-  }
-
-  if (fwrite(p1, sizeof(char), size - (p1 - filebuffer), Fptr) != (size_t)(size - (p1 - filebuffer))) {
-    Cli_Error("Unable to fwrite() buffer\n");
-    fclose(Fptr);
-    delete[]filebuffer;
-    return CLI_ERROR;
-  }
-  fclose(Fptr);
-  delete[]filebuffer;
-  return CLI_OK;
-
-}
-
-
-void
-CIFCWriteEntry::PrintEle()
-{
-  printf("%s:%d:%s\n", KeyWord, CountOn, Input);
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCHead(char *ts_version, char *build_date, char *platform, int nodes)
-{
-  ink_strlcpy(KeyWord, IFC_HEAD, sizeof(KeyWord));
-  snprintf(Input, sizeof(Input), "%s\n%s\n%s\n%d", ts_version, build_date, platform, nodes);
-  CountOn = 0;
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCFeature(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_FEATURE, sizeof(KeyWord));
-  CountOn = 0;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCTar(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_TAR, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCCommonTar(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_COMMON_TAR, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCTarInfo(char *tar, char *filelist)
-{
-  ink_strlcpy(KeyWord, IFC_TAR_INFO, sizeof(KeyWord));
-  CountOn = 0;
-  snprintf(Input, sizeof(Input), "%s:\n%s", tar, filelist);
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCBinGroup(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_BIN_GROUP, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCBinDir(char *subdir, char *filelist)
-{
-  ink_strlcpy(KeyWord, IFC_BIN_DIR, sizeof(KeyWord));
-  CountOn = 1;
-  snprintf(Input, sizeof(Input), "%s:%s", subdir, filelist);
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCBinCommon(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_BIN_COMMON, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCLibGroup(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_LIB_GROUP, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCLibDir(char *subdir, char *filelist)
-{
-  ink_strlcpy(KeyWord, IFC_LIB_DIR, sizeof(KeyWord));
-  CountOn = 1;
-  snprintf(Input, sizeof(Input), "%s:%s", subdir, filelist);
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCLibCommon(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_LIB_COMMON, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCConfigGroup(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_CONFIG_GROUP, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCConfigDir(char *subdir, char *filelist)
-{
-  ink_strlcpy(KeyWord, IFC_CONFIG_DIR, sizeof(KeyWord));
-  CountOn = 1;
-  snprintf(Input, sizeof(Input), "%s:%s", subdir, filelist);
-  return (ConfigWriteIFCEle());
-}
-
-int
-CIFCWriteEntry::ConfigWriteIFCConfigCommon(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_CONFIG_COMMON, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-
-int
-CIFCWriteEntry::ConfigWriteIFCCommonFile(char *input)
-{
-  ink_strlcpy(KeyWord, IFC_COMMON_FILE, sizeof(KeyWord));
-  CountOn = 1;
-  ink_strlcpy(Input, input, sizeof(Input));
-  return (ConfigWriteIFCEle());
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigWrite
-//
-// This is the callback function for the "config:write" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigWrite(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  /*if(cliCheckIfEnabled("config:write") == CLI_ERROR)
-     {
-     return CMD_ERROR;
-     } */
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-  Cli_Debug("Cmd_ConfigWrite argc %d\n", argc);
-
-  if (CIFCWriteEntry::ConfigWriteCheckIFCEnv() == TS_ERR_READ_FILE) {
-    Cli_Error("Set $IFCVERSION, $IFCPATH and $IFCFILENAME First\n");
-    return CLI_ERROR;
-  }
-
-  CIFCWriteEntry Entry;
-
-  if (Entry.Cli_NewIFCFile() == TS_ERR_WRITE_FILE) {
-    return CLI_ERROR;
-  }
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_WRITE_IFC_HEAD:
-      return (Entry.ConfigWriteIFCHead(argtable[1].arg_string,
-                                       argtable[2].arg_string, argtable[3].arg_string, argtable[4].arg_int));
-
-    case CMD_CONFIG_WRITE_FEATURE:
-      return (Entry.ConfigWriteIFCFeature(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_TAR:
-      return (Entry.ConfigWriteIFCTar(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_TAR_INFO:
-      return (Entry.ConfigWriteIFCTarInfo(argtable[0].arg_string, argtable[1].arg_string));
-
-    case CMD_CONFIG_WRITE_TAR_COMMON:
-      return (Entry.ConfigWriteIFCCommonTar(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_BIN_DIR:
-      return (Entry.ConfigWriteIFCBinDir(argtable[0].arg_string, argtable[1].arg_string));
-
-    case CMD_CONFIG_WRITE_BIN_GROUP:
-      return (Entry.ConfigWriteIFCBinGroup(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_BIN_COMMON:
-      return (Entry.ConfigWriteIFCBinCommon(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_LIB_DIR:
-      return (Entry.ConfigWriteIFCLibDir(argtable[0].arg_string, argtable[1].arg_string));
-
-    case CMD_CONFIG_WRITE_LIB_GROUP:
-      return (Entry.ConfigWriteIFCLibGroup(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_LIB_COMMON:
-      return (Entry.ConfigWriteIFCLibCommon(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_CONFIG_DIR:
-      return (Entry.ConfigWriteIFCConfigDir(argtable[0].arg_string, argtable[1].arg_string));
-
-    case CMD_CONFIG_WRITE_CONFIG_GROUP:
-      return (Entry.ConfigWriteIFCConfigGroup(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_CONFIG_COMMON:
-      return (Entry.ConfigWriteIFCConfigCommon(argtable[0].arg_string));
-
-    case CMD_CONFIG_WRITE_COMMON_FILE:
-      return (Entry.ConfigWriteIFCCommonFile(argtable[0].arg_string));
-    }
-  }
-
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigWrite0
-//
-// Register "config:write" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigWrite()
-{
-  createArgument("ifc-head", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_WRITE_IFC_HEAD, "Specify the head information of ifc file", (char *) NULL);
-  createArgument("ts-version", CMD_CONFIG_WRITE_IFC_HEAD, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_TS_VERSION, "Specify the version of Traffic Server installed",
-                 (char *) NULL);
-  createArgument("build-date", CMD_CONFIG_WRITE_TS_VERSION, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_BUILD_DATE, "Specify date of the Traffic Server Build", (char *) NULL);
-  createArgument("platform", CMD_CONFIG_WRITE_BUILD_DATE, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_PLATFORM, "Specify the platform of installation", (char *) NULL);
-  createArgument("nodes", CMD_CONFIG_WRITE_PLATFORM, CLI_ARGV_INT,
-                 (char *) NULL, CMD_CONFIG_WRITE_NODES, "Specify the number of node in the cluster", (char *) NULL);
-  createArgument("feature", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_FEATURE, "Specify the feature string", (char *) NULL);
-  createArgument("tar", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_TAR, "Specify the tar file list", (char *) NULL);
-  createArgument("tar-common", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_TAR_COMMON, "Specify the MUST-HAVE tar files", (char *) NULL);
-  createArgument("tar-info", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_TAR_INFO, "Specify the file contained in this named tar file",
-                 (char *) NULL);
-  createArgument("filelist", CLI_ARGV_NO_POS, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_FILELIST, "Specify the filelist contained in this named tar file",
-                 (char *) NULL);
-  createArgument("bin-dir", 1, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_WRITE_BIN_DIR,
-                 "Specify the subdirectories and the files in each of them in bin directory", (char *) NULL);
-  createArgument("bin-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_BIN_GROUP,
-                 "Specify the file listed in the bin directory", (char *) NULL);
-  createArgument("bin-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_BIN_COMMON,
-                 "Specify the MUST-HAVE bin files", (char *) NULL);
-  createArgument("lib-dir", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_DIR,
-                 "Specify the subdirectories and the files in each of them in lib directory", (char *) NULL);
-  createArgument("lib-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_GROUP,
-                 "Specify the file listed in the lib directory", (char *) NULL);
-  createArgument("lib-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_LIB_COMMON,
-                 "Specify the MUST-HAVE lib files", (char *) NULL);
-  createArgument("config-dir", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_DIR,
-                 "Specify the subdirectories and the files in each of them in the config directory", (char *) NULL);
-  createArgument("config-group", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_GROUP,
-                 "Specify the file listed in the config directory", (char *) NULL);
-  createArgument("config-common", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_CONFIG_COMMON,
-                 "Specify the MUST-HAVE config files", (char *) NULL);
-  createArgument("common-file", 1, CLI_ARGV_STRING, (char *) NULL, CMD_CONFIG_WRITE_COMMON_FILE,
-                 "Specify the MUST-HAVE files", (char *) NULL);
-
-  return CLI_OK;
-}


[37/44] git commit: TS-2360: Update TSMimeHdrFieldValueStringGet docs

Posted by zw...@apache.org.
TS-2360: Update TSMimeHdrFieldValueStringGet docs


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

Branch: refs/heads/5.0.x
Commit: 0c6c25e6cde89cdb66284b43fb8bcdfe4a009687
Parents: 51a9252
Author: James Peach <jp...@apache.org>
Authored: Tue Nov 19 21:29:52 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Nov 21 08:57:50 2013 -0800

----------------------------------------------------------------------
 doc/conf.py                                     |  1 +
 .../api/TSMimeHdrFieldValueStringGet.en.rst     | 47 ++++++++++----------
 2 files changed, 24 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c6c25e6/doc/conf.py
----------------------------------------------------------------------
diff --git a/doc/conf.py b/doc/conf.py
index 3eac055..0539bff 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -266,6 +266,7 @@ man_pages = [
    ('reference/api/TSRemap.en', 'TSRemap', u'Traffic Server remap plugin entry points ', None, u'3ts'),
    ('reference/api/TSTrafficServerVersionGet.en', 'TSTrafficServerVersionGet', u'return Traffic Server version information', None, u'3ts'),
    ('reference/api/TSUrlCreate.en', 'TSUrlCreate', u'Traffic Server URL manipulation API', None, u'3ts'),
+   ('reference/api/TSMimeHdrFieldValueStringGet.en', 'TSMimeHdrFieldValueStringGet', u'Get HTTP MIME header values', None, u'3ts'),
 
    ('reference/commands/traffic_cop.en', 'traffic_cop', u'Traffic Server watchdog', None, '8'),
    ('reference/commands/traffic_line.en', 'traffic_line', u'Traffic Server command line', None, '8'),

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0c6c25e6/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
index feec628..75453c7 100644
--- a/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
+++ b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
@@ -36,30 +36,31 @@ Synopsis
 Description
 ===========
 
-MIME headers and fields can be components of request headers, response
-headers, or standalone headers created within your plugin. The various
-functions here are all used to access header values of specific types, but it
-is up to the caller to know if a header has appropriate semantics for the API
-used. For all but :func:`TSMimeHdrFieldValueStringGet`, an appropriate data
-conversion algorithm is applied to the header field string.
-
-All APIs takes an argument with the :type:`TSMBuffer` marshal buffer, and the
-:type:`TSMLoc` for the location to headers. In addition, the required
-:data:`field` argument is the locator of a specific header value, as returned
-by e.g. :func:`TSMimeHdrFieldFind`.
-
-Within the header field, comma separated values can be retrieved with an index
-(:data:`idx`) ranging from 0 to the max number of fields for this value; this
-max is retrieved using :func:`TSMimeHdrFieldValuesCount`. An :data:`idx` value of
+MIME headers and fields can be components of request headers,
+response headers, or standalone headers created within a Traffic
+Server plugin. The functions here are all used to access header
+values of specific types, but it is up to the caller to know if a
+header has appropriate semantics for the API used. For all but
+:func:`TSMimeHdrFieldValueStringGet`, an appropriate data conversion
+algorithm is applied to the header field string.
+
+All the APIs take a :type:`TSMBuffer` marshal buffer argument, and
+a :type:`TSMLoc` argument indicating the location of the HTTP
+headers. The required :data:`field` argument is the locator of a
+specific header value, as returned by an accessor function such as
+:func:`TSMimeHdrFieldFind`.
+
+Within the header field, comma-separated values can be retrieved with an index
+(:data:`idx`) ranging from 0 to the maximum number of fields for this value; this
+maximum is retrieved using :func:`TSMimeHdrFieldValuesCount`. An :data:`idx` value of
 ``-1`` has the semantics of retrieving the entire header value, regardless of
-how many comma separated values there are. If a header is not comma separated,
+how many comma-separated values there are. If a header is not comma-separated,
 an :data:`idx` of :data:`0` or :data:`-1` are the same, but the latter is
-definitely preferred and recommended.
-
-For :func:`TSMimeHdrFieldValueStringGet`, an additional parameter can be
-provided, which is populated with the length of the string returned. If this
-argument is NULL, it is not derefenced and no length is returned.
+preferred.
 
+:func:`TSMimeHdrFieldValueStringGet` returns a pointer to the header
+value, and populated :data:`value_len_ptr` with the length of the
+value in bytes. The returned header value is not NUL-terminated.
 
 Return values
 =============
@@ -68,8 +69,6 @@ All functions returns the header value with a type matching the respective
 function name. Using :func:`TSMimeHdrFieldValueDateGet` on a header which
 does not have date-time semantics always returns :data:`0`.
 
-
-
 Examples
 ========
 
@@ -109,4 +108,4 @@ This examples show how to retrieve and copy a specific header.
 See also
 ========
 
-:manpage:`TSAPI(3ts)`, :manpage:`TSMBufferCreate(3ts)`, :manpage:`TSMimeHdrFieldValuesCount`
+:manpage:`TSAPI(3ts)`, :manpage:`TSMBufferCreate(3ts)`, :manpage:`TSMimeHdrFieldValuesCount(3ts)`


[25/44] git commit: TS-2360 Fix usage of TSMimeHdrFieldValueStringGet() in some plugins.

Posted by zw...@apache.org.
TS-2360 Fix usage of TSMimeHdrFieldValueStringGet() in some plugins.

This also adds Sphinx docs for the TSMimeHdrFieldValueStringGet() and
family of APIs. Finally, it also adds a regression test for the -1
IDX argument.


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

Branch: refs/heads/5.0.x
Commit: 7878e058b154cfe43e52fd0bdd1e327583cf58fc
Parents: 4626716
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Nov 18 16:17:32 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Nov 18 16:18:20 2013 -0700

----------------------------------------------------------------------
 .../api/TSMimeHdrFieldValueStringGet.en.rst     | 108 +++++++++++++++++++
 doc/reference/api/index.en.rst                  |   1 +
 .../working-with-http-headers.en.rst            |   2 +-
 example/append-transform/append-transform.c     |   2 +-
 example/basic-auth/basic-auth.c                 |   2 +-
 example/remap/remap.cc                          |   4 +-
 example/response-header-1/response-header-1.c   |   2 +-
 example/thread-pool/psi.c                       |   2 +-
 plugins/experimental/authproxy/utils.cc         |   4 +-
 plugins/experimental/balancer/hashkey.h         |   2 +-
 .../experimental/buffer_upload/buffer_upload.cc |   2 +-
 .../custom_redirect/custom_redirect.cc          |   2 +-
 plugins/experimental/esi/combo_handler.cc       |   2 +-
 plugins/experimental/lua/lapi.cc                |   2 +-
 .../memcached_remap/memcached_remap.cc          |   4 +-
 plugins/experimental/metalink/metalink.cc       |   2 +-
 plugins/experimental/mysql_remap/mysql_remap.cc |   2 +-
 plugins/experimental/spdy/http.cc               |   2 +-
 plugins/gzip/gzip.cc                            |   2 +-
 plugins/header_filter/rules.cc                  |   2 +-
 plugins/header_rewrite/conditions.cc            |   5 +-
 proxy/InkAPITest.cc                             |  11 +-
 22 files changed, 141 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
new file mode 100644
index 0000000..aacc6af
--- /dev/null
+++ b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
@@ -0,0 +1,108 @@
+.. 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.
+
+.. default-domain:: c
+
+============================
+TSMimeHdrFieldValueStringGet
+============================
+
+
+Synopsis
+========
+
+`#include <ts/ts.h>`
+
+.. function::  const char* TSMimeHdrFieldValueStringGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int idx, int* value_len_ptr)
+.. function::  int TSMimeHdrFieldValueIntGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int idx)
+.. function::  int64_t TSMimeHdrFieldValueInt64Get(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int idx)
+.. function::  unsigned int TSMimeHdrFieldValueUintGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc field, int idx)
+.. function::  time_t TSMimeHdrFieldValueDateGet(TSMBuffer bufp, TSMLoc hdr, TSMLoc field)
+
+
+Description
+===========
+
+MIME headers and fields can be components of request headers, response
+headers, or standalone headers created within your plugin. The various
+functions here are all used to access header values of specific types, but it
+is up to the caller to know if a header has appropriate semantics for the API
+used. For all but :func:`TSMimeHdrFieldValueStringGet`, an appropriate data
+conversion algorithm is applied to the header field string.
+
+All APIs takes an argument with the :type:`TSMBuffer` marshal buffer, and the
+:type:`TSMLoc` for the location to headers. In addition, the required
+:data:`field` argument is the locator of a specific header value, as returned
+by e.g. :func:`TSMimeHdrFieldFind`.
+
+Within the header field, comma separated values can be retrieved with an index
+(:data:`idx`) ranging from 0 to the max number of fields for this value; this
+max is retrieved using :func:`TSMimeHdrFieldValuesCount`. An :data:`idx` value of
+``-1`` has the semantics of retrieving the entire header value, regardless of
+how many comma separated values there are. If a header is not comma separated,
+an :data:`idx` of :data:`0` or :data:`-1` are the same, but the latter is
+definitely preferred and recommended.
+
+For :func:`TSMimeHdrFieldValueStringGet`, an additional parameter can be
+provided, which is populated with the length of the string returned. If this
+argument is NULL, it is not derefenced and no length is returned.
+
+
+Return values
+=============
+
+All functions returns the header value with a type matching the respective
+function name. Using :func:`TSMimeHdrFieldValueDateGet` on a header which
+does not have date-time semantics always returns :data:`0`.
+
+
+
+Examples
+========
+
+::
+
+    #include <string.h>
+    #include <ts/ts.h>
+
+    int
+    get_content_type(TSHttpTxn txnp, char* buf)
+    {
+      TSMBuffer bufp;
+      TSMLoc hdrs;
+      TSMLoc ctype_field;
+      int len = -1;
+
+      if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &bufp, &hdrs)) {
+        ctype_field = TSMimeHdrFieldFind(bufp, hdrs, TS_MIME_FIELD_CONTENT_TYPE, TS_MIME_LEN_CONTENT_TYPE);
+
+        if (TS_NULL_MLOC != ctype_field) {
+          const char* str = TSMimeHdrFieldValueStringGet(bufp, hdrs, ctype_field, -1, &len);
+
+          memcpy(buf, str, len);
+          TSHandleMLocRelease(bufp, hdrs, ctype_field);
+        }
+        TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdrs);
+      }
+
+      return len;
+    }
+
+
+See also
+========
+
+:manpage:`TSAPI(3ts)`, :manpage:`TSMBufferCreate(3ts)`, :manpage:`TSMimeHdrFieldValuesCount`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/doc/reference/api/index.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/index.en.rst b/doc/reference/api/index.en.rst
index 3509312..7414411 100644
--- a/doc/reference/api/index.en.rst
+++ b/doc/reference/api/index.en.rst
@@ -29,6 +29,7 @@ API Reference
   TSIOBufferCreate.en
   TSInstallDirGet.en
   TSMBufferCreate.en
+  TSMimeHdrFieldValueStringGet.en
   TSPluginInit.en
   TSRemap.en
   TSTrafficServerVersionGet.en

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
----------------------------------------------------------------------
diff --git a/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst b/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
index a3b382c..207ea73 100644
--- a/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
+++ b/doc/sdk/header-based-plugin-examples/basic-authorization-plugin/working-with-http-headers.en.rst
@@ -50,7 +50,7 @@ are present and valid:
 ::
 
     :::c
-    val = TSMimeHdrFieldValueStringGet (bufp, hdr_loc, field_loc, 0, &authval_length);
+    val = TSMimeHdrFieldValueStringGet (bufp, hdr_loc, field_loc, -1, &authval_length);
     if (!val) {
         TSError ("no value in Proxy-Authorization field\n");
         TSHandleMLocRelease (bufp, hdr_loc, field_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/append-transform/append-transform.c
----------------------------------------------------------------------
diff --git a/example/append-transform/append-transform.c b/example/append-transform/append-transform.c
index 31d78e6..77ba97f 100644
--- a/example/append-transform/append-transform.c
+++ b/example/append-transform/append-transform.c
@@ -268,7 +268,7 @@ transformable(TSHttpTxn txnp)
       return 0;
     }
 
-    value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &val_length);
+    value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &val_length);
     if (value && (strncasecmp(value, "text/html", sizeof("text/html") - 1) == 0)) {
       ASSERT_SUCCESS(TSHandleMLocRelease(bufp, hdr_loc, field_loc));
       ASSERT_SUCCESS(TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/basic-auth/basic-auth.c
----------------------------------------------------------------------
diff --git a/example/basic-auth/basic-auth.c b/example/basic-auth/basic-auth.c
index 5b3cda0..963b78e 100644
--- a/example/basic-auth/basic-auth.c
+++ b/example/basic-auth/basic-auth.c
@@ -107,7 +107,7 @@ handle_dns(TSHttpTxn txnp, TSCont contp)
     goto done;
   }
 
-  val = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &authval_length);
+  val = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &authval_length);
   if (NULL == val) {
     TSError("no value in Proxy-Authorization field\n");
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/remap/remap.cc
----------------------------------------------------------------------
diff --git a/example/remap/remap.cc b/example/remap/remap.cc
index add7b1f..941bcaa 100644
--- a/example/remap/remap.cc
+++ b/example/remap/remap.cc
@@ -293,12 +293,12 @@ TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
 
   if ((cfield = TSMimeHdrFieldFind(rri->requestBufp, rri->requestHdrp, TS_MIME_FIELD_DATE, -1)) != TS_NULL_MLOC) {
     fprintf(stderr, "We have \"Date\" header in request\n");
-    value = TSMimeHdrFieldValueStringGet(rri->requestBufp, rri->requestHdrp, cfield, 0, NULL);
+    value = TSMimeHdrFieldValueStringGet(rri->requestBufp, rri->requestHdrp, cfield, -1, NULL);
     fprintf(stderr, "Header value: %s\n", value);
   }
   if ((cfield = TSMimeHdrFieldFind(rri->requestBufp, rri->requestHdrp, "MyHeader", sizeof("MyHeader") - 1)) != TS_NULL_MLOC) {
     fprintf(stderr, "We have \"MyHeader\" header in request\n");
-    value = TSMimeHdrFieldValueStringGet(rri->requestBufp, rri->requestHdrp, cfield, 0, NULL);
+    value = TSMimeHdrFieldValueStringGet(rri->requestBufp, rri->requestHdrp, cfield, -1, NULL);
     fprintf(stderr, "Header value: %s\n", value);
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/response-header-1/response-header-1.c
----------------------------------------------------------------------
diff --git a/example/response-header-1/response-header-1.c b/example/response-header-1/response-header-1.c
index 68c1d11..814c2d2 100644
--- a/example/response-header-1/response-header-1.c
+++ b/example/response-header-1/response-header-1.c
@@ -157,7 +157,7 @@ modify_header(TSHttpTxn txnp)
     }
 
     /* Get the cached MIME value for this name in this HTTP header */
-    chkptr = TSMimeHdrFieldValueStringGet(cached_bufp, cached_loc, cached_field_loc, 0, &chklength);
+    chkptr = TSMimeHdrFieldValueStringGet(cached_bufp, cached_loc, cached_field_loc, -1, &chklength);
     if (NULL == chkptr || !chklength) {
       TSError("Could not find value for cached MIME field name %s", mimehdr1_name);
       TSHandleMLocRelease(resp_bufp, TS_NULL_MLOC, resp_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/example/thread-pool/psi.c
----------------------------------------------------------------------
diff --git a/example/thread-pool/psi.c b/example/thread-pool/psi.c
index fb84a4a..24fef91 100644
--- a/example/thread-pool/psi.c
+++ b/example/thread-pool/psi.c
@@ -911,7 +911,7 @@ transformable(TSHttpTxn txnp)
     return 0;
   }
 
-  value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, NULL);
+  value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, NULL);
   if ((value == NULL) || (strncasecmp(value, "text/", sizeof("text/") - 1) != 0)) {
     TSHandleMLocRelease(bufp, hdr_loc, field_loc);
     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/authproxy/utils.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/authproxy/utils.cc b/plugins/experimental/authproxy/utils.cc
index 315477d..d55e1af 100644
--- a/plugins/experimental/authproxy/utils.cc
+++ b/plugins/experimental/authproxy/utils.cc
@@ -163,7 +163,7 @@ HttpIsChunkedEncoding(TSMBuffer mbuf, TSMLoc mhdr)
         const char * str;
         int len;
 
-        str = TSMimeHdrFieldValueStringGet(mbuf, mhdr, mloc, 0 /* index */, &len);
+        str = TSMimeHdrFieldValueStringGet(mbuf, mhdr, mloc, -1 /* index */, &len);
         if (str && len) {
             ischunked = (strncmp("chunked", str, len) == 0);
         }
@@ -184,7 +184,7 @@ HttpGetOriginHost(TSMBuffer mbuf, TSMLoc mhdr, char * name, size_t namelen)
     // depends on whether pristine_host_hdr is set.
     mloc = TSMimeHdrFieldFind(mbuf, mhdr, TS_MIME_FIELD_HOST, -1);
     if (mloc != TS_NULL_MLOC) {
-        host = TSMimeHdrFieldValueStringGet(mbuf, mhdr, mloc, 0 /* index */, &len);
+        host = TSMimeHdrFieldValueStringGet(mbuf, mhdr, mloc, -1 /* index */, &len);
         TSHandleMLocRelease(mbuf, mhdr, mloc);
 
         if (host) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/balancer/hashkey.h
----------------------------------------------------------------------
diff --git a/plugins/experimental/balancer/hashkey.h b/plugins/experimental/balancer/hashkey.h
index 856c84f..f4b516a 100644
--- a/plugins/experimental/balancer/hashkey.h
+++ b/plugins/experimental/balancer/hashkey.h
@@ -223,7 +223,7 @@ class HeaderHashKey : public HashKey
     // Note that hdrLoc is freed as part of the Resources dtor, and we free the "string" value
     // in the free_key() implementation (after we're done with it).
     if (bufp && hdrLoc && (fieldLoc = TSMimeHdrFieldFind(bufp, hdrLoc, _header, _header_len))) {
-      if (TS_ERROR != TSMimeHdrFieldValueStringGet(bufp, hdrLoc, fieldLoc, 0, &val, &len)) {
+      if (TS_ERROR != TSMimeHdrFieldValueStringGet(bufp, hdrLoc, fieldLoc, -1, &val, &len)) {
         *data = val;
       } else {
         *data = NULL;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/buffer_upload/buffer_upload.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/buffer_upload/buffer_upload.cc b/plugins/experimental/buffer_upload/buffer_upload.cc
index 10d400e..ae346bb 100644
--- a/plugins/experimental/buffer_upload/buffer_upload.cc
+++ b/plugins/experimental/buffer_upload/buffer_upload.cc
@@ -749,7 +749,7 @@ attach_pvc_plugin(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
           TSHandleMLocRelease(req_bufp, TS_NULL_MLOC, req_loc);
           break;
         }
-        host_hdr_str_val = TSMimeHdrFieldValueStringGet(req_bufp, req_loc, field_loc, 0, &host_hdr_str_val_len);
+        host_hdr_str_val = TSMimeHdrFieldValueStringGet(req_bufp, req_loc, field_loc, -1, &host_hdr_str_val_len);
         if (NOT_VALID_PTR(host_hdr_str_val) || host_hdr_str_val_len <= 0) {
           //if (VALID_PTR(str))
           //  TSHandleStringRelease(req_bufp, field_loc, str);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/custom_redirect/custom_redirect.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/custom_redirect/custom_redirect.cc b/plugins/experimental/custom_redirect/custom_redirect.cc
index ea02333..5ccf8ef 100644
--- a/plugins/experimental/custom_redirect/custom_redirect.cc
+++ b/plugins/experimental/custom_redirect/custom_redirect.cc
@@ -68,7 +68,7 @@ handle_response (TSHttpTxn txnp, TSCont /* contp ATS_UNUSED */)
                   redirect_url_loc = TSMimeHdrFieldFind (resp_bufp, resp_loc, redirect_url_header, redirect_url_header_len);
 
                     if (redirect_url_loc) {
-                        redirect_url_str = TSMimeHdrFieldValueStringGet (resp_bufp, resp_loc, redirect_url_loc, 0, &redirect_url_length);
+                        redirect_url_str = TSMimeHdrFieldValueStringGet (resp_bufp, resp_loc, redirect_url_loc, -1, &redirect_url_length);
                         if (redirect_url_str) {
                             if (redirect_url_length > 0) {
                               TSRedirectUrlSet(txnp, redirect_url_str, redirect_url_length);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/esi/combo_handler.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/combo_handler.cc b/plugins/experimental/esi/combo_handler.cc
index e14c04c..ca218af 100644
--- a/plugins/experimental/esi/combo_handler.cc
+++ b/plugins/experimental/esi/combo_handler.cc
@@ -349,7 +349,7 @@ getDefaultBucket(TSHttpTxn /* txnp ATS_UNUSED */, TSMBuffer bufp, TSMLoc hdr_obj
     return false;
   }
 
-  host = TSMimeHdrFieldValueStringGet(bufp, hdr_obj, field_loc, 0, &host_len);
+  host = TSMimeHdrFieldValueStringGet(bufp, hdr_obj, field_loc, -1, &host_len);
   if (!host || host_len <= 0) {
     LOG_ERROR("Error Extracting Host Header");
     TSHandleMLocRelease (bufp, hdr_obj, field_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/lua/lapi.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/lapi.cc b/plugins/experimental/lua/lapi.cc
index c284429..efa1b3d 100644
--- a/plugins/experimental/lua/lapi.cc
+++ b/plugins/experimental/lua/lapi.cc
@@ -389,7 +389,7 @@ LuaRemapHeaderIndex(lua_State * lua)
     return 1;
   }
 
-  value = TSMimeHdrFieldValueStringGet(hdrs->buffer, hdrs->headers, field, 0, &vlen);
+  value = TSMimeHdrFieldValueStringGet(hdrs->buffer, hdrs->headers, field, -1, &vlen);
   lua_pushlstring(lua, value, vlen);
   return 1;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/memcached_remap/memcached_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/memcached_remap/memcached_remap.cc b/plugins/experimental/memcached_remap/memcached_remap.cc
index 7e63812..d7495c2 100644
--- a/plugins/experimental/memcached_remap/memcached_remap.cc
+++ b/plugins/experimental/memcached_remap/memcached_remap.cc
@@ -70,9 +70,7 @@ bool do_memcached_remap(TSCont contp, TSHttpTxn txnp)
         goto release_url;
     }
 
-    request_host =
-        TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc, 0,
-                                     &request_host_length);
+    request_host = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc, -1, &request_host_length);
     if (request_host == NULL || strlen(request_host) < 1) {
         TSDebug(PLUGIN_NAME, "couldn't find request HOST header");
         goto release_field;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/metalink/metalink.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/metalink/metalink.cc b/plugins/experimental/metalink/metalink.cc
index 86747ef..18ad584 100644
--- a/plugins/experimental/metalink/metalink.cc
+++ b/plugins/experimental/metalink/metalink.cc
@@ -565,7 +565,7 @@ http_send_response_hdr(TSCont contp, void *edata)
   /* If can't parse or lookup "Location: ..." URL, should still check if
    * response has "Digest: SHA-256=..." header? No: Can't parse or lookup URL
    * in "Location: ..." header is error */
-  value = TSMimeHdrFieldValueStringGet(data->resp_bufp, data->hdr_loc, data->location_loc, 0, &length);
+  value = TSMimeHdrFieldValueStringGet(data->resp_bufp, data->hdr_loc, data->location_loc, -1, &length);
   if (TSUrlParse(data->resp_bufp, data->url_loc, &value, value + length) != TS_PARSE_DONE) {
 
     TSHandleMLocRelease(data->resp_bufp, TS_NULL_MLOC, data->url_loc);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/mysql_remap/mysql_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/mysql_remap/mysql_remap.cc b/plugins/experimental/mysql_remap/mysql_remap.cc
index 848537d..c93274e 100644
--- a/plugins/experimental/mysql_remap/mysql_remap.cc
+++ b/plugins/experimental/mysql_remap/mysql_remap.cc
@@ -68,7 +68,7 @@ bool do_mysql_remap(TSCont contp,TSHttpTxn txnp) {
       goto release_url;
   }
   
-  request_host = TSMimeHdrFieldValueStringGet (reqp, hdr_loc, field_loc, 0, &request_host_length);
+  request_host = TSMimeHdrFieldValueStringGet (reqp, hdr_loc, field_loc, -1, &request_host_length);
   if (!request_host_length) {
     TSDebug(PLUGIN_NAME,"couldn't find request HOST header");
     goto release_field;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/experimental/spdy/http.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/spdy/http.cc b/plugins/experimental/spdy/http.cc
index db17249..64d46de 100644
--- a/plugins/experimental/spdy/http.cc
+++ b/plugins/experimental/spdy/http.cc
@@ -90,7 +90,7 @@ http_send_response(
         }
 
         value.first = TSMimeHdrFieldValueStringGet(buffer, header,
-                field, 0, &value.second);
+                field, -1, &value.second);
         kvblock.insert(std::string(name.first, name.second),
                 std::string(value.first, value.second));
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/gzip/gzip.cc
----------------------------------------------------------------------
diff --git a/plugins/gzip/gzip.cc b/plugins/gzip/gzip.cc
index 9c84dc8..ac654f7 100644
--- a/plugins/gzip/gzip.cc
+++ b/plugins/gzip/gzip.cc
@@ -555,7 +555,7 @@ gzip_transformable(TSHttpTxn txnp, int server, HostConfiguration * host_configur
     return 0;
   }
 
-  value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &len);
+  value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &len);
 
   int rv = host_configuration->ContentTypeIsCompressible(value, len);
   if (!rv) { 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/header_filter/rules.cc
----------------------------------------------------------------------
diff --git a/plugins/header_filter/rules.cc b/plugins/header_filter/rules.cc
index 62c21cb..feebc04 100644
--- a/plugins/header_filter/rules.cc
+++ b/plugins/header_filter/rules.cc
@@ -77,7 +77,7 @@ RulesEntry::execute(TSMBuffer& reqp, TSMLoc& hdr_loc) const
         bool nuke = false;
       
         if (_q_type != QUAL_NONE)
-          val = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field, 0, &val_len);
+          val = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field, -1, &val_len);
 
         switch (_q_type) {
         case QUAL_NONE:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index f57e6e9..4ff38b6 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -192,7 +192,7 @@ ConditionHeader::append_value(std::string& s, const Resources& res)
     field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, _qualifier.c_str(), _qualifier.size());
     TSDebug(PLUGIN_NAME, "Getting Header: %s, field_loc: %p", _qualifier.c_str(), field_loc);
     if (field_loc != NULL) {
-      value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &len);
+      value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &len);
       TSDebug(PLUGIN_NAME, "Appending HEADER(%s) to evaluation value -> %.*s", _qualifier.c_str(), len, value);
       s.append(value, len);
       TSHandleMLocRelease(bufp, hdr_loc, field_loc);
@@ -423,8 +423,7 @@ void ConditionCookie::append_value(std::string& s, const Resources& res)
     return;
 
   // Get all cookies
-  // NB! Cookie field does not support commas, so we use index == 0
-  cookies = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, 0, &cookies_len);
+  cookies = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, -1, &cookies_len);
   if (cookies == NULL || cookies_len <= 0)
     goto out_release_field;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7878e058/proxy/InkAPITest.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 9bbf6a5..3e0ce3a 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -3688,6 +3688,7 @@ REGRESSION_TEST(SDK_API_TSMimeHdrField) (RegressionTest * test, int /* atype ATS
   const char *field1Value3Get;
   const char *field1Value4Get;
   const char *field1Value5Get;
+  const char *field1ValueAllGet;
   const char *field1ValueNewGet;
 
   int lengthField1Value1;
@@ -3695,6 +3696,7 @@ REGRESSION_TEST(SDK_API_TSMimeHdrField) (RegressionTest * test, int /* atype ATS
   int lengthField1Value3;
   int lengthField1Value4;
   int lengthField1Value5;
+  int lengthField1ValueAll;
   int lengthField1ValueNew;
 
   time_t field2Value1 = time(NULL);
@@ -3996,13 +3998,20 @@ REGRESSION_TEST(SDK_API_TSMimeHdrField) (RegressionTest * test, int /* atype ATS
       field1Value3Get = TSMimeHdrFieldValueStringGet(bufp1, mime_loc1, field_loc11, 2, &lengthField1Value3);
       field1Value4Get = TSMimeHdrFieldValueStringGet(bufp1, mime_loc1, field_loc11, 3, &lengthField1Value4);
       field1Value5Get = TSMimeHdrFieldValueStringGet(bufp1, mime_loc1, field_loc11, 4, &lengthField1Value5);
+      field1ValueAllGet = TSMimeHdrFieldValueStringGet(bufp1, mime_loc1, field_loc11, -1, &lengthField1ValueAll);
       if (((strncmp(field1Value1Get, field1Value1, lengthField1Value1) == 0) && lengthField1Value1 == (int) strlen(field1Value1)) &&
           ((strncmp(field1Value2Get, field1Value2, lengthField1Value2) == 0) && lengthField1Value2 == (int) strlen(field1Value2)) &&
           ((strncmp(field1Value3Get, field1Value3, lengthField1Value3) == 0) && lengthField1Value3 == (int) strlen(field1Value3)) &&
           ((strncmp(field1Value4Get, field1Value4, lengthField1Value4) == 0) && lengthField1Value4 == (int) strlen(field1Value4)) &&
-          ((strncmp(field1Value5Get, field1Value5, lengthField1Value5) == 0) && lengthField1Value5 == (int) strlen(field1Value5))) {
+          ((strncmp(field1Value5Get, field1Value5, lengthField1Value5) == 0) && lengthField1Value5 == (int) strlen(field1Value5)) &&
+          (strstr(field1ValueAllGet, field1Value1Get) == field1Value1Get) &&
+          (strstr(field1ValueAllGet, field1Value2Get) == field1Value2Get) &&
+          (strstr(field1ValueAllGet, field1Value3Get) == field1Value3Get) &&
+          (strstr(field1ValueAllGet, field1Value4Get) == field1Value4Get) &&
+          (strstr(field1ValueAllGet, field1Value5Get) == field1Value5Get)) {
         SDK_RPRINT(test, "TSMimeHdrFieldValueStringInsert", "TestCase1&2&3&4&5", TC_PASS, "ok");
         SDK_RPRINT(test, "TSMimeHdrFieldValueStringGet", "TestCase1&2&3&4&5", TC_PASS, "ok");
+        SDK_RPRINT(test, "TSMimeHdrFieldValueStringGet with IDX=-1", "TestCase1&2&3&4&5", TC_PASS, "ok");
         test_passed_Mime_Hdr_Field_Value_String_Insert = true;
         test_passed_Mime_Hdr_Field_Value_String_Get = true;
 


[28/44] git commit: TS-2364: Introduce slice notation to field syntax in log format

Posted by zw...@apache.org.
TS-2364: Introduce slice notation to field syntax in log format

Now, we have two kind of field syntax in log format:
(1) simple syntax: '%<field>', for example: %<cqu>
(2) container field, syntax: '%<{field}container>',
    for example: %<{Referer}cqh>.

This patch introduces slice notation to field syntax, so that we can easy to
limit the length of filed's output. With slice notation, the filed syntax will
looks like:
(1) '%<field[start:end]>'
(2) '%<{field}container[start:end]>'

In both forms, slice notation can be omitted, which means the whole field.

But with one limitation: slice notation makes sense only when the field is
string type and it shouldn't be ip/timestamp which are converted to
string from integer.

We can see the syntax of slice notation from Python, Golang, it's pretty
simple:
  [start:end] //items start through end-1
  [start:]    //items start through the rest of the array
  [:end]      //items from the beginning through end-1
  [:]         //the whole array(by default)

For example,
  '%<cqup>'       //the whole characters of <cqup>.
  '%<cqup>[:]'    //the whole characters of <cqup>.
  '%<cqup[0:30]>' //the first 30 characters of <cqup>.
  '%<cqup[-10:]>' //the last 10 characters of <cqup>.
  '%<cqup[:-5]>'  //everything except the last 5 characters of <cqup>.

Signed-off-by: Yunkai Zhang <qi...@taobao.com>


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

Branch: refs/heads/5.0.x
Commit: 6dc186740eea69c180fdda732608d8b0fedfcbf3
Parents: b187978
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Tue Nov 19 18:12:20 2013 +0800
Committer: Yunkai Zhang <qi...@taobao.com>
Committed: Wed Nov 20 11:29:39 2013 +0800

----------------------------------------------------------------------
 CHANGES                              |  2 +
 proxy/config/logs_xml.config.default | 24 +++++++---
 proxy/logging/Log.cc                 | 30 ++++++------
 proxy/logging/LogAccess.cc           | 21 ++++++--
 proxy/logging/LogAccess.h            |  4 +-
 proxy/logging/LogField.cc            | 79 ++++++++++++++++++++++++++++++-
 proxy/logging/LogField.h             | 31 ++++++++++++
 proxy/logging/LogFormat.cc           | 15 +++++-
 8 files changed, 178 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6dc18674/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index ece5bc6..0e634d6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2364] Introduce slice notation to field syntax in log format.
+
   *) [TS-2360] Fix usage of TSMimeHdrFieldValueStringGet() IDX in some plugins.
 
   *) [TS-2361] Load regex_remap configuration relative to the configuration directory.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6dc18674/proxy/config/logs_xml.config.default
----------------------------------------------------------------------
diff --git a/proxy/config/logs_xml.config.default b/proxy/config/logs_xml.config.default
index 7633808..00bae06 100644
--- a/proxy/config/logs_xml.config.default
+++ b/proxy/config/logs_xml.config.default
@@ -23,12 +23,24 @@ specifications (a '*' denotes a tag that is required):
        A valid format specification is a printf-style string that describes
        what each log entry looks like when formatted for ascii output.
        Placeholders for valid Inktomi field names are specified using the
-       notation '%<field>'.  The specified field can be of two types: 
-           (1) simple; example %<cqu> 
-	   (2) container field, which is a field within a container (such
-	   as an http header or an Inktomi stat).  Fields of this type have
-	   the syntax: '%<{field}container>'.  See documentation for valid
-	   container names.
+       notation '%<field>'.  The specified field can be of two types:
+           (1) simple field: '%<field>', for example %<cqu>.
+           (2) container field: '%<field>container', which is a field within
+               a container (such as an http header or an Inktomi stat).  See
+               documentation for valid container names.
+       To limit the length of field's output, we can use slice notation with
+       above two types:
+           (1) simple field with slice: '%<field[start:end]>',
+           (2) container field with slice: '%<field>container[start:end]'.
+           Here is same example about slice notation:
+            '%<cqup>[:]'    # the whole characters of <cqup>.
+            '%<cqup[0:30]>' # the first 30 characters of <cqup>.
+            '%<cqup[-10:]>' # the last 10 characters of <cqup>.
+            '%<cqup[:-5]>'  # everything except the last 5 characters of <cqup>.
+          Note: slice notation makes sense only when:
+            * the target field is a string type, and
+            * it shouldn't be ip/timestamp which are converted
+              to string from integer internally.
        If you want to include quotes within the format string, escape them
        with a backslash. For example, to quote the client request url (cqu),
        you would type something like

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6dc18674/proxy/logging/Log.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index f1962ad..546f83f 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -356,7 +356,7 @@ Log::init_fields()
   field = NEW (new LogField ("client_auth_user_name", "caun",
                              LogField::STRING,
                              &LogAccess::marshal_client_auth_user_name,
-                             &LogAccess::unmarshal_str));
+                             (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add (field, false);
   ink_hash_table_insert (field_symbol_hash, "caun", field);
 
@@ -405,63 +405,63 @@ Log::init_fields()
   field = NEW(new LogField("client_req_text", "cqtx",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_text,
-                           &LogAccess::unmarshal_http_text));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_http_text));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cqtx", field);
 
   field = NEW(new LogField("client_req_http_method", "cqhm",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_http_method,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cqhm", field);
 
   field = NEW(new LogField("client_req_url", "cqu",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_url,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cqu", field);
 
   field = NEW(new LogField("client_req_url_canonical", "cquc",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_url_canon,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cquc", field);
 
   field = NEW(new LogField("client_req_unmapped_url_canonical", "cquuc",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_unmapped_url_canon,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cquuc", field);
 
   field = NEW(new LogField("client_req_unmapped_url_path", "cquup",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_unmapped_url_path,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cquup", field);
 
   field = NEW(new LogField("client_req_unmapped_url_host", "cquuh",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_unmapped_url_host,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cquuh", field);
 
   field = NEW(new LogField("client_req_url_scheme", "cqus",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_url_scheme,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cqus", field);
 
   field = NEW(new LogField("client_req_url_path", "cqup",
                            LogField::STRING,
                            &LogAccess::marshal_client_req_url_path,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cqup", field);
 
@@ -504,7 +504,7 @@ Log::init_fields()
   field = NEW(new LogField("proxy_resp_content_type", "psct",
                            LogField::STRING,
                            &LogAccess::marshal_proxy_resp_content_type,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "psct", field);
 
@@ -629,7 +629,7 @@ Log::init_fields()
   field = NEW(new LogField("proxy_req_server_name", "pqsn",
                            LogField::STRING,
                            &LogAccess::marshal_proxy_req_server_name,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "pqsn", field);
 
@@ -690,7 +690,7 @@ Log::init_fields()
   field = NEW(new LogField("proxy_host_name", "phn",
                            LogField::STRING,
                            &LogAccess::marshal_proxy_host_name,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "phn", field);
 
@@ -705,7 +705,7 @@ Log::init_fields()
   field = NEW(new LogField("accelerator_id", "xid",
                            LogField::STRING,
                            &LogAccess::marshal_client_accelerator_id,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "xid", field);
   // X-WAID
@@ -723,7 +723,7 @@ Log::init_fields()
   field = NEW(new LogField("server_host_name", "shn",
                            LogField::STRING,
                            &LogAccess::marshal_server_host_name,
-                           &LogAccess::unmarshal_str));
+                           (LogField::UnmarshalFunc)&LogAccess::unmarshal_str));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "shn", field);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6dc18674/proxy/logging/LogAccess.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index c6f6eda..4254569 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -998,7 +998,7 @@ LogAccess::unmarshal_int_to_str_hex(char **buf, char *dest, int len)
   -------------------------------------------------------------------------*/
 
 int
-LogAccess::unmarshal_str(char **buf, char *dest, int len)
+LogAccess::unmarshal_str(char **buf, char *dest, int len, LogSlice *slice)
 {
   ink_assert(buf != NULL);
   ink_assert(*buf != NULL);
@@ -1008,6 +1008,21 @@ LogAccess::unmarshal_str(char **buf, char *dest, int len)
   int val_len = (int)::strlen(val_buf);
 
   *buf += LogAccess::strlen(val_buf);   // this is how it was stored
+
+  if (slice && slice->m_enable) {
+    int offset, n;
+
+    n = slice->toStrOffset(val_len, &offset);
+    if (n <= 0)
+      return 0;
+
+    if (n >= len)
+      return -1;
+
+    memcpy(dest, (val_buf + offset), n);
+    return n;
+  }
+
   if (val_len < len) {
     memcpy(dest, val_buf, val_len);
     return val_len;
@@ -1093,7 +1108,7 @@ LogAccess::unmarshal_http_version(char **buf, char *dest, int len)
   -------------------------------------------------------------------------*/
 
 int
-LogAccess::unmarshal_http_text(char **buf, char *dest, int len)
+LogAccess::unmarshal_http_text(char **buf, char *dest, int len, LogSlice *slice)
 {
   ink_assert(buf != NULL);
   ink_assert(*buf != NULL);
@@ -1108,7 +1123,7 @@ LogAccess::unmarshal_http_text(char **buf, char *dest, int len)
   }
   p += res1;
   *p++ = ' ';
-  int res2 = unmarshal_str(buf, p, len - res1 - 1);
+  int res2 = unmarshal_str(buf, p, len - res1 - 1, slice);
   if (res2 < 0) {
     return -1;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6dc18674/proxy/logging/LogAccess.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index e0a27b3..eb10824 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -277,10 +277,10 @@ public:
   static int unmarshal_itox(int64_t val, char *dest, int field_width = 0, char leading_char = ' ');
   static int unmarshal_int_to_str(char **buf, char *dest, int len);
   static int unmarshal_int_to_str_hex(char **buf, char *dest, int len);
-  static int unmarshal_str(char **buf, char *dest, int len);
+  static int unmarshal_str(char **buf, char *dest, int len, LogSlice *slice = NULL);
   static int unmarshal_ttmsf(char **buf, char *dest, int len);
   static int unmarshal_http_version(char **buf, char *dest, int len);
-  static int unmarshal_http_text(char **buf, char *dest, int len);
+  static int unmarshal_http_text(char **buf, char *dest, int len, LogSlice *slice = NULL);
   static int unmarshal_http_status(char **buf, char *dest, int len);
   static int unmarshal_ip(char** buf, IpEndpoint* dest);
   static int unmarshal_ip_to_str(char **buf, char *dest, int len);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6dc18674/proxy/logging/LogField.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogField.cc b/proxy/logging/LogField.cc
index 3f0ddee..6bab383 100644
--- a/proxy/logging/LogField.cc
+++ b/proxy/logging/LogField.cc
@@ -65,6 +65,78 @@ const char *aggregate_names[] = {
   ""
 };
 
+LogSlice::LogSlice(char *str)
+{
+  char *a, *b, *c;
+
+  m_enable = false;
+  m_start = 0;
+  m_end = INT_MAX;
+
+  if ((a = strchr(str, '[')) == NULL)
+    return;
+
+  *a++ = '\0';
+  if ((b = strchr(a, ':')) == NULL)
+    return;
+
+  *b++ = '\0';
+  if ((c = strchr(b, ']')) == NULL)
+    return;
+
+  m_enable = true;
+
+  // eat space
+  while (a != b && *a == ' ') a++;
+
+  if (a != b)
+    m_start = atoi(a);
+
+  // eat space
+  while (b != c && *b == ' ') b++;
+
+  if (b != c)
+    m_end = atoi(b);
+}
+
+int
+LogSlice::toStrOffset(int strlen, int *offset)
+{
+  int i, j, len;
+
+  // letf index
+  if (m_start >= 0)
+    i = m_start;
+  else
+    i = m_start + strlen;
+
+  if (i >= strlen)
+    return 0;
+
+  if (i < 0)
+    i = 0;
+
+  // right index
+  if (m_end >= 0)
+    j = m_end;
+  else
+    j = m_end + strlen;
+
+  if (j <= 0)
+    return 0;
+
+  if (j > strlen)
+    j = strlen;
+
+  // available length
+  len = j - i;
+
+  if (len > 0)
+    *offset = i;
+
+  return len;
+}
+
 /*-------------------------------------------------------------------------
   LogField::LogField
   -------------------------------------------------------------------------*/
@@ -131,7 +203,7 @@ LogField::LogField(const char *field, Container container)
   case ESSH:
   case ECSSH:
   case SCFG:
-    m_unmarshal_func = &(LogAccess::unmarshal_str);
+    m_unmarshal_func = (UnmarshalFunc)&(LogAccess::unmarshal_str);
     break;
 
   case ICFG:
@@ -300,6 +372,11 @@ unsigned
 LogField::unmarshal(char **buf, char *dest, int len)
 {
   if (m_alias_map == NULL) {
+    if (m_unmarshal_func == (UnmarshalFunc)LogAccess::unmarshal_str
+        || m_unmarshal_func == (UnmarshalFunc)LogAccess::unmarshal_http_text) {
+      UnmarshalFuncWithSlice func = (UnmarshalFuncWithSlice)m_unmarshal_func;
+      return (*func) (buf, dest, len, &m_slice);
+    }
     return (*m_unmarshal_func) (buf, dest, len);
   } else {
     return (*m_unmarshal_func_map) (buf, dest, len, m_alias_map);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6dc18674/proxy/logging/LogField.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogField.h b/proxy/logging/LogField.h
index 6aa35d1..1847daa 100644
--- a/proxy/logging/LogField.h
+++ b/proxy/logging/LogField.h
@@ -31,6 +31,35 @@
 
 class LogAccess;
 
+struct LogSlice
+{
+  bool m_enable;
+  int m_start;
+  int m_end;
+
+  LogSlice() {
+    m_enable = false;
+    m_start = 0;
+    m_end = INT_MAX;
+  }
+
+  //
+  // Initialize LogSlice by slice notation,
+  // the str looks like: "xxx[0:30]".
+  //
+  LogSlice(char *str);
+
+  //
+  // Convert slice notation to target string's offset,
+  // return the available length belongs to this slice.
+  //
+  // Use the offset and return value, we can locate the
+  // string content indicated by this slice.
+  //
+  int toStrOffset(int strlen, int *offset);
+};
+
+
 /*-------------------------------------------------------------------------
   LogField
 
@@ -47,6 +76,7 @@ class LogField
 public:
   typedef int (LogAccess::*MarshalFunc) (char *buf);
   typedef int (*UnmarshalFunc) (char **buf, char *dest, int len);
+  typedef int (*UnmarshalFuncWithSlice) (char **buf, char *dest, int len, LogSlice *slice);
   typedef int (*UnmarshalFuncWithMap) (char **buf, char *dest, int len, Ptr<LogFieldAliasMap> map);
 
 
@@ -152,6 +182,7 @@ private:
 
 public:
   LINK(LogField, link);
+  LogSlice m_slice;
 
 private:
 // luis, check where this is used and what it does

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6dc18674/proxy/logging/LogFormat.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogFormat.cc b/proxy/logging/LogFormat.cc
index 753779f..80e46f4 100644
--- a/proxy/logging/LogFormat.cc
+++ b/proxy/logging/LogFormat.cc
@@ -502,6 +502,7 @@ LogFormat::parse_symbol_string(const char *symbol_string, LogFieldList *field_li
         name = symbol + 1;
         *name_end = 0;          // changes '}' to '\0'
         sym = name_end + 1;     // start of container symbol
+        LogSlice slice(sym);
         Debug("log-format", "Name = %s, symbol = %s", name, sym);
         container = LogField::valid_container_name(sym);
         if (container == LogField::NO_CONTAINER) {
@@ -509,6 +510,11 @@ LogFormat::parse_symbol_string(const char *symbol_string, LogFieldList *field_li
         } else {
           f = NEW(new LogField(name, container));
           ink_assert(f != NULL);
+          if (slice.m_enable) {
+            f->m_slice = slice;
+            Debug("log-slice", "symbol = %s, [%d:%d]", sym,
+                  f->m_slice.m_start, f->m_slice.m_end);
+          }
           field_list->add(f, false);
           field_count++;
           Debug("log-format", "Container field {%s}%s added", name, sym);
@@ -521,10 +527,17 @@ LogFormat::parse_symbol_string(const char *symbol_string, LogFieldList *field_li
     // treat this like a regular field symbol
     //
     else {
+      LogSlice slice(symbol);
       Debug("log-format", "Regular field symbol: %s", symbol);
       f = Log::global_field_list.find_by_symbol(symbol);
       if (f != NULL) {
-        field_list->add(f);
+        LogField *cpy = NEW(new LogField(*f));
+        if (slice.m_enable) {
+          cpy->m_slice = slice;
+          Debug("log-slice", "symbol = %s, [%d:%d]", symbol,
+                cpy->m_slice.m_start, cpy->m_slice.m_end);
+        }
+        field_list->add(cpy, false);
         field_count++;
         Debug("log-format", "Regular field %s added", symbol);
       } else {


[24/44] git commit: TS-2361: improve regex_remap plugin loading semantics

Posted by zw...@apache.org.
TS-2361: improve regex_remap plugin loading semantics

The location of the regex_remap configuration is not well-defined
if it is a relative path. Either it will be found in the current
directory (which is undefined), or a hard-coded global directory
will be used.

This change always uses the absolute path if an absolute path is
provided. If a relative path is provided, then we load that relative
to the configured Traffic Server configuration directory.


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

Branch: refs/heads/5.0.x
Commit: 4626716fd390efdab12bae35a25abf41cf88c937
Parents: 6bfba8b
Author: James Peach <jp...@apache.org>
Authored: Fri Nov 15 22:05:31 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Mon Nov 18 14:41:21 2013 -0800

----------------------------------------------------------------------
 CHANGES                            |   2 +
 plugins/regex_remap/regex_remap.cc | 160 +++++++++++++++++---------------
 2 files changed, 89 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4626716f/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8d47730..5bb14b4 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 Changes with Apache Traffic Server 4.2.0
 
 
+  *) [TS-2361] Load regex_remap configuration relative to the configuration directory.
+
   *) [TS-2359] Make install over existing installation can fail.
 
   *) [TS-2350] Enhancements to traffic_top

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4626716f/plugins/regex_remap/regex_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 496fd30..a85475e 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -54,9 +54,6 @@ static const char* PLUGIN_NAME = "regex_remap";
 static const int OVECCOUNT = 30; // We support $0 - $9 x2 ints, and this needs to be 1.5x that
 static const int MAX_SUBS = 32;   // No more than 32 substitution variables in the subst string
 
-// TODO: This should be "autoconf'ed" or something ...
-#define DEFAULT_PATH "/usr/local/etc/regex_remap/"
-
 // Substitutions other than regex matches
 enum ExtraSubstitutions {
   SUB_HOST = 11,
@@ -600,8 +597,13 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
     return TS_ERROR;
   }
 
+  if (argc < 3) {
+    TSError("%s missing configuration file", PLUGIN_NAME);
+    return TS_ERROR;
+  }
+
   // Really simple (e.g. basic) config parser
-  for (int i=2; i < argc; ++i) {
+  for (int i = 3; i < argc; ++i) {
     if (strncmp(argv[i], "profile", 7) == 0) {
       ri->profile = true;
     } else if (strncmp(argv[i], "no-profile", 10) == 0) {
@@ -619,92 +621,104 @@ TSRemapNewInstance(int argc, char* argv[], void** ih, char* /* errbuf ATS_UNUSED
     } else if (strncmp(argv[i], "no-matrix-parameters", 18) == 0) {
       ri->matrix_params = false;
     } else {
-      if (0 != access(argv[2], R_OK)) {
-        ri->filename = DEFAULT_PATH;
-        ri->filename += argv[2];
-      } else {
-        ri->filename = argv[2];
-      }
+      TSError("%s: invalid option '%s'", PLUGIN_NAME, argv[i]);
+    }
+  }
 
-      f.open((ri->filename).c_str(), std::ios::in);
-      if (!f.is_open()) { // Try with the default path instead
-        TSError("unable to open %s", (ri->filename).c_str());
-        return TS_ERROR;
-      }
-      TSDebug(PLUGIN_NAME, "loading regular expression maps from %s", (ri->filename).c_str());
+  if (*argv[2] == '/') {
+    // Absolute path, just use it.
+    ri->filename = argv[2];
+  } else {
+    // Relative path. Make it relative to the configuration directory.
+    ri->filename = TSConfigDirGet();
+    ri->filename += "/";
+    ri->filename += argv[2];
+  }
 
-      while (!f.eof()) {
-        std::string line, regex, subst, options;
-        std::string::size_type pos1, pos2;
+  if (0 != access(ri->filename.c_str(), R_OK)) {
+    TSError("%s: failed to access %s: %s", PLUGIN_NAME, ri->filename.c_str(), strerror(errno));
+    return TS_ERROR;
+  }
+
+  f.open((ri->filename).c_str(), std::ios::in);
+  if (!f.is_open()) {
+    TSError("%s: unable to open %s", PLUGIN_NAME, (ri->filename).c_str());
+    return TS_ERROR;
+  }
+  TSDebug(PLUGIN_NAME, "loading regular expression maps from %s", (ri->filename).c_str());
 
-        getline(f, line);
-        ++lineno;
-        if (line.empty())
-          continue;
-        pos1 = line.find_first_not_of(" \t\n");
-        if (line[pos1] == '#')
-          continue;  // Skip comment lines
+  while (!f.eof()) {
+    std::string line, regex, subst, options;
+    std::string::size_type pos1, pos2;
 
+    getline(f, line);
+    ++lineno;
+    if (line.empty())
+      continue;
+    pos1 = line.find_first_not_of(" \t\n");
+    if (line[pos1] == '#')
+      continue;  // Skip comment lines
+
+    if (pos1 != std::string::npos) {
+      pos2 = line.find_first_of(" \t\n", pos1);
+      if (pos2 != std::string::npos) {
+        regex = line.substr(pos1, pos2-pos1);
+        pos1 = line.find_first_not_of(" \t\n#", pos2);
         if (pos1 != std::string::npos) {
           pos2 = line.find_first_of(" \t\n", pos1);
-          if (pos2 != std::string::npos) {
-            regex = line.substr(pos1, pos2-pos1);
-            pos1 = line.find_first_not_of(" \t\n#", pos2);
-            if (pos1 != std::string::npos) {
-              pos2 = line.find_first_of(" \t\n", pos1);
-              if (pos2 == std::string::npos)
-                pos2 = line.length();
-              subst = line.substr(pos1, pos2-pos1);
-              pos1 = line.find_first_not_of(" \t\n#", pos2);
-              if (pos1 != std::string::npos) {
-                pos2 = line.find_first_of("\n#", pos1);
-                if (pos2 == std::string::npos)
-                  pos2 = line.length();
-                options = line.substr(pos1, pos2-pos1);
-              }
-            }
+          if (pos2 == std::string::npos)
+            pos2 = line.length();
+          subst = line.substr(pos1, pos2-pos1);
+          pos1 = line.find_first_not_of(" \t\n#", pos2);
+          if (pos1 != std::string::npos) {
+            pos2 = line.find_first_of("\n#", pos1);
+            if (pos2 == std::string::npos)
+              pos2 = line.length();
+            options = line.substr(pos1, pos2-pos1);
           }
         }
+      }
+    }
 
-        if (regex.empty()) {
-          // No regex found on this line
-          TSError("no regexp found in %s: line %d", (ri->filename).c_str(), lineno);
-          continue;
-        }
-        if (subst.empty() && options.empty()) {
-          // No substitution found on this line (and no options)
-          TSError("no substitution string found in %s: line %d", (ri->filename).c_str(), lineno);
-          continue;
-        }
+    if (regex.empty()) {
+      // No regex found on this line
+      TSError("no regexp found in %s: line %d", (ri->filename).c_str(), lineno);
+      continue;
+    }
+    if (subst.empty() && options.empty()) {
+      // No substitution found on this line (and no options)
+      TSError("no substitution string found in %s: line %d", (ri->filename).c_str(), lineno);
+      continue;
+    }
 
-        // Got a regex and substitution string
-        RemapRegex* cur = new RemapRegex(regex, subst, options);
+    // Got a regex and substitution string
+    RemapRegex* cur = new RemapRegex(regex, subst, options);
 
-        if (cur == NULL) {
-          TSError("can't create a new regex remap rule");
-          continue;
-        }
+    if (cur == NULL) {
+      TSError("%s: can't create a new regex remap rule", PLUGIN_NAME);
+      continue;
+    }
 
-        if (cur->compile(&error, &erroffset) < 0) {
-          TSError("PCRE failed in %s (line %d) at offset %d: %s", (ri->filename).c_str(), lineno, erroffset, error);
-          delete(cur);
-        } else {
-          TSDebug(PLUGIN_NAME, "added regex=%s with substitution=%s and options `%s'",
-                   regex.c_str(), subst.c_str(), options.c_str());
-          cur->set_order(++count);
-          if (ri->first == NULL)
-            ri->first = cur;
-          else
-            ri->last->set_next(cur);
-          ri->last = cur;
-        }
-      }
+    if (cur->compile(&error, &erroffset) < 0) {
+      TSError("%s: PCRE failed in %s (line %d) at offset %d: %s",
+          PLUGIN_NAME, (ri->filename).c_str(), lineno, erroffset, error);
+      delete(cur);
+    } else {
+      TSDebug(PLUGIN_NAME, "added regex=%s with substitution=%s and options `%s'",
+               regex.c_str(), subst.c_str(), options.c_str());
+      cur->set_order(++count);
+      if (ri->first == NULL)
+        ri->first = cur;
+      else
+        ri->last->set_next(cur);
+      ri->last = cur;
     }
+
   }
 
   // Make sure we got something...
   if (ri->first == NULL) {
-    TSError("Got no regular expressions from the maps");
+    TSError("%s: no regular expressions from the maps", PLUGIN_NAME);
     return TS_ERROR;
   }
 


[14/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/cli_feature_spec.txt
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/cli_feature_spec.txt b/cmd/traffic_shell/cli_feature_spec.txt
new file mode 100644
index 0000000..f6e7c9d
--- /dev/null
+++ b/cmd/traffic_shell/cli_feature_spec.txt
@@ -0,0 +1,230 @@
+traffic_shell  "a CLI for Traffic Server"
+
+==========
+Motivation
+==========
+
+The purpose of traffic_shell (command line interface, or CLI) is to
+improve the usability of Traffic Server in both OEM and direct sales
+environments. The CLI is a powerful, easy to use tool which can be
+used to configure and monitor individual Traffic Server machines.  Our
+goal is to make configuring Traffic Server as easy as configuring
+other network devices such as routers and switches. 
+
+The CLI accepts commands in a unix shell-like fashion.  Commands are
+organized in an easy to navigate hierarchy.  The CLI supports basic
+command completion, command history, and context sensitive help.  This
+format was designed to be familiar to network engineers everywhere,
+and also to be easier to document, maintain, and add features. 
+
+============
+Architecture
+============
+
+The CLI is a standalone executable which is part of a Traffic Server
+installation on the Linux platform. The CLI supports the following
+operation modes. Note that a "user" can be a person, a script, or some
+other mechanism for remote control of network devices via command line
+interface. 
+
+- Interactive mode:
+"traffic_shell"
+Similar to unix shell, the CLI can be the login shell for
+administrators.  The user types command at a prompt, and the CLI
+processes the command and displays the result.  While in interactive
+mode, the user can execute a file which contains a list of commands. 
+
+-- Execute file mode:
+"traffic_shell -f filename" where file contains a list of CLI commands.
+CLI runs commands and sends results to stdout.
+
+The CLI interface is implemented in a combination of TCL and C++.
+From the traffic_shell prompt, users can access the scripting
+capabilities of TCL.   
+
+The shell and parsing functionality will utilize TCL. Commands
+themselves will be written in C++. The CLI uses the traffic_manager
+Management API to make Traffic Server configuration changes.
+
+The overall CLI architecture is as follows:
+
+- traffic_shell ---------------------------
+|                                         |
+| --------------------------------------- |
+| Shell and parser implemented in TCL/C++ |
+| --------------------------------------- |
+|                 ^                       |
+| ----------------|-------------------    |
+| CLI commands implemented in C++         |
+| ------------------------------------    |
+|         ^                               |
+| --------|----------                     |
+| Management API (.a)                     |
+| -------------------                     |
+|                                         |
+-------------------------------------------
+
+=================
+Quick Start Guide
+=================
+
+There are two basic commands categories, "show" and "config".  Show
+commands are used to view configuration information and statistics.
+Config commands are used to configure Traffic Server.  To use the
+config commands, you must first enter "enable mode" by using the
+enable command, which asks for the admin password (same password as
+WebUI). 
+
+At any point you can access context sensitive help by specifying "-h"
+or "-help" after a command name.  The following is a list of commands
+and options:
+
+-------------
+Show Commands
+-------------
+
+show                         Show command
+show:status                  Proxy status
+show:version                 Version information
+show:security                Security information
+show:http                    HTTP protocol configuration
+show:icp [peer]              ICP protocol configuration
+show:proxy                   Proxy configuration
+show:cache [rules|storage]   Cache configuration
+show:virtual-ip              Virtual-ip configuration
+show:hostdb                  Host database configuration
+show:dns-resolver            DNS resolver configuration
+show:logging                 Logging configuration
+show:ssl                     SSL configuration
+show:parent                  Parent configuration
+show:remap                   Remap configuration
+show:socks                   SOCKS configuration
+show:port-tunnels            Port tunnels configuration
+show:scheduled-update        Scheduled update configuration
+show:proxy-stats             Proxy statistics
+show:http-trans-stats        HTTP transaction statistics
+show:http-stats              HTTP statistics
+show:icp-stats               ICP statistics
+show:cache-stats             Cache statistics
+show:hostdb-stats            Host database statistics
+show:dns-stats               DNS statistics
+show:logging-stats           Logging statistics
+show:alarms                  Show active alarms
+
+---------------
+Config commands
+---------------
+
+config:get <variable>          Display a variable value
+config:set <variable> <value>  Set variable to specified value
+config:name <string>           Set proxy name <string>
+config:start                   Start proxy software
+config:stop                    Stop proxy software
+
+config:ssl <on | off>
+config:ssl ports <int>      
+
+config:parent <on | off>    
+config:parent name <parent>
+config:parent rules <url>    
+
+config:remap <url>              Update remap configuration file <url>
+    
+config:clock date <mm/dd/yyyy>          
+config:clock time <hh:mm:ss>
+config:clock timezone <number from list>       
+    
+config:security <ip-allow | mgmt-allow | admin> <url-config-file>
+config:security password                 
+
+config:http <on | off>
+config:http <keep-alive-timeout-in | keep-alive-timeout-out> <seconds>
+config:http <inactive-timeout-in | inactive-timeout-out> <seconds>
+config:http <active-timeout-in | active-timeout-out> <seconds>
+config:http <remove-from | remove-referer> <on | off>
+config:http <remove-user | remove-cookie> <on | off>
+config:http <remove-header> <string>
+config:http <insert-ip | remove-ip> <on | off>
+config:http proxy <fwd | rev | fwd-rev>      
+
+config:icp mode <disabled | receive | send-receive>
+config:icp port <int>
+config:icp multicast <on | off>
+config:icp query-timeout <seconds>
+config:icp peers <url-config-file>           
+ 
+config:port-tunnels server-other-ports <port>
+
+config:scheduled-update mode <on | off>
+config:scheduled-update retry count <int> interval <int>
+config:scheduled-update max-concurrent <int>
+config:scheduled-update force-immediate <on | off>
+config:scheduled-update rules <url-config-file>  
+    
+config:socks <on | off>
+config:socks server-ip <x.x.x.x>
+config:socks port <int>
+config:socks timeout <seconds>      
+    
+    
+config:cache <on | off>
+config:cache <http> <on | off>
+config:cache ignore-bypass <on | off>
+config:cache <max-object-size | max-alternates> <int>
+config:cache file <url-config-file>
+config:cache freshness verify <when-expired | no-date | always | never>
+config:cache freshness minimum <explicit | last-modified | nothing>
+config:cache freshness no-expire-limit greater-than <sec> less-than <sec>
+config:cache <dynamic | alternates> <on | off>
+config:cache vary <text | images | other> <string>
+config:cache vary cookies <none | all | non-text>        
+    
+    
+config:hostdb <lookup-timeout | foreground-timeout> <seconds>
+config:hostdb <background-timeout | invalid-host-timeout> <seconds>
+config:hostdb <re-dns-on-reload> <on | off>,
+Configure Host Database
+    
+config:logging event <enabled | trans-only | error-only | disabled>
+config:logging mgmt-directory <string>
+config:logging <space-limit | space-headroom> <megabytes>
+config:logging collation-status <inactive | host | send-standard |
+                                 send-custom | send-all>
+config:logging collation-host <string>
+config:logging collation secret <string> tagged <on | off> orphan-limit <int>
+config:logging format <squid | netscape-common | netscape-ext | netscape-ext2>
+               type <ascii | binary> file <string> header <string>
+config:logging splitting <icp | http> <on | off>
+config:logging custom <on | off> format <traditional | xml>
+config:logging rolling <on | off> offset <hour> interval <hours>
+               auto-delete <on | off>,
+	
+config:dns resolve-timeout <seconds>
+config:dns retries <int>,
+
+config:virtual-ip <on | off>
+config:virtual-ip add <x.x.x.x> device <string> sub-intf <int>
+config:virtual-ip delete <virtual ip number>,
+
+config:network ip-address <x.x.x.x>      (Linux only)
+config:network hostname <string>         (Linux only)
+config:network netmask <x.x.x.x>         (Linux only)
+config:network domainname <string>       (Linux only)
+config:network dns-ip <x.x.x.x>          (Linux only)
+config:network defaultrouter <x.x.x.x>   (Linux only)
+
+config:alarms resolve-name <string>
+config:alarms resolve-number <int>
+config:alarms resolve-all
+config:alarms notify <on | off>,
+
+----------------
+Utility commands
+----------------
+    
+enable              Enable Restricted Commands
+
+disable             Disable Restricted Commands
+ 
+debug <on|off>      Turn debugging print statements on/off
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/commandOptions.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/commandOptions.h b/cmd/traffic_shell/commandOptions.h
new file mode 100644
index 0000000..1f8f9c6
--- /dev/null
+++ b/cmd/traffic_shell/commandOptions.h
@@ -0,0 +1,47 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/* commandOptions.h
+ * these are valid options for createArgument
+ *
+ *
+ */
+
+#ifndef COMMAND_OPTIONS
+#define COMMAND_OPTIONS
+
+
+#define CLI_ARGV_CONSTANT_OPTIONAL                    0x401
+#define CLI_ARGV_INT_OPTIONAL                         0x402
+#define CLI_ARGV_STRING_OPTIONAL                      0x404
+#define CLI_ARGV_FLOAT_OPTIONAL                       0x408
+#define CLI_ARGV_FUNC_OPTIONAL                        0x410
+#define CLI_ARGV_HELP_OPTIONAL                        0x420
+#define CLI_ARGV_CONST_OPTION_OPTIONAL                0x440
+#define CLI_ARGV_CONSTANT_REQUIRED                    0x801
+#define CLI_ARGV_INT_REQUIRED                         0x802
+#define CLI_ARGV_STRING_REQUIRED                      0x804
+#define CLI_ARGV_FLOAT_REQUIRED                       0x808
+
+
+#endif /*COMMAND_OPTIONS */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/createArgument.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/createArgument.cc b/cmd/traffic_shell/createArgument.cc
new file mode 100644
index 0000000..e2f4e1b
--- /dev/null
+++ b/cmd/traffic_shell/createArgument.cc
@@ -0,0 +1,387 @@
+/** @file
+
+  This file provides basic create Argument defintion, for any new arguments.
+
+  @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 <stdlib.h>
+#include <tcl.h>
+#include <string.h>
+
+#include "createArgument.h"
+#include "definitions.h"
+#include "commandOptions.h"
+#include "hashtable.h"
+#include "ink_string.h"
+
+#define totalArguments 30       /* This is arbitary value */
+#define NEG_BOUND -10
+#define POS_BOUND 10
+
+static cli_ArgvInfo *ArgvTable;
+static cli_ArgvInfo *org_ArgvTable;
+extern Tcl_Interp *interp;
+
+cli_ArgvInfo *cliGetArgvInfo();
+cli_ArgvInfo *cliGetOrgArgvInfo();
+int getCommandOption(int commandoption, int *arg_type, int *arg_option);
+char **findRequired(cli_ArgvInfo * argtable);
+extern void setReqdArgs(char **required_args);
+
+int
+createArgument(const char *argument, int position, int commandoption,
+               char *range, int argumentRef, const char *helpString, char *defValue)
+{
+  int arg_type = 0;
+  int arg_option = 0;
+  char **reqd_args;
+  cli_ArgvInfo *aCliArgvTable = cliGetArgvInfo();
+
+  size_t key_len = sizeof(char) * (strlen(argument) + 1);
+  aCliArgvTable->key = (char *) ckalloc(key_len);
+  ink_strlcpy(aCliArgvTable->key, argument, key_len);
+
+  aCliArgvTable->position = position;
+
+  getCommandOption(commandoption, &arg_type, &arg_option);
+  aCliArgvTable->type = arg_type;
+  if (arg_option != 0) {
+    aCliArgvTable->option = arg_option;
+  }
+
+
+  aCliArgvTable->arg_ref = argumentRef;
+
+  if (range != NULL) {
+    aCliArgvTable->range_set = true;
+    if (aCliArgvTable->type == CLI_ARGV_INT || aCliArgvTable->type == CLI_ARGV_OPTION_INT_VALUE) {
+      getIntRange(range, &(aCliArgvTable->l_range.int_r1), &(aCliArgvTable->u_range.int_r2));
+    }
+    if (aCliArgvTable->type == CLI_ARGV_FLOAT || aCliArgvTable->type == CLI_ARGV_OPTION_FLOAT_VALUE) {
+      getFloatRange(range, &(aCliArgvTable->l_range.float_r1), &(aCliArgvTable->u_range.float_r2));
+    }
+
+  }
+
+  if (defValue != NULL) {
+    size_t def_len = sizeof(char) * (strlen(defValue) + 1);
+    aCliArgvTable->def = (char *) ckalloc(def_len);
+    ink_strlcpy(aCliArgvTable->def, defValue, def_len);
+  }
+
+
+  if (helpString != NULL) {
+    size_t help_len = sizeof(char) * (strlen(helpString) + 1);
+    aCliArgvTable->help = (char *) ckalloc(help_len);
+    ink_strlcpy(aCliArgvTable->help, helpString, help_len);
+  }
+
+  reqd_args = findRequired(cliGetOrgArgvInfo());
+  setReqdArgs(reqd_args);
+  return TCL_OK;
+}
+
+
+cli_ArgvInfo *
+cliGetArgvInfo()
+{
+  cli_ArgvInfo *temp_ArgvTable = ArgvTable;
+  ArgvTable++;
+  return temp_ArgvTable;
+}
+
+int
+cliSetArgvInfo(cli_ArgvInfo * argtable)
+{
+  ArgvTable = argtable;
+  org_ArgvTable = argtable;
+  return TCL_OK;
+}
+
+cli_ArgvInfo *
+cliGetOrgArgvInfo()
+{
+  return org_ArgvTable;
+}
+
+
+char **
+findRequired(cli_ArgvInfo * argtable)
+{
+  char **args;
+  cli_ArgvInfo *infoPtr;
+  int count_required = 0, i = 0;
+  for (infoPtr = argtable; (infoPtr->key != NULL); infoPtr++) {
+    if (infoPtr->option == CLI_ARGV_REQUIRED) {
+      count_required++;
+    }
+  }
+  if (count_required == 0)
+    return (char **) NULL;
+
+  args = (char **) ckalloc(sizeof(char *) * (count_required + 1));
+  for (infoPtr = argtable; (infoPtr->key != NULL); infoPtr++) {
+    if (infoPtr->option == CLI_ARGV_REQUIRED) {
+
+      args[i] = ats_strdup(infoPtr->key);
+      i++;
+    }
+  }
+  args[i] = NULL;
+  return args;
+}
+
+
+int
+getCommandOption(int commandoption, int *arg_type, int *arg_option)
+{
+  switch (commandoption) {
+  case CLI_ARGV_CONSTANT:
+    *arg_type = CLI_ARGV_CONSTANT;
+    *arg_option = 0;
+    break;
+  case CLI_ARGV_CONST_OPTION:
+    *arg_type = CLI_ARGV_CONST_OPTION;
+    *arg_option = 0;
+    break;
+  case CLI_ARGV_INT:
+    *arg_type = CLI_ARGV_INT;
+    *arg_option = 0;
+    break;
+  case CLI_ARGV_STRING:
+    *arg_type = CLI_ARGV_STRING;
+    *arg_option = 0;
+    break;
+  case CLI_ARGV_FLOAT:
+    *arg_type = CLI_ARGV_FLOAT;
+    *arg_option = 0;
+    break;
+  case CLI_ARGV_OPTION_NAME_VALUE:
+    *arg_type = CLI_ARGV_OPTION_NAME_VALUE;
+    *arg_option = 0;
+    break;
+  case CLI_ARGV_OPTION_FLOAT_VALUE:
+    *arg_type = CLI_ARGV_OPTION_FLOAT_VALUE;
+    *arg_option = 0;
+    break;
+  case CLI_ARGV_OPTION_INT_VALUE:
+    *arg_type = CLI_ARGV_OPTION_INT_VALUE;
+    *arg_option = 0;
+    break;
+  case CLI_ARGV_CONSTANT_OPTIONAL:
+    *arg_type = CLI_ARGV_CONSTANT;
+    *arg_option = CLI_ARGV_OPTIONAL;
+    break;
+  case CLI_ARGV_INT_OPTIONAL:
+    *arg_type = CLI_ARGV_INT;
+    *arg_option = CLI_ARGV_OPTIONAL;
+    break;
+  case CLI_ARGV_STRING_OPTIONAL:
+    *arg_type = CLI_ARGV_STRING;
+    *arg_option = CLI_ARGV_OPTIONAL;
+    break;
+  case CLI_ARGV_FLOAT_OPTIONAL:
+    *arg_type = CLI_ARGV_FLOAT;
+    *arg_option = CLI_ARGV_OPTIONAL;
+    break;
+  case CLI_ARGV_FUNC_OPTIONAL:
+    *arg_type = CLI_ARGV_FUNC;
+    *arg_option = CLI_ARGV_OPTIONAL;
+    break;
+  case CLI_ARGV_HELP_OPTIONAL:
+    *arg_type = CLI_ARGV_HELP;
+    *arg_option = CLI_ARGV_OPTIONAL;
+    break;
+  case CLI_ARGV_CONST_OPTION_OPTIONAL:
+    *arg_type = CLI_ARGV_CONST_OPTION;
+    *arg_option = CLI_ARGV_OPTIONAL;
+    break;
+  case CLI_ARGV_CONSTANT_REQUIRED:
+    *arg_type = CLI_ARGV_CONSTANT;
+    *arg_option = CLI_ARGV_REQUIRED;
+    break;
+  case CLI_ARGV_INT_REQUIRED:
+    *arg_type = CLI_ARGV_INT;
+    *arg_option = CLI_ARGV_REQUIRED;
+    break;
+  case CLI_ARGV_STRING_REQUIRED:
+    *arg_type = CLI_ARGV_STRING;
+    *arg_option = CLI_ARGV_REQUIRED;
+    break;
+  case CLI_ARGV_FLOAT_REQUIRED:
+    *arg_type = CLI_ARGV_FLOAT;
+    *arg_option = CLI_ARGV_REQUIRED;
+    break;
+  default:
+    *arg_type = 0;
+    *arg_option = 0;
+    break;
+  }
+  return TCL_OK;
+}
+
+int
+getIntRange(char *range, int *r1, int *r2)
+{
+  char *range_str;
+  char *str;
+  int bound, i = 0, len;
+  char *buf;
+  char *endPtr;
+
+  buf = (char *) ckalloc(sizeof(char) * 256);
+  range_str = ats_strdup(range);
+  len = strlen(range_str);
+  range_str[len] = 0;
+  str = range_str;
+  while (*str != 0) {
+    if (*str == '-') {
+      bound = NEG_BOUND;
+      str++;
+    }
+
+    else if (*str == '+') {
+      bound = POS_BOUND;
+      str++;
+    } else {
+      Tcl_AppendResult(interp, "range not specified correctly", (char *) NULL);
+      ckfree(buf);
+      ckfree(range_str);
+      return TCL_ERROR;
+    }
+    if (*str == 'r') {
+      str++;
+      i = 0;
+      for (; (*str != '+'); str++) {
+        if (*str == 0)
+          break;
+        buf[i] = *str;
+        i++;
+      }
+      buf[i] = 0;
+      if (bound == NEG_BOUND) {
+        *r1 = strtol(buf, &endPtr, 0);
+        if ((endPtr == buf) || (*endPtr != 0)) {
+          Tcl_AppendResult(interp, "negative range is not correct\n", (char *) NULL);
+          ckfree(buf);
+          ckfree(range_str);
+          return TCL_ERROR;
+
+        }
+      } else if (bound == POS_BOUND) {
+        *r2 = strtol(buf, &endPtr, 0);
+        if ((endPtr == buf) || (*endPtr != 0)) {
+          Tcl_AppendResult(interp, "positive range is not correct\n", (char *) NULL);
+          ckfree(buf);
+          ckfree(range_str);
+          return TCL_ERROR;
+
+        }
+      }
+
+    } else {
+      Tcl_AppendResult(interp, "range not specified correctly\n");
+      ckfree(buf);
+      ckfree(range_str);
+      return TCL_ERROR;
+    }
+
+
+  }
+  ckfree(buf);
+  ckfree(range_str);
+  return TCL_OK;
+}
+
+
+int
+getFloatRange(char *range, float *r1, float *r2)
+{
+  char *range_str;
+  char *str;
+  int bound, i = 0, len;
+  char *buf;
+  char *endPtr;
+
+  buf = (char *) ckalloc(sizeof(char) * 256);
+  range_str = ats_strdup(range);
+  len = strlen(range_str);
+  range_str[len] = 0;
+  str = range_str;
+  while (*str != 0) {
+    if (*str == '-') {
+      bound = NEG_BOUND;
+      str++;
+    }
+
+    else if (*str == '+') {
+      bound = POS_BOUND;
+      str++;
+    } else {
+      Tcl_AppendResult(interp, "range not specified correctly", (char *) NULL);
+      ckfree(buf);
+      ckfree(range_str);
+      return TCL_ERROR;
+    }
+    if (*str == 'r') {
+      str++;
+      i = 0;
+      for (; (*str != '+'); str++) {
+        if (*str == 0)
+          break;
+        buf[i] = *str;
+        i++;
+      }
+      buf[i] = 0;
+      if (bound == NEG_BOUND) {
+        // Solaris is messed up, in that strtod() does not honor C99/SUSv3 mode.
+        *r1 = strtold(buf, &endPtr);
+        if ((endPtr == buf) || (*endPtr != 0)) {
+          Tcl_AppendResult(interp, "negative range is not correct", (char *) NULL);
+          ckfree(buf);
+          ckfree(range_str);
+          return TCL_ERROR;
+
+        }
+      } else if (bound == POS_BOUND) {
+        *r2 = strtold(buf, &endPtr);
+        if ((endPtr == buf) || (*endPtr != 0)) {
+          Tcl_AppendResult(interp, "positive range is not correct", (char *) NULL);
+          ckfree(buf);
+          ckfree(range_str);
+          return TCL_ERROR;
+
+        }
+      }
+
+    } else {
+      Tcl_AppendResult(interp, "range not specified correctly");
+      ckfree(buf);
+      ckfree(range_str);
+      return TCL_ERROR;
+    }
+
+
+  }
+  ckfree(buf);
+  ckfree(range_str);
+  return TCL_OK;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/createArgument.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/createArgument.h b/cmd/traffic_shell/createArgument.h
new file mode 100644
index 0000000..4681c3a
--- /dev/null
+++ b/cmd/traffic_shell/createArgument.h
@@ -0,0 +1,119 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/*
+ *   createArgument.h --
+ *
+ *
+ *    This file provides basic create Argument declartion,
+ *    for any new arguments.
+ *
+ *
+ *
+ *
+ *    Dated  : 12/11/2000.
+ */
+
+#ifndef CREATE_ARGUMENT
+#define CREATE_ARGUMENT
+
+#include <commandOptions.h>
+
+typedef union arg_value
+{                               /* Value of the argument can be
+                                   integr or float or string */
+  char *arg_string;
+  int arg_int;
+  float arg_float;
+} arg_value;
+
+typedef union lower_range
+{
+  int int_r1;
+  float float_r1;
+} lower_range;
+
+typedef union upper_range
+{
+  int int_r2;
+  float float_r2;
+} upper_range;
+
+typedef struct cli_ArgvInfo
+{
+  char *key;                    /*  The key string that flags
+                                   the option  in the argv array */
+  int position;                 /* indicates position of the
+                                   argument in command */
+  int type;                     /* Indicates argument type;  */
+  int arg_ref;                  /* User creates an integer to
+                                   refer to this argument */
+  lower_range l_range;          /* lower_range */
+  upper_range u_range;          /* upper_range */
+  bool range_set;                /* flag which indicates if range is set by user */
+  int option;                   /* flag which indicates if argument is optional or required */
+  char *help;                   /* Documentation message describing this  option. */
+  char *def;                    /* default value */
+
+} cli_ArgvInfo;
+
+
+typedef struct cli_parsedArgInfo
+{
+  int parsed_args;
+  char *data;
+  int arg_int;
+  float arg_float;
+  char *arg_string;
+  char *arg_usage;
+} cli_parsedArgInfo;
+
+
+typedef struct cli_cmdCallbackInfo
+{
+  const char *command_usage;
+  cli_parsedArgInfo *parsedArgTable;
+  void *userdata;
+} cli_cmdCallbackInfo;
+
+
+typedef struct cli_CommandInfo
+{
+  const char *command_name;           /* command name    */
+  cli_ArgvInfo *argtable;       /* pointer to argv table */
+  char **reqd_args;             /* holds reference no for
+                                   required arguments */
+  cli_parsedArgInfo *parsedArgTable;    /* holds parsed arguments */
+  char *helpString;
+
+} cli_CommandInfo;
+
+extern int createArgument(const char *argument, int position, int commandoption,
+                          char *range, int argumentRef, const char *helpString, char *defValue);
+
+
+
+extern int getIntRange(char *range, int *r1, int *r2);
+extern int getFloatRange(char *range, float *r1, float *r2);
+
+#endif /*CREATE_ARGUMENT */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/createCommand.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/createCommand.cc b/cmd/traffic_shell/createCommand.cc
new file mode 100644
index 0000000..d1dc5e4
--- /dev/null
+++ b/cmd/traffic_shell/createCommand.cc
@@ -0,0 +1,166 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/*
+ *   createCommand.c --
+ *
+ *
+ *    This file provides basic create command definition,
+ *    for any new commands.
+ *
+ *    It overrides any existing commands with the new command
+ *    without any warning
+ *
+ *
+ *    Dated  : 12/11/2000.
+ */
+
+#include <tcl.h>
+#include <stdlib.h>
+#include "definitions.h"
+#include "createArgument.h"
+#include "hashtable.h"
+
+static char **reqd_args;
+char **getReqdArgs();
+
+extern Tcl_Interp *interp;
+/* This is the only interp for the whole application */
+
+extern cli_ArgvInfo *cliGetArgvInfo();
+extern int cliSetArgvInfo(cli_ArgvInfo * argtable);
+
+
+
+int
+createCommand(const char *cmdName, Tcl_CmdProc cmdFuncPtr,
+              createArgumentFuncPtr argvFuncPtr, cmdTerritory cmdScope, const char *usage, const char *helpString)
+{
+  /* No code to support threads for Tcl */
+
+  /* If required add thread Specific code
+     here
+     Hint: Use Tcl_GetThreadData
+
+   */
+  int isSafe, i;
+  cli_ArgvInfo *argtable;
+  char **required_args;
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+
+  if ((cmdName == NULL) || (cmdFuncPtr == NULL) || (helpString == NULL)) {
+    printf("Error: New command with NULL string or object procs or with no help string provided\n");
+    return TCL_ERROR;
+  }
+
+
+  /* Used for creating internal commands */
+  isSafe = Tcl_IsSafe(interp);
+
+  argtable = (cli_ArgvInfo *) ckalloc(sizeof(cli_ArgvInfo) * 100);
+  for (i = 0; i < 100; i++) {
+    argtable[i].key = (char *) NULL;
+    argtable[i].type = CLI_ARGV_END;
+    argtable[i].range_set = false;
+    argtable[i].option = CLI_ARGV_OPTIONAL;
+    argtable[i].def = (char *) NULL;
+    argtable[i].help = (char *) NULL;
+
+  }
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) ckalloc(sizeof(cli_cmdCallbackInfo));
+
+  cmdCallbackInfo->command_usage = usage;
+
+  cmdCallbackInfo->parsedArgTable = (cli_parsedArgInfo *) ckalloc(sizeof(cli_parsedArgInfo) * 100);
+  for (i = 0; i < 100; i++) {
+    cmdCallbackInfo->parsedArgTable[i].parsed_args = CLI_PARSED_ARGV_END;
+    cmdCallbackInfo->parsedArgTable[i].data = (char *) NULL;
+    cmdCallbackInfo->parsedArgTable[i].arg_string = (char *) NULL;
+    cmdCallbackInfo->parsedArgTable[i].arg_int = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
+    cmdCallbackInfo->parsedArgTable[i].arg_float = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
+    cmdCallbackInfo->parsedArgTable[i].arg_usage = (char *) NULL;
+
+  }
+
+  cmdCallbackInfo->userdata = (void *) NULL;
+
+  /* Create a new command with cmdName */
+  Tcl_CreateCommand(interp, cmdName, cmdFuncPtr, (ClientData) cmdCallbackInfo,
+                    (void (*)_ANSI_ARGS_((ClientData))) NULL);
+
+  cliSetArgvInfo(argtable);
+  if (isSafe) {
+    if (cmdScope == CLI_COMMAND_INTERNAL) {
+      Tcl_HideCommand(interp, cmdName, cmdName);
+    }
+  }
+
+
+  if (argvFuncPtr != NULL) {
+    (*argvFuncPtr) ();
+    /* Now call create Arguments so that we can fill the necessary
+       data structure and call parseArgv to parse the arguments.
+     */
+  }
+
+  required_args = getReqdArgs();
+  cliAddCommandtoHashtable(cmdName, argtable, required_args, cmdCallbackInfo->parsedArgTable, helpString);
+
+
+  return TCL_OK;
+
+}
+
+void
+setReqdArgs(char **required_args)
+{
+  reqd_args = required_args;
+}
+
+char **
+getReqdArgs()
+{
+  return reqd_args;
+}
+
+int
+cmd_ok()
+{
+  /* if it called many times, the interperter will store only
+     the latest.
+   */
+  Tcl_AppendElement(interp, "+OK");
+  return TCL_OK;
+}
+
+
+int
+cmd_error()
+{
+  /* If it called many times, the interpreter will store only
+     the latest
+   */
+  Tcl_AppendElement(interp, "-ERROR");
+  return TCL_ERROR;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/createCommand.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/createCommand.h b/cmd/traffic_shell/createCommand.h
new file mode 100644
index 0000000..b6a5147
--- /dev/null
+++ b/cmd/traffic_shell/createCommand.h
@@ -0,0 +1,59 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/*
+ *   createCommand.h --
+ *
+ *
+ *    This file provides basic create command declartion,
+ *    for any new commands.
+ *
+ *    It overrides any existing commands with the new command
+ *
+ *
+ *
+ *    Dated  : 12/11/2000.
+ */
+
+#ifndef CREATE_COMMAND
+#define CREATE_COMMAND
+
+#include "definitions.h"
+
+
+
+/* First Argument  cmdName: New command name for CLI
+   Second Argument cmdFuncPtr : A 'C' function to be invoked
+                                for the new Command
+   Third Argument argvFuncPtr : Function to attach arguments
+                                Pass NULL for no arguments.
+   Fourth Argument cmdScope   : Scope of the command.
+                                Pass NULL, if the new command
+                                needs to be visible for
+                                the customer.
+*/
+
+extern int createCommand(const char *cmdName, Tcl_CmdProc * cmdFuncPtr,
+                         createArgumentFuncPtr argvFuncPtr, cmdTerritory cmdScope, const char *usage, const char *helpstring);
+
+#endif /* CREATE_COMMAND */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/definitions.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/definitions.h b/cmd/traffic_shell/definitions.h
new file mode 100644
index 0000000..327baad
--- /dev/null
+++ b/cmd/traffic_shell/definitions.h
@@ -0,0 +1,77 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/*
+ * Legal values for the type field of a createArgv:
+ *
+ */
+#include <tcl.h>
+
+#ifndef DEFINITIONS
+#define DEFINITIONS
+
+#define CLI_OK    TCL_OK
+
+#define CLI_ERROR TCL_ERROR
+#define CMD_OK cmd_ok()
+#define CMD_ERROR cmd_error()
+
+#define CLI_ARGV_CONSTANT                   0x1
+#define CLI_ARGV_INT                        0x2
+#define CLI_ARGV_STRING                     0x4
+#define CLI_ARGV_FLOAT                      0x8
+#define CLI_ARGV_FUNC                       0x10
+#define CLI_ARGV_HELP                       0x20
+#define CLI_ARGV_CONST_OPTION               0x40
+#define CLI_ARGV_OPTION_FLOAT_VALUE         0x80
+#define CLI_ARGV_OPTION_INT_VALUE           0x90
+#define CLI_ARGV_OPTION_NAME_VALUE          0x100
+#define CLI_ARGV_END                        0x200
+#define CLI_PARSED_ARGV_END                 0x1000
+#define CLI_PARSED_ARGV_DATA                0x1001
+#define CLI_PARENT_ARGV                     1
+#define CLI_ARGV_NO_POS                     -1
+
+#define CLI_ARGV_OPTIONAL                   0x400
+#define CLI_ARGV_REQUIRED                   0x800
+
+#define CLI_DEFAULT_INT_OR_FLOAT_VALUE               -32768
+
+typedef enum
+{
+  CLI_COMMAND_INTERNAL = 0x300,
+  CLI_COMMAND_EXTERNAL = 0x700
+} cmdTerritory;
+
+typedef int (commandFunctionptr) (ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]);
+typedef int (createArgumentFuncPtr) ();
+
+int cmd_ok(void);
+int cmd_error(void);
+
+extern int AlarmCallbackPrint;
+
+int processArgForCommand(Tcl_Interp * interp, int argc, const char *argv[]);
+int processHelpCommand(int argc, const char *argv[]);
+
+#endif /*DEFINITIONS */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/hashtable.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/hashtable.cc b/cmd/traffic_shell/hashtable.cc
new file mode 100644
index 0000000..183ebf0
--- /dev/null
+++ b/cmd/traffic_shell/hashtable.cc
@@ -0,0 +1,219 @@
+/** @file
+
+  Stuff related to hashtable
+
+  @section license License
+
+  Copyright (c) 1997-1998 Sun Microsystems, Inc.
+
+  TK 8.3 license:
+
+  This software is copyrighted by the Regents of the University of
+  California, Sun Microsystems, Inc., and other parties.  The following
+  terms apply to all files associated with the software unless explicitly
+  disclaimed in individual files.
+
+  The authors hereby grant permission to use, copy, modify, distribute,
+  and license this software and its documentation for any purpose, provided
+  that existing copyright notices are retained in all copies and that this
+  notice is included verbatim in any distributions. No written agreement,
+  license, or royalty fee is required for any of the authorized uses.
+  Modifications to this software may be copyrighted by their authors
+  and need not follow the licensing terms described here, provided that
+  the new terms are clearly indicated on the first page of each file where
+  they apply.
+
+  IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+  FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+  ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+  DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+
+  THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+  IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+  NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+  MODIFICATIONS.
+
+  GOVERNMENT USE: If you are acquiring this software on behalf of the
+  U.S. government, the Government shall have only "Restricted Rights"
+  in the software and related documentation as defined in the Federal
+  Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
+  are acquiring the software on behalf of the Department of Defense, the
+  software shall be classified as "Commercial Computer Software" and the
+  Government shall have only "Restricted Rights" as defined in Clause
+  252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
+  authors grant the U.S. Government and others acting in its behalf
+  permission to use and distribute the software in accordance with the
+  terms specified in this license.
+
+  @section details Details
+
+  Parts of this code is based on code from TK, tkConfig.c. The license
+  on this code allows us to use as long as we keep the license with
+  the source.  Note that only parts of this code is from tkConfig.c,
+  since it's been modified to work with our internals.
+
+ */
+
+#include <tcl.h>
+#include <stdlib.h>
+#include <string.h>
+#include "definitions.h"
+#include "createArgument.h"
+#include "ink_string.h"
+#include "ink_defs.h"
+
+
+extern Tcl_Interp *interp;
+Tcl_HashTable CommandHashtable;
+
+#define OPTION_HASH_KEY "cliOptionTable"
+static void DestroyOptionHashTable _ANSI_ARGS_((ClientData clientData, Tcl_Interp * interp));
+
+int
+cliCreateCommandHashtable()
+{
+  Tcl_HashTable *hashTablePtr;
+
+  /*
+   * We use an AssocData value in the interpreter to keep a hash
+   * table of all the option tables we've created for this application.
+   * This is used for two purposes.  First, it allows us to share the
+   * tables (e.g. in several chains) and second, we use the deletion
+   * callback for the AssocData to delete all the option tables when
+   * the interpreter is deleted.  The code below finds the hash table
+   * or creates a new one if it doesn't already exist.
+   */
+  hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL);
+  if (hashTablePtr == NULL) {
+    hashTablePtr = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
+    Tcl_InitHashTable(hashTablePtr, TCL_STRING_KEYS);
+    Tcl_SetAssocData(interp, OPTION_HASH_KEY, DestroyOptionHashTable, (ClientData) hashTablePtr);
+  }
+
+  return TCL_OK;
+}
+
+
+int
+cliAddCommandtoHashtable(const char *name, cli_ArgvInfo * argtable,
+                         char **reqd_args, cli_parsedArgInfo * parsedArgTable, const char *helpString)
+{
+  Tcl_HashEntry *entryPtr;
+  int newCmd;
+  cli_CommandInfo *commandinfo;
+  Tcl_HashTable *hashTablePtr;
+
+  hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL);
+  if (hashTablePtr == NULL) {
+    Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL);
+    return TCL_ERROR;
+  }
+
+
+  commandinfo = (cli_CommandInfo *) ckalloc(sizeof(cli_CommandInfo));
+  commandinfo->command_name = name;
+  commandinfo->argtable = argtable;
+  commandinfo->reqd_args = reqd_args;
+  commandinfo->parsedArgTable = parsedArgTable;
+  if (helpString != NULL) {
+    int helpString_size = sizeof(char) * (strlen(helpString) + 1);
+    commandinfo->helpString = (char *) ckalloc(helpString_size);
+    ink_strlcpy(commandinfo->helpString, helpString, helpString_size);
+  }
+
+  /*
+   * See if a table has already been created for this template.  If
+   * so, just reuse the existing table.
+   */
+
+  entryPtr = Tcl_CreateHashEntry(hashTablePtr, name, &newCmd);
+  if (entryPtr == NULL) {
+    Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL);
+    return TCL_ERROR;
+  }
+  Tcl_SetHashValue(entryPtr, commandinfo);
+  return TCL_OK;
+}
+
+
+cli_CommandInfo *
+cliGetCommandArgsfromHashtable(char *name)
+{
+  Tcl_HashEntry *entryPtr;
+  cli_CommandInfo *commandinfo;
+  Tcl_HashTable *hashTablePtr;
+
+  hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL);
+  if (hashTablePtr == NULL) {
+    Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL);
+    return NULL;
+  }
+
+  entryPtr = Tcl_FindHashEntry(hashTablePtr, name);
+  if (entryPtr == NULL) {
+    Tcl_AppendResult(interp, "no command named \"", name, "\"", (char *) NULL);
+    return NULL;
+  }
+
+  commandinfo = (cli_CommandInfo *) Tcl_GetHashValue(entryPtr);
+  if (commandinfo == (cli_CommandInfo *) NULL) {
+    Tcl_AppendResult(interp, "no command named \"", name, "\"", (char *) NULL);
+    return NULL;
+  }
+
+  return (commandinfo);
+
+}
+
+
+static void
+DestroyOptionHashTable(ClientData clientData, Tcl_Interp * /* interp ATS_UNUSED */)
+    /* The hash table we are destroying */
+    /* The interpreter we are destroying */
+{
+  Tcl_HashTable *hashTablePtr = (Tcl_HashTable *) clientData;
+  Tcl_HashSearch search;
+  Tcl_HashEntry *hashEntryPtr;
+  cli_CommandInfo *commandinfo;
+  cli_ArgvInfo *infoPtr;
+
+  for (hashEntryPtr = Tcl_FirstHashEntry(hashTablePtr, &search);
+       hashEntryPtr != NULL; hashEntryPtr = Tcl_NextHashEntry(&search)) {
+
+    commandinfo = (cli_CommandInfo *) Tcl_GetHashValue(hashEntryPtr);
+    if (commandinfo) {
+      if (commandinfo->reqd_args) {
+        ckfree((char *) commandinfo->reqd_args);
+      }
+
+      if (commandinfo->argtable) {
+        for (infoPtr = commandinfo->argtable; infoPtr->key != NULL; infoPtr++) {
+          if (infoPtr->key) {
+            ckfree((char *) infoPtr->key);
+          }
+          if (infoPtr->help) {
+            ckfree((char *) infoPtr->help);
+          }
+          if (infoPtr->def) {
+            ckfree((char *) infoPtr->def);
+          }
+        }
+        ckfree((char *) commandinfo->argtable);
+      }
+
+      if (commandinfo->command_name) {
+        ckfree((char *) commandinfo->command_name);
+      }
+      if (commandinfo->helpString) {
+        ckfree((char *) commandinfo->helpString);
+      }
+      ckfree((char *) commandinfo);
+    }
+    hashEntryPtr = Tcl_NextHashEntry(&search);
+  }
+  Tcl_DeleteHashTable(hashTablePtr);
+  ckfree((char *) hashTablePtr);
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/hashtable.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/hashtable.h b/cmd/traffic_shell/hashtable.h
new file mode 100644
index 0000000..96f9f7b
--- /dev/null
+++ b/cmd/traffic_shell/hashtable.h
@@ -0,0 +1,45 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/* hashtable.h
+ * has function declarations for the stuff realted to hashtable
+ *
+ */
+
+#ifndef CREATE_HASH
+#define CREATE_HASH
+
+#include "createArgument.h"
+
+extern int cliCreateCommandHashtable();
+
+extern int cliAddCommandtoHashtable(const char *name, cli_ArgvInfo * argtable, char **reqd_args,
+                                    cli_parsedArgInfo * parsedArgTable, const char *helpString);
+
+extern cli_CommandInfo *cliGetCommandArgsfromHashtable(char *name);
+
+extern int cliParseArgument(int argc, const char **argv, cli_CommandInfo * commandinfo);
+
+extern int getIntRange(char *range, int *r1, int *r2);
+extern int floatIntRange(char *range, float *r1, float *r2);
+#endif /* CREATE_HASH */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/processArgument.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/processArgument.cc b/cmd/traffic_shell/processArgument.cc
new file mode 100644
index 0000000..24f0810
--- /dev/null
+++ b/cmd/traffic_shell/processArgument.cc
@@ -0,0 +1,57 @@
+/** @file
+
+  A brief file description
+
+  @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 <tcl.h>
+#include "hashtable.h"
+#include "definitions.h"
+#include "ink_error.h"
+#include "ink_defs.h"
+#include <string.h>
+
+// processArgForCommand
+int
+processArgForCommand(Tcl_Interp * /* interp ATS_UNUSED */, int argc, const char *argv[])
+{
+  cli_CommandInfo *commandinfo = cliGetCommandArgsfromHashtable((char *) argv[0]);
+
+  if (commandinfo == NULL)
+    return TCL_ERROR;
+
+  return (cliParseArgument(argc, argv, commandinfo));
+}
+
+
+//processHelpCmd
+int
+processHelpCommand(int argc, const char *argv[])
+{
+  if (argc == 2) {
+    int length = strlen(argv[1]);
+    if ((length >= 2) && ((strncmp(argv[1], "-help", length) == 0) || (strncmp(argv[1], "-h", length) == 0))) {
+      return TCL_OK;
+    }
+  } else
+    return TCL_ERROR;
+
+  return TCL_ERROR;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/traffic_shell.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/traffic_shell.cc b/cmd/traffic_shell/traffic_shell.cc
new file mode 100644
index 0000000..8da720a
--- /dev/null
+++ b/cmd/traffic_shell/traffic_shell.cc
@@ -0,0 +1,113 @@
+/** @file
+
+  A brief file description
+
+  @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 "ink_config.h"
+#include <stdlib.h>
+#include "tcl.h"
+#include <string.h>
+#include "ink_args.h"
+#include "ink_file.h"
+#include "ink_error.h"
+#include "I_Layout.h"
+#include "I_Version.h"
+#include "CliMgmtUtils.h"
+#include "mgmtapi.h"
+
+extern int Tcl_AppInit(Tcl_Interp * interp);
+extern void Tcl_ReadlineMain(void);
+extern int CliDisplayPrintf;
+void eventCallbackFn(char *name, char *msg, int pri, void *data);
+
+// default is that alarms appear in CLI as they occur
+int AlarmCallbackPrint = 1;
+
+// registers an event callback for all events in general
+void register_event_callback(void);
+
+AppVersionInfo appVersionInfo;
+int version_flag = 0;
+
+int
+main(int argc, char *argv[])
+{
+  TSError status;
+
+  // build the application information structure
+  appVersionInfo.setup(PACKAGE_NAME,"traffic_shell", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
+
+  // Before accessing file system initialize Layout engine
+  Layout::create();
+
+  // Argument description table used to describe how to parse command line args,
+  // see 'ink_args.h' for meanings of the various fields
+  ArgumentDescription argument_descriptions[] = {
+    {"version", 'V', "Print Version Id", "T", &version_flag, NULL, NULL}
+  };
+
+  // Process command line arguments and dump into variables
+  process_args(argument_descriptions, countof(argument_descriptions), argv);
+
+  // check for the version number request
+  if (version_flag) {
+    ink_fputln(stderr, appVersionInfo.FullVersionInfoStr);
+    exit(0);
+  }
+
+  // traffic_shell binary should use printf to display information onscreen
+  CliDisplayPrintf = 1;
+
+  // initialize MgmtAPI using TS runtime directory
+  status = TSInit(Layout::get()->runtimedir, TS_MGMT_OPT_DEFAULTS);
+  if (status) {
+    printf("TSInit %d: Failed to initialize MgmtAPI in %s\n", status, Layout::get()->runtimedir);
+  } else {
+    printf("Successfully Initialized MgmtAPI in %s \n", Layout::get()->runtimedir);
+  }
+
+  register_event_callback();
+
+#if HAVE_LIBREADLINE
+  Tcl_SetMainLoop(Tcl_ReadlineMain);
+#endif
+
+  Tcl_Main(argc, argv, Tcl_AppInit);
+  exit(0);
+}
+
+void
+eventCallbackFn(char *name, char * /* msg ATS_UNUSED */, int /* pri ATS_UNUSED */, void * /* data ATS_UNUSED */)
+{
+  if (AlarmCallbackPrint == 1) {
+    printf("\n**********\n" "ALARM SIGNALLED: %s\n" "**********\n", name);
+  }
+
+  return;
+}
+
+// registers an event callback for all events in general
+void
+register_event_callback(void)
+{
+  // TODO: Check return code?
+  TSEventSignalCbRegister(NULL, eventCallbackFn, NULL);
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index fe77e8d..bd76888 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1844,6 +1844,7 @@ AC_CONFIG_FILES([
   cmd/Makefile
   cmd/traffic_cop/Makefile
   cmd/traffic_line/Makefile
+  cmd/traffic_shell/Makefile
   cmd/traffic_top/Makefile
   doc/Doxyfile
   doc/Makefile
@@ -1889,7 +1890,6 @@ AC_CONFIG_FILES([
   mgmt/Makefile
   mgmt/api/Makefile
   mgmt/api/include/Makefile
-  mgmt/cli/Makefile
   mgmt/cluster/Makefile
   mgmt/preparse/Makefile
   mgmt/stats/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/Makefile.am b/mgmt/Makefile.am
index 78673ff..30c8609 100644
--- a/mgmt/Makefile.am
+++ b/mgmt/Makefile.am
@@ -17,7 +17,7 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-SUBDIRS = cluster preparse utils web2 stats api cli
+SUBDIRS = cluster preparse utils web2 stats api
 
 # This is for traffic_manager only (local manager)
 AM_CPPFLAGS = $(ink_with_modules_local) \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/CliCreateCommands.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/CliCreateCommands.cc b/mgmt/cli/CliCreateCommands.cc
deleted file mode 100644
index 5a22207..0000000
--- a/mgmt/cli/CliCreateCommands.cc
+++ /dev/null
@@ -1,318 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/****************************************************************
- * Filename: CliCreateCommands.cc
- * Purpose: This file contains the CLI command creation function.
- *
- *
- ****************************************************************/
-
-#include "CliCreateCommands.h"
-#include "createCommand.h"
-#include "ShowCmd.h"
-#include "ConfigCmd.h"
-#include "UtilCmds.h"
-#include "CliDisplay.h"
-#include "I_Layout.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <string>
-#include <sstream>
-#include <algorithm>
-
-////////////////////////////////////////////////////////////////
-// Called during Tcl_AppInit, this function creates the CLI commands
-//
-int
-CliCreateCommands()
-{
-  createCommand("config:root", Cmd_ConfigRoot, NULL, CLI_COMMAND_EXTERNAL, "config:root", "Switch to root user");
-
-  createCommand("show", Cmd_Show, NULL, CLI_COMMAND_EXTERNAL, "show", "Show command");
-
-  createCommand("config", Cmd_Config, NULL, CLI_COMMAND_EXTERNAL, "config", "Config command");
-
-  createCommand("show:status", Cmd_ShowStatus, NULL, CLI_COMMAND_EXTERNAL, "show:status", "Proxy status");
-
-  createCommand("show:version", Cmd_ShowVersion, NULL, CLI_COMMAND_EXTERNAL, "show:version", "Version information");
-
-
-  createCommand("show:security", Cmd_ShowSecurity, NULL, CLI_COMMAND_EXTERNAL, "show:security", "Security information");
-
-  createCommand("show:http", Cmd_ShowHttp, NULL, CLI_COMMAND_EXTERNAL, "show:http", "HTTP protocol configuration");
-
-  createCommand("show:icp", Cmd_ShowIcp, CmdArgs_ShowIcp, CLI_COMMAND_EXTERNAL,
-                "show:icp [peer]", "ICP protocol configuration");
-
-  createCommand("show:proxy", Cmd_ShowProxy, NULL, CLI_COMMAND_EXTERNAL, "show:proxy", "Proxy configuration");
-
-  createCommand("show:cache", Cmd_ShowCache, CmdArgs_ShowCache, CLI_COMMAND_EXTERNAL,
-                "show:cache [rules|storage]", "Cache configuration");
-
-  createCommand("show:virtual-ip", Cmd_ShowVirtualIp, NULL, CLI_COMMAND_EXTERNAL,
-                "show:virtual-ip", "Virtual-ip configuration");
-
-  createCommand("show:hostdb", Cmd_ShowHostDb, NULL, CLI_COMMAND_EXTERNAL,
-                "show:hostdb", "Host database configuration");
-
-  createCommand("show:dns-resolver", Cmd_ShowDnsResolver, NULL, CLI_COMMAND_EXTERNAL,
-                "show:dns-resolver", "DNS resolver configuration");
-
-  createCommand("show:logging", Cmd_ShowLogging, NULL, CLI_COMMAND_EXTERNAL, "show:logging", "Logging configuration");
-
-  createCommand("show:ssl", Cmd_ShowSsl, NULL, CLI_COMMAND_EXTERNAL, "show:ssl", "SSL configuration");
-
-  createCommand("show:parent", Cmd_ShowParents, CmdArgs_ShowParents, CLI_COMMAND_EXTERNAL,
-                "show:parent", "Parent configuration");
-
-  createCommand("show:remap", Cmd_ShowRemap, NULL, CLI_COMMAND_EXTERNAL, "show:remap", "Remap configuration");
-
-  createCommand("show:socks", Cmd_ShowSocks, CmdArgs_ShowSocks, CLI_COMMAND_EXTERNAL,
-                "show:socks", "SOCKS configuration");
-
-  createCommand("show:scheduled-update", Cmd_ShowScheduledUpdate, CmdArgs_ShowScheduledUpdate, CLI_COMMAND_EXTERNAL,
-                "show:scheduled-update", "Scheduled update configuration");
-
-  createCommand("show:proxy-stats", Cmd_ShowProxyStats, NULL, CLI_COMMAND_EXTERNAL,
-                "show:proxy-stats", "Proxy statistics");
-
-  createCommand("show:http-trans-stats", Cmd_ShowHttpTransStats, NULL, CLI_COMMAND_EXTERNAL,
-                "show:http-trans-stats", "HTTP transaction statistics");
-
-  createCommand("show:http-stats", Cmd_ShowHttpStats, NULL, CLI_COMMAND_EXTERNAL, "show:http-stats", "HTTP statistics");
-
-  createCommand("show:icp-stats", Cmd_ShowIcpStats, NULL, CLI_COMMAND_EXTERNAL, "show:icp-stats", "ICP statistics");
-
-  createCommand("show:cache-stats", Cmd_ShowCacheStats, NULL, CLI_COMMAND_EXTERNAL,
-                "show:cache-stats", "Cache statistics");
-
-  createCommand("show:hostdb-stats", Cmd_ShowHostDbStats, NULL, CLI_COMMAND_EXTERNAL,
-                "show:hostdb-stats", "Host database statistics");
-
-  createCommand("show:dns-stats", Cmd_ShowDnsStats, NULL, CLI_COMMAND_EXTERNAL, "show:dns-stats", "DNS statistics");
-
-  createCommand("show:logging-stats", Cmd_ShowLoggingStats, NULL, CLI_COMMAND_EXTERNAL,
-                "show:logging-stats", "Logging statistics");
-
-  createCommand("show:alarms", Cmd_ShowAlarms, NULL, CLI_COMMAND_EXTERNAL, "show:alarms", "Show active alarms");
-
-  createCommand("show:cluster", Cmd_ShowCluster, NULL, CLI_COMMAND_EXTERNAL,
-                "show:cluster", "Show Cluster Ports Settings");
-
-  createCommand("config:get", Cmd_ConfigGet, NULL, CLI_COMMAND_EXTERNAL,
-                "config:get <variable>", "Display a variable value");
-
-  createCommand("config:set", Cmd_ConfigSet, NULL, CLI_COMMAND_EXTERNAL,
-                "config:set <variable> <value>", "Set variable to specified value");
-
-  createCommand("config:name", Cmd_ConfigName, NULL, CLI_COMMAND_EXTERNAL,
-                "config:name <string>", "Set proxy name <string>");
-
-  createCommand("config:start", Cmd_ConfigStart, NULL, CLI_COMMAND_EXTERNAL, "config:start", "Start proxy software");
-
-  createCommand("config:stop", Cmd_ConfigStop, NULL, CLI_COMMAND_EXTERNAL, "config:stop", "Stop proxy software");
-
-  createCommand("config:hard-restart", Cmd_ConfigHardRestart, NULL, CLI_COMMAND_EXTERNAL,
-                "config:hard-restart", "Perform Hard Restart of all software components");
-
-  createCommand("config:restart", Cmd_ConfigRestart, CmdArgs_ConfigRestart, CLI_COMMAND_EXTERNAL,
-                "config:restart [cluster]", "Perform Restart of proxy software");
-
-  createCommand("config:ssl", Cmd_ConfigSsl, CmdArgs_ConfigSsl, CLI_COMMAND_EXTERNAL,
-                "config:ssl status <on | off>\n" "config:ssl ports <int>", "Configure ssl");
-
-  createCommand("config:parent", Cmd_ConfigParents, CmdArgs_ConfigParents, CLI_COMMAND_EXTERNAL,
-                "config:parent status <on | off>\n"
-                "config:parent name <parent>\n" "config:parent rules <url>", "Update parent configuration");
-
-
-  createCommand("config:remap", Cmd_ConfigRemap, NULL, CLI_COMMAND_EXTERNAL,
-                "config:remap <url>", "Update remap configuration file <url>");
-
-  createCommand("config:clock", Cmd_ConfigClock, CmdArgs_ConfigClock, CLI_COMMAND_EXTERNAL,
-                "config:clock date <mm/dd/yyyy>\n"
-                "config:clock time <hh:mm:ss>\n"
-                "config:clock timezone <number from list | list>", "Configure date, time, timezone");
-
-  createCommand("config:security", Cmd_ConfigSecurity, CmdArgs_ConfigSecurity, CLI_COMMAND_EXTERNAL,
-                "config:security <ip-allow | mgmt-allow | admin> <url-config-file>\n"
-                "config:security password", "Update security configuration");
-
-  createCommand("config:http", Cmd_ConfigHttp, CmdArgs_ConfigHttp, CLI_COMMAND_EXTERNAL,
-                "config:http status <on | off>\n"
-                "config:http <keep-alive-timeout-in | keep-alive-timeout-out> <seconds>\n"
-                "config:http <inactive-timeout-in | inactive-timeout-out> <seconds>\n"
-                "config:http <active-timeout-in | active-timeout-out> <seconds>\n"
-                "config:http <remove-from | remove-referer> <on | off>\n"
-                "config:http <remove-user | remove-cookie> <on | off>\n"
-                "config:http <remove-header> <string>\n"
-                "config:http <insert-ip | remove-ip> <on | off>\n"
-                "config:http proxy <fwd | rev | fwd-rev>", "Configure HTTP");
-
-  createCommand("config:icp", Cmd_ConfigIcp, CmdArgs_ConfigIcp, CLI_COMMAND_EXTERNAL,
-                "config:icp mode <disabled | receive | send-receive>\n"
-                "config:icp port <int>\n"
-                "config:icp multicast <on | off>\n"
-                "config:icp query-timeout <seconds>\n" "config:icp peers <url-config-file>", "Configure ICP");
-
-  createCommand("config:scheduled-update", Cmd_ConfigScheduledUpdate, CmdArgs_ConfigScheduledUpdate,
-                CLI_COMMAND_EXTERNAL,
-                "config:scheduled-update status <on | off>\n" "config:scheduled-update retry-count <int>\n"
-                "config:scheduled-update retry-interval <sec>\n" "config:scheduled-update max-concurrent <int>\n"
-                "config:scheduled-update force-immediate <on | off>\n"
-                "config:scheduled-update rules <url-config-file>", "Configure Scheduled Update");
-
-  createCommand("config:socks", Cmd_ConfigSocks, CmdArgs_ConfigSocks, CLI_COMMAND_EXTERNAL,
-                "config:socks status <on | off>\n"
-                "config:socks version <version>\n"
-                "config:socks default-servers <string>\n"
-                "config:socks accept <on | off>\n" "config:socks accept-port <int>", "Configure Socks");
-
-  createCommand("config:cache", Cmd_ConfigCache, CmdArgs_ConfigCache, CLI_COMMAND_EXTERNAL,
-                "config:cache <http> <on | off>\n"
-                "config:cache ignore-bypass <on | off>\n"
-                "config:cache <max-object-size | max-alternates> <int>\n"
-                "config:cache file <url-config-file>\n"
-                "config:cache freshness verify <when-expired | no-date | always | never>\n"
-                "config:cache freshness minimum <explicit | last-modified | nothing>\n"
-                "config:cache freshness no-expire-limit greater-than <sec> less-than <sec>\n"
-                "config:cache <dynamic | alternates> <on | off>\n"
-                "config:cache vary <text | images | other> <string>\n"
-                "config:cache cookies <none | all | images | non-text>\n" "config:cache clear", "Configure Cache");
-
-
-  createCommand("config:hostdb", Cmd_ConfigHostdb, CmdArgs_ConfigHostdb, CLI_COMMAND_EXTERNAL,
-                "config:hostdb <lookup-timeout | foreground-timeout> <seconds>\n"
-                "config:hostdb <background-timeout | invalid-host-timeout> <seconds>\n"
-                "config:hostdb <re-dns-on-reload> <on | off>\n" "config:hostdb clear", "Configure Host Database");
-
-  createCommand("config:logging", Cmd_ConfigLogging, CmdArgs_ConfigLogging, CLI_COMMAND_EXTERNAL,
-                "config:logging event <enabled | trans-only | error-only | disabled>\n"
-                "config:logging mgmt-directory <string>\n"
-                "config:logging <space-limit | space-headroom> <megabytes>\n"
-                "config:logging collation-status <inactive | host | send-standard |\n"
-                "                                 send-custom | send-all>\n"
-                "config:logging collation-host <string>\n"
-                "config:logging collation secret <string> tagged <on | off> orphan-limit <int>\n"
-                "config:logging format <squid | netscape-common | netscape-ext | netscape-ext2> <on | off>\n"
-                "               type <ascii | binary> file <string> header <string>\n"
-                "config:logging splitting <icp | http> <on | off>\n"
-                "config:logging custom <on | off> format <traditional | xml>\n"
-                "config:logging rolling <on | off> offset <hour> interval <hours>\n"
-                "               auto-delete <on | off>", "Configure Logging");
-
-
-  createCommand("config:dns", Cmd_ConfigDns, CmdArgs_ConfigDns, CLI_COMMAND_EXTERNAL,
-                "config:dns resolve-timeout <seconds>\n" "config:dns retries <int>", "Configure DNS");
-
-  createCommand("config:virtual-ip", Cmd_ConfigVirtualip, CmdArgs_ConfigVirtualip, CLI_COMMAND_EXTERNAL,
-                "config:virtual-ip status <on | off>\n"
-                "config:virtual-ip list\n"
-                "config:virtual-ip add <x.x.x.x> device <string> sub-intf <int>\n"
-                "config:virtual-ip delete <virtual ip number>", "Configure virtual-ip");
-
-  createCommand("config:alarms", Cmd_ConfigAlarm, CmdArgs_ConfigAlarm, CLI_COMMAND_EXTERNAL,
-                "config:alarms resolve-name <string>\n"
-                "config:alarms resolve-number <int>\n"
-                "config:alarms resolve-all\n"
-                "config:alarms notify <on | off>", "Resolve Alarms, Turn notification on/off");
-
-  createCommand("enable", Cmd_Enable, CmdArgs_Enable, CLI_COMMAND_EXTERNAL,
-                "enable \n" "enable status ", "Enable Restricted Commands");
-
-  createCommand("disable", Cmd_Disable, NULL, CLI_COMMAND_EXTERNAL, "disable", "Disable Restricted Commands");
-
-
-  createCommand("debug", DebugCmd, DebugCmdArgs, CLI_COMMAND_EXTERNAL,
-                "debug <on|off>", "Turn debugging print statements on/off");
-
-  createCommand("help", Cmd_Help, NULL, CLI_COMMAND_EXTERNAL,
-                "help [topic]", "Display online help");
-
-  return CLI_OK;
-}
-
-#if defined(__SUNPRO_CC)
-
-// Solaris doesn't like to link libstdc++ code. I don't have a system to test. Sorry.
-
-int
-Cmd_Help(ClientData, Tcl_Interp *, int, const char *[])
-{
-  return CMD_OK;
-}
-
-#else
-
-struct replace_colon
-{
-  char operator() (char c) const {
-    return (c == ':') ? '_' : c;
-  }
-};
-
-static int
-xsystem(const char * cmd)
-{
-  // Some versions of glibc declare system(3) with the warn_unused_result
-  // attribute. Pretend to use the return value so it will shut the hell up.
-  return system(cmd);
-}
-
-int
-Cmd_Help(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * /* interp ATS_UNUSED */, int argc, const char *argv[])
-{
-  Cli_Debug("looking for online help in %s\n", Layout::get()->datadir);
-
-  for (int i = 1; i < argc; ++i) {
-    std::ostringstream  cmd;
-    std::string         topic(argv[i]);
-
-    // Replace ':' with '_' so we can find the right on-disk man page.
-    std::transform(topic.begin(), topic.end(), topic.begin(), replace_colon());
-
-    // Check whether we have the man page on disk before we pass any user input
-    // to the shell via system(3).
-    cmd << Layout::get()->datadir << "/trafficshell/" << topic << ".1";
-    if (access(cmd.str().c_str(), R_OK) != 0) {
-      Cli_Debug("missing %s\n", cmd.str().c_str());
-      continue;
-    }
-
-    cmd.clear();
-    cmd.seekp(std::ios_base::beg);
-
-    cmd << "man "
-      << Layout::get()->datadir << "/trafficshell/" << topic << ".1";
-
-    Cli_Debug("%s\n", cmd.str().c_str());
-    xsystem(cmd.str().c_str());
-  }
-
-  return CMD_OK;
-}
-
-#endif  /* __SUNPRO_C */
-
-// vim: set ts=2 sw=2 et :

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/CliCreateCommands.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/CliCreateCommands.h b/mgmt/cli/CliCreateCommands.h
deleted file mode 100644
index da49ae7..0000000
--- a/mgmt/cli/CliCreateCommands.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/****************************************************************
- * Filename: CliCreateCommands.h
- * Purpose: This file contains the CLI command creation function.
- *
- *
- ****************************************************************/
-
-#ifndef __CLI_CREATE_COMMANDS_H__
-#define __CLI_CREATE_COMMANDS_H__
-
-////////////////////////////////////////////////////////////////
-// Called during Tcl_AppInit, this function creates generic the CLI commands
-//
-int CliCreateCommands();
-
-#endif // __CLI_CREATE_COMMANDS_H__

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/CliDisplay.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/CliDisplay.cc b/mgmt/cli/CliDisplay.cc
deleted file mode 100644
index 74dda07..0000000
--- a/mgmt/cli/CliDisplay.cc
+++ /dev/null
@@ -1,221 +0,0 @@
-/** @file
-
-  Implementation of CliDisplay routines for the use of TB
-
-  @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 "libts.h"
-#include "CliDisplay.h"
-#include "definitions.h"
-#include <string.h>
-
-
-#define BUF_SIZE 1024
-
-extern Tcl_Interp *interp;
-static CliPrintLevelT CliPrintLevel = CLI_PRINT_DEFAULT;
-
-int CliDisplayPrintf = 0;
-
-/*****************************************************************
- * Display one of the predefined error messages.
- */
-int
-Cli_Error(const char *errString, ...)
-{
-  char buffer[BUF_SIZE];
-
-  va_list ap;
-  va_start(ap, errString);
-  // XXX/amitk ugh. easy buffer overrun.
-  // why isn't vsnprintf always available??
-  vsprintf(buffer, errString, ap);
-  va_end(ap);
-
-  // fix for BZ27769
-  //   libtrafficshell.a standalone uses Tcl_AppendResult
-  //   traffic_shell binary uses printf
-  if (CliDisplayPrintf) {
-    printf("%s", buffer);
-  } else {
-    Tcl_AppendResult(interp, buffer, (char *) NULL);
-  }
-
-  return CLI_OK;
-}
-
-/****************************************************************
- * Set print level
- *   level = CLI_PRINT_DEFAULT (Cli_Printf)
- *   level = CLI_PRINT_INFO    (Cli_Printf, Cli_Info)
- *   level = CLI_PRINT_DEBUG   (Cli_Printf, Cli_Debug)
- *   level = CLI_PRINT_INFO | CLI_PRINT_DEBUG  (Cli_Printf, Cli_Debug, Cli_Info)
- */
-int
-Cli_SetPrintLevel(CliPrintLevelT level)
-{
-  CliPrintLevel = level;
-  return CLI_OK;
-
-}
-
-/****************************************************************
- * return the current print level
- */
-CliPrintLevelT
-Cli_GetPrintLevel()
-{
-  return CliPrintLevel;
-}
-
-/****************************************************************
- * Display string
- */
-int
-Cli_Printf(const char *string, ...)
-{
-  char buffer[BUF_SIZE];
-  va_list ap;
-
-  va_start(ap, string);
-  vsprintf(buffer, string, ap);
-  va_end(ap);
-
-  // fix for BZ27769
-  //   libtrafficshell.a standalone uses Tcl_AppendResult
-  //   traffic_shell binary uses printf
-  if (CliDisplayPrintf) {
-    printf("%s", buffer);
-  } else {
-    Tcl_AppendResult(interp, buffer, (char *) NULL);
-  }
-
-  return CLI_OK;
-}
-
-/****************************************************************
- * Display informative message
- */
-int
-Cli_Info(const char *string, ...)
-{
-  char buffer[BUF_SIZE];
-  va_list ap;
-
-  va_start(ap, string);
-  if (CliPrintLevel & CLI_PRINT_INFO) {
-    vsprintf(buffer, string, ap);
-
-    // fix for BZ27769
-    //   libtrafficshell.a standalone uses Tcl_AppendResult
-    //   traffic_shell binary uses printf
-    if (CliDisplayPrintf) {
-      printf("%s", buffer);
-    } else {
-      Tcl_AppendResult(interp, buffer, (char *) NULL);
-    }
-  }
-  va_end(ap);
-
-  return CLI_OK;
-}
-
-
-/****************************************************************
- * Display debug statement
- */
-int
-Cli_Debug(const char *string, ...)
-{
-  char buffer[BUF_SIZE];
-  va_list ap;
-
-  // allocate enough room for "debug: " at beginning of string
-  const size_t new_string_size = strlen(string) + 8;
-  char *new_string = (char *)alloca(new_string_size);
-  ink_strlcpy(new_string, "debug: ", new_string_size);
-  ink_strlcat(new_string, string, new_string_size );
-
-  va_start(ap, string);
-  if (CliPrintLevel & CLI_PRINT_DEBUG) {
-    vsprintf(buffer, new_string, ap);
-
-    // fix for BZ27769
-    //   libtrafficshell.a standalone uses Tcl_AppendResult
-    //   traffic_shell binary uses printf
-    if (CliDisplayPrintf) {
-      printf("%s", buffer);
-    } else {
-      Tcl_AppendResult(interp, buffer, (char *) NULL);
-    }
-  }
-  va_end(ap);
-
-  return CLI_OK;
-}
-
-int
-Cli_PrintEnable(const char *string, int flag)
-{
-  if (flag == 0)
-    Cli_Printf("%soff\n", string);
-  else if (flag == 1)
-    Cli_Printf("%son\n", string);
-  else {
-    Cli_Debug(ERR_INVALID_PARAMETER);
-    return CLI_ERROR;
-  }
-
-  return CLI_OK;
-}
-
-int
-Cli_PrintOnOff(int flag)
-{
-  switch (flag) {
-  case 0:
-    Cli_Printf("off\n");
-    break;
-  case 1:
-    Cli_Printf("on\n");
-    break;
-  default:
-    Cli_Printf("?\n");
-    break;
-  }
-  return CLI_OK;
-}
-
-int
-Cli_PrintArg(int arg_index, const cli_parsedArgInfo * argtable)
-{
-
-
-
-  if (arg_index >= 0) {
-    Cli_Debug("%d %d %s\n", argtable[arg_index].parsed_args,
-              argtable[arg_index].arg_int, argtable[arg_index].arg_string);
-    return CLI_OK;
-  }
-  return CLI_ERROR;
-}
-
-#undef BUF_SIZE

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/CliDisplay.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/CliDisplay.h b/mgmt/cli/CliDisplay.h
deleted file mode 100644
index be47db4..0000000
--- a/mgmt/cli/CliDisplay.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/****************************************************************
- * Filename: CliDisplay.h
- * Purpose: This file contains the CLI display routines.
- *
- *
- ****************************************************************/
-
-#include <stdarg.h>
-#include <stdio.h>
-#include "createArgument.h"
-
-#ifndef __CLI_ERROR_HANDLE_H__
-#define __CLI_ERROR_HANDLE_H__
-
-/* CLI print levels
- */
-typedef enum
-{
-  CLI_PRINT_DEFAULT = 0x0,
-  CLI_PRINT_INFO = 0x2,
-  CLI_PRINT_DEBUG = 0x4
-} CliPrintLevelT;
-
-/* All possible error strings are defined below.
- *    In the future, this could be changed to a message_id/lookup mechanism.
- */
-
-#define ERR_RECORD_GET         "INKRecordGet: failed to retrieve %s\n"
-#define ERR_RECORD_GET_INT     "INKRecordGetInt: failed to retrieve %s\n"
-#define ERR_RECORD_GET_COUNTER "INKRecordGetCounter: failed to retrieve %s\n"
-#define ERR_RECORD_GET_FLOAT   "INKRecordGetFloat: failed to retrieve %s\n"
-#define ERR_RECORD_GET_STRING  "INKRecordGetString: failed to retrieve %s\n"
-#define ERR_RECORD_SET         "INKRecordSet: failed to set %s value %s\n"
-#define ERR_RECORD_SET_INT     "INKRecordSetInt: failed to set %s value %d\n"
-#define ERR_RECORD_SET_FLOAT   "INKRecordSetFloat: failed to set %s value %f\n"
-#define ERR_RECORD_SET_STRING  "INKRecordSetString: failed to set %s value %s\n"
-
-
-#define ERR_COMMAND_SYNTAX    "\nCommand Syntax: \n%s\n\n"
-#define ERR_REQ_ACTION_UNDEF  "Undefined Action Required before Changes Take Effect\n"
-#define ERR_TOO_MANY_ARGS     "\nToo many arguments specified.\n"
-
-#define ERR_INVALID_COMMAND   "wrong # args: should be \n"
-#define ERR_INVALID_PARAMETER "Invalid Parameter\n"
-#define ERR_MISSING_PARAMETER "Missing Parameter\n"
-
-#define ERR_PROXY_STATE_ALREADY "Proxy is already %s\n" // on/off
-#define ERR_PROXY_STATE_SET     "Unable to set Proxy %s\n"      // on/off
-
-#define ERR_CONFIG_FILE_READ  "Error Reading Rules File %d\n"
-#define ERR_CONFIG_FILE_WRITE "Error Writing Rules File %d\n"
-#define ERR_READ_FROM_URL     "Error Reading File from URL %s\n"
-
-#define ERR_ALARM_LIST        "Error Retrieving Alarm List\n"
-#define ERR_ALARM_STATUS      "Error Determining Active/Inactive status of alarm %s\n"
-#define ERR_ALARM_RESOLVE_INACTIVE "Error: Attempt to resolve inactive alarm %s\n"
-#define ERR_ALARM_RESOLVE     "Errur: Unable to resolve alarm %s\n"
-#define ERR_ALARM_RESOLVE_NUMBER "Error: Alarm number non-existent\n"
-
-int Cli_Error(const char *errString, ...);
-int Cli_SetPrintLevel(CliPrintLevelT level);
-CliPrintLevelT Cli_GetPrintLevel();
-int Cli_Printf(const char *string, ...);
-int Cli_Debug(const char *string, ...);
-int Cli_PrintEnable(const char *string, int flag);
-int Cli_PrintOnOff(int flag);
-int Cli_PrintArg(int arg_index, const cli_parsedArgInfo * argtable);
-#endif // __CLI_ERROR_HANDLE_H__


[38/44] convert CRLF->LF, make sure it never happens again

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/cache-data-structures.en.rst
----------------------------------------------------------------------
diff --git a/doc/arch/cache/cache-data-structures.en.rst b/doc/arch/cache/cache-data-structures.en.rst
old mode 100755
new mode 100644
index 6ce9bc8..508c4da
--- a/doc/arch/cache/cache-data-structures.en.rst
+++ b/doc/arch/cache/cache-data-structures.en.rst
@@ -1,164 +1,164 @@
-.. 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.
-
-Cache Data Structures
-******************************
-
-.. include:: common.defs
-
-.. cpp:class:: OpenDir
-
-   An open directory entry. It contains all the information of a :cpp:class:`Dir` plus additional information from the first :cpp:class:`Doc`.
-
-.. cpp:class:: CacheVC
-
-   A virtual connection class which accepts input for writing to cache.
-
-.. cpp:function:: int CacheVC::openReadStartHead(int event, Event* e)
-
-   Do the initial read for a cached object.
-
-.. cpp:function:: int CacheVC::openReadStartEarliest(int event, Event* e)
-
-   Do the initial read for an alternate of an object.
-
-.. cpp:class:: HttpTunnel
-
-   Data transfer driver. This contains a set of *producers*. Each producer is connected to one or more *consumers*. The tunnel handles events and buffers so that data moves from producers to consumers. The data, as much as possible, is kept in reference counted buffers so that copies are done only when the data is modified or for sources (which acquire data from outside |TS|) and sinks (which move data to outside |TS|).
-
-.. cpp:class:: CacheControlResult
-
-   Holds the data from a line in :file:`cache.config`.
-
-.. cpp:class:: CacheHTTPInfoVector
-
-   Defined in |P-CacheHttp.h|_. This is an array of :cpp:class:`HTTPInfo` objects and serves as the respository of information about alternates of an object. It is marshaled as part of the metadata for an object in the cache.
-
-.. cpp:class:: HTTPInfo
-
-   Defined in |HTTP.h|_.
-
-   This class is a wrapper for :cpp:class:`HTTPCacheAlt`. It provides the external API for accessing data in the wrapped class. It contains only a pointer (possibly ``NULL``) to an instance of the wrapped class.
-
-.. cpp:class:: CacheHTTPInfo
-
-   A typedef for :cpp:class:`HTTPInfo`.
-
-.. cpp:class:: HTTPCacheAlt
-
-   Defined in |HTTP.h|_.
-
-   This is the metadata for a single alternate for a cached object. In contains among other data
-
-   * The key for the earliest ``Doc`` of the alternate.
-   * The request and response headers.
-   * The fragment offset table. [#]_
-   * Timestamps for request and response from origin server.
-
-.. cpp:class:: EvacuationBlock
-
-    Record for evacuation.
-
-.. cpp:class:: Vol
-
-   This represents a storage unit inside a cache volume.
-
-   .. cpp:member:: off_t Vol::segments
-
-      The number of segments in the volume. This will be roughly the total number of entries divided by the number of entries in a segment. It will be rounded up to cover all entries.
-
-   .. cpp:member:: off_t Vol::buckets
-
-      The number of buckets in the volume. This will be roughly the number of entries in a segment divided by ``DIR_DEPTH``. For currently defined values this is around 16,384 (2^16 / 4). Buckets are used as the targets of the index hash.
-
-   .. cpp:member:: DLL\<EvacuationBlock\> Vol::evacuate
-
-      Array of of :cpp:class:`EvacuationBlock` buckets. This is sized so there is one bucket for every evacuation span.
-
-   .. cpp:member:: off_t len
-
-      Length of stripe in bytes.
-
-.. cpp:function:: int Vol::evac_range(off_t low, off_t high, int evac_phase)
-
-   Start an evacuation if there is any :cpp:class:`EvacuationBlock` in the range from *low* to *high*. Return 0 if no evacuation was started, non-zero otherwise.
-
-.. cpp:class:: CacheVol
-
-   A cache volume as described in :file:`volume.config`.
-
-.. cpp:class:: Doc
-
-   Defined in |P-CacheVol.h|_.
-
-   .. cpp:member:: uint32_t Doc::magic
-
-      Validity check value. Set to ``DOC_MAGIC`` for a valid document.
-
-   .. cpp:member:: uint32_t Doc::len
-
-      The length of this segment including the header length, fragment table, and this structure.
-
-   .. cpp:member:: uint64_t Doc::total_len
-
-      Total length of the entire document not including meta data but including headers.
-
-   .. cpp:member:: INK_MD5 Doc::first_key
-
-      First index key in the document (the index key used to locate this object in the volume index).
-
-   .. cpp:member:: INK_MD5 Doc::key
-
-      The index key for this fragment. Fragment keys are computationally chained so that the key for the next and previous fragments can be computed from this key.
-
-   .. cpp:member:: uint32_t Doc::hlen
-
-      Document header (metadata) length. This is not the length of the HTTP headers.
-
-   .. cpp:member:: uint8_t Doc::ftype
-
-      Fragment type. Currently only `CACHE_FRAG_TYPE_HTTP` is used. Other types may be used for cache extensions if those are ever used / implemented.
-
-   .. cpp:member:: uint24_t Doc::flen
-
-      Fragment table length, if any. Only the first ``Doc`` in an object should contain a fragment table.
-
-      The fragment table is a list of offsets relative to the HTTP content (not counting metadata or HTTP headers). Each offset is the byte offset of the first byte in the fragment. The first element in the table is the second fragment (what would be index 1 for an array). The offset for the first fragment is of course always zero and so not stored. The purpose of this is to enable a fast seek for range requests - given the first ``Doc`` the fragment containing the first byte in the range can be computed and loaded directly without further disk access.
-
-      Removed as of version 3.3.0.
-
-   .. cpp:member:: uint32_t Doc::sync_serial
-
-      Unknown.
-
-   .. cpp:member:: uint32_t Doc::write_serial
-
-      Unknown.
-
-   .. cpp:member:: uint32_t pinned
-
-      Flag and timer for pinned objects.
-
-   .. cpp:member:: uint32_t checksum
-
-      Unknown. (A checksum of some sort)
-
-.. cpp:class:: VolHeaderFooter
-
-.. rubric:: Footnotes
-
-.. [#] Changed in version 3.2.0. This previously resided in the first ``Doc`` but that caused different alternates to share the same fragment table.
+.. 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.
+
+Cache Data Structures
+******************************
+
+.. include:: common.defs
+
+.. cpp:class:: OpenDir
+
+   An open directory entry. It contains all the information of a :cpp:class:`Dir` plus additional information from the first :cpp:class:`Doc`.
+
+.. cpp:class:: CacheVC
+
+   A virtual connection class which accepts input for writing to cache.
+
+.. cpp:function:: int CacheVC::openReadStartHead(int event, Event* e)
+
+   Do the initial read for a cached object.
+
+.. cpp:function:: int CacheVC::openReadStartEarliest(int event, Event* e)
+
+   Do the initial read for an alternate of an object.
+
+.. cpp:class:: HttpTunnel
+
+   Data transfer driver. This contains a set of *producers*. Each producer is connected to one or more *consumers*. The tunnel handles events and buffers so that data moves from producers to consumers. The data, as much as possible, is kept in reference counted buffers so that copies are done only when the data is modified or for sources (which acquire data from outside |TS|) and sinks (which move data to outside |TS|).
+
+.. cpp:class:: CacheControlResult
+
+   Holds the data from a line in :file:`cache.config`.
+
+.. cpp:class:: CacheHTTPInfoVector
+
+   Defined in |P-CacheHttp.h|_. This is an array of :cpp:class:`HTTPInfo` objects and serves as the respository of information about alternates of an object. It is marshaled as part of the metadata for an object in the cache.
+
+.. cpp:class:: HTTPInfo
+
+   Defined in |HTTP.h|_.
+
+   This class is a wrapper for :cpp:class:`HTTPCacheAlt`. It provides the external API for accessing data in the wrapped class. It contains only a pointer (possibly ``NULL``) to an instance of the wrapped class.
+
+.. cpp:class:: CacheHTTPInfo
+
+   A typedef for :cpp:class:`HTTPInfo`.
+
+.. cpp:class:: HTTPCacheAlt
+
+   Defined in |HTTP.h|_.
+
+   This is the metadata for a single alternate for a cached object. In contains among other data
+
+   * The key for the earliest ``Doc`` of the alternate.
+   * The request and response headers.
+   * The fragment offset table. [#]_
+   * Timestamps for request and response from origin server.
+
+.. cpp:class:: EvacuationBlock
+
+    Record for evacuation.
+
+.. cpp:class:: Vol
+
+   This represents a storage unit inside a cache volume.
+
+   .. cpp:member:: off_t Vol::segments
+
+      The number of segments in the volume. This will be roughly the total number of entries divided by the number of entries in a segment. It will be rounded up to cover all entries.
+
+   .. cpp:member:: off_t Vol::buckets
+
+      The number of buckets in the volume. This will be roughly the number of entries in a segment divided by ``DIR_DEPTH``. For currently defined values this is around 16,384 (2^16 / 4). Buckets are used as the targets of the index hash.
+
+   .. cpp:member:: DLL\<EvacuationBlock\> Vol::evacuate
+
+      Array of of :cpp:class:`EvacuationBlock` buckets. This is sized so there is one bucket for every evacuation span.
+
+   .. cpp:member:: off_t len
+
+      Length of stripe in bytes.
+
+.. cpp:function:: int Vol::evac_range(off_t low, off_t high, int evac_phase)
+
+   Start an evacuation if there is any :cpp:class:`EvacuationBlock` in the range from *low* to *high*. Return 0 if no evacuation was started, non-zero otherwise.
+
+.. cpp:class:: CacheVol
+
+   A cache volume as described in :file:`volume.config`.
+
+.. cpp:class:: Doc
+
+   Defined in |P-CacheVol.h|_.
+
+   .. cpp:member:: uint32_t Doc::magic
+
+      Validity check value. Set to ``DOC_MAGIC`` for a valid document.
+
+   .. cpp:member:: uint32_t Doc::len
+
+      The length of this segment including the header length, fragment table, and this structure.
+
+   .. cpp:member:: uint64_t Doc::total_len
+
+      Total length of the entire document not including meta data but including headers.
+
+   .. cpp:member:: INK_MD5 Doc::first_key
+
+      First index key in the document (the index key used to locate this object in the volume index).
+
+   .. cpp:member:: INK_MD5 Doc::key
+
+      The index key for this fragment. Fragment keys are computationally chained so that the key for the next and previous fragments can be computed from this key.
+
+   .. cpp:member:: uint32_t Doc::hlen
+
+      Document header (metadata) length. This is not the length of the HTTP headers.
+
+   .. cpp:member:: uint8_t Doc::ftype
+
+      Fragment type. Currently only `CACHE_FRAG_TYPE_HTTP` is used. Other types may be used for cache extensions if those are ever used / implemented.
+
+   .. cpp:member:: uint24_t Doc::flen
+
+      Fragment table length, if any. Only the first ``Doc`` in an object should contain a fragment table.
+
+      The fragment table is a list of offsets relative to the HTTP content (not counting metadata or HTTP headers). Each offset is the byte offset of the first byte in the fragment. The first element in the table is the second fragment (what would be index 1 for an array). The offset for the first fragment is of course always zero and so not stored. The purpose of this is to enable a fast seek for range requests - given the first ``Doc`` the fragment containing the first byte in the range can be computed and loaded directly without further disk access.
+
+      Removed as of version 3.3.0.
+
+   .. cpp:member:: uint32_t Doc::sync_serial
+
+      Unknown.
+
+   .. cpp:member:: uint32_t Doc::write_serial
+
+      Unknown.
+
+   .. cpp:member:: uint32_t pinned
+
+      Flag and timer for pinned objects.
+
+   .. cpp:member:: uint32_t checksum
+
+      Unknown. (A checksum of some sort)
+
+.. cpp:class:: VolHeaderFooter
+
+.. rubric:: Footnotes
+
+.. [#] Changed in version 3.2.0. This previously resided in the first ``Doc`` but that caused different alternates to share the same fragment table.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/images/ats-cache-write-cursor.png
----------------------------------------------------------------------
diff --git a/doc/arch/cache/images/ats-cache-write-cursor.png b/doc/arch/cache/images/ats-cache-write-cursor.png
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/images/cache-directory-structure.png
----------------------------------------------------------------------
diff --git a/doc/arch/cache/images/cache-directory-structure.png b/doc/arch/cache/images/cache-directory-structure.png
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/images/cache-doc-layout-3-2-0.png
----------------------------------------------------------------------
diff --git a/doc/arch/cache/images/cache-doc-layout-3-2-0.png b/doc/arch/cache/images/cache-doc-layout-3-2-0.png
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/images/cache-doc-layout-4-0-1.png
----------------------------------------------------------------------
diff --git a/doc/arch/cache/images/cache-doc-layout-4-0-1.png b/doc/arch/cache/images/cache-doc-layout-4-0-1.png
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/images/cache-multi-fragment.png
----------------------------------------------------------------------
diff --git a/doc/arch/cache/images/cache-multi-fragment.png b/doc/arch/cache/images/cache-multi-fragment.png
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/images/cache-stripe-layout.png
----------------------------------------------------------------------
diff --git a/doc/arch/cache/images/cache-stripe-layout.png b/doc/arch/cache/images/cache-stripe-layout.png
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/images/dir-bucket-assign.png
----------------------------------------------------------------------
diff --git a/doc/arch/cache/images/dir-bucket-assign.png b/doc/arch/cache/images/dir-bucket-assign.png
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/images/dir-segment-bucket.png
----------------------------------------------------------------------
diff --git a/doc/arch/cache/images/dir-segment-bucket.png b/doc/arch/cache/images/dir-segment-bucket.png
old mode 100755
new mode 100644

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/70c70caf/doc/arch/cache/tier-storage.en.rst
----------------------------------------------------------------------
diff --git a/doc/arch/cache/tier-storage.en.rst b/doc/arch/cache/tier-storage.en.rst
old mode 100755
new mode 100644
index a379a27..b802929
--- a/doc/arch/cache/tier-storage.en.rst
+++ b/doc/arch/cache/tier-storage.en.rst
@@ -1,118 +1,118 @@
-.. 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.
-
-==============================
-Tiered Storage Design
-==============================
-
-.. include:: common.defs
-
---------------
-Introduction
---------------
-
-Tiered storage is an attempt to allow |TS| to take advantage of physical storage with different properties. This design
-concerns only mechanism. Policies to take advantage of these are outside of the scope of this document. Instead we will
-presume an *oracle* which implements this policy and describe the queries that must be answered by the oracle and the
-effects of the answers.
-
-Beyond avoiding question of tier policy the design is also intended to be effectively identical to current operations
-for the case where there is only one tier.
-
-The most common case for tiers is an ordered list of tiers, where higher tiers are presumed faster but more expensive
-(or more limited in capacity). This is not required. It might be that different tiers are differentiated by other
-properties (such as expected persistence). The design here is intended to handle both cases.
-
-The design presumes that if a user has multiple tiers of storage and an ordering for those tiers, he will usually want
-content stored at one tier level to also be stored at every other lower level as well, so that it does not have to be
-copied if evicted from a higher tier.
-
--------------
-Configuration
--------------
-
-Each storage unit in :file:`storage.config` can be marked with a *quality* value which is 32 bit number. Storage units
-that are not marked are all assigned the same value which is guaranteed to be distinct from all explicit values. The
-quality value is arbitrary from the point of view of this design, serving as a tag rather than a numeric value. The user
-(via the oracle) can impose what ever additional meaning is useful on this value (rating, bit slicing, etc.). In such
-cases all volumes should be explicitly assigned a value, as the default / unmarked value is not guaranteed to have any
-relationship to explicit values. The unmarked value is intended to be useful in situations where the user has no
-interest in tiered storage and so wants to let Traffic Server automatically handle all volumes as a single tier.
-
--------------
-Operations
--------------
-
-After a client request is received and processed, volume assignment is done. This would be changed to do volume assignment across all tiers simultaneously. For each tier the oracle would return one of four values along with a volume pointer.
-
-`READ`
-    The tier appears to have the object and can serve it.
-
-`WRITE`
-    The object is not in this tier and should be written to this tier if possible.
-
-`RW`
-    Treat as `READ` if possible but if the object turns out to not in the cache treat as `WRITE`.
-
-`NO_SALE`
-    Do not interact with this tier for this object.
-
-The volume returned for the tier must be a volume with the corresponding tier quality value. In effect the current style
-of volume assignment is done for each tier, by assigning one volume out of all of the volumes of the same quality and
-returning one of `RW` or `WRITE` depending on whether the initial volume directory lookup succeeds. Note that as with
-current volume assignment it is presumed this can be done from in memory structures (no disk I/O required).
-
-If the oracle returns `READ` or `RW` for more than one tier, it must also return an ordering for those tiers (it may
-return an ordering for all tiers, ones that are not readable will be ignored). For each tier, in that order, a read of
-cache storage is attempted for the object. A successful read locks that tier as the provider of cached content. If no
-tier has a successful read, or no tier is marked `READ` or `RW` then it is a cache miss. Any tier marked `RW` that fails
-the read test is demoted to `WRITE`.
-
-If the object is cached every tier that returns `WRITE` receives the object to store in the selected volume (this
-includes `RW` returns that are demoted to `WRITE`). This is a cache to cache copy, not from the origin server. In this
-case tiers marked `RW` that are not tested for read will not receive any data and will not be further involved in the
-request processing.
-
-For a cache miss, all tiers marked `WRITE` will receive data from the origin server connection (if successful).
-
-This means, among other things, that if there is a tier with the object all other tiers that are written will get a
-local copy of the object, the origin server will not be used. In terms of implementation, currently a cache write to a
-volume is done via the construction of an instance of `CacheVC` which recieves the object stream. For tiered storage the
-same thing is done for each target volume.
-
-For cache volume overrides (e.g. via :file:`hosting.config`) this same process is used except with only the volumes
-stripes contained within the specified cache volume.
-
--------
-Copying
--------
-
-It may be necessary to provide a mechanism to copy objects between tiers outside of a client originated transaction. In
-terms of implementation this is straight forward using `HttpTunnel` as if in a transaction only using a `CacheVC`
-instance for both the producer and consumer. The more difficult question is what event would trigger a possible copy. A
-signal could be provided whenever a volume directory entry is deleted although it should be noted that the object in
-question may have already been evicted when this event happens.
-
-----------------
-Additional Notes
-----------------
-
-As an example use, it would be possible to have only one cache volume that uses tiered storage for a particular set of
-domains using volume tagging. :file:`hosting.config` would be used to direct those domains to the selected cache volume.
-The oracle would check the URL in parallel and return `NO_SALE` for the tiers in the target cache volume for other
-domains. For the other tier (that of the unmarked storage units) the oracle would return `RW` for the tier in all cases
-as that tier would not be queried for the target domains.
+.. 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.
+
+==============================
+Tiered Storage Design
+==============================
+
+.. include:: common.defs
+
+--------------
+Introduction
+--------------
+
+Tiered storage is an attempt to allow |TS| to take advantage of physical storage with different properties. This design
+concerns only mechanism. Policies to take advantage of these are outside of the scope of this document. Instead we will
+presume an *oracle* which implements this policy and describe the queries that must be answered by the oracle and the
+effects of the answers.
+
+Beyond avoiding question of tier policy the design is also intended to be effectively identical to current operations
+for the case where there is only one tier.
+
+The most common case for tiers is an ordered list of tiers, where higher tiers are presumed faster but more expensive
+(or more limited in capacity). This is not required. It might be that different tiers are differentiated by other
+properties (such as expected persistence). The design here is intended to handle both cases.
+
+The design presumes that if a user has multiple tiers of storage and an ordering for those tiers, he will usually want
+content stored at one tier level to also be stored at every other lower level as well, so that it does not have to be
+copied if evicted from a higher tier.
+
+-------------
+Configuration
+-------------
+
+Each storage unit in :file:`storage.config` can be marked with a *quality* value which is 32 bit number. Storage units
+that are not marked are all assigned the same value which is guaranteed to be distinct from all explicit values. The
+quality value is arbitrary from the point of view of this design, serving as a tag rather than a numeric value. The user
+(via the oracle) can impose what ever additional meaning is useful on this value (rating, bit slicing, etc.). In such
+cases all volumes should be explicitly assigned a value, as the default / unmarked value is not guaranteed to have any
+relationship to explicit values. The unmarked value is intended to be useful in situations where the user has no
+interest in tiered storage and so wants to let Traffic Server automatically handle all volumes as a single tier.
+
+-------------
+Operations
+-------------
+
+After a client request is received and processed, volume assignment is done. This would be changed to do volume assignment across all tiers simultaneously. For each tier the oracle would return one of four values along with a volume pointer.
+
+`READ`
+    The tier appears to have the object and can serve it.
+
+`WRITE`
+    The object is not in this tier and should be written to this tier if possible.
+
+`RW`
+    Treat as `READ` if possible but if the object turns out to not in the cache treat as `WRITE`.
+
+`NO_SALE`
+    Do not interact with this tier for this object.
+
+The volume returned for the tier must be a volume with the corresponding tier quality value. In effect the current style
+of volume assignment is done for each tier, by assigning one volume out of all of the volumes of the same quality and
+returning one of `RW` or `WRITE` depending on whether the initial volume directory lookup succeeds. Note that as with
+current volume assignment it is presumed this can be done from in memory structures (no disk I/O required).
+
+If the oracle returns `READ` or `RW` for more than one tier, it must also return an ordering for those tiers (it may
+return an ordering for all tiers, ones that are not readable will be ignored). For each tier, in that order, a read of
+cache storage is attempted for the object. A successful read locks that tier as the provider of cached content. If no
+tier has a successful read, or no tier is marked `READ` or `RW` then it is a cache miss. Any tier marked `RW` that fails
+the read test is demoted to `WRITE`.
+
+If the object is cached every tier that returns `WRITE` receives the object to store in the selected volume (this
+includes `RW` returns that are demoted to `WRITE`). This is a cache to cache copy, not from the origin server. In this
+case tiers marked `RW` that are not tested for read will not receive any data and will not be further involved in the
+request processing.
+
+For a cache miss, all tiers marked `WRITE` will receive data from the origin server connection (if successful).
+
+This means, among other things, that if there is a tier with the object all other tiers that are written will get a
+local copy of the object, the origin server will not be used. In terms of implementation, currently a cache write to a
+volume is done via the construction of an instance of `CacheVC` which recieves the object stream. For tiered storage the
+same thing is done for each target volume.
+
+For cache volume overrides (e.g. via :file:`hosting.config`) this same process is used except with only the volumes
+stripes contained within the specified cache volume.
+
+-------
+Copying
+-------
+
+It may be necessary to provide a mechanism to copy objects between tiers outside of a client originated transaction. In
+terms of implementation this is straight forward using `HttpTunnel` as if in a transaction only using a `CacheVC`
+instance for both the producer and consumer. The more difficult question is what event would trigger a possible copy. A
+signal could be provided whenever a volume directory entry is deleted although it should be noted that the object in
+question may have already been evicted when this event happens.
+
+----------------
+Additional Notes
+----------------
+
+As an example use, it would be possible to have only one cache volume that uses tiered storage for a particular set of
+domains using volume tagging. :file:`hosting.config` would be used to direct those domains to the selected cache volume.
+The oracle would check the URL in parallel and return `NO_SALE` for the tiers in the target cache volume for other
+domains. For the other tier (that of the unmarked storage units) the oracle would return `RW` for the tier in all cases
+as that tier would not be queried for the target domains.


[12/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/ConfigCmd.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/ConfigCmd.cc b/mgmt/cli/ConfigCmd.cc
deleted file mode 100644
index a40da20..0000000
--- a/mgmt/cli/ConfigCmd.cc
+++ /dev/null
@@ -1,4626 +0,0 @@
-/** @file
-
-  This file contains the CLI's "config" command implementation.
-
-  @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.
- 
-  @section description createArgument("timezone",1,CLI_ARGV_OPTION_INT_VALUE,
-		  (char*)NULL, CMD_CONFIG_TIMEZONE, "Time Zone",
-                  (char*)NULL);
- */
-
-
-#include "libts.h"
-#include "I_Layout.h"
-#include "mgmtapi.h"
-#include "ShowCmd.h"
-#include "ConfigCmd.h"
-#include "createArgument.h"
-#include "CliMgmtUtils.h"
-#include "CliDisplay.h"
-// TODO: Remove all those system defines
-//       and protecect them via #ifdef HAVE_FOO_H
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <termios.h>
-#include <stdarg.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <sys/time.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#include <sys/wait.h>
-#include <errno.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-
-bool enable_restricted_commands = false;
-
-static int find_value(const char *pathname, const char *key, char *value, int value_len, const char *delim, int no);
-
-int
-u_getch(void)
-{
-  static signed int returned = (-1), fd;
-  static struct termios new_io_settings, old_io_settings;
-  fd = fileno(stdin);
-  tcgetattr(fd, &old_io_settings);
-  new_io_settings = old_io_settings;
-  new_io_settings.c_lflag &= ~(ICANON | ECHO);
-  tcsetattr(fd, TCSANOW, &new_io_settings);
-  returned = getchar();
-  tcsetattr(fd, TCSANOW, &old_io_settings);
-  return returned;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_Enable
-//
-// This is the callback
-// function for the "enable" command.
-// TODO: This currently doesn't do anything, these commands are
-//       always available.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_Enable(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable, *infoPtr;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-  infoPtr = argtable;
-
-  /* Add "enable status" to check the status of enable/disable */
-  if (argc == 2) {
-    switch (infoPtr->parsed_args) {
-    case CMD_ENABLE_STATUS:
-      if (enable_restricted_commands == true) {
-        Cli_Printf("on\n");
-        return CMD_OK;
-      } else {
-        Cli_Printf("off\n");
-        return CMD_ERROR;
-      }
-    default:
-      Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-      return CMD_ERROR;
-    }
-  }
-
-  if (enable_restricted_commands == true) {
-    Cli_Printf("Already Enabled\n");
-    return CMD_OK;
-  }
-
-  // TODO: replace this assert with appropriate authentication
-  ink_release_assert(enable_restricted_commands);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_Enable
-//
-// Register "enable" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_Enable()
-{
-
-  createArgument("status", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_ENABLE_STATUS, "Check Enable Status", (char *) NULL);
-  return CLI_OK;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_Disable
-//
-// This is the callback
-// function for the "disable" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_Disable(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (getuid() == 0) {
-    Cli_Printf("root user cannot \"disable\"\n");
-    return 0;
-  }
-
-  enable_restricted_commands = false;
-  return 0;
-}
-
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_Config
-//
-// This is the callback function for the "config" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_Config(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  char *cmdinfo, *temp;
-  int i = 0;
-
-  Cli_Debug("Cmd_Config\n");
-  Tcl_Eval(interp, "info commands config* ");
-
-  size_t cmdinfo_len = strlen(Tcl_GetStringResult(interp)) + 2;
-  cmdinfo = (char *)alloca(sizeof(char) * cmdinfo_len);
-  ink_strlcpy(cmdinfo, Tcl_GetStringResult(interp), cmdinfo_len);
-  size_t temp_len = strlen(cmdinfo) + 20;
-  temp = (char *)alloca(sizeof(char) * temp_len);
-  ink_strlcpy(temp, "lsort \"", temp_len);
-  ink_strlcat(temp, cmdinfo, temp_len);
-  ink_strlcat(temp, "\"", temp_len);
-
-  Tcl_Eval(interp, temp);
-  ink_strlcpy(cmdinfo, Tcl_GetStringResult(interp), cmdinfo_len);
-  i = i + strlen("config ");
-  while (cmdinfo[i] != 0) {
-    if (cmdinfo[i] == ' ') {
-      cmdinfo[i] = '\n';
-    }
-    i++;
-  }
-  cmdinfo[i] = '\n';
-  i++;
-  cmdinfo[i] = 0;
-  Cli_Printf("Following are the available config commands\n");
-  Cli_Printf(cmdinfo + strlen("config "));
-
-  return CLI_OK;
-
-}
-
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_Config
-//
-// Register "config" command arguments with the Tcl interpreter.
-//
-int
-CmdArgs_Config()
-{
-  Cli_Debug("CmdArgs_Config\n");
-
-  return CLI_OK;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigGet
-//
-// This is the callback function for the "config:get" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigGet(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:get") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-
-  Cli_Debug("Cmd_ConfigGet argc %d\n", argc);
-
-  if (argc == 2) {
-    return (ConfigGet(argv[1]));
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigSet
-//
-// This is the callback function for the "config:set" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigSet(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:set") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-
-  Cli_Debug("Cmd_ConfigSet argc %d\n", argc);
-
-  if (argc == 3) {
-    return (ConfigSet(argv[1], argv[2]));
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigName
-//
-// This is the callback function for the "config:name" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigName(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:name") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-
-  Cli_Debug("Cmd_ConfigName argc %d\n", argc);
-
-  return (ConfigName(argv[1]));
-
-  // coverity[unreachable]
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigStart
-//
-// This is the callback function for the "config:start" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigStart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:start") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-
-  Cli_Debug("Cmd_ConfigStart argc %d\n", argc);
-
-  if (argc == 1) {
-    return (ConfigStart());
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigStop
-//
-// This is the callback function for the "config:stop" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigStop(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-  if (cliCheckIfEnabled("config:stop") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  Cli_Debug("Cmd_ConfigStop argc %d\n", argc);
-
-  if (argc == 1) {
-    return (ConfigStop());
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigHardRestart
-//
-// This is the callback function for the "config:hard-restart" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigHardRestart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-  if (cliCheckIfEnabled("config:hard-restart") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  Cli_Debug("Cmd_ConfigHardRestart argc %d\n", argc);
-
-  if (argc == 1) {
-    return (TSHardRestart());
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigRestart
-//
-// This is the callback function for the "config:restart" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigRestart(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-  if (cliCheckIfEnabled("config:restart") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-  Cli_Debug("Cmd_ConfigRestart argc %d\n", argc);
-
-  if (argc == 1) {
-    return (TSRestart(false));
-  } else if (argc == 2) {
-    if (argtable[0].parsed_args == CMD_CONFIG_RESTART_CLUSTER) {
-      return (TSRestart(true));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigRestart
-//
-// Register "config:restart" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigRestart()
-{
-  createArgument("cluster", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_RESTART_CLUSTER, "Restart the entire cluster", (char *) NULL);
-
-  return 0;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigParents
-//
-// This is the callback function for the "config:parents" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigParents(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:parents") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigParents argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable, *infoPtr;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-  infoPtr = argtable;
-
-  if (argc == 1) {
-    Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-    return CMD_ERROR;
-  }
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (infoPtr->parsed_args) {
-    case CMD_CONFIG_PARENTS_STATUS:
-      return (Cli_RecordOnOff_Action((argc == 3),
-                                     "proxy.config.http.parent_proxy_routing_enable", argtable->arg_string));
-
-    case CMD_CONFIG_PARENTS_CACHE:
-      return (Cli_RecordString_Action((argc == 3), "proxy.config.http.parent_proxies", argtable->arg_string));
-
-    case CMD_CONFIG_PARENTS_CONFIG_FILE:
-      return (Cli_ConfigFileURL_Action(TS_FNAME_PARENT_PROXY, "parent.config", argtable->arg_string));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigParents
-//
-// Register "config:parents" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigParents()
-{
-
-  createArgument("status", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_PARENTS_STATUS, "Parenting <on|off>", (char *) NULL);
-  createArgument("name", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_PARENTS_CACHE, "Specify cache parent", (char *) NULL);
-  createArgument("rules", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_PARENTS_CONFIG_FILE, "Specify config file", (char *) NULL);
-  return CLI_OK;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigRemap
-//
-// This is the callback function for the "config:remap" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigRemap(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:remap") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  Cli_Debug("Cmd_ConfigRemap argc %d\n", argc);
-
-  if (argc == 2) {
-    return (ConfigRemap(argv[1]));
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigPorts
-//
-// This is the callback function for the "config:ports" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigPorts(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:ports") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  Cli_Debug("Cmd_ConfigPorts argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  Cli_Debug("Cmd_ConfigPorts argc %d\n", argc);
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-
-    if (argc == 2) {            // get
-      return (ConfigPortsGet(argtable[0].parsed_args));
-    } else {                    // set
-      switch (argtable->parsed_args) {
-      case CMD_CONFIG_PORTS_CONNECT:
-        return (ConfigPortsSet(argtable[0].parsed_args, argtable[0].data));
-        break;
-      case CMD_CONFIG_PORTS_HTTP_SERVER:
-      case CMD_CONFIG_PORTS_CLUSTER:
-      case CMD_CONFIG_PORTS_CLUSTER_RS:
-      case CMD_CONFIG_PORTS_CLUSTER_MC:
-      case CMD_CONFIG_PORTS_SOCKS_SERVER:
-      case CMD_CONFIG_PORTS_ICP:
-        return (ConfigPortsSet(argtable[0].parsed_args, &argtable[0].arg_int));
-      }
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX,
-            "\n\nconfig:ports <http-server | http-other | webui | cluster-rs | cluster-mc | \n  ssl | \n socks-server | icp > \n <port | ports list>\n");
-  return CMD_ERROR;
-
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigPorts
-//
-// Register "config:ports" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigPorts()
-{
-  createArgument("http-server", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_PORTS_HTTP_SERVER, "Set Ports for http-server", (char *) NULL);
-  createArgument("cluster", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_PORTS_CLUSTER, "Set Ports for cluster", (char *) NULL);
-  createArgument("cluster-rs", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_PORTS_CLUSTER_RS, "Set Ports for cluster-rs", (char *) NULL);
-  createArgument("cluster-mc", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_PORTS_CLUSTER_MC, "Set Ports for cluster-mc", (char *) NULL);
-  createArgument("connect", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_PORTS_CONNECT, "Set Ports for allowed CONNECT", (char *) NULL);
-  createArgument("socks-server", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_PORTS_SOCKS_SERVER, "Set Ports for socks-server", (char *) NULL);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigClock
-//
-// This is the callback function for the "config:clock" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigClock(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  int setvar = 0;
-
-  if (cliCheckIfEnabled("config:clock") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigClock argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  Cli_PrintArg(0, argtable);
-  Cli_PrintArg(1, argtable);
-
-  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable[0].parsed_args) {
-    case CMD_CONFIG_DATE:
-      return (ConfigDate(argtable->arg_string));
-    case CMD_CONFIG_TIME:
-      return (ConfigTime(argtable->arg_string));
-    case CMD_CONFIG_TIMEZONE:
-      if (argc == 3) {
-        setvar = 1;
-      }
-      if (argtable[1].parsed_args == CMD_CONFIG_TIMEZONE_LIST) {
-        return (ConfigTimezoneList());
-      } else {
-        return (ConfigTimezone(argtable->arg_int, setvar));
-      }
-    }
-  }
-
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigClock
-//
-// Register "config:clock" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigClock()
-{
-  createArgument("date", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_DATE, "System Date <mm/dd/yyyy>", (char *) NULL);
-
-  createArgument("time", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_TIME, "System Time <hh:mm:ss>", (char *) NULL);
-
-  createArgument("timezone", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_TIMEZONE, "Time Zone", (char *) NULL);
-
-  createArgument("list", CMD_CONFIG_TIMEZONE, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_TIMEZONE_LIST, "Display Time Zone List", (char *) NULL);
-
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigSecurity
-//
-// This is the callback function for the "config:security" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigSecurity(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:security") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigSecurity argc %d\n", argc);
-
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable[0].parsed_args) {
-    case CMD_CONFIG_SECURITY_IP:
-      return (Cli_ConfigFileURL_Action(TS_FNAME_IP_ALLOW, "ip_allow.config", argtable->arg_string));
-
-    case CMD_CONFIG_SECURITY_PASSWORD:
-      return (ConfigSecurityPasswd());
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigSecurity
-//
-// Register "config:security" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigSecurity()
-{
-  createArgument("ip-allow", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_SECURITY_IP, "Clients allowed to connect to proxy <url>", (char *) NULL);
-  createArgument("password", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_SECURITY_PASSWORD, "Change Admin Password", (char *) NULL);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigHttp
-//
-// This is the callback function for the "config:http" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigHttp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  int setvar = 0;
-  if (cliCheckIfEnabled("config:http") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-
-  Cli_Debug("Cmd_ConfigHttp argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  if (argc == 3) {
-    setvar = 1;
-  }
-
-  if (argc > 3) {
-    Cli_Error("Too many arguments\n");
-    Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-    return CMD_ERROR;
-  }
-
-  Cli_PrintArg(0, argtable);
-  Cli_PrintArg(1, argtable);
-
-  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_HTTP_STATUS:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.http.cache.http", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_IN:
-      return (Cli_RecordInt_Action(action, "proxy.config.http.keep_alive_no_activity_timeout_in", argtable->arg_int));
-
-    case CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_OUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.http.keep_alive_no_activity_timeout_out", argtable->arg_int));
-
-    case CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_IN:
-      return (Cli_RecordInt_Action(action, "proxy.config.http.transaction_no_activity_timeout_in", argtable->arg_int));
-
-    case CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_OUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.http.transaction_no_activity_timeout_out", argtable->arg_int));
-
-    case CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_IN:
-      return (Cli_RecordInt_Action(action, "proxy.config.http.transaction_active_timeout_in", argtable->arg_int));
-
-    case CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_OUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.http.transaction_active_timeout_out", argtable->arg_int));
-
-    case CMD_CONFIG_HTTP_REMOVE_FROM:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_from", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_REMOVE_REFERER:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_referer", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_REMOVE_USER:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_user_agent", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_REMOVE_COOKIE:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_cookie", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_REMOVE_HEADER:
-      return (Cli_RecordString_Action(action, "proxy.config.http.anonymize_other_header_list", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_GLOBAL_USER_AGENT:
-      return (Cli_RecordString_Action(action, "proxy.config.http.global_user_agent_header", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_INSERT_IP:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_insert_client_ip", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_REMOVE_IP:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.http.anonymize_remove_client_ip", argtable->arg_string));
-
-    case CMD_CONFIG_HTTP_PROXY:
-      return (ConfigHttpProxy(argtable[1].parsed_args, setvar));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigHttp
-//
-// Register "config:http" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigHttp()
-{
-  createArgument("status", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_STATUS, "HTTP proxying <on | off>", (char *) NULL);
-
-  createArgument("keep-alive-timeout-in", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_IN, "Keep alive timeout inbound <seconds>",
-                 (char *) NULL);
-  createArgument("keep-alive-timeout-out", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_KEEP_ALIVE_TIMEOUT_OUT, "Keep alive timeout outbound <seconds>",
-                 (char *) NULL);
-  createArgument("inactive-timeout-in", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_IN, "Inactive timeout inbound <seconds>",
-                 (char *) NULL);
-  createArgument("inactive-timeout-out", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_INACTIVE_TIMEOUT_OUT, "Inactive timeout outbound <seconds>",
-                 (char *) NULL);
-  createArgument("active-timeout-in", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_IN, "Active timeout inbound <seconds>", (char *) NULL);
-  createArgument("active-timeout-out", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_ACTIVE_TIMEOUT_OUT, "Active timeout outbound <seconds>", (char *) NULL);
-
-  createArgument("remove-from", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_FROM, "Remove \"From:\" header <on|off>", (char *) NULL);
-  createArgument("remove-referer", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_REFERER, "Remove \"Referer:\" header <on|off>", (char *) NULL);
-  createArgument("remove-user", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_USER, "Remove \"User:\" header <on|off>", (char *) NULL);
-  createArgument("remove-cookie", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_COOKIE, "Remove \"Cookie:\" header <on|off>", (char *) NULL);
-  createArgument("remove-header", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_HEADER, "String of headers to be removed <string>",
-                 (char *) NULL);
-
-  createArgument("global-user-agent", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_GLOBAL_USER_AGENT, "User-Agent to send to Origin <string>",
-                 (char *) NULL);
-
-  createArgument("insert-ip", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_INSERT_IP, "Insert client IP into header <on|off>", (char *) NULL);
-  createArgument("remove-ip", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HTTP_REMOVE_IP, "Remove client IP from header <on|off>", (char *) NULL);
-  createArgument("proxy", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_HTTP_PROXY, "Proxy Mode <fwd | rev | fwd-rev>", (char *) NULL);
-  createArgument("fwd", CMD_CONFIG_HTTP_PROXY, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_HTTP_FWD, "Specify proxy mode to be forward", (char *) NULL);
-  createArgument("rev", CMD_CONFIG_HTTP_PROXY, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_HTTP_REV, "Specify proxy mode to be reverse", (char *) NULL);
-  createArgument("fwd-rev", CMD_CONFIG_HTTP_PROXY, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_HTTP_FWD_REV, "Specify proxy mode to be both", (char *) NULL);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigIcp
-//
-// This is the callback function for the "config:icp" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigIcp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:icp") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigIcp argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_ICP_MODE:
-      return (ConfigIcpMode(argtable[1].parsed_args, action));
-
-    case CMD_CONFIG_ICP_PORT:
-      return (Cli_RecordInt_Action(action, "proxy.config.icp.icp_port", argtable->arg_int));
-
-    case CMD_CONFIG_ICP_MCAST:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.icp.multicast_enabled", argtable->arg_string));
-
-    case CMD_CONFIG_ICP_QTIMEOUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.icp.query_timeout", argtable->arg_int));
-
-    case CMD_CONFIG_ICP_PEERS:
-      return (Cli_ConfigFileURL_Action(TS_FNAME_ICP_PEER, "icp.config", argtable->arg_string));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigIcp
-//
-// Register "config:Icp" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigIcp()
-{
-  createArgument("mode", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_ICP_MODE, "Mode <disabled | receive | send-receive>", (char *) NULL);
-
-  createArgument("receive", CMD_CONFIG_ICP_MODE, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_ICP_MODE_RECEIVE, "Specify receive mode for icp", (char *) NULL);
-
-  createArgument("send-receive", CMD_CONFIG_ICP_MODE, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_ICP_MODE_SENDRECEIVE, "Specify send & receive mode for icp", (char *) NULL);
-
-  createArgument("disabled", CMD_CONFIG_ICP_MODE, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_ICP_MODE_DISABLED, "icp mode disabled", (char *) NULL);
-
-  createArgument("port", 1, CLI_ARGV_OPTION_INT_VALUE, (char *) NULL, CMD_CONFIG_ICP_PORT, "Port <int>", (char *) NULL);
-  createArgument("multicast", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_ICP_MCAST, "Multicast <on|off>", (char *) NULL);
-  createArgument("query-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_ICP_QTIMEOUT, "Query Timeout <seconds>", (char *) NULL);
-  createArgument("peers", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_ICP_PEERS, "URL for ICP Peers config file <url>", (char *) NULL);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigPortTunnles
-//
-// Register "config:PortTunnles" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigPortTunnels()
-{
-
-  createArgument("server-other-ports", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_PORT_TUNNELS_SERVER_OTHER_PORTS, "Set the tunnel port number <int>",
-                 (char *) NULL);
-  return 0;
-}
-
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigScheduledUpdate
-//
-// This is the callback function for the "config:scheduled-update" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigScheduledUpdate(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:scheduled-update") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigScheduledUpdate argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_SCHEDULED_UPDATE_STATUS:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.update.enabled", argtable->arg_string));
-
-    case CMD_CONFIG_SCHEDULED_UPDATE_RETRY_COUNT:
-      return (Cli_RecordInt_Action(action, "proxy.config.update.retry_count", argtable->arg_int));
-
-    case CMD_CONFIG_SCHEDULED_UPDATE_RETRY_INTERVAL:
-      return (Cli_RecordInt_Action(action, "proxy.config.update.retry_interval", argtable->arg_int));
-
-    case CMD_CONFIG_SCHEDULED_UPDATE_MAX_CONCURRENT:
-      return (Cli_RecordInt_Action(action, "proxy.config.update.concurrent_updates", argtable->arg_int));
-
-    case CMD_CONFIG_SCHEDULED_UPDATE_FORCE_IMMEDIATE:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.update.force", argtable->arg_string));
-
-    case CMD_CONFIG_SCHEDULED_UPDATE_RULES:
-      return (Cli_ConfigFileURL_Action(TS_FNAME_UPDATE_URL, "update.config", argtable->arg_string));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigScheduled-Update
-//
-// Register "config:Scheduled-Update" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigScheduledUpdate()
-{
-  createArgument("status", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_STATUS, "Set scheduled-update status <on | off>",
-                 (char *) NULL);
-  createArgument("retry-count", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_RETRY_COUNT, "Set retry-count <int>", (char *) NULL);
-  createArgument("retry-interval", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_RETRY_INTERVAL, "Set retry-interval <sec>", (char *) NULL);
-  createArgument("max-concurrent", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_MAX_CONCURRENT, "Set maximum concurrent updates",
-                 (char *) NULL);
-  createArgument("force-immediate", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_FORCE_IMMEDIATE, "Set force-immediate <on | off>",
-                 (char *) NULL);
-  createArgument("rules", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_SCHEDULED_UPDATE_RULES, "Update update.config file from url <string>",
-                 (char *) NULL);
-
-  return 0;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigSocks
-//
-// This is the callback function for the "config:scheduled-update" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigSocks(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:socks") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigSocks argc %d\n", argc);
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_SOCKS_STATUS:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.socks.socks_needed", argtable->arg_string));
-
-    case CMD_CONFIG_SOCKS_VERSION:
-      return (Cli_RecordInt_Action(action, "proxy.config.socks.socks_version", argtable->arg_int));
-
-    case CMD_CONFIG_SOCKS_DEFAULT_SERVERS:
-      return (Cli_RecordString_Action(action, "proxy.config.socks.default_servers", argtable->arg_string));
-
-    case CMD_CONFIG_SOCKS_ACCEPT:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.socks.accept_enabled", argtable->arg_string));
-
-    case CMD_CONFIG_SOCKS_ACCEPT_PORT:
-      return (Cli_RecordInt_Action(action, "proxy.config.socks.accept_port", argtable->arg_int));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigScheduled-Update
-//
-// Register "config:Scheduled-Update" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigSocks()
-{
-  createArgument("status", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_SOCKS_STATUS, "Set socks status <on | off>", (char *) NULL);
-
-  createArgument("version", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_SOCKS_VERSION, "Set version <int>", (char *) NULL);
-
-  createArgument("default-servers", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_SOCKS_DEFAULT_SERVERS, "Set default-servers <string>", (char *) NULL);
-
-  createArgument("accept", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_SOCKS_ACCEPT, "Set accept <on | off>", (char *) NULL);
-
-  createArgument("accept-port", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_SOCKS_ACCEPT_PORT, "Set server accept-port <int>", (char *) NULL);
-
-  return 0;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigCache
-//
-// This is the callback function for the "config:cache" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigCache(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:cache") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigCache argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int action = 0;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_CACHE_HTTP:
-      return (Cli_RecordOnOff_Action((argc == 3), "proxy.config.http.cache.http", argtable->arg_string));
-
-    case CMD_CONFIG_CACHE_CLUSTER_BYPASS:
-      return (Cli_RecordOnOff_Action((argc == 3),
-                                     "proxy.config.http.cache.cluster_cache_local", argtable->arg_string));
-    case CMD_CONFIG_CACHE_IGNORE_BYPASS:
-      return (Cli_RecordOnOff_Action((argc == 3),
-                                     "proxy.config.http.cache.ignore_client_no_cache", argtable->arg_string));
-
-    case CMD_CONFIG_CACHE_MAX_OBJECT_SIZE:
-      return (Cli_RecordInt_Action((argc == 3), "proxy.config.cache.max_doc_size", argtable->arg_int));
-
-    case CMD_CONFIG_CACHE_MAX_ALTERNATES:
-      return (Cli_RecordInt_Action((argc == 3), "proxy.config.cache.limits.http.max_alts", argtable->arg_int));
-
-    case CMD_CONFIG_CACHE_FILE:
-      return (Cli_ConfigFileURL_Action(TS_FNAME_CACHE_OBJ, "cache.config", argtable->arg_string));
-
-    case CMD_CONFIG_CACHE_FRESHNESS:
-      if (argtable[1].parsed_args != CLI_PARSED_ARGV_END) {
-        switch (argtable[1].parsed_args) {
-        case CMD_CONFIG_CACHE_FRESHNESS_VERIFY:
-          if (argc == 4) {
-            action = RECORD_SET;
-          }
-          return (ConfigCacheFreshnessVerify(argtable[2].parsed_args, action));
-
-        case CMD_CONFIG_CACHE_FRESHNESS_MINIMUM:
-          if (argc == 4) {
-            action = RECORD_SET;
-          }
-          return (ConfigCacheFreshnessMinimum(argtable[2].parsed_args, action));
-
-        case CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT:
-          if (argtable[2].parsed_args != CLI_PARSED_ARGV_END) {
-            if ((argtable[2].parsed_args ==
-                 CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_GREATER_THAN) &&
-                (argtable[3].parsed_args == CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_LESS_THAN) && (argc == 7)) {
-              action = RECORD_SET;
-            } else {
-              Cli_Printf("\n config:cache freshness no-expire-limit greater-than <value> less-than<value>\n");
-              return CMD_ERROR;
-            }
-          }
-          Cli_Debug("greater than %d, less than %d \n", argtable[2].arg_int, argtable[3].arg_int);
-          return (ConfigCacheFreshnessNoExpireLimit(argtable[2].arg_int, argtable[3].arg_int, action));
-
-        }
-      }
-      Cli_Printf("\n config:cache freshness <verify | minimum | no-expire-limit> \n");
-      return CMD_ERROR;
-    case CMD_CONFIG_CACHE_DYNAMIC:
-      return (Cli_RecordOnOff_Action((argc == 3),
-                                     "proxy.config.http.cache.cache_urls_that_look_dynamic", argtable->arg_string));
-
-    case CMD_CONFIG_CACHE_ALTERNATES:
-      return (Cli_RecordOnOff_Action((argc == 3),
-                                     "proxy.config.http.cache.enable_default_vary_headers", argtable->arg_string));
-
-    case CMD_CONFIG_CACHE_VARY:
-      if (argtable[1].arg_string) {
-        action = RECORD_SET;
-      }
-      return (ConfigCacheVary(argtable[1].parsed_args, argtable[1].arg_string, action));
-
-    case CMD_CONFIG_CACHE_COOKIES:
-      if (argc == 3) {
-        action = RECORD_SET;
-      }
-      return (ConfigCacheCookies(argtable[1].parsed_args, action));
-    case CMD_CONFIG_CACHE_CLEAR:
-      return (ConfigCacheClear());
-    }
-  }
-
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigCache
-//
-// Register "config:cache" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigCache()
-{
-  createArgument("http", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_HTTP, "HTTP Protocol caching <on|off>", (char *) NULL);
-  createArgument("ignore-bypass", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_IGNORE_BYPASS, "Ignore Bypass <on|off>", (char *) NULL);
-  createArgument("max-object-size", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_MAX_OBJECT_SIZE, "Maximum object size <bytes>", (char *) NULL);
-  createArgument("max-alternates", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_MAX_ALTERNATES, "Maximum alternates <int>", (char *) NULL);
-  createArgument("file", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_FILE, "Load cache.config file from url <string>", (char *) NULL);
-  createArgument("freshness", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS, "Freshness parameters <verify | minimum | no-expire-limit>",
-                 (char *) NULL);
-  createArgument("verify", CMD_CONFIG_CACHE_FRESHNESS, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY,
-                 "Freshness verify <when-expired | no-date | always | never> ", (char *) NULL);
-
-  createArgument("when-expired", CMD_CONFIG_CACHE_FRESHNESS_VERIFY, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY_WHEN_EXPIRED,
-                 "Set freshness verify to be when-expired", (char *) NULL);
-
-  createArgument("no-date", CMD_CONFIG_CACHE_FRESHNESS_VERIFY, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY_NO_DATE,
-                 "Set freshness verify to be no-date", (char *) NULL);
-
-  createArgument("always", CMD_CONFIG_CACHE_FRESHNESS_VERIFY, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY_ALWALYS,
-                 "Set freshness verify to be always", (char *) NULL);
-
-  createArgument("never", CMD_CONFIG_CACHE_FRESHNESS_VERIFY, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_VERIFY_NEVER,
-                 "Set the freshness verify to be never", (char *) NULL);
-
-  createArgument("minimum", CMD_CONFIG_CACHE_FRESHNESS, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_MINIMUM,
-                 "Set freshness minimum <explicit | last-modified | nothing>", (char *) NULL);
-
-  createArgument("explicit", CMD_CONFIG_CACHE_FRESHNESS_MINIMUM, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_EXPLICIT,
-                 "Set the Freshness Minimum to be explicit", (char *) NULL);
-
-  createArgument("last-modified", CMD_CONFIG_CACHE_FRESHNESS_MINIMUM, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_LAST_MODIFIED,
-                 "Set the Freshness Minimum to be last modified", (char *) NULL);
-
-  createArgument("nothing", CMD_CONFIG_CACHE_FRESHNESS_MINIMUM, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_MINIMUM_NOTHING,
-                 "Specify the Freshness minimum to be nothing", (char *) NULL);
-
-  createArgument("no-expire-limit", CMD_CONFIG_CACHE_FRESHNESS, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT,
-                 "Set the Freshness no-expire-limit time", (char *) NULL);
-
-  createArgument("greater-than", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_GREATER_THAN,
-                 "Set the minimum Freshness no-expire-limit time", (char *) NULL);
-
-  createArgument("less-than", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_FRESHNESS_NO_EXPIRE_LIMIT_LESS_THAN,
-                 "Set the maximum Freshness no-expire-limit time", (char *) NULL);
-
-  createArgument("dynamic", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_DYNAMIC, "Set Dynamic <on|off>", (char *) NULL);
-
-  createArgument("alternates", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_ALTERNATES, "Set Alternates <on|off>", (char *) NULL);
-  createArgument("vary", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_CACHE_VARY, "Set vary <text | images | other> <field>", (char *) NULL);
-  createArgument("text", CMD_CONFIG_CACHE_VARY, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_VARY_TEXT, "Set vary text's value", (char *) NULL);
-  createArgument("images", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_VARY_COOKIES_IMAGES, "Set vary images' value", (char *) NULL);
-  createArgument("other", CMD_CONFIG_CACHE_VARY, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_CACHE_VARY_OTHER, "Set vary other's value", (char *) NULL);
-
-  createArgument("cookies", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES, "Set cookies <none | all | images | non-text | non-text-ext>",
-                 (char *) NULL);
-  createArgument("none", CMD_CONFIG_CACHE_COOKIES, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES_NONE, "No cookies", (char *) NULL);
-  createArgument("all", CMD_CONFIG_CACHE_COOKIES, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES_ALL, "All cookies", (char *) NULL);
-  createArgument("non-text", CMD_CONFIG_CACHE_COOKIES, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES_NON_TEXT, "Non-text cookies", (char *) NULL);
-  createArgument("non-text-ext", CMD_CONFIG_CACHE_COOKIES, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_COOKIES_NON_TEXT_EXT, "Non-text-ext cookies", (char *) NULL);
-  createArgument("clear", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_CACHE_CLEAR, "Clear the cache and start Traffic Server", (char *) NULL);
-  return 0;
-}
-
-
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigHostdb
-//
-// This is the callback function for the "config:hostdb" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigHostdb(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:hostdb") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigHostdb argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_HOSTDB_LOOKUP_TIMEOUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.hostdb.lookup_timeout", argtable->arg_int));
-
-    case CMD_CONFIG_HOSTDB_FOREGROUND_TIMEOUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.hostdb.timeout", argtable->arg_int));
-
-    case CMD_CONFIG_HOSTDB_BACKGROUND_TIMEOUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.hostdb.verify_after", argtable->arg_int));
-
-    case CMD_CONFIG_HOSTDB_INVALID_HOST_TIMEOUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.hostdb.fail.timeout", argtable->arg_int));
-
-    case CMD_CONFIG_HOSTDB_RE_DNS_ON_RELOAD:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.hostdb.re_dns_on_reload", argtable->arg_string));
-    case CMD_CONFIG_HOSTDB_CLEAR:
-      return (ConfigHostdbClear());
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigHostdb
-//
-// Register "config:Hostdb" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigHostdb()
-{
-  createArgument("lookup-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HOSTDB_LOOKUP_TIMEOUT, "Lookup Timeout <seconds>", (char *) NULL);
-  createArgument("foreground-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HOSTDB_FOREGROUND_TIMEOUT, "Foreground Timeout <minutes>", (char *) NULL);
-  createArgument("background-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HOSTDB_BACKGROUND_TIMEOUT, "Background Timeout <minutes>", (char *) NULL);
-  createArgument("invalid-host-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_HOSTDB_INVALID_HOST_TIMEOUT, "Invalid Host Timeout <minutes>",
-                 (char *) NULL);
-  createArgument("re-dns-on-reload", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_HOSTDB_RE_DNS_ON_RELOAD, "Re-DNS on Reload Timeout <on|off>", (char *) NULL);
-  createArgument("clear", 1, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_HOSTDB_CLEAR, "Clear the HostDB and start Traffic Server", (char *) NULL);
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigDns
-//
-// This is the callback function for the "config:dns" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigDns(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:dns") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigDns argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_DNS_RESOLVE_TIMEOUT:
-      return (Cli_RecordInt_Action(action, "proxy.config.dns.lookup_timeout", argtable->arg_int));
-
-    case CMD_CONFIG_DNS_RETRIES:
-      return (Cli_RecordInt_Action(action, "proxy.config.dns.retries", argtable->arg_int));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigDns
-//
-// Register "config:dns" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigDns()
-{
-  createArgument("resolve-timeout", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_DNS_RESOLVE_TIMEOUT, "Resolve timeout <int>", (char *) NULL);
-  createArgument("retries", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_DNS_RETRIES, "Number of retries <int>", (char *) NULL);
-
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigVirtualip
-//
-// This is the callback function for the "config:virtualip" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigVirtualip(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:virtualip") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigCache argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int setvar = 0;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_VIRTUALIP_STATUS:
-      return (Cli_RecordOnOff_Action((argc == 3), "proxy.config.vmap.enabled", argtable->arg_string));
-
-    case CMD_CONFIG_VIRTUALIP_LIST:
-      return (ConfigVirtualIpList());
-
-    case CMD_CONFIG_VIRTUALIP_ADD:
-      if (argc == 8) {
-        setvar = 1;
-      }
-      Cli_PrintArg(0, argtable);
-      Cli_PrintArg(1, argtable);
-      Cli_PrintArg(2, argtable);
-      Cli_PrintArg(3, argtable);
-      if (ConfigVirtualipAdd(argtable[1].arg_string, argtable[2].arg_string, argtable[3].arg_int, setvar) == CLI_OK) {
-        return CMD_OK;
-      } else {
-        return CMD_ERROR;
-      }
-
-    case CMD_CONFIG_VIRTUALIP_DELETE:
-      if (argc == 3) {
-        setvar = 1;
-      }
-      if (ConfigVirtualipDelete(argtable[0].arg_int, setvar) == CLI_OK) {
-        return CMD_OK;
-      } else {
-        return CMD_ERROR;
-      }
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigVirtualip
-//
-// Register "config:virtualip" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigVirtualip()
-{
-
-  createArgument("status", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_VIRTUALIP_STATUS, "Virtual IP <on | off>", (char *) NULL);
-  createArgument("list", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_VIRTUALIP_LIST, "List virtual IP addresses", (char *) NULL);
-  createArgument("add", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_VIRTUALIP_ADD, "add ip <x.x.x.x> device <string> sub-intf <int>",
-                 (char *) NULL);
-  createArgument("ip", CMD_CONFIG_VIRTUALIP_ADD, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_VIRTUALIP_ADD_IP, "Virtual IP Address <x.x.x.x>", (char *) NULL);
-  createArgument("device", CMD_CONFIG_VIRTUALIP_ADD_IP, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_VIRTUALIP_ADD_DEVICE, "Virtual IP device <string>", (char *) NULL);
-  createArgument("sub-intf", CMD_CONFIG_VIRTUALIP_ADD_DEVICE, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_VIRTUALIP_ADD_SUBINTERFACE, "Virtual IP sub interface <integer>",
-                 (char *) NULL);
-  createArgument("delete", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_VIRTUALIP_DELETE, "Delete Virtual IP <integer>", (char *) NULL);
-  return CLI_OK;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigLogging
-//
-// This is the callback function for the "config:logging" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigLogging(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:logging") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigCache argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int setvar = 0;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_LOGGING_EVENT:
-      if (argc == 3) {
-        setvar = 1;
-      }
-      return (ConfigLoggingEvent(argtable[1].parsed_args, setvar));
-    case CMD_CONFIG_LOGGING_MGMT_DIRECTORY:
-      return (Cli_RecordString_Action((argc == 3), "proxy.config.log.logfile_dir", argtable->arg_string));
-
-    case CMD_CONFIG_LOGGING_SPACE_LIMIT:
-      return (Cli_RecordInt_Action((argc == 3), "proxy.config.log.max_space_mb_for_logs", argtable->arg_int));
-
-    case CMD_CONFIG_LOGGING_SPACE_HEADROOM:
-      return (Cli_RecordInt_Action((argc == 3), "proxy.config.log.max_space_mb_headroom", argtable->arg_int));
-
-    case CMD_CONFIG_LOGGING_COLLATION_STATUS:
-      if (argc == 3) {
-        setvar = 1;
-      }
-      return (ConfigLoggingCollationStatus(argtable[1].parsed_args, setvar));
-    case CMD_CONFIG_LOGGING_COLLATION_HOST:
-      return (Cli_RecordString_Action((argc == 3), "proxy.config.log.collation_host", argtable->arg_string));
-
-    case CMD_CONFIG_LOGGING_COLLATION:
-      if (argc == 8) {
-        setvar = 1;
-      }
-      Cli_PrintArg(1, argtable);
-      Cli_PrintArg(2, argtable);
-      Cli_PrintArg(3, argtable);
-      Cli_PrintArg(4, argtable);
-      return (ConfigLoggingCollation(argtable[1].arg_string, argtable[3].parsed_args, argtable[4].arg_int, setvar));
-    case CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT:
-      if (argc == 10) {
-        setvar = 1;
-      }
-      Cli_PrintArg(1, argtable);
-      Cli_PrintArg(2, argtable);
-      Cli_PrintArg(3, argtable);
-      Cli_PrintArg(4, argtable);
-      Cli_PrintArg(5, argtable);
-      Cli_PrintArg(6, argtable);
-      return (ConfigLoggingFormatTypeFile(argtable[1].parsed_args,
-                                          argtable[2].parsed_args,
-                                          argtable[4].parsed_args,
-                                          argtable[5].arg_string, argtable[6].arg_string, setvar));
-    case CMD_CONFIG_LOGGING_SPLITTING:
-      if (argc == 4) {
-        setvar = 1;
-      }
-      Cli_PrintArg(1, argtable);
-      Cli_PrintArg(2, argtable);
-      return (ConfigLoggingSplitting(argtable[1].parsed_args, argtable[2].parsed_args, setvar));
-
-    case CMD_CONFIG_LOGGING_CUSTOM:
-      if (argc == 5) {
-        setvar = 1;
-      }
-      Cli_PrintArg(1, argtable);
-      Cli_PrintArg(2, argtable);
-      Cli_PrintArg(3, argtable);
-      return (ConfigLoggingCustomFormat(argtable[1].parsed_args, argtable[3].parsed_args, setvar));
-
-    case CMD_CONFIG_LOGGING_ROLLING:
-      if (argc == 9) {
-        setvar = 1;
-      }
-      Cli_PrintArg(1, argtable);
-      Cli_PrintArg(2, argtable);
-      Cli_PrintArg(3, argtable);
-      Cli_PrintArg(4, argtable);
-      Cli_PrintArg(5, argtable);
-      return (ConfigLoggingRollingOffsetIntervalAutodelete(argtable[1].parsed_args,
-                                                           argtable[2].arg_int,
-                                                           argtable[3].arg_int, argtable[5].parsed_args, setvar));
-
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigLogging
-//
-// Register "config:logging" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigLogging()
-{
-
-  createArgument("on", CLI_ARGV_NO_POS, CLI_ARGV_REQUIRED,
-                 (char *) NULL, CMD_CONFIG_LOGGING_ON, "Enable logging", (char *) NULL);
-  createArgument("off", CLI_ARGV_NO_POS, CLI_ARGV_REQUIRED,
-                 (char *) NULL, CMD_CONFIG_LOGGING_OFF, "Disable logging", (char *) NULL);
-  createArgument("event", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT, "Events <enabled | trans-only | error-only | disabled>",
-                 (char *) NULL);
-  createArgument("enabled", CMD_CONFIG_LOGGING_EVENT, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT_ENABLED, "Event logging enabled", (char *) NULL);
-  createArgument("trans-only", CMD_CONFIG_LOGGING_EVENT, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT_TRANS_ONLY, "Event logging for transactions only",
-                 (char *) NULL);
-  createArgument("error-only", CMD_CONFIG_LOGGING_EVENT, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT_ERROR_ONLY, "Event logging for errors only", (char *) NULL);
-  createArgument("disabled", CMD_CONFIG_LOGGING_EVENT, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_LOGGING_EVENT_DISABLED, "Event logging is disabled", (char *) NULL);
-  createArgument("mgmt-directory", 1, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_LOGGING_MGMT_DIRECTORY, "Logging MGMT directory <string>", (char *) NULL);
-  createArgument("space-limit", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_LOGGING_SPACE_LIMIT, "Space limit for logs <mb>", (char *) NULL);
-  createArgument("space-headroom", 1, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_LOGGING_SPACE_HEADROOM, "Space for headroom <mb>", (char *) NULL);
-  createArgument("collation-status", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_STATUS,
-                 "Collation status <inactive | host | send-standard |\n" "                   send-custom | send-all>",
-                 (char *) NULL);
-  createArgument("inactive", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_CONSTANT, (char *) NULL,
-                 CMD_CONFIG_LOGGING_COLLATION_STATUS_INACTIVE, "No collation", (char *) NULL);
-  createArgument("host", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_CONSTANT, (char *) NULL,
-                 CMD_CONFIG_LOGGING_COLLATION_STATUS_HOST, "Be a collation host (receiver)", (char *) NULL);
-  createArgument("send-standard", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL,
-                 CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_STANDARD, "Send standard logs", (char *) NULL);
-  createArgument("send-custom", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL,
-                 CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_CUSTOM, "Send custom logs", (char *) NULL);
-  createArgument("send-all", CMD_CONFIG_LOGGING_COLLATION_STATUS, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL,
-                 CMD_CONFIG_LOGGING_COLLATION_STATUS_SEND_ALL, "Send all logs", (char *) NULL);
-  createArgument("collation-host", 1, CLI_ARGV_OPTION_NAME_VALUE, (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_HOST,
-                 "Specify the collation host <string>", (char *) NULL);
-
-  createArgument("collation", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION, "Collation parameters secret <secret> tagged <on | off>\n"
-                 "                   orphan-limit <orphan>", (char *) NULL);
-
-  createArgument("secret", CMD_CONFIG_LOGGING_COLLATION, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_SECRET, "Collation secret is <string>", (char *) NULL);
-
-  createArgument("tagged", CLI_ARGV_NO_POS, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_TAGGED, "Collation tagged is <on | off>", (char *) NULL);
-
-  createArgument("orphan-limit", CLI_ARGV_NO_POS, CLI_ARGV_INT,
-                 (char *) NULL, CMD_CONFIG_LOGGING_COLLATION_ORPHAN_LIMIT,
-                 "Collation orphan limit size <mb>", (char *) NULL);
-
-  createArgument("format", CLI_ARGV_NO_POS, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT,
-                 "Logging format <squid | netscape-common | netscape-ext |\n"
-                 "                   netscape-ext2>", (char *) NULL);
-
-  createArgument("squid", CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_FORMAT_SQUID, "Squid <on | off>", (char *) NULL);
-  createArgument("netscape-common", CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_COMMON, "Netscape Common <on | off>", (char *) NULL);
-  createArgument("netscape-ext", CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_EXT, "Netscape Extended <on | off>", (char *) NULL);
-  createArgument("netscape-ext2", CMD_CONFIG_LOGGING_AND_CUSTOM_FORMAT, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_FORMAT_NETSCAPE_EXT2,
-                 "Netscape Extended 2 <on | off>", (char *) NULL);
-
-  createArgument("type", CLI_ARGV_NO_POS, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_TYPE, "Logging type <ascii | binary>", (char *) NULL);
-  createArgument("ascii", CMD_CONFIG_LOGGING_TYPE, CLI_ARGV_REQUIRED,
-                 (char *) NULL, CMD_CONFIG_LOGGING_TYPE_ASCII, "ASCII log files", (char *) NULL);
-  createArgument("binary", CMD_CONFIG_LOGGING_TYPE, CLI_ARGV_REQUIRED,
-                 (char *) NULL, CMD_CONFIG_LOGGING_TYPE_BINARY, "Binary log files", (char *) NULL);
-
-  createArgument("file", CLI_ARGV_NO_POS, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_LOGGING_FILE, "Log file name <string>", (char *) NULL);
-
-  createArgument("header", CLI_ARGV_NO_POS, CLI_ARGV_STRING,
-                 (char *) NULL, CMD_CONFIG_LOGGING_HEADER, "Log file header <string>", (char *) NULL);
-
-  createArgument("splitting", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_SPLITTING,
-                 "Splitting of logs for protocols <icp | http>", (char *) NULL);
-  createArgument("icp", CMD_CONFIG_LOGGING_SPLITTING, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_SPLITTING_ICP, "Split ICP <on | off>", (char *) NULL);
-  createArgument("http", CMD_CONFIG_LOGGING_SPLITTING, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_SPLITTING_HTTP, "Split of HTTP <on | off>", (char *) NULL);
-
-  createArgument("custom", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_CUSTOM,
-                 "Custom Logging <on | off>", (char *) NULL);
-
-  createArgument("rolling", 1, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_ROLLING,
-                 "Log file rolling <on | off> offset <hour>\n"
-                 "                   interval <num-hours> auto-delete <on | off>", (char *) NULL);
-
-  createArgument("offset", CLI_ARGV_NO_POS, CLI_ARGV_INT,
-                 (char *) NULL, CMD_CONFIG_LOGGING_OFFSET, "Rolling offset <hour> (24hour format)", (char *) NULL);
-
-  createArgument("interval", CLI_ARGV_NO_POS, CLI_ARGV_INT,
-                 (char *) NULL, CMD_CONFIG_LOGGING_INTERVAL, "Rolling interval <seconds>", (char *) NULL);
-  createArgument("auto-delete", CLI_ARGV_NO_POS, CLI_ARGV_CONST_OPTION,
-                 (char *) NULL, CMD_CONFIG_LOGGING_AUTO_DELETE, "Auto delete <on | off>", (char *) NULL);
-  return 0;
-
-
-}
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigSsl
-//
-// This is the callback function for the "config:ssl" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigSsl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:ssl") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigSsl argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  int action = (argc == 3) ? RECORD_SET : RECORD_GET;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_SSL_STATUS:
-      return (Cli_RecordOnOff_Action(action, "proxy.config.ssl.enabled", argtable->arg_string));
-
-    case CMD_CONFIG_SSL_PORT:
-      return (Cli_RecordInt_Action(action, "proxy.config.ssl.server_port", argtable->arg_int));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigSsl
-//
-// Register "config:ssl" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigSsl()
-{
-  createArgument("status", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_SSL_STATUS, "SSL <on | off>", (char *) NULL);
-
-  createArgument("ports", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_SSL_PORT, "SSL port <int>", (char *) NULL);
-  return 0;
-}
-
-
-////////////////////////////////////////////////////////////////
-// Cmd_ConfigAlarm
-//
-// This is the callback function for the "config:alarm" command.
-//
-// Parameters:
-//    clientData -- information about parsed arguments
-//    interp -- the Tcl interpreter
-//    argc -- number of command arguments
-//    argv -- the command arguments
-//
-int
-Cmd_ConfigAlarm(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
-{
-  /* call to processArgForCommand must appear at the beginning
-   * of each command's callback function
-   */
-  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
-    return CMD_ERROR;
-  }
-
-  if (processHelpCommand(argc, argv) == CLI_OK)
-    return CMD_OK;
-
-  if (cliCheckIfEnabled("config:alarm") == CLI_ERROR) {
-    return CMD_ERROR;
-  }
-  Cli_Debug("Cmd_ConfigAlarm argc %d\n", argc);
-
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-  cli_parsedArgInfo *argtable;
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
-  argtable = cmdCallbackInfo->parsedArgTable;
-
-  if (argtable->parsed_args != CLI_PARSED_ARGV_END) {
-    switch (argtable->parsed_args) {
-    case CMD_CONFIG_ALARM_RESOLVE_NAME:
-      if (argc < 3) {
-        return (ShowAlarms());
-      }
-      return (ConfigAlarmResolveName(argtable->arg_string));
-    case CMD_CONFIG_ALARM_RESOLVE_NUMBER:
-      if (argc < 3) {
-        return (ShowAlarms());
-      }
-      return (ConfigAlarmResolveNumber(argtable->arg_int));
-    case CMD_CONFIG_ALARM_RESOLVE_ALL:
-      return (ConfigAlarmResolveAll());
-    case CMD_CONFIG_ALARM_NOTIFY:
-      Cli_Debug("Cmd_ConfigAlarm \"%s\"\n", argtable->arg_string);
-      return (ConfigAlarmNotify(argtable->arg_string));
-    }
-  }
-  Cli_Error(ERR_COMMAND_SYNTAX, cmdCallbackInfo->command_usage);
-  return CMD_ERROR;
-}
-
-
-
-////////////////////////////////////////////////////////////////
-// CmdArgs_ConfigAlarm
-//
-// Register "config:alarm" arguments with the Tcl interpreter.
-//
-int
-CmdArgs_ConfigAlarm()
-{
-  createArgument("resolve-name", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_ALARM_RESOLVE_NAME, "Resolve by name <string>", (char *) NULL);
-
-  createArgument("resolve-number", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_INT_VALUE,
-                 (char *) NULL, CMD_CONFIG_ALARM_RESOLVE_NUMBER, "Resolve by number from list <int>", (char *) NULL);
-
-  createArgument("resolve-all", CLI_ARGV_NO_POS, CLI_ARGV_CONSTANT,
-                 (char *) NULL, CMD_CONFIG_ALARM_RESOLVE_ALL, "Resolve all alarms", (char *) NULL);
-
-  createArgument("notify", CLI_ARGV_NO_POS, CLI_ARGV_OPTION_NAME_VALUE,
-                 (char *) NULL, CMD_CONFIG_ALARM_NOTIFY, "Alarm notification <on | off>", (char *) NULL);
-  return CLI_OK;
-}
-
-
-////////////////////////////////////////////////////////////////
-//
-// "config" sub-command implementations
-//
-////////////////////////////////////////////////////////////////
-
-
-// config start sub-command
-int
-ConfigStart()
-{
-  TSProxyStateT state = TSProxyStateGet();
-
-  switch (state) {
-  case TS_PROXY_ON:
-    // do nothing, proxy is already on
-    Cli_Error(ERR_PROXY_STATE_ALREADY, "on");
-    break;
-  case TS_PROXY_OFF:
-  case TS_PROXY_UNDEFINED:
-    if (TSProxyStateSet(TS_PROXY_ON, TS_CACHE_CLEAR_OFF)) {
-      Cli_Error(ERR_PROXY_STATE_SET, "on");
-      return CLI_ERROR;
-    }
-    break;
-  }
-  return CLI_OK;
-}
-
-// config stop sub-command
-int
-ConfigStop()
-{
-  TSProxyStateT state = TSProxyStateGet();
-
-  switch (state) {
-  case TS_PROXY_OFF:
-    // do nothing, proxy is already off
-    Cli_Error(ERR_PROXY_STATE_ALREADY, "off");
-    break;
-  case TS_PROXY_ON:
-  case TS_PROXY_UNDEFINED:
-    if (TSProxyStateSet(TS_PROXY_OFF, TS_CACHE_CLEAR_OFF)) {
-      Cli_Error(ERR_PROXY_STATE_SET, "off");
-      return CLI_ERROR;
-    }
-    break;
-  }
-  return CLI_OK;
-}
-
-// config get sub-command
-//   used to get the value of any config variable in records.config
-int
-ConfigGet(const char *rec_name)
-{
-  Cli_Debug("ConfigGet: rec_name %s\n", rec_name);
-
-  TSError status;
-  TSRecordEle rec_val;
-
-  status = Cli_RecordGet(rec_name, &rec_val);
-
-  if (status) {
-    return status;
-  }
-  // display the result
-
-  switch (rec_val.rec_type) {
-  case TS_REC_INT:            // TS64 aka "long long"
-    Cli_Printf("%s = %d\n", rec_name, (int) rec_val.int_val);
-    break;
-  case TS_REC_COUNTER:        // TS64 aka "long long"
-    Cli_Printf("%s = %d\n", rec_name, (int) rec_val.counter_val);
-    break;
-  case TS_REC_FLOAT:          // float
-    Cli_Printf("%s = %f\n", rec_name, rec_val.float_val);
-    break;
-  case TS_REC_STRING:         // char*
-    Cli_Printf("%s = \"%s\"\n", rec_name, rec_val.string_val);
-    break;
-  case TS_REC_UNDEFINED:      // what's this???
-    Cli_Printf("%s = UNDEFINED\n", rec_name);
-    break;
-  }
-
-  return CLI_OK;
-}
-
-// config set sub-command
-//   used to set the value of any variable in records.config
-
-int
-ConfigSet(const char *rec_name, const char *value)
-{
-  Cli_Debug("ConfigSet: rec_name %s value %s\n", rec_name, value);
-
-  TSError status;
-  TSActionNeedT action_need;
-
-  status = Cli_RecordSet(rec_name, value, &action_need);
-  if (status) {
-    return status;
-  }
-
-  return (Cli_ConfigEnactChanges(action_need));
-}
-
-// config name sub-command
-//   used to set or display the value of proxy.config.proxy_name
-
-int
-ConfigName(const char *proxy_name)
-{
-  TSError status = TS_ERR_OKAY;
-  TSString str_val = NULL;
-  TSActionNeedT action_need;
-
-  if (proxy_name) {             // set the name
-
-    Cli_Debug("ConfigName: set name proxy_name %s\n", proxy_name);
-
-    status = Cli_RecordSetString("proxy.config.proxy_name", (TSString) proxy_name, &action_need);
-
-    if (status) {
-      return status;
-    }
-
-    return (Cli_ConfigEnactChanges(action_need));
-
-  }
-
-  else {                        // display the name
-    Cli_Debug("ConfigName: get name\n");
-
-    status = Cli_RecordGetString("proxy.config.proxy_name", &str_val);
-    if (status) {
-      return status;
-    }
-
-    if (str_val) {
-      Cli_Printf("%s\n", str_val);
-    } else {
-      Cli_Printf("none\n");
-    }
-  }
-
-  return CLI_OK;
-
-}
-
-// config ports sub-command
-//   used to set the value of port(s)
-
-int
-ConfigPortsSet(int arg_ref, void *valuePtr)
-{
-
-  switch (arg_ref) {
-  case CMD_CONFIG_PORTS_CONNECT:
-    Cli_Debug("ConfigPortsSet: arg_ref %d value %s\n", arg_ref, (char *) valuePtr);
-    break;
-  default:
-    Cli_Debug("ConfigPortsSet: arg_ref %d value %d\n", arg_ref, *(TSInt *) valuePtr);
-  }
-
-  TSError status = TS_ERR_OKAY;
-  TSActionNeedT action_need = TS_ACTION_UNDEFINED;
-
-  Cli_Debug("ConfigPorts: set\n");
-  switch (arg_ref) {
-  case CMD_CONFIG_PORTS_HTTP_SERVER:
-    status = Cli_RecordSetInt("proxy.config.http.server_port", *(TSInt *) valuePtr, &action_need);
-    break;
-  case CMD_CONFIG_PORTS_CLUSTER:
-    status = Cli_RecordSetInt("proxy.config.cluster.cluster_port", *(TSInt *) valuePtr, &action_need);
-    break;
-  case CMD_CONFIG_PORTS_CLUSTER_RS:
-    status = Cli_RecordSetInt("proxy.config.cluster.rsport", *(TSInt *) valuePtr, &action_need);
-    break;
-  case CMD_CONFIG_PORTS_CLUSTER_MC:
-    status = Cli_RecordSetInt("proxy.config.cluster.mcport", *(TSInt *) valuePtr, &action_need);
-    break;
-  case CMD_CONFIG_PORTS_CONNECT:
-    status = Cli_RecordSetString("proxy.config.http.connect_ports", (TSString) valuePtr, &action_need);
-    break;
-  case CMD_CONFIG_PORTS_SOCKS_SERVER:
-    status = Cli_RecordSetInt("proxy.config.socks.socks_server_port", *(TSInt *) valuePtr, &action_need);
-    break;
-  case CMD_CONFIG_PORTS_ICP:
-    status = Cli_RecordSetInt("proxy.config.icp.icp_port", *(TSInt *) valuePtr, &action_need);
-    break;
-  }
-
-  if (status) {
-    return status;
-  }
-
-  return (Cli_ConfigEnactChanges(action_need));
-
-}
-
-// config ports sub-command
-//   used to display the value of port(s)
-
-int
-ConfigPortsGet(int arg_ref)
-{
-  TSError status = TS_ERR_OKAY;
-  TSInt int_val = -1;
-  TSString str_val = NULL;
-
-  Cli_Debug("ConfigPortsGet: get\n");
-
-  switch (arg_ref) {
-  case CMD_CONFIG_PORTS_HTTP_SERVER:
-    status = Cli_RecordGetInt("proxy.config.http.server_port", &int_val);
-    if (status) {
-      return status;
-    }
-    Cli_Printf("%d\n", int_val);
-    break;
-  case CMD_CONFIG_PORTS_CLUSTER:
-    status = Cli_RecordGetInt("proxy.config.cluster.cluster_port", &int_val);
-    if (status) {
-      return status;
-    }
-    Cli_Printf("%d\n", int_val);
-    break;
-  case CMD

<TRUNCATED>

[02/44] git commit: TS-2348: Rename tstop to traffic_top

Posted by zw...@apache.org.
TS-2348: Rename tstop to traffic_top


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

Branch: refs/heads/5.0.x
Commit: 88666ad43f65f5218602955b2bffcf2ba1883d30
Parents: 9dd6348
Author: James Peach <jp...@apache.org>
Authored: Sat Nov 9 15:33:53 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Wed Nov 13 15:01:59 2013 -0800

----------------------------------------------------------------------
 CHANGES                                   |   2 +
 Makefile.am                               |   4 +-
 cmd/Makefile.am                           |  18 ++
 cmd/traffic_top/Makefile.am               |  40 +++
 cmd/traffic_top/README                    |   4 +
 cmd/traffic_top/stats.h                   | 393 +++++++++++++++++++++++++
 cmd/traffic_top/traffic_top.cc            | 376 +++++++++++++++++++++++
 configure.ac                              |   2 +
 doc/admin/getting-started.en.rst          |   2 +-
 doc/admin/monitoring-traffic.en.rst       |   2 +-
 doc/conf.py                               |   2 +-
 doc/reference/commands/index.en.rst       |   8 +-
 doc/reference/commands/traffic_top.en.rst |  27 ++
 doc/reference/commands/tstop.en.rst       |  29 --
 tools/Makefile.am                         |  18 --
 tools/tstop/.gitignore                    |   1 -
 tools/tstop/README                        |   4 -
 tools/tstop/stats.h                       | 393 -------------------------
 tools/tstop/tstop.cc                      | 378 ------------------------
 19 files changed, 870 insertions(+), 833 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 5e3c759..56b3d62 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 Changes with Apache Traffic Server 4.2.0
 
 
+  *) [TS-2348] Rename tstop to traffic_top.
+
   *) [TS-2340] Fix TextLogObject log rolling.
    Author: bettydramit <b1...@gmail.com>
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 273e7b4..9312d4a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,9 +29,9 @@ export CCACHE_BASEDIR
 # proxy/api/ts has to be built first, since so much of libraries and "core
 # depends on the generates ts/ts.h include file.
 if STANDALONE_IOCORE
-SUBDIRS =  proxy/api/ts iocore lib proxy/hdrs proxy/shared mgmt proxy cop plugins tools example
+SUBDIRS =  proxy/api/ts iocore lib proxy/hdrs proxy/shared mgmt proxy cop plugins cmd tools example
 else
-SUBDIRS =  proxy/api/ts iocore lib proxy/hdrs proxy/shared mgmt proxy cop rc doc plugins tools example
+SUBDIRS =  proxy/api/ts iocore lib proxy/hdrs proxy/shared mgmt proxy cop rc doc plugins cmd tools example
 endif
 
 DIST_BUILD_USER=`id -nu`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/cmd/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
new file mode 100644
index 0000000..097159d
--- /dev/null
+++ b/cmd/Makefile.am
@@ -0,0 +1,18 @@
+#
+#  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.
+
+SUBDIRS = traffic_top

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/cmd/traffic_top/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/Makefile.am b/cmd/traffic_top/Makefile.am
new file mode 100644
index 0000000..292d350
--- /dev/null
+++ b/cmd/traffic_top/Makefile.am
@@ -0,0 +1,40 @@
+#
+#  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.
+
+# We only build tstop if libcurses and libcurl are available.
+if BUILD_TSTOP
+
+bin_PROGRAMS = traffic_top
+
+AM_CPPFLAGS = $(iocore_include_dirs) \
+  -I$(top_srcdir)/lib -I$(top_builddir)/lib \
+  -I$(top_srcdir)/lib/ts -I$(top_builddir)/lib/ts
+
+traffic_top_CPPFLAGS = \
+  -I$(top_srcdir)/mgmt/api/include
+traffic_top_CXXFLAGS = \
+  @CURL_CFLAGS@
+
+traffic_top_SOURCES = traffic_top.cc
+traffic_top_LDADD = \
+  $(top_builddir)/mgmt/api/libtsmgmt.la \
+  @CURL_LIBS@ @CURSES_LIB@
+
+# Install a compatibility symlink because traffic_top was named tstop in previous releases.
+install-exec-hook:
+	cd $(DESTDIR)$(bindir) && $(LN_S) traffic_top tstop
+endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/cmd/traffic_top/README
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/README b/cmd/traffic_top/README
new file mode 100644
index 0000000..10f33b7
--- /dev/null
+++ b/cmd/traffic_top/README
@@ -0,0 +1,4 @@
+Top type program for Apache Traffic Server that displays common
+statistical information about the server.  Requires the server to be
+running the stats_over_http plugin.
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/cmd/traffic_top/stats.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/stats.h b/cmd/traffic_top/stats.h
new file mode 100644
index 0000000..35295c8
--- /dev/null
+++ b/cmd/traffic_top/stats.h
@@ -0,0 +1,393 @@
+/** @file
+
+    Include file for the tstop stats.
+
+    @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.
+*/
+
+#define __STDC_FORMAT_MACROS 1
+
+#include <curl/curl.h>
+#include <map>
+#include <string>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include "mgmtapi.h"
+
+using namespace std;
+
+struct LookupItem {
+  LookupItem(const char *s, const char *n, const int t): pretty(s), name(n), type(t) {}
+  LookupItem(const char *s, const char *n, const char *d, const int t): pretty(s), name(n), numerator(n), denominator(d), type(t) {}
+  const char *pretty;
+  const char *name;
+  const char *numerator;
+  const char *denominator;
+  int type;
+};
+extern size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream);
+extern char curl_error[CURL_ERROR_SIZE];
+extern string response;
+
+namespace constant {
+  const char global[] = "\"global\": {\n";
+  const char start[] = "\"proxy.process.";
+  const char seperator[] = "\": \"";
+  const char end[] = "\",\n";
+};
+
+//----------------------------------------------------------------------------
+class Stats {
+public:
+  Stats(const string &host) {
+    _host = host;
+    _stats = NULL;
+    _old_stats = NULL;
+    _absolute = false;
+    lookup_table.insert(make_pair("version", LookupItem("Version", "proxy.process.version.server.short", 1)));
+    lookup_table.insert(make_pair("disk_used", LookupItem("Disk Used", "proxy.process.cache.bytes_used", 1)));
+    lookup_table.insert(make_pair("disk_total", LookupItem("Disk Total", "proxy.process.cache.bytes_total", 1)));
+    lookup_table.insert(make_pair("ram_used", LookupItem("Ram Used", "proxy.process.cache.ram_cache.bytes_used", 1)));
+    lookup_table.insert(make_pair("ram_total", LookupItem("Ram Total", "proxy.process.cache.ram_cache.total_bytes", 1)));
+    lookup_table.insert(make_pair("lookups", LookupItem("Lookups", "proxy.process.http.cache_lookups", 2)));
+    lookup_table.insert(make_pair("cache_writes", LookupItem("Writes", "proxy.process.http.cache_writes", 2)));
+    lookup_table.insert(make_pair("cache_updates", LookupItem("Updates", "proxy.process.http.cache_updates", 2)));
+    lookup_table.insert(make_pair("cache_deletes", LookupItem("Deletes", "proxy.process.http.cache_deletes", 2)));
+    lookup_table.insert(make_pair("read_active", LookupItem("Read Active", "proxy.process.cache.read.active", 1)));
+    lookup_table.insert(make_pair("write_active", LookupItem("Writes Active", "proxy.process.cache.write.active", 1)));
+    lookup_table.insert(make_pair("update_active", LookupItem("Update Active", "proxy.process.cache.update.active", 1)));
+    lookup_table.insert(make_pair("entries", LookupItem("Entries", "proxy.process.cache.direntries.used", 1)));
+    lookup_table.insert(make_pair("avg_size", LookupItem("Avg Size", "disk_used", "entries", 3)));
+
+    lookup_table.insert(make_pair("dns_time", LookupItem("DNS Time", "proxy.node.dns.lookup_avg_time_ms", 2)));
+    lookup_table.insert(make_pair("dns_hits", LookupItem("DNS hits", "proxy.node.hostdb.total_hits", 2)));
+    lookup_table.insert(make_pair("dns_lookups", LookupItem("DNS lookups", "proxy.node.hostdb.total_lookups", 2)));
+    lookup_table.insert(make_pair("client_req", LookupItem("Requests", "proxy.process.http.incoming_requests", 2)));
+    lookup_table.insert(make_pair("client_conn", LookupItem("New Conn", "proxy.process.http.total_client_connections", 2)));
+    lookup_table.insert(make_pair("client_req_conn", LookupItem("Req/Conn", "client_req", "client_conn", 3)));
+    lookup_table.insert(make_pair("client_curr_conn", LookupItem("Curr Conn", "proxy.process.http.current_client_connections", 1)));
+    lookup_table.insert(make_pair("client_actv_conn", LookupItem("Active Con", "proxy.process.http.current_active_client_connections", 1)));
+
+    lookup_table.insert(make_pair("server_req", LookupItem("Requests", "proxy.process.http.outgoing_requests", 2)));
+    lookup_table.insert(make_pair("server_conn", LookupItem("New Conn", "proxy.process.http.total_server_connections", 2)));
+    lookup_table.insert(make_pair("server_req_conn", LookupItem("Req/Conn", "server_req", "server_conn", 3)));
+    lookup_table.insert(make_pair("server_curr_conn", LookupItem("Curr Conn", "proxy.process.http.current_server_connections", 1)));
+
+
+    lookup_table.insert(make_pair("client_head", LookupItem("Head Bytes", "proxy.process.http.user_agent_response_header_total_size", 2)));
+    lookup_table.insert(make_pair("client_body", LookupItem("Body Bytes", "proxy.process.http.user_agent_response_document_total_size", 2)));
+    lookup_table.insert(make_pair("server_head", LookupItem("Head Bytes", "proxy.process.http.origin_server_response_header_total_size", 2)));
+    lookup_table.insert(make_pair("server_body", LookupItem("Body Bytes", "proxy.process.http.origin_server_response_document_total_size", 2)));
+
+    // not used directly
+    lookup_table.insert(make_pair("ram_hit", LookupItem("Ram Hit", "proxy.process.cache.ram_cache.hits", 2)));
+    lookup_table.insert(make_pair("ram_miss", LookupItem("Ram Misses", "proxy.process.cache.ram_cache.misses", 2)));
+
+
+
+    lookup_table.insert(make_pair("client_abort", LookupItem("Clnt Abort", "proxy.process.http.err_client_abort_count_stat", 2)));
+    lookup_table.insert(make_pair("conn_fail", LookupItem("Conn Fail", "proxy.process.http.err_connect_fail_count_stat", 2)));
+    lookup_table.insert(make_pair("abort", LookupItem("Abort", "proxy.process.http.transaction_counts.errors.aborts", 2)));
+    lookup_table.insert(make_pair("t_conn_fail", LookupItem("Conn Fail", "proxy.process.http.transaction_counts.errors.connect_failed", 2)));
+    lookup_table.insert(make_pair("other_err", LookupItem("Other Err", "proxy.process.http.transaction_counts.errors.other", 2)));
+    // percentage
+    lookup_table.insert(make_pair("ram_ratio", LookupItem("Ram Hit", "ram_hit", "ram_hit_miss", 4)));
+    lookup_table.insert(make_pair("dns_ratio", LookupItem("DNS Hit", "dns_hits", "dns_lookups", 4)));
+
+    // percentage of requests
+    lookup_table.insert(make_pair("fresh", LookupItem("Fresh", "proxy.process.http.transaction_counts.hit_fresh", 5)));
+    lookup_table.insert(make_pair("reval", LookupItem("Revalidate", "proxy.process.http.transaction_counts.hit_revalidated", 5)));
+    lookup_table.insert(make_pair("cold", LookupItem("Cold", "proxy.process.http.transaction_counts.miss_cold", 5)));
+    lookup_table.insert(make_pair("changed", LookupItem("Changed", "proxy.process.http.transaction_counts.miss_changed", 5)));
+    lookup_table.insert(make_pair("not", LookupItem("Not Cache", "proxy.process.http.transaction_counts.miss_not_cacheable", 5)));
+    lookup_table.insert(make_pair("no", LookupItem("No Cache", "proxy.process.http.transaction_counts.miss_client_no_cache", 5)));
+
+    lookup_table.insert(make_pair("fresh_time", LookupItem("Fresh (ms)", "proxy.process.http.transaction_totaltime.hit_fresh", "fresh", 8)));
+    lookup_table.insert(make_pair("reval_time", LookupItem("Reval (ms)", "proxy.process.http.transaction_totaltime.hit_revalidated", "reval", 8)));
+    lookup_table.insert(make_pair("cold_time", LookupItem("Cold (ms)", "proxy.process.http.transaction_totaltime.miss_cold", "cold", 8)));
+    lookup_table.insert(make_pair("changed_time", LookupItem("Chang (ms)", "proxy.process.http.transaction_totaltime.miss_changed", "changed", 8)));
+    lookup_table.insert(make_pair("not_time", LookupItem("Not (ms)", "proxy.process.http.transaction_totaltime.miss_not_cacheable", "not", 8)));
+    lookup_table.insert(make_pair("no_time", LookupItem("No (ms)", "proxy.process.http.transaction_totaltime.miss_client_no_cache", "no", 8)));
+
+    lookup_table.insert(make_pair("get", LookupItem("GET", "proxy.process.http.get_requests", 5)));
+    lookup_table.insert(make_pair("head", LookupItem("HEAD", "proxy.process.http.head_requests", 5)));
+    lookup_table.insert(make_pair("post", LookupItem("POST", "proxy.process.http.post_requests", 5)));
+    lookup_table.insert(make_pair("2xx", LookupItem("2xx", "proxy.process.http.2xx_responses", 5)));
+    lookup_table.insert(make_pair("3xx", LookupItem("3xx", "proxy.process.http.3xx_responses", 5)));
+    lookup_table.insert(make_pair("4xx", LookupItem("4xx", "proxy.process.http.4xx_responses", 5)));
+    lookup_table.insert(make_pair("5xx", LookupItem("5xx", "proxy.process.http.5xx_responses", 5)));
+
+    lookup_table.insert(make_pair("200", LookupItem("200", "proxy.process.http.200_responses", 5)));
+    lookup_table.insert(make_pair("206", LookupItem("206", "proxy.process.http.206_responses", 5)));
+    lookup_table.insert(make_pair("301", LookupItem("301", "proxy.process.http.301_responses", 5)));
+    lookup_table.insert(make_pair("302", LookupItem("302", "proxy.process.http.302_responses", 5)));
+    lookup_table.insert(make_pair("304", LookupItem("304", "proxy.process.http.304_responses", 5)));
+    lookup_table.insert(make_pair("404", LookupItem("404", "proxy.process.http.404_responses", 5)));
+    lookup_table.insert(make_pair("502", LookupItem("502", "proxy.process.http.502_responses", 5)));
+
+    lookup_table.insert(make_pair("s_100", LookupItem("100 B", "proxy.process.http.response_document_size_100", 5)));
+    lookup_table.insert(make_pair("s_1k", LookupItem("1 KB", "proxy.process.http.response_document_size_1K", 5)));
+    lookup_table.insert(make_pair("s_3k", LookupItem("3 KB", "proxy.process.http.response_document_size_3K", 5)));
+    lookup_table.insert(make_pair("s_5k", LookupItem("5 KB", "proxy.process.http.response_document_size_5K", 5)));
+    lookup_table.insert(make_pair("s_10k", LookupItem("10 KB", "proxy.process.http.response_document_size_10K", 5)));
+    lookup_table.insert(make_pair("s_1m", LookupItem("1 MB", "proxy.process.http.response_document_size_1M", 5)));
+    lookup_table.insert(make_pair("s_>1m", LookupItem("> 1 MB", "proxy.process.http.response_document_size_inf", 5)));
+
+
+    // sum together
+    lookup_table.insert(make_pair("ram_hit_miss", LookupItem("Ram Hit+Miss", "ram_hit", "ram_miss", 6)));
+    lookup_table.insert(make_pair("client_net", LookupItem("Net (bits)", "client_head", "client_body", 7)));
+    lookup_table.insert(make_pair("client_size", LookupItem("Total Size", "client_head", "client_body", 6)));
+    lookup_table.insert(make_pair("client_avg_size", LookupItem("Avg Size", "client_size", "client_req", 3)));
+
+    lookup_table.insert(make_pair("server_net", LookupItem("Net (bits)", "server_head", "server_body", 7)));
+    lookup_table.insert(make_pair("server_size", LookupItem("Total Size", "server_head", "server_body", 6)));
+    lookup_table.insert(make_pair("server_avg_size", LookupItem("Avg Size", "server_size", "server_req", 3)));
+
+
+    lookup_table.insert(make_pair("total_time", LookupItem("Total Time", "proxy.process.http.total_transactions_time", 2)));
+    lookup_table.insert(make_pair("client_req_time", LookupItem("Resp (ms)", "total_time", "client_req", 3)));
+  }
+
+  void getStats() {
+
+    if (_host == "") {
+      int64_t value = 0;
+      if (_old_stats != NULL) {
+        delete _old_stats;
+        _old_stats = NULL;
+      }
+      _old_stats = _stats;
+      _stats = new map<string, string>;
+
+      gettimeofday(&_time, NULL);
+      double now = _time.tv_sec + (double)_time.tv_usec / 1000000;
+
+      for (map<string, LookupItem>::const_iterator lookup_it = lookup_table.begin();
+           lookup_it != lookup_table.end(); ++lookup_it) {
+        const LookupItem &item = lookup_it->second;
+
+        if (item.type == 1 || item.type == 2 || item.type == 5 || item.type == 8) {
+          if (strcmp(item.pretty, "Version") == 0) {
+            // special case for Version informaion
+            TSString strValue = NULL;
+            assert(TSRecordGetString(item.name, &strValue) == TS_ERR_OKAY);
+            string key = item.name;
+            (*_stats)[key] = strValue;
+          } else {
+            assert(TSRecordGetInt(item.name, &value) == TS_ERR_OKAY);
+            string key = item.name;
+            char buffer[32];
+            sprintf(buffer, "%" PRId64, value);
+            string foo = buffer;
+            (*_stats)[key] = foo;
+          }
+        }
+      } 
+      _old_time = _now;
+      _now = now;
+      _time_diff = _now - _old_time;
+    } else {
+      CURL *curl;
+      CURLcode res;
+
+      curl = curl_easy_init();
+      if (curl) {
+        string url = "http://" + _host + "/_stats";
+        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
+        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_error);
+
+        // update time
+        gettimeofday(&_time, NULL);
+        double now = _time.tv_sec + (double)_time.tv_usec / 1000000;
+
+        response.clear();
+        response.reserve(32768); // should hopefully be smaller then 32KB
+        res = curl_easy_perform(curl);
+
+        // only if success update stats and time information
+        if (res == 0) {
+          if (_old_stats != NULL) {
+            delete _old_stats;
+            _old_stats = NULL;
+          }
+          _old_stats = _stats;
+          _stats = new map<string, string>;
+
+          // parse
+          parseResponse(response);
+          _old_time = _now;
+          _now = now;
+          _time_diff = _now - _old_time;
+        }
+
+        /* always cleanup */ 
+        curl_easy_cleanup(curl);
+      }
+    }
+  }
+
+  int64_t getValue(const string &key, const map<string, string> *stats) const {
+    map<string, string>::const_iterator stats_it = stats->find(key);
+    assert(stats_it != stats->end());
+    int64_t value = atoll(stats_it->second.c_str());
+    return value;
+  }
+
+  void getStat(const string &key, double &value, int overrideType = 0) {
+    string strtmp;
+    int typetmp;
+    getStat(key, value, strtmp, typetmp, overrideType);
+  }
+
+
+  void getStat(const string &key, string &value) {
+    map<string, LookupItem>::const_iterator lookup_it = lookup_table.find(key);
+    assert(lookup_it != lookup_table.end());
+    const LookupItem &item = lookup_it->second;
+    
+    map<string, string>::const_iterator stats_it = _stats->find(item.name);
+    assert(stats_it != _stats->end());
+    value = stats_it->second.c_str();
+  }
+
+  void getStat(const string &key, double &value, string &prettyName, int &type, int overrideType = 0) {
+    map<string, LookupItem>::const_iterator lookup_it = lookup_table.find(key);
+    assert(lookup_it != lookup_table.end());
+    const LookupItem &item = lookup_it->second;
+    prettyName = item.pretty;
+    if (overrideType != 0)
+      type = overrideType;
+    else
+      type = item.type;
+
+    if (type == 1 || type == 2 || type == 5 || type == 8) {
+      value = getValue(item.name, _stats);
+      if (key == "total_time") {
+        value = value / 10000000;
+      }
+
+      if ((type == 2 || type == 5 || type == 8) && _old_stats != NULL && _absolute == false) {
+        double old = getValue(item.name, _old_stats);
+        if (key == "total_time") {
+          old = old / 10000000;
+        }
+        value = (value - old) / _time_diff;
+      }
+    } else if (type == 3 || type == 4) {
+      double numerator;
+      double denominator;
+      getStat(item.numerator, numerator);
+      getStat(item.denominator, denominator);
+      if (denominator == 0)
+        value = 0;
+      else
+        value = numerator / denominator;
+      if (type == 4) {
+        value *= 100;
+      }
+    } else if (type == 6 || type == 7) {
+      double numerator;
+      double denominator;
+      getStat(item.numerator, numerator, 2);
+      getStat(item.denominator, denominator, 2);
+      value = numerator + denominator;
+      if (type == 7)
+        value *= 8;
+    }
+
+    if (type == 8) {
+      double denominator;
+      getStat(item.denominator, denominator, 2);
+      if (denominator == 0)
+        value = 0;
+      else
+        value = value / denominator * 1000;
+    }
+
+    if (type == 5) {
+      double denominator = 0;
+      getStat("client_req", denominator);
+      if (denominator == 0)
+        value = 0;
+      else
+        value = value / denominator * 100;
+    }
+  }
+
+  bool toggleAbsolute() {
+    if (_absolute == true)
+      _absolute = false;
+    else
+      _absolute = true;
+
+    return _absolute;
+  }
+
+  void parseResponse(const string &response) {
+    // move past global
+    size_t pos = response.find(constant::global);
+    pos += sizeof(constant::global) - 1;
+
+    // find parts of the line
+    while (1) {
+      size_t start = response.find(constant::start, pos);
+      size_t seperator = response.find(constant::seperator, pos);
+      size_t end = response.find(constant::end, pos);
+  
+      if (start == string::npos || seperator == string::npos || end == string::npos)
+        return;
+
+      //cout << constant::start << " " << start << endl;
+      //cout << constant::seperator << " " << seperator << endl;
+      //cout << constant::end << " " << end << endl;
+
+      string key = response.substr(start + 1, seperator - start - 1);
+      string value = response.substr(seperator + sizeof(constant::seperator) - 1, end - seperator - sizeof(constant::seperator) + 1);
+
+      (*_stats)[key] = value;
+      //cout << "key " << key << " " << "value " << value << endl;
+      pos = end + sizeof(constant::end) - 1;
+      //cout << "pos: " << pos << endl;
+    }
+  }
+
+  ~Stats() {
+    if (_stats != NULL) {
+      delete _stats;
+    }
+    if (_old_stats != NULL) {
+      delete _old_stats;
+    }
+  }
+
+private:
+  map<string, string> *_stats;
+  map<string, string> *_old_stats;
+  map<string, LookupItem> lookup_table;
+  string _host;
+  double _old_time;
+  double _now;
+  double _time_diff;
+  struct timeval _time;
+  bool _absolute;
+};

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/cmd/traffic_top/traffic_top.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/traffic_top.cc b/cmd/traffic_top/traffic_top.cc
new file mode 100644
index 0000000..a801520
--- /dev/null
+++ b/cmd/traffic_top/traffic_top.cc
@@ -0,0 +1,376 @@
+/** @file
+
+    Main file for the traffic_top application.
+
+    @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 "ink_config.h"
+#include <map>
+#include <list>
+#include <string>
+#include <string.h>
+#include <iostream>
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+
+// At least on solaris, the default ncurses defines macros such as
+// clear() that break stdlibc++.
+#define NOMACROS 1
+#define NCURSES_NOMACROS 1
+
+#if defined HAVE_NCURSESW_CURSES_H
+#  include <ncursesw/curses.h>
+#elif defined HAVE_NCURSESW_H
+#  include <ncursesw.h>
+#elif defined HAVE_NCURSES_CURSES_H
+#  include <ncurses/curses.h>
+#elif defined HAVE_NCURSES_H
+#  include <ncurses.h>
+#elif defined HAVE_CURSES_H
+#  include <curses.h>
+#else
+#  error "SysV or X/Open-compatible Curses header file required"
+#endif
+
+#include "stats.h"
+
+using namespace std;
+char curl_error[CURL_ERROR_SIZE];
+string response;
+
+namespace colorPair {
+  const short red = 1;
+  const short yellow = 2;
+  const short green = 3;
+  const short blue = 4;
+  const short black = 5;
+  const short grey = 6;
+  const short cyan = 7;
+  const short border = 8;
+};
+
+//----------------------------------------------------------------------------
+static void prettyPrint(const int x, const int y, const double number, const int type) {
+  char buffer[32];
+  char exp = ' ';
+  double my_number = number;
+  short color;
+  if (number > 1000000000000LL) {
+    my_number = number / 1000000000000LL;
+    exp = 'T';
+    color = colorPair::red;
+  } else if (number > 1000000000) {
+    my_number = number / 1000000000;
+    exp = 'G';
+    color = colorPair::red;
+  } else if (number > 1000000) {
+    my_number = number / 1000000;
+    exp = 'M';
+    color = colorPair::yellow;
+  } else if (number > 1000) {
+    my_number = number / 1000;
+    exp = 'K';
+    color = colorPair::cyan;
+  } else if (my_number <= .09) {
+    color = colorPair::grey;
+  } else {
+    color = colorPair::green;
+  }
+
+  if (type == 4 || type == 5) {
+    if (number > 90) {
+      color = colorPair::red;
+    } else if (number > 80) {
+      color = colorPair::yellow;
+    } else if (number > 50) {
+      color = colorPair::blue;
+    } else if (my_number <= .09) {
+      color = colorPair::grey;
+    } else {
+      color = colorPair::green;
+    }
+    snprintf(buffer, sizeof(buffer), "%6.1f%%%%", (double)my_number);
+  } else
+    snprintf(buffer, sizeof(buffer), "%6.1f%c", (double)my_number, exp);
+  attron(COLOR_PAIR(color));
+  attron(A_BOLD);
+  mvprintw(y, x, buffer);
+  attroff(COLOR_PAIR(color));
+  attroff(A_BOLD);
+}
+
+//----------------------------------------------------------------------------
+static void makeTable(const int x, const int y, const list<string> &items, Stats &stats) {
+  int my_y = y;
+
+  for (list<string>::const_iterator it = items.begin(); it != items.end(); ++it) {
+    string prettyName;
+    double value = 0;
+    int type;
+
+    stats.getStat(*it, value, prettyName, type);
+    mvprintw(my_y, x, prettyName.c_str());
+    prettyPrint(x + 10, my_y++, value, type);
+  }
+}
+
+//----------------------------------------------------------------------------
+size_t write_data(void *ptr, size_t size, size_t nmemb, void * /* stream */)
+{
+  response.append((char*)ptr, size * nmemb);
+  //cout << "appending: " << size * nmemb << endl;
+  //int written = fwrite(ptr, size, nmemb, (FILE *)stream);
+  return size * nmemb;
+}
+
+//----------------------------------------------------------------------------
+static void help(const string &host, const string &version) {
+
+  timeout(1000);
+
+  while(1) {
+    clear();
+    time_t now = time(NULL);
+    struct tm *nowtm = localtime(&now);
+    char timeBuf[32];
+    strftime(timeBuf, sizeof(timeBuf), "%H:%M:%S", nowtm);
+
+    //clear();
+    attron(A_BOLD); mvprintw(0, 0, "Overview:"); attroff(A_BOLD);
+    mvprintw(1, 0,
+      "traffic_top is a top like program for Apache Traffic Server (ATS). "
+      "There is a lot of statistical information gathered by ATS. "
+      "This program tries to show some of the more important stats and gives a good overview of what the proxy server is doing. "
+      "Hopefully this can be used as a tool for diagnosing the proxy server if there are problems.");
+
+    attron(A_BOLD); mvprintw(7, 0, "Definitions:"); attroff(A_BOLD);
+    mvprintw(8,  0, "Fresh      => Requests that were servered by fresh entries in cache");
+    mvprintw(9,  0, "Revalidate => Requests that contacted the origin to verify if still valid");
+    mvprintw(10, 0, "Cold       => Requests that were not in cache at all");
+    mvprintw(11, 0, "Changed    => Requests that required entries in cache to be updated");
+    mvprintw(12, 0, "Changed    => Requests that can't be cached for some reason");
+    mvprintw(12, 0, "No Cache   => Requests that the client sent Cache-Control: no-cache header");
+
+    attron(COLOR_PAIR(colorPair::border));
+    attron(A_BOLD);
+    mvprintw(23, 0, "%s - %.12s - %.12s      (b)ack                            ", timeBuf, version.c_str(), host.c_str());
+    attroff(COLOR_PAIR(colorPair::border));
+    attroff(A_BOLD);
+    refresh();
+    int x = getch();
+    if (x == 'b')
+      break;
+  }
+}
+
+static void usage()
+{
+  fprintf(stderr, "Usage: traffic_top [-s seconds] hostname|hostname:port\n");
+  exit(1);
+}
+
+//----------------------------------------------------------------------------
+int main(int argc, char **argv)
+{
+  int sleep_time = 5000;
+  bool absolute = false;
+  int opt;
+  while ((opt = getopt(argc, argv, "s:")) != -1) {
+    switch(opt) {
+    case 's':
+      sleep_time = atoi(optarg) * 1000;
+      break;
+    default:
+      usage();
+    }
+  }
+
+  string host = "";
+  if (optind >= argc) {
+    if (TS_ERR_OKAY != TSInit(NULL, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS | TS_MGMT_OPT_NO_SOCK_TESTS))) {
+      fprintf(stderr, "Error: missing hostname on command line or error connecting to the local manager\n");
+      usage();
+    }
+  } else {
+    host = argv[optind];
+  }
+  Stats stats(host);
+
+  if (host == "") {
+    char hostname[25];
+    hostname[sizeof(hostname) - 1] = '\0';
+    gethostname(hostname, sizeof(hostname) - 1);
+    host = hostname;
+  }
+
+  initscr();
+  curs_set(0);
+
+  start_color();			/* Start color functionality	*/
+
+  init_pair(colorPair::red, COLOR_RED, COLOR_BLACK);
+  init_pair(colorPair::yellow, COLOR_YELLOW, COLOR_BLACK);
+  init_pair(colorPair::grey, COLOR_BLACK, COLOR_BLACK);
+  init_pair(colorPair::green, COLOR_GREEN, COLOR_BLACK);
+  init_pair(colorPair::blue, COLOR_BLUE, COLOR_BLACK);
+  init_pair(colorPair::cyan, COLOR_CYAN, COLOR_BLACK);
+  init_pair(colorPair::border, COLOR_WHITE, COLOR_BLUE);
+  //  mvchgat(0, 0, -1, A_BLINK, 1, NULL);
+
+  stats.getStats();
+  while(1) {
+    attron(COLOR_PAIR(colorPair::border));
+    attron(A_BOLD);
+    for (int i = 0; i <= 22; ++i) {
+      mvprintw(i, 39, " ");
+    }
+    string version;
+    time_t now = time(NULL);
+    struct tm *nowtm = localtime(&now);
+    char timeBuf[32];
+    strftime(timeBuf, sizeof(timeBuf), "%H:%M:%S", nowtm);
+    stats.getStat("version", version);
+    mvprintw(0, 0, "         CACHE INFORMATION             ");
+    mvprintw(0, 40, "       CLIENT REQUEST & RESPONSE        ");
+    mvprintw(16, 0, "             CLIENT                    ");
+    mvprintw(16, 40, "           ORIGIN SERVER                ");
+    mvprintw(23, 0, "%8.8s - %-10.10s - %-24.24s      (q)uit (h)elp (%c)bsolute  ", timeBuf, version.c_str(), host.c_str(), absolute ? 'A' : 'a');
+    attroff(COLOR_PAIR(colorPair::border));
+    attroff(A_BOLD);
+
+    list<string> cache1;
+    cache1.push_back("disk_used");
+    cache1.push_back("disk_total");
+    cache1.push_back("ram_used");
+    cache1.push_back("ram_total");
+    cache1.push_back("lookups");
+    cache1.push_back("cache_writes");
+    cache1.push_back("cache_updates");
+    cache1.push_back("cache_deletes");
+    cache1.push_back("read_active");
+    cache1.push_back("write_active");
+    cache1.push_back("update_active");
+    cache1.push_back("entries");
+    cache1.push_back("avg_size");
+    cache1.push_back("dns_lookups");
+    cache1.push_back("dns_hits");
+    makeTable(0, 1, cache1, stats);
+
+    list<string> cache2;
+    cache2.push_back("ram_ratio");
+    cache2.push_back("fresh");
+    cache2.push_back("reval");
+    cache2.push_back("cold");
+    cache2.push_back("changed");
+    cache2.push_back("not");
+    cache2.push_back("no");
+    cache2.push_back("fresh_time");
+    cache2.push_back("reval_time");
+    cache2.push_back("cold_time");
+    cache2.push_back("changed_time");
+    cache2.push_back("not_time");
+    cache2.push_back("no_time");
+    cache2.push_back("dns_ratio");
+    cache2.push_back("dns_time");
+    makeTable(21, 1, cache2, stats);
+
+    list<string> response1;
+    response1.push_back("get");
+    response1.push_back("head");
+    response1.push_back("post");
+    response1.push_back("2xx");
+    response1.push_back("3xx");
+    response1.push_back("4xx");
+    response1.push_back("5xx");
+    response1.push_back("conn_fail");
+    response1.push_back("other_err");
+    response1.push_back("abort");
+    makeTable(41, 1, response1, stats);
+
+    list<string> response2;
+    response2.push_back("200");
+    response2.push_back("206");
+    response2.push_back("301");
+    response2.push_back("302");
+    response2.push_back("304");
+    response2.push_back("404");
+    response2.push_back("502");
+    response2.push_back("s_100");
+    response2.push_back("s_1k");
+    response2.push_back("s_3k");
+    response2.push_back("s_5k");
+    response2.push_back("s_10k");
+    response2.push_back("s_1m");
+    response2.push_back("s_>1m");
+    makeTable(62, 1, response2, stats);
+
+    list<string> client1;
+    client1.push_back("client_req");
+    client1.push_back("client_req_conn");
+    client1.push_back("client_conn");
+    client1.push_back("client_curr_conn");
+    client1.push_back("client_actv_conn");
+    makeTable(0, 17, client1, stats);
+
+    list<string> client2;
+    client2.push_back("client_head");
+    client2.push_back("client_body");
+    client2.push_back("client_avg_size");
+    client2.push_back("client_net");
+    client2.push_back("client_req_time");
+    makeTable(21, 17, client2, stats);
+
+    list<string> server1;
+    server1.push_back("server_req");
+    server1.push_back("server_req_conn");
+    server1.push_back("server_conn");
+    server1.push_back("server_curr_conn");
+    makeTable(41, 17, server1, stats);
+
+    list<string> server2;
+    server2.push_back("server_head");
+    server2.push_back("server_body");
+    server2.push_back("server_avg_size");
+    server2.push_back("server_net");
+    makeTable(62, 17, server2, stats);
+
+    curs_set(0);
+    refresh();
+    timeout(sleep_time);
+
+    int x = getch();
+    if (x == 'q')
+      break;
+    if (x == 'h') {
+      help(host, version);
+    }
+    if (x == 'a') {
+      absolute = stats.toggleAbsolute();
+    }
+    if (x == -1)
+      stats.getStats();
+    clear();
+  }
+  endwin();
+
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 75979e5..99a2239 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1842,6 +1842,8 @@ AC_SUBST([TFW_PACKAGE_SUFFIX])
 AC_CONFIG_FILES([
   Makefile
   cop/Makefile
+  cmd/Makefile
+  cmd/traffic_top/Makefile
   doc/Doxyfile
   doc/Makefile
   example/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/doc/admin/getting-started.en.rst
----------------------------------------------------------------------
diff --git a/doc/admin/getting-started.en.rst b/doc/admin/getting-started.en.rst
index 72936e2..bdb68d8 100644
--- a/doc/admin/getting-started.en.rst
+++ b/doc/admin/getting-started.en.rst
@@ -76,7 +76,7 @@ In order to build Traffic Server from source you will need the following
 -  hwloc
 -  lua
 -  curses
--  curl (both for tstop)
+-  curl (both for :program:`traffic_top`)
 
 if you're building from a git clone, you'll also need
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/doc/admin/monitoring-traffic.en.rst
----------------------------------------------------------------------
diff --git a/doc/admin/monitoring-traffic.en.rst b/doc/admin/monitoring-traffic.en.rst
index 348aed8..28f40ec 100644
--- a/doc/admin/monitoring-traffic.en.rst
+++ b/doc/admin/monitoring-traffic.en.rst
@@ -101,4 +101,4 @@ prepend the Traffic Line command with ``./`` (for example:
 :option:`traffic_line -r` ``variable``).
 
 
-.. XXX: We're missing docs on how to use tstop here.
+.. XXX: We're missing docs on how to use traffic_top here.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/doc/conf.py
----------------------------------------------------------------------
diff --git a/doc/conf.py b/doc/conf.py
index c3244bf..3eac055 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -276,7 +276,7 @@ man_pages = [
    ('reference/commands/traffic_shell.en', 'traffic_shell', u'Traffic Server shell', None, '8'),
 
    ('reference/commands/tspush.en', 'tspush', u'Push objects into the Traffic Server cache', None, '1'),
-   ('reference/commands/tstop.en','tstop', u'Display Traffic Server statistics', None, '1'),
+   ('reference/commands/traffic_top.en','traffic_top', u'Display Traffic Server statistics', None, '1'),
    ('reference/commands/tsxs.en', 'tsxs', u'Traffic Server plugin tool', None, '1'),
 
    ('reference/configuration/cache.config.en', 'cache.config', u'Traffic Server cache configuration file', None, '5'),

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/doc/reference/commands/index.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/index.en.rst b/doc/reference/commands/index.en.rst
index f5e30d5..6764fec 100644
--- a/doc/reference/commands/index.en.rst
+++ b/doc/reference/commands/index.en.rst
@@ -5,9 +5,9 @@
   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
@@ -28,8 +28,6 @@ Command Reference
   traffic_manager.en
   traffic_server.en
   traffic_shell.en
+  traffic_top.en
   tspush.en
-  tstop.en
   tsxs.en
-
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/doc/reference/commands/traffic_top.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/traffic_top.en.rst b/doc/reference/commands/traffic_top.en.rst
new file mode 100644
index 0000000..dec0a05
--- /dev/null
+++ b/doc/reference/commands/traffic_top.en.rst
@@ -0,0 +1,27 @@
+.. 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_top
+==========
+
+.. program:: traffic_top
+
+Description
+===========
+
+.. option:: -s COUNT

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/doc/reference/commands/tstop.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/tstop.en.rst b/doc/reference/commands/tstop.en.rst
deleted file mode 100644
index b9dbcd7..0000000
--- a/doc/reference/commands/tstop.en.rst
+++ /dev/null
@@ -1,29 +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.
-
-=====
-tstop
-=====
-
-.. program:: tstop
-
-Description
-===========
-
-.. option:: -s COUNT
-
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/tools/Makefile.am
----------------------------------------------------------------------
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 327615f..9038212 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -18,7 +18,6 @@
 #  limitations under the License.
 
 bin_SCRIPTS = tsxs tspush
-bin_PROGRAMS =
 
 AM_CPPFLAGS = $(iocore_include_dirs) \
   -I$(top_srcdir)/lib -I$(top_builddir)/lib \
@@ -40,20 +39,3 @@ http_load_http_load_SOURCES =  \
   http_load/timers.h
 
 endif
-
-# We only build tstop if libcurses and libcurl are available.
-if BUILD_TSTOP
-
-bin_PROGRAMS += tstop/tstop
-
-tstop_tstop_CPPFLAGS = \
-  -I$(top_srcdir)/mgmt/api/include
-tstop_tstop_CXXFLAGS = \
-  @CURL_CFLAGS@
-
-tstop_tstop_SOURCES = tstop/tstop.cc
-tstop_tstop_LDADD = \
-  $(top_builddir)/mgmt/api/libtsmgmt.la \
-  @CURL_LIBS@ @CURSES_LIB@
-
-endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/tools/tstop/.gitignore
----------------------------------------------------------------------
diff --git a/tools/tstop/.gitignore b/tools/tstop/.gitignore
deleted file mode 100644
index c518e71..0000000
--- a/tools/tstop/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tstop

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/tools/tstop/README
----------------------------------------------------------------------
diff --git a/tools/tstop/README b/tools/tstop/README
deleted file mode 100644
index 10f33b7..0000000
--- a/tools/tstop/README
+++ /dev/null
@@ -1,4 +0,0 @@
-Top type program for Apache Traffic Server that displays common
-statistical information about the server.  Requires the server to be
-running the stats_over_http plugin.
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/tools/tstop/stats.h
----------------------------------------------------------------------
diff --git a/tools/tstop/stats.h b/tools/tstop/stats.h
deleted file mode 100644
index 35295c8..0000000
--- a/tools/tstop/stats.h
+++ /dev/null
@@ -1,393 +0,0 @@
-/** @file
-
-    Include file for the tstop stats.
-
-    @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.
-*/
-
-#define __STDC_FORMAT_MACROS 1
-
-#include <curl/curl.h>
-#include <map>
-#include <string>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include "mgmtapi.h"
-
-using namespace std;
-
-struct LookupItem {
-  LookupItem(const char *s, const char *n, const int t): pretty(s), name(n), type(t) {}
-  LookupItem(const char *s, const char *n, const char *d, const int t): pretty(s), name(n), numerator(n), denominator(d), type(t) {}
-  const char *pretty;
-  const char *name;
-  const char *numerator;
-  const char *denominator;
-  int type;
-};
-extern size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream);
-extern char curl_error[CURL_ERROR_SIZE];
-extern string response;
-
-namespace constant {
-  const char global[] = "\"global\": {\n";
-  const char start[] = "\"proxy.process.";
-  const char seperator[] = "\": \"";
-  const char end[] = "\",\n";
-};
-
-//----------------------------------------------------------------------------
-class Stats {
-public:
-  Stats(const string &host) {
-    _host = host;
-    _stats = NULL;
-    _old_stats = NULL;
-    _absolute = false;
-    lookup_table.insert(make_pair("version", LookupItem("Version", "proxy.process.version.server.short", 1)));
-    lookup_table.insert(make_pair("disk_used", LookupItem("Disk Used", "proxy.process.cache.bytes_used", 1)));
-    lookup_table.insert(make_pair("disk_total", LookupItem("Disk Total", "proxy.process.cache.bytes_total", 1)));
-    lookup_table.insert(make_pair("ram_used", LookupItem("Ram Used", "proxy.process.cache.ram_cache.bytes_used", 1)));
-    lookup_table.insert(make_pair("ram_total", LookupItem("Ram Total", "proxy.process.cache.ram_cache.total_bytes", 1)));
-    lookup_table.insert(make_pair("lookups", LookupItem("Lookups", "proxy.process.http.cache_lookups", 2)));
-    lookup_table.insert(make_pair("cache_writes", LookupItem("Writes", "proxy.process.http.cache_writes", 2)));
-    lookup_table.insert(make_pair("cache_updates", LookupItem("Updates", "proxy.process.http.cache_updates", 2)));
-    lookup_table.insert(make_pair("cache_deletes", LookupItem("Deletes", "proxy.process.http.cache_deletes", 2)));
-    lookup_table.insert(make_pair("read_active", LookupItem("Read Active", "proxy.process.cache.read.active", 1)));
-    lookup_table.insert(make_pair("write_active", LookupItem("Writes Active", "proxy.process.cache.write.active", 1)));
-    lookup_table.insert(make_pair("update_active", LookupItem("Update Active", "proxy.process.cache.update.active", 1)));
-    lookup_table.insert(make_pair("entries", LookupItem("Entries", "proxy.process.cache.direntries.used", 1)));
-    lookup_table.insert(make_pair("avg_size", LookupItem("Avg Size", "disk_used", "entries", 3)));
-
-    lookup_table.insert(make_pair("dns_time", LookupItem("DNS Time", "proxy.node.dns.lookup_avg_time_ms", 2)));
-    lookup_table.insert(make_pair("dns_hits", LookupItem("DNS hits", "proxy.node.hostdb.total_hits", 2)));
-    lookup_table.insert(make_pair("dns_lookups", LookupItem("DNS lookups", "proxy.node.hostdb.total_lookups", 2)));
-    lookup_table.insert(make_pair("client_req", LookupItem("Requests", "proxy.process.http.incoming_requests", 2)));
-    lookup_table.insert(make_pair("client_conn", LookupItem("New Conn", "proxy.process.http.total_client_connections", 2)));
-    lookup_table.insert(make_pair("client_req_conn", LookupItem("Req/Conn", "client_req", "client_conn", 3)));
-    lookup_table.insert(make_pair("client_curr_conn", LookupItem("Curr Conn", "proxy.process.http.current_client_connections", 1)));
-    lookup_table.insert(make_pair("client_actv_conn", LookupItem("Active Con", "proxy.process.http.current_active_client_connections", 1)));
-
-    lookup_table.insert(make_pair("server_req", LookupItem("Requests", "proxy.process.http.outgoing_requests", 2)));
-    lookup_table.insert(make_pair("server_conn", LookupItem("New Conn", "proxy.process.http.total_server_connections", 2)));
-    lookup_table.insert(make_pair("server_req_conn", LookupItem("Req/Conn", "server_req", "server_conn", 3)));
-    lookup_table.insert(make_pair("server_curr_conn", LookupItem("Curr Conn", "proxy.process.http.current_server_connections", 1)));
-
-
-    lookup_table.insert(make_pair("client_head", LookupItem("Head Bytes", "proxy.process.http.user_agent_response_header_total_size", 2)));
-    lookup_table.insert(make_pair("client_body", LookupItem("Body Bytes", "proxy.process.http.user_agent_response_document_total_size", 2)));
-    lookup_table.insert(make_pair("server_head", LookupItem("Head Bytes", "proxy.process.http.origin_server_response_header_total_size", 2)));
-    lookup_table.insert(make_pair("server_body", LookupItem("Body Bytes", "proxy.process.http.origin_server_response_document_total_size", 2)));
-
-    // not used directly
-    lookup_table.insert(make_pair("ram_hit", LookupItem("Ram Hit", "proxy.process.cache.ram_cache.hits", 2)));
-    lookup_table.insert(make_pair("ram_miss", LookupItem("Ram Misses", "proxy.process.cache.ram_cache.misses", 2)));
-
-
-
-    lookup_table.insert(make_pair("client_abort", LookupItem("Clnt Abort", "proxy.process.http.err_client_abort_count_stat", 2)));
-    lookup_table.insert(make_pair("conn_fail", LookupItem("Conn Fail", "proxy.process.http.err_connect_fail_count_stat", 2)));
-    lookup_table.insert(make_pair("abort", LookupItem("Abort", "proxy.process.http.transaction_counts.errors.aborts", 2)));
-    lookup_table.insert(make_pair("t_conn_fail", LookupItem("Conn Fail", "proxy.process.http.transaction_counts.errors.connect_failed", 2)));
-    lookup_table.insert(make_pair("other_err", LookupItem("Other Err", "proxy.process.http.transaction_counts.errors.other", 2)));
-    // percentage
-    lookup_table.insert(make_pair("ram_ratio", LookupItem("Ram Hit", "ram_hit", "ram_hit_miss", 4)));
-    lookup_table.insert(make_pair("dns_ratio", LookupItem("DNS Hit", "dns_hits", "dns_lookups", 4)));
-
-    // percentage of requests
-    lookup_table.insert(make_pair("fresh", LookupItem("Fresh", "proxy.process.http.transaction_counts.hit_fresh", 5)));
-    lookup_table.insert(make_pair("reval", LookupItem("Revalidate", "proxy.process.http.transaction_counts.hit_revalidated", 5)));
-    lookup_table.insert(make_pair("cold", LookupItem("Cold", "proxy.process.http.transaction_counts.miss_cold", 5)));
-    lookup_table.insert(make_pair("changed", LookupItem("Changed", "proxy.process.http.transaction_counts.miss_changed", 5)));
-    lookup_table.insert(make_pair("not", LookupItem("Not Cache", "proxy.process.http.transaction_counts.miss_not_cacheable", 5)));
-    lookup_table.insert(make_pair("no", LookupItem("No Cache", "proxy.process.http.transaction_counts.miss_client_no_cache", 5)));
-
-    lookup_table.insert(make_pair("fresh_time", LookupItem("Fresh (ms)", "proxy.process.http.transaction_totaltime.hit_fresh", "fresh", 8)));
-    lookup_table.insert(make_pair("reval_time", LookupItem("Reval (ms)", "proxy.process.http.transaction_totaltime.hit_revalidated", "reval", 8)));
-    lookup_table.insert(make_pair("cold_time", LookupItem("Cold (ms)", "proxy.process.http.transaction_totaltime.miss_cold", "cold", 8)));
-    lookup_table.insert(make_pair("changed_time", LookupItem("Chang (ms)", "proxy.process.http.transaction_totaltime.miss_changed", "changed", 8)));
-    lookup_table.insert(make_pair("not_time", LookupItem("Not (ms)", "proxy.process.http.transaction_totaltime.miss_not_cacheable", "not", 8)));
-    lookup_table.insert(make_pair("no_time", LookupItem("No (ms)", "proxy.process.http.transaction_totaltime.miss_client_no_cache", "no", 8)));
-
-    lookup_table.insert(make_pair("get", LookupItem("GET", "proxy.process.http.get_requests", 5)));
-    lookup_table.insert(make_pair("head", LookupItem("HEAD", "proxy.process.http.head_requests", 5)));
-    lookup_table.insert(make_pair("post", LookupItem("POST", "proxy.process.http.post_requests", 5)));
-    lookup_table.insert(make_pair("2xx", LookupItem("2xx", "proxy.process.http.2xx_responses", 5)));
-    lookup_table.insert(make_pair("3xx", LookupItem("3xx", "proxy.process.http.3xx_responses", 5)));
-    lookup_table.insert(make_pair("4xx", LookupItem("4xx", "proxy.process.http.4xx_responses", 5)));
-    lookup_table.insert(make_pair("5xx", LookupItem("5xx", "proxy.process.http.5xx_responses", 5)));
-
-    lookup_table.insert(make_pair("200", LookupItem("200", "proxy.process.http.200_responses", 5)));
-    lookup_table.insert(make_pair("206", LookupItem("206", "proxy.process.http.206_responses", 5)));
-    lookup_table.insert(make_pair("301", LookupItem("301", "proxy.process.http.301_responses", 5)));
-    lookup_table.insert(make_pair("302", LookupItem("302", "proxy.process.http.302_responses", 5)));
-    lookup_table.insert(make_pair("304", LookupItem("304", "proxy.process.http.304_responses", 5)));
-    lookup_table.insert(make_pair("404", LookupItem("404", "proxy.process.http.404_responses", 5)));
-    lookup_table.insert(make_pair("502", LookupItem("502", "proxy.process.http.502_responses", 5)));
-
-    lookup_table.insert(make_pair("s_100", LookupItem("100 B", "proxy.process.http.response_document_size_100", 5)));
-    lookup_table.insert(make_pair("s_1k", LookupItem("1 KB", "proxy.process.http.response_document_size_1K", 5)));
-    lookup_table.insert(make_pair("s_3k", LookupItem("3 KB", "proxy.process.http.response_document_size_3K", 5)));
-    lookup_table.insert(make_pair("s_5k", LookupItem("5 KB", "proxy.process.http.response_document_size_5K", 5)));
-    lookup_table.insert(make_pair("s_10k", LookupItem("10 KB", "proxy.process.http.response_document_size_10K", 5)));
-    lookup_table.insert(make_pair("s_1m", LookupItem("1 MB", "proxy.process.http.response_document_size_1M", 5)));
-    lookup_table.insert(make_pair("s_>1m", LookupItem("> 1 MB", "proxy.process.http.response_document_size_inf", 5)));
-
-
-    // sum together
-    lookup_table.insert(make_pair("ram_hit_miss", LookupItem("Ram Hit+Miss", "ram_hit", "ram_miss", 6)));
-    lookup_table.insert(make_pair("client_net", LookupItem("Net (bits)", "client_head", "client_body", 7)));
-    lookup_table.insert(make_pair("client_size", LookupItem("Total Size", "client_head", "client_body", 6)));
-    lookup_table.insert(make_pair("client_avg_size", LookupItem("Avg Size", "client_size", "client_req", 3)));
-
-    lookup_table.insert(make_pair("server_net", LookupItem("Net (bits)", "server_head", "server_body", 7)));
-    lookup_table.insert(make_pair("server_size", LookupItem("Total Size", "server_head", "server_body", 6)));
-    lookup_table.insert(make_pair("server_avg_size", LookupItem("Avg Size", "server_size", "server_req", 3)));
-
-
-    lookup_table.insert(make_pair("total_time", LookupItem("Total Time", "proxy.process.http.total_transactions_time", 2)));
-    lookup_table.insert(make_pair("client_req_time", LookupItem("Resp (ms)", "total_time", "client_req", 3)));
-  }
-
-  void getStats() {
-
-    if (_host == "") {
-      int64_t value = 0;
-      if (_old_stats != NULL) {
-        delete _old_stats;
-        _old_stats = NULL;
-      }
-      _old_stats = _stats;
-      _stats = new map<string, string>;
-
-      gettimeofday(&_time, NULL);
-      double now = _time.tv_sec + (double)_time.tv_usec / 1000000;
-
-      for (map<string, LookupItem>::const_iterator lookup_it = lookup_table.begin();
-           lookup_it != lookup_table.end(); ++lookup_it) {
-        const LookupItem &item = lookup_it->second;
-
-        if (item.type == 1 || item.type == 2 || item.type == 5 || item.type == 8) {
-          if (strcmp(item.pretty, "Version") == 0) {
-            // special case for Version informaion
-            TSString strValue = NULL;
-            assert(TSRecordGetString(item.name, &strValue) == TS_ERR_OKAY);
-            string key = item.name;
-            (*_stats)[key] = strValue;
-          } else {
-            assert(TSRecordGetInt(item.name, &value) == TS_ERR_OKAY);
-            string key = item.name;
-            char buffer[32];
-            sprintf(buffer, "%" PRId64, value);
-            string foo = buffer;
-            (*_stats)[key] = foo;
-          }
-        }
-      } 
-      _old_time = _now;
-      _now = now;
-      _time_diff = _now - _old_time;
-    } else {
-      CURL *curl;
-      CURLcode res;
-
-      curl = curl_easy_init();
-      if (curl) {
-        string url = "http://" + _host + "/_stats";
-        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
-        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
-        curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_error);
-
-        // update time
-        gettimeofday(&_time, NULL);
-        double now = _time.tv_sec + (double)_time.tv_usec / 1000000;
-
-        response.clear();
-        response.reserve(32768); // should hopefully be smaller then 32KB
-        res = curl_easy_perform(curl);
-
-        // only if success update stats and time information
-        if (res == 0) {
-          if (_old_stats != NULL) {
-            delete _old_stats;
-            _old_stats = NULL;
-          }
-          _old_stats = _stats;
-          _stats = new map<string, string>;
-
-          // parse
-          parseResponse(response);
-          _old_time = _now;
-          _now = now;
-          _time_diff = _now - _old_time;
-        }
-
-        /* always cleanup */ 
-        curl_easy_cleanup(curl);
-      }
-    }
-  }
-
-  int64_t getValue(const string &key, const map<string, string> *stats) const {
-    map<string, string>::const_iterator stats_it = stats->find(key);
-    assert(stats_it != stats->end());
-    int64_t value = atoll(stats_it->second.c_str());
-    return value;
-  }
-
-  void getStat(const string &key, double &value, int overrideType = 0) {
-    string strtmp;
-    int typetmp;
-    getStat(key, value, strtmp, typetmp, overrideType);
-  }
-
-
-  void getStat(const string &key, string &value) {
-    map<string, LookupItem>::const_iterator lookup_it = lookup_table.find(key);
-    assert(lookup_it != lookup_table.end());
-    const LookupItem &item = lookup_it->second;
-    
-    map<string, string>::const_iterator stats_it = _stats->find(item.name);
-    assert(stats_it != _stats->end());
-    value = stats_it->second.c_str();
-  }
-
-  void getStat(const string &key, double &value, string &prettyName, int &type, int overrideType = 0) {
-    map<string, LookupItem>::const_iterator lookup_it = lookup_table.find(key);
-    assert(lookup_it != lookup_table.end());
-    const LookupItem &item = lookup_it->second;
-    prettyName = item.pretty;
-    if (overrideType != 0)
-      type = overrideType;
-    else
-      type = item.type;
-
-    if (type == 1 || type == 2 || type == 5 || type == 8) {
-      value = getValue(item.name, _stats);
-      if (key == "total_time") {
-        value = value / 10000000;
-      }
-
-      if ((type == 2 || type == 5 || type == 8) && _old_stats != NULL && _absolute == false) {
-        double old = getValue(item.name, _old_stats);
-        if (key == "total_time") {
-          old = old / 10000000;
-        }
-        value = (value - old) / _time_diff;
-      }
-    } else if (type == 3 || type == 4) {
-      double numerator;
-      double denominator;
-      getStat(item.numerator, numerator);
-      getStat(item.denominator, denominator);
-      if (denominator == 0)
-        value = 0;
-      else
-        value = numerator / denominator;
-      if (type == 4) {
-        value *= 100;
-      }
-    } else if (type == 6 || type == 7) {
-      double numerator;
-      double denominator;
-      getStat(item.numerator, numerator, 2);
-      getStat(item.denominator, denominator, 2);
-      value = numerator + denominator;
-      if (type == 7)
-        value *= 8;
-    }
-
-    if (type == 8) {
-      double denominator;
-      getStat(item.denominator, denominator, 2);
-      if (denominator == 0)
-        value = 0;
-      else
-        value = value / denominator * 1000;
-    }
-
-    if (type == 5) {
-      double denominator = 0;
-      getStat("client_req", denominator);
-      if (denominator == 0)
-        value = 0;
-      else
-        value = value / denominator * 100;
-    }
-  }
-
-  bool toggleAbsolute() {
-    if (_absolute == true)
-      _absolute = false;
-    else
-      _absolute = true;
-
-    return _absolute;
-  }
-
-  void parseResponse(const string &response) {
-    // move past global
-    size_t pos = response.find(constant::global);
-    pos += sizeof(constant::global) - 1;
-
-    // find parts of the line
-    while (1) {
-      size_t start = response.find(constant::start, pos);
-      size_t seperator = response.find(constant::seperator, pos);
-      size_t end = response.find(constant::end, pos);
-  
-      if (start == string::npos || seperator == string::npos || end == string::npos)
-        return;
-
-      //cout << constant::start << " " << start << endl;
-      //cout << constant::seperator << " " << seperator << endl;
-      //cout << constant::end << " " << end << endl;
-
-      string key = response.substr(start + 1, seperator - start - 1);
-      string value = response.substr(seperator + sizeof(constant::seperator) - 1, end - seperator - sizeof(constant::seperator) + 1);
-
-      (*_stats)[key] = value;
-      //cout << "key " << key << " " << "value " << value << endl;
-      pos = end + sizeof(constant::end) - 1;
-      //cout << "pos: " << pos << endl;
-    }
-  }
-
-  ~Stats() {
-    if (_stats != NULL) {
-      delete _stats;
-    }
-    if (_old_stats != NULL) {
-      delete _old_stats;
-    }
-  }
-
-private:
-  map<string, string> *_stats;
-  map<string, string> *_old_stats;
-  map<string, LookupItem> lookup_table;
-  string _host;
-  double _old_time;
-  double _now;
-  double _time_diff;
-  struct timeval _time;
-  bool _absolute;
-};

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88666ad4/tools/tstop/tstop.cc
----------------------------------------------------------------------
diff --git a/tools/tstop/tstop.cc b/tools/tstop/tstop.cc
deleted file mode 100644
index 16d6e65..0000000
--- a/tools/tstop/tstop.cc
+++ /dev/null
@@ -1,378 +0,0 @@
-/** @file
-
-    Main file for the tstop application.
-
-    @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 "ink_config.h"
-#include <map>
-#include <list>
-#include <string>
-#include <string.h>
-#include <iostream>
-#include <assert.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-
-// At least on solaris, the default ncurses defines macros such as
-// clear() that break stdlibc++.
-#define NOMACROS 1
-#define NCURSES_NOMACROS 1
-
-#if defined HAVE_NCURSESW_CURSES_H
-#  include <ncursesw/curses.h>
-#elif defined HAVE_NCURSESW_H
-#  include <ncursesw.h>
-#elif defined HAVE_NCURSES_CURSES_H
-#  include <ncurses/curses.h>
-#elif defined HAVE_NCURSES_H
-#  include <ncurses.h>
-#elif defined HAVE_CURSES_H
-#  include <curses.h>
-#else
-#  error "SysV or X/Open-compatible Curses header file required"
-#endif
-
-#include "stats.h"
-
-using namespace std;
-char curl_error[CURL_ERROR_SIZE];
-string response;
-
-namespace colorPair {
-  const short red = 1;
-  const short yellow = 2;
-  const short green = 3;
-  const short blue = 4;
-  const short black = 5;
-  const short grey = 6;
-  const short cyan = 7;
-  const short border = 8;
-};
-
-//----------------------------------------------------------------------------
-static void prettyPrint(const int x, const int y, const double number, const int type) {
-  char buffer[32];
-  char exp = ' ';
-  double my_number = number;
-  short color;
-  if (number > 1000000000000LL) {
-    my_number = number / 1000000000000LL;
-    exp = 'T';
-    color = colorPair::red;
-  } else if (number > 1000000000) {
-    my_number = number / 1000000000;
-    exp = 'G';
-    color = colorPair::red;
-  } else if (number > 1000000) {
-    my_number = number / 1000000;
-    exp = 'M';
-    color = colorPair::yellow;
-  } else if (number > 1000) {
-    my_number = number / 1000;
-    exp = 'K';
-    color = colorPair::cyan;
-  } else if (my_number <= .09) {
-    color = colorPair::grey;
-  } else {
-    color = colorPair::green;
-  }
-
-  if (type == 4 || type == 5) {
-    if (number > 90) {
-      color = colorPair::red;
-    } else if (number > 80) {
-      color = colorPair::yellow;
-    } else if (number > 50) {
-      color = colorPair::blue;
-    } else if (my_number <= .09) {
-      color = colorPair::grey;
-    } else {
-      color = colorPair::green;
-    }
-    snprintf(buffer, sizeof(buffer), "%6.1f%%%%", (double)my_number);
-  } else
-    snprintf(buffer, sizeof(buffer), "%6.1f%c", (double)my_number, exp);
-  attron(COLOR_PAIR(color));
-  attron(A_BOLD);
-  mvprintw(y, x, buffer);
-  attroff(COLOR_PAIR(color));
-  attroff(A_BOLD);
-}
-
-//----------------------------------------------------------------------------
-static void makeTable(const int x, const int y, const list<string> &items, Stats &stats) {
-  int my_y = y;
-
-  for (list<string>::const_iterator it = items.begin(); it != items.end(); ++it) {
-    string prettyName;
-    double value = 0;
-    int type;
-
-    stats.getStat(*it, value, prettyName, type);
-    mvprintw(my_y, x, prettyName.c_str());
-    prettyPrint(x + 10, my_y++, value, type);
-  }
-}
-
-//----------------------------------------------------------------------------
-size_t write_data(void *ptr, size_t size, size_t nmemb, void * /* stream */)
-{
-  response.append((char*)ptr, size * nmemb);
-  //cout << "appending: " << size * nmemb << endl;
-  //int written = fwrite(ptr, size, nmemb, (FILE *)stream);
-  return size * nmemb;
-}
-
-//----------------------------------------------------------------------------
-static void help(const string &host, const string &version) {
-
-  timeout(1000);
-
-  while(1) {
-    clear();
-    time_t now = time(NULL);
-    struct tm *nowtm = localtime(&now);
-    char timeBuf[32];
-    strftime(timeBuf, sizeof(timeBuf), "%H:%M:%S", nowtm);
-
-    //clear();
-    attron(A_BOLD); mvprintw(0, 0, "Overview:"); attroff(A_BOLD); 
-    mvprintw(1, 0, "tstop is a top like program for Apache Traffic Server (ATS).  There is a lot of statistical information gathered by ATS.  This program tries to show some of the more important stats and gives a good overview of what the proxy server is doing.  Hopefully this can be used as a tool to diagnosing the proxy server is there are problems.");
-
-    attron(A_BOLD); mvprintw(7, 0, "Definitions:"); attroff(A_BOLD); 
-    mvprintw(8, 0, "Fresh      => Requests that were servered by fresh entries in cache");
-    mvprintw(9, 0, "Revalidate => Requests that contacted the origin to verify if still valid");
-    mvprintw(10, 0, "Cold       => Requests that were not in cache at all");
-    mvprintw(11, 0, "Changed    => Requests that required entries in cache to be updated");
-    mvprintw(12, 0, "Changed    => Requests that can't be cached for some reason");
-    mvprintw(12, 0, "No Cache   => Requests that the client sent Cache-Control: no-cache header");
-
-    attron(COLOR_PAIR(colorPair::border));
-    attron(A_BOLD);
-    mvprintw(23, 0, "%s - %.12s - %.12s      (b)ack                            ", timeBuf, version.c_str(), host.c_str());
-    attroff(COLOR_PAIR(colorPair::border));
-    attroff(A_BOLD);
-    refresh();
-    int x = getch();
-    if (x == 'b')
-      break;
-  }
-}
-
-static void usage(char **argv) {
-  fprintf(stderr, "Usage: %s [-s seconds] hostname|hostname:port\n", argv[0]);
-  exit(1);
-}
-
-
-//----------------------------------------------------------------------------
-int main(int argc, char **argv)
-{
-  int sleep_time = 5000;
-  bool absolute = false;
-  int opt;
-  while ((opt = getopt(argc, argv, "s:")) != -1) {
-    switch(opt) {
-    case 's':
-      sleep_time = atoi(optarg) * 1000;
-      break;
-    default:
-      usage(argv);
-    }
-  }
-
-  string host = "";
-  if (optind >= argc) {
-    if (TS_ERR_OKAY != TSInit(NULL, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS | TS_MGMT_OPT_NO_SOCK_TESTS))) {
-      fprintf(stderr, "Error: missing hostname on command line or error connecting to the local manager\n");
-      usage(argv);
-    }
-  } else {
-    host = argv[optind];
-  }
-  Stats stats(host);
-
-  if (host == "") {
-    char hostname[25];
-    hostname[sizeof(hostname) - 1] = '\0';
-    gethostname(hostname, sizeof(hostname) - 1);
-    host = hostname;
-  }
-
-  initscr();
-  curs_set(0);
-  
-
-  start_color();			/* Start color functionality	*/
-  
-  init_pair(colorPair::red, COLOR_RED, COLOR_BLACK);
-  init_pair(colorPair::yellow, COLOR_YELLOW, COLOR_BLACK);
-  init_pair(colorPair::grey, COLOR_BLACK, COLOR_BLACK);
-  init_pair(colorPair::green, COLOR_GREEN, COLOR_BLACK);
-  init_pair(colorPair::blue, COLOR_BLUE, COLOR_BLACK);
-  init_pair(colorPair::cyan, COLOR_CYAN, COLOR_BLACK);
-  init_pair(colorPair::border, COLOR_WHITE, COLOR_BLUE);
-  //  mvchgat(0, 0, -1, A_BLINK, 1, NULL);
-
-  stats.getStats();
-  while(1) {
-    attron(COLOR_PAIR(colorPair::border));
-    attron(A_BOLD);
-    for (int i = 0; i <= 22; ++i) {
-      mvprintw(i, 39, " ");
-    }
-    string version;
-    time_t now = time(NULL);
-    struct tm *nowtm = localtime(&now);
-    char timeBuf[32];
-    strftime(timeBuf, sizeof(timeBuf), "%H:%M:%S", nowtm);
-    stats.getStat("version", version);
-    mvprintw(0, 0, "         CACHE INFORMATION             ");
-    mvprintw(0, 40, "       CLIENT REQUEST & RESPONSE        ");
-    mvprintw(16, 0, "             CLIENT                    ");
-    mvprintw(16, 40, "           ORIGIN SERVER                ");
-    mvprintw(23, 0, "%8.8s - %-10.10s - %-24.24s      (q)uit (h)elp (%c)bsolute  ", timeBuf, version.c_str(), host.c_str(), absolute ? 'A' : 'a');
-    attroff(COLOR_PAIR(colorPair::border));
-    attroff(A_BOLD);
-
-    list<string> cache1;
-    cache1.push_back("disk_used");
-    cache1.push_back("disk_total");
-    cache1.push_back("ram_used");
-    cache1.push_back("ram_total");
-    cache1.push_back("lookups");
-    cache1.push_back("cache_writes");
-    cache1.push_back("cache_updates");
-    cache1.push_back("cache_deletes");
-    cache1.push_back("read_active");
-    cache1.push_back("write_active");
-    cache1.push_back("update_active");
-    cache1.push_back("entries");
-    cache1.push_back("avg_size");
-    cache1.push_back("dns_lookups");
-    cache1.push_back("dns_hits");
-    makeTable(0, 1, cache1, stats);
-
-
-    list<string> cache2;
-    cache2.push_back("ram_ratio");
-    cache2.push_back("fresh");
-    cache2.push_back("reval");
-    cache2.push_back("cold");
-    cache2.push_back("changed");
-    cache2.push_back("not");
-    cache2.push_back("no");
-    cache2.push_back("fresh_time");
-    cache2.push_back("reval_time");
-    cache2.push_back("cold_time");
-    cache2.push_back("changed_time");
-    cache2.push_back("not_time");
-    cache2.push_back("no_time");
-    cache2.push_back("dns_ratio");
-    cache2.push_back("dns_time");
-    makeTable(21, 1, cache2, stats);
-
-    list<string> response1;
-    response1.push_back("get");
-    response1.push_back("head");
-    response1.push_back("post");
-    response1.push_back("2xx");
-    response1.push_back("3xx");
-    response1.push_back("4xx");
-    response1.push_back("5xx");
-    response1.push_back("conn_fail");
-    response1.push_back("other_err");
-    response1.push_back("abort");
-    makeTable(41, 1, response1, stats);
-
-
-    list<string> response2;
-    response2.push_back("200");
-    response2.push_back("206");
-    response2.push_back("301");
-    response2.push_back("302");
-    response2.push_back("304");
-    response2.push_back("404");
-    response2.push_back("502");
-    response2.push_back("s_100");
-    response2.push_back("s_1k");
-    response2.push_back("s_3k");
-    response2.push_back("s_5k");
-    response2.push_back("s_10k");
-    response2.push_back("s_1m");
-    response2.push_back("s_>1m");
-    makeTable(62, 1, response2, stats);
-
-    list<string> client1;
-    client1.push_back("client_req");
-    client1.push_back("client_req_conn");
-    client1.push_back("client_conn");
-    client1.push_back("client_curr_conn");
-    client1.push_back("client_actv_conn");
-    makeTable(0, 17, client1, stats);
-
-
-    list<string> client2;
-    client2.push_back("client_head");
-    client2.push_back("client_body");
-    client2.push_back("client_avg_size");
-    client2.push_back("client_net");
-    client2.push_back("client_req_time");
-    makeTable(21, 17, client2, stats);
-
-    list<string> server1;
-    server1.push_back("server_req");
-    server1.push_back("server_req_conn");
-    server1.push_back("server_conn");
-    server1.push_back("server_curr_conn");
-    makeTable(41, 17, server1, stats);
-
-
-    list<string> server2;
-    server2.push_back("server_head");
-    server2.push_back("server_body");
-    server2.push_back("server_avg_size");
-    server2.push_back("server_net");
-    makeTable(62, 17, server2, stats);
-
-
-    curs_set(0);
-    refresh();
-    timeout(sleep_time);
-
-    int x = getch();
-    if (x == 'q')
-      break;
-    if (x == 'h') {
-      help(host, version);
-    }
-    if (x == 'a') {
-      absolute = stats.toggleAbsolute();
-    }
-    if (x == -1)
-      stats.getStats();
-    clear();
-  }
-  endwin();
-
-  return 0;
-}


[36/44] git commit: Add CHANGES for TS-2379

Posted by zw...@apache.org.
Add CHANGES for TS-2379


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

Branch: refs/heads/5.0.x
Commit: 51a9252dcd6fa76fb7846c3ca10cf1651fa55f83
Parents: ae51d4e
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Thu Nov 21 11:48:11 2013 +0800
Committer: Yunkai Zhang <qi...@taobao.com>
Committed: Thu Nov 21 11:48:11 2013 +0800

----------------------------------------------------------------------
 CHANGES | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/51a9252d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 445a6c3..8fc1232 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2379] Add a new field: '%<chp>', "client_host_port" to LogFormat.
+
   *) [TS-2374] Abort the producer if the none of it`s consumers is alive.
 
   *) [TS-2327] TSRedirectUrlSet does not perform DNS lookup of redirected OS


[27/44] git commit: TS-2360 Improve the example slightly, but it is still an example

Posted by zw...@apache.org.
TS-2360 Improve the example slightly, but it is still an example


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

Branch: refs/heads/5.0.x
Commit: b187978b8992f7625073081ad053e41e3704ab4d
Parents: 7195488
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Nov 18 22:14:02 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Nov 18 22:14:02 2013 -0700

----------------------------------------------------------------------
 doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b187978b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
index aacc6af..feec628 100644
--- a/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
+++ b/doc/reference/api/TSMimeHdrFieldValueStringGet.en.rst
@@ -73,13 +73,15 @@ does not have date-time semantics always returns :data:`0`.
 Examples
 ========
 
+This examples show how to retrieve and copy a specific header.
+
 ::
 
     #include <string.h>
     #include <ts/ts.h>
 
     int
-    get_content_type(TSHttpTxn txnp, char* buf)
+    get_content_type(TSHttpTxn txnp, char* buf, size_t buf_size)
     {
       TSMBuffer bufp;
       TSMLoc hdrs;
@@ -92,6 +94,8 @@ Examples
         if (TS_NULL_MLOC != ctype_field) {
           const char* str = TSMimeHdrFieldValueStringGet(bufp, hdrs, ctype_field, -1, &len);
 
+          if (len > buf_size)
+            len = buf_size;
           memcpy(buf, str, len);
           TSHandleMLocRelease(bufp, hdrs, ctype_field);
         }


[44/44] git commit: Merge branch 'master' into 5.0.x

Posted by zw...@apache.org.
Merge branch 'master' into 5.0.x


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

Branch: refs/heads/5.0.x
Commit: c63666b1353fd089bc42f6f535a95c75548cc321
Parents: 3433ea6 c54477a
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Nov 21 11:41:47 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Nov 21 11:41:47 2013 -0700

----------------------------------------------------------------------
 .gitattributes                                  |    1 +
 .gitignore                                      |    8 +-
 CHANGES                                         |   23 +-
 Makefile.am                                     |   28 +-
 README-EC2                                      |  268 +-
 ci/jenkins/README                               |   32 +
 ci/jenkins/jobs.yaml                            |   76 +-
 cmd/Makefile.am                                 |   18 +
 cmd/traffic_cop/Makefile.am                     |   43 +
 cmd/traffic_cop/traffic_cop.cc                  | 1849 +++++++
 cmd/traffic_line/Makefile.am                    |   36 +
 cmd/traffic_line/traffic_line.cc                |  218 +
 cmd/traffic_shell/CliCreateCommands.cc          |  318 ++
 cmd/traffic_shell/CliCreateCommands.h           |   39 +
 cmd/traffic_shell/CliDisplay.cc                 |  221 +
 cmd/traffic_shell/CliDisplay.h                  |   91 +
 cmd/traffic_shell/CliMgmtUtils.cc               |  625 +++
 cmd/traffic_shell/CliMgmtUtils.h                |  152 +
 cmd/traffic_shell/ConfigCmd.cc                  | 4626 ++++++++++++++++++
 cmd/traffic_shell/ConfigCmd.h                   |  865 ++++
 cmd/traffic_shell/ConfigUpgradeCmd.cc           |  634 +++
 cmd/traffic_shell/ConfigUpgradeCmd.h            |  252 +
 cmd/traffic_shell/ConfigUpgradeReadCmd.cc       |  498 ++
 cmd/traffic_shell/ConfigUpgradeWriteCmd.cc      |  517 ++
 cmd/traffic_shell/Makefile.am                   |   77 +
 cmd/traffic_shell/ShowCmd.cc                    | 2322 +++++++++
 cmd/traffic_shell/ShowCmd.h                     |  247 +
 cmd/traffic_shell/UtilCmds.cc                   |  196 +
 cmd/traffic_shell/UtilCmds.h                    |   94 +
 cmd/traffic_shell/cliAppInit.cc                 |  165 +
 cmd/traffic_shell/cliParseArg.cc                |  457 ++
 cmd/traffic_shell/cli_detailed_command_list.txt | 1623 ++++++
 cmd/traffic_shell/cli_feature_spec.txt          |  230 +
 cmd/traffic_shell/commandOptions.h              |   47 +
 cmd/traffic_shell/createArgument.cc             |  387 ++
 cmd/traffic_shell/createArgument.h              |  119 +
 cmd/traffic_shell/createCommand.cc              |  166 +
 cmd/traffic_shell/createCommand.h               |   59 +
 cmd/traffic_shell/definitions.h                 |   77 +
 cmd/traffic_shell/hashtable.cc                  |  219 +
 cmd/traffic_shell/hashtable.h                   |   45 +
 cmd/traffic_shell/processArgument.cc            |   57 +
 cmd/traffic_shell/traffic_shell.cc              |  113 +
 cmd/traffic_top/Makefile.am                     |   41 +
 cmd/traffic_top/README                          |    4 +
 cmd/traffic_top/stats.h                         |  457 ++
 cmd/traffic_top/traffic_top.cc                  |  465 ++
 config.layout                                   |    2 +-
 configure.ac                                    |    7 +-
 cop/Makefile.am                                 |   42 -
 cop/TrafficCop.cc                               | 1849 -------
 doc/admin/getting-started.en.rst                |    2 +-
 doc/admin/monitoring-traffic.en.rst             |    2 +-
 doc/arch/cache/cache-api.en.rst                 |   84 +-
 doc/arch/cache/cache-appendix.en.rst            |  194 +-
 doc/arch/cache/cache-arch.en.rst                | 1596 +++---
 doc/arch/cache/cache-data-structures.en.rst     |  328 +-
 .../cache/images/ats-cache-write-cursor.png     |  Bin
 .../cache/images/cache-directory-structure.png  |  Bin
 .../cache/images/cache-doc-layout-3-2-0.png     |  Bin
 .../cache/images/cache-doc-layout-4-0-1.png     |  Bin
 doc/arch/cache/images/cache-multi-fragment.png  |  Bin
 doc/arch/cache/images/cache-stripe-layout.png   |  Bin
 doc/arch/cache/images/dir-bucket-assign.png     |  Bin
 doc/arch/cache/images/dir-segment-bucket.png    |  Bin
 doc/arch/cache/tier-storage.en.rst              |  236 +-
 doc/conf.py                                     |    3 +-
 .../api/TSMimeHdrFieldValueStringGet.en.rst     |  111 +
 doc/reference/api/index.en.rst                  |    1 +
 doc/reference/commands/index.en.rst             |    8 +-
 doc/reference/commands/traffic_top.en.rst       |   27 +
 doc/reference/commands/tstop.en.rst             |   29 -
 .../working-with-http-headers.en.rst            |    2 +-
 example/append-transform/append-transform.c     |    2 +-
 example/basic-auth/basic-auth.c                 |    2 +-
 example/remap/remap.cc                          |    4 +-
 example/response-header-1/response-header-1.c   |    2 +-
 example/thread-pool/psi.c                       |    2 +-
 iocore/cache/Cache.cc                           |   30 +-
 iocore/cache/CacheHttp.cc                       |   16 +-
 iocore/cache/CacheRead.cc                       |   10 +-
 iocore/cache/CacheWrite.cc                      |    4 -
 iocore/cache/I_CacheDefs.h                      |    2 +-
 iocore/cache/Makefile.am                        |    3 -
 iocore/cache/P_CacheInternal.h                  |   13 +-
 iocore/cache/RamCacheCLFUS.cc                   |    4 +-
 iocore/cache/RamCacheLRU.cc                     |    2 +-
 iocore/dns/DNS.cc                               |    3 +-
 iocore/dns/Makefile.am                          |    4 -
 iocore/dns/P_DNSProcessor.h                     |   26 -
 iocore/dns/P_SplitDNSProcessor.h                |   27 +
 iocore/eventsystem/I_EThread.h                  |   17 -
 iocore/eventsystem/I_Event.h                    |    2 +-
 iocore/eventsystem/I_ProxyAllocator.h           |   51 +-
 iocore/eventsystem/I_Thread.h                   |   21 +-
 iocore/eventsystem/P_IOBuffer.h                 |   20 +-
 iocore/eventsystem/ProxyAllocator.cc            |    6 +-
 iocore/hostdb/HostDB.cc                         |    2 +-
 iocore/hostdb/Makefile.am                       |    3 -
 iocore/hostdb/MultiCache.cc                     |    1 -
 iocore/net/Makefile.am                          |    4 -
 iocore/net/Socks.cc                             |    2 +-
 lib/records/RecMessage.cc                       |    6 +-
 mgmt/Makefile.am                                |    2 +-
 mgmt/api/Makefile.am                            |    5 +-
 mgmt/cli/CliCreateCommands.cc                   |  318 --
 mgmt/cli/CliCreateCommands.h                    |   39 -
 mgmt/cli/CliDisplay.cc                          |  221 -
 mgmt/cli/CliDisplay.h                           |   91 -
 mgmt/cli/CliMgmtUtils.cc                        |  625 ---
 mgmt/cli/CliMgmtUtils.h                         |  152 -
 mgmt/cli/ConfigCmd.cc                           | 4626 ------------------
 mgmt/cli/ConfigCmd.h                            |  865 ----
 mgmt/cli/ConfigUpgradeCmd.cc                    |  634 ---
 mgmt/cli/ConfigUpgradeCmd.h                     |  252 -
 mgmt/cli/ConfigUpgradeReadCmd.cc                |  498 --
 mgmt/cli/ConfigUpgradeWriteCmd.cc               |  517 --
 mgmt/cli/Makefile.am                            |   88 -
 mgmt/cli/ShowCmd.cc                             | 2322 ---------
 mgmt/cli/ShowCmd.h                              |  247 -
 mgmt/cli/TrafficLine.cc                         |  218 -
 mgmt/cli/UtilCmds.cc                            |  196 -
 mgmt/cli/UtilCmds.h                             |   94 -
 mgmt/cli/cliAppInit.cc                          |  165 -
 mgmt/cli/cliMain.cc                             |  113 -
 mgmt/cli/cliParseArg.cc                         |  457 --
 mgmt/cli/cli_detailed_command_list.txt          | 1623 ------
 mgmt/cli/cli_feature_spec.txt                   |  230 -
 mgmt/cli/commandOptions.h                       |   47 -
 mgmt/cli/createArgument.cc                      |  387 --
 mgmt/cli/createArgument.h                       |  119 -
 mgmt/cli/createCommand.cc                       |  166 -
 mgmt/cli/createCommand.h                        |   59 -
 mgmt/cli/definitions.h                          |   77 -
 mgmt/cli/hashtable.cc                           |  219 -
 mgmt/cli/hashtable.h                            |   45 -
 mgmt/cli/processArgument.cc                     |   57 -
 plugins/experimental/authproxy/utils.cc         |    4 +-
 plugins/experimental/balancer/hashkey.h         |    2 +-
 .../experimental/buffer_upload/buffer_upload.cc |    2 +-
 .../custom_redirect/custom_redirect.cc          |    2 +-
 plugins/experimental/esi/combo_handler.cc       |    2 +-
 plugins/experimental/lua/lapi.cc                |    2 +-
 .../memcached_remap/memcached_remap.cc          |    4 +-
 plugins/experimental/metalink/metalink.cc       |    2 +-
 plugins/experimental/mysql_remap/mysql_remap.cc |  498 +-
 plugins/experimental/spdy/http.cc               |    2 +-
 plugins/gzip/gzip.cc                            |    2 +-
 plugins/header_filter/rules.cc                  |    2 +-
 plugins/header_rewrite/conditions.cc            |    5 +-
 plugins/regex_remap/regex_remap.cc              |  160 +-
 proxy/ICPConfig.cc                              |    6 +
 proxy/ICPlog.h                                  |    1 +
 proxy/Initialize.cc                             |   39 +-
 proxy/Initialize.h                              |    2 +-
 proxy/InkAPITest.cc                             |   11 +-
 proxy/config/logs_xml.config.default            |   24 +-
 proxy/hdrs/HdrHeap.cc                           |    4 +-
 proxy/http/HttpClientSession.cc                 |    2 +-
 proxy/http/HttpSM.cc                            |    5 +
 proxy/http/HttpServerSession.cc                 |    2 +-
 proxy/http/HttpTransactCache.cc                 |    5 -
 proxy/logging/Log.cc                            |   37 +-
 proxy/logging/LogAccess.cc                      |   30 +-
 proxy/logging/LogAccess.h                       |    5 +-
 proxy/logging/LogAccessHttp.cc                  |   13 +
 proxy/logging/LogAccessHttp.h                   |    1 +
 proxy/logging/LogAccessICP.cc                   |   13 +
 proxy/logging/LogAccessICP.h                    |    3 +-
 proxy/logging/LogField.cc                       |   79 +-
 proxy/logging/LogField.h                        |   31 +
 proxy/logging/LogFormat.cc                      |   15 +-
 proxy/shared/UglyLogStubs.cc                    |    1 -
 proxy/signals.cc                                |    4 +-
 tools/Makefile.am                               |   18 -
 tools/tstop/.gitignore                          |    1 -
 tools/tstop/README                              |    4 -
 tools/tstop/stats.h                             |  393 --
 tools/tstop/tstop.cc                            |  378 --
 179 files changed, 21048 insertions(+), 20461 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c63666b1/CHANGES
----------------------------------------------------------------------
diff --cc CHANGES
index 4877e65,8fc1232..0882bf2
--- a/CHANGES
+++ b/CHANGES
@@@ -1,12 -1,28 +1,33 @@@
                                                           -*- coding: utf-8 -*-
 -Changes with Apache Traffic Server 4.2.0
 +Changes with Apache Traffic Server 5.0.0
 +
 +  *) [TS-1919] Eliminate CacheLookupHttpConfig. This breaks cluster
 +   compatibility, so all cluster nodes should be upgraded simultaneously.
  
+   *) [TS-2379] Add a new field: '%<chp>', "client_host_port" to LogFormat.
+ 
+   *) [TS-2374] Abort the producer if the none of it`s consumers is alive.
+ 
+   *) [TS-2327] TSRedirectUrlSet does not perform DNS lookup of redirected OS
+ 
+   *) [TS-1468] Check vary and accept headers on non-200 responses in cache
+ 
+   *) [TS-2352] refine THREAD_ALLOC feature.
+ 
+   *) [TS-2364] Introduce slice notation to field syntax in log format.
+ 
+   *) [TS-2360] Fix usage of TSMimeHdrFieldValueStringGet() IDX in some plugins.
+ 
+   *) [TS-2361] Load regex_remap configuration relative to the configuration directory.
+ 
+   *) [TS-2359] Make install over existing installation can fail.
+ 
+   *) [TS-2350] Enhancements to traffic_top
+ 
+   *) [TS-2348] Rename tstop to traffic_top.
  
 +Changes with Apache Traffic Server 4.2.0
 +
    *) [TS-2340] Fix TextLogObject log rolling.
     Author: bettydramit <b1...@gmail.com>
  

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c63666b1/iocore/cache/Cache.cc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c63666b1/iocore/cache/CacheRead.cc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c63666b1/iocore/cache/P_CacheInternal.h
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c63666b1/proxy/http/HttpSM.cc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c63666b1/proxy/http/HttpTransactCache.cc
----------------------------------------------------------------------


[31/44] git commit: fix linking traffic_api_cli_remote on ubuntu

Posted by zw...@apache.org.
fix linking traffic_api_cli_remote on ubuntu


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

Branch: refs/heads/5.0.x
Commit: 938fa1ec285cb814e5bd94bb08efd71d09b83087
Parents: 898d55f
Author: Zhao Yongming <mi...@gmail.com>
Authored: Sun Nov 17 09:17:19 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Wed Nov 20 17:55:49 2013 +0800

----------------------------------------------------------------------
 cmd/traffic_cop/Makefile.am   | 1 +
 cmd/traffic_line/Makefile.am  | 1 +
 cmd/traffic_shell/Makefile.am | 1 +
 cmd/traffic_top/Makefile.am   | 1 +
 mgmt/api/Makefile.am          | 5 +++--
 5 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/938fa1ec/cmd/traffic_cop/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_cop/Makefile.am b/cmd/traffic_cop/Makefile.am
index 6403623..f5a25a4 100644
--- a/cmd/traffic_cop/Makefile.am
+++ b/cmd/traffic_cop/Makefile.am
@@ -36,6 +36,7 @@ traffic_cop_SOURCES = \
 traffic_cop_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
 
 traffic_cop_LDADD = \
+  $(top_builddir)/mgmt/api/libtsmgmtshare.la \
   $(top_builddir)/mgmt/api/libtsmgmt.la \
   $(top_builddir)/lib/ts/libtsutil.la \
   $(top_builddir)/lib/records/librec4cop.a \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/938fa1ec/cmd/traffic_line/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_line/Makefile.am b/cmd/traffic_line/Makefile.am
index 6a2aec3..debf8bd 100644
--- a/cmd/traffic_line/Makefile.am
+++ b/cmd/traffic_line/Makefile.am
@@ -30,6 +30,7 @@ traffic_line_SOURCES = \
 
 traffic_line_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
 traffic_line_LDADD = \
+  $(top_builddir)/mgmt/api/libtsmgmtshare.la \
   $(top_builddir)/mgmt/api/libtsmgmt.la \
   $(top_builddir)/lib/ts/libtsutil.la \
   @LIBRESOLV@ @LIBTCL@ @LIBSSL@

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/938fa1ec/cmd/traffic_shell/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/Makefile.am b/cmd/traffic_shell/Makefile.am
index ba3356c..09574cd 100644
--- a/cmd/traffic_shell/Makefile.am
+++ b/cmd/traffic_shell/Makefile.am
@@ -67,6 +67,7 @@ libtrafficshell_a_SOURCES = \
 traffic_shell_LDFLAGS =	@EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
 traffic_shell_LDADD = \
   libtrafficshell.a \
+  $(top_builddir)/mgmt/api/libtsmgmtshare.la \
   $(top_builddir)/mgmt/api/libtsmgmt.la \
   $(top_builddir)/mgmt/utils/libutils_lm.a \
   $(top_builddir)/lib/ts/libtsutil.la \

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/938fa1ec/cmd/traffic_top/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/Makefile.am b/cmd/traffic_top/Makefile.am
index 51e45e5..d9fc2e5 100644
--- a/cmd/traffic_top/Makefile.am
+++ b/cmd/traffic_top/Makefile.am
@@ -31,6 +31,7 @@ traffic_top_CXXFLAGS = \
 
 traffic_top_SOURCES = traffic_top.cc
 traffic_top_LDADD = \
+  $(top_builddir)/mgmt/api/libtsmgmtshare.la \
   $(top_builddir)/mgmt/api/libtsmgmt.la \
   @CURL_LIBS@ @CURSES_LIB@
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/938fa1ec/mgmt/api/Makefile.am
----------------------------------------------------------------------
diff --git a/mgmt/api/Makefile.am b/mgmt/api/Makefile.am
index d07a2b7..bb311a3 100644
--- a/mgmt/api/Makefile.am
+++ b/mgmt/api/Makefile.am
@@ -35,10 +35,8 @@ DEFS += $(MGMT_DEFS)
 
 noinst_LIBRARIES = libmgmtapilocal.a
 libmgmtapilocal_a_SOURCES = \
-  include/mgmtapi.h \
   CfgContextDefs.h \
   CoreAPI.cc \
-  CoreAPI.h \
   EventControlMain.cc \
   EventControlMain.h \
   NetworkUtilsDefs.h \
@@ -61,6 +59,8 @@ libtsmgmtshare_la_SOURCES = \
   EventCallback.h \
   GenericParser.cc \
   GenericParser.h \
+  include/mgmtapi.h \
+  CoreAPI.h \
   INKMgmtAPI.cc
 
 if BUILD_TESTS
@@ -85,6 +85,7 @@ if BUILD_TESTS
 endif
 
 traffic_api_cli_remote_LDADD = \
+  libtsmgmtshare.la \
   libtsmgmt.la \
   $(top_builddir)/lib/ts/libtsutil.la \
   @LIBTCL@ @LIBSSL@


[42/44] git commit: Renamed the git repos to track the major release number. This only applies for v4 and v5, v3.2 has to stay as is.

Posted by zw...@apache.org.
Renamed the git repos to track the major release number. This only
applies for v4 and v5, v3.2 has to stay as is.


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

Branch: refs/heads/5.0.x
Commit: 9214792f82a479e72b2568116769b5026d760c25
Parents: 0c8fba4
Author: Leif Hedstrom <zw...@apache.org>
Authored: Thu Nov 21 11:09:51 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Thu Nov 21 11:09:51 2013 -0700

----------------------------------------------------------------------
 ci/jenkins/jobs.yaml | 76 +++++++++++++++++++++++------------------------
 1 file changed, 38 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9214792f/ci/jenkins/jobs.yaml
----------------------------------------------------------------------
diff --git a/ci/jenkins/jobs.yaml b/ci/jenkins/jobs.yaml
index 03a55ff..ec866f0 100644
--- a/ci/jenkins/jobs.yaml
+++ b/ci/jenkins/jobs.yaml
@@ -223,10 +223,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 
 - project:
@@ -259,10 +259,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: centos-6.4-x64
@@ -294,10 +294,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: master
             tag: taobao
@@ -334,10 +334,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: fedora-15-x64
@@ -369,10 +369,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: fedora-15-x86
@@ -404,10 +404,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: fedora-18-x64
@@ -439,10 +439,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: fedora-18-x86
@@ -474,10 +474,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: fedora-rawhide-x64
@@ -509,10 +509,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-clang-{tag}-regression':
             branch: master
             tag: debug
@@ -523,7 +523,7 @@
             repo: file:///home/jenkins/git/trafficserver
         - '{node}-{branch}-clang-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: fedora-rawhide-x86
@@ -555,10 +555,10 @@
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: freebsd-9.1-x64
@@ -588,12 +588,12 @@
             repo: file:///home/jenkins/git/trafficserver_3.2
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: omnios-x64
@@ -623,12 +623,12 @@
             repo: file:///home/jenkins/git/trafficserver_3.2
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: opensuse-12-x64
@@ -658,12 +658,12 @@
             repo: file:///home/jenkins/git/trafficserver_3.2
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: ubuntu-10.04-x64
@@ -698,12 +698,12 @@
             repo: file:///home/jenkins/git/trafficserver_3.2
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: ubuntu-12.04-x64
@@ -738,17 +738,17 @@
             repo: file:///home/jenkins/git/trafficserver_3.2
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
             tag: hardening
             hardening: '1'
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: master
             tag: taobao
@@ -788,12 +788,12 @@
             repo: file:///home/jenkins/git/trafficserver_3.2
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///home/jenkins/git/trafficserver_4.1
+            repo: file:///home/jenkins/git/trafficserver_4
 
 - project:
     name: mac-os-x
@@ -823,19 +823,19 @@
             repo: file:///Users/jenkins/git/trafficserver_3.2
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
-            repo: file:///Users/jenkins/git/trafficserver_4.1
+            repo: file:///Users/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 4.1.x
             tag: debug
             debug: --enable-debug
-            repo: file:///Users/jenkins/git/trafficserver_4.1
+            repo: file:///Users/jenkins/git/trafficserver_4
         - '{node}-{branch}-{tag}-regression':
             branch: 5.0.x
-            repo: file:///Users/jenkins/git/trafficserver_5.0
+            repo: file:///Users/jenkins/git/trafficserver_5
         - '{node}-{branch}-{tag}-regression':
             branch: 5.0.x
             tag: debug
             debug: --enable-debug
-            repo: file:///Users/jenkins/git/trafficserver_5.0
+            repo: file:///Users/jenkins/git/trafficserver_5
 
 # vim: sw=4 ts=4 et ft=yaml :


[19/44] git commit: TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
TS-2349: Move traffic_shell to the cmd subdirectory


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

Branch: refs/heads/5.0.x
Commit: 775ad1dc4c8f005f0a23dee1531bfd0288eed444
Parents: c83e1d8
Author: James Peach <jp...@apache.org>
Authored: Sat Nov 9 21:06:00 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Nov 14 12:30:54 2013 -0800

----------------------------------------------------------------------
 cmd/Makefile.am                                 |    2 +-
 cmd/traffic_shell/CliCreateCommands.cc          |  318 ++
 cmd/traffic_shell/CliCreateCommands.h           |   39 +
 cmd/traffic_shell/CliDisplay.cc                 |  221 +
 cmd/traffic_shell/CliDisplay.h                  |   91 +
 cmd/traffic_shell/CliMgmtUtils.cc               |  625 +++
 cmd/traffic_shell/CliMgmtUtils.h                |  152 +
 cmd/traffic_shell/ConfigCmd.cc                  | 4626 ++++++++++++++++++
 cmd/traffic_shell/ConfigCmd.h                   |  865 ++++
 cmd/traffic_shell/ConfigUpgradeCmd.cc           |  634 +++
 cmd/traffic_shell/ConfigUpgradeCmd.h            |  252 +
 cmd/traffic_shell/ConfigUpgradeReadCmd.cc       |  498 ++
 cmd/traffic_shell/ConfigUpgradeWriteCmd.cc      |  517 ++
 cmd/traffic_shell/Makefile.am                   |   76 +
 cmd/traffic_shell/ShowCmd.cc                    | 2322 +++++++++
 cmd/traffic_shell/ShowCmd.h                     |  247 +
 cmd/traffic_shell/UtilCmds.cc                   |  196 +
 cmd/traffic_shell/UtilCmds.h                    |   94 +
 cmd/traffic_shell/cliAppInit.cc                 |  165 +
 cmd/traffic_shell/cliParseArg.cc                |  457 ++
 cmd/traffic_shell/cli_detailed_command_list.txt | 1623 ++++++
 cmd/traffic_shell/cli_feature_spec.txt          |  230 +
 cmd/traffic_shell/commandOptions.h              |   47 +
 cmd/traffic_shell/createArgument.cc             |  387 ++
 cmd/traffic_shell/createArgument.h              |  119 +
 cmd/traffic_shell/createCommand.cc              |  166 +
 cmd/traffic_shell/createCommand.h               |   59 +
 cmd/traffic_shell/definitions.h                 |   77 +
 cmd/traffic_shell/hashtable.cc                  |  219 +
 cmd/traffic_shell/hashtable.h                   |   45 +
 cmd/traffic_shell/processArgument.cc            |   57 +
 cmd/traffic_shell/traffic_shell.cc              |  113 +
 configure.ac                                    |    2 +-
 mgmt/Makefile.am                                |    2 +-
 mgmt/cli/CliCreateCommands.cc                   |  318 --
 mgmt/cli/CliCreateCommands.h                    |   39 -
 mgmt/cli/CliDisplay.cc                          |  221 -
 mgmt/cli/CliDisplay.h                           |   91 -
 mgmt/cli/CliMgmtUtils.cc                        |  625 ---
 mgmt/cli/CliMgmtUtils.h                         |  152 -
 mgmt/cli/ConfigCmd.cc                           | 4626 ------------------
 mgmt/cli/ConfigCmd.h                            |  865 ----
 mgmt/cli/ConfigUpgradeCmd.cc                    |  634 ---
 mgmt/cli/ConfigUpgradeCmd.h                     |  252 -
 mgmt/cli/ConfigUpgradeReadCmd.cc                |  498 --
 mgmt/cli/ConfigUpgradeWriteCmd.cc               |  517 --
 mgmt/cli/Makefile.am                            |   78 -
 mgmt/cli/ShowCmd.cc                             | 2322 ---------
 mgmt/cli/ShowCmd.h                              |  247 -
 mgmt/cli/UtilCmds.cc                            |  196 -
 mgmt/cli/UtilCmds.h                             |   94 -
 mgmt/cli/cliAppInit.cc                          |  165 -
 mgmt/cli/cliMain.cc                             |  113 -
 mgmt/cli/cliParseArg.cc                         |  457 --
 mgmt/cli/cli_detailed_command_list.txt          | 1623 ------
 mgmt/cli/cli_feature_spec.txt                   |  230 -
 mgmt/cli/commandOptions.h                       |   47 -
 mgmt/cli/createArgument.cc                      |  387 --
 mgmt/cli/createArgument.h                       |  119 -
 mgmt/cli/createCommand.cc                       |  166 -
 mgmt/cli/createCommand.h                        |   59 -
 mgmt/cli/definitions.h                          |   77 -
 mgmt/cli/hashtable.cc                           |  219 -
 mgmt/cli/hashtable.h                            |   45 -
 mgmt/cli/processArgument.cc                     |   57 -
 65 files changed, 15540 insertions(+), 15542 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
index 58a8a68..6a7d258 100644
--- a/cmd/Makefile.am
+++ b/cmd/Makefile.am
@@ -15,4 +15,4 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-SUBDIRS = traffic_top traffic_cop traffic_line
+SUBDIRS = traffic_top traffic_cop traffic_line traffic_shell

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/CliCreateCommands.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/CliCreateCommands.cc b/cmd/traffic_shell/CliCreateCommands.cc
new file mode 100644
index 0000000..5a22207
--- /dev/null
+++ b/cmd/traffic_shell/CliCreateCommands.cc
@@ -0,0 +1,318 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/****************************************************************
+ * Filename: CliCreateCommands.cc
+ * Purpose: This file contains the CLI command creation function.
+ *
+ *
+ ****************************************************************/
+
+#include "CliCreateCommands.h"
+#include "createCommand.h"
+#include "ShowCmd.h"
+#include "ConfigCmd.h"
+#include "UtilCmds.h"
+#include "CliDisplay.h"
+#include "I_Layout.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <string>
+#include <sstream>
+#include <algorithm>
+
+////////////////////////////////////////////////////////////////
+// Called during Tcl_AppInit, this function creates the CLI commands
+//
+int
+CliCreateCommands()
+{
+  createCommand("config:root", Cmd_ConfigRoot, NULL, CLI_COMMAND_EXTERNAL, "config:root", "Switch to root user");
+
+  createCommand("show", Cmd_Show, NULL, CLI_COMMAND_EXTERNAL, "show", "Show command");
+
+  createCommand("config", Cmd_Config, NULL, CLI_COMMAND_EXTERNAL, "config", "Config command");
+
+  createCommand("show:status", Cmd_ShowStatus, NULL, CLI_COMMAND_EXTERNAL, "show:status", "Proxy status");
+
+  createCommand("show:version", Cmd_ShowVersion, NULL, CLI_COMMAND_EXTERNAL, "show:version", "Version information");
+
+
+  createCommand("show:security", Cmd_ShowSecurity, NULL, CLI_COMMAND_EXTERNAL, "show:security", "Security information");
+
+  createCommand("show:http", Cmd_ShowHttp, NULL, CLI_COMMAND_EXTERNAL, "show:http", "HTTP protocol configuration");
+
+  createCommand("show:icp", Cmd_ShowIcp, CmdArgs_ShowIcp, CLI_COMMAND_EXTERNAL,
+                "show:icp [peer]", "ICP protocol configuration");
+
+  createCommand("show:proxy", Cmd_ShowProxy, NULL, CLI_COMMAND_EXTERNAL, "show:proxy", "Proxy configuration");
+
+  createCommand("show:cache", Cmd_ShowCache, CmdArgs_ShowCache, CLI_COMMAND_EXTERNAL,
+                "show:cache [rules|storage]", "Cache configuration");
+
+  createCommand("show:virtual-ip", Cmd_ShowVirtualIp, NULL, CLI_COMMAND_EXTERNAL,
+                "show:virtual-ip", "Virtual-ip configuration");
+
+  createCommand("show:hostdb", Cmd_ShowHostDb, NULL, CLI_COMMAND_EXTERNAL,
+                "show:hostdb", "Host database configuration");
+
+  createCommand("show:dns-resolver", Cmd_ShowDnsResolver, NULL, CLI_COMMAND_EXTERNAL,
+                "show:dns-resolver", "DNS resolver configuration");
+
+  createCommand("show:logging", Cmd_ShowLogging, NULL, CLI_COMMAND_EXTERNAL, "show:logging", "Logging configuration");
+
+  createCommand("show:ssl", Cmd_ShowSsl, NULL, CLI_COMMAND_EXTERNAL, "show:ssl", "SSL configuration");
+
+  createCommand("show:parent", Cmd_ShowParents, CmdArgs_ShowParents, CLI_COMMAND_EXTERNAL,
+                "show:parent", "Parent configuration");
+
+  createCommand("show:remap", Cmd_ShowRemap, NULL, CLI_COMMAND_EXTERNAL, "show:remap", "Remap configuration");
+
+  createCommand("show:socks", Cmd_ShowSocks, CmdArgs_ShowSocks, CLI_COMMAND_EXTERNAL,
+                "show:socks", "SOCKS configuration");
+
+  createCommand("show:scheduled-update", Cmd_ShowScheduledUpdate, CmdArgs_ShowScheduledUpdate, CLI_COMMAND_EXTERNAL,
+                "show:scheduled-update", "Scheduled update configuration");
+
+  createCommand("show:proxy-stats", Cmd_ShowProxyStats, NULL, CLI_COMMAND_EXTERNAL,
+                "show:proxy-stats", "Proxy statistics");
+
+  createCommand("show:http-trans-stats", Cmd_ShowHttpTransStats, NULL, CLI_COMMAND_EXTERNAL,
+                "show:http-trans-stats", "HTTP transaction statistics");
+
+  createCommand("show:http-stats", Cmd_ShowHttpStats, NULL, CLI_COMMAND_EXTERNAL, "show:http-stats", "HTTP statistics");
+
+  createCommand("show:icp-stats", Cmd_ShowIcpStats, NULL, CLI_COMMAND_EXTERNAL, "show:icp-stats", "ICP statistics");
+
+  createCommand("show:cache-stats", Cmd_ShowCacheStats, NULL, CLI_COMMAND_EXTERNAL,
+                "show:cache-stats", "Cache statistics");
+
+  createCommand("show:hostdb-stats", Cmd_ShowHostDbStats, NULL, CLI_COMMAND_EXTERNAL,
+                "show:hostdb-stats", "Host database statistics");
+
+  createCommand("show:dns-stats", Cmd_ShowDnsStats, NULL, CLI_COMMAND_EXTERNAL, "show:dns-stats", "DNS statistics");
+
+  createCommand("show:logging-stats", Cmd_ShowLoggingStats, NULL, CLI_COMMAND_EXTERNAL,
+                "show:logging-stats", "Logging statistics");
+
+  createCommand("show:alarms", Cmd_ShowAlarms, NULL, CLI_COMMAND_EXTERNAL, "show:alarms", "Show active alarms");
+
+  createCommand("show:cluster", Cmd_ShowCluster, NULL, CLI_COMMAND_EXTERNAL,
+                "show:cluster", "Show Cluster Ports Settings");
+
+  createCommand("config:get", Cmd_ConfigGet, NULL, CLI_COMMAND_EXTERNAL,
+                "config:get <variable>", "Display a variable value");
+
+  createCommand("config:set", Cmd_ConfigSet, NULL, CLI_COMMAND_EXTERNAL,
+                "config:set <variable> <value>", "Set variable to specified value");
+
+  createCommand("config:name", Cmd_ConfigName, NULL, CLI_COMMAND_EXTERNAL,
+                "config:name <string>", "Set proxy name <string>");
+
+  createCommand("config:start", Cmd_ConfigStart, NULL, CLI_COMMAND_EXTERNAL, "config:start", "Start proxy software");
+
+  createCommand("config:stop", Cmd_ConfigStop, NULL, CLI_COMMAND_EXTERNAL, "config:stop", "Stop proxy software");
+
+  createCommand("config:hard-restart", Cmd_ConfigHardRestart, NULL, CLI_COMMAND_EXTERNAL,
+                "config:hard-restart", "Perform Hard Restart of all software components");
+
+  createCommand("config:restart", Cmd_ConfigRestart, CmdArgs_ConfigRestart, CLI_COMMAND_EXTERNAL,
+                "config:restart [cluster]", "Perform Restart of proxy software");
+
+  createCommand("config:ssl", Cmd_ConfigSsl, CmdArgs_ConfigSsl, CLI_COMMAND_EXTERNAL,
+                "config:ssl status <on | off>\n" "config:ssl ports <int>", "Configure ssl");
+
+  createCommand("config:parent", Cmd_ConfigParents, CmdArgs_ConfigParents, CLI_COMMAND_EXTERNAL,
+                "config:parent status <on | off>\n"
+                "config:parent name <parent>\n" "config:parent rules <url>", "Update parent configuration");
+
+
+  createCommand("config:remap", Cmd_ConfigRemap, NULL, CLI_COMMAND_EXTERNAL,
+                "config:remap <url>", "Update remap configuration file <url>");
+
+  createCommand("config:clock", Cmd_ConfigClock, CmdArgs_ConfigClock, CLI_COMMAND_EXTERNAL,
+                "config:clock date <mm/dd/yyyy>\n"
+                "config:clock time <hh:mm:ss>\n"
+                "config:clock timezone <number from list | list>", "Configure date, time, timezone");
+
+  createCommand("config:security", Cmd_ConfigSecurity, CmdArgs_ConfigSecurity, CLI_COMMAND_EXTERNAL,
+                "config:security <ip-allow | mgmt-allow | admin> <url-config-file>\n"
+                "config:security password", "Update security configuration");
+
+  createCommand("config:http", Cmd_ConfigHttp, CmdArgs_ConfigHttp, CLI_COMMAND_EXTERNAL,
+                "config:http status <on | off>\n"
+                "config:http <keep-alive-timeout-in | keep-alive-timeout-out> <seconds>\n"
+                "config:http <inactive-timeout-in | inactive-timeout-out> <seconds>\n"
+                "config:http <active-timeout-in | active-timeout-out> <seconds>\n"
+                "config:http <remove-from | remove-referer> <on | off>\n"
+                "config:http <remove-user | remove-cookie> <on | off>\n"
+                "config:http <remove-header> <string>\n"
+                "config:http <insert-ip | remove-ip> <on | off>\n"
+                "config:http proxy <fwd | rev | fwd-rev>", "Configure HTTP");
+
+  createCommand("config:icp", Cmd_ConfigIcp, CmdArgs_ConfigIcp, CLI_COMMAND_EXTERNAL,
+                "config:icp mode <disabled | receive | send-receive>\n"
+                "config:icp port <int>\n"
+                "config:icp multicast <on | off>\n"
+                "config:icp query-timeout <seconds>\n" "config:icp peers <url-config-file>", "Configure ICP");
+
+  createCommand("config:scheduled-update", Cmd_ConfigScheduledUpdate, CmdArgs_ConfigScheduledUpdate,
+                CLI_COMMAND_EXTERNAL,
+                "config:scheduled-update status <on | off>\n" "config:scheduled-update retry-count <int>\n"
+                "config:scheduled-update retry-interval <sec>\n" "config:scheduled-update max-concurrent <int>\n"
+                "config:scheduled-update force-immediate <on | off>\n"
+                "config:scheduled-update rules <url-config-file>", "Configure Scheduled Update");
+
+  createCommand("config:socks", Cmd_ConfigSocks, CmdArgs_ConfigSocks, CLI_COMMAND_EXTERNAL,
+                "config:socks status <on | off>\n"
+                "config:socks version <version>\n"
+                "config:socks default-servers <string>\n"
+                "config:socks accept <on | off>\n" "config:socks accept-port <int>", "Configure Socks");
+
+  createCommand("config:cache", Cmd_ConfigCache, CmdArgs_ConfigCache, CLI_COMMAND_EXTERNAL,
+                "config:cache <http> <on | off>\n"
+                "config:cache ignore-bypass <on | off>\n"
+                "config:cache <max-object-size | max-alternates> <int>\n"
+                "config:cache file <url-config-file>\n"
+                "config:cache freshness verify <when-expired | no-date | always | never>\n"
+                "config:cache freshness minimum <explicit | last-modified | nothing>\n"
+                "config:cache freshness no-expire-limit greater-than <sec> less-than <sec>\n"
+                "config:cache <dynamic | alternates> <on | off>\n"
+                "config:cache vary <text | images | other> <string>\n"
+                "config:cache cookies <none | all | images | non-text>\n" "config:cache clear", "Configure Cache");
+
+
+  createCommand("config:hostdb", Cmd_ConfigHostdb, CmdArgs_ConfigHostdb, CLI_COMMAND_EXTERNAL,
+                "config:hostdb <lookup-timeout | foreground-timeout> <seconds>\n"
+                "config:hostdb <background-timeout | invalid-host-timeout> <seconds>\n"
+                "config:hostdb <re-dns-on-reload> <on | off>\n" "config:hostdb clear", "Configure Host Database");
+
+  createCommand("config:logging", Cmd_ConfigLogging, CmdArgs_ConfigLogging, CLI_COMMAND_EXTERNAL,
+                "config:logging event <enabled | trans-only | error-only | disabled>\n"
+                "config:logging mgmt-directory <string>\n"
+                "config:logging <space-limit | space-headroom> <megabytes>\n"
+                "config:logging collation-status <inactive | host | send-standard |\n"
+                "                                 send-custom | send-all>\n"
+                "config:logging collation-host <string>\n"
+                "config:logging collation secret <string> tagged <on | off> orphan-limit <int>\n"
+                "config:logging format <squid | netscape-common | netscape-ext | netscape-ext2> <on | off>\n"
+                "               type <ascii | binary> file <string> header <string>\n"
+                "config:logging splitting <icp | http> <on | off>\n"
+                "config:logging custom <on | off> format <traditional | xml>\n"
+                "config:logging rolling <on | off> offset <hour> interval <hours>\n"
+                "               auto-delete <on | off>", "Configure Logging");
+
+
+  createCommand("config:dns", Cmd_ConfigDns, CmdArgs_ConfigDns, CLI_COMMAND_EXTERNAL,
+                "config:dns resolve-timeout <seconds>\n" "config:dns retries <int>", "Configure DNS");
+
+  createCommand("config:virtual-ip", Cmd_ConfigVirtualip, CmdArgs_ConfigVirtualip, CLI_COMMAND_EXTERNAL,
+                "config:virtual-ip status <on | off>\n"
+                "config:virtual-ip list\n"
+                "config:virtual-ip add <x.x.x.x> device <string> sub-intf <int>\n"
+                "config:virtual-ip delete <virtual ip number>", "Configure virtual-ip");
+
+  createCommand("config:alarms", Cmd_ConfigAlarm, CmdArgs_ConfigAlarm, CLI_COMMAND_EXTERNAL,
+                "config:alarms resolve-name <string>\n"
+                "config:alarms resolve-number <int>\n"
+                "config:alarms resolve-all\n"
+                "config:alarms notify <on | off>", "Resolve Alarms, Turn notification on/off");
+
+  createCommand("enable", Cmd_Enable, CmdArgs_Enable, CLI_COMMAND_EXTERNAL,
+                "enable \n" "enable status ", "Enable Restricted Commands");
+
+  createCommand("disable", Cmd_Disable, NULL, CLI_COMMAND_EXTERNAL, "disable", "Disable Restricted Commands");
+
+
+  createCommand("debug", DebugCmd, DebugCmdArgs, CLI_COMMAND_EXTERNAL,
+                "debug <on|off>", "Turn debugging print statements on/off");
+
+  createCommand("help", Cmd_Help, NULL, CLI_COMMAND_EXTERNAL,
+                "help [topic]", "Display online help");
+
+  return CLI_OK;
+}
+
+#if defined(__SUNPRO_CC)
+
+// Solaris doesn't like to link libstdc++ code. I don't have a system to test. Sorry.
+
+int
+Cmd_Help(ClientData, Tcl_Interp *, int, const char *[])
+{
+  return CMD_OK;
+}
+
+#else
+
+struct replace_colon
+{
+  char operator() (char c) const {
+    return (c == ':') ? '_' : c;
+  }
+};
+
+static int
+xsystem(const char * cmd)
+{
+  // Some versions of glibc declare system(3) with the warn_unused_result
+  // attribute. Pretend to use the return value so it will shut the hell up.
+  return system(cmd);
+}
+
+int
+Cmd_Help(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * /* interp ATS_UNUSED */, int argc, const char *argv[])
+{
+  Cli_Debug("looking for online help in %s\n", Layout::get()->datadir);
+
+  for (int i = 1; i < argc; ++i) {
+    std::ostringstream  cmd;
+    std::string         topic(argv[i]);
+
+    // Replace ':' with '_' so we can find the right on-disk man page.
+    std::transform(topic.begin(), topic.end(), topic.begin(), replace_colon());
+
+    // Check whether we have the man page on disk before we pass any user input
+    // to the shell via system(3).
+    cmd << Layout::get()->datadir << "/trafficshell/" << topic << ".1";
+    if (access(cmd.str().c_str(), R_OK) != 0) {
+      Cli_Debug("missing %s\n", cmd.str().c_str());
+      continue;
+    }
+
+    cmd.clear();
+    cmd.seekp(std::ios_base::beg);
+
+    cmd << "man "
+      << Layout::get()->datadir << "/trafficshell/" << topic << ".1";
+
+    Cli_Debug("%s\n", cmd.str().c_str());
+    xsystem(cmd.str().c_str());
+  }
+
+  return CMD_OK;
+}
+
+#endif  /* __SUNPRO_C */
+
+// vim: set ts=2 sw=2 et :

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/CliCreateCommands.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/CliCreateCommands.h b/cmd/traffic_shell/CliCreateCommands.h
new file mode 100644
index 0000000..da49ae7
--- /dev/null
+++ b/cmd/traffic_shell/CliCreateCommands.h
@@ -0,0 +1,39 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/****************************************************************
+ * Filename: CliCreateCommands.h
+ * Purpose: This file contains the CLI command creation function.
+ *
+ *
+ ****************************************************************/
+
+#ifndef __CLI_CREATE_COMMANDS_H__
+#define __CLI_CREATE_COMMANDS_H__
+
+////////////////////////////////////////////////////////////////
+// Called during Tcl_AppInit, this function creates generic the CLI commands
+//
+int CliCreateCommands();
+
+#endif // __CLI_CREATE_COMMANDS_H__

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/CliDisplay.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/CliDisplay.cc b/cmd/traffic_shell/CliDisplay.cc
new file mode 100644
index 0000000..74dda07
--- /dev/null
+++ b/cmd/traffic_shell/CliDisplay.cc
@@ -0,0 +1,221 @@
+/** @file
+
+  Implementation of CliDisplay routines for the use of TB
+
+  @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 "libts.h"
+#include "CliDisplay.h"
+#include "definitions.h"
+#include <string.h>
+
+
+#define BUF_SIZE 1024
+
+extern Tcl_Interp *interp;
+static CliPrintLevelT CliPrintLevel = CLI_PRINT_DEFAULT;
+
+int CliDisplayPrintf = 0;
+
+/*****************************************************************
+ * Display one of the predefined error messages.
+ */
+int
+Cli_Error(const char *errString, ...)
+{
+  char buffer[BUF_SIZE];
+
+  va_list ap;
+  va_start(ap, errString);
+  // XXX/amitk ugh. easy buffer overrun.
+  // why isn't vsnprintf always available??
+  vsprintf(buffer, errString, ap);
+  va_end(ap);
+
+  // fix for BZ27769
+  //   libtrafficshell.a standalone uses Tcl_AppendResult
+  //   traffic_shell binary uses printf
+  if (CliDisplayPrintf) {
+    printf("%s", buffer);
+  } else {
+    Tcl_AppendResult(interp, buffer, (char *) NULL);
+  }
+
+  return CLI_OK;
+}
+
+/****************************************************************
+ * Set print level
+ *   level = CLI_PRINT_DEFAULT (Cli_Printf)
+ *   level = CLI_PRINT_INFO    (Cli_Printf, Cli_Info)
+ *   level = CLI_PRINT_DEBUG   (Cli_Printf, Cli_Debug)
+ *   level = CLI_PRINT_INFO | CLI_PRINT_DEBUG  (Cli_Printf, Cli_Debug, Cli_Info)
+ */
+int
+Cli_SetPrintLevel(CliPrintLevelT level)
+{
+  CliPrintLevel = level;
+  return CLI_OK;
+
+}
+
+/****************************************************************
+ * return the current print level
+ */
+CliPrintLevelT
+Cli_GetPrintLevel()
+{
+  return CliPrintLevel;
+}
+
+/****************************************************************
+ * Display string
+ */
+int
+Cli_Printf(const char *string, ...)
+{
+  char buffer[BUF_SIZE];
+  va_list ap;
+
+  va_start(ap, string);
+  vsprintf(buffer, string, ap);
+  va_end(ap);
+
+  // fix for BZ27769
+  //   libtrafficshell.a standalone uses Tcl_AppendResult
+  //   traffic_shell binary uses printf
+  if (CliDisplayPrintf) {
+    printf("%s", buffer);
+  } else {
+    Tcl_AppendResult(interp, buffer, (char *) NULL);
+  }
+
+  return CLI_OK;
+}
+
+/****************************************************************
+ * Display informative message
+ */
+int
+Cli_Info(const char *string, ...)
+{
+  char buffer[BUF_SIZE];
+  va_list ap;
+
+  va_start(ap, string);
+  if (CliPrintLevel & CLI_PRINT_INFO) {
+    vsprintf(buffer, string, ap);
+
+    // fix for BZ27769
+    //   libtrafficshell.a standalone uses Tcl_AppendResult
+    //   traffic_shell binary uses printf
+    if (CliDisplayPrintf) {
+      printf("%s", buffer);
+    } else {
+      Tcl_AppendResult(interp, buffer, (char *) NULL);
+    }
+  }
+  va_end(ap);
+
+  return CLI_OK;
+}
+
+
+/****************************************************************
+ * Display debug statement
+ */
+int
+Cli_Debug(const char *string, ...)
+{
+  char buffer[BUF_SIZE];
+  va_list ap;
+
+  // allocate enough room for "debug: " at beginning of string
+  const size_t new_string_size = strlen(string) + 8;
+  char *new_string = (char *)alloca(new_string_size);
+  ink_strlcpy(new_string, "debug: ", new_string_size);
+  ink_strlcat(new_string, string, new_string_size );
+
+  va_start(ap, string);
+  if (CliPrintLevel & CLI_PRINT_DEBUG) {
+    vsprintf(buffer, new_string, ap);
+
+    // fix for BZ27769
+    //   libtrafficshell.a standalone uses Tcl_AppendResult
+    //   traffic_shell binary uses printf
+    if (CliDisplayPrintf) {
+      printf("%s", buffer);
+    } else {
+      Tcl_AppendResult(interp, buffer, (char *) NULL);
+    }
+  }
+  va_end(ap);
+
+  return CLI_OK;
+}
+
+int
+Cli_PrintEnable(const char *string, int flag)
+{
+  if (flag == 0)
+    Cli_Printf("%soff\n", string);
+  else if (flag == 1)
+    Cli_Printf("%son\n", string);
+  else {
+    Cli_Debug(ERR_INVALID_PARAMETER);
+    return CLI_ERROR;
+  }
+
+  return CLI_OK;
+}
+
+int
+Cli_PrintOnOff(int flag)
+{
+  switch (flag) {
+  case 0:
+    Cli_Printf("off\n");
+    break;
+  case 1:
+    Cli_Printf("on\n");
+    break;
+  default:
+    Cli_Printf("?\n");
+    break;
+  }
+  return CLI_OK;
+}
+
+int
+Cli_PrintArg(int arg_index, const cli_parsedArgInfo * argtable)
+{
+
+
+
+  if (arg_index >= 0) {
+    Cli_Debug("%d %d %s\n", argtable[arg_index].parsed_args,
+              argtable[arg_index].arg_int, argtable[arg_index].arg_string);
+    return CLI_OK;
+  }
+  return CLI_ERROR;
+}
+
+#undef BUF_SIZE

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/CliDisplay.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/CliDisplay.h b/cmd/traffic_shell/CliDisplay.h
new file mode 100644
index 0000000..be47db4
--- /dev/null
+++ b/cmd/traffic_shell/CliDisplay.h
@@ -0,0 +1,91 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/****************************************************************
+ * Filename: CliDisplay.h
+ * Purpose: This file contains the CLI display routines.
+ *
+ *
+ ****************************************************************/
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "createArgument.h"
+
+#ifndef __CLI_ERROR_HANDLE_H__
+#define __CLI_ERROR_HANDLE_H__
+
+/* CLI print levels
+ */
+typedef enum
+{
+  CLI_PRINT_DEFAULT = 0x0,
+  CLI_PRINT_INFO = 0x2,
+  CLI_PRINT_DEBUG = 0x4
+} CliPrintLevelT;
+
+/* All possible error strings are defined below.
+ *    In the future, this could be changed to a message_id/lookup mechanism.
+ */
+
+#define ERR_RECORD_GET         "INKRecordGet: failed to retrieve %s\n"
+#define ERR_RECORD_GET_INT     "INKRecordGetInt: failed to retrieve %s\n"
+#define ERR_RECORD_GET_COUNTER "INKRecordGetCounter: failed to retrieve %s\n"
+#define ERR_RECORD_GET_FLOAT   "INKRecordGetFloat: failed to retrieve %s\n"
+#define ERR_RECORD_GET_STRING  "INKRecordGetString: failed to retrieve %s\n"
+#define ERR_RECORD_SET         "INKRecordSet: failed to set %s value %s\n"
+#define ERR_RECORD_SET_INT     "INKRecordSetInt: failed to set %s value %d\n"
+#define ERR_RECORD_SET_FLOAT   "INKRecordSetFloat: failed to set %s value %f\n"
+#define ERR_RECORD_SET_STRING  "INKRecordSetString: failed to set %s value %s\n"
+
+
+#define ERR_COMMAND_SYNTAX    "\nCommand Syntax: \n%s\n\n"
+#define ERR_REQ_ACTION_UNDEF  "Undefined Action Required before Changes Take Effect\n"
+#define ERR_TOO_MANY_ARGS     "\nToo many arguments specified.\n"
+
+#define ERR_INVALID_COMMAND   "wrong # args: should be \n"
+#define ERR_INVALID_PARAMETER "Invalid Parameter\n"
+#define ERR_MISSING_PARAMETER "Missing Parameter\n"
+
+#define ERR_PROXY_STATE_ALREADY "Proxy is already %s\n" // on/off
+#define ERR_PROXY_STATE_SET     "Unable to set Proxy %s\n"      // on/off
+
+#define ERR_CONFIG_FILE_READ  "Error Reading Rules File %d\n"
+#define ERR_CONFIG_FILE_WRITE "Error Writing Rules File %d\n"
+#define ERR_READ_FROM_URL     "Error Reading File from URL %s\n"
+
+#define ERR_ALARM_LIST        "Error Retrieving Alarm List\n"
+#define ERR_ALARM_STATUS      "Error Determining Active/Inactive status of alarm %s\n"
+#define ERR_ALARM_RESOLVE_INACTIVE "Error: Attempt to resolve inactive alarm %s\n"
+#define ERR_ALARM_RESOLVE     "Errur: Unable to resolve alarm %s\n"
+#define ERR_ALARM_RESOLVE_NUMBER "Error: Alarm number non-existent\n"
+
+int Cli_Error(const char *errString, ...);
+int Cli_SetPrintLevel(CliPrintLevelT level);
+CliPrintLevelT Cli_GetPrintLevel();
+int Cli_Printf(const char *string, ...);
+int Cli_Debug(const char *string, ...);
+int Cli_PrintEnable(const char *string, int flag);
+int Cli_PrintOnOff(int flag);
+int Cli_PrintArg(int arg_index, const cli_parsedArgInfo * argtable);
+#endif // __CLI_ERROR_HANDLE_H__

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/CliMgmtUtils.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/CliMgmtUtils.cc b/cmd/traffic_shell/CliMgmtUtils.cc
new file mode 100644
index 0000000..222e334
--- /dev/null
+++ b/cmd/traffic_shell/CliMgmtUtils.cc
@@ -0,0 +1,625 @@
+/** @file
+
+  This file contains various utility functions which call the TSMgmtAPI.
+
+  @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 "libts.h"
+#include "I_Layout.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include "CliMgmtUtils.h"
+#include "CliDisplay.h"
+#include "ink_resource.h"
+#include "definitions.h"
+#include "ConfigCmd.h"
+
+
+void Cli_DisplayMgmtAPI_Error(TSError status);
+
+// Get a records.config variable by name
+TSError
+Cli_RecordGet(const char *rec_name, TSRecordEle * rec_val)
+{
+  TSError status;
+  if ((status = TSRecordGet((char *) rec_name, rec_val))) {
+    Cli_Debug(ERR_RECORD_GET, rec_name);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+// Get an integer type records.config variable
+TSError
+Cli_RecordGetInt(const char *rec_name, TSInt * int_val)
+{
+  TSError status;
+  if ((status = TSRecordGetInt(rec_name, int_val))) {
+    Cli_Debug(ERR_RECORD_GET_INT, rec_name);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+// Get an counter type records.config variable
+TSError
+Cli_RecordGetCounter(const char *rec_name, TSCounter * ctr_val)
+{
+  TSError status;
+  if ((status = TSRecordGetCounter(rec_name, ctr_val))) {
+    Cli_Debug(ERR_RECORD_GET_COUNTER, rec_name);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+// Get a float type records.config variable
+TSError
+Cli_RecordGetFloat(const char *rec_name, TSFloat * float_val)
+{
+  TSError status;
+  if ((status = TSRecordGetFloat(rec_name, float_val))) {
+    Cli_Debug(ERR_RECORD_GET_FLOAT, rec_name);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+// Get a string type records.config variable
+TSError
+Cli_RecordGetString(const char *rec_name, char **string_val)
+{
+  TSError status;
+  if ((status = TSRecordGetString(rec_name, string_val))) {
+    Cli_Debug(ERR_RECORD_GET_STRING, rec_name);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+// Use a string to set a records.config variable
+TSError
+Cli_RecordSet(const char *rec_name, const char *rec_value, TSActionNeedT * action_need)
+{
+  TSError status;
+  if ((status = TSRecordSet((char *) rec_name, (TSString) rec_value, action_need))) {
+    Cli_Debug(ERR_RECORD_SET, rec_name, rec_value);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+// Set an integer type records.config variable
+TSError
+Cli_RecordSetInt(const char *rec_name, TSInt int_val, TSActionNeedT * action_need)
+{
+  TSError status;
+  if ((status = TSRecordSetInt(rec_name, int_val, action_need))) {
+    Cli_Debug(ERR_RECORD_SET_INT, rec_name, int_val);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+// Set a float type records.config variable
+TSError
+Cli_RecordSetFloat(const char *rec_name, TSFloat float_val, TSActionNeedT * action_need)
+{
+  TSError status;
+  if ((status = TSRecordSetFloat(rec_name, float_val, action_need))) {
+    Cli_Debug(ERR_RECORD_SET_FLOAT, rec_name, float_val);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+
+// Set a string type records.config variable
+TSError
+Cli_RecordSetString(const char *rec_name, TSString str_val, TSActionNeedT * action_need)
+{
+  TSError status;
+  if ((status = TSRecordSetString(rec_name, str_val, action_need))) {
+    Cli_Debug(ERR_RECORD_SET_STRING, rec_name, str_val);
+    Cli_DisplayMgmtAPI_Error(status);
+  }
+  return status;
+}
+
+void
+Cli_DisplayMgmtAPI_Error(TSError status)
+{
+  switch (status) {
+  case TS_ERR_OKAY:           // do nothing
+    break;
+  case TS_ERR_READ_FILE:
+    Cli_Printf("\nERROR: Unable to read config file.\n\n");
+    break;
+  case TS_ERR_WRITE_FILE:
+    Cli_Printf("\nERROR: Unable to write config file.\n\n");
+    break;
+  case TS_ERR_PARSE_CONFIG_RULE:
+    Cli_Printf("\nERROR: Unable to parse config file.\n\n");
+    break;
+  case TS_ERR_INVALID_CONFIG_RULE:
+    Cli_Printf("\nERROR: Invalid Configuration Rule in config file.\n\n");
+    break;
+  case TS_ERR_NET_ESTABLISH:
+    Cli_Printf("\nERROR: Unable to establish connection to traffic_manager.\n"
+               "       Ability to make configuration changes depends on traffic_manager.\n");
+    break;
+  case TS_ERR_NET_READ:
+    Cli_Printf("\nERROR: Unable to read data from traffic_manager.\n"
+               "       Ability to monitor the system changes depends on traffic_manager.\n");
+    break;
+  case TS_ERR_NET_WRITE:
+    Cli_Printf("\nERROR: Unable to write configuration data to traffic_manager.\n"
+               "       Ability to make configuration changes depends on traffic_manager.\n");
+    break;
+  case TS_ERR_NET_EOF:
+    Cli_Printf("\nERROR: Unexpected EOF while communicating with traffic_manager.\n"
+               "       Ability to make configuration changes depends on traffic_manager.\n");
+    break;
+  case TS_ERR_NET_TIMEOUT:
+    Cli_Printf("\nERROR: Timed-out while communicating with traffic_manager.\n"
+               "       Ability to make configuration changes depends on traffic_manager.\n");
+    break;
+  case TS_ERR_SYS_CALL:
+    Cli_Printf("\nERROR: Internal System Call failed.\n\n");
+    break;
+  case TS_ERR_PARAMS:
+    Cli_Printf("\nERROR: Invalid parameters passed to a function.\n\n");
+    break;
+  case TS_ERR_FAIL:
+    Cli_Printf("\nERROR: Invalid parameter specified.\n" "       Check parameters for correct syntax and type.\n\n");
+    break;
+  default:
+    Cli_Printf("\nERROR: Undocumented Error. Status = %d.\n\n", status);
+    break;
+  }
+}
+
+// Retrieve and display contents of a rules file
+TSError
+Cli_DisplayRules(TSFileNameT fname)
+{
+  TSError status;
+  char *text;
+  int size = 0, version = 0;
+
+  if ((status = TSConfigFileRead(fname, &text, &size, &version))) {
+    Cli_Debug(ERR_CONFIG_FILE_READ, fname);
+    Cli_DisplayMgmtAPI_Error(status);
+  } else {
+    if (size) {
+      // Fix TSqa12220: use printf directly since Cli_Printf may
+      // not allocate enough buffer space to display the file contents
+      puts(text);
+      ats_free(text);
+    } else {
+      Cli_Printf("no rules\n");
+    }
+  }
+
+  return status;
+}
+
+// Retrieve and use config file from remote URL
+TSError
+Cli_SetConfigFileFromUrl(TSFileNameT file, const char *url)
+{
+  char *buf;
+  int size = 0;
+  int version = -1;
+  TSError status;
+
+  Cli_Debug("Cli_SetConfigFileFromUrl: file %d url %s\n", file, url);
+
+  // read config file from Url
+  if ((status = TSReadFromUrl((char *) url, NULL, NULL, &buf, &size))) {
+    Cli_Debug(ERR_READ_FROM_URL, url);
+    Cli_DisplayMgmtAPI_Error(status);
+    return status;
+  }
+
+  Cli_Debug("Cli_SetConfigFileFromUrl: size %d version %d\n", size, version);
+
+  Cli_Debug("Cli_SetConfigFileFromUrl: buf\n%s\n", buf);
+
+  // write config file
+  if ((status = TSConfigFileWrite(file, buf, size, version))) {
+    Cli_Debug(ERR_CONFIG_FILE_WRITE, file);
+    Cli_DisplayMgmtAPI_Error(status);
+    if (size)
+      ats_free(buf);
+    return status;
+  }
+
+  if (size)
+    ats_free(buf);
+
+  Cli_Printf("Successfully updated config file.\n");
+
+  return status;
+}
+
+// enable recent configuration changes by performing the action specified
+// by the action_need value
+TSError
+Cli_ConfigEnactChanges(TSActionNeedT action_need)
+{
+  TSError status;
+
+  Cli_Debug("Cli_ConfigEnactChanges: action_need %d\n", action_need);
+
+  switch (action_need) {
+  case TS_ACTION_SHUTDOWN:
+    Cli_Debug("Cli_ConfigEnactChanges: TS_ACTION_SHUTDOWN\n");
+    Cli_Printf("\nHard Restart required.\n"
+               "  Change will take effect after next Hard Restart.\n"
+               "  Use the \"config:hard-restart\" command to restart now.\n\n");
+    break;
+
+  case TS_ACTION_RESTART:
+    Cli_Debug("Cli_ConfigEnactChanges: TS_ACTION_RESTART\n");
+    Cli_Printf("\nRestart required.\n"
+               "  Change will take effect after next Restart.\n"
+               "  Use the \"config:restart\" command to restart now.\n\n");
+    break;
+
+  case TS_ACTION_DYNAMIC:
+    Cli_Debug("Cli_ConfigEnactChanges: TS_ACTION_DYNAMIC\n");
+    // no additional action required
+    break;
+
+  case TS_ACTION_RECONFIGURE:
+    Cli_Debug("Cli_ConfigEnactChanges: TS_ACTION_RECONFIGURE\n");
+    status = TSActionDo(TS_ACTION_RECONFIGURE);
+    if (status) {
+      Cli_Error("\nERROR %d: Failed to reread configuration files.\n\n", status);
+      return TS_ERR_FAIL;
+    }
+    break;
+
+  default:
+    Cli_Debug("  Status Message #%d\n", action_need);
+    Cli_Error("\nYou may need to use the \"config:hard-restart\" command\n" "to enable this configuration change.\n\n");
+    return TS_ERR_OKAY;
+  }
+
+  return TS_ERR_OKAY;
+}
+
+// evaluate "stringval" and return 1 if "on", otherwise 0
+int
+Cli_EvalOnOffString(char *stringval)
+{
+  if (strcmp(stringval, "on") == 0) {
+    return 1;
+  }
+  if (strcmp(stringval, "off") == 0) {
+    return 0;
+  }
+
+  return -1;
+}
+
+////////////////////////////////////////////////////////////////
+// Cli_RecordOnOff_Action
+//
+// used for records.config INT variables when 1 = on, 0 = off
+//
+// action = RECORD_GET retrieve and display the variable
+//          RECORD_SET set the variable
+//
+// record = variable in records.config
+//
+// on_off = "on" mean 1, "off" mean 0
+//
+int
+Cli_RecordOnOff_Action(int action, const char *record, const char *on_off)
+{
+  TSActionNeedT action_need;
+  TSError status;
+  TSInt int_val;
+
+  switch (action) {
+  case RECORD_SET:
+    if (on_off) {
+      if (!strcasecmp(on_off, "on")) {
+        int_val = 1;
+      } else if (!strcasecmp(on_off, "off")) {
+        int_val = 0;
+      } else {
+        Cli_Error("Expected \"on\" or \"off\" but got %s\n", on_off);
+        return CLI_ERROR;
+      }
+    } else {
+      Cli_Error("Expected <on | off> but got nothing.\n");
+      return CLI_ERROR;
+    }
+    status = Cli_RecordSetInt(record, int_val, &action_need);
+    if (status != TS_ERR_OKAY) {
+      return status;
+    }
+    return (Cli_ConfigEnactChanges(action_need));
+
+  case RECORD_GET:
+    int_val = -1;
+    status = Cli_RecordGetInt(record, &int_val);
+    Cli_PrintEnable("", int_val);
+    return CLI_OK;
+  }
+  return CLI_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cli_RecordInt_Action
+//
+// used for records.config INT variables
+//
+// action = RECORD_GET retrieve and display the variable
+//          RECORD_SET set the variable
+//
+// record = variable in records.config
+//
+// value = the integer value used by RECORD_SET
+//
+int
+Cli_RecordInt_Action(int action, const char *record, int value)
+{
+  switch (action) {
+  case RECORD_SET:
+    {
+      TSActionNeedT action_need = TS_ACTION_UNDEFINED;
+      TSError status = Cli_RecordSetInt(record, value, &action_need);
+
+      if (status) {
+        return status;
+      }
+      return (Cli_ConfigEnactChanges(action_need));
+    }
+  case RECORD_GET:
+    {
+      TSInt value_in = -1;
+      TSError status = Cli_RecordGetInt(record, &value_in);
+
+      if (status) {
+        return status;
+      }
+      Cli_Printf("%d\n", value_in);
+      return CLI_OK;
+    }
+  }
+  return CLI_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cli_RecordHostname_Action
+//
+// used for records.config STRING variables
+// performs checking to see if string is a valid fully qualified hostname
+//
+// action = RECORD_GET retrieve and display the variable
+//          RECORD_SET set the variable
+//
+// record = variable in records.config
+//
+// hostname = string to set
+//
+int
+Cli_RecordHostname_Action(int action, char *record, char *hostname)
+{
+  TSError status;
+  TSActionNeedT action_need = TS_ACTION_UNDEFINED;
+  TSString str_val = NULL;
+
+  switch (action) {
+  case RECORD_SET:
+    if (IsValidFQHostname(hostname) == CLI_OK) {
+      status = Cli_RecordSetString(record, (TSString) hostname, &action_need);
+
+      if (status) {
+        return status;
+      }
+      return (Cli_ConfigEnactChanges(action_need));
+    }
+    Cli_Error("ERROR: %s is an invalid name.\n", hostname);
+    return CLI_ERROR;
+
+  case RECORD_GET:
+    status = Cli_RecordGetString(record, &str_val);
+    if (status) {
+      return status;
+    }
+    if (str_val)
+      Cli_Printf("%s\n", str_val);
+    else
+      Cli_Printf("none\n");
+    return CLI_OK;
+  }
+  return CLI_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cli_RecordString_Action
+//
+// used for records.config STRING variables
+//
+// action = RECORD_GET retrieve and display the variable
+//          RECORD_SET set the variable
+//
+// record = variable in records.config
+//
+// string_val = string to set
+//
+int
+Cli_RecordString_Action(int action, const char *record, char *string_val)
+{
+  TSError status;
+  TSActionNeedT action_need = TS_ACTION_UNDEFINED;
+  TSString str_val = NULL;
+
+  switch (action) {
+  case RECORD_SET:
+    status = Cli_RecordSetString(record, (TSString) string_val, &action_need);
+
+    if (status) {
+      return status;
+    }
+    return (Cli_ConfigEnactChanges(action_need));
+
+  case RECORD_GET:
+    status = Cli_RecordGetString(record, &str_val);
+    if (status) {
+      return status;
+    }
+    if (str_val)
+      Cli_Printf("%s\n", str_val);
+    else
+      Cli_Printf("none\n");
+    return CLI_OK;
+  }
+  return CLI_ERROR;
+}
+
+////////////////////////////////////////////////////////////////
+// Cli_ConfigFileURL_Action
+//
+// used for config files other than records.config
+//
+// file = integer which specifies config file
+//
+// filename = config file name to display
+//
+// url = if non-NULL, update the file using contents of URL
+//
+int
+Cli_ConfigFileURL_Action(TSFileNameT file, const char *filename, const char *url)
+{
+  TSError status;
+  // Retrieve  file from url
+
+  if (url == NULL) {
+    Cli_Printf("%s File Rules\n", filename);
+    Cli_Printf("----------------------------\n");
+    status = Cli_DisplayRules(file);
+    return status;
+  }
+  Cli_Printf("Retrieve and Install %s file from url %s\n", filename, url);
+
+  status = Cli_SetConfigFileFromUrl(file, url);
+
+  return (status);
+}
+
+int
+cliCheckIfEnabled(const char *command)
+{
+  if (enable_restricted_commands == false) {
+    Cli_Error("\n%s is a restricted command only accessible from enable mode\n\n", command);
+    return CLI_ERROR;
+  }
+  return CLI_OK;
+}
+
+int
+GetTSDirectory(char *ts_path, size_t ts_path_len)
+{
+
+  ink_strlcpy(ts_path, Layout::get()->bindir, ts_path_len);
+  if (access(ts_path, R_OK) == -1) {
+    Cli_Error("unable to access() '%s': %d, %s\n",
+              ts_path, errno, strerror(errno));
+    Cli_Error(" Please set correct path in env variable TS_ROOT \n");
+    return -1;
+  }
+
+  return 0;
+}
+
+int
+StopTrafficServer()
+{
+  char ts_path[PATH_NAME_MAX + 1];
+  char stop_ts[1024];
+
+  if (GetTSDirectory(ts_path,sizeof(ts_path))) {
+    return CLI_ERROR;
+  }
+  snprintf(stop_ts, sizeof(stop_ts), "%s/stop_traffic_server", ts_path);
+  if (system(stop_ts) == -1)
+    return CLI_ERROR;
+
+  return 0;
+}
+
+int
+StartTrafficServer()
+{
+  char ts_path[PATH_NAME_MAX + 1];
+  char start_ts[1024];
+
+  if (GetTSDirectory(ts_path,sizeof(ts_path))) {
+    return CLI_ERROR;
+  }
+  // root user should start_traffic_shell as inktomi user
+  if (getuid() == 0) {
+    snprintf(start_ts, sizeof(start_ts), "/bin/su - inktomi -c \"%s/start_traffic_server\"", ts_path);
+  } else {
+    snprintf(start_ts, sizeof(start_ts), "%s/start_traffic_server", ts_path);
+  }
+  if (system(start_ts) == -1)
+    return CLI_ERROR;
+
+  return 0;
+}
+
+int
+Cli_CheckPluginStatus(TSString plugin)
+{
+
+  int match = 0;
+  TSCfgContext ctx;
+  TSCfgIterState ctx_state;
+  TSPluginEle *ele;
+
+  ctx = TSCfgContextCreate(TS_FNAME_PLUGIN);
+  if (TSCfgContextGet(ctx) != TS_ERR_OKAY) {
+    printf("ERROR READING FILE\n");
+  }
+  ele = (TSPluginEle *) TSCfgContextGetFirst(ctx, &ctx_state);
+
+  while (ele) {
+    if (!strcasecmp(plugin, ele->name)) {
+      match = 1;
+      break;
+    }
+    ele = (TSPluginEle *) TSCfgContextGetNext(ctx, &ctx_state);
+  }
+
+  if (match) {
+    return CLI_OK;
+  } else {
+    return CLI_ERROR;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/CliMgmtUtils.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/CliMgmtUtils.h b/cmd/traffic_shell/CliMgmtUtils.h
new file mode 100644
index 0000000..3798f70
--- /dev/null
+++ b/cmd/traffic_shell/CliMgmtUtils.h
@@ -0,0 +1,152 @@
+/** @file
+
+  This file declares various utility functions which call the TSMgmtAPI.
+
+  @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 "mgmtapi.h"
+
+#define RECORD_GET 0
+#define RECORD_SET 1
+
+// Get a records.config variable by name
+TSError Cli_RecordGet(const char *rec_name, TSRecordEle * rec_val);
+
+// Get an integer type records.config variable
+TSError Cli_RecordGetInt(const char *rec_name, TSInt * int_val);
+
+// Get an counter type records.config variable
+TSError Cli_RecordGetCounter(const char *rec_name, TSCounter * ctr_val);
+
+// Get a float type records.config variable
+TSError Cli_RecordGetFloat(const char *rec_name, TSFloat * float_val);
+
+// Get a string type records.config variable
+TSError Cli_RecordGetString(const char *rec_name, char **string_val);
+
+// Use a string to set a records.config variable
+TSError Cli_RecordSet(const char *rec_name, const char *rec_value, TSActionNeedT * action_need);
+
+// Set an integer type records.config variable
+TSError Cli_RecordSetInt(const char *rec_name, TSInt int_val, TSActionNeedT * action_need);
+
+//Set a float type records.config variable
+TSError Cli_RecordSetFloat(const char *rec_name, TSFloat float_val, TSActionNeedT * action_need);
+
+// Set a string type records.config variable
+TSError Cli_RecordSetString(const char *rec_name, TSString str_val, TSActionNeedT * action_need);
+
+// Retrieve and display contents of a rules file
+TSError Cli_DisplayRules(TSFileNameT fname);
+
+// Retrieve and use config file from remote URL
+TSError Cli_SetConfigFileFromUrl(TSFileNameT file, const char *url);
+
+// enable recent configuration changes by performing the action specified
+// by the action_need value
+TSError Cli_ConfigEnactChanges(TSActionNeedT action_need);
+
+// evaluate "stringval" and return 1 if "on", otherwise 0
+int Cli_EvalOnOffString(char *stringval);
+
+////////////////////////////////////////////////////////////////
+// Cli_Record functions are used by various config commands
+// to get/display and set variables in records.config
+//
+
+////////////////////////////////////////////////////////////////
+// Cli_RecordOnOff_Action
+//
+// used for records.config INT variables when 1 = on, 0 = off
+//
+// action = RECORD_GET retrieve and display the variable
+//          RECORD_SET set the variable
+//
+// record = variable in records.config
+//
+// on_off = "on" mean 1, "off" mean 0
+//
+int Cli_RecordOnOff_Action(int action, const char *record, const char *on_off);
+
+////////////////////////////////////////////////////////////////
+// Cli_RecordInt_Action
+//
+// used for records.config INT variables
+//
+// action = RECORD_GET retrieve and display the variable
+//          RECORD_SET set the variable
+//
+// record = variable in records.config
+//
+// value = the integer value used by RECORD_SET
+//
+int Cli_RecordInt_Action(int action, const char *record, int value);
+
+////////////////////////////////////////////////////////////////
+// Cli_RecordHostname_Action
+//
+// used for records.config STRING variables
+// performs checking to see if string is a valid fully qualified hostname
+//
+// action = RECORD_GET retrieve and display the variable
+//          RECORD_SET set the variable
+//
+// record = variable in records.config
+//
+// hostname = string to set
+//
+int Cli_RecordHostname_Action(int action, const char *record, char *hostname);
+
+////////////////////////////////////////////////////////////////
+// Cli_RecordString_Action
+//
+// used for records.config STRING variables
+//
+// action = RECORD_GET retrieve and display the variable
+//          RECORD_SET set the variable
+//
+// record = variable in records.config
+//
+// string_val = string to set
+//
+int Cli_RecordString_Action(int action, const char *record, char *string_val);
+
+////////////////////////////////////////////////////////////////
+// Cli_ConfigFileURL_Action
+//
+// used for config files other than records.config
+//
+// file = integer which specifies config file
+//
+// filename = config file name to display
+//
+// url = if non-NULL, update the file using contents of URL
+//
+int Cli_ConfigFileURL_Action(TSFileNameT file, const char *filename, const char *url);
+
+extern bool enable_restricted_commands;
+
+int cliCheckIfEnabled(const char *command);
+
+int GetTSDirectory(char *ts_path, size_t ts_path_len);
+
+int StopTrafficServer();
+int StartTrafficServer();
+int Cli_CheckPluginStatus(TSString plugin);


[32/44] git commit: Add a new field: '%', "client_host_port" to LogFormat

Posted by zw...@apache.org.
Add a new field: '%<chp>', "client_host_port" to LogFormat

Signed-off-by: Yunkai Zhang <qi...@taobao.com>


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

Branch: refs/heads/5.0.x
Commit: ed8f6e9b02170f311992dc5f00f9838b88ec7077
Parents: 938fa1e
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Wed Nov 20 17:45:08 2013 +0800
Committer: Yunkai Zhang <qi...@taobao.com>
Committed: Wed Nov 20 22:27:06 2013 +0800

----------------------------------------------------------------------
 proxy/ICPConfig.cc             |  6 ++++++
 proxy/ICPlog.h                 |  1 +
 proxy/logging/Log.cc           |  7 +++++++
 proxy/logging/LogAccess.cc     |  9 +++++++++
 proxy/logging/LogAccess.h      |  1 +
 proxy/logging/LogAccessHttp.cc | 13 +++++++++++++
 proxy/logging/LogAccessHttp.h  |  1 +
 proxy/logging/LogAccessICP.cc  | 13 +++++++++++++
 proxy/logging/LogAccessICP.h   |  3 ++-
 9 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/ICPConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/ICPConfig.cc b/proxy/ICPConfig.cc
index 01523f2..3e19557 100644
--- a/proxy/ICPConfig.cc
+++ b/proxy/ICPConfig.cc
@@ -1301,6 +1301,12 @@ ICPlog::GetClientIP()
   return &_s->_sender.sa;
 }
 
+in_port_t
+ICPlog::GetClientPort()
+{
+  return _s->_sender.port();
+}
+
 SquidLogCode ICPlog::GetAction()
 {
   if (_s->_queryResult == CACHE_EVENT_LOOKUP)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/ICPlog.h
----------------------------------------------------------------------
diff --git a/proxy/ICPlog.h b/proxy/ICPlog.h
index a5e01d9..f7f37e9 100644
--- a/proxy/ICPlog.h
+++ b/proxy/ICPlog.h
@@ -52,6 +52,7 @@ public:
   }
   ink_hrtime GetElapsedTime();
   sockaddr const* GetClientIP();
+  in_port_t GetClientPort();
   SquidLogCode GetAction();
   const char *GetCode();
   int GetSize();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/logging/Log.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 546f83f..6a64ce7 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -346,6 +346,13 @@ Log::init_fields()
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "chi", field);
 
+  field = NEW(new LogField("client_host_port", "chp",
+                           LogField::sINT,
+                           &LogAccess::marshal_client_host_port,
+                           &LogAccess::unmarshal_int_to_str));
+  global_field_list.add(field, false);
+  ink_hash_table_insert(field_symbol_hash, "chp", field);
+
   field = NEW(new LogField("client_host_ip_hex", "chih",
                            LogField::IP,
                            &LogAccess::marshal_client_host_ip,

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/logging/LogAccess.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index 4254569..60fc53c 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -84,6 +84,15 @@ LogAccess::marshal_client_host_ip(char *buf)
   -------------------------------------------------------------------------*/
 
 int
+LogAccess::marshal_client_host_port(char *buf)
+{
+  DEFAULT_INT_FIELD;
+}
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+int
 LogAccess::marshal_client_auth_user_name(char *buf)
 {
   DEFAULT_STR_FIELD;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/logging/LogAccess.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index eb10824..4438f7b 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -168,6 +168,7 @@ public:
   // client -> proxy fields
   //
   inkcoreapi virtual int marshal_client_host_ip(char *);        // STR
+  inkcoreapi virtual int marshal_client_host_port(char *);      // INT
   inkcoreapi virtual int marshal_client_auth_user_name(char *); // STR
   int marshal_client_req_timestamp_sec(char *); // INT
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/logging/LogAccessHttp.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index cc89abc..e527fd6 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -145,6 +145,19 @@ LogAccessHttp::marshal_client_host_ip(char *buf)
 }
 
 /*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+int
+LogAccessHttp::marshal_client_host_port(char *buf)
+{
+  if (buf) {
+    uint16_t port = ntohs(m_http_sm->t_state.client_info.addr.port());
+    marshal_int(buf, port);
+  }
+  return INK_MIN_ALIGN;
+}
+
+/*-------------------------------------------------------------------------
   user authenticated to the proxy (RFC931)
   -------------------------------------------------------------------------*/
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/logging/LogAccessHttp.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h
index 88192d0..4d6abeb 100644
--- a/proxy/logging/LogAccessHttp.h
+++ b/proxy/logging/LogAccessHttp.h
@@ -56,6 +56,7 @@ public:
   // client -> proxy fields
   //
   virtual int marshal_client_host_ip(char *);   // STR
+  virtual int marshal_client_host_port(char *); // INT
   virtual int marshal_client_auth_user_name(char *);    // STR
   virtual int marshal_client_req_text(char *);  // STR
   virtual int marshal_client_req_http_method(char *);   // INT

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/logging/LogAccessICP.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccessICP.cc b/proxy/logging/LogAccessICP.cc
index ebdd0df..5f9bb15 100644
--- a/proxy/logging/LogAccessICP.cc
+++ b/proxy/logging/LogAccessICP.cc
@@ -74,6 +74,19 @@ LogAccessICP::marshal_client_host_ip(char *buf)
   -------------------------------------------------------------------------*/
 
 int
+LogAccessICP::marshal_client_host_port(char *buf)
+{
+  if (buf) {
+    uint16_t port = ntohs(m_icp_log->GetClientPort());
+    marshal_int(buf, port);
+  }
+  return INK_MIN_ALIGN;
+}
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+int
 LogAccessICP::marshal_client_auth_user_name(char *buf)
 {
   char *str = (char *) m_icp_log->GetIdent();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed8f6e9b/proxy/logging/LogAccessICP.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogAccessICP.h b/proxy/logging/LogAccessICP.h
index 158d6bc..74eca8e 100644
--- a/proxy/logging/LogAccessICP.h
+++ b/proxy/logging/LogAccessICP.h
@@ -51,7 +51,8 @@ public:
   //
   // client -> proxy fields
   //
-  virtual int marshal_client_host_ip(char *);   // INT
+  virtual int marshal_client_host_ip(char *);   // STR
+  virtual int marshal_client_host_port(char *); // INT
   virtual int marshal_client_auth_user_name(char *);    // STR
   virtual int marshal_client_req_text(char *);  // STR
   virtual int marshal_client_req_http_method(char *);   // INT


[08/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/cli_feature_spec.txt
----------------------------------------------------------------------
diff --git a/mgmt/cli/cli_feature_spec.txt b/mgmt/cli/cli_feature_spec.txt
deleted file mode 100644
index f6e7c9d..0000000
--- a/mgmt/cli/cli_feature_spec.txt
+++ /dev/null
@@ -1,230 +0,0 @@
-traffic_shell  "a CLI for Traffic Server"
-
-==========
-Motivation
-==========
-
-The purpose of traffic_shell (command line interface, or CLI) is to
-improve the usability of Traffic Server in both OEM and direct sales
-environments. The CLI is a powerful, easy to use tool which can be
-used to configure and monitor individual Traffic Server machines.  Our
-goal is to make configuring Traffic Server as easy as configuring
-other network devices such as routers and switches. 
-
-The CLI accepts commands in a unix shell-like fashion.  Commands are
-organized in an easy to navigate hierarchy.  The CLI supports basic
-command completion, command history, and context sensitive help.  This
-format was designed to be familiar to network engineers everywhere,
-and also to be easier to document, maintain, and add features. 
-
-============
-Architecture
-============
-
-The CLI is a standalone executable which is part of a Traffic Server
-installation on the Linux platform. The CLI supports the following
-operation modes. Note that a "user" can be a person, a script, or some
-other mechanism for remote control of network devices via command line
-interface. 
-
-- Interactive mode:
-"traffic_shell"
-Similar to unix shell, the CLI can be the login shell for
-administrators.  The user types command at a prompt, and the CLI
-processes the command and displays the result.  While in interactive
-mode, the user can execute a file which contains a list of commands. 
-
--- Execute file mode:
-"traffic_shell -f filename" where file contains a list of CLI commands.
-CLI runs commands and sends results to stdout.
-
-The CLI interface is implemented in a combination of TCL and C++.
-From the traffic_shell prompt, users can access the scripting
-capabilities of TCL.   
-
-The shell and parsing functionality will utilize TCL. Commands
-themselves will be written in C++. The CLI uses the traffic_manager
-Management API to make Traffic Server configuration changes.
-
-The overall CLI architecture is as follows:
-
-- traffic_shell ---------------------------
-|                                         |
-| --------------------------------------- |
-| Shell and parser implemented in TCL/C++ |
-| --------------------------------------- |
-|                 ^                       |
-| ----------------|-------------------    |
-| CLI commands implemented in C++         |
-| ------------------------------------    |
-|         ^                               |
-| --------|----------                     |
-| Management API (.a)                     |
-| -------------------                     |
-|                                         |
--------------------------------------------
-
-=================
-Quick Start Guide
-=================
-
-There are two basic commands categories, "show" and "config".  Show
-commands are used to view configuration information and statistics.
-Config commands are used to configure Traffic Server.  To use the
-config commands, you must first enter "enable mode" by using the
-enable command, which asks for the admin password (same password as
-WebUI). 
-
-At any point you can access context sensitive help by specifying "-h"
-or "-help" after a command name.  The following is a list of commands
-and options:
-
--------------
-Show Commands
--------------
-
-show                         Show command
-show:status                  Proxy status
-show:version                 Version information
-show:security                Security information
-show:http                    HTTP protocol configuration
-show:icp [peer]              ICP protocol configuration
-show:proxy                   Proxy configuration
-show:cache [rules|storage]   Cache configuration
-show:virtual-ip              Virtual-ip configuration
-show:hostdb                  Host database configuration
-show:dns-resolver            DNS resolver configuration
-show:logging                 Logging configuration
-show:ssl                     SSL configuration
-show:parent                  Parent configuration
-show:remap                   Remap configuration
-show:socks                   SOCKS configuration
-show:port-tunnels            Port tunnels configuration
-show:scheduled-update        Scheduled update configuration
-show:proxy-stats             Proxy statistics
-show:http-trans-stats        HTTP transaction statistics
-show:http-stats              HTTP statistics
-show:icp-stats               ICP statistics
-show:cache-stats             Cache statistics
-show:hostdb-stats            Host database statistics
-show:dns-stats               DNS statistics
-show:logging-stats           Logging statistics
-show:alarms                  Show active alarms
-
----------------
-Config commands
----------------
-
-config:get <variable>          Display a variable value
-config:set <variable> <value>  Set variable to specified value
-config:name <string>           Set proxy name <string>
-config:start                   Start proxy software
-config:stop                    Stop proxy software
-
-config:ssl <on | off>
-config:ssl ports <int>      
-
-config:parent <on | off>    
-config:parent name <parent>
-config:parent rules <url>    
-
-config:remap <url>              Update remap configuration file <url>
-    
-config:clock date <mm/dd/yyyy>          
-config:clock time <hh:mm:ss>
-config:clock timezone <number from list>       
-    
-config:security <ip-allow | mgmt-allow | admin> <url-config-file>
-config:security password                 
-
-config:http <on | off>
-config:http <keep-alive-timeout-in | keep-alive-timeout-out> <seconds>
-config:http <inactive-timeout-in | inactive-timeout-out> <seconds>
-config:http <active-timeout-in | active-timeout-out> <seconds>
-config:http <remove-from | remove-referer> <on | off>
-config:http <remove-user | remove-cookie> <on | off>
-config:http <remove-header> <string>
-config:http <insert-ip | remove-ip> <on | off>
-config:http proxy <fwd | rev | fwd-rev>      
-
-config:icp mode <disabled | receive | send-receive>
-config:icp port <int>
-config:icp multicast <on | off>
-config:icp query-timeout <seconds>
-config:icp peers <url-config-file>           
- 
-config:port-tunnels server-other-ports <port>
-
-config:scheduled-update mode <on | off>
-config:scheduled-update retry count <int> interval <int>
-config:scheduled-update max-concurrent <int>
-config:scheduled-update force-immediate <on | off>
-config:scheduled-update rules <url-config-file>  
-    
-config:socks <on | off>
-config:socks server-ip <x.x.x.x>
-config:socks port <int>
-config:socks timeout <seconds>      
-    
-    
-config:cache <on | off>
-config:cache <http> <on | off>
-config:cache ignore-bypass <on | off>
-config:cache <max-object-size | max-alternates> <int>
-config:cache file <url-config-file>
-config:cache freshness verify <when-expired | no-date | always | never>
-config:cache freshness minimum <explicit | last-modified | nothing>
-config:cache freshness no-expire-limit greater-than <sec> less-than <sec>
-config:cache <dynamic | alternates> <on | off>
-config:cache vary <text | images | other> <string>
-config:cache vary cookies <none | all | non-text>        
-    
-    
-config:hostdb <lookup-timeout | foreground-timeout> <seconds>
-config:hostdb <background-timeout | invalid-host-timeout> <seconds>
-config:hostdb <re-dns-on-reload> <on | off>,
-Configure Host Database
-    
-config:logging event <enabled | trans-only | error-only | disabled>
-config:logging mgmt-directory <string>
-config:logging <space-limit | space-headroom> <megabytes>
-config:logging collation-status <inactive | host | send-standard |
-                                 send-custom | send-all>
-config:logging collation-host <string>
-config:logging collation secret <string> tagged <on | off> orphan-limit <int>
-config:logging format <squid | netscape-common | netscape-ext | netscape-ext2>
-               type <ascii | binary> file <string> header <string>
-config:logging splitting <icp | http> <on | off>
-config:logging custom <on | off> format <traditional | xml>
-config:logging rolling <on | off> offset <hour> interval <hours>
-               auto-delete <on | off>,
-	
-config:dns resolve-timeout <seconds>
-config:dns retries <int>,
-
-config:virtual-ip <on | off>
-config:virtual-ip add <x.x.x.x> device <string> sub-intf <int>
-config:virtual-ip delete <virtual ip number>,
-
-config:network ip-address <x.x.x.x>      (Linux only)
-config:network hostname <string>         (Linux only)
-config:network netmask <x.x.x.x>         (Linux only)
-config:network domainname <string>       (Linux only)
-config:network dns-ip <x.x.x.x>          (Linux only)
-config:network defaultrouter <x.x.x.x>   (Linux only)
-
-config:alarms resolve-name <string>
-config:alarms resolve-number <int>
-config:alarms resolve-all
-config:alarms notify <on | off>,
-
-----------------
-Utility commands
-----------------
-    
-enable              Enable Restricted Commands
-
-disable             Disable Restricted Commands
- 
-debug <on|off>      Turn debugging print statements on/off
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/commandOptions.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/commandOptions.h b/mgmt/cli/commandOptions.h
deleted file mode 100644
index 1f8f9c6..0000000
--- a/mgmt/cli/commandOptions.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/* commandOptions.h
- * these are valid options for createArgument
- *
- *
- */
-
-#ifndef COMMAND_OPTIONS
-#define COMMAND_OPTIONS
-
-
-#define CLI_ARGV_CONSTANT_OPTIONAL                    0x401
-#define CLI_ARGV_INT_OPTIONAL                         0x402
-#define CLI_ARGV_STRING_OPTIONAL                      0x404
-#define CLI_ARGV_FLOAT_OPTIONAL                       0x408
-#define CLI_ARGV_FUNC_OPTIONAL                        0x410
-#define CLI_ARGV_HELP_OPTIONAL                        0x420
-#define CLI_ARGV_CONST_OPTION_OPTIONAL                0x440
-#define CLI_ARGV_CONSTANT_REQUIRED                    0x801
-#define CLI_ARGV_INT_REQUIRED                         0x802
-#define CLI_ARGV_STRING_REQUIRED                      0x804
-#define CLI_ARGV_FLOAT_REQUIRED                       0x808
-
-
-#endif /*COMMAND_OPTIONS */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/createArgument.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/createArgument.cc b/mgmt/cli/createArgument.cc
deleted file mode 100644
index e2f4e1b..0000000
--- a/mgmt/cli/createArgument.cc
+++ /dev/null
@@ -1,387 +0,0 @@
-/** @file
-
-  This file provides basic create Argument defintion, for any new arguments.
-
-  @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 <stdlib.h>
-#include <tcl.h>
-#include <string.h>
-
-#include "createArgument.h"
-#include "definitions.h"
-#include "commandOptions.h"
-#include "hashtable.h"
-#include "ink_string.h"
-
-#define totalArguments 30       /* This is arbitary value */
-#define NEG_BOUND -10
-#define POS_BOUND 10
-
-static cli_ArgvInfo *ArgvTable;
-static cli_ArgvInfo *org_ArgvTable;
-extern Tcl_Interp *interp;
-
-cli_ArgvInfo *cliGetArgvInfo();
-cli_ArgvInfo *cliGetOrgArgvInfo();
-int getCommandOption(int commandoption, int *arg_type, int *arg_option);
-char **findRequired(cli_ArgvInfo * argtable);
-extern void setReqdArgs(char **required_args);
-
-int
-createArgument(const char *argument, int position, int commandoption,
-               char *range, int argumentRef, const char *helpString, char *defValue)
-{
-  int arg_type = 0;
-  int arg_option = 0;
-  char **reqd_args;
-  cli_ArgvInfo *aCliArgvTable = cliGetArgvInfo();
-
-  size_t key_len = sizeof(char) * (strlen(argument) + 1);
-  aCliArgvTable->key = (char *) ckalloc(key_len);
-  ink_strlcpy(aCliArgvTable->key, argument, key_len);
-
-  aCliArgvTable->position = position;
-
-  getCommandOption(commandoption, &arg_type, &arg_option);
-  aCliArgvTable->type = arg_type;
-  if (arg_option != 0) {
-    aCliArgvTable->option = arg_option;
-  }
-
-
-  aCliArgvTable->arg_ref = argumentRef;
-
-  if (range != NULL) {
-    aCliArgvTable->range_set = true;
-    if (aCliArgvTable->type == CLI_ARGV_INT || aCliArgvTable->type == CLI_ARGV_OPTION_INT_VALUE) {
-      getIntRange(range, &(aCliArgvTable->l_range.int_r1), &(aCliArgvTable->u_range.int_r2));
-    }
-    if (aCliArgvTable->type == CLI_ARGV_FLOAT || aCliArgvTable->type == CLI_ARGV_OPTION_FLOAT_VALUE) {
-      getFloatRange(range, &(aCliArgvTable->l_range.float_r1), &(aCliArgvTable->u_range.float_r2));
-    }
-
-  }
-
-  if (defValue != NULL) {
-    size_t def_len = sizeof(char) * (strlen(defValue) + 1);
-    aCliArgvTable->def = (char *) ckalloc(def_len);
-    ink_strlcpy(aCliArgvTable->def, defValue, def_len);
-  }
-
-
-  if (helpString != NULL) {
-    size_t help_len = sizeof(char) * (strlen(helpString) + 1);
-    aCliArgvTable->help = (char *) ckalloc(help_len);
-    ink_strlcpy(aCliArgvTable->help, helpString, help_len);
-  }
-
-  reqd_args = findRequired(cliGetOrgArgvInfo());
-  setReqdArgs(reqd_args);
-  return TCL_OK;
-}
-
-
-cli_ArgvInfo *
-cliGetArgvInfo()
-{
-  cli_ArgvInfo *temp_ArgvTable = ArgvTable;
-  ArgvTable++;
-  return temp_ArgvTable;
-}
-
-int
-cliSetArgvInfo(cli_ArgvInfo * argtable)
-{
-  ArgvTable = argtable;
-  org_ArgvTable = argtable;
-  return TCL_OK;
-}
-
-cli_ArgvInfo *
-cliGetOrgArgvInfo()
-{
-  return org_ArgvTable;
-}
-
-
-char **
-findRequired(cli_ArgvInfo * argtable)
-{
-  char **args;
-  cli_ArgvInfo *infoPtr;
-  int count_required = 0, i = 0;
-  for (infoPtr = argtable; (infoPtr->key != NULL); infoPtr++) {
-    if (infoPtr->option == CLI_ARGV_REQUIRED) {
-      count_required++;
-    }
-  }
-  if (count_required == 0)
-    return (char **) NULL;
-
-  args = (char **) ckalloc(sizeof(char *) * (count_required + 1));
-  for (infoPtr = argtable; (infoPtr->key != NULL); infoPtr++) {
-    if (infoPtr->option == CLI_ARGV_REQUIRED) {
-
-      args[i] = ats_strdup(infoPtr->key);
-      i++;
-    }
-  }
-  args[i] = NULL;
-  return args;
-}
-
-
-int
-getCommandOption(int commandoption, int *arg_type, int *arg_option)
-{
-  switch (commandoption) {
-  case CLI_ARGV_CONSTANT:
-    *arg_type = CLI_ARGV_CONSTANT;
-    *arg_option = 0;
-    break;
-  case CLI_ARGV_CONST_OPTION:
-    *arg_type = CLI_ARGV_CONST_OPTION;
-    *arg_option = 0;
-    break;
-  case CLI_ARGV_INT:
-    *arg_type = CLI_ARGV_INT;
-    *arg_option = 0;
-    break;
-  case CLI_ARGV_STRING:
-    *arg_type = CLI_ARGV_STRING;
-    *arg_option = 0;
-    break;
-  case CLI_ARGV_FLOAT:
-    *arg_type = CLI_ARGV_FLOAT;
-    *arg_option = 0;
-    break;
-  case CLI_ARGV_OPTION_NAME_VALUE:
-    *arg_type = CLI_ARGV_OPTION_NAME_VALUE;
-    *arg_option = 0;
-    break;
-  case CLI_ARGV_OPTION_FLOAT_VALUE:
-    *arg_type = CLI_ARGV_OPTION_FLOAT_VALUE;
-    *arg_option = 0;
-    break;
-  case CLI_ARGV_OPTION_INT_VALUE:
-    *arg_type = CLI_ARGV_OPTION_INT_VALUE;
-    *arg_option = 0;
-    break;
-  case CLI_ARGV_CONSTANT_OPTIONAL:
-    *arg_type = CLI_ARGV_CONSTANT;
-    *arg_option = CLI_ARGV_OPTIONAL;
-    break;
-  case CLI_ARGV_INT_OPTIONAL:
-    *arg_type = CLI_ARGV_INT;
-    *arg_option = CLI_ARGV_OPTIONAL;
-    break;
-  case CLI_ARGV_STRING_OPTIONAL:
-    *arg_type = CLI_ARGV_STRING;
-    *arg_option = CLI_ARGV_OPTIONAL;
-    break;
-  case CLI_ARGV_FLOAT_OPTIONAL:
-    *arg_type = CLI_ARGV_FLOAT;
-    *arg_option = CLI_ARGV_OPTIONAL;
-    break;
-  case CLI_ARGV_FUNC_OPTIONAL:
-    *arg_type = CLI_ARGV_FUNC;
-    *arg_option = CLI_ARGV_OPTIONAL;
-    break;
-  case CLI_ARGV_HELP_OPTIONAL:
-    *arg_type = CLI_ARGV_HELP;
-    *arg_option = CLI_ARGV_OPTIONAL;
-    break;
-  case CLI_ARGV_CONST_OPTION_OPTIONAL:
-    *arg_type = CLI_ARGV_CONST_OPTION;
-    *arg_option = CLI_ARGV_OPTIONAL;
-    break;
-  case CLI_ARGV_CONSTANT_REQUIRED:
-    *arg_type = CLI_ARGV_CONSTANT;
-    *arg_option = CLI_ARGV_REQUIRED;
-    break;
-  case CLI_ARGV_INT_REQUIRED:
-    *arg_type = CLI_ARGV_INT;
-    *arg_option = CLI_ARGV_REQUIRED;
-    break;
-  case CLI_ARGV_STRING_REQUIRED:
-    *arg_type = CLI_ARGV_STRING;
-    *arg_option = CLI_ARGV_REQUIRED;
-    break;
-  case CLI_ARGV_FLOAT_REQUIRED:
-    *arg_type = CLI_ARGV_FLOAT;
-    *arg_option = CLI_ARGV_REQUIRED;
-    break;
-  default:
-    *arg_type = 0;
-    *arg_option = 0;
-    break;
-  }
-  return TCL_OK;
-}
-
-int
-getIntRange(char *range, int *r1, int *r2)
-{
-  char *range_str;
-  char *str;
-  int bound, i = 0, len;
-  char *buf;
-  char *endPtr;
-
-  buf = (char *) ckalloc(sizeof(char) * 256);
-  range_str = ats_strdup(range);
-  len = strlen(range_str);
-  range_str[len] = 0;
-  str = range_str;
-  while (*str != 0) {
-    if (*str == '-') {
-      bound = NEG_BOUND;
-      str++;
-    }
-
-    else if (*str == '+') {
-      bound = POS_BOUND;
-      str++;
-    } else {
-      Tcl_AppendResult(interp, "range not specified correctly", (char *) NULL);
-      ckfree(buf);
-      ckfree(range_str);
-      return TCL_ERROR;
-    }
-    if (*str == 'r') {
-      str++;
-      i = 0;
-      for (; (*str != '+'); str++) {
-        if (*str == 0)
-          break;
-        buf[i] = *str;
-        i++;
-      }
-      buf[i] = 0;
-      if (bound == NEG_BOUND) {
-        *r1 = strtol(buf, &endPtr, 0);
-        if ((endPtr == buf) || (*endPtr != 0)) {
-          Tcl_AppendResult(interp, "negative range is not correct\n", (char *) NULL);
-          ckfree(buf);
-          ckfree(range_str);
-          return TCL_ERROR;
-
-        }
-      } else if (bound == POS_BOUND) {
-        *r2 = strtol(buf, &endPtr, 0);
-        if ((endPtr == buf) || (*endPtr != 0)) {
-          Tcl_AppendResult(interp, "positive range is not correct\n", (char *) NULL);
-          ckfree(buf);
-          ckfree(range_str);
-          return TCL_ERROR;
-
-        }
-      }
-
-    } else {
-      Tcl_AppendResult(interp, "range not specified correctly\n");
-      ckfree(buf);
-      ckfree(range_str);
-      return TCL_ERROR;
-    }
-
-
-  }
-  ckfree(buf);
-  ckfree(range_str);
-  return TCL_OK;
-}
-
-
-int
-getFloatRange(char *range, float *r1, float *r2)
-{
-  char *range_str;
-  char *str;
-  int bound, i = 0, len;
-  char *buf;
-  char *endPtr;
-
-  buf = (char *) ckalloc(sizeof(char) * 256);
-  range_str = ats_strdup(range);
-  len = strlen(range_str);
-  range_str[len] = 0;
-  str = range_str;
-  while (*str != 0) {
-    if (*str == '-') {
-      bound = NEG_BOUND;
-      str++;
-    }
-
-    else if (*str == '+') {
-      bound = POS_BOUND;
-      str++;
-    } else {
-      Tcl_AppendResult(interp, "range not specified correctly", (char *) NULL);
-      ckfree(buf);
-      ckfree(range_str);
-      return TCL_ERROR;
-    }
-    if (*str == 'r') {
-      str++;
-      i = 0;
-      for (; (*str != '+'); str++) {
-        if (*str == 0)
-          break;
-        buf[i] = *str;
-        i++;
-      }
-      buf[i] = 0;
-      if (bound == NEG_BOUND) {
-        // Solaris is messed up, in that strtod() does not honor C99/SUSv3 mode.
-        *r1 = strtold(buf, &endPtr);
-        if ((endPtr == buf) || (*endPtr != 0)) {
-          Tcl_AppendResult(interp, "negative range is not correct", (char *) NULL);
-          ckfree(buf);
-          ckfree(range_str);
-          return TCL_ERROR;
-
-        }
-      } else if (bound == POS_BOUND) {
-        *r2 = strtold(buf, &endPtr);
-        if ((endPtr == buf) || (*endPtr != 0)) {
-          Tcl_AppendResult(interp, "positive range is not correct", (char *) NULL);
-          ckfree(buf);
-          ckfree(range_str);
-          return TCL_ERROR;
-
-        }
-      }
-
-    } else {
-      Tcl_AppendResult(interp, "range not specified correctly");
-      ckfree(buf);
-      ckfree(range_str);
-      return TCL_ERROR;
-    }
-
-
-  }
-  ckfree(buf);
-  ckfree(range_str);
-  return TCL_OK;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/createArgument.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/createArgument.h b/mgmt/cli/createArgument.h
deleted file mode 100644
index 4681c3a..0000000
--- a/mgmt/cli/createArgument.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/*
- *   createArgument.h --
- *
- *
- *    This file provides basic create Argument declartion,
- *    for any new arguments.
- *
- *
- *
- *
- *    Dated  : 12/11/2000.
- */
-
-#ifndef CREATE_ARGUMENT
-#define CREATE_ARGUMENT
-
-#include <commandOptions.h>
-
-typedef union arg_value
-{                               /* Value of the argument can be
-                                   integr or float or string */
-  char *arg_string;
-  int arg_int;
-  float arg_float;
-} arg_value;
-
-typedef union lower_range
-{
-  int int_r1;
-  float float_r1;
-} lower_range;
-
-typedef union upper_range
-{
-  int int_r2;
-  float float_r2;
-} upper_range;
-
-typedef struct cli_ArgvInfo
-{
-  char *key;                    /*  The key string that flags
-                                   the option  in the argv array */
-  int position;                 /* indicates position of the
-                                   argument in command */
-  int type;                     /* Indicates argument type;  */
-  int arg_ref;                  /* User creates an integer to
-                                   refer to this argument */
-  lower_range l_range;          /* lower_range */
-  upper_range u_range;          /* upper_range */
-  bool range_set;                /* flag which indicates if range is set by user */
-  int option;                   /* flag which indicates if argument is optional or required */
-  char *help;                   /* Documentation message describing this  option. */
-  char *def;                    /* default value */
-
-} cli_ArgvInfo;
-
-
-typedef struct cli_parsedArgInfo
-{
-  int parsed_args;
-  char *data;
-  int arg_int;
-  float arg_float;
-  char *arg_string;
-  char *arg_usage;
-} cli_parsedArgInfo;
-
-
-typedef struct cli_cmdCallbackInfo
-{
-  const char *command_usage;
-  cli_parsedArgInfo *parsedArgTable;
-  void *userdata;
-} cli_cmdCallbackInfo;
-
-
-typedef struct cli_CommandInfo
-{
-  const char *command_name;           /* command name    */
-  cli_ArgvInfo *argtable;       /* pointer to argv table */
-  char **reqd_args;             /* holds reference no for
-                                   required arguments */
-  cli_parsedArgInfo *parsedArgTable;    /* holds parsed arguments */
-  char *helpString;
-
-} cli_CommandInfo;
-
-extern int createArgument(const char *argument, int position, int commandoption,
-                          char *range, int argumentRef, const char *helpString, char *defValue);
-
-
-
-extern int getIntRange(char *range, int *r1, int *r2);
-extern int getFloatRange(char *range, float *r1, float *r2);
-
-#endif /*CREATE_ARGUMENT */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/createCommand.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/createCommand.cc b/mgmt/cli/createCommand.cc
deleted file mode 100644
index d1dc5e4..0000000
--- a/mgmt/cli/createCommand.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/*
- *   createCommand.c --
- *
- *
- *    This file provides basic create command definition,
- *    for any new commands.
- *
- *    It overrides any existing commands with the new command
- *    without any warning
- *
- *
- *    Dated  : 12/11/2000.
- */
-
-#include <tcl.h>
-#include <stdlib.h>
-#include "definitions.h"
-#include "createArgument.h"
-#include "hashtable.h"
-
-static char **reqd_args;
-char **getReqdArgs();
-
-extern Tcl_Interp *interp;
-/* This is the only interp for the whole application */
-
-extern cli_ArgvInfo *cliGetArgvInfo();
-extern int cliSetArgvInfo(cli_ArgvInfo * argtable);
-
-
-
-int
-createCommand(const char *cmdName, Tcl_CmdProc cmdFuncPtr,
-              createArgumentFuncPtr argvFuncPtr, cmdTerritory cmdScope, const char *usage, const char *helpString)
-{
-  /* No code to support threads for Tcl */
-
-  /* If required add thread Specific code
-     here
-     Hint: Use Tcl_GetThreadData
-
-   */
-  int isSafe, i;
-  cli_ArgvInfo *argtable;
-  char **required_args;
-  cli_cmdCallbackInfo *cmdCallbackInfo;
-
-  if ((cmdName == NULL) || (cmdFuncPtr == NULL) || (helpString == NULL)) {
-    printf("Error: New command with NULL string or object procs or with no help string provided\n");
-    return TCL_ERROR;
-  }
-
-
-  /* Used for creating internal commands */
-  isSafe = Tcl_IsSafe(interp);
-
-  argtable = (cli_ArgvInfo *) ckalloc(sizeof(cli_ArgvInfo) * 100);
-  for (i = 0; i < 100; i++) {
-    argtable[i].key = (char *) NULL;
-    argtable[i].type = CLI_ARGV_END;
-    argtable[i].range_set = false;
-    argtable[i].option = CLI_ARGV_OPTIONAL;
-    argtable[i].def = (char *) NULL;
-    argtable[i].help = (char *) NULL;
-
-  }
-
-  cmdCallbackInfo = (cli_cmdCallbackInfo *) ckalloc(sizeof(cli_cmdCallbackInfo));
-
-  cmdCallbackInfo->command_usage = usage;
-
-  cmdCallbackInfo->parsedArgTable = (cli_parsedArgInfo *) ckalloc(sizeof(cli_parsedArgInfo) * 100);
-  for (i = 0; i < 100; i++) {
-    cmdCallbackInfo->parsedArgTable[i].parsed_args = CLI_PARSED_ARGV_END;
-    cmdCallbackInfo->parsedArgTable[i].data = (char *) NULL;
-    cmdCallbackInfo->parsedArgTable[i].arg_string = (char *) NULL;
-    cmdCallbackInfo->parsedArgTable[i].arg_int = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
-    cmdCallbackInfo->parsedArgTable[i].arg_float = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
-    cmdCallbackInfo->parsedArgTable[i].arg_usage = (char *) NULL;
-
-  }
-
-  cmdCallbackInfo->userdata = (void *) NULL;
-
-  /* Create a new command with cmdName */
-  Tcl_CreateCommand(interp, cmdName, cmdFuncPtr, (ClientData) cmdCallbackInfo,
-                    (void (*)_ANSI_ARGS_((ClientData))) NULL);
-
-  cliSetArgvInfo(argtable);
-  if (isSafe) {
-    if (cmdScope == CLI_COMMAND_INTERNAL) {
-      Tcl_HideCommand(interp, cmdName, cmdName);
-    }
-  }
-
-
-  if (argvFuncPtr != NULL) {
-    (*argvFuncPtr) ();
-    /* Now call create Arguments so that we can fill the necessary
-       data structure and call parseArgv to parse the arguments.
-     */
-  }
-
-  required_args = getReqdArgs();
-  cliAddCommandtoHashtable(cmdName, argtable, required_args, cmdCallbackInfo->parsedArgTable, helpString);
-
-
-  return TCL_OK;
-
-}
-
-void
-setReqdArgs(char **required_args)
-{
-  reqd_args = required_args;
-}
-
-char **
-getReqdArgs()
-{
-  return reqd_args;
-}
-
-int
-cmd_ok()
-{
-  /* if it called many times, the interperter will store only
-     the latest.
-   */
-  Tcl_AppendElement(interp, "+OK");
-  return TCL_OK;
-}
-
-
-int
-cmd_error()
-{
-  /* If it called many times, the interpreter will store only
-     the latest
-   */
-  Tcl_AppendElement(interp, "-ERROR");
-  return TCL_ERROR;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/createCommand.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/createCommand.h b/mgmt/cli/createCommand.h
deleted file mode 100644
index b6a5147..0000000
--- a/mgmt/cli/createCommand.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/*
- *   createCommand.h --
- *
- *
- *    This file provides basic create command declartion,
- *    for any new commands.
- *
- *    It overrides any existing commands with the new command
- *
- *
- *
- *    Dated  : 12/11/2000.
- */
-
-#ifndef CREATE_COMMAND
-#define CREATE_COMMAND
-
-#include "definitions.h"
-
-
-
-/* First Argument  cmdName: New command name for CLI
-   Second Argument cmdFuncPtr : A 'C' function to be invoked
-                                for the new Command
-   Third Argument argvFuncPtr : Function to attach arguments
-                                Pass NULL for no arguments.
-   Fourth Argument cmdScope   : Scope of the command.
-                                Pass NULL, if the new command
-                                needs to be visible for
-                                the customer.
-*/
-
-extern int createCommand(const char *cmdName, Tcl_CmdProc * cmdFuncPtr,
-                         createArgumentFuncPtr argvFuncPtr, cmdTerritory cmdScope, const char *usage, const char *helpstring);
-
-#endif /* CREATE_COMMAND */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/definitions.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/definitions.h b/mgmt/cli/definitions.h
deleted file mode 100644
index 327baad..0000000
--- a/mgmt/cli/definitions.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/*
- * Legal values for the type field of a createArgv:
- *
- */
-#include <tcl.h>
-
-#ifndef DEFINITIONS
-#define DEFINITIONS
-
-#define CLI_OK    TCL_OK
-
-#define CLI_ERROR TCL_ERROR
-#define CMD_OK cmd_ok()
-#define CMD_ERROR cmd_error()
-
-#define CLI_ARGV_CONSTANT                   0x1
-#define CLI_ARGV_INT                        0x2
-#define CLI_ARGV_STRING                     0x4
-#define CLI_ARGV_FLOAT                      0x8
-#define CLI_ARGV_FUNC                       0x10
-#define CLI_ARGV_HELP                       0x20
-#define CLI_ARGV_CONST_OPTION               0x40
-#define CLI_ARGV_OPTION_FLOAT_VALUE         0x80
-#define CLI_ARGV_OPTION_INT_VALUE           0x90
-#define CLI_ARGV_OPTION_NAME_VALUE          0x100
-#define CLI_ARGV_END                        0x200
-#define CLI_PARSED_ARGV_END                 0x1000
-#define CLI_PARSED_ARGV_DATA                0x1001
-#define CLI_PARENT_ARGV                     1
-#define CLI_ARGV_NO_POS                     -1
-
-#define CLI_ARGV_OPTIONAL                   0x400
-#define CLI_ARGV_REQUIRED                   0x800
-
-#define CLI_DEFAULT_INT_OR_FLOAT_VALUE               -32768
-
-typedef enum
-{
-  CLI_COMMAND_INTERNAL = 0x300,
-  CLI_COMMAND_EXTERNAL = 0x700
-} cmdTerritory;
-
-typedef int (commandFunctionptr) (ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]);
-typedef int (createArgumentFuncPtr) ();
-
-int cmd_ok(void);
-int cmd_error(void);
-
-extern int AlarmCallbackPrint;
-
-int processArgForCommand(Tcl_Interp * interp, int argc, const char *argv[]);
-int processHelpCommand(int argc, const char *argv[]);
-
-#endif /*DEFINITIONS */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/hashtable.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/hashtable.cc b/mgmt/cli/hashtable.cc
deleted file mode 100644
index 183ebf0..0000000
--- a/mgmt/cli/hashtable.cc
+++ /dev/null
@@ -1,219 +0,0 @@
-/** @file
-
-  Stuff related to hashtable
-
-  @section license License
-
-  Copyright (c) 1997-1998 Sun Microsystems, Inc.
-
-  TK 8.3 license:
-
-  This software is copyrighted by the Regents of the University of
-  California, Sun Microsystems, Inc., and other parties.  The following
-  terms apply to all files associated with the software unless explicitly
-  disclaimed in individual files.
-
-  The authors hereby grant permission to use, copy, modify, distribute,
-  and license this software and its documentation for any purpose, provided
-  that existing copyright notices are retained in all copies and that this
-  notice is included verbatim in any distributions. No written agreement,
-  license, or royalty fee is required for any of the authorized uses.
-  Modifications to this software may be copyrighted by their authors
-  and need not follow the licensing terms described here, provided that
-  the new terms are clearly indicated on the first page of each file where
-  they apply.
-
-  IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
-  FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
-  ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
-  DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
-  POSSIBILITY OF SUCH DAMAGE.
-
-  THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
-  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
-  FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
-  IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
-  NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
-  MODIFICATIONS.
-
-  GOVERNMENT USE: If you are acquiring this software on behalf of the
-  U.S. government, the Government shall have only "Restricted Rights"
-  in the software and related documentation as defined in the Federal
-  Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
-  are acquiring the software on behalf of the Department of Defense, the
-  software shall be classified as "Commercial Computer Software" and the
-  Government shall have only "Restricted Rights" as defined in Clause
-  252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
-  authors grant the U.S. Government and others acting in its behalf
-  permission to use and distribute the software in accordance with the
-  terms specified in this license.
-
-  @section details Details
-
-  Parts of this code is based on code from TK, tkConfig.c. The license
-  on this code allows us to use as long as we keep the license with
-  the source.  Note that only parts of this code is from tkConfig.c,
-  since it's been modified to work with our internals.
-
- */
-
-#include <tcl.h>
-#include <stdlib.h>
-#include <string.h>
-#include "definitions.h"
-#include "createArgument.h"
-#include "ink_string.h"
-#include "ink_defs.h"
-
-
-extern Tcl_Interp *interp;
-Tcl_HashTable CommandHashtable;
-
-#define OPTION_HASH_KEY "cliOptionTable"
-static void DestroyOptionHashTable _ANSI_ARGS_((ClientData clientData, Tcl_Interp * interp));
-
-int
-cliCreateCommandHashtable()
-{
-  Tcl_HashTable *hashTablePtr;
-
-  /*
-   * We use an AssocData value in the interpreter to keep a hash
-   * table of all the option tables we've created for this application.
-   * This is used for two purposes.  First, it allows us to share the
-   * tables (e.g. in several chains) and second, we use the deletion
-   * callback for the AssocData to delete all the option tables when
-   * the interpreter is deleted.  The code below finds the hash table
-   * or creates a new one if it doesn't already exist.
-   */
-  hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL);
-  if (hashTablePtr == NULL) {
-    hashTablePtr = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
-    Tcl_InitHashTable(hashTablePtr, TCL_STRING_KEYS);
-    Tcl_SetAssocData(interp, OPTION_HASH_KEY, DestroyOptionHashTable, (ClientData) hashTablePtr);
-  }
-
-  return TCL_OK;
-}
-
-
-int
-cliAddCommandtoHashtable(const char *name, cli_ArgvInfo * argtable,
-                         char **reqd_args, cli_parsedArgInfo * parsedArgTable, const char *helpString)
-{
-  Tcl_HashEntry *entryPtr;
-  int newCmd;
-  cli_CommandInfo *commandinfo;
-  Tcl_HashTable *hashTablePtr;
-
-  hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL);
-  if (hashTablePtr == NULL) {
-    Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL);
-    return TCL_ERROR;
-  }
-
-
-  commandinfo = (cli_CommandInfo *) ckalloc(sizeof(cli_CommandInfo));
-  commandinfo->command_name = name;
-  commandinfo->argtable = argtable;
-  commandinfo->reqd_args = reqd_args;
-  commandinfo->parsedArgTable = parsedArgTable;
-  if (helpString != NULL) {
-    int helpString_size = sizeof(char) * (strlen(helpString) + 1);
-    commandinfo->helpString = (char *) ckalloc(helpString_size);
-    ink_strlcpy(commandinfo->helpString, helpString, helpString_size);
-  }
-
-  /*
-   * See if a table has already been created for this template.  If
-   * so, just reuse the existing table.
-   */
-
-  entryPtr = Tcl_CreateHashEntry(hashTablePtr, name, &newCmd);
-  if (entryPtr == NULL) {
-    Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL);
-    return TCL_ERROR;
-  }
-  Tcl_SetHashValue(entryPtr, commandinfo);
-  return TCL_OK;
-}
-
-
-cli_CommandInfo *
-cliGetCommandArgsfromHashtable(char *name)
-{
-  Tcl_HashEntry *entryPtr;
-  cli_CommandInfo *commandinfo;
-  Tcl_HashTable *hashTablePtr;
-
-  hashTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, OPTION_HASH_KEY, NULL);
-  if (hashTablePtr == NULL) {
-    Tcl_AppendResult(interp, "can not add command to hash table", (char *) NULL);
-    return NULL;
-  }
-
-  entryPtr = Tcl_FindHashEntry(hashTablePtr, name);
-  if (entryPtr == NULL) {
-    Tcl_AppendResult(interp, "no command named \"", name, "\"", (char *) NULL);
-    return NULL;
-  }
-
-  commandinfo = (cli_CommandInfo *) Tcl_GetHashValue(entryPtr);
-  if (commandinfo == (cli_CommandInfo *) NULL) {
-    Tcl_AppendResult(interp, "no command named \"", name, "\"", (char *) NULL);
-    return NULL;
-  }
-
-  return (commandinfo);
-
-}
-
-
-static void
-DestroyOptionHashTable(ClientData clientData, Tcl_Interp * /* interp ATS_UNUSED */)
-    /* The hash table we are destroying */
-    /* The interpreter we are destroying */
-{
-  Tcl_HashTable *hashTablePtr = (Tcl_HashTable *) clientData;
-  Tcl_HashSearch search;
-  Tcl_HashEntry *hashEntryPtr;
-  cli_CommandInfo *commandinfo;
-  cli_ArgvInfo *infoPtr;
-
-  for (hashEntryPtr = Tcl_FirstHashEntry(hashTablePtr, &search);
-       hashEntryPtr != NULL; hashEntryPtr = Tcl_NextHashEntry(&search)) {
-
-    commandinfo = (cli_CommandInfo *) Tcl_GetHashValue(hashEntryPtr);
-    if (commandinfo) {
-      if (commandinfo->reqd_args) {
-        ckfree((char *) commandinfo->reqd_args);
-      }
-
-      if (commandinfo->argtable) {
-        for (infoPtr = commandinfo->argtable; infoPtr->key != NULL; infoPtr++) {
-          if (infoPtr->key) {
-            ckfree((char *) infoPtr->key);
-          }
-          if (infoPtr->help) {
-            ckfree((char *) infoPtr->help);
-          }
-          if (infoPtr->def) {
-            ckfree((char *) infoPtr->def);
-          }
-        }
-        ckfree((char *) commandinfo->argtable);
-      }
-
-      if (commandinfo->command_name) {
-        ckfree((char *) commandinfo->command_name);
-      }
-      if (commandinfo->helpString) {
-        ckfree((char *) commandinfo->helpString);
-      }
-      ckfree((char *) commandinfo);
-    }
-    hashEntryPtr = Tcl_NextHashEntry(&search);
-  }
-  Tcl_DeleteHashTable(hashTablePtr);
-  ckfree((char *) hashTablePtr);
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/hashtable.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/hashtable.h b/mgmt/cli/hashtable.h
deleted file mode 100644
index 96f9f7b..0000000
--- a/mgmt/cli/hashtable.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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.
- */
-
-/* hashtable.h
- * has function declarations for the stuff realted to hashtable
- *
- */
-
-#ifndef CREATE_HASH
-#define CREATE_HASH
-
-#include "createArgument.h"
-
-extern int cliCreateCommandHashtable();
-
-extern int cliAddCommandtoHashtable(const char *name, cli_ArgvInfo * argtable, char **reqd_args,
-                                    cli_parsedArgInfo * parsedArgTable, const char *helpString);
-
-extern cli_CommandInfo *cliGetCommandArgsfromHashtable(char *name);
-
-extern int cliParseArgument(int argc, const char **argv, cli_CommandInfo * commandinfo);
-
-extern int getIntRange(char *range, int *r1, int *r2);
-extern int floatIntRange(char *range, float *r1, float *r2);
-#endif /* CREATE_HASH */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/processArgument.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/processArgument.cc b/mgmt/cli/processArgument.cc
deleted file mode 100644
index 24f0810..0000000
--- a/mgmt/cli/processArgument.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-/** @file
-
-  A brief file description
-
-  @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 <tcl.h>
-#include "hashtable.h"
-#include "definitions.h"
-#include "ink_error.h"
-#include "ink_defs.h"
-#include <string.h>
-
-// processArgForCommand
-int
-processArgForCommand(Tcl_Interp * /* interp ATS_UNUSED */, int argc, const char *argv[])
-{
-  cli_CommandInfo *commandinfo = cliGetCommandArgsfromHashtable((char *) argv[0]);
-
-  if (commandinfo == NULL)
-    return TCL_ERROR;
-
-  return (cliParseArgument(argc, argv, commandinfo));
-}
-
-
-//processHelpCmd
-int
-processHelpCommand(int argc, const char *argv[])
-{
-  if (argc == 2) {
-    int length = strlen(argv[1]);
-    if ((length >= 2) && ((strncmp(argv[1], "-help", length) == 0) || (strncmp(argv[1], "-h", length) == 0))) {
-      return TCL_OK;
-    }
-  } else
-    return TCL_ERROR;
-
-  return TCL_ERROR;
-}


[13/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/CliMgmtUtils.cc
----------------------------------------------------------------------
diff --git a/mgmt/cli/CliMgmtUtils.cc b/mgmt/cli/CliMgmtUtils.cc
deleted file mode 100644
index 222e334..0000000
--- a/mgmt/cli/CliMgmtUtils.cc
+++ /dev/null
@@ -1,625 +0,0 @@
-/** @file
-
-  This file contains various utility functions which call the TSMgmtAPI.
-
-  @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 "libts.h"
-#include "I_Layout.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include "CliMgmtUtils.h"
-#include "CliDisplay.h"
-#include "ink_resource.h"
-#include "definitions.h"
-#include "ConfigCmd.h"
-
-
-void Cli_DisplayMgmtAPI_Error(TSError status);
-
-// Get a records.config variable by name
-TSError
-Cli_RecordGet(const char *rec_name, TSRecordEle * rec_val)
-{
-  TSError status;
-  if ((status = TSRecordGet((char *) rec_name, rec_val))) {
-    Cli_Debug(ERR_RECORD_GET, rec_name);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-// Get an integer type records.config variable
-TSError
-Cli_RecordGetInt(const char *rec_name, TSInt * int_val)
-{
-  TSError status;
-  if ((status = TSRecordGetInt(rec_name, int_val))) {
-    Cli_Debug(ERR_RECORD_GET_INT, rec_name);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-// Get an counter type records.config variable
-TSError
-Cli_RecordGetCounter(const char *rec_name, TSCounter * ctr_val)
-{
-  TSError status;
-  if ((status = TSRecordGetCounter(rec_name, ctr_val))) {
-    Cli_Debug(ERR_RECORD_GET_COUNTER, rec_name);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-// Get a float type records.config variable
-TSError
-Cli_RecordGetFloat(const char *rec_name, TSFloat * float_val)
-{
-  TSError status;
-  if ((status = TSRecordGetFloat(rec_name, float_val))) {
-    Cli_Debug(ERR_RECORD_GET_FLOAT, rec_name);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-// Get a string type records.config variable
-TSError
-Cli_RecordGetString(const char *rec_name, char **string_val)
-{
-  TSError status;
-  if ((status = TSRecordGetString(rec_name, string_val))) {
-    Cli_Debug(ERR_RECORD_GET_STRING, rec_name);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-// Use a string to set a records.config variable
-TSError
-Cli_RecordSet(const char *rec_name, const char *rec_value, TSActionNeedT * action_need)
-{
-  TSError status;
-  if ((status = TSRecordSet((char *) rec_name, (TSString) rec_value, action_need))) {
-    Cli_Debug(ERR_RECORD_SET, rec_name, rec_value);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-// Set an integer type records.config variable
-TSError
-Cli_RecordSetInt(const char *rec_name, TSInt int_val, TSActionNeedT * action_need)
-{
-  TSError status;
-  if ((status = TSRecordSetInt(rec_name, int_val, action_need))) {
-    Cli_Debug(ERR_RECORD_SET_INT, rec_name, int_val);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-// Set a float type records.config variable
-TSError
-Cli_RecordSetFloat(const char *rec_name, TSFloat float_val, TSActionNeedT * action_need)
-{
-  TSError status;
-  if ((status = TSRecordSetFloat(rec_name, float_val, action_need))) {
-    Cli_Debug(ERR_RECORD_SET_FLOAT, rec_name, float_val);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-
-// Set a string type records.config variable
-TSError
-Cli_RecordSetString(const char *rec_name, TSString str_val, TSActionNeedT * action_need)
-{
-  TSError status;
-  if ((status = TSRecordSetString(rec_name, str_val, action_need))) {
-    Cli_Debug(ERR_RECORD_SET_STRING, rec_name, str_val);
-    Cli_DisplayMgmtAPI_Error(status);
-  }
-  return status;
-}
-
-void
-Cli_DisplayMgmtAPI_Error(TSError status)
-{
-  switch (status) {
-  case TS_ERR_OKAY:           // do nothing
-    break;
-  case TS_ERR_READ_FILE:
-    Cli_Printf("\nERROR: Unable to read config file.\n\n");
-    break;
-  case TS_ERR_WRITE_FILE:
-    Cli_Printf("\nERROR: Unable to write config file.\n\n");
-    break;
-  case TS_ERR_PARSE_CONFIG_RULE:
-    Cli_Printf("\nERROR: Unable to parse config file.\n\n");
-    break;
-  case TS_ERR_INVALID_CONFIG_RULE:
-    Cli_Printf("\nERROR: Invalid Configuration Rule in config file.\n\n");
-    break;
-  case TS_ERR_NET_ESTABLISH:
-    Cli_Printf("\nERROR: Unable to establish connection to traffic_manager.\n"
-               "       Ability to make configuration changes depends on traffic_manager.\n");
-    break;
-  case TS_ERR_NET_READ:
-    Cli_Printf("\nERROR: Unable to read data from traffic_manager.\n"
-               "       Ability to monitor the system changes depends on traffic_manager.\n");
-    break;
-  case TS_ERR_NET_WRITE:
-    Cli_Printf("\nERROR: Unable to write configuration data to traffic_manager.\n"
-               "       Ability to make configuration changes depends on traffic_manager.\n");
-    break;
-  case TS_ERR_NET_EOF:
-    Cli_Printf("\nERROR: Unexpected EOF while communicating with traffic_manager.\n"
-               "       Ability to make configuration changes depends on traffic_manager.\n");
-    break;
-  case TS_ERR_NET_TIMEOUT:
-    Cli_Printf("\nERROR: Timed-out while communicating with traffic_manager.\n"
-               "       Ability to make configuration changes depends on traffic_manager.\n");
-    break;
-  case TS_ERR_SYS_CALL:
-    Cli_Printf("\nERROR: Internal System Call failed.\n\n");
-    break;
-  case TS_ERR_PARAMS:
-    Cli_Printf("\nERROR: Invalid parameters passed to a function.\n\n");
-    break;
-  case TS_ERR_FAIL:
-    Cli_Printf("\nERROR: Invalid parameter specified.\n" "       Check parameters for correct syntax and type.\n\n");
-    break;
-  default:
-    Cli_Printf("\nERROR: Undocumented Error. Status = %d.\n\n", status);
-    break;
-  }
-}
-
-// Retrieve and display contents of a rules file
-TSError
-Cli_DisplayRules(TSFileNameT fname)
-{
-  TSError status;
-  char *text;
-  int size = 0, version = 0;
-
-  if ((status = TSConfigFileRead(fname, &text, &size, &version))) {
-    Cli_Debug(ERR_CONFIG_FILE_READ, fname);
-    Cli_DisplayMgmtAPI_Error(status);
-  } else {
-    if (size) {
-      // Fix TSqa12220: use printf directly since Cli_Printf may
-      // not allocate enough buffer space to display the file contents
-      puts(text);
-      ats_free(text);
-    } else {
-      Cli_Printf("no rules\n");
-    }
-  }
-
-  return status;
-}
-
-// Retrieve and use config file from remote URL
-TSError
-Cli_SetConfigFileFromUrl(TSFileNameT file, const char *url)
-{
-  char *buf;
-  int size = 0;
-  int version = -1;
-  TSError status;
-
-  Cli_Debug("Cli_SetConfigFileFromUrl: file %d url %s\n", file, url);
-
-  // read config file from Url
-  if ((status = TSReadFromUrl((char *) url, NULL, NULL, &buf, &size))) {
-    Cli_Debug(ERR_READ_FROM_URL, url);
-    Cli_DisplayMgmtAPI_Error(status);
-    return status;
-  }
-
-  Cli_Debug("Cli_SetConfigFileFromUrl: size %d version %d\n", size, version);
-
-  Cli_Debug("Cli_SetConfigFileFromUrl: buf\n%s\n", buf);
-
-  // write config file
-  if ((status = TSConfigFileWrite(file, buf, size, version))) {
-    Cli_Debug(ERR_CONFIG_FILE_WRITE, file);
-    Cli_DisplayMgmtAPI_Error(status);
-    if (size)
-      ats_free(buf);
-    return status;
-  }
-
-  if (size)
-    ats_free(buf);
-
-  Cli_Printf("Successfully updated config file.\n");
-
-  return status;
-}
-
-// enable recent configuration changes by performing the action specified
-// by the action_need value
-TSError
-Cli_ConfigEnactChanges(TSActionNeedT action_need)
-{
-  TSError status;
-
-  Cli_Debug("Cli_ConfigEnactChanges: action_need %d\n", action_need);
-
-  switch (action_need) {
-  case TS_ACTION_SHUTDOWN:
-    Cli_Debug("Cli_ConfigEnactChanges: TS_ACTION_SHUTDOWN\n");
-    Cli_Printf("\nHard Restart required.\n"
-               "  Change will take effect after next Hard Restart.\n"
-               "  Use the \"config:hard-restart\" command to restart now.\n\n");
-    break;
-
-  case TS_ACTION_RESTART:
-    Cli_Debug("Cli_ConfigEnactChanges: TS_ACTION_RESTART\n");
-    Cli_Printf("\nRestart required.\n"
-               "  Change will take effect after next Restart.\n"
-               "  Use the \"config:restart\" command to restart now.\n\n");
-    break;
-
-  case TS_ACTION_DYNAMIC:
-    Cli_Debug("Cli_ConfigEnactChanges: TS_ACTION_DYNAMIC\n");
-    // no additional action required
-    break;
-
-  case TS_ACTION_RECONFIGURE:
-    Cli_Debug("Cli_ConfigEnactChanges: TS_ACTION_RECONFIGURE\n");
-    status = TSActionDo(TS_ACTION_RECONFIGURE);
-    if (status) {
-      Cli_Error("\nERROR %d: Failed to reread configuration files.\n\n", status);
-      return TS_ERR_FAIL;
-    }
-    break;
-
-  default:
-    Cli_Debug("  Status Message #%d\n", action_need);
-    Cli_Error("\nYou may need to use the \"config:hard-restart\" command\n" "to enable this configuration change.\n\n");
-    return TS_ERR_OKAY;
-  }
-
-  return TS_ERR_OKAY;
-}
-
-// evaluate "stringval" and return 1 if "on", otherwise 0
-int
-Cli_EvalOnOffString(char *stringval)
-{
-  if (strcmp(stringval, "on") == 0) {
-    return 1;
-  }
-  if (strcmp(stringval, "off") == 0) {
-    return 0;
-  }
-
-  return -1;
-}
-
-////////////////////////////////////////////////////////////////
-// Cli_RecordOnOff_Action
-//
-// used for records.config INT variables when 1 = on, 0 = off
-//
-// action = RECORD_GET retrieve and display the variable
-//          RECORD_SET set the variable
-//
-// record = variable in records.config
-//
-// on_off = "on" mean 1, "off" mean 0
-//
-int
-Cli_RecordOnOff_Action(int action, const char *record, const char *on_off)
-{
-  TSActionNeedT action_need;
-  TSError status;
-  TSInt int_val;
-
-  switch (action) {
-  case RECORD_SET:
-    if (on_off) {
-      if (!strcasecmp(on_off, "on")) {
-        int_val = 1;
-      } else if (!strcasecmp(on_off, "off")) {
-        int_val = 0;
-      } else {
-        Cli_Error("Expected \"on\" or \"off\" but got %s\n", on_off);
-        return CLI_ERROR;
-      }
-    } else {
-      Cli_Error("Expected <on | off> but got nothing.\n");
-      return CLI_ERROR;
-    }
-    status = Cli_RecordSetInt(record, int_val, &action_need);
-    if (status != TS_ERR_OKAY) {
-      return status;
-    }
-    return (Cli_ConfigEnactChanges(action_need));
-
-  case RECORD_GET:
-    int_val = -1;
-    status = Cli_RecordGetInt(record, &int_val);
-    Cli_PrintEnable("", int_val);
-    return CLI_OK;
-  }
-  return CLI_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cli_RecordInt_Action
-//
-// used for records.config INT variables
-//
-// action = RECORD_GET retrieve and display the variable
-//          RECORD_SET set the variable
-//
-// record = variable in records.config
-//
-// value = the integer value used by RECORD_SET
-//
-int
-Cli_RecordInt_Action(int action, const char *record, int value)
-{
-  switch (action) {
-  case RECORD_SET:
-    {
-      TSActionNeedT action_need = TS_ACTION_UNDEFINED;
-      TSError status = Cli_RecordSetInt(record, value, &action_need);
-
-      if (status) {
-        return status;
-      }
-      return (Cli_ConfigEnactChanges(action_need));
-    }
-  case RECORD_GET:
-    {
-      TSInt value_in = -1;
-      TSError status = Cli_RecordGetInt(record, &value_in);
-
-      if (status) {
-        return status;
-      }
-      Cli_Printf("%d\n", value_in);
-      return CLI_OK;
-    }
-  }
-  return CLI_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cli_RecordHostname_Action
-//
-// used for records.config STRING variables
-// performs checking to see if string is a valid fully qualified hostname
-//
-// action = RECORD_GET retrieve and display the variable
-//          RECORD_SET set the variable
-//
-// record = variable in records.config
-//
-// hostname = string to set
-//
-int
-Cli_RecordHostname_Action(int action, char *record, char *hostname)
-{
-  TSError status;
-  TSActionNeedT action_need = TS_ACTION_UNDEFINED;
-  TSString str_val = NULL;
-
-  switch (action) {
-  case RECORD_SET:
-    if (IsValidFQHostname(hostname) == CLI_OK) {
-      status = Cli_RecordSetString(record, (TSString) hostname, &action_need);
-
-      if (status) {
-        return status;
-      }
-      return (Cli_ConfigEnactChanges(action_need));
-    }
-    Cli_Error("ERROR: %s is an invalid name.\n", hostname);
-    return CLI_ERROR;
-
-  case RECORD_GET:
-    status = Cli_RecordGetString(record, &str_val);
-    if (status) {
-      return status;
-    }
-    if (str_val)
-      Cli_Printf("%s\n", str_val);
-    else
-      Cli_Printf("none\n");
-    return CLI_OK;
-  }
-  return CLI_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cli_RecordString_Action
-//
-// used for records.config STRING variables
-//
-// action = RECORD_GET retrieve and display the variable
-//          RECORD_SET set the variable
-//
-// record = variable in records.config
-//
-// string_val = string to set
-//
-int
-Cli_RecordString_Action(int action, const char *record, char *string_val)
-{
-  TSError status;
-  TSActionNeedT action_need = TS_ACTION_UNDEFINED;
-  TSString str_val = NULL;
-
-  switch (action) {
-  case RECORD_SET:
-    status = Cli_RecordSetString(record, (TSString) string_val, &action_need);
-
-    if (status) {
-      return status;
-    }
-    return (Cli_ConfigEnactChanges(action_need));
-
-  case RECORD_GET:
-    status = Cli_RecordGetString(record, &str_val);
-    if (status) {
-      return status;
-    }
-    if (str_val)
-      Cli_Printf("%s\n", str_val);
-    else
-      Cli_Printf("none\n");
-    return CLI_OK;
-  }
-  return CLI_ERROR;
-}
-
-////////////////////////////////////////////////////////////////
-// Cli_ConfigFileURL_Action
-//
-// used for config files other than records.config
-//
-// file = integer which specifies config file
-//
-// filename = config file name to display
-//
-// url = if non-NULL, update the file using contents of URL
-//
-int
-Cli_ConfigFileURL_Action(TSFileNameT file, const char *filename, const char *url)
-{
-  TSError status;
-  // Retrieve  file from url
-
-  if (url == NULL) {
-    Cli_Printf("%s File Rules\n", filename);
-    Cli_Printf("----------------------------\n");
-    status = Cli_DisplayRules(file);
-    return status;
-  }
-  Cli_Printf("Retrieve and Install %s file from url %s\n", filename, url);
-
-  status = Cli_SetConfigFileFromUrl(file, url);
-
-  return (status);
-}
-
-int
-cliCheckIfEnabled(const char *command)
-{
-  if (enable_restricted_commands == false) {
-    Cli_Error("\n%s is a restricted command only accessible from enable mode\n\n", command);
-    return CLI_ERROR;
-  }
-  return CLI_OK;
-}
-
-int
-GetTSDirectory(char *ts_path, size_t ts_path_len)
-{
-
-  ink_strlcpy(ts_path, Layout::get()->bindir, ts_path_len);
-  if (access(ts_path, R_OK) == -1) {
-    Cli_Error("unable to access() '%s': %d, %s\n",
-              ts_path, errno, strerror(errno));
-    Cli_Error(" Please set correct path in env variable TS_ROOT \n");
-    return -1;
-  }
-
-  return 0;
-}
-
-int
-StopTrafficServer()
-{
-  char ts_path[PATH_NAME_MAX + 1];
-  char stop_ts[1024];
-
-  if (GetTSDirectory(ts_path,sizeof(ts_path))) {
-    return CLI_ERROR;
-  }
-  snprintf(stop_ts, sizeof(stop_ts), "%s/stop_traffic_server", ts_path);
-  if (system(stop_ts) == -1)
-    return CLI_ERROR;
-
-  return 0;
-}
-
-int
-StartTrafficServer()
-{
-  char ts_path[PATH_NAME_MAX + 1];
-  char start_ts[1024];
-
-  if (GetTSDirectory(ts_path,sizeof(ts_path))) {
-    return CLI_ERROR;
-  }
-  // root user should start_traffic_shell as inktomi user
-  if (getuid() == 0) {
-    snprintf(start_ts, sizeof(start_ts), "/bin/su - inktomi -c \"%s/start_traffic_server\"", ts_path);
-  } else {
-    snprintf(start_ts, sizeof(start_ts), "%s/start_traffic_server", ts_path);
-  }
-  if (system(start_ts) == -1)
-    return CLI_ERROR;
-
-  return 0;
-}
-
-int
-Cli_CheckPluginStatus(TSString plugin)
-{
-
-  int match = 0;
-  TSCfgContext ctx;
-  TSCfgIterState ctx_state;
-  TSPluginEle *ele;
-
-  ctx = TSCfgContextCreate(TS_FNAME_PLUGIN);
-  if (TSCfgContextGet(ctx) != TS_ERR_OKAY) {
-    printf("ERROR READING FILE\n");
-  }
-  ele = (TSPluginEle *) TSCfgContextGetFirst(ctx, &ctx_state);
-
-  while (ele) {
-    if (!strcasecmp(plugin, ele->name)) {
-      match = 1;
-      break;
-    }
-    ele = (TSPluginEle *) TSCfgContextGetNext(ctx, &ctx_state);
-  }
-
-  if (match) {
-    return CLI_OK;
-  } else {
-    return CLI_ERROR;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/mgmt/cli/CliMgmtUtils.h
----------------------------------------------------------------------
diff --git a/mgmt/cli/CliMgmtUtils.h b/mgmt/cli/CliMgmtUtils.h
deleted file mode 100644
index 3798f70..0000000
--- a/mgmt/cli/CliMgmtUtils.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/** @file
-
-  This file declares various utility functions which call the TSMgmtAPI.
-
-  @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 "mgmtapi.h"
-
-#define RECORD_GET 0
-#define RECORD_SET 1
-
-// Get a records.config variable by name
-TSError Cli_RecordGet(const char *rec_name, TSRecordEle * rec_val);
-
-// Get an integer type records.config variable
-TSError Cli_RecordGetInt(const char *rec_name, TSInt * int_val);
-
-// Get an counter type records.config variable
-TSError Cli_RecordGetCounter(const char *rec_name, TSCounter * ctr_val);
-
-// Get a float type records.config variable
-TSError Cli_RecordGetFloat(const char *rec_name, TSFloat * float_val);
-
-// Get a string type records.config variable
-TSError Cli_RecordGetString(const char *rec_name, char **string_val);
-
-// Use a string to set a records.config variable
-TSError Cli_RecordSet(const char *rec_name, const char *rec_value, TSActionNeedT * action_need);
-
-// Set an integer type records.config variable
-TSError Cli_RecordSetInt(const char *rec_name, TSInt int_val, TSActionNeedT * action_need);
-
-//Set a float type records.config variable
-TSError Cli_RecordSetFloat(const char *rec_name, TSFloat float_val, TSActionNeedT * action_need);
-
-// Set a string type records.config variable
-TSError Cli_RecordSetString(const char *rec_name, TSString str_val, TSActionNeedT * action_need);
-
-// Retrieve and display contents of a rules file
-TSError Cli_DisplayRules(TSFileNameT fname);
-
-// Retrieve and use config file from remote URL
-TSError Cli_SetConfigFileFromUrl(TSFileNameT file, const char *url);
-
-// enable recent configuration changes by performing the action specified
-// by the action_need value
-TSError Cli_ConfigEnactChanges(TSActionNeedT action_need);
-
-// evaluate "stringval" and return 1 if "on", otherwise 0
-int Cli_EvalOnOffString(char *stringval);
-
-////////////////////////////////////////////////////////////////
-// Cli_Record functions are used by various config commands
-// to get/display and set variables in records.config
-//
-
-////////////////////////////////////////////////////////////////
-// Cli_RecordOnOff_Action
-//
-// used for records.config INT variables when 1 = on, 0 = off
-//
-// action = RECORD_GET retrieve and display the variable
-//          RECORD_SET set the variable
-//
-// record = variable in records.config
-//
-// on_off = "on" mean 1, "off" mean 0
-//
-int Cli_RecordOnOff_Action(int action, const char *record, const char *on_off);
-
-////////////////////////////////////////////////////////////////
-// Cli_RecordInt_Action
-//
-// used for records.config INT variables
-//
-// action = RECORD_GET retrieve and display the variable
-//          RECORD_SET set the variable
-//
-// record = variable in records.config
-//
-// value = the integer value used by RECORD_SET
-//
-int Cli_RecordInt_Action(int action, const char *record, int value);
-
-////////////////////////////////////////////////////////////////
-// Cli_RecordHostname_Action
-//
-// used for records.config STRING variables
-// performs checking to see if string is a valid fully qualified hostname
-//
-// action = RECORD_GET retrieve and display the variable
-//          RECORD_SET set the variable
-//
-// record = variable in records.config
-//
-// hostname = string to set
-//
-int Cli_RecordHostname_Action(int action, const char *record, char *hostname);
-
-////////////////////////////////////////////////////////////////
-// Cli_RecordString_Action
-//
-// used for records.config STRING variables
-//
-// action = RECORD_GET retrieve and display the variable
-//          RECORD_SET set the variable
-//
-// record = variable in records.config
-//
-// string_val = string to set
-//
-int Cli_RecordString_Action(int action, const char *record, char *string_val);
-
-////////////////////////////////////////////////////////////////
-// Cli_ConfigFileURL_Action
-//
-// used for config files other than records.config
-//
-// file = integer which specifies config file
-//
-// filename = config file name to display
-//
-// url = if non-NULL, update the file using contents of URL
-//
-int Cli_ConfigFileURL_Action(TSFileNameT file, const char *filename, const char *url);
-
-extern bool enable_restricted_commands;
-
-int cliCheckIfEnabled(const char *command);
-
-int GetTSDirectory(char *ts_path, size_t ts_path_len);
-
-int StopTrafficServer();
-int StartTrafficServer();
-int Cli_CheckPluginStatus(TSString plugin);


[30/44] git commit: set the tracker_event to NULL if we cancelled the event.

Posted by zw...@apache.org.
set the tracker_event to NULL if we cancelled the event.


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

Branch: refs/heads/5.0.x
Commit: 898d55ff248cb5b179bed07e3e59057f6a261bfc
Parents: de4c7d2
Author: weijin <ta...@taobao.com>
Authored: Wed Nov 20 15:51:07 2013 +0800
Committer: weijin <ta...@taobao.com>
Committed: Wed Nov 20 15:51:07 2013 +0800

----------------------------------------------------------------------
 proxy/signals.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/898d55ff/proxy/signals.cc
----------------------------------------------------------------------
diff --git a/proxy/signals.cc b/proxy/signals.cc
index 968c1ac..83f275d 100644
--- a/proxy/signals.cc
+++ b/proxy/signals.cc
@@ -380,8 +380,10 @@ init_tracker(const char *config_var, RecDataT /* type ATS_UNUSED */, RecData dat
   else
     dump_mem_info_frequency = REC_ConfigReadInteger("proxy.config.dump_mem_info_frequency");
   Debug("tracker", "init_tracker called [%d]\n", dump_mem_info_frequency);
-  if (tracker_event)
+  if (tracker_event) {
     tracker_event->cancel();
+    tracker_event = NULL;
+  }
   if (dump_mem_info_frequency > 0) {
     tracker_event = eventProcessor.schedule_every(new TrackerContinuation,
                                                   HRTIME_SECONDS(dump_mem_info_frequency), ET_CALL);


[23/44] git commit: TS-2359: force tstop symlink

Posted by zw...@apache.org.
TS-2359: force tstop symlink

If you run "make install" a second time then "ln -s" will fail
because the symlink already exists. Autoconf doesn't have a test
for "ln -sf", so just remove the target beforehand.


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

Branch: refs/heads/5.0.x
Commit: 6bfba8bc7c752ec0ad2cd099da8473ebb15f66fc
Parents: b9b1bdc
Author: James Peach <jp...@apache.org>
Authored: Fri Nov 15 22:02:34 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Sat Nov 16 20:34:30 2013 -0800

----------------------------------------------------------------------
 CHANGES                     | 3 +++
 cmd/traffic_top/Makefile.am | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6bfba8bc/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d6327c2..8d47730 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+
+  *) [TS-2359] Make install over existing installation can fail.
+
   *) [TS-2350] Enhancements to traffic_top
 
   *) [TS-2348] Rename tstop to traffic_top.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6bfba8bc/cmd/traffic_top/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_top/Makefile.am b/cmd/traffic_top/Makefile.am
index 292d350..51e45e5 100644
--- a/cmd/traffic_top/Makefile.am
+++ b/cmd/traffic_top/Makefile.am
@@ -36,5 +36,5 @@ traffic_top_LDADD = \
 
 # Install a compatibility symlink because traffic_top was named tstop in previous releases.
 install-exec-hook:
-	cd $(DESTDIR)$(bindir) && $(LN_S) traffic_top tstop
+	cd $(DESTDIR)$(bindir) && $(RM) tstop && $(LN_S) traffic_top tstop
 endif


[05/44] TS-2349: move traffic_cop to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6917d8ef/cop/TrafficCop.cc
----------------------------------------------------------------------
diff --git a/cop/TrafficCop.cc b/cop/TrafficCop.cc
deleted file mode 100644
index 7a258b8..0000000
--- a/cop/TrafficCop.cc
+++ /dev/null
@@ -1,1849 +0,0 @@
-/** @file
-
-  Main entry point for the traffic_cop application.
-
-  @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 "libts.h"
-#include "I_Layout.h"
-#include "I_Version.h"
-#include "I_RecCore.h"
-#include "mgmtapi.h"
-#include "ClusterCom.h"
-
-#include <string>
-#include <map>
-
-#if defined(linux) || defined (solaris)
-#include "sys/utsname.h"
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-
-union semun
-{
-  int val;                      /* value for SETVAL */
-  struct semid_ds *buf;         /* buffer for IPC_STAT, IPC_SET */
-  unsigned short int *array;    /* array for GETALL, SETALL */
-  struct seminfo *__buf;        /* buffer for IPC_INFO */
-};
-#endif  // linux check
-#include <grp.h>
-
-static const long MAX_LOGIN =  sysconf(_SC_LOGIN_NAME_MAX) <= 0 ? _POSIX_LOGIN_NAME_MAX :  sysconf(_SC_LOGIN_NAME_MAX);
-static const char COP_TRACE_FILE[] = "/tmp/traffic_cop.trace";
-
-#define OPTIONS_MAX     32
-#define OPTIONS_LEN_MAX 1024
-
-#ifndef WAIT_ANY
-#define WAIT_ANY (pid_t) -1
-#endif // !WAIT_ANY
-
-#define COP_FATAL    LOG_ALERT
-#define COP_WARNING  LOG_ERR
-#define COP_DEBUG    LOG_DEBUG
-
-Diags * g_diags; // link time dependency
-
-static const char *root_dir;
-static const char *runtime_dir;
-static const char *config_dir;
-static char config_file[PATH_NAME_MAX];
-
-static char cop_lockfile[PATH_NAME_MAX];
-static char manager_lockfile[PATH_NAME_MAX];
-static char server_lockfile[PATH_NAME_MAX];
-
-static int check_memory_min_swapfree_kb = 0;
-static int check_memory_min_memfree_kb = 0;
-
-static int syslog_facility = LOG_DAEMON;
-static char syslog_fac_str[PATH_NAME_MAX] = "LOG_DAEMON";
-
-static int killsig = SIGKILL;
-static int coresig = 0;
-
-static char* admin_user;
-static uid_t admin_uid;
-static gid_t admin_gid;
-static bool admin_user_p = false;
-static char manager_binary[PATH_NAME_MAX] = "traffic_manager";
-static char server_binary[PATH_NAME_MAX] = "traffic_server";
-static char manager_options[OPTIONS_LEN_MAX] = "";
-
-static char log_file[PATH_NAME_MAX] = "traffic.out";
-static char bin_path[PATH_NAME_MAX] = "bin";
-
-static int autoconf_port = 8083;
-static int rs_port = 8088;
-static MgmtClusterType cluster_type = NO_CLUSTER;
-static int http_backdoor_port = 8084;
-
-#if defined(linux)
-// TS-1075 : auto-port ::connect DoS on high traffic linux systems
-static int source_port = 0;
-#endif
-
-static int manager_failures = 0;
-static int server_failures = 0;
-static int server_not_found = 0;
-
-static const int sleep_time = 10;       // 10 sec
-static const int manager_timeout = 3 * 60;      //  3 min
-static const int server_timeout = 3 * 60;       //  3 min
-
-// traffic_manager flap detection
-#define MANAGER_FLAP_DETECTION 1
-#if defined(MANAGER_FLAP_DETECTION)
-#define MANAGER_MAX_FLAP_COUNT 3        // if flap this many times, give up for a while
-#define MANAGER_FLAP_INTERVAL_MSEC 60000        // if x number of flaps happen in this interval, declare flapping
-#define MANAGER_FLAP_RETRY_MSEC 60000   // if flapping, don't try to restart until after this retry duration
-static bool manager_flapping = false;   // is the manager flapping?
-static int manager_flap_count = 0;      // how many times has the manager flapped?
-static ink_hrtime manager_flap_interval_start_time = 0; // first time we attempted to start the manager in past little while)
-static ink_hrtime manager_flap_retry_start_time = 0;    // first time we attempted to start the manager in past little while)
-#endif
-
-// transient syscall error timeout
-#define TRANSIENT_ERROR_WAIT_MS 500
-
-static const int kill_timeout = 1 * 60; //  1 min
-
-static int child_pid = 0;
-static int child_status = 0;
-static int sem_id = 11452;
-
-AppVersionInfo appVersionInfo;
-
-static char const localhost[] = "127.0.0.1";
-
-static void cop_log(int priority, const char *format, ...) TS_PRINTFLIKE(2, 3);
-inline static void dummy_cop_log_trace(const char *format, ...) TS_PRINTFLIKE(1, 2);
-
-static void get_admin_user(void);
-
-struct ConfigValue
-{
-  ConfigValue(RecT _t, RecDataT _d, const std::string& _v)
-    : config_type(_t), data_type(_d), data_value(_v) {
-    }
-
-  RecT        config_type;
-  RecDataT    data_type;
-  std::string data_value;
-};
-
-typedef std::map<std::string, ConfigValue> ConfigValueTable;
-static ConfigValueTable configTable;
-
-inline static void
-dummy_cop_log_trace(const char *format, ...)
-{
-  (void)format;
-}
-
-#if TS_USE_COP_DEBUG
-#define cop_log_trace(...)              cop_log(COP_DEBUG, __VA_ARGS__)
-#else
-#define cop_log_trace(...)      if (0) dummy_cop_log_trace(__VA_ARGS__)
-#endif
-
-
-static void
-cop_log(int priority, const char *format, ...)
-{
-  va_list args;
-  char buffer[8192];
-#if TS_USE_COP_DEBUG
-  static FILE *trace_file = NULL;
-  struct timeval now;
-  double now_f;
-#endif
-
-  va_start(args, format);
-
-#if TS_USE_COP_DEBUG
-  if (!trace_file) {
-    if (!unlink(COP_TRACE_FILE))
-      trace_file = fopen(COP_TRACE_FILE, "w");
-  }
-  if (trace_file) {
-    gettimeofday(&now, NULL);
-    now_f = now.tv_sec + now.tv_usec / 1000000.0f;
-    switch (priority) {
-    case COP_DEBUG:
-      fprintf(trace_file, "<%.4f> [DEBUG]: ", now_f);
-      break;
-    case COP_WARNING:
-      fprintf(trace_file, "<%.4f> [WARNING]: ", now_f);
-      break;
-    case COP_FATAL:
-      fprintf(trace_file, "<%.4f> [FATAL]: ", now_f);
-      break;
-    default:
-      fprintf(trace_file, "<%.4f> [unknown]: ", now_f);
-      break;
-    }
-
-    va_list args_tmp;
-    va_copy(args_tmp, args);
-
-    vfprintf(trace_file, format, args_tmp);
-    fflush(trace_file);
-
-    va_end(args_tmp);
-  }
-#endif
-
-  vsprintf(buffer, format, args);
-  syslog(priority, "%s", buffer);
-
-  va_end(args);
-}
-
-
-void
-chown_file_to_admin_user(const char *file) {
-  if (admin_user_p) {
-    if (chown(file, admin_uid, admin_gid) < 0) {
-      cop_log(COP_FATAL, "cop couldn't chown the file: '%s' for '%s' (%d/%d) : [%d] %s\n",
-              file, admin_user, admin_uid, admin_gid, errno, strerror(errno));
-    }
-  }
-}
-
-static void
-sig_child(int signum)
-{
-  pid_t pid = 0;
-  int status = 0;
-
-  cop_log_trace("Entering sig_child(%d)\n", signum);
-  for (;;) {
-    pid = waitpid(WAIT_ANY, &status, WNOHANG);
-
-    if (pid <= 0) {
-      break;
-    }
-    // TSqa03086 - We can not log the child status signal from
-    //   the signal handler since syslog can deadlock.  Record
-    //   the pid and the status in a global for logging
-    //   next time through the event loop.  We will occasionally
-    //   lose some information if we get two sig childs in rapid
-    //   succession
-    child_pid = pid;
-    child_status = status;
-  }
-  cop_log_trace("Leaving sig_child(%d)\n", signum);
-}
-
-static void
-sig_term(int signum)
-{
-  pid_t pid = 0;
-  int status = 0;
-
-  //killsig = SIGTERM;
-
-  cop_log_trace("Entering sig_term(%d)\n", signum);
-
-  // safely^W commit suicide.
-  cop_log_trace("Sending signal %d to entire group\n", signum);
-  killpg(0, signum);
-  
-  cop_log_trace("Waiting for children to exit.");
-
-  for (;;) {
-    pid = waitpid(WAIT_ANY, &status, WNOHANG);
-
-    if (pid <= 0) {
-      break;
-    }
-    // TSqa03086 - We can not log the child status signal from
-    //   the signal handler since syslog can deadlock.  Record
-    //   the pid and the status in a global for logging
-    //   next time through the event loop.  We will occasionally
-    //   lose some information if we get two sig childs in rapid
-    //   succession
-    child_pid = pid;
-    child_status = status;
-  }
-  cop_log_trace("Leaving sig_term(%d), exiting traffic_cop\n", signum);
-  exit(0);
-}
-
-static void
-#if defined(solaris)
-sig_fatal(int signum, siginfo_t * t, void *c)
-#else
-sig_fatal(int signum)
-#endif
-{
-  cop_log_trace("Entering sig_fatal(%d)\n", signum);
-#if defined(solaris)
-  if (t) {
-    if (t->si_code <= 0) {
-      cop_log(COP_FATAL, "cop received fatal user signal [%d] from"
-              " pid [%d] uid [%d]\n", signum, (int)(t->si_pid), t->si_uid);
-    } else {
-      cop_log(COP_FATAL, "cop received fatal kernel signal [%d], " "reason [%d]\n", signum, t->si_code);
-    }
-  } else {
-#endif
-    cop_log(COP_FATAL, "cop received fatal signal [%d]\n", signum);
-#if defined(solaris)
-  }
-#endif
-  cop_log_trace("Leaving sig_fatal(%d)\n", signum);
-  abort();
-}
-
-static void
-#if defined(solaris)
-sig_alarm_warn(int signum, siginfo_t * t, void *c)
-#else
-sig_alarm_warn(int signum)
-#endif
-{
-  cop_log_trace("Entering sig_alarm_warn(%d)\n", signum);
-  cop_log(COP_WARNING, "unable to kill traffic_server for the last" " %d seconds\n", kill_timeout);
-
-  // Set us up for another alarm
-  alarm(kill_timeout);
-  cop_log_trace("Leaving sig_alarm_warn(%d)\n", signum);
-}
-
-static void
-sig_ignore(int signum)
-{
-  cop_log_trace("Entering sig_ignore(%d)\n", signum);
-  // No code here yet...
-  cop_log_trace("Leaving sig_ignore(%d)\n", signum);
-}
-
-static void
-set_alarm_death()
-{
-  struct sigaction action;
-
-  cop_log_trace("Entering set_alarm_death()\n");
-#if defined(solaris)
-  action.sa_handler = NULL;
-  action.sa_sigaction = sig_fatal;
-  sigemptyset(&action.sa_mask);
-  action.sa_flags = SA_SIGINFO;
-#else
-  action.sa_handler = sig_fatal;
-  sigemptyset(&action.sa_mask);
-  action.sa_flags = 0;
-#endif
-
-  sigaction(SIGALRM, &action, NULL);
-  cop_log_trace("Leaving set_alarm_death()\n");
-}
-
-static void
-set_alarm_warn()
-{
-  struct sigaction action;
-
-  cop_log_trace("Entering set_alarm_warn()\n");
-#if defined(solaris)
-  action.sa_handler = NULL;
-  action.sa_sigaction = sig_alarm_warn;
-  sigemptyset(&action.sa_mask);
-  action.sa_flags = SA_SIGINFO;
-#else
-  action.sa_handler = sig_alarm_warn;
-  sigemptyset(&action.sa_mask);
-  action.sa_flags = 0;
-#endif
-
-  sigaction(SIGALRM, &action, NULL);
-  cop_log_trace("Leaving set_alarm_warn()\n");
-
-}
-
-static void
-process_syslog_config(void)
-{
-  int new_fac;
-
-  cop_log_trace("Entering process_syslog_config()\n");
-  new_fac = facility_string_to_int(syslog_fac_str);
-
-  if (new_fac >= 0 && new_fac != syslog_facility) {
-    closelog();
-    openlog("traffic_cop", LOG_PID | LOG_NDELAY | LOG_NOWAIT, new_fac);
-    syslog_facility = new_fac;
-  }
-  cop_log_trace("Leaving process_syslog_config()\n");
-}
-
-// Paranoia: wrap the process termination call within alarms
-//           so that when the killing call doesn't return we
-//           will still wake up
-static void
-safe_kill(const char *lockfile_name, const char *pname, bool group)
-{
-  Lockfile lockfile(lockfile_name);
-  chown_file_to_admin_user(lockfile_name);
-
-  cop_log_trace("Entering safe_kill(%s, %s, %d)\n", lockfile_name, pname, group);
-  set_alarm_warn();
-  alarm(kill_timeout);
-
-  if (group == true) {
-    lockfile.KillGroup(killsig, coresig, pname);
-  } else {
-    lockfile.Kill(killsig, coresig, pname);
-  }
-  chown_file_to_admin_user(lockfile_name);
-
-  alarm(0);
-  set_alarm_death();
-  cop_log_trace("Leaving safe_kill(%s, %s, %d)\n", lockfile_name, pname, group);
-}
-
-
-// ink_hrtime milliseconds()
-//
-// Returns the result of gettimeofday converted to
-// one 64bit int
-//
-static ink_hrtime
-milliseconds(void)
-{
-  struct timeval curTime;
-
-  cop_log_trace("Entering milliseconds()\n");
-  ink_gethrtimeofday(&curTime, NULL);
-  // Make liberal use of casting to ink_hrtime to ensure the
-  //  compiler does not truncate our result
-  cop_log_trace("Leaving milliseconds()\n");
-  return ((ink_hrtime) curTime.tv_sec * 1000) + ((ink_hrtime) curTime.tv_usec / 1000);
-}
-
-static void
-millisleep(int ms)
-{
-  struct timespec ts;
-
-  cop_log_trace("Entering millisleep(%d)\n", ms);
-  ts.tv_sec = ms / 1000;
-  ts.tv_nsec = (ms - ts.tv_sec * 1000) * 1000 * 1000;
-  nanosleep(&ts, NULL);
-  cop_log_trace("Leaving millisleep(%d)\n", ms);
-}
-
-static bool
-transient_error(int error, int wait_ms)
-{
-  cop_log_trace("Entering transient_error(%d, %d)\n", error, wait_ms);
-
-  // switch cases originally from UnixNex::accept_error_seriousness()
-  switch (error) {
-  case EAGAIN:
-  case EINTR:
-    break;
-
-  case ENFILE:
-  case EMFILE:
-  case ENOMEM:
-#ifdef ENOBUFS
-  case ENOBUFS:
-#endif
-#if defined(ENOSR) && !defined(freebsd) && !defined(darwin)
-  case ENOSR:
-#endif
-    if (wait_ms)
-      millisleep(wait_ms);
-    break;
-
-  default:
-    cop_log_trace("Leaving transient_error(%d, %d) --> false\n", error, wait_ms);
-    return false;
-  }
-  cop_log_trace("Leaving transient_error(%d, %d) --> true\n", error, wait_ms);
-  return true;
-}
-
-static void
-config_register_variable(RecT rec_type, RecDataT data_type, const char * name, const char * value, bool /* inc_version */)
-{
-  configTable.insert(std::make_pair(std::string(name), ConfigValue(rec_type, data_type, value)));
-}
-
-static void
-config_read_string(const char *name, char *val, size_t val_len, bool miss_ok = false)
-{
-  ConfigValueTable::const_iterator config;
-
-  config = configTable.find(name);
-  if (config == configTable.end()) {
-    if (miss_ok)
-      return;
-    else
-      goto ConfigStrFatalError;
-  }
-
-  if (config->second.data_type != RECD_STRING) {
-    goto ConfigStrFatalError;
-  }
-
-  ink_strlcpy(val, RecConfigOverrideFromEnvironment(name, config->second.data_value.c_str()), val_len);
-  return;
-
-ConfigStrFatalError:
-  cop_log(COP_FATAL, "could not find string variable %s in records.config\n", name);
-  exit(1);
-}
-
-static void
-config_read_int(const char *name, int *val, bool miss_ok = false)
-{
-  ConfigValueTable::const_iterator config;
-
-  config = configTable.find(name);
-  if (config == configTable.end()) {
-    if (miss_ok)
-      return;
-    else
-      goto ConfigIntFatalError;
-  }
-
-  if (config->second.data_type != RECD_INT) {
-    goto ConfigIntFatalError;
-  }
-
-  *val = atoi(RecConfigOverrideFromEnvironment(name, config->second.data_value.c_str()));
-  return;
-
-ConfigIntFatalError:
-  cop_log(COP_FATAL, "could not find integer variable %s in records.config\n", name);
-  exit(1);
-}
-
-static void
-config_reload_records()
-{
-  struct stat stat_buf;
-  static time_t last_mod = 0;
-  char log_dir[PATH_NAME_MAX];
-  char log_filename[PATH_NAME_MAX];
-  int tmp_int;
-
-  cop_log_trace("Entering %s()\n", __func__);
-  // coverity[fs_check_call]
-  if (stat(config_file, &stat_buf) == -1) {
-    cop_log(COP_FATAL, "could not stat \"%s\"\n", config_file);
-    exit(1);
-  }
-
-  if (stat_buf.st_mtime <= last_mod) {  // no change, no need to re-read
-    return;
-  } else {
-    last_mod = stat_buf.st_mtime;
-  }
-
-  configTable.clear();
-
-  if (RecConfigFileParse(config_file, config_register_variable, false) != REC_ERR_OKAY) {
-    cop_log(COP_FATAL, "could not parse \"%s\"\n", config_file);
-    exit(1);
-  }
-
-  config_read_string("proxy.config.manager_binary", manager_binary, sizeof(manager_binary), true);
-  config_read_string("proxy.config.proxy_binary", server_binary, sizeof(server_binary), true);
-  get_admin_user();
-
-  config_read_string("proxy.config.bin_path", bin_path, sizeof(bin_path), true);
-  Layout::get()->relative(bin_path, sizeof(bin_path), bin_path);
-  if (access(bin_path, R_OK) == -1) {
-    ink_strlcpy(bin_path, Layout::get()->bindir, sizeof(bin_path));
-    if (access(bin_path, R_OK) == -1) {
-      cop_log(COP_FATAL, "could not access() \"%s\"\n", bin_path);
-      cop_log(COP_FATAL, "please set 'proxy.config.bin_path' \n");
-      exit(1);
-    }
-  }
-  config_read_string("proxy.config.log.logfile_dir", log_dir, sizeof(log_dir));
-  Layout::get()->relative(log_dir, sizeof(log_dir), log_dir);
-  if (access(log_dir, W_OK) == -1) {
-    ink_strlcpy(log_dir, Layout::get()->logdir, sizeof(log_dir));
-    if (access(log_dir, W_OK) == -1) {
-      cop_log(COP_FATAL, "could not access() \"%s\"\n", log_dir);
-      cop_log(COP_FATAL, "please set 'proxy.config.log.logfile_dir' \n");
-      exit(1);
-    }
-  }
-  config_read_string("proxy.config.output.logfile", log_filename, sizeof(log_filename));
-  Layout::relative_to(log_file, sizeof(log_file), log_dir, log_filename);
-  config_read_int("proxy.config.process_manager.mgmt_port", &http_backdoor_port, true);
-  config_read_int("proxy.config.admin.autoconf_port", &autoconf_port, true);
-  config_read_int("proxy.config.cluster.rsport", &rs_port, true);
-  config_read_int("proxy.config.lm.sem_id", &sem_id, true);
-
-#if defined(linux)
-  // TS-1075 : auto-port ::connect DoS on high traffic linux systems
-  config_read_int("proxy.config.cop.source_port", &source_port, true);
-#endif
-
-  config_read_int("proxy.local.cluster.type", &tmp_int);
-  cluster_type = static_cast<MgmtClusterType>(tmp_int);
-
-  config_read_string("proxy.config.syslog_facility", syslog_fac_str, sizeof(syslog_fac_str), true);
-  process_syslog_config();
-  config_read_int("proxy.config.cop.core_signal", &coresig, true);
-
-  config_read_int("proxy.config.cop.linux_min_swapfree_kb", &check_memory_min_swapfree_kb, true);
-  config_read_int("proxy.config.cop.linux_min_memfree_kb", &check_memory_min_memfree_kb, true);
-
-  cop_log_trace("Leaving %s()\n", __func__);
-}
-
-static void
-get_admin_user()
-{
-  struct passwd *pwd = NULL;
-
-  if (!admin_user)
-    admin_user = (char *)ats_malloc(MAX_LOGIN);
-
-  config_read_string("proxy.config.admin.user_id", admin_user, MAX_LOGIN);
-
-  if (*admin_user) {
-    char *end = admin_user + strlen(admin_user) - 1;
-
-    // Trim trailing spaces.
-    while (end >= admin_user && isspace(*end))
-      end--;
-    *(end + 1) = '\0';
-
-    if (*admin_user == '#') {
-      int uid = atoi(admin_user + 1);
-      if (uid == -1) {
-        // XXX: Can this call hapen after setuid?
-        uid = (int)geteuid();
-      }
-      pwd = getpwuid((uid_t)uid);
-    } else {
-      pwd = getpwnam(admin_user);
-    }
-
-    if (pwd) {
-      admin_uid = pwd->pw_uid;
-      admin_gid = pwd->pw_gid;
-      admin_user_p = true;
-    } else {
-      cop_log(COP_FATAL, "can't get passwd entry for the admin user '%s' - [%d] %s\n", admin_user, errno, strerror(errno));
-      exit(1);
-    }
-  }
-}
-
-static void
-spawn_manager()
-{
-  char prog[PATH_NAME_MAX];
-  char *options[OPTIONS_MAX];
-  char *last;
-  char *tok;
-  int log_fd;
-  int err;
-  int key;
-
-  cop_log_trace("Entering spawn_manager()\n");
-  // Clean up shared memory segments.
-  if (sem_id > 0) {
-    key = sem_id;
-  } else {
-    key = 11452;
-  }
-  for (;; key++) {
-    err = semget(key, 1, 0666);
-    if (err < 0) {
-      break;
-    }
-#if defined(solaris) || defined(kfreebsd) || defined(unknown)
-    err = semctl(err, 1, IPC_RMID);
-#else
-    union semun dummy_semun;
-    memset(&dummy_semun, 0, sizeof(dummy_semun));
-    err = semctl(err, 1, IPC_RMID, dummy_semun);
-#endif
-    if (err < 0) {
-      break;
-    }
-  }
-
-  Layout::relative_to(prog, sizeof(prog), bin_path, manager_binary);
-  if (access(prog, R_OK | X_OK) == -1) {
-    cop_log(COP_FATAL, "unable to access() manager binary \"%s\" [%d '%s']\n", prog, errno, strerror(errno));
-    exit(1);
-  }
-
-  cop_log_trace("spawn_manager: Launching %s with options '%s'\n", prog, manager_options);
-  int i;
-  for (i = 0; i < OPTIONS_MAX; i++) {
-    options[i] = NULL;
-  }
-  options[0] = prog;
-  i = 1;
-  tok = strtok_r(manager_options, " ", &last);
-  options[i++] = tok;
-  if (tok != NULL) {
-    while (i < OPTIONS_MAX && (tok = strtok_r(NULL, " ", &last))) {
-      options[i++] = tok;
-    }
-  }
-
-  // Move any traffic.out that we can not write to, out
-  //  of the way (TSqa2232)
-  // coverity[fs_check_call]
-  if (access(log_file, W_OK) < 0 && errno == EACCES) {
-    char old_log_file[PATH_NAME_MAX];
-    snprintf(old_log_file, sizeof(old_log_file), "%s.old", log_file);
-    // coverity[toctou]
-    rename(log_file, old_log_file);
-    cop_log(COP_WARNING, "rename %s to %s as it is not accessible.\n", log_file, old_log_file);
-  }
-  // coverity[toctou]
-  if ((log_fd = open(log_file, O_WRONLY | O_APPEND | O_CREAT, 0640)) < 0) {
-    cop_log(COP_WARNING, "unable to open log file \"%s\" [%d '%s']\n", log_file, errno, strerror(errno));
-  }
-
-  err = fork();
-  if (err == 0) {
-    if (log_fd >= 0) {
-      dup2(log_fd, STDOUT_FILENO);
-      dup2(log_fd, STDERR_FILENO);
-      close(log_fd);
-    }
-
-    err = execv(prog, options);
-    cop_log_trace("Somehow execv(%s, options, NULL) failed (%d)!\n", prog, err);
-    exit(1);
-  } else if (err == -1) {
-    cop_log(COP_FATAL, "unable to fork [%d '%s']\n", errno, strerror(errno));
-    exit(1);
-  } else {
-    close(log_fd);
-  }
-
-  manager_failures = 0;
-  cop_log_trace("Leaving spawn_manager()\n");
-}
-
-
-static int
-poll_read_or_write(int fd, int timeout, int inorout)
-{
-  struct pollfd info;
-  int err;
-
-  info.fd = fd;
-  info.events = inorout;
-  info.revents = 0;
-
-  do {
-    err = poll(&info, 1, timeout);
-  } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
-  if ((err > 0) && (info.revents & inorout)) {
-    return 1;
-  }
-
-  return err;
-}
-
-inline static int
-poll_read(int fd, int timeout)
-{
-  return poll_read_or_write(fd, timeout, POLLIN);
-}
-
-inline static int
-poll_write(int fd, int timeout)
-{
-  return poll_read_or_write(fd, timeout, POLLOUT);
-}
-
-static int
-open_socket(int port, const char *ip = NULL, char const *ip_to_bind = NULL)
-{
-
-  int sock = 0;
-  struct addrinfo hints;
-  struct addrinfo *result = NULL;
-  struct addrinfo *result_to_bind = NULL;
-  char port_str[8] = {'\0'};
-  int err = 0;
-
-  cop_log_trace("Entering open_socket(%d, %s, %s)\n", port, ip, ip_to_bind);
-  if (!ip) {
-    ip = localhost;
-  }
-
-#if defined(linux)
-  // TS-1075 : auto-port ::connect DoS on high traffic linux systems
-  // unbound connections are "unsafe" in high connection count environments
-  if (!ip_to_bind) {
-    ip = localhost;
-  }
-#endif
-
-  snprintf(port_str, sizeof(port_str), "%d", port);
-  memset(&hints, 0, sizeof(hints));
-  hints.ai_family = AF_UNSPEC;
-  hints.ai_socktype = SOCK_STREAM;
-
-  err = getaddrinfo(ip, port_str, &hints, &result);
-  if (err != 0) {
-    cop_log (COP_WARNING, "(test) unable to get address info [%d %s] at ip %s, port %s\n", err, gai_strerror(err), ip, port_str);
-    goto getaddrinfo_error;
-  }
-
-  // Create a socket
-  do {
-    sock = socket(result->ai_family, result->ai_socktype, 0);
-  } while ((sock < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
-  if (sock < 0) {
-    cop_log(COP_WARNING, "(test) unable to create socket [%d '%s']\n", errno, strerror(errno));
-    goto error;
-  }
-
-  if (ip_to_bind) {
-    memset(&hints, 0, sizeof(hints));
-    hints.ai_family = result->ai_family;
-    hints.ai_socktype = result->ai_socktype;
-
-    err = getaddrinfo(ip_to_bind, NULL, &hints, &result_to_bind);
-    if (err != 0) {
-      cop_log (COP_WARNING, "(test) unable to get address info [%d %s] at ip %s\n", err, gai_strerror(err), ip_to_bind);
-      freeaddrinfo(result_to_bind);
-      goto error;
-    }
-
-#if defined(linux)
-    // TS-1075 : auto-port ::connect DoS on high traffic linux systems
-    // Bash the port on ::bind so that we always use the same port
-    if (0 != source_port) {
-      if (result_to_bind->ai_addr->sa_family == AF_INET) {
-        ((sockaddr_in *)result_to_bind->ai_addr)->sin_port = htons(source_port);
-      } else {
-        ((sockaddr_in6 *)result_to_bind->ai_addr)->sin6_port = htons(source_port);
-      }
-
-      // also set REUSEADDR so that previous cop connections in the TIME_WAIT state
-      // do not interfere
-      if (safe_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, SOCKOPT_ON, sizeof(int)) < 0) {
-        cop_log (COP_WARNING, "(test) unable to set REUSEADDR socket option [%d '%s']\n", errno, strerror (errno));
-      }
-    }
-#endif
-
-    if (safe_bind(sock, result_to_bind->ai_addr, result_to_bind->ai_addrlen) < 0) {
-      cop_log (COP_WARNING, "(test) unable to bind socket [%d '%s']\n", errno, strerror (errno));
-    }
-
-    freeaddrinfo(result_to_bind);
-  }
-
-  // Put the socket in non-blocking mode...just to be extra careful
-  // that we never block.
-  do {
-    err = fcntl(sock, F_SETFL, O_NONBLOCK);
-  } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
-  if (err < 0) {
-    cop_log(COP_WARNING, "(test) unable to put socket in non-blocking mode [%d '%s']\n", errno, strerror(errno));
-    goto error;
-  }
-  // Connect to the specified port on the machine we're running on.
-  do {
-    err = connect(sock, result->ai_addr, result->ai_addrlen);
-  } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
-  if ((err < 0) && (errno != EINPROGRESS)) {
-    cop_log(COP_WARNING, "(test) unable to connect to server [%d '%s'] at port %d\n", errno, strerror(errno), port);
-    goto error;
-  }
-  cop_log_trace("Leaving open_socket(%d, %s, %s) --> %d\n", port, ip, ip_to_bind, sock);
-  freeaddrinfo(result);
-  return sock;
-
-error:
-  if (sock >= 0) {
-    close_socket(sock);
-  }
-  cop_log_trace("Leaving open_socket(%d, %s, %s) --> %d\n", port, ip, ip_to_bind, -1);
-getaddrinfo_error:
-  freeaddrinfo(result);
-  return -1;
-}
-
-static int
-test_port(int port, const char *request, char *buffer, int bufsize,
-          int64_t test_timeout, char const *ip = NULL, char const *ip_to_bind = NULL)
-{
-  int64_t start_time, timeout;
-  int sock;
-  size_t length = strlen(request);
-  int64_t err, idx;
-
-  start_time = milliseconds();
-
-  sock = open_socket(port, ip, ip_to_bind);
-  if (sock < 0) {
-    goto error;
-  }
-
-  timeout = milliseconds() - start_time;
-  if (timeout >= test_timeout) {
-    cop_log(COP_WARNING, "(test) timeout occurred [%" PRId64 " ms]\n", timeout);
-    goto error;
-  }
-  timeout = test_timeout - timeout;
-
-  err = poll_write(sock, timeout);
-  if (err < 0) {
-    cop_log(COP_WARNING, "(test) poll write failed [%d '%s']\n", errno, strerror(errno));
-    goto error;
-  } else if (err == 0) {
-    cop_log(COP_WARNING, "(test) write timeout [%" PRId64 " ms]\n", timeout);
-    goto error;
-  }
-  // Write the request to the server.
-  while (length > 0) {
-    do {
-      err = write(sock, request, length);
-    } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
-    if (err < 0) {
-      cop_log(COP_WARNING, "(test) write failed [%d '%s']\n", errno, strerror(errno));
-      goto error;
-    }
-
-    request += err;
-    length -= err;
-  }
-
-  idx = 0;
-  for (;;) {
-    if (idx >= bufsize) {
-      cop_log(COP_WARNING, "(test) response is too large [%" PRId64 "]\n", idx);
-      goto error;
-    }
-
-    timeout = milliseconds() - start_time;
-    if (timeout >= test_timeout) {
-      cop_log(COP_WARNING, "(test) timeout occurred [%" PRId64 " ms]\n", timeout);
-      goto error;
-    }
-    timeout = test_timeout - timeout;
-
-    err = poll_read(sock, timeout);
-    if (err < 0) {
-      cop_log(COP_WARNING, "(test) poll read failed [%d '%s']\n", errno, strerror(errno));
-      goto error;
-    } else if (err == 0) {
-      cop_log(COP_WARNING, "(test) read timeout [%" PRId64 " ]\n", timeout);
-      goto error;
-    }
-
-    do {
-      err = read(sock, &buffer[idx], bufsize - idx);
-    } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
-    if (err < 0) {
-      cop_log(COP_WARNING, "(test) read failed [%d '%s']\n", errno, strerror(errno));
-      goto error;
-    } else if (err == 0) {
-      buffer[idx] = '\0';
-      close(sock);
-      return 0;
-    } else {
-      idx += err;
-    }
-  }
-
-error:
-  if (sock >= 0) {
-    close_socket(sock);
-  }
-  return -1;
-}
-
-static int
-read_manager_string(const char *variable, char *value, size_t val_len)
-{
-  char buffer[4096];
-  char request[1024];
-  char *p, *e;
-  int err;
-
-  snprintf(request, sizeof(request), "read %s\n", variable);
-
-  err = test_port(rs_port, request, buffer, 4095, manager_timeout * 1000);
-  if (err < 0) {
-    return err;
-  }
-
-  p = strstr(buffer, variable);
-  if (!p) {
-    cop_log(COP_WARNING, "(manager test) could not find record name in response\n");
-    return -1;
-  }
-  p += strlen(variable);
-
-  p = strstr(p, "Val:");
-  if (!p) {
-    cop_log(COP_WARNING, "(manager test) could not find record value in response\n");
-    return -1;
-  }
-  p += sizeof("Val:") - 1;
-
-  while (*p && (*p != '\'')) {
-    p += 1;
-  }
-
-  if (*p == '\0') {
-    cop_log(COP_WARNING, "(manager test) could not find properly delimited value in response\n");
-    return -1;
-  }
-  p += 1;
-
-  e = p;
-  while (*e && (*e != '\'')) {
-    e += 1;
-  }
-
-  if (*e != '\'') {
-    cop_log(COP_WARNING, "(manager test) could not find properly delimited value in response\n");
-    return -1;
-  }
-
-  ink_strlcpy(value, p, MIN((size_t)(e - p + 1), val_len));
-
-  return 0;
-}
-
-static int
-read_manager_int(const char *variable, int *value)
-{
-  char buffer[4096];
-  char request[1024];
-  char *p;
-  int err;
-
-  snprintf(request, sizeof(request), "read %s\n", variable);
-
-  err = test_port(rs_port, request, buffer, 4095, manager_timeout * 1000);
-  if (err < 0) {
-    return err;
-  }
-
-  p = strstr(buffer, variable);
-  if (!p) {
-    cop_log(COP_WARNING, "(manager test) could not find record name in response\n");
-    return -1;
-  }
-  p += strlen(variable);
-
-  p = strstr(p, "Val:");
-  if (!p) {
-    cop_log(COP_WARNING, "(manager test) could not find record value in response\n");
-    return -1;
-  }
-  p += sizeof("Val:") - 1;
-
-  while (*p && (*p != '\'')) {
-    p += 1;
-  }
-
-  if (*p == '\0') {
-    cop_log(COP_WARNING, "(manager test) could not find properly delimited value in response\n");
-    return -1;
-  }
-  p += 1;
-
-  *value = 0;
-  while (isdigit(*p)) {
-    *value = *value * 10 + (*p - '0');
-    p += 1;
-  }
-
-  if (*p != '\'') {
-    cop_log(COP_WARNING, "(manager test) could not find properly delimited value in response\n");
-    return -1;
-  }
-  return 0;
-}
-
-static int
-read_mgmt_cli_int(const char *variable, int *value)
-{
-  TSInt val;
-
-  if (TSRecordGetInt(variable, &val) != TS_ERR_OKAY) {
-    cop_log(COP_WARNING, "(cli test) could not communicate with mgmt cli\n");
-    return -1;
-  }
-  *value = val;
-  return 0;
-}
-
-
-static int
-test_rs_port()
-{
-  char buffer[4096];
-  int err;
-
-  err = read_manager_string("proxy.config.manager_binary", buffer, sizeof(buffer));
-  if (err < 0) {
-    return err;
-  }
-
-  if (strcmp(buffer, manager_binary) != 0) {
-    cop_log(COP_WARNING, "(manager test) bad response value\n");
-    return -1;
-  }
-
-  return 0;
-}
-
-
-static int
-test_mgmt_cli_port()
-{
-  TSString val = NULL;
-  int ret = 0;
-
-  if (TSRecordGetString("proxy.config.manager_binary", &val) !=  TS_ERR_OKAY) {
-    cop_log(COP_WARNING, "(cli test) unable to retrieve manager_binary\n");
-    ret = -1;
-  } else {
-    if (strcmp(val, manager_binary) != 0) {
-      cop_log(COP_WARNING, "(cli test) bad response value, got %s, expected %s\n", val, manager_binary);
-      ret = -1;
-    }
-  }
-
-  if (val)
-    TSfree(val);
-  return ret;
-}
-
-
-static int
-test_http_port(int port, char *request, int timeout, char const *ip = NULL, char const *ip_to_bind = NULL)
-{
-  char buffer[4096];
-  char *p;
-  int err;
-
-  err = test_port(port, request, buffer, 4095, timeout, ip, ip_to_bind);
-  if (err < 0) {
-    return err;
-  }
-
-  p = buffer;
-
-  if (strncmp(p, "HTTP/", 5) != 0) {
-    cop_log(COP_WARNING, "(http test) received malformed response\n");
-    return -1;
-  }
-
-  p += 5;
-  while (*p && !isspace(*p)) {
-    p += 1;
-  }
-
-  while (*p && isspace(*p)) {
-    p += 1;
-  }
-
-  if (strncmp(p, "200", 3) != 0) {
-    char pstatus[4] = { 0 };
-    ink_strlcpy(pstatus, p, sizeof(pstatus));
-    cop_log(COP_WARNING, "(http test) received non-200 status(%s)\n", pstatus);
-    return -1;
-  }
-
-  p = strstr(p, "\r\n\r\n");
-  if (!p) {
-    cop_log(COP_WARNING, "(http test) could not find end of header\n");
-    return -1;
-  }
-
-  p += 4;
-  while (*p) {
-    if (strncmp(p, "abcdefghijklmnopqrstuvwxyz", 26) != 0) {
-      cop_log(COP_WARNING, "(http test) corrupted response data\n");
-      return -1;
-    }
-
-    p += 26;
-    while (*p && (*p != '\n')) {
-      p += 1;
-    }
-    p += 1;
-  }
-
-  return 0;
-}
-
-static int
-test_server_http_port()
-{
-  char request[1024] = {'\0'};
-
-  // Generate a request for a the 'synthetic.txt' document the manager
-  // servers up on the autoconf port.
-  snprintf(request, sizeof(request), "GET http://127.0.0.1:%d/synthetic.txt HTTP/1.0\r\n\r\n", autoconf_port);
-
-  return test_http_port(http_backdoor_port, request, server_timeout * 1000, localhost, localhost);
-}
-
-static int
-heartbeat_manager()
-{
-  int err;
-
-  cop_log_trace("Entering heartbeat_manager()\n");
-  // the CLI, and the rsport if cluster is enabled.
-  err = test_mgmt_cli_port();
-  if ((0 == err) && (cluster_type != NO_CLUSTER))
-    err = test_rs_port();
-
-  if (err < 0) {
-    // See heartbeat_server()'s comments for how we determine a server/manager failure.
-    manager_failures += 1;
-    cop_log(COP_WARNING, "manager heartbeat [variable] failed [%d]\n", manager_failures);
-
-    if (manager_failures > 1) {
-      manager_failures = 0;
-      cop_log(COP_WARNING, "killing manager\n");
-      safe_kill(manager_lockfile, manager_binary, true);
-    }
-    cop_log_trace("Leaving heartbeat_manager() --> %d\n", err);
-    return err;
-  }
-
-  cop_log_trace("Leaving heartbeat_manager() --> %d\n", err);
-  return err;
-}
-
-static int
-heartbeat_server()
-{
-  int err;
-
-  cop_log_trace("Entering heartbeat_server()\n");
-  err = test_server_http_port();
-
-  if (err < 0) {
-    // If the test failed, increment the count of the number of
-    // failures. We don't kill the server the first time the test
-    // fails because we might just have gotten caught in a race
-    // where we decided to do the test because we thought the
-    // server was up even though somebody was in the process of
-    // bringing it down. The "server_up" function will reset
-    // 'server_failures' if it determines the server is down.
-
-    server_failures += 1;
-    cop_log(COP_WARNING, "server heartbeat failed [%d]\n", server_failures);
-
-    // If this is the second time that the server test has failed
-    // we kill the server.
-    if (server_failures > 1) {
-      server_failures = 0;
-      cop_log(COP_WARNING, "killing server\n");
-
-      // TSqa02622: Change the ALRM signal handler while
-      //   trying to kill the process since if a core
-      //   is being written, it could take a long time
-      //   Set a new alarm so that we can print warnings
-      //   if it is taking too long to kill the server
-      //
-      safe_kill(server_lockfile, server_binary, false);
-    }
-  } else {
-    if (server_failures)
-      cop_log(COP_WARNING, "server heartbeat succeeded\n");
-    server_failures = 0;
-  }
-
-  cop_log_trace("Leaving heartbeat_server() --> %d\n", err);
-  return err;
-}
-
-static int
-server_up()
-{
-  static int old_val = 0;
-  int val = -1;
-  int err;
-
-  cop_log_trace("Entering server_up()\n");
-  if (cluster_type != NO_CLUSTER) {
-    err = read_manager_int("proxy.node.proxy_running", &val);
-  } else {
-    err = read_mgmt_cli_int("proxy.node.proxy_running", &val);
-  }
-
-  if (err < 0) {
-    cop_log(COP_WARNING, "could not contact manager, assuming server is down\n");
-    cop_log_trace("Leaving server_up() --> 0\n");
-    return 0;
-  }
-
-  if (val != old_val) {
-    server_failures = 0;
-    server_not_found = 0;
-    old_val = val;
-  }
-
-  if (val == 1) {
-    cop_log_trace("Leaving server_up() --> 1\n");
-    return 1;
-  } else {
-    cop_log_trace("Leaving server_up() --> 0\n");
-    return 0;
-  }
-}
-
-
-//         |  state  |  status  |  action
-// --------|---------|----------|---------------
-// manager |   up    |    ok    |  nothing
-// server  |   up    |    ok    |
-// --------|---------|----------|---------------
-// manager |   up    |    bad   |  kill manager
-// server  |   up    |    ?     |
-// --------|---------|----------|---------------
-// manager |   up    |    ok    |  kill manager
-// server  |   down  |    ?     |
-// --------|---------|----------|---------------
-// manager |   up    |    ok    |  kill server
-// server  |   up    |    bad   |
-
-
-static void
-check_programs()
-{
-  int err;
-  pid_t holding_pid;
-
-  cop_log_trace("Entering check_programs()\n");
-
-  // Try to get the manager lock file. If we succeed in doing this,
-  // it means there is no manager running.
-  Lockfile manager_lf(manager_lockfile);
-  err = manager_lf.Open(&holding_pid);
-  chown_file_to_admin_user(manager_lockfile);
-
-  if (err > 0) {
-    // 'lockfile_open' returns the file descriptor of the opened
-    // lockfile.  We need to close this before spawning the
-    // manager so that the manager can grab the lock.
-    manager_lf.Close();
-
-#if !defined(MANAGER_FLAP_DETECTION)
-    // Make sure we don't have a stray traffic server running.
-    cop_log(COP_WARNING, "traffic_manager not running, making sure traffic_server is dead\n");
-    safe_kill(server_lockfile, server_binary, false);
-    // Spawn the manager.
-    cop_log(COP_WARNING, "spawning traffic_manager\n");
-    spawn_manager();
-#else
-    // Make sure we don't have a stray traffic server running.
-    if (!manager_flapping) {
-      cop_log(COP_WARNING, "traffic_manager not running, making sure traffic_server is dead\n");
-      safe_kill(server_lockfile, server_binary, false);
-    }
-    // Spawn the manager (check for flapping manager too)
-    ink_hrtime now = milliseconds();
-    if (!manager_flapping) {
-      if ((manager_flap_interval_start_time == 0) ||
-          (now - manager_flap_interval_start_time > MANAGER_FLAP_INTERVAL_MSEC)
-        ) {
-        // either:
-        // . it's our first time through
-        // . we were flapping a while ago, but we would
-        //   like to retry now
-        // . it's been a while since we last tried to start
-        //   traffic_manager
-        manager_flap_count = 0;
-      }
-      if (manager_flap_count >= MANAGER_MAX_FLAP_COUNT) {
-        // we've flapped too many times, hold off for a while
-        cop_log(COP_WARNING, "unable to start traffic_manager, retrying in %d second(s)\n",
-                MANAGER_FLAP_RETRY_MSEC / 1000);
-        manager_flapping = true;
-        manager_flap_retry_start_time = now;
-      } else {
-        // try to spawn traffic_manager
-        cop_log(COP_WARNING, "spawning traffic_manager\n");
-        spawn_manager();
-        // track spawn attempt
-        if (manager_flap_count == 0) {
-          manager_flap_interval_start_time = now;
-        }
-        manager_flap_count++;
-      }
-    } else {
-      // we were flapping, take some time off and don't call
-      // spawn_manager
-      if (now - manager_flap_retry_start_time > MANAGER_FLAP_RETRY_MSEC) {
-        manager_flapping = false;
-        manager_flap_interval_start_time = 0;
-      }
-    }
-#endif
-  } else {
-    // If there is a manager running we want to heartbeat it to
-    // make sure it hasn't wedged. If the manager test succeeds we
-    // check to see if the server is up. (That is, it hasn't been
-    // brought down via the UI).  If the manager thinks the server
-    // is up, we make sure there is actually a server process
-    // running. If there is we test it.
-
-    alarm(2 * manager_timeout);
-    err = heartbeat_manager();
-    alarm(0);
-
-    if (err < 0) {
-      return;
-    }
-
-    if (server_up() <= 0) {
-      return;
-    }
-
-    Lockfile server_lf(server_lockfile);
-    err = server_lf.Open(&holding_pid);
-
-    if (err > 0) {
-      server_lf.Close();
-
-      server_not_found += 1;
-      cop_log(COP_WARNING, "cannot find traffic_server [%d]\n", server_not_found);
-
-      if (server_not_found > 1) {
-        server_not_found = 0;
-        cop_log(COP_WARNING, "killing manager\n");
-        safe_kill(manager_lockfile, manager_binary, true);
-      }
-    } else {
-      alarm(2 * server_timeout);
-      heartbeat_server();
-      alarm(0);
-    }
-  }
-  cop_log_trace("Leaving check_programs()\n");
-}
-
-static void
-check_memory()
-{
-  // TODO: We need to take care of other systems, ie bsd, solaris.
-  //    And we should try to summarize whether the swapping is really
-  //    putting the server under memory pressure. Or should we check
-  //    the process memory usage of the server & manager?
-  cop_log_trace("Entering check_memory()\n");
-#if defined(linux)
-  if (check_memory_min_swapfree_kb > 0 || check_memory_min_memfree_kb > 0) {
-    FILE *fp;
-    char buf[LINE_MAX];
-    long long memfree, swapfree, swapsize;
-    memfree = swapfree = swapsize = 0;
-    if ((fp = fopen("/proc/meminfo", "r"))) {
-      while (fgets(buf, sizeof buf, fp)) {
-        if (strncmp(buf, "MemFree:", sizeof "MemFree:" - 1) == 0)
-          memfree = strtoll(buf + sizeof "MemFree:" - 1, 0, 10);
-        else if (strncmp(buf, "SwapFree:", sizeof "SwapFree:" - 1) == 0)
-          swapfree = strtoll(buf + sizeof "SwapFree:" - 1, 0, 10);
-        else if (strncmp(buf, "SwapTotal:", sizeof "SwapTotal:" - 1) == 0)
-          swapsize = strtoll(buf + sizeof "SwapTotal:" - 1, 0, 10);
-      }
-      fclose(fp);
-      // simple heuristic for linux
-      //    swapsize swapfree memfree
-      // 1:    >0      low     high    (bad)
-      // 2:    >0      high    low     (okay)
-      // 3:    >0      low     low     (bad; covered by 1)
-      // 4:     0       0      high    (okay)
-      // 5:     0       0      low     (bad)
-      if ((swapsize != 0 && swapfree < check_memory_min_swapfree_kb) ||
-          (swapsize == 0 && memfree < check_memory_min_memfree_kb)) {
-        cop_log(COP_WARNING, "Low memory available (swap: %dkB, mem: %dkB)\n", (int) swapfree, (int) memfree);
-        cop_log(COP_WARNING, "Killing '%s' and '%s'\n", manager_binary, server_binary);
-        manager_failures = 0;
-        safe_kill(manager_lockfile, manager_binary, true);
-        server_failures = 0;
-        safe_kill(server_lockfile, server_binary, false);
-      }
-    } else {
-      cop_log(COP_WARNING, "Unable to open /proc/meminfo: %s\n", strerror(errno));
-    }
-  }
-#endif
-  cop_log_trace("Leaving check_memory()\n");
-}
-
-static int
-check_no_run()
-{
-  char path[PATH_NAME_MAX * 2];
-  struct stat info;
-  int err;
-
-  cop_log_trace("Entering check_no_run()\n");
-  snprintf(path, sizeof(path), "%s/no_cop", runtime_dir);
-
-  do {
-    err = stat(path, &info);
-  } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
-  if (err < 0) {
-    cop_log_trace("Leaving check_no_run() --> 0\n");
-    return 0;
-  }
-
-  cop_log(COP_WARNING, "encountered \"%s\" file...exiting\n", path);
-  cop_log_trace("Leaving check_no_run() --> -1\n");
-  return -1;
-}
-
-// Changed function from taking no argument and returning void
-// to taking a void* and returning a void*. The change was made
-// so that we can call ink_thread_create() on this function
-// in the case of running cop as a win32 service.
-static void*
-check(void *arg)
-{
-  bool mgmt_init = false;
-  cop_log_trace("Entering check()\n");
-
-  for (;;) {
-    // problems with the ownership of this file as root Make sure it is
-    // owned by the admin user
-    chown_file_to_admin_user(manager_lockfile);
-    chown_file_to_admin_user(server_lockfile);
-
-    alarm(2 * (sleep_time + manager_timeout * 2 + server_timeout));
-
-    if (check_no_run() < 0) {
-      break;
-    }
-    // Log any SIGCLD singals we received
-    if (child_pid > 0) {
-      if (WIFEXITED(child_status) == 0) {
-        // Child terminated abnormally
-        cop_log(COP_WARNING,
-                "cop received non-normal child status signal [%d %d]\n", child_pid, WEXITSTATUS(child_status));
-      } else {
-        // normal termination
-        cop_log(COP_WARNING, "cop received child status signal [%d %d]\n", child_pid, child_status);
-      }
-      if (WIFSIGNALED(child_status)) {
-        int sig = WTERMSIG(child_status);
-        cop_log(COP_WARNING, "child terminated due to signal %d: %s\n", sig, strsignal(sig));
-      }
-
-      child_pid = 0;
-      child_status = 0;
-    }
-
-    // Re-read the config file information
-    config_reload_records();
-
-    // Check to make sure the programs are running
-    check_programs();
-
-    // Check to see if we're running out of free memory
-    check_memory();
-
-    // Pause to catch our breath. (10 seconds).
-    // Use 'millisleep()' because normal 'sleep()' interferes with
-    // the SIGALRM signal which we use to heartbeat the cop.
-    millisleep(sleep_time * 1000);
-
-    // We do this after the first round of checks, since the first "check" will spawn traffic_manager
-    if (!mgmt_init) {
-      TSInit(Layout::get()->runtimedir, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS));
-      mgmt_init = true;
-    }
-  }
-
-  // Done with the mgmt API.
-  TSTerminate();
-
-  cop_log_trace("Leaving check()\n");
-  return arg;
-}
-
-
-static void
-check_lockfile()
-{
-  int err;
-  pid_t holding_pid;
-
-  cop_log_trace("Entering check_lockfile()\n");
-  Lockfile cop_lf(cop_lockfile);
-  err = cop_lf.Get(&holding_pid);
-  if (err < 0) {
-    cop_log(COP_WARNING, "periodic cop heartbeat couldn't open '%s' (errno %d)\n", cop_lockfile, -err);
-    exit(1);
-  } else if (err == 0) {
-    cop_log(COP_DEBUG, "periodic heartbeat successful, another cop still on duty\n");
-    exit(1);
-  }
-
-  cop_log(LOG_NOTICE, "--- Cop Starting [Version: %s] ---\n", appVersionInfo.FullVersionInfoStr);
-  cop_log_trace("Leaving check_lockfile()\n");
-}
-
-static void
-init_signals()
-{
-  struct sigaction action;
-
-  cop_log_trace("Entering init_signals()\n");
-  // Handle the SIGTERM and SIGINT signal:
-  // We kill the process group and wait() for all children
-  action.sa_handler = sig_term;
-  sigemptyset(&action.sa_mask);
-  action.sa_flags = 0;
-
-  sigaction(SIGTERM, &action, NULL);
-  sigaction(SIGINT, &action, NULL);
-
-  // Handle the SIGCHLD signal. We simply reap all children that
-  // die (which should only be spawned traffic_manager's).
-  action.sa_handler = sig_child;
-  sigemptyset(&action.sa_mask);
-  action.sa_flags = 0;
-
-  sigaction(SIGCHLD, &action, NULL);
-
-  // Handle a bunch of fatal signals. We simply call abort() when
-  // these signals arrive in order to generate a core. There is some
-  // difficulty with generating core files when linking with libthread
-  // under solaris.
-#if defined(solaris)
-  action.sa_handler = NULL;
-  action.sa_sigaction = sig_fatal;
-#else
-  action.sa_handler = sig_fatal;
-#endif
-  sigemptyset(&action.sa_mask);
-#if defined(solaris)
-  action.sa_flags = SA_SIGINFO;
-#else
-  action.sa_flags = 0;
-#endif
-
-  sigaction(SIGQUIT, &action, NULL);
-  sigaction(SIGILL, &action, NULL);
-  sigaction(SIGFPE, &action, NULL);
-  sigaction(SIGBUS, &action, NULL);
-  sigaction(SIGSEGV, &action, NULL);
-#if !defined(linux)
-  sigaction(SIGEMT, &action, NULL);
-  sigaction(SIGSYS, &action, NULL);
-#endif
-
-  // Handle the SIGALRM signal. We use this signal to make sure the
-  // cop never wedges. It gets reset every time through its loop. If
-  // the alarm ever expires we treat it as a fatal signal and dump
-  // core, secure in the knowledge we'll get restarted.
-  set_alarm_death();
-
-  action.sa_handler = sig_ignore;
-  sigemptyset(&action.sa_mask);
-  action.sa_flags = 0;
-
-  sigaction(SIGPIPE, &action, NULL);
-  cop_log_trace("Leaving init_signals()\n");
-}
-
-static void
-init_config_dir()
-{
-
-  struct stat info;
-
-  cop_log_trace("Entering init_config_dir()\n");
-
-  root_dir = Layout::get()->prefix;
-  runtime_dir = Layout::get()->runtimedir;
-  config_dir = Layout::get()->sysconfdir;
-
-  if (chdir(root_dir) < 0) {
-    cop_log(COP_FATAL, "unable to change to root directory \"%s\" [%d '%s']\n", root_dir, errno, strerror(errno));
-    cop_log(COP_FATAL," please set correct path in env variable TS_ROOT \n");
-    exit(1);
-  }
-
-  if (stat(config_dir, &info) < 0) {
-    cop_log(COP_FATAL, "unable to locate config directory '%s'\n",config_dir);
-    cop_log(COP_FATAL, " please try setting correct root path in env variable TS_ROOT \n");
-    exit(1);
-  }
-
-  if (stat(runtime_dir, &info) < 0) {
-    cop_log(COP_FATAL, "unable to locate local state directory '%s'\n",runtime_dir);
-    cop_log(COP_FATAL, " please try setting correct root path in either env variable TS_ROOT \n");
-    exit(1);
-  }
-  cop_log_trace("Leaving init_config_dir()\n");
-}
-
-static void
-init_lockfiles()
-{
-
-  cop_log_trace("Entering init_lockfiles()\n");
-  Layout::relative_to(cop_lockfile, sizeof(cop_lockfile), Layout::get()->runtimedir, COP_LOCK);
-  Layout::relative_to(manager_lockfile, sizeof(manager_lockfile), Layout::get()->runtimedir, MANAGER_LOCK);
-  Layout::relative_to(server_lockfile, sizeof(server_lockfile), Layout::get()->runtimedir, SERVER_LOCK);
-
-  cop_log_trace("Leaving init_lockfiles()\n");
-}
-
-inline static void
-init_syslog()
-{
-  openlog("traffic_cop", LOG_PID | LOG_NDELAY | LOG_NOWAIT, LOG_DAEMON);
-}
-
-static void
-init_config_file()
-{
-  struct stat info;
-
-  cop_log_trace("Entering init_config_file()\n");
-  Layout::relative_to(config_file, sizeof(config_file), config_dir, "records.config.shadow");
-  if (stat(config_file, &info) < 0) {
-    Layout::relative_to(config_file, sizeof(config_file), config_dir, "records.config");
-    if (stat(config_file, &info) < 0) {
-      cop_log(COP_FATAL, "unable to locate \"%s/records.config\" or \"%s/records.config.shadow\"\n", config_dir, config_dir);
-      exit(1);
-    }
-  }
-  cop_log_trace("Leaving init_config_file()\n");
-}
-
-static void
-init()
-{
-  cop_log_trace("Entering init()\n");
-
-  RecConfigFileInit();
-
-  init_signals();
-  init_syslog();
-
-  init_config_dir();
-
-  init_config_file();
-  init_lockfiles();
-  check_lockfile();
-
-  cop_log_trace("Leaving init()\n");
-}
-
-int version_flag = 0;
-
-int
-main(int argc, char *argv[])
-{
-  int fd;
-  appVersionInfo.setup(PACKAGE_NAME,"traffic_cop", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
-
-  // Before accessing file system initialize Layout engine
-  Layout::create();
-
-  for (int i = 1; i < argc; i++) {
-    if (strcmp(argv[i], "-stop") == 0) {
-      ink_fputln(stdout, "Cool! I think I'll be a STOP cop!");
-      killsig = SIGSTOP;
-    } else if (strcmp(argv[i], "-V") == 0) {
-      ink_fputln(stderr, appVersionInfo.FullVersionInfoStr);
-      exit(0);
-    }
-  }
-  // Detach STDIN, STDOUT, and STDERR (basically, "nohup"). /leif
-  signal(SIGHUP, SIG_IGN);
-  signal(SIGTSTP, SIG_IGN);
-  signal(SIGTTOU, SIG_IGN);
-  signal(SIGTTIN, SIG_IGN);
-
-  // setup supplementary groups if it is not set. any way, worth a try.
-  if (0 == getgroups(0, NULL)) {
-    uid_t uid = getuid();
-    gid_t gid = getgid();
-
-    const int bufSize = 1024;
-    char buf[bufSize];
-
-    struct passwd passwdInfo;
-    struct passwd *ppasswd = NULL;
-    int res;
-    res = getpwuid_r(uid, &passwdInfo, buf, bufSize, &ppasswd);
-    if (!res && ppasswd) {
-        initgroups(ppasswd->pw_name,gid);
-    }
-  }
-
-  setsid();                     // Important, thanks Vlad. :)
-#if (defined(freebsd) && !defined(kfreebsd)) || defined(openbsd)
-  setpgrp(0,0);
-#else
-  setpgrp();
-#endif
-
-  close(STDIN_FILENO);
-  close(STDOUT_FILENO);
-  close(STDERR_FILENO);
-  if ((fd = open("/dev/null", O_WRONLY, 0)) >= 0) {
-    fcntl(fd, F_DUPFD, STDIN_FILENO);
-    fcntl(fd, F_DUPFD, STDOUT_FILENO);
-    fcntl(fd, F_DUPFD, STDERR_FILENO);
-    close(fd);
-  } else {
-    ink_fputln(stderr, "Unable to open /dev/null");
-    return 0;
-  }
-
-  // Initialize and start it up.
-  init();
-  check(NULL);
-
-  return 0;
-}
-


[29/44] git commit: TS-2352: refine THREAD_ALLOC feature

Posted by zw...@apache.org.
TS-2352: refine THREAD_ALLOC feature

1) Move the definition of "ProxyAllocator xxxx" in EThread class to its
   parent Thread class, so that all threads can feel free to use
   THREAD_ALLOC feature.

2) Disable THREAD_ALLOC when enable reclaimable-freelist as reclaimable
   freelist has implemented thread-local pool.

Signed-off-by: Yunkai Zhang <qi...@taobao.com>


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

Branch: refs/heads/5.0.x
Commit: de4c7d233b55b2259e518895f121f68c58bc22ea
Parents: 6dc1867
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Fri Nov 15 17:55:10 2013 +0800
Committer: Yunkai Zhang <qi...@taobao.com>
Committed: Wed Nov 20 12:11:22 2013 +0800

----------------------------------------------------------------------
 CHANGES                               |  2 ++
 iocore/cache/P_CacheInternal.h        |  2 +-
 iocore/cache/RamCacheCLFUS.cc         |  4 +--
 iocore/cache/RamCacheLRU.cc           |  2 +-
 iocore/eventsystem/I_EThread.h        | 17 ----------
 iocore/eventsystem/I_Event.h          |  2 +-
 iocore/eventsystem/I_ProxyAllocator.h | 51 +++++++++++++++++++-----------
 iocore/eventsystem/I_Thread.h         | 21 +++++++++++-
 iocore/eventsystem/P_IOBuffer.h       | 20 ++++++------
 iocore/eventsystem/ProxyAllocator.cc  |  6 +++-
 proxy/hdrs/HdrHeap.cc                 |  4 +--
 proxy/http/HttpClientSession.cc       |  2 +-
 proxy/http/HttpServerSession.cc       |  2 +-
 13 files changed, 79 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 0e634d6..d2fa182 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2352] refine THREAD_ALLOC feature.
+
   *) [TS-2364] Introduce slice notation to field syntax in log format.
 
   *) [TS-2360] Fix usage of TSMimeHdrFieldValueStringGet() IDX in some plugins.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/cache/P_CacheInternal.h
----------------------------------------------------------------------
diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h
index 3c180ac..f330fbb 100644
--- a/iocore/cache/P_CacheInternal.h
+++ b/iocore/cache/P_CacheInternal.h
@@ -633,7 +633,7 @@ free_CacheVC(CacheVC *cont)
 #ifdef DEBUG
   SET_CONTINUATION_HANDLER(cont, &CacheVC::dead);
 #endif
-  THREAD_FREE_TO(cont, cacheVConnectionAllocator, this_ethread(), thread_freelist_size);
+  THREAD_FREE(cont, cacheVConnectionAllocator, this_thread());
   return EVENT_DONE;
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/cache/RamCacheCLFUS.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/RamCacheCLFUS.cc b/iocore/cache/RamCacheCLFUS.cc
index 5a0854a..80922b5 100644
--- a/iocore/cache/RamCacheCLFUS.cc
+++ b/iocore/cache/RamCacheCLFUS.cc
@@ -305,7 +305,7 @@ Lfree:
   uint32_t b = e->key.word(3) % nbuckets;
   bucket[b].remove(e);
   DDebug("ram_cache", "put %X %d %d size %d FREED", e->key.word(3), e->auxkey1, e->auxkey2, e->size);
-  THREAD_FREE(e, ramCacheCLFUSEntryAllocator, this_ethread());
+  THREAD_FREE(e, ramCacheCLFUSEntryAllocator, this_thread());
 }
 
 void
@@ -348,7 +348,7 @@ RamCacheCLFUS::destroy(RamCacheCLFUSEntry *e)
   uint32_t b = e->key.word(3) % nbuckets;
   bucket[b].remove(e);
   DDebug("ram_cache", "put %X %d %d DESTROYED", e->key.word(3), e->auxkey1, e->auxkey2);
-  THREAD_FREE(e, ramCacheCLFUSEntryAllocator, this_ethread());
+  THREAD_FREE(e, ramCacheCLFUSEntryAllocator, this_thread());
   return ret;
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/cache/RamCacheLRU.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/RamCacheLRU.cc b/iocore/cache/RamCacheLRU.cc
index 7562b12..ddf7620 100644
--- a/iocore/cache/RamCacheLRU.cc
+++ b/iocore/cache/RamCacheLRU.cc
@@ -131,7 +131,7 @@ RamCacheLRUEntry * RamCacheLRU::remove(RamCacheLRUEntry *e) {
   CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, -e->data->block_size());
   DDebug("ram_cache", "put %X %d %d FREED", e->key.word(3), e->auxkey1, e->auxkey2);
   e->data = NULL;
-  THREAD_FREE(e, ramCacheLRUEntryAllocator, this_ethread());
+  THREAD_FREE(e, ramCacheLRUEntryAllocator, this_thread());
   objects--;
   return ret;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/eventsystem/I_EThread.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_EThread.h b/iocore/eventsystem/I_EThread.h
index e5f1c56..c1e07ab 100644
--- a/iocore/eventsystem/I_EThread.h
+++ b/iocore/eventsystem/I_EThread.h
@@ -28,7 +28,6 @@
 #include "libts.h"
 #include "I_Thread.h"
 #include "I_PriorityEventQueue.h"
-#include "I_ProxyAllocator.h"
 #include "I_ProtectedQueue.h"
 
 // TODO: This would be much nicer to have "run-time" configurable (or something),
@@ -264,22 +263,6 @@ public:
   Event *schedule_local(Event *e);
 
   InkRand generator;
-  ProxyAllocator eventAllocator;
-  ProxyAllocator netVCAllocator;
-  ProxyAllocator sslNetVCAllocator;
-  ProxyAllocator httpClientSessionAllocator;
-  ProxyAllocator httpServerSessionAllocator;
-  ProxyAllocator hdrHeapAllocator;
-  ProxyAllocator strHeapAllocator;
-  ProxyAllocator cacheVConnectionAllocator;
-  ProxyAllocator openDirEntryAllocator;
-  ProxyAllocator ramCacheCLFUSEntryAllocator;
-  ProxyAllocator ramCacheLRUEntryAllocator;
-  ProxyAllocator evacuationBlockAllocator;
-  ProxyAllocator ioDataAllocator;
-  ProxyAllocator ioAllocator;
-  ProxyAllocator ioBlockAllocator;
-  ProxyAllocator ioBufAllocator[DEFAULT_BUFFER_SIZES];
 
 private:
   // prevent unauthorized copies (Not implemented)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/eventsystem/I_Event.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_Event.h b/iocore/eventsystem/I_Event.h
index 7a37ea0..797e313 100644
--- a/iocore/eventsystem/I_Event.h
+++ b/iocore/eventsystem/I_Event.h
@@ -280,6 +280,6 @@ extern ClassAllocator<Event> eventAllocator;
   if (_p->globally_allocated)    \
     ::_a.free(_p);               \
   else                           \
-    THREAD_FREE_TO(_p, _a, _t, thread_freelist_size)
+    THREAD_FREE(_p, _a, _t)
 
 #endif /*_Event_h_*/

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/eventsystem/I_ProxyAllocator.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_ProxyAllocator.h b/iocore/eventsystem/I_ProxyAllocator.h
index dc3b965..94415e0 100644
--- a/iocore/eventsystem/I_ProxyAllocator.h
+++ b/iocore/eventsystem/I_ProxyAllocator.h
@@ -47,6 +47,7 @@ struct ProxyAllocator
 
 template<class C> inline C * thread_alloc(ClassAllocator<C> &a, ProxyAllocator & l)
 {
+#if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST
   if (l.freelist) {
     C *v = (C *) l.freelist;
     l.freelist = *(C **) l.freelist;
@@ -54,11 +55,15 @@ template<class C> inline C * thread_alloc(ClassAllocator<C> &a, ProxyAllocator &
     *(void **) v = *(void **) &a.proto.typeObject;
     return v;
   }
+#else
+  (void)l;
+#endif
   return a.alloc();
 }
 
 template<class C> inline C * thread_alloc_init(ClassAllocator<C> &a, ProxyAllocator & l)
 {
+#if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST
   if (l.freelist) {
     C *v = (C *) l.freelist;
     l.freelist = *(C **) l.freelist;
@@ -66,10 +71,25 @@ template<class C> inline C * thread_alloc_init(ClassAllocator<C> &a, ProxyAlloca
     memcpy((void *) v, (void *) &a.proto.typeObject, sizeof(C));
     return v;
   }
+#else
+  (void)l;
+#endif
   return a.alloc();
 }
 
 template<class C> inline void
+thread_free(ClassAllocator<C> &a, C *p)
+{
+  a.free(p);
+}
+
+static inline void
+thread_free(Allocator &a, void *p)
+{
+  a.free_void(p);
+}
+
+template<class C> inline void
 thread_freeup(ClassAllocator<C> &a, ProxyAllocator & l)
 {
   while (l.freelist) {
@@ -84,26 +104,21 @@ thread_freeup(ClassAllocator<C> &a, ProxyAllocator & l)
 void* thread_alloc(Allocator &a, ProxyAllocator &l);
 void thread_freeup(Allocator &a, ProxyAllocator &l);
 
-#if defined(TS_USE_FREELIST)
-
 #define THREAD_ALLOC(_a, _t) thread_alloc(::_a, _t->_a)
 #define THREAD_ALLOC_INIT(_a, _t) thread_alloc_init(::_a, _t->_a)
-#define THREAD_FREE_TO(_p, _a, _t, _m) do { \
-  *(char **)_p = (char*)_t->_a.freelist;    \
-  _t->_a.freelist = _p;                     \
-  _t->_a.allocated++;                       \
-  if (_t->_a.allocated > _m)                \
-    thread_freeup(::_a, _t->_a);            \
+#if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST
+#define THREAD_FREE(_p, _a, _t) do {            \
+  *(char **)_p = (char*)_t->_a.freelist;        \
+  _t->_a.freelist = _p;                         \
+  _t->_a.allocated++;                           \
+  if (_t->_a.allocated > thread_freelist_size)  \
+    thread_freeup(::_a, _t->_a);                \
 } while (0)
-
-#else /* !defined(TS_USE_FREELIST) */
-
-#define THREAD_ALLOC(_a, _t) ::_a.alloc()
-#define THREAD_ALLOC_INIT(_a, _t) ::_a.alloc()
-#define THREAD_FREE_TO(_p, _a, _t, _m) ::_a.free(_p)
-
-#endif /* defined(TS_USE_FREELIST */
-
-#define THREAD_FREE(_p, _a, _t) THREAD_FREE_TO(_p, _a, _t, thread_freelist_size)
+#else /* !TS_USE_FREELIST || TS_USE_RECLAIMABLE_FREELIST */
+#define THREAD_FREE(_p, _a, _t) do {  \
+  (void)_t;                           \
+  thread_free(::_a, _p);              \
+} while (0)
+#endif
 
 #endif /* _ProxyAllocator_h_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/eventsystem/I_Thread.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_Thread.h b/iocore/eventsystem/I_Thread.h
index 3a40c52..4916e51 100644
--- a/iocore/eventsystem/I_Thread.h
+++ b/iocore/eventsystem/I_Thread.h
@@ -64,7 +64,8 @@
 -- -include I_Event.h or P_Event.h
 #endif
 #include "libts.h"
-  class Thread;
+#include "I_ProxyAllocator.h"
+class Thread;
 class ProxyMutex;
 
 #define THREADAPI
@@ -125,6 +126,24 @@ public:
   inkcoreapi static ink_thread_key thread_data_key;
   Ptr<ProxyMutex> mutex_ptr;
 
+  // For THREAD_ALLOC
+  ProxyAllocator eventAllocator;
+  ProxyAllocator netVCAllocator;
+  ProxyAllocator sslNetVCAllocator;
+  ProxyAllocator httpClientSessionAllocator;
+  ProxyAllocator httpServerSessionAllocator;
+  ProxyAllocator hdrHeapAllocator;
+  ProxyAllocator strHeapAllocator;
+  ProxyAllocator cacheVConnectionAllocator;
+  ProxyAllocator openDirEntryAllocator;
+  ProxyAllocator ramCacheCLFUSEntryAllocator;
+  ProxyAllocator ramCacheLRUEntryAllocator;
+  ProxyAllocator evacuationBlockAllocator;
+  ProxyAllocator ioDataAllocator;
+  ProxyAllocator ioAllocator;
+  ProxyAllocator ioBlockAllocator;
+  ProxyAllocator ioBufAllocator[DEFAULT_BUFFER_SIZES];
+
 private:
   // prevent unauthorized copies (Not implemented)
   Thread(const Thread &);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/eventsystem/P_IOBuffer.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/P_IOBuffer.h b/iocore/eventsystem/P_IOBuffer.h
index 0842aff..c0ad45b 100644
--- a/iocore/eventsystem/P_IOBuffer.h
+++ b/iocore/eventsystem/P_IOBuffer.h
@@ -203,7 +203,7 @@ new_IOBufferData_internal(
                            void *b, int64_t size, int64_t asize_index)
 {
   (void) size;
-  IOBufferData *d = THREAD_ALLOC(ioDataAllocator, this_ethread());
+  IOBufferData *d = THREAD_ALLOC(ioDataAllocator, this_thread());
   d->_size_index = asize_index;
   ink_assert(BUFFER_SIZE_INDEX_IS_CONSTANT(asize_index)
              || size <= d->block_size());
@@ -263,7 +263,7 @@ new_IOBufferData_internal(
 #endif
                            int64_t size_index, AllocType type)
 {
-  IOBufferData *d = THREAD_ALLOC(ioDataAllocator, this_ethread());
+  IOBufferData *d = THREAD_ALLOC(ioDataAllocator, this_thread());
 #ifdef TRACK_BUFFER_USER
   d->_location = loc;
 #endif
@@ -336,7 +336,7 @@ TS_INLINE void
 IOBufferData::free()
 {
   dealloc();
-  THREAD_FREE(this, ioDataAllocator, this_ethread());
+  THREAD_FREE(this, ioDataAllocator, this_thread());
 }
 
 //////////////////////////////////////////////////////////////////
@@ -352,7 +352,7 @@ new_IOBufferBlock_internal(
 #endif
   )
 {
-  IOBufferBlock *b = THREAD_ALLOC(ioBlockAllocator, this_ethread());
+  IOBufferBlock *b = THREAD_ALLOC(ioBlockAllocator, this_thread());
 #ifdef TRACK_BUFFER_USER
   b->_location = location;
 #endif
@@ -366,7 +366,7 @@ new_IOBufferBlock_internal(
 #endif
                             IOBufferData * d, int64_t len, int64_t offset)
 {
-  IOBufferBlock *b = THREAD_ALLOC(ioBlockAllocator, this_ethread());
+  IOBufferBlock *b = THREAD_ALLOC(ioBlockAllocator, this_thread());
 #ifdef TRACK_BUFFER_USER
   b->_location = location;
 #endif
@@ -468,7 +468,7 @@ TS_INLINE void
 IOBufferBlock::free()
 {
   dealloc();
-  THREAD_FREE(this, ioBlockAllocator, this_ethread());
+  THREAD_FREE(this, ioBlockAllocator, this_thread());
 }
 
 TS_INLINE void
@@ -777,7 +777,7 @@ TS_INLINE MIOBuffer * new_MIOBuffer_internal(
 #endif
                                                int64_t size_index)
 {
-  MIOBuffer *b = THREAD_ALLOC(ioAllocator, this_ethread());
+  MIOBuffer *b = THREAD_ALLOC(ioAllocator, this_thread());
 #ifdef TRACK_BUFFER_USER
   b->_location = location;
 #endif
@@ -790,7 +790,7 @@ free_MIOBuffer(MIOBuffer * mio)
 {
   mio->_writer = NULL;
   mio->dealloc_all_readers();
-  THREAD_FREE(mio, ioAllocator, this_ethread());
+  THREAD_FREE(mio, ioAllocator, this_thread());
 }
 
 TS_INLINE MIOBuffer * new_empty_MIOBuffer_internal(
@@ -799,7 +799,7 @@ TS_INLINE MIOBuffer * new_empty_MIOBuffer_internal(
 #endif
                                                      int64_t size_index)
 {
-  MIOBuffer *b = THREAD_ALLOC(ioAllocator, this_ethread());
+  MIOBuffer *b = THREAD_ALLOC(ioAllocator, this_thread());
   b->size_index = size_index;
 #ifdef TRACK_BUFFER_USER
   b->_location = location;
@@ -810,7 +810,7 @@ TS_INLINE MIOBuffer * new_empty_MIOBuffer_internal(
 TS_INLINE void
 free_empty_MIOBuffer(MIOBuffer * mio)
 {
-  THREAD_FREE(mio, ioAllocator, this_ethread());
+  THREAD_FREE(mio, ioAllocator, this_thread());
 }
 
 TS_INLINE IOBufferReader *

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/iocore/eventsystem/ProxyAllocator.cc
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/ProxyAllocator.cc b/iocore/eventsystem/ProxyAllocator.cc
index 53a8d60..327b49b 100644
--- a/iocore/eventsystem/ProxyAllocator.cc
+++ b/iocore/eventsystem/ProxyAllocator.cc
@@ -27,12 +27,16 @@ int thread_freelist_size = 512;
 void*
 thread_alloc(Allocator &a, ProxyAllocator &l)
 {
+#if TS_USE_FREELIST && !TS_USE_RECLAIMABLE_FREELIST
   if (l.freelist) {
     void *v = (void *) l.freelist;
     l.freelist = *(void **) l.freelist;
     l.allocated--;
     return v;
   }
+#else
+  (void)l;
+#endif
   return a.alloc_void();
 }
 
@@ -46,4 +50,4 @@ thread_freeup(Allocator &a, ProxyAllocator &l)
     a.free_void(v);                  // we could use a bulk free here
   }
   ink_assert(!l.allocated);
- }
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/proxy/hdrs/HdrHeap.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/HdrHeap.cc b/proxy/hdrs/HdrHeap.cc
index 6bcd06b..a70c0ab 100644
--- a/proxy/hdrs/HdrHeap.cc
+++ b/proxy/hdrs/HdrHeap.cc
@@ -181,7 +181,7 @@ HdrHeap::destroy()
     m_ronly_heap[i].m_ref_count_ptr = NULL;
 
   if (m_size == HDR_HEAP_DEFAULT_SIZE) {
-    THREAD_FREE(this, hdrHeapAllocator, this_ethread());
+    THREAD_FREE(this, hdrHeapAllocator, this_thread());
   } else {
     ats_free(this);
   }
@@ -1105,7 +1105,7 @@ void
 HdrStrHeap::free()
 {
   if (m_heap_size == HDR_STR_HEAP_DEFAULT_SIZE) {
-    THREAD_FREE(this, strHeapAllocator, this_ethread());
+    THREAD_FREE(this, strHeapAllocator, this_thread());
   } else {
     ats_free(this);
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/proxy/http/HttpClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpClientSession.cc b/proxy/http/HttpClientSession.cc
index c4d1965..5db6275 100644
--- a/proxy/http/HttpClientSession.cc
+++ b/proxy/http/HttpClientSession.cc
@@ -108,7 +108,7 @@ HttpClientSession::destroy()
 {
   this->cleanup();
   if (proxy_allocated)
-    THREAD_FREE(this, httpClientSessionAllocator, this_ethread());
+    THREAD_FREE(this, httpClientSessionAllocator, this_thread());
   else
     httpClientSessionAllocator.free(this);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de4c7d23/proxy/http/HttpServerSession.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpServerSession.cc b/proxy/http/HttpServerSession.cc
index 7898c09..dd3de61 100644
--- a/proxy/http/HttpServerSession.cc
+++ b/proxy/http/HttpServerSession.cc
@@ -52,7 +52,7 @@ HttpServerSession::destroy()
 
   mutex.clear();
   if (2 == share_session)
-    THREAD_FREE(this, httpServerSessionAllocator, this_ethread());
+    THREAD_FREE(this, httpServerSessionAllocator, this_thread());
   else
     httpServerSessionAllocator.free(this);
 }


[26/44] git commit: Added TS-2360.

Posted by zw...@apache.org.
Added TS-2360.


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

Branch: refs/heads/5.0.x
Commit: 7195488f61345eaf4269e52eb188d345034cf440
Parents: 7878e05
Author: Leif Hedstrom <zw...@apache.org>
Authored: Mon Nov 18 16:23:00 2013 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Mon Nov 18 16:23:00 2013 -0700

----------------------------------------------------------------------
 CHANGES | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7195488f/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 5bb14b4..ece5bc6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2360] Fix usage of TSMimeHdrFieldValueStringGet() IDX in some plugins.
 
   *) [TS-2361] Load regex_remap configuration relative to the configuration directory.
 


[20/44] git commit: TS-2349: update .gitignore

Posted by zw...@apache.org.
TS-2349: update .gitignore

Ignore the command-line build artifacts in their new locations.


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

Branch: refs/heads/5.0.x
Commit: 8f75a092f4be30dfda23d4846a83e88376e5e2e1
Parents: 775ad1d
Author: James Peach <jp...@apache.org>
Authored: Sat Nov 9 21:12:33 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Nov 14 12:31:04 2013 -0800

----------------------------------------------------------------------
 .gitignore | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8f75a092/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index e98af41..a8bba97 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,10 @@ doc/locale/pot
 MYMETA.*
 pm_to_blib
 
+cmd/traffic_line/traffic_line
+cmd/traffic_shell/traffic_shell
+cmd/traffic_cop/traffic_cop
+cmd/traffic_top/traffic_top
 
 lib/ts/ink_autoconf.h
 lib/ts/ink_config.h
@@ -74,8 +78,6 @@ mgmt/tools/traffic_shmem_clean
 mgmt/tools/traffic_time_config
 mgmt/tools/traffic_vip_config
 mgmt/api/api_cli_remote
-mgmt/cli/traffic_line
-mgmt/cli/traffic_shell
 mgmt/tools/shmem_clean
 mgmt/traffic_manager
 proxy/traffic_logcat
@@ -84,8 +86,6 @@ proxy/traffic_sac
 proxy/traffic_server
 proxy/test_xml_parser
 
-cop/traffic_cop
-
 libtool
 m4/libtool.m4
 m4/ltoptions.m4


[06/44] git commit: TS-2349: move traffic_cop to the cmd subdirectory

Posted by zw...@apache.org.
TS-2349: move traffic_cop to the cmd subdirectory


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

Branch: refs/heads/5.0.x
Commit: 6917d8ef0623be0e85c77718ba566dfc6c2a0bc6
Parents: cdfe125
Author: James Peach <jp...@apache.org>
Authored: Sat Nov 9 20:29:50 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Nov 14 12:30:22 2013 -0800

----------------------------------------------------------------------
 Makefile.am                    |    4 +-
 cmd/Makefile.am                |    2 +-
 cmd/traffic_cop/Makefile.am    |   42 +
 cmd/traffic_cop/traffic_cop.cc | 1849 +++++++++++++++++++++++++++++++++++
 configure.ac                   |    2 +-
 cop/Makefile.am                |   42 -
 cop/TrafficCop.cc              | 1849 -----------------------------------
 7 files changed, 1895 insertions(+), 1895 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6917d8ef/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index 2534837..0ececb4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,9 +29,9 @@ export CCACHE_BASEDIR
 # proxy/api/ts has to be built first, since so much of libraries and "core
 # depends on the generates ts/ts.h include file.
 if STANDALONE_IOCORE
-SUBDIRS =  proxy/api/ts iocore lib proxy/hdrs proxy/shared mgmt proxy cop plugins cmd tools example
+SUBDIRS =  proxy/api/ts iocore lib proxy/hdrs proxy/shared mgmt proxy plugins cmd tools example
 else
-SUBDIRS =  proxy/api/ts iocore lib proxy/hdrs proxy/shared mgmt proxy cop rc doc plugins cmd tools example
+SUBDIRS =  proxy/api/ts iocore lib proxy/hdrs proxy/shared mgmt proxy rc doc plugins cmd tools example
 endif
 
 DIST_BUILD_USER=`id -nu`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6917d8ef/cmd/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
index 097159d..4d30867 100644
--- a/cmd/Makefile.am
+++ b/cmd/Makefile.am
@@ -15,4 +15,4 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-SUBDIRS = traffic_top
+SUBDIRS = traffic_top traffic_cop

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6917d8ef/cmd/traffic_cop/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_cop/Makefile.am b/cmd/traffic_cop/Makefile.am
new file mode 100644
index 0000000..6403623
--- /dev/null
+++ b/cmd/traffic_cop/Makefile.am
@@ -0,0 +1,42 @@
+#
+# 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)/mgmt \
+  -I$(top_srcdir)/mgmt/cluster \
+  -I$(top_srcdir)/mgmt/api/include
+
+MGMT_DEFS = @MGMT_DEFS@
+DEFS += $(MGMT_DEFS)
+
+bin_PROGRAMS = traffic_cop
+
+traffic_cop_SOURCES = \
+  traffic_cop.cc
+
+traffic_cop_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
+
+traffic_cop_LDADD = \
+  $(top_builddir)/mgmt/api/libtsmgmt.la \
+  $(top_builddir)/lib/ts/libtsutil.la \
+  $(top_builddir)/lib/records/librec4cop.a \
+  @LIBRESOLV@ @LIBSSL@

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6917d8ef/cmd/traffic_cop/traffic_cop.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_cop/traffic_cop.cc b/cmd/traffic_cop/traffic_cop.cc
new file mode 100644
index 0000000..7a258b8
--- /dev/null
+++ b/cmd/traffic_cop/traffic_cop.cc
@@ -0,0 +1,1849 @@
+/** @file
+
+  Main entry point for the traffic_cop application.
+
+  @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 "libts.h"
+#include "I_Layout.h"
+#include "I_Version.h"
+#include "I_RecCore.h"
+#include "mgmtapi.h"
+#include "ClusterCom.h"
+
+#include <string>
+#include <map>
+
+#if defined(linux) || defined (solaris)
+#include "sys/utsname.h"
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+
+union semun
+{
+  int val;                      /* value for SETVAL */
+  struct semid_ds *buf;         /* buffer for IPC_STAT, IPC_SET */
+  unsigned short int *array;    /* array for GETALL, SETALL */
+  struct seminfo *__buf;        /* buffer for IPC_INFO */
+};
+#endif  // linux check
+#include <grp.h>
+
+static const long MAX_LOGIN =  sysconf(_SC_LOGIN_NAME_MAX) <= 0 ? _POSIX_LOGIN_NAME_MAX :  sysconf(_SC_LOGIN_NAME_MAX);
+static const char COP_TRACE_FILE[] = "/tmp/traffic_cop.trace";
+
+#define OPTIONS_MAX     32
+#define OPTIONS_LEN_MAX 1024
+
+#ifndef WAIT_ANY
+#define WAIT_ANY (pid_t) -1
+#endif // !WAIT_ANY
+
+#define COP_FATAL    LOG_ALERT
+#define COP_WARNING  LOG_ERR
+#define COP_DEBUG    LOG_DEBUG
+
+Diags * g_diags; // link time dependency
+
+static const char *root_dir;
+static const char *runtime_dir;
+static const char *config_dir;
+static char config_file[PATH_NAME_MAX];
+
+static char cop_lockfile[PATH_NAME_MAX];
+static char manager_lockfile[PATH_NAME_MAX];
+static char server_lockfile[PATH_NAME_MAX];
+
+static int check_memory_min_swapfree_kb = 0;
+static int check_memory_min_memfree_kb = 0;
+
+static int syslog_facility = LOG_DAEMON;
+static char syslog_fac_str[PATH_NAME_MAX] = "LOG_DAEMON";
+
+static int killsig = SIGKILL;
+static int coresig = 0;
+
+static char* admin_user;
+static uid_t admin_uid;
+static gid_t admin_gid;
+static bool admin_user_p = false;
+static char manager_binary[PATH_NAME_MAX] = "traffic_manager";
+static char server_binary[PATH_NAME_MAX] = "traffic_server";
+static char manager_options[OPTIONS_LEN_MAX] = "";
+
+static char log_file[PATH_NAME_MAX] = "traffic.out";
+static char bin_path[PATH_NAME_MAX] = "bin";
+
+static int autoconf_port = 8083;
+static int rs_port = 8088;
+static MgmtClusterType cluster_type = NO_CLUSTER;
+static int http_backdoor_port = 8084;
+
+#if defined(linux)
+// TS-1075 : auto-port ::connect DoS on high traffic linux systems
+static int source_port = 0;
+#endif
+
+static int manager_failures = 0;
+static int server_failures = 0;
+static int server_not_found = 0;
+
+static const int sleep_time = 10;       // 10 sec
+static const int manager_timeout = 3 * 60;      //  3 min
+static const int server_timeout = 3 * 60;       //  3 min
+
+// traffic_manager flap detection
+#define MANAGER_FLAP_DETECTION 1
+#if defined(MANAGER_FLAP_DETECTION)
+#define MANAGER_MAX_FLAP_COUNT 3        // if flap this many times, give up for a while
+#define MANAGER_FLAP_INTERVAL_MSEC 60000        // if x number of flaps happen in this interval, declare flapping
+#define MANAGER_FLAP_RETRY_MSEC 60000   // if flapping, don't try to restart until after this retry duration
+static bool manager_flapping = false;   // is the manager flapping?
+static int manager_flap_count = 0;      // how many times has the manager flapped?
+static ink_hrtime manager_flap_interval_start_time = 0; // first time we attempted to start the manager in past little while)
+static ink_hrtime manager_flap_retry_start_time = 0;    // first time we attempted to start the manager in past little while)
+#endif
+
+// transient syscall error timeout
+#define TRANSIENT_ERROR_WAIT_MS 500
+
+static const int kill_timeout = 1 * 60; //  1 min
+
+static int child_pid = 0;
+static int child_status = 0;
+static int sem_id = 11452;
+
+AppVersionInfo appVersionInfo;
+
+static char const localhost[] = "127.0.0.1";
+
+static void cop_log(int priority, const char *format, ...) TS_PRINTFLIKE(2, 3);
+inline static void dummy_cop_log_trace(const char *format, ...) TS_PRINTFLIKE(1, 2);
+
+static void get_admin_user(void);
+
+struct ConfigValue
+{
+  ConfigValue(RecT _t, RecDataT _d, const std::string& _v)
+    : config_type(_t), data_type(_d), data_value(_v) {
+    }
+
+  RecT        config_type;
+  RecDataT    data_type;
+  std::string data_value;
+};
+
+typedef std::map<std::string, ConfigValue> ConfigValueTable;
+static ConfigValueTable configTable;
+
+inline static void
+dummy_cop_log_trace(const char *format, ...)
+{
+  (void)format;
+}
+
+#if TS_USE_COP_DEBUG
+#define cop_log_trace(...)              cop_log(COP_DEBUG, __VA_ARGS__)
+#else
+#define cop_log_trace(...)      if (0) dummy_cop_log_trace(__VA_ARGS__)
+#endif
+
+
+static void
+cop_log(int priority, const char *format, ...)
+{
+  va_list args;
+  char buffer[8192];
+#if TS_USE_COP_DEBUG
+  static FILE *trace_file = NULL;
+  struct timeval now;
+  double now_f;
+#endif
+
+  va_start(args, format);
+
+#if TS_USE_COP_DEBUG
+  if (!trace_file) {
+    if (!unlink(COP_TRACE_FILE))
+      trace_file = fopen(COP_TRACE_FILE, "w");
+  }
+  if (trace_file) {
+    gettimeofday(&now, NULL);
+    now_f = now.tv_sec + now.tv_usec / 1000000.0f;
+    switch (priority) {
+    case COP_DEBUG:
+      fprintf(trace_file, "<%.4f> [DEBUG]: ", now_f);
+      break;
+    case COP_WARNING:
+      fprintf(trace_file, "<%.4f> [WARNING]: ", now_f);
+      break;
+    case COP_FATAL:
+      fprintf(trace_file, "<%.4f> [FATAL]: ", now_f);
+      break;
+    default:
+      fprintf(trace_file, "<%.4f> [unknown]: ", now_f);
+      break;
+    }
+
+    va_list args_tmp;
+    va_copy(args_tmp, args);
+
+    vfprintf(trace_file, format, args_tmp);
+    fflush(trace_file);
+
+    va_end(args_tmp);
+  }
+#endif
+
+  vsprintf(buffer, format, args);
+  syslog(priority, "%s", buffer);
+
+  va_end(args);
+}
+
+
+void
+chown_file_to_admin_user(const char *file) {
+  if (admin_user_p) {
+    if (chown(file, admin_uid, admin_gid) < 0) {
+      cop_log(COP_FATAL, "cop couldn't chown the file: '%s' for '%s' (%d/%d) : [%d] %s\n",
+              file, admin_user, admin_uid, admin_gid, errno, strerror(errno));
+    }
+  }
+}
+
+static void
+sig_child(int signum)
+{
+  pid_t pid = 0;
+  int status = 0;
+
+  cop_log_trace("Entering sig_child(%d)\n", signum);
+  for (;;) {
+    pid = waitpid(WAIT_ANY, &status, WNOHANG);
+
+    if (pid <= 0) {
+      break;
+    }
+    // TSqa03086 - We can not log the child status signal from
+    //   the signal handler since syslog can deadlock.  Record
+    //   the pid and the status in a global for logging
+    //   next time through the event loop.  We will occasionally
+    //   lose some information if we get two sig childs in rapid
+    //   succession
+    child_pid = pid;
+    child_status = status;
+  }
+  cop_log_trace("Leaving sig_child(%d)\n", signum);
+}
+
+static void
+sig_term(int signum)
+{
+  pid_t pid = 0;
+  int status = 0;
+
+  //killsig = SIGTERM;
+
+  cop_log_trace("Entering sig_term(%d)\n", signum);
+
+  // safely^W commit suicide.
+  cop_log_trace("Sending signal %d to entire group\n", signum);
+  killpg(0, signum);
+  
+  cop_log_trace("Waiting for children to exit.");
+
+  for (;;) {
+    pid = waitpid(WAIT_ANY, &status, WNOHANG);
+
+    if (pid <= 0) {
+      break;
+    }
+    // TSqa03086 - We can not log the child status signal from
+    //   the signal handler since syslog can deadlock.  Record
+    //   the pid and the status in a global for logging
+    //   next time through the event loop.  We will occasionally
+    //   lose some information if we get two sig childs in rapid
+    //   succession
+    child_pid = pid;
+    child_status = status;
+  }
+  cop_log_trace("Leaving sig_term(%d), exiting traffic_cop\n", signum);
+  exit(0);
+}
+
+static void
+#if defined(solaris)
+sig_fatal(int signum, siginfo_t * t, void *c)
+#else
+sig_fatal(int signum)
+#endif
+{
+  cop_log_trace("Entering sig_fatal(%d)\n", signum);
+#if defined(solaris)
+  if (t) {
+    if (t->si_code <= 0) {
+      cop_log(COP_FATAL, "cop received fatal user signal [%d] from"
+              " pid [%d] uid [%d]\n", signum, (int)(t->si_pid), t->si_uid);
+    } else {
+      cop_log(COP_FATAL, "cop received fatal kernel signal [%d], " "reason [%d]\n", signum, t->si_code);
+    }
+  } else {
+#endif
+    cop_log(COP_FATAL, "cop received fatal signal [%d]\n", signum);
+#if defined(solaris)
+  }
+#endif
+  cop_log_trace("Leaving sig_fatal(%d)\n", signum);
+  abort();
+}
+
+static void
+#if defined(solaris)
+sig_alarm_warn(int signum, siginfo_t * t, void *c)
+#else
+sig_alarm_warn(int signum)
+#endif
+{
+  cop_log_trace("Entering sig_alarm_warn(%d)\n", signum);
+  cop_log(COP_WARNING, "unable to kill traffic_server for the last" " %d seconds\n", kill_timeout);
+
+  // Set us up for another alarm
+  alarm(kill_timeout);
+  cop_log_trace("Leaving sig_alarm_warn(%d)\n", signum);
+}
+
+static void
+sig_ignore(int signum)
+{
+  cop_log_trace("Entering sig_ignore(%d)\n", signum);
+  // No code here yet...
+  cop_log_trace("Leaving sig_ignore(%d)\n", signum);
+}
+
+static void
+set_alarm_death()
+{
+  struct sigaction action;
+
+  cop_log_trace("Entering set_alarm_death()\n");
+#if defined(solaris)
+  action.sa_handler = NULL;
+  action.sa_sigaction = sig_fatal;
+  sigemptyset(&action.sa_mask);
+  action.sa_flags = SA_SIGINFO;
+#else
+  action.sa_handler = sig_fatal;
+  sigemptyset(&action.sa_mask);
+  action.sa_flags = 0;
+#endif
+
+  sigaction(SIGALRM, &action, NULL);
+  cop_log_trace("Leaving set_alarm_death()\n");
+}
+
+static void
+set_alarm_warn()
+{
+  struct sigaction action;
+
+  cop_log_trace("Entering set_alarm_warn()\n");
+#if defined(solaris)
+  action.sa_handler = NULL;
+  action.sa_sigaction = sig_alarm_warn;
+  sigemptyset(&action.sa_mask);
+  action.sa_flags = SA_SIGINFO;
+#else
+  action.sa_handler = sig_alarm_warn;
+  sigemptyset(&action.sa_mask);
+  action.sa_flags = 0;
+#endif
+
+  sigaction(SIGALRM, &action, NULL);
+  cop_log_trace("Leaving set_alarm_warn()\n");
+
+}
+
+static void
+process_syslog_config(void)
+{
+  int new_fac;
+
+  cop_log_trace("Entering process_syslog_config()\n");
+  new_fac = facility_string_to_int(syslog_fac_str);
+
+  if (new_fac >= 0 && new_fac != syslog_facility) {
+    closelog();
+    openlog("traffic_cop", LOG_PID | LOG_NDELAY | LOG_NOWAIT, new_fac);
+    syslog_facility = new_fac;
+  }
+  cop_log_trace("Leaving process_syslog_config()\n");
+}
+
+// Paranoia: wrap the process termination call within alarms
+//           so that when the killing call doesn't return we
+//           will still wake up
+static void
+safe_kill(const char *lockfile_name, const char *pname, bool group)
+{
+  Lockfile lockfile(lockfile_name);
+  chown_file_to_admin_user(lockfile_name);
+
+  cop_log_trace("Entering safe_kill(%s, %s, %d)\n", lockfile_name, pname, group);
+  set_alarm_warn();
+  alarm(kill_timeout);
+
+  if (group == true) {
+    lockfile.KillGroup(killsig, coresig, pname);
+  } else {
+    lockfile.Kill(killsig, coresig, pname);
+  }
+  chown_file_to_admin_user(lockfile_name);
+
+  alarm(0);
+  set_alarm_death();
+  cop_log_trace("Leaving safe_kill(%s, %s, %d)\n", lockfile_name, pname, group);
+}
+
+
+// ink_hrtime milliseconds()
+//
+// Returns the result of gettimeofday converted to
+// one 64bit int
+//
+static ink_hrtime
+milliseconds(void)
+{
+  struct timeval curTime;
+
+  cop_log_trace("Entering milliseconds()\n");
+  ink_gethrtimeofday(&curTime, NULL);
+  // Make liberal use of casting to ink_hrtime to ensure the
+  //  compiler does not truncate our result
+  cop_log_trace("Leaving milliseconds()\n");
+  return ((ink_hrtime) curTime.tv_sec * 1000) + ((ink_hrtime) curTime.tv_usec / 1000);
+}
+
+static void
+millisleep(int ms)
+{
+  struct timespec ts;
+
+  cop_log_trace("Entering millisleep(%d)\n", ms);
+  ts.tv_sec = ms / 1000;
+  ts.tv_nsec = (ms - ts.tv_sec * 1000) * 1000 * 1000;
+  nanosleep(&ts, NULL);
+  cop_log_trace("Leaving millisleep(%d)\n", ms);
+}
+
+static bool
+transient_error(int error, int wait_ms)
+{
+  cop_log_trace("Entering transient_error(%d, %d)\n", error, wait_ms);
+
+  // switch cases originally from UnixNex::accept_error_seriousness()
+  switch (error) {
+  case EAGAIN:
+  case EINTR:
+    break;
+
+  case ENFILE:
+  case EMFILE:
+  case ENOMEM:
+#ifdef ENOBUFS
+  case ENOBUFS:
+#endif
+#if defined(ENOSR) && !defined(freebsd) && !defined(darwin)
+  case ENOSR:
+#endif
+    if (wait_ms)
+      millisleep(wait_ms);
+    break;
+
+  default:
+    cop_log_trace("Leaving transient_error(%d, %d) --> false\n", error, wait_ms);
+    return false;
+  }
+  cop_log_trace("Leaving transient_error(%d, %d) --> true\n", error, wait_ms);
+  return true;
+}
+
+static void
+config_register_variable(RecT rec_type, RecDataT data_type, const char * name, const char * value, bool /* inc_version */)
+{
+  configTable.insert(std::make_pair(std::string(name), ConfigValue(rec_type, data_type, value)));
+}
+
+static void
+config_read_string(const char *name, char *val, size_t val_len, bool miss_ok = false)
+{
+  ConfigValueTable::const_iterator config;
+
+  config = configTable.find(name);
+  if (config == configTable.end()) {
+    if (miss_ok)
+      return;
+    else
+      goto ConfigStrFatalError;
+  }
+
+  if (config->second.data_type != RECD_STRING) {
+    goto ConfigStrFatalError;
+  }
+
+  ink_strlcpy(val, RecConfigOverrideFromEnvironment(name, config->second.data_value.c_str()), val_len);
+  return;
+
+ConfigStrFatalError:
+  cop_log(COP_FATAL, "could not find string variable %s in records.config\n", name);
+  exit(1);
+}
+
+static void
+config_read_int(const char *name, int *val, bool miss_ok = false)
+{
+  ConfigValueTable::const_iterator config;
+
+  config = configTable.find(name);
+  if (config == configTable.end()) {
+    if (miss_ok)
+      return;
+    else
+      goto ConfigIntFatalError;
+  }
+
+  if (config->second.data_type != RECD_INT) {
+    goto ConfigIntFatalError;
+  }
+
+  *val = atoi(RecConfigOverrideFromEnvironment(name, config->second.data_value.c_str()));
+  return;
+
+ConfigIntFatalError:
+  cop_log(COP_FATAL, "could not find integer variable %s in records.config\n", name);
+  exit(1);
+}
+
+static void
+config_reload_records()
+{
+  struct stat stat_buf;
+  static time_t last_mod = 0;
+  char log_dir[PATH_NAME_MAX];
+  char log_filename[PATH_NAME_MAX];
+  int tmp_int;
+
+  cop_log_trace("Entering %s()\n", __func__);
+  // coverity[fs_check_call]
+  if (stat(config_file, &stat_buf) == -1) {
+    cop_log(COP_FATAL, "could not stat \"%s\"\n", config_file);
+    exit(1);
+  }
+
+  if (stat_buf.st_mtime <= last_mod) {  // no change, no need to re-read
+    return;
+  } else {
+    last_mod = stat_buf.st_mtime;
+  }
+
+  configTable.clear();
+
+  if (RecConfigFileParse(config_file, config_register_variable, false) != REC_ERR_OKAY) {
+    cop_log(COP_FATAL, "could not parse \"%s\"\n", config_file);
+    exit(1);
+  }
+
+  config_read_string("proxy.config.manager_binary", manager_binary, sizeof(manager_binary), true);
+  config_read_string("proxy.config.proxy_binary", server_binary, sizeof(server_binary), true);
+  get_admin_user();
+
+  config_read_string("proxy.config.bin_path", bin_path, sizeof(bin_path), true);
+  Layout::get()->relative(bin_path, sizeof(bin_path), bin_path);
+  if (access(bin_path, R_OK) == -1) {
+    ink_strlcpy(bin_path, Layout::get()->bindir, sizeof(bin_path));
+    if (access(bin_path, R_OK) == -1) {
+      cop_log(COP_FATAL, "could not access() \"%s\"\n", bin_path);
+      cop_log(COP_FATAL, "please set 'proxy.config.bin_path' \n");
+      exit(1);
+    }
+  }
+  config_read_string("proxy.config.log.logfile_dir", log_dir, sizeof(log_dir));
+  Layout::get()->relative(log_dir, sizeof(log_dir), log_dir);
+  if (access(log_dir, W_OK) == -1) {
+    ink_strlcpy(log_dir, Layout::get()->logdir, sizeof(log_dir));
+    if (access(log_dir, W_OK) == -1) {
+      cop_log(COP_FATAL, "could not access() \"%s\"\n", log_dir);
+      cop_log(COP_FATAL, "please set 'proxy.config.log.logfile_dir' \n");
+      exit(1);
+    }
+  }
+  config_read_string("proxy.config.output.logfile", log_filename, sizeof(log_filename));
+  Layout::relative_to(log_file, sizeof(log_file), log_dir, log_filename);
+  config_read_int("proxy.config.process_manager.mgmt_port", &http_backdoor_port, true);
+  config_read_int("proxy.config.admin.autoconf_port", &autoconf_port, true);
+  config_read_int("proxy.config.cluster.rsport", &rs_port, true);
+  config_read_int("proxy.config.lm.sem_id", &sem_id, true);
+
+#if defined(linux)
+  // TS-1075 : auto-port ::connect DoS on high traffic linux systems
+  config_read_int("proxy.config.cop.source_port", &source_port, true);
+#endif
+
+  config_read_int("proxy.local.cluster.type", &tmp_int);
+  cluster_type = static_cast<MgmtClusterType>(tmp_int);
+
+  config_read_string("proxy.config.syslog_facility", syslog_fac_str, sizeof(syslog_fac_str), true);
+  process_syslog_config();
+  config_read_int("proxy.config.cop.core_signal", &coresig, true);
+
+  config_read_int("proxy.config.cop.linux_min_swapfree_kb", &check_memory_min_swapfree_kb, true);
+  config_read_int("proxy.config.cop.linux_min_memfree_kb", &check_memory_min_memfree_kb, true);
+
+  cop_log_trace("Leaving %s()\n", __func__);
+}
+
+static void
+get_admin_user()
+{
+  struct passwd *pwd = NULL;
+
+  if (!admin_user)
+    admin_user = (char *)ats_malloc(MAX_LOGIN);
+
+  config_read_string("proxy.config.admin.user_id", admin_user, MAX_LOGIN);
+
+  if (*admin_user) {
+    char *end = admin_user + strlen(admin_user) - 1;
+
+    // Trim trailing spaces.
+    while (end >= admin_user && isspace(*end))
+      end--;
+    *(end + 1) = '\0';
+
+    if (*admin_user == '#') {
+      int uid = atoi(admin_user + 1);
+      if (uid == -1) {
+        // XXX: Can this call hapen after setuid?
+        uid = (int)geteuid();
+      }
+      pwd = getpwuid((uid_t)uid);
+    } else {
+      pwd = getpwnam(admin_user);
+    }
+
+    if (pwd) {
+      admin_uid = pwd->pw_uid;
+      admin_gid = pwd->pw_gid;
+      admin_user_p = true;
+    } else {
+      cop_log(COP_FATAL, "can't get passwd entry for the admin user '%s' - [%d] %s\n", admin_user, errno, strerror(errno));
+      exit(1);
+    }
+  }
+}
+
+static void
+spawn_manager()
+{
+  char prog[PATH_NAME_MAX];
+  char *options[OPTIONS_MAX];
+  char *last;
+  char *tok;
+  int log_fd;
+  int err;
+  int key;
+
+  cop_log_trace("Entering spawn_manager()\n");
+  // Clean up shared memory segments.
+  if (sem_id > 0) {
+    key = sem_id;
+  } else {
+    key = 11452;
+  }
+  for (;; key++) {
+    err = semget(key, 1, 0666);
+    if (err < 0) {
+      break;
+    }
+#if defined(solaris) || defined(kfreebsd) || defined(unknown)
+    err = semctl(err, 1, IPC_RMID);
+#else
+    union semun dummy_semun;
+    memset(&dummy_semun, 0, sizeof(dummy_semun));
+    err = semctl(err, 1, IPC_RMID, dummy_semun);
+#endif
+    if (err < 0) {
+      break;
+    }
+  }
+
+  Layout::relative_to(prog, sizeof(prog), bin_path, manager_binary);
+  if (access(prog, R_OK | X_OK) == -1) {
+    cop_log(COP_FATAL, "unable to access() manager binary \"%s\" [%d '%s']\n", prog, errno, strerror(errno));
+    exit(1);
+  }
+
+  cop_log_trace("spawn_manager: Launching %s with options '%s'\n", prog, manager_options);
+  int i;
+  for (i = 0; i < OPTIONS_MAX; i++) {
+    options[i] = NULL;
+  }
+  options[0] = prog;
+  i = 1;
+  tok = strtok_r(manager_options, " ", &last);
+  options[i++] = tok;
+  if (tok != NULL) {
+    while (i < OPTIONS_MAX && (tok = strtok_r(NULL, " ", &last))) {
+      options[i++] = tok;
+    }
+  }
+
+  // Move any traffic.out that we can not write to, out
+  //  of the way (TSqa2232)
+  // coverity[fs_check_call]
+  if (access(log_file, W_OK) < 0 && errno == EACCES) {
+    char old_log_file[PATH_NAME_MAX];
+    snprintf(old_log_file, sizeof(old_log_file), "%s.old", log_file);
+    // coverity[toctou]
+    rename(log_file, old_log_file);
+    cop_log(COP_WARNING, "rename %s to %s as it is not accessible.\n", log_file, old_log_file);
+  }
+  // coverity[toctou]
+  if ((log_fd = open(log_file, O_WRONLY | O_APPEND | O_CREAT, 0640)) < 0) {
+    cop_log(COP_WARNING, "unable to open log file \"%s\" [%d '%s']\n", log_file, errno, strerror(errno));
+  }
+
+  err = fork();
+  if (err == 0) {
+    if (log_fd >= 0) {
+      dup2(log_fd, STDOUT_FILENO);
+      dup2(log_fd, STDERR_FILENO);
+      close(log_fd);
+    }
+
+    err = execv(prog, options);
+    cop_log_trace("Somehow execv(%s, options, NULL) failed (%d)!\n", prog, err);
+    exit(1);
+  } else if (err == -1) {
+    cop_log(COP_FATAL, "unable to fork [%d '%s']\n", errno, strerror(errno));
+    exit(1);
+  } else {
+    close(log_fd);
+  }
+
+  manager_failures = 0;
+  cop_log_trace("Leaving spawn_manager()\n");
+}
+
+
+static int
+poll_read_or_write(int fd, int timeout, int inorout)
+{
+  struct pollfd info;
+  int err;
+
+  info.fd = fd;
+  info.events = inorout;
+  info.revents = 0;
+
+  do {
+    err = poll(&info, 1, timeout);
+  } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
+
+  if ((err > 0) && (info.revents & inorout)) {
+    return 1;
+  }
+
+  return err;
+}
+
+inline static int
+poll_read(int fd, int timeout)
+{
+  return poll_read_or_write(fd, timeout, POLLIN);
+}
+
+inline static int
+poll_write(int fd, int timeout)
+{
+  return poll_read_or_write(fd, timeout, POLLOUT);
+}
+
+static int
+open_socket(int port, const char *ip = NULL, char const *ip_to_bind = NULL)
+{
+
+  int sock = 0;
+  struct addrinfo hints;
+  struct addrinfo *result = NULL;
+  struct addrinfo *result_to_bind = NULL;
+  char port_str[8] = {'\0'};
+  int err = 0;
+
+  cop_log_trace("Entering open_socket(%d, %s, %s)\n", port, ip, ip_to_bind);
+  if (!ip) {
+    ip = localhost;
+  }
+
+#if defined(linux)
+  // TS-1075 : auto-port ::connect DoS on high traffic linux systems
+  // unbound connections are "unsafe" in high connection count environments
+  if (!ip_to_bind) {
+    ip = localhost;
+  }
+#endif
+
+  snprintf(port_str, sizeof(port_str), "%d", port);
+  memset(&hints, 0, sizeof(hints));
+  hints.ai_family = AF_UNSPEC;
+  hints.ai_socktype = SOCK_STREAM;
+
+  err = getaddrinfo(ip, port_str, &hints, &result);
+  if (err != 0) {
+    cop_log (COP_WARNING, "(test) unable to get address info [%d %s] at ip %s, port %s\n", err, gai_strerror(err), ip, port_str);
+    goto getaddrinfo_error;
+  }
+
+  // Create a socket
+  do {
+    sock = socket(result->ai_family, result->ai_socktype, 0);
+  } while ((sock < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
+
+  if (sock < 0) {
+    cop_log(COP_WARNING, "(test) unable to create socket [%d '%s']\n", errno, strerror(errno));
+    goto error;
+  }
+
+  if (ip_to_bind) {
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_family = result->ai_family;
+    hints.ai_socktype = result->ai_socktype;
+
+    err = getaddrinfo(ip_to_bind, NULL, &hints, &result_to_bind);
+    if (err != 0) {
+      cop_log (COP_WARNING, "(test) unable to get address info [%d %s] at ip %s\n", err, gai_strerror(err), ip_to_bind);
+      freeaddrinfo(result_to_bind);
+      goto error;
+    }
+
+#if defined(linux)
+    // TS-1075 : auto-port ::connect DoS on high traffic linux systems
+    // Bash the port on ::bind so that we always use the same port
+    if (0 != source_port) {
+      if (result_to_bind->ai_addr->sa_family == AF_INET) {
+        ((sockaddr_in *)result_to_bind->ai_addr)->sin_port = htons(source_port);
+      } else {
+        ((sockaddr_in6 *)result_to_bind->ai_addr)->sin6_port = htons(source_port);
+      }
+
+      // also set REUSEADDR so that previous cop connections in the TIME_WAIT state
+      // do not interfere
+      if (safe_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, SOCKOPT_ON, sizeof(int)) < 0) {
+        cop_log (COP_WARNING, "(test) unable to set REUSEADDR socket option [%d '%s']\n", errno, strerror (errno));
+      }
+    }
+#endif
+
+    if (safe_bind(sock, result_to_bind->ai_addr, result_to_bind->ai_addrlen) < 0) {
+      cop_log (COP_WARNING, "(test) unable to bind socket [%d '%s']\n", errno, strerror (errno));
+    }
+
+    freeaddrinfo(result_to_bind);
+  }
+
+  // Put the socket in non-blocking mode...just to be extra careful
+  // that we never block.
+  do {
+    err = fcntl(sock, F_SETFL, O_NONBLOCK);
+  } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
+
+  if (err < 0) {
+    cop_log(COP_WARNING, "(test) unable to put socket in non-blocking mode [%d '%s']\n", errno, strerror(errno));
+    goto error;
+  }
+  // Connect to the specified port on the machine we're running on.
+  do {
+    err = connect(sock, result->ai_addr, result->ai_addrlen);
+  } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
+
+  if ((err < 0) && (errno != EINPROGRESS)) {
+    cop_log(COP_WARNING, "(test) unable to connect to server [%d '%s'] at port %d\n", errno, strerror(errno), port);
+    goto error;
+  }
+  cop_log_trace("Leaving open_socket(%d, %s, %s) --> %d\n", port, ip, ip_to_bind, sock);
+  freeaddrinfo(result);
+  return sock;
+
+error:
+  if (sock >= 0) {
+    close_socket(sock);
+  }
+  cop_log_trace("Leaving open_socket(%d, %s, %s) --> %d\n", port, ip, ip_to_bind, -1);
+getaddrinfo_error:
+  freeaddrinfo(result);
+  return -1;
+}
+
+static int
+test_port(int port, const char *request, char *buffer, int bufsize,
+          int64_t test_timeout, char const *ip = NULL, char const *ip_to_bind = NULL)
+{
+  int64_t start_time, timeout;
+  int sock;
+  size_t length = strlen(request);
+  int64_t err, idx;
+
+  start_time = milliseconds();
+
+  sock = open_socket(port, ip, ip_to_bind);
+  if (sock < 0) {
+    goto error;
+  }
+
+  timeout = milliseconds() - start_time;
+  if (timeout >= test_timeout) {
+    cop_log(COP_WARNING, "(test) timeout occurred [%" PRId64 " ms]\n", timeout);
+    goto error;
+  }
+  timeout = test_timeout - timeout;
+
+  err = poll_write(sock, timeout);
+  if (err < 0) {
+    cop_log(COP_WARNING, "(test) poll write failed [%d '%s']\n", errno, strerror(errno));
+    goto error;
+  } else if (err == 0) {
+    cop_log(COP_WARNING, "(test) write timeout [%" PRId64 " ms]\n", timeout);
+    goto error;
+  }
+  // Write the request to the server.
+  while (length > 0) {
+    do {
+      err = write(sock, request, length);
+    } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
+
+    if (err < 0) {
+      cop_log(COP_WARNING, "(test) write failed [%d '%s']\n", errno, strerror(errno));
+      goto error;
+    }
+
+    request += err;
+    length -= err;
+  }
+
+  idx = 0;
+  for (;;) {
+    if (idx >= bufsize) {
+      cop_log(COP_WARNING, "(test) response is too large [%" PRId64 "]\n", idx);
+      goto error;
+    }
+
+    timeout = milliseconds() - start_time;
+    if (timeout >= test_timeout) {
+      cop_log(COP_WARNING, "(test) timeout occurred [%" PRId64 " ms]\n", timeout);
+      goto error;
+    }
+    timeout = test_timeout - timeout;
+
+    err = poll_read(sock, timeout);
+    if (err < 0) {
+      cop_log(COP_WARNING, "(test) poll read failed [%d '%s']\n", errno, strerror(errno));
+      goto error;
+    } else if (err == 0) {
+      cop_log(COP_WARNING, "(test) read timeout [%" PRId64 " ]\n", timeout);
+      goto error;
+    }
+
+    do {
+      err = read(sock, &buffer[idx], bufsize - idx);
+    } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
+
+    if (err < 0) {
+      cop_log(COP_WARNING, "(test) read failed [%d '%s']\n", errno, strerror(errno));
+      goto error;
+    } else if (err == 0) {
+      buffer[idx] = '\0';
+      close(sock);
+      return 0;
+    } else {
+      idx += err;
+    }
+  }
+
+error:
+  if (sock >= 0) {
+    close_socket(sock);
+  }
+  return -1;
+}
+
+static int
+read_manager_string(const char *variable, char *value, size_t val_len)
+{
+  char buffer[4096];
+  char request[1024];
+  char *p, *e;
+  int err;
+
+  snprintf(request, sizeof(request), "read %s\n", variable);
+
+  err = test_port(rs_port, request, buffer, 4095, manager_timeout * 1000);
+  if (err < 0) {
+    return err;
+  }
+
+  p = strstr(buffer, variable);
+  if (!p) {
+    cop_log(COP_WARNING, "(manager test) could not find record name in response\n");
+    return -1;
+  }
+  p += strlen(variable);
+
+  p = strstr(p, "Val:");
+  if (!p) {
+    cop_log(COP_WARNING, "(manager test) could not find record value in response\n");
+    return -1;
+  }
+  p += sizeof("Val:") - 1;
+
+  while (*p && (*p != '\'')) {
+    p += 1;
+  }
+
+  if (*p == '\0') {
+    cop_log(COP_WARNING, "(manager test) could not find properly delimited value in response\n");
+    return -1;
+  }
+  p += 1;
+
+  e = p;
+  while (*e && (*e != '\'')) {
+    e += 1;
+  }
+
+  if (*e != '\'') {
+    cop_log(COP_WARNING, "(manager test) could not find properly delimited value in response\n");
+    return -1;
+  }
+
+  ink_strlcpy(value, p, MIN((size_t)(e - p + 1), val_len));
+
+  return 0;
+}
+
+static int
+read_manager_int(const char *variable, int *value)
+{
+  char buffer[4096];
+  char request[1024];
+  char *p;
+  int err;
+
+  snprintf(request, sizeof(request), "read %s\n", variable);
+
+  err = test_port(rs_port, request, buffer, 4095, manager_timeout * 1000);
+  if (err < 0) {
+    return err;
+  }
+
+  p = strstr(buffer, variable);
+  if (!p) {
+    cop_log(COP_WARNING, "(manager test) could not find record name in response\n");
+    return -1;
+  }
+  p += strlen(variable);
+
+  p = strstr(p, "Val:");
+  if (!p) {
+    cop_log(COP_WARNING, "(manager test) could not find record value in response\n");
+    return -1;
+  }
+  p += sizeof("Val:") - 1;
+
+  while (*p && (*p != '\'')) {
+    p += 1;
+  }
+
+  if (*p == '\0') {
+    cop_log(COP_WARNING, "(manager test) could not find properly delimited value in response\n");
+    return -1;
+  }
+  p += 1;
+
+  *value = 0;
+  while (isdigit(*p)) {
+    *value = *value * 10 + (*p - '0');
+    p += 1;
+  }
+
+  if (*p != '\'') {
+    cop_log(COP_WARNING, "(manager test) could not find properly delimited value in response\n");
+    return -1;
+  }
+  return 0;
+}
+
+static int
+read_mgmt_cli_int(const char *variable, int *value)
+{
+  TSInt val;
+
+  if (TSRecordGetInt(variable, &val) != TS_ERR_OKAY) {
+    cop_log(COP_WARNING, "(cli test) could not communicate with mgmt cli\n");
+    return -1;
+  }
+  *value = val;
+  return 0;
+}
+
+
+static int
+test_rs_port()
+{
+  char buffer[4096];
+  int err;
+
+  err = read_manager_string("proxy.config.manager_binary", buffer, sizeof(buffer));
+  if (err < 0) {
+    return err;
+  }
+
+  if (strcmp(buffer, manager_binary) != 0) {
+    cop_log(COP_WARNING, "(manager test) bad response value\n");
+    return -1;
+  }
+
+  return 0;
+}
+
+
+static int
+test_mgmt_cli_port()
+{
+  TSString val = NULL;
+  int ret = 0;
+
+  if (TSRecordGetString("proxy.config.manager_binary", &val) !=  TS_ERR_OKAY) {
+    cop_log(COP_WARNING, "(cli test) unable to retrieve manager_binary\n");
+    ret = -1;
+  } else {
+    if (strcmp(val, manager_binary) != 0) {
+      cop_log(COP_WARNING, "(cli test) bad response value, got %s, expected %s\n", val, manager_binary);
+      ret = -1;
+    }
+  }
+
+  if (val)
+    TSfree(val);
+  return ret;
+}
+
+
+static int
+test_http_port(int port, char *request, int timeout, char const *ip = NULL, char const *ip_to_bind = NULL)
+{
+  char buffer[4096];
+  char *p;
+  int err;
+
+  err = test_port(port, request, buffer, 4095, timeout, ip, ip_to_bind);
+  if (err < 0) {
+    return err;
+  }
+
+  p = buffer;
+
+  if (strncmp(p, "HTTP/", 5) != 0) {
+    cop_log(COP_WARNING, "(http test) received malformed response\n");
+    return -1;
+  }
+
+  p += 5;
+  while (*p && !isspace(*p)) {
+    p += 1;
+  }
+
+  while (*p && isspace(*p)) {
+    p += 1;
+  }
+
+  if (strncmp(p, "200", 3) != 0) {
+    char pstatus[4] = { 0 };
+    ink_strlcpy(pstatus, p, sizeof(pstatus));
+    cop_log(COP_WARNING, "(http test) received non-200 status(%s)\n", pstatus);
+    return -1;
+  }
+
+  p = strstr(p, "\r\n\r\n");
+  if (!p) {
+    cop_log(COP_WARNING, "(http test) could not find end of header\n");
+    return -1;
+  }
+
+  p += 4;
+  while (*p) {
+    if (strncmp(p, "abcdefghijklmnopqrstuvwxyz", 26) != 0) {
+      cop_log(COP_WARNING, "(http test) corrupted response data\n");
+      return -1;
+    }
+
+    p += 26;
+    while (*p && (*p != '\n')) {
+      p += 1;
+    }
+    p += 1;
+  }
+
+  return 0;
+}
+
+static int
+test_server_http_port()
+{
+  char request[1024] = {'\0'};
+
+  // Generate a request for a the 'synthetic.txt' document the manager
+  // servers up on the autoconf port.
+  snprintf(request, sizeof(request), "GET http://127.0.0.1:%d/synthetic.txt HTTP/1.0\r\n\r\n", autoconf_port);
+
+  return test_http_port(http_backdoor_port, request, server_timeout * 1000, localhost, localhost);
+}
+
+static int
+heartbeat_manager()
+{
+  int err;
+
+  cop_log_trace("Entering heartbeat_manager()\n");
+  // the CLI, and the rsport if cluster is enabled.
+  err = test_mgmt_cli_port();
+  if ((0 == err) && (cluster_type != NO_CLUSTER))
+    err = test_rs_port();
+
+  if (err < 0) {
+    // See heartbeat_server()'s comments for how we determine a server/manager failure.
+    manager_failures += 1;
+    cop_log(COP_WARNING, "manager heartbeat [variable] failed [%d]\n", manager_failures);
+
+    if (manager_failures > 1) {
+      manager_failures = 0;
+      cop_log(COP_WARNING, "killing manager\n");
+      safe_kill(manager_lockfile, manager_binary, true);
+    }
+    cop_log_trace("Leaving heartbeat_manager() --> %d\n", err);
+    return err;
+  }
+
+  cop_log_trace("Leaving heartbeat_manager() --> %d\n", err);
+  return err;
+}
+
+static int
+heartbeat_server()
+{
+  int err;
+
+  cop_log_trace("Entering heartbeat_server()\n");
+  err = test_server_http_port();
+
+  if (err < 0) {
+    // If the test failed, increment the count of the number of
+    // failures. We don't kill the server the first time the test
+    // fails because we might just have gotten caught in a race
+    // where we decided to do the test because we thought the
+    // server was up even though somebody was in the process of
+    // bringing it down. The "server_up" function will reset
+    // 'server_failures' if it determines the server is down.
+
+    server_failures += 1;
+    cop_log(COP_WARNING, "server heartbeat failed [%d]\n", server_failures);
+
+    // If this is the second time that the server test has failed
+    // we kill the server.
+    if (server_failures > 1) {
+      server_failures = 0;
+      cop_log(COP_WARNING, "killing server\n");
+
+      // TSqa02622: Change the ALRM signal handler while
+      //   trying to kill the process since if a core
+      //   is being written, it could take a long time
+      //   Set a new alarm so that we can print warnings
+      //   if it is taking too long to kill the server
+      //
+      safe_kill(server_lockfile, server_binary, false);
+    }
+  } else {
+    if (server_failures)
+      cop_log(COP_WARNING, "server heartbeat succeeded\n");
+    server_failures = 0;
+  }
+
+  cop_log_trace("Leaving heartbeat_server() --> %d\n", err);
+  return err;
+}
+
+static int
+server_up()
+{
+  static int old_val = 0;
+  int val = -1;
+  int err;
+
+  cop_log_trace("Entering server_up()\n");
+  if (cluster_type != NO_CLUSTER) {
+    err = read_manager_int("proxy.node.proxy_running", &val);
+  } else {
+    err = read_mgmt_cli_int("proxy.node.proxy_running", &val);
+  }
+
+  if (err < 0) {
+    cop_log(COP_WARNING, "could not contact manager, assuming server is down\n");
+    cop_log_trace("Leaving server_up() --> 0\n");
+    return 0;
+  }
+
+  if (val != old_val) {
+    server_failures = 0;
+    server_not_found = 0;
+    old_val = val;
+  }
+
+  if (val == 1) {
+    cop_log_trace("Leaving server_up() --> 1\n");
+    return 1;
+  } else {
+    cop_log_trace("Leaving server_up() --> 0\n");
+    return 0;
+  }
+}
+
+
+//         |  state  |  status  |  action
+// --------|---------|----------|---------------
+// manager |   up    |    ok    |  nothing
+// server  |   up    |    ok    |
+// --------|---------|----------|---------------
+// manager |   up    |    bad   |  kill manager
+// server  |   up    |    ?     |
+// --------|---------|----------|---------------
+// manager |   up    |    ok    |  kill manager
+// server  |   down  |    ?     |
+// --------|---------|----------|---------------
+// manager |   up    |    ok    |  kill server
+// server  |   up    |    bad   |
+
+
+static void
+check_programs()
+{
+  int err;
+  pid_t holding_pid;
+
+  cop_log_trace("Entering check_programs()\n");
+
+  // Try to get the manager lock file. If we succeed in doing this,
+  // it means there is no manager running.
+  Lockfile manager_lf(manager_lockfile);
+  err = manager_lf.Open(&holding_pid);
+  chown_file_to_admin_user(manager_lockfile);
+
+  if (err > 0) {
+    // 'lockfile_open' returns the file descriptor of the opened
+    // lockfile.  We need to close this before spawning the
+    // manager so that the manager can grab the lock.
+    manager_lf.Close();
+
+#if !defined(MANAGER_FLAP_DETECTION)
+    // Make sure we don't have a stray traffic server running.
+    cop_log(COP_WARNING, "traffic_manager not running, making sure traffic_server is dead\n");
+    safe_kill(server_lockfile, server_binary, false);
+    // Spawn the manager.
+    cop_log(COP_WARNING, "spawning traffic_manager\n");
+    spawn_manager();
+#else
+    // Make sure we don't have a stray traffic server running.
+    if (!manager_flapping) {
+      cop_log(COP_WARNING, "traffic_manager not running, making sure traffic_server is dead\n");
+      safe_kill(server_lockfile, server_binary, false);
+    }
+    // Spawn the manager (check for flapping manager too)
+    ink_hrtime now = milliseconds();
+    if (!manager_flapping) {
+      if ((manager_flap_interval_start_time == 0) ||
+          (now - manager_flap_interval_start_time > MANAGER_FLAP_INTERVAL_MSEC)
+        ) {
+        // either:
+        // . it's our first time through
+        // . we were flapping a while ago, but we would
+        //   like to retry now
+        // . it's been a while since we last tried to start
+        //   traffic_manager
+        manager_flap_count = 0;
+      }
+      if (manager_flap_count >= MANAGER_MAX_FLAP_COUNT) {
+        // we've flapped too many times, hold off for a while
+        cop_log(COP_WARNING, "unable to start traffic_manager, retrying in %d second(s)\n",
+                MANAGER_FLAP_RETRY_MSEC / 1000);
+        manager_flapping = true;
+        manager_flap_retry_start_time = now;
+      } else {
+        // try to spawn traffic_manager
+        cop_log(COP_WARNING, "spawning traffic_manager\n");
+        spawn_manager();
+        // track spawn attempt
+        if (manager_flap_count == 0) {
+          manager_flap_interval_start_time = now;
+        }
+        manager_flap_count++;
+      }
+    } else {
+      // we were flapping, take some time off and don't call
+      // spawn_manager
+      if (now - manager_flap_retry_start_time > MANAGER_FLAP_RETRY_MSEC) {
+        manager_flapping = false;
+        manager_flap_interval_start_time = 0;
+      }
+    }
+#endif
+  } else {
+    // If there is a manager running we want to heartbeat it to
+    // make sure it hasn't wedged. If the manager test succeeds we
+    // check to see if the server is up. (That is, it hasn't been
+    // brought down via the UI).  If the manager thinks the server
+    // is up, we make sure there is actually a server process
+    // running. If there is we test it.
+
+    alarm(2 * manager_timeout);
+    err = heartbeat_manager();
+    alarm(0);
+
+    if (err < 0) {
+      return;
+    }
+
+    if (server_up() <= 0) {
+      return;
+    }
+
+    Lockfile server_lf(server_lockfile);
+    err = server_lf.Open(&holding_pid);
+
+    if (err > 0) {
+      server_lf.Close();
+
+      server_not_found += 1;
+      cop_log(COP_WARNING, "cannot find traffic_server [%d]\n", server_not_found);
+
+      if (server_not_found > 1) {
+        server_not_found = 0;
+        cop_log(COP_WARNING, "killing manager\n");
+        safe_kill(manager_lockfile, manager_binary, true);
+      }
+    } else {
+      alarm(2 * server_timeout);
+      heartbeat_server();
+      alarm(0);
+    }
+  }
+  cop_log_trace("Leaving check_programs()\n");
+}
+
+static void
+check_memory()
+{
+  // TODO: We need to take care of other systems, ie bsd, solaris.
+  //    And we should try to summarize whether the swapping is really
+  //    putting the server under memory pressure. Or should we check
+  //    the process memory usage of the server & manager?
+  cop_log_trace("Entering check_memory()\n");
+#if defined(linux)
+  if (check_memory_min_swapfree_kb > 0 || check_memory_min_memfree_kb > 0) {
+    FILE *fp;
+    char buf[LINE_MAX];
+    long long memfree, swapfree, swapsize;
+    memfree = swapfree = swapsize = 0;
+    if ((fp = fopen("/proc/meminfo", "r"))) {
+      while (fgets(buf, sizeof buf, fp)) {
+        if (strncmp(buf, "MemFree:", sizeof "MemFree:" - 1) == 0)
+          memfree = strtoll(buf + sizeof "MemFree:" - 1, 0, 10);
+        else if (strncmp(buf, "SwapFree:", sizeof "SwapFree:" - 1) == 0)
+          swapfree = strtoll(buf + sizeof "SwapFree:" - 1, 0, 10);
+        else if (strncmp(buf, "SwapTotal:", sizeof "SwapTotal:" - 1) == 0)
+          swapsize = strtoll(buf + sizeof "SwapTotal:" - 1, 0, 10);
+      }
+      fclose(fp);
+      // simple heuristic for linux
+      //    swapsize swapfree memfree
+      // 1:    >0      low     high    (bad)
+      // 2:    >0      high    low     (okay)
+      // 3:    >0      low     low     (bad; covered by 1)
+      // 4:     0       0      high    (okay)
+      // 5:     0       0      low     (bad)
+      if ((swapsize != 0 && swapfree < check_memory_min_swapfree_kb) ||
+          (swapsize == 0 && memfree < check_memory_min_memfree_kb)) {
+        cop_log(COP_WARNING, "Low memory available (swap: %dkB, mem: %dkB)\n", (int) swapfree, (int) memfree);
+        cop_log(COP_WARNING, "Killing '%s' and '%s'\n", manager_binary, server_binary);
+        manager_failures = 0;
+        safe_kill(manager_lockfile, manager_binary, true);
+        server_failures = 0;
+        safe_kill(server_lockfile, server_binary, false);
+      }
+    } else {
+      cop_log(COP_WARNING, "Unable to open /proc/meminfo: %s\n", strerror(errno));
+    }
+  }
+#endif
+  cop_log_trace("Leaving check_memory()\n");
+}
+
+static int
+check_no_run()
+{
+  char path[PATH_NAME_MAX * 2];
+  struct stat info;
+  int err;
+
+  cop_log_trace("Entering check_no_run()\n");
+  snprintf(path, sizeof(path), "%s/no_cop", runtime_dir);
+
+  do {
+    err = stat(path, &info);
+  } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
+
+  if (err < 0) {
+    cop_log_trace("Leaving check_no_run() --> 0\n");
+    return 0;
+  }
+
+  cop_log(COP_WARNING, "encountered \"%s\" file...exiting\n", path);
+  cop_log_trace("Leaving check_no_run() --> -1\n");
+  return -1;
+}
+
+// Changed function from taking no argument and returning void
+// to taking a void* and returning a void*. The change was made
+// so that we can call ink_thread_create() on this function
+// in the case of running cop as a win32 service.
+static void*
+check(void *arg)
+{
+  bool mgmt_init = false;
+  cop_log_trace("Entering check()\n");
+
+  for (;;) {
+    // problems with the ownership of this file as root Make sure it is
+    // owned by the admin user
+    chown_file_to_admin_user(manager_lockfile);
+    chown_file_to_admin_user(server_lockfile);
+
+    alarm(2 * (sleep_time + manager_timeout * 2 + server_timeout));
+
+    if (check_no_run() < 0) {
+      break;
+    }
+    // Log any SIGCLD singals we received
+    if (child_pid > 0) {
+      if (WIFEXITED(child_status) == 0) {
+        // Child terminated abnormally
+        cop_log(COP_WARNING,
+                "cop received non-normal child status signal [%d %d]\n", child_pid, WEXITSTATUS(child_status));
+      } else {
+        // normal termination
+        cop_log(COP_WARNING, "cop received child status signal [%d %d]\n", child_pid, child_status);
+      }
+      if (WIFSIGNALED(child_status)) {
+        int sig = WTERMSIG(child_status);
+        cop_log(COP_WARNING, "child terminated due to signal %d: %s\n", sig, strsignal(sig));
+      }
+
+      child_pid = 0;
+      child_status = 0;
+    }
+
+    // Re-read the config file information
+    config_reload_records();
+
+    // Check to make sure the programs are running
+    check_programs();
+
+    // Check to see if we're running out of free memory
+    check_memory();
+
+    // Pause to catch our breath. (10 seconds).
+    // Use 'millisleep()' because normal 'sleep()' interferes with
+    // the SIGALRM signal which we use to heartbeat the cop.
+    millisleep(sleep_time * 1000);
+
+    // We do this after the first round of checks, since the first "check" will spawn traffic_manager
+    if (!mgmt_init) {
+      TSInit(Layout::get()->runtimedir, static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS));
+      mgmt_init = true;
+    }
+  }
+
+  // Done with the mgmt API.
+  TSTerminate();
+
+  cop_log_trace("Leaving check()\n");
+  return arg;
+}
+
+
+static void
+check_lockfile()
+{
+  int err;
+  pid_t holding_pid;
+
+  cop_log_trace("Entering check_lockfile()\n");
+  Lockfile cop_lf(cop_lockfile);
+  err = cop_lf.Get(&holding_pid);
+  if (err < 0) {
+    cop_log(COP_WARNING, "periodic cop heartbeat couldn't open '%s' (errno %d)\n", cop_lockfile, -err);
+    exit(1);
+  } else if (err == 0) {
+    cop_log(COP_DEBUG, "periodic heartbeat successful, another cop still on duty\n");
+    exit(1);
+  }
+
+  cop_log(LOG_NOTICE, "--- Cop Starting [Version: %s] ---\n", appVersionInfo.FullVersionInfoStr);
+  cop_log_trace("Leaving check_lockfile()\n");
+}
+
+static void
+init_signals()
+{
+  struct sigaction action;
+
+  cop_log_trace("Entering init_signals()\n");
+  // Handle the SIGTERM and SIGINT signal:
+  // We kill the process group and wait() for all children
+  action.sa_handler = sig_term;
+  sigemptyset(&action.sa_mask);
+  action.sa_flags = 0;
+
+  sigaction(SIGTERM, &action, NULL);
+  sigaction(SIGINT, &action, NULL);
+
+  // Handle the SIGCHLD signal. We simply reap all children that
+  // die (which should only be spawned traffic_manager's).
+  action.sa_handler = sig_child;
+  sigemptyset(&action.sa_mask);
+  action.sa_flags = 0;
+
+  sigaction(SIGCHLD, &action, NULL);
+
+  // Handle a bunch of fatal signals. We simply call abort() when
+  // these signals arrive in order to generate a core. There is some
+  // difficulty with generating core files when linking with libthread
+  // under solaris.
+#if defined(solaris)
+  action.sa_handler = NULL;
+  action.sa_sigaction = sig_fatal;
+#else
+  action.sa_handler = sig_fatal;
+#endif
+  sigemptyset(&action.sa_mask);
+#if defined(solaris)
+  action.sa_flags = SA_SIGINFO;
+#else
+  action.sa_flags = 0;
+#endif
+
+  sigaction(SIGQUIT, &action, NULL);
+  sigaction(SIGILL, &action, NULL);
+  sigaction(SIGFPE, &action, NULL);
+  sigaction(SIGBUS, &action, NULL);
+  sigaction(SIGSEGV, &action, NULL);
+#if !defined(linux)
+  sigaction(SIGEMT, &action, NULL);
+  sigaction(SIGSYS, &action, NULL);
+#endif
+
+  // Handle the SIGALRM signal. We use this signal to make sure the
+  // cop never wedges. It gets reset every time through its loop. If
+  // the alarm ever expires we treat it as a fatal signal and dump
+  // core, secure in the knowledge we'll get restarted.
+  set_alarm_death();
+
+  action.sa_handler = sig_ignore;
+  sigemptyset(&action.sa_mask);
+  action.sa_flags = 0;
+
+  sigaction(SIGPIPE, &action, NULL);
+  cop_log_trace("Leaving init_signals()\n");
+}
+
+static void
+init_config_dir()
+{
+
+  struct stat info;
+
+  cop_log_trace("Entering init_config_dir()\n");
+
+  root_dir = Layout::get()->prefix;
+  runtime_dir = Layout::get()->runtimedir;
+  config_dir = Layout::get()->sysconfdir;
+
+  if (chdir(root_dir) < 0) {
+    cop_log(COP_FATAL, "unable to change to root directory \"%s\" [%d '%s']\n", root_dir, errno, strerror(errno));
+    cop_log(COP_FATAL," please set correct path in env variable TS_ROOT \n");
+    exit(1);
+  }
+
+  if (stat(config_dir, &info) < 0) {
+    cop_log(COP_FATAL, "unable to locate config directory '%s'\n",config_dir);
+    cop_log(COP_FATAL, " please try setting correct root path in env variable TS_ROOT \n");
+    exit(1);
+  }
+
+  if (stat(runtime_dir, &info) < 0) {
+    cop_log(COP_FATAL, "unable to locate local state directory '%s'\n",runtime_dir);
+    cop_log(COP_FATAL, " please try setting correct root path in either env variable TS_ROOT \n");
+    exit(1);
+  }
+  cop_log_trace("Leaving init_config_dir()\n");
+}
+
+static void
+init_lockfiles()
+{
+
+  cop_log_trace("Entering init_lockfiles()\n");
+  Layout::relative_to(cop_lockfile, sizeof(cop_lockfile), Layout::get()->runtimedir, COP_LOCK);
+  Layout::relative_to(manager_lockfile, sizeof(manager_lockfile), Layout::get()->runtimedir, MANAGER_LOCK);
+  Layout::relative_to(server_lockfile, sizeof(server_lockfile), Layout::get()->runtimedir, SERVER_LOCK);
+
+  cop_log_trace("Leaving init_lockfiles()\n");
+}
+
+inline static void
+init_syslog()
+{
+  openlog("traffic_cop", LOG_PID | LOG_NDELAY | LOG_NOWAIT, LOG_DAEMON);
+}
+
+static void
+init_config_file()
+{
+  struct stat info;
+
+  cop_log_trace("Entering init_config_file()\n");
+  Layout::relative_to(config_file, sizeof(config_file), config_dir, "records.config.shadow");
+  if (stat(config_file, &info) < 0) {
+    Layout::relative_to(config_file, sizeof(config_file), config_dir, "records.config");
+    if (stat(config_file, &info) < 0) {
+      cop_log(COP_FATAL, "unable to locate \"%s/records.config\" or \"%s/records.config.shadow\"\n", config_dir, config_dir);
+      exit(1);
+    }
+  }
+  cop_log_trace("Leaving init_config_file()\n");
+}
+
+static void
+init()
+{
+  cop_log_trace("Entering init()\n");
+
+  RecConfigFileInit();
+
+  init_signals();
+  init_syslog();
+
+  init_config_dir();
+
+  init_config_file();
+  init_lockfiles();
+  check_lockfile();
+
+  cop_log_trace("Leaving init()\n");
+}
+
+int version_flag = 0;
+
+int
+main(int argc, char *argv[])
+{
+  int fd;
+  appVersionInfo.setup(PACKAGE_NAME,"traffic_cop", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
+
+  // Before accessing file system initialize Layout engine
+  Layout::create();
+
+  for (int i = 1; i < argc; i++) {
+    if (strcmp(argv[i], "-stop") == 0) {
+      ink_fputln(stdout, "Cool! I think I'll be a STOP cop!");
+      killsig = SIGSTOP;
+    } else if (strcmp(argv[i], "-V") == 0) {
+      ink_fputln(stderr, appVersionInfo.FullVersionInfoStr);
+      exit(0);
+    }
+  }
+  // Detach STDIN, STDOUT, and STDERR (basically, "nohup"). /leif
+  signal(SIGHUP, SIG_IGN);
+  signal(SIGTSTP, SIG_IGN);
+  signal(SIGTTOU, SIG_IGN);
+  signal(SIGTTIN, SIG_IGN);
+
+  // setup supplementary groups if it is not set. any way, worth a try.
+  if (0 == getgroups(0, NULL)) {
+    uid_t uid = getuid();
+    gid_t gid = getgid();
+
+    const int bufSize = 1024;
+    char buf[bufSize];
+
+    struct passwd passwdInfo;
+    struct passwd *ppasswd = NULL;
+    int res;
+    res = getpwuid_r(uid, &passwdInfo, buf, bufSize, &ppasswd);
+    if (!res && ppasswd) {
+        initgroups(ppasswd->pw_name,gid);
+    }
+  }
+
+  setsid();                     // Important, thanks Vlad. :)
+#if (defined(freebsd) && !defined(kfreebsd)) || defined(openbsd)
+  setpgrp(0,0);
+#else
+  setpgrp();
+#endif
+
+  close(STDIN_FILENO);
+  close(STDOUT_FILENO);
+  close(STDERR_FILENO);
+  if ((fd = open("/dev/null", O_WRONLY, 0)) >= 0) {
+    fcntl(fd, F_DUPFD, STDIN_FILENO);
+    fcntl(fd, F_DUPFD, STDOUT_FILENO);
+    fcntl(fd, F_DUPFD, STDERR_FILENO);
+    close(fd);
+  } else {
+    ink_fputln(stderr, "Unable to open /dev/null");
+    return 0;
+  }
+
+  // Initialize and start it up.
+  init();
+  check(NULL);
+
+  return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6917d8ef/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 99a2239..ef218c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1841,8 +1841,8 @@ AC_SUBST([TFW_PACKAGE_SUFFIX])
 
 AC_CONFIG_FILES([
   Makefile
-  cop/Makefile
   cmd/Makefile
+  cmd/traffic_cop/Makefile
   cmd/traffic_top/Makefile
   doc/Doxyfile
   doc/Makefile

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/6917d8ef/cop/Makefile.am
----------------------------------------------------------------------
diff --git a/cop/Makefile.am b/cop/Makefile.am
deleted file mode 100644
index d89e8b0..0000000
--- a/cop/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# 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)/mgmt \
-  -I$(top_srcdir)/mgmt/cluster \
-  -I$(top_srcdir)/mgmt/api/include
-
-MGMT_DEFS = @MGMT_DEFS@
-DEFS += $(MGMT_DEFS)
-
-bin_PROGRAMS = traffic_cop
-
-traffic_cop_SOURCES = \
-  TrafficCop.cc
-
-traffic_cop_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
-
-traffic_cop_LDADD = \
-  $(top_builddir)/mgmt/api/libtsmgmt.la \
-  $(top_builddir)/lib/ts/libtsutil.la \
-  $(top_builddir)/lib/records/librec4cop.a \
-  @LIBRESOLV@ @LIBSSL@


[33/44] git commit: TS-1468: Check vary and accept headers on non-200 responses in cache

Posted by zw...@apache.org.
TS-1468: Check vary and accept headers on non-200 responses in cache


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

Branch: refs/heads/5.0.x
Commit: 46adeb3d0e4b8a927c24a479f2c1a91b28358c6e
Parents: ed8f6e9
Author: Bryan Call <bc...@apache.org>
Authored: Wed Nov 20 18:49:00 2013 -0800
Committer: Bryan Call <bc...@apache.org>
Committed: Wed Nov 20 18:49:00 2013 -0800

----------------------------------------------------------------------
 CHANGES                         | 2 ++
 proxy/http/HttpTransactCache.cc | 5 -----
 2 files changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/46adeb3d/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d2fa182..fdac461 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-1468] Check vary and accept headers on non-200 responses in cache
+
   *) [TS-2352] refine THREAD_ALLOC feature.
 
   *) [TS-2364] Introduce slice notation to field syntax in log format.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/46adeb3d/proxy/http/HttpTransactCache.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransactCache.cc b/proxy/http/HttpTransactCache.cc
index 8699ee8..1b0fc04 100644
--- a/proxy/http/HttpTransactCache.cc
+++ b/proxy/http/HttpTransactCache.cc
@@ -305,11 +305,6 @@ HttpTransactCache::calculate_quality_of_match(CacheLookupHttpConfig * http_confi
   if (client_request->method_get_wksidx() == HTTP_WKSIDX_PURGE)
     return (float)1.0;
 
-  // BZ49848 - for cached negative respones, we don't check for the
-  // Accept* headers. This should also be good for the 301 response.
-  if (obj_origin_server_response->status_get() != HTTP_STATUS_OK)
-    return (float)1.0;
-
   // Now calculate a quality based on all sorts of logic
   float q[4], Q;
   MIMEField *accept_field;


[16/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/Makefile.am
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/Makefile.am b/cmd/traffic_shell/Makefile.am
new file mode 100644
index 0000000..ba3356c
--- /dev/null
+++ b/cmd/traffic_shell/Makefile.am
@@ -0,0 +1,76 @@
+#
+# 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/ts \
+  -I$(top_srcdir)/mgmt/api/include
+
+bin_PROGRAMS = traffic_shell
+traffic_shell_SOURCES = \
+  cliAppInit.cc \
+  CliCreateCommands.h \
+  traffic_shell.cc \
+  CliMgmtUtils.h \
+  ConfigCmd.h \
+  createArgument.h \
+  createCommand.h \
+  definitions.h \
+  hashtable.h \
+  ShowCmd.h
+
+noinst_LIBRARIES = libtrafficshell.a
+libtrafficshell_a_SOURCES = \
+  CliCreateCommands.cc \
+  CliCreateCommands.h \
+  CliDisplay.cc \
+  CliDisplay.h \
+  CliMgmtUtils.cc \
+  CliMgmtUtils.h \
+  cliParseArg.cc \
+  commandOptions.h \
+  ConfigCmd.cc \
+  ConfigCmd.h \
+  ConfigUpgradeCmd.h \
+  ConfigUpgradeReadCmd.cc \
+  ConfigUpgradeWriteCmd.cc \
+  createArgument.cc \
+  createArgument.h \
+  createCommand.cc \
+  createCommand.h \
+  definitions.h \
+  hashtable.cc \
+  hashtable.h \
+  processArgument.cc \
+  ShowCmd.cc \
+  ShowCmd.h \
+  UtilCmds.cc \
+  UtilCmds.h
+
+traffic_shell_LDFLAGS =	@EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
+traffic_shell_LDADD = \
+  libtrafficshell.a \
+  $(top_builddir)/mgmt/api/libtsmgmt.la \
+  $(top_builddir)/mgmt/utils/libutils_lm.a \
+  $(top_builddir)/lib/ts/libtsutil.la \
+  $(LIBTCL) $(LIBREADLINE) \
+  @LIBRESOLV@ @LIBEXPAT@ @LIBSSL@ \
+  @LIBPCRE@ @LIBREADLINE@ \
+  -lm

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/ShowCmd.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ShowCmd.cc b/cmd/traffic_shell/ShowCmd.cc
new file mode 100644
index 0000000..ed71560
--- /dev/null
+++ b/cmd/traffic_shell/ShowCmd.cc
@@ -0,0 +1,2322 @@
+/** @file
+
+  This file contains the "show" command implementation.
+
+  @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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "ShowCmd.h"
+#include "ConfigCmd.h"
+#include "createArgument.h"
+#include "CliMgmtUtils.h"
+#include "CliDisplay.h"
+#include "ink_defs.h"
+#include "ink_string.h"
+
+////////////////////////////////////////////////////////////////
+// Cmd_Show
+//
+// This is the callback function for the "show" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_Show(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  char *cmdinfo, *temp;
+  int i = 0;
+  Cli_Debug("Cmd_Show\n");
+  Tcl_Eval(interp, "info commands show* ");
+
+  int cmdinfo_size = sizeof(char) * (strlen(Tcl_GetStringResult(interp)) + 2);
+  cmdinfo = (char *)alloca(cmdinfo_size);
+  ink_strlcpy(cmdinfo, Tcl_GetStringResult(interp), cmdinfo_size);
+  int temp_size = sizeof(char) * (strlen(cmdinfo) + 20);
+  temp = (char *)alloca(temp_size);
+  ink_strlcpy(temp, "lsort \"", temp_size);
+  ink_strlcat(temp, cmdinfo, temp_size);
+  ink_strlcat(temp, "\"", temp_size);
+  Tcl_Eval(interp, temp);
+  ink_strlcpy(cmdinfo, Tcl_GetStringResult(interp), cmdinfo_size);
+  i = i + strlen("show ");
+  while (cmdinfo[i] != 0) {
+    if (cmdinfo[i] == ' ') {
+      cmdinfo[i] = '\n';
+    }
+    i++;
+  }
+  cmdinfo[i] = '\n';
+  i++;
+  cmdinfo[i] = 0;
+  Cli_Printf("Following are the available show commands\n");
+  Cli_Printf(cmdinfo + strlen("show "));
+
+  return 0;
+
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowStatus
+//
+// This is the callback function for the "show:status" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowStatus(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowStatus\n");
+
+  return (ShowStatus());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowVersion
+//
+// This is the callback function for the "show:version" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowVersion(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowVersion\n");
+
+  return (ShowVersion());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowPorts
+//
+// This is the callback function for the "show:ports" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowPorts(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowPorts\n");
+
+  return (ShowPorts());
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowCluster
+//
+// This is the callback function for the "show:security" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowCluster(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowCluster\n");
+
+  return (ShowCluster());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowSecurity
+//
+// This is the callback function for the "show:security" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowSecurity(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowSecurity\n");
+
+  return (ShowSecurity());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowHttp
+//
+// This is the callback function for the "show:http" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowHttp(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowHttp\n");
+
+  return (ShowHttp());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowIcp
+//
+// This is the callback function for the "show:icp" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowIcp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowIcp argc %d\n", argc);
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
+    if (argtable[0].parsed_args == CMD_SHOW_ICP_PEER) {
+      return (ShowIcpPeer());
+    }
+    Cli_Error(ERR_INVALID_COMMAND);
+    return CMD_ERROR;
+  }
+  return (ShowIcp());
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ShowIcp
+//
+// Register "show:icp" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ShowIcp()
+{
+  createArgument("peers", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_SHOW_ICP_PEER, "ICP Peer Configuration", (char *) NULL);
+
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowProxy
+//
+// This is the callback function for the "show:proxy" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowProxy(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowProxy\n");
+
+  return (ShowProxy());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowCache
+//
+// This is the callback function for the "show:cache" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowCache(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowCache\n");
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
+    if (argtable[0].parsed_args == CMD_SHOW_CACHE_RULES) {
+      return (ShowCacheRules());
+    } else if (argtable[0].parsed_args == CMD_SHOW_CACHE_STORAGE) {
+      return (ShowCacheStorage());
+    }
+
+    Cli_Error(ERR_INVALID_COMMAND);
+    return CMD_ERROR;
+  }
+  return (ShowCache());
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ShowCache
+//
+// Register "show:cache" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ShowCache()
+{
+  createArgument("rules", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_SHOW_CACHE_RULES, "Rules from cache.config", (char *) NULL);
+  createArgument("storage", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_SHOW_CACHE_STORAGE, "Rules from storage.config", (char *) NULL);
+
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowVirtualIp
+//
+// This is the callback function for the "show:virtual-ip" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowVirtualIp(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowVirtualIp\n");
+
+  return (ShowVirtualIp());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowHostDb
+//
+// This is the callback function for the "show:hostdb" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowHostDb(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowHostDb\n");
+
+  return (ShowHostDb());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowDnsResolver
+//
+// This is the callback function for the "show:dns-resolver" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowDnsResolver(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowDnsResolver\n");
+
+  return (ShowDnsResolver());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowLogging
+//
+// This is the callback function for the "show:logging" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowLogging(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowLogging\n");
+
+  return (ShowLogging());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowSsl
+//
+// This is the callback function for the "show:ssl" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowSsl(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowSsl\n");
+
+  return (ShowSsl());
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowParents
+//
+// This is the callback function for the "show:parents" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowParents(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowParents\n");
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
+    if (argtable[0].parsed_args == CMD_SHOW_PARENT_RULES) {
+      return (ShowParentRules());
+    }
+
+    Cli_Error(ERR_INVALID_COMMAND);
+    return CMD_ERROR;
+  }
+
+  return (ShowParents());
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ShowParents
+//
+// Register "show:parents" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ShowParents()
+{
+  createArgument("rules", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_SHOW_PARENT_RULES, "Display parent.config rules file", (char *) NULL);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowRemap
+//
+// This is the callback function for the "show:remap" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowRemap(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowRemap\n");
+
+  return (ShowRemap());
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowSocks
+//
+// This is the callback function for the "show:socks" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowSocks(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowSocks\n");
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
+    if (argtable[0].parsed_args == CMD_SHOW_SOCKS_RULES) {
+      return (ShowSocksRules());
+    }
+
+    Cli_Error(ERR_INVALID_COMMAND);
+    return CMD_ERROR;
+  }
+
+  return (ShowSocks());
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ShowSocks
+//
+// Register "show:socks" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ShowSocks()
+{
+  createArgument("rules", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_SHOW_SOCKS_RULES, "Display socks.config rules file", (char *) NULL);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowScheduledUpdate
+//
+// This is the callback function for the "show:scheduled-update" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowScheduledUpdate(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowScheduledUpdate\n");
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  if (argtable[0].parsed_args != CLI_PARSED_ARGV_END) {
+    if (argtable[0].parsed_args == CMD_SHOW_UPDATE_RULES) {
+      return (ShowScheduledUpdateRules());
+    }
+
+    Cli_Error(ERR_INVALID_COMMAND);
+    return CMD_ERROR;
+  }
+
+  return (ShowScheduledUpdate());
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_ShowScheduledUpdate
+//
+// Register "show:scheduled-update" arguments with the Tcl interpreter.
+//
+int
+CmdArgs_ShowScheduledUpdate()
+{
+  createArgument("rules", 1, CLI_ARGV_CONSTANT,
+                 (char *) NULL, CMD_SHOW_UPDATE_RULES, "Display update.config rules file", (char *) NULL);
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowProxyStats
+//
+// This is the callback function for the "show:proxy-stats" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowProxyStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowProxyStats\n");
+
+  return (ShowProxyStats());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowHttpTransStats
+//
+// This is the callback function for the "show:http-trans-stats" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowHttpTransStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowHttpTransStats\n");
+
+  return (ShowHttpTransStats());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowHttpStats
+//
+// This is the callback function for the "show:http-stats" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowHttpStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowHttpStats\n");
+
+  return (ShowHttpStats());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowIcpStats
+//
+// This is the callback function for the "show:icp-stats" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowIcpStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowIcpStats\n");
+
+  return (ShowIcpStats());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowCacheStats
+//
+// This is the callback function for the "show:cache-stats" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowCacheStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowCacheStats\n");
+
+  return (ShowCacheStats());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowHostDbStats
+//
+// This is the callback function for the "show:hostdb-stats" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowHostDbStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowHostDbStats\n");
+
+  return (ShowHostDbStats());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowDnsStats
+//
+// This is the callback function for the "show:dns-stats" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowDnsStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowDnsStats\n");
+
+  return (ShowDnsStats());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowLoggingStats
+//
+// This is the callback function for the "show:logging-stats" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowLoggingStats(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowLoggingStats\n");
+
+  return (ShowLoggingStats());
+}
+
+////////////////////////////////////////////////////////////////
+// Cmd_ShowAlarms
+//
+// This is the callback function for the "show:alarms" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ShowAlarms(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  Cli_Debug("Cmd_ShowAlarms\n");
+
+  return (ShowAlarms());
+}
+
+////////////////////////////////////////////////////////////////
+// CmdArgs_None
+//
+// Register a command with no arguments with the Tcl interpreter.
+//
+int
+CmdArgs_None()
+{
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// "show" sub-command implementations
+//
+////////////////////////////////////////////////////////////////
+
+
+// show status sub-command
+int
+ShowStatus()
+{
+  TSProxyStateT state = TSProxyStateGet();
+  Cli_Printf("\n");
+  switch (state) {
+  case TS_PROXY_ON:
+    Cli_Printf("Proxy -- on\n");
+    break;
+  case TS_PROXY_OFF:
+    Cli_Printf("Proxy -- off\n");
+    break;
+  case TS_PROXY_UNDEFINED:
+    Cli_Printf("Proxy status undefined\n");
+    break;
+  }
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show version sub-command
+int
+ShowVersion()
+{
+  TSError status = TS_ERR_OKAY;
+  TSString ts_version = NULL;
+  TSString tm_version = NULL;
+
+  status = Cli_RecordGetString("proxy.process.version.server.short", &ts_version);
+  status = Cli_RecordGetString("proxy.node.version.manager.short", &tm_version);
+
+  Cli_Printf("\n");
+  Cli_Printf("traffic_server version --- %s\n" "traffic_manager version -- %s\n", ts_version, tm_version);
+  Cli_Printf("\n");
+
+  return status;
+}
+
+// show ports sub-command
+int
+ShowPorts()
+{
+  TSString http_ports = NULL;
+  TSInt cluster = -1;
+  TSInt cluster_rs = -1;
+  TSInt cluster_mc = -1;
+  TSInt socks_server = -1;
+  TSInt icp = -1;
+  TSString connect = NULL;
+
+  // retrieve values
+
+  Cli_RecordGetString("proxy.config.http.server_ports", &http_ports);
+  Cli_RecordGetInt("proxy.config.cluster.cluster_port", &cluster);
+  Cli_RecordGetInt("proxy.config.cluster.rsport", &cluster_rs);
+  Cli_RecordGetInt("proxy.config.cluster.mcport", &cluster_mc);
+  Cli_RecordGetString("proxy.config.http.connect_ports", &connect);
+  Cli_RecordGetInt("proxy.config.socks.socks_server_port", &socks_server);
+  Cli_RecordGetInt("proxy.config.icp.icp_port", &icp);
+
+  // display results
+  Cli_Printf("\n");
+  Cli_Printf("HTTP Ports ------------- %s\n", (http_ports != NULL) ? http_ports : "none");
+  Cli_Printf("Cluster Port ----------- %d\n", cluster);
+  Cli_Printf("Cluster RS Port -------- %d\n", cluster_rs);
+  Cli_Printf("Cluster MC Port -------- %d\n", cluster_mc);
+  Cli_Printf("Allowed CONNECT Ports -- %s\n", (connect != NULL) ? connect : "none");
+  Cli_Printf("SOCKS Server Port ------ %d\n", socks_server);
+  Cli_Printf("ICP Port --------------- %d\n", icp);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show cluster sub-command
+int
+ShowCluster()
+{
+  TSInt cluster = -1;
+  TSInt cluster_rs = -1;
+  TSInt cluster_mc = -1;
+
+  Cli_RecordGetInt("proxy.config.cluster.cluster_port", &cluster);
+  Cli_RecordGetInt("proxy.config.cluster.rsport", &cluster_rs);
+  Cli_RecordGetInt("proxy.config.cluster.mcport", &cluster_mc);
+
+  Cli_Printf("\n");
+  Cli_Printf("Cluster Port ----------- %d\n", cluster);
+  Cli_Printf("Cluster RS Port -------- %d\n", cluster_rs);
+  Cli_Printf("Cluster MC Port -------- %d\n", cluster_mc);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show security sub-command
+int
+ShowSecurity()
+{
+  Cli_Printf("\n");
+  Cli_Printf("Traffic Server Access\n" "-------------------\n");
+  TSError status = Cli_DisplayRules(TS_FNAME_IP_ALLOW);
+
+  return status;
+}
+
+// show http sub-command
+int
+ShowHttp()
+{
+  // declare and initialize variables
+
+  TSInt http_enabled = -1;
+  TSInt keepalive_timeout_in = -1;
+  TSInt keepalive_timeout_out = -1;
+  TSInt inactivity_timeout_in = -1;
+  TSInt inactivity_timeout_out = -1;
+  TSInt activity_timeout_in = -1;
+  TSInt activity_timeout_out = -1;
+  TSInt max_alts = -1;
+  TSInt remove_from = -1;
+  TSInt remove_referer = -1;
+  TSInt remove_user_agent = -1;
+  TSInt remove_cookie = -1;
+  TSString other_header_list = NULL;
+  TSInt insert_client_ip = -1;
+  TSInt remove_client_ip = -1;
+  TSInt http_server = -1;
+  TSString http_other = NULL;
+  TSString global_user_agent = NULL;
+
+  // retrieve values
+
+  Cli_RecordGetInt("proxy.config.http.cache.http", &http_enabled);
+  Cli_RecordGetInt("proxy.config.http.keep_alive_no_activity_timeout_in", &keepalive_timeout_in);
+  Cli_RecordGetInt("proxy.config.http.keep_alive_no_activity_timeout_out", &keepalive_timeout_out);
+  Cli_RecordGetInt("proxy.config.http.transaction_no_activity_timeout_in", &inactivity_timeout_in);
+  Cli_RecordGetInt("proxy.config.http.transaction_no_activity_timeout_out", &inactivity_timeout_out);
+  Cli_RecordGetInt("proxy.config.http.transaction_active_timeout_in", &activity_timeout_in);
+  Cli_RecordGetInt("proxy.config.http.transaction_active_timeout_out", &activity_timeout_out);
+  Cli_RecordGetInt("proxy.config.cache.limits.http.max_alts", &max_alts);
+  Cli_RecordGetInt("proxy.config.http.anonymize_remove_from", &remove_from);
+  Cli_RecordGetInt("proxy.config.http.anonymize_remove_referer", &remove_referer);
+  Cli_RecordGetInt("proxy.config.http.anonymize_remove_user_agent", &remove_user_agent);
+  Cli_RecordGetInt("proxy.config.http.anonymize_remove_cookie", &remove_cookie);
+  Cli_RecordGetString("proxy.config.http.anonymize_other_header_list", &other_header_list);
+  Cli_RecordGetInt("proxy.config.http.anonymize_insert_client_ip", &insert_client_ip);
+  Cli_RecordGetInt("proxy.config.http.anonymize_remove_client_ip", &remove_client_ip);
+  Cli_RecordGetInt("proxy.config.http.server_port", &http_server);
+
+  Cli_RecordGetString("proxy.config.http.global_user_agent_header", &global_user_agent);
+
+  // display results
+  Cli_Printf("\n");
+  Cli_Printf("HTTP Caching ------------------ %s\n", (http_enabled == 1) ? "on" : "off");
+  Cli_Printf("HTTP Server Port -------------- %d\n", http_server);
+  Cli_Printf("HTTP Other Ports -------------- %s\n", (http_other != NULL) ? http_other : "none");
+  Cli_Printf("Keep-Alive Timeout Inbound ---- %d s\n", keepalive_timeout_in);
+  Cli_Printf("Keep-Alive Timeout Outbound --- %d s\n", keepalive_timeout_out);
+  Cli_Printf("Inactivity Timeout Inbound ---- %d s\n", inactivity_timeout_in);
+  Cli_Printf("Inactivity Timeout Outbound --- %d s\n", inactivity_timeout_out);
+  Cli_Printf("Activity Timeout Inbound ------ %d s\n", activity_timeout_in);
+  Cli_Printf("Activity Timeout Outbound ----- %d s\n", activity_timeout_out);
+  Cli_Printf("Maximum Number of Alternates -- %d\n", max_alts);
+
+  if (remove_from == 1 || remove_referer == 1 || remove_user_agent == 1 || remove_cookie == 1) {
+    Cli_Printf("Remove the following common headers -- \n");
+    if (remove_from == 1) {
+      Cli_Printf("From\n");
+    }
+    if (remove_referer == 1) {
+      Cli_Printf("Referer\n");
+    }
+    if (remove_user_agent == 1) {
+      Cli_Printf("User-Agent\n");
+    }
+    if (remove_cookie == 1) {
+      Cli_Printf("Cookie\n");
+    }
+  }
+  if (other_header_list != NULL && strlen(other_header_list)) {
+    Cli_Printf("Remove additional headers ----- " "%s\n", other_header_list);
+  }
+  if (insert_client_ip == 1) {
+    Cli_Printf("Insert Client IP Address into Header\n");
+  }
+  if (remove_client_ip == 1) {
+    Cli_Printf("Remove Client IP Address from Header\n");
+  }
+  if (global_user_agent) {
+    Cli_Printf("Set User-Agent header to %s\n", global_user_agent);
+  }
+
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show icp sub-command
+int
+ShowIcp()
+{
+  // declare and initialize variables
+
+  TSInt icp_enabled = 0;
+  TSInt icp_port = -1;
+  TSInt multicast_enabled = 0;
+  TSInt query_timeout = 2;
+
+  // retrieve value
+
+  Cli_RecordGetInt("proxy.config.icp.enabled", &icp_enabled);
+  Cli_RecordGetInt("proxy.config.icp.icp_port", &icp_port);
+  Cli_RecordGetInt("proxy.config.icp.multicast_enabled", &multicast_enabled);
+  Cli_RecordGetInt("proxy.config.icp.query_timeout", &query_timeout);
+
+  // display results
+  Cli_Printf("\n");
+
+  Cli_PrintEnable("ICP Mode Enabled ------- ", icp_enabled);
+  Cli_Printf("ICP Port --------------- %d\n", icp_port);
+  Cli_PrintEnable("ICP Multicast Enabled -- ", multicast_enabled);
+  Cli_Printf("ICP Query Timeout ------ %d s\n", query_timeout);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show icp peer sub-command
+int
+ShowIcpPeer()
+{
+  // display rules from icp.config
+  Cli_Printf("\n");
+  Cli_Printf("icp.config Rules\n" "-------------------\n");
+  TSError status = Cli_DisplayRules(TS_FNAME_ICP_PEER);
+  Cli_Printf("\n");
+
+  return status;
+}
+
+// show proxy sub-command
+int
+ShowProxy()
+{
+
+  TSString proxy_name = NULL;
+
+  Cli_RecordGetString("proxy.config.proxy_name", &proxy_name);
+  Cli_Printf("\n");
+  Cli_Printf("Name -- %s\n", proxy_name);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show cache sub-command
+int
+ShowCache()
+{
+  // declare and initialize variables
+
+  TSInt cache_http = -1;
+  TSInt cache_bypass = -1;
+  TSInt max_doc_size = -1;
+  TSInt when_to_reval = -1;
+  TSInt reqd_headers = -1;
+  TSInt min_life = -1;
+  TSInt max_life = -1;
+  TSInt dynamic_urls = -1;
+  TSInt alternates = -1;
+  const char *vary_def_text = "NONE";
+  const char *vary_def_image = "NONE";
+  const char *vary_def_other = "NONE";
+  TSInt cookies = -1;
+
+  // retrieve values
+
+  Cli_RecordGetInt("proxy.config.http.cache.http", &cache_http);
+  Cli_RecordGetInt("proxy.config.cache.max_doc_size", &max_doc_size);
+  Cli_RecordGetInt("proxy.config.http.cache.when_to_revalidate", &when_to_reval);
+  Cli_RecordGetInt("proxy.config.http.cache.required_headers", &reqd_headers);
+  Cli_RecordGetInt("proxy.config.http.cache.heuristic_min_lifetime", &min_life);
+  Cli_RecordGetInt("proxy.config.http.cache.heuristic_max_lifetime", &max_life);
+  Cli_RecordGetInt("proxy.config.http.cache.cache_urls_that_look_dynamic", &dynamic_urls);
+  Cli_RecordGetInt("proxy.config.http.cache.enable_default_vary_headers", &alternates);
+  Cli_RecordGetString("proxy.config.http.cache.vary_default_text", (char**)&vary_def_text);
+  Cli_RecordGetString("proxy.config.http.cache.vary_default_images", (char**)&vary_def_image);
+  Cli_RecordGetString("proxy.config.http.cache.vary_default_other", (char**)&vary_def_other);
+
+  Cli_RecordGetInt("proxy.config.http.cache.cache_responses_to_cookies", &cookies);
+
+
+  // display results
+  Cli_Printf("\n");
+
+  Cli_PrintEnable("HTTP Caching --------------------------- ", cache_http);
+
+  Cli_PrintEnable("Ignore User Requests To Bypass Cache --- ", cache_bypass);
+
+  if (max_doc_size == 0)
+    Cli_Printf("Maximum HTTP Object Size ----------- NONE\n");
+  else
+    Cli_Printf("Maximum HTTP Object Size ----------- %d\n", max_doc_size);
+
+  Cli_Printf("Freshness\n");
+  Cli_Printf("  Verify Freshness By Checking --------- ");
+
+  switch (when_to_reval) {
+  case 0:
+    Cli_Printf("When The Object Has Expired\n");
+    break;
+  case 1:
+    Cli_Printf("When The Object Has No Expiry Date\n");
+    break;
+  case 2:
+    Cli_Printf("Always\n");
+    break;
+  case 3:
+    Cli_Printf("Never\n");
+    break;
+  default:
+    Cli_Printf("unknown\n");
+    break;
+  }
+
+  Cli_Printf("  Minimum Information to be Cacheable -- ");
+
+  switch (reqd_headers) {
+  case 0:
+    Cli_Printf("Nothing\n");
+    break;
+  case 1:
+    Cli_Printf("A Last Modified Time\n");
+    break;
+  case 2:
+    Cli_Printf("An Explicit Lifetime\n");
+    break;
+  default:
+    Cli_Printf("unknown\n");
+    break;
+  }
+
+  Cli_Printf("  If Object has no Expiration Date: \n" "    Leave it in Cache for at least ----- %d s\n", min_life);
+  Cli_Printf("    but no more than ------------------- %d s\n", max_life);
+
+  Cli_Printf("Variable Content\n");
+
+  Cli_PrintEnable("  Cache Responses to URLs that contain\n    \"?\",\";\",\"cgi\" or end in \".asp\" ----- ",
+                  dynamic_urls);
+
+  Cli_PrintEnable("  Alternates Enabled ------------------- ", alternates);
+
+  Cli_Printf("  Vary on HTTP Header Fields: \n");
+  Cli_Printf("    Text ------------------------------- %s\n", vary_def_text);
+  Cli_Printf("    Images ----------------------------- %s\n", vary_def_image);
+  Cli_Printf("    Other ------------------------------ %s\n", vary_def_other);
+
+  Cli_Printf("  Cache responses to requests containing cookies for:\n");
+
+  switch (cookies) {
+  case 0:
+    Cli_Printf("    No Content-types\n");
+    break;
+  case 1:
+    Cli_Printf("    All Content-types\n");
+    break;
+  case 2:
+    Cli_Printf("    Only Image-content Types\n");
+    break;
+  case 3:
+    Cli_Printf("    Content Types which are not Text\n");
+    break;
+  case 4:
+    Cli_Printf("    Content Types which are not Text with some exceptions\n");
+    break;
+  }
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show cache rules sub-command
+int
+ShowCacheRules()
+{
+  // display rules from cache.config
+  Cli_Printf("\n");
+
+  Cli_Printf("cache.config rules\n" "-------------------\n");
+  TSError status = Cli_DisplayRules(TS_FNAME_CACHE_OBJ);
+
+  Cli_Printf("\n");
+
+  return status;
+}
+
+// show cache storage sub-command
+int
+ShowCacheStorage()
+{
+  // display rules from storage.config
+  Cli_Printf("storage.config rules\n");
+
+  TSError status = Cli_DisplayRules(TS_FNAME_STORAGE);
+
+  return status;
+}
+
+
+// show virtual-ip sub-command
+int
+ShowVirtualIp()
+{
+  TSCfgContext VipCtx;
+  int EleCount, i;
+  TSVirtIpAddrEle *VipElePtr;
+
+  VipCtx = TSCfgContextCreate(TS_FNAME_VADDRS);
+  if (TSCfgContextGet(VipCtx) != TS_ERR_OKAY)
+    Cli_Printf("ERROR READING FILE\n");
+  EleCount = TSCfgContextGetCount(VipCtx);
+  Cli_Printf("\n");
+  Cli_Printf("%d Elements in Record\n", EleCount);
+  Cli_Printf("\n");
+  for (i = 0; i < EleCount; i++) {
+    VipElePtr = (TSVirtIpAddrEle *) TSCfgContextGetEleAt(VipCtx, i);
+    Cli_Printf("%d %s %s %d\n", i, VipElePtr->ip_addr, VipElePtr->intr, VipElePtr->sub_intr);
+  }
+  Cli_Printf("\n");
+  return CLI_OK;
+}
+
+// show hostdb sub-command
+int
+ShowHostDb()
+{
+
+  // declare and initialize variables
+
+  TSInt lookup_timeout = -1;
+  TSInt timeout = -1;
+  TSInt verify_after = -1;
+  TSInt fail_timeout = -1;
+  TSInt re_dns_on_reload = 0;
+  TSInt dns_lookup_timeout = -1;
+  TSInt dns_retries = -1;
+
+  // retrieve value
+
+  Cli_RecordGetInt("proxy.config.hostdb.lookup_timeout", &lookup_timeout);
+  Cli_RecordGetInt("proxy.config.hostdb.timeout", &timeout);
+  Cli_RecordGetInt("proxy.config.hostdb.verify_after", &verify_after);
+  Cli_RecordGetInt("proxy.config.hostdb.fail.timeout", &fail_timeout);
+  Cli_RecordGetInt("proxy.config.hostdb.re_dns_on_reload", &re_dns_on_reload);
+  Cli_RecordGetInt("proxy.config.dns.lookup_timeout", &dns_lookup_timeout);
+  Cli_RecordGetInt("proxy.config.dns.retries", &dns_retries);
+
+  // display results
+  Cli_Printf("\n");
+
+  Cli_Printf("Lookup Timeout ----------- %d s\n", lookup_timeout);
+  Cli_Printf("Foreground Timeout ------- %d s\n", timeout);
+  Cli_Printf("Background Timeout ------- %d s\n", verify_after);
+  Cli_Printf("Invalid Host Timeout ----- %d s\n", fail_timeout);
+  if (Cli_PrintEnable("Re-DNS on Reload --------- ", re_dns_on_reload) == CLI_ERROR) {
+    return CLI_ERROR;
+  }
+  Cli_Printf("Resolve Attempt Timeout -- %d s\n", dns_lookup_timeout);
+  Cli_Printf("Number of retries -------- %d \n", dns_retries);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show dns-resolver sub-command
+int
+ShowDnsResolver()
+{
+  // declare and initialize variables
+
+  TSInt dns_search_default_domains = 0;
+  TSInt http_enable_url_expandomatic = 0;
+
+  // retrieve value
+
+  Cli_RecordGetInt("proxy.config.dns.search_default_domains", &dns_search_default_domains);
+  Cli_RecordGetInt("proxy.config.http.enable_url_expandomatic", &http_enable_url_expandomatic);
+
+  // display results
+  Cli_Printf("\n");
+
+  if (Cli_PrintEnable("Local Domain Expansion -- ", dns_search_default_domains) == CLI_ERROR) {
+    return CLI_ERROR;
+  }
+  if (Cli_PrintEnable(".com Domain Expansion --- ", http_enable_url_expandomatic) == CLI_ERROR) {
+    return CLI_ERROR;
+  }
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show logging sub-command
+int
+ShowLogging()
+{
+  // declare and initialize variables
+
+  TSInt logging_enabled = 0;
+  TSInt log_space = -1;
+  TSInt headroom_space = -1;
+  TSInt collation_mode = 0;
+  const char *collation_host = "None";
+  TSInt collation_port = -1;
+  TSString collation_secret = NULL;
+  TSInt host_tag = 0;
+  TSInt preproc_threads = 0;
+  TSInt orphan_space = -1;
+
+  TSInt squid_log = 0;
+  TSInt is_ascii = 1;
+  TSString file_name = NULL;
+  TSString file_header = NULL;
+
+  TSInt common_log = 0;
+  TSInt common_is_ascii = 0;
+  TSString common_file_name = NULL;
+  TSString common_file_header = NULL;
+
+  TSInt extended_log = 0;
+  TSInt extended_is_ascii = 0;
+  TSString extended_file_name = NULL;
+  TSString extended_file_header = NULL;
+
+  TSInt extended2_log = 0;
+  TSInt extended2_is_ascii = 0;
+  TSString extended2_file_name = NULL;
+  TSString extended2_file_header = NULL;
+
+  TSInt icp_log = 0;
+  TSInt http_host_log = 0;
+  TSInt custom_log = 0;
+  TSInt xml_log = 0;
+  TSInt rolling = 0;
+  TSInt roll_offset_hr = -1;
+  TSInt roll_interval = -1;
+  TSInt auto_delete = 0;
+  // retrieve value
+
+  Cli_RecordGetInt("proxy.config.log.logging_enabled", &logging_enabled);
+  Cli_RecordGetInt("proxy.config.log.max_space_mb_for_logs", &log_space);
+  Cli_RecordGetInt("proxy.config.log.max_space_mb_headroom", &headroom_space);
+  Cli_RecordGetInt("proxy.local.log.collation_mode", &collation_mode);
+  Cli_RecordGetString("proxy.config.log.collation_host", (char**)&collation_host);
+  Cli_RecordGetInt("proxy.config.log.collation_port", &collation_port);
+  Cli_RecordGetString("proxy.config.log.collation_secret", &collation_secret);
+  Cli_RecordGetInt("proxy.config.log.collation_host_tagged", &host_tag);
+  Cli_RecordGetInt("proxy.config.log.max_space_mb_for_orphan_logs", &orphan_space);
+  Cli_RecordGetInt("proxy.config.log.collation_preproc_threads", &preproc_threads);
+
+  Cli_RecordGetInt("proxy.config.log.squid_log_enabled", &squid_log);
+  Cli_RecordGetInt("proxy.config.log.squid_log_is_ascii", &is_ascii);
+  Cli_RecordGetString("proxy.config.log.squid_log_name", &file_name);
+  Cli_RecordGetString("proxy.config.log.squid_log_header", &file_header);
+
+  Cli_RecordGetInt("proxy.config.log.common_log_enabled", &common_log);
+  Cli_RecordGetInt("proxy.config.log.common_log_is_ascii", &common_is_ascii);
+  Cli_RecordGetString("proxy.config.log.common_log_name", &common_file_name);
+  Cli_RecordGetString("proxy.config.log.common_log_header", &common_file_header);
+
+  Cli_RecordGetInt("proxy.config.log.extended_log_enabled", &extended_log);
+  Cli_RecordGetInt("proxy.config.log.extended_log_is_ascii", &extended_is_ascii);
+  Cli_RecordGetString("proxy.config.log.extended_log_name", &extended_file_name);
+  Cli_RecordGetString("proxy.config.log.extended_log_header", &extended_file_header);
+
+  Cli_RecordGetInt("proxy.config.log.extended2_log_enabled", &extended2_log);
+  Cli_RecordGetInt("proxy.config.log.extended2_log_is_ascii", &extended2_is_ascii);
+  Cli_RecordGetString("proxy.config.log.extended2_log_name", &extended2_file_name);
+  Cli_RecordGetString("proxy.config.log.extended2_log_header", &extended2_file_header);
+
+  Cli_RecordGetInt("proxy.config.log.separate_icp_logs", &icp_log);
+  Cli_RecordGetInt("proxy.config.log.separate_host_logs", &http_host_log);
+  Cli_RecordGetInt("proxy.config.log.separate_host_logs", &custom_log);
+
+  Cli_RecordGetInt("proxy.config.log.rolling_enabled", &rolling);
+  Cli_RecordGetInt("proxy.config.log.rolling_offset_hr", &roll_offset_hr);
+  Cli_RecordGetInt("proxy.config.log.rolling_interval_sec", &roll_interval);
+  Cli_RecordGetInt("proxy.config.log.auto_delete_rolled_files", &auto_delete);
+
+  // display results
+  Cli_Printf("\n");
+
+  Cli_Printf("Logging Mode ----------------------------- ");
+  switch (logging_enabled) {
+  case 0:
+    Cli_Printf("no logging\n");
+    break;
+  case 1:
+    Cli_Printf("errors only\n");
+    break;
+  case 2:
+    Cli_Printf("transactions only\n");
+    break;
+  case 3:
+    Cli_Printf("errors and transactions\n");
+    break;
+  default:
+    Cli_Printf("invalid mode\n");
+    break;
+  }
+
+  Cli_Printf("\nManagement\n");
+  Cli_Printf("  Log Space Limit ------------------------ %d MB\n", log_space);
+  Cli_Printf("  Log Space Headroom --------------------- %d MB\n", headroom_space);
+
+  Cli_PrintEnable("\nLog Collation ---------------------------- ", collation_mode);
+  Cli_Printf("  Host ----------------------------------- %s\n", collation_host);
+  Cli_Printf("  Port ----------------------------------- %d\n", collation_port);
+  Cli_Printf("  Secret --------------------------------- %s\n", collation_secret);
+  Cli_PrintEnable("  Host Tagged ---------------------------- ", host_tag);
+  Cli_PrintEnable("  Preproc Threads ------------------------ ", preproc_threads);
+  Cli_Printf("  Space Limit for Orphan Files ----------- %d MB\n", orphan_space);
+
+  Cli_PrintEnable("\nSquid Format ----------------------------- ", squid_log);
+  if (is_ascii == 1)
+    Cli_Printf("  File Type ------------------------------ %s\n", "ASCII");
+  else if (is_ascii == 0)
+    Cli_Printf("  File Type ------------------------------ %s\n", "BINARY");
+  else
+    Cli_Debug(ERR_INVALID_PARAMETER);
+  Cli_Printf("  File Name ------------------------------ %s\n", file_name);
+  Cli_Printf("  File Header ---------------------------- %s\n", file_header);
+
+  Cli_PrintEnable("\nNetscape Common -------------------------- ", common_log);
+  if (common_is_ascii == 1)
+    Cli_Printf("  File Type ------------------------------ %s\n", "ASCII");
+  else if (common_is_ascii == 0)
+    Cli_Printf("  File Type ------------------------------ %s\n", "BINARY");
+  else
+    Cli_Debug(ERR_INVALID_PARAMETER);
+  Cli_Printf("  File Name ------------------------------ %s\n", common_file_name);
+  Cli_Printf("  File Header ---------------------------- %s\n", common_file_header);
+
+  Cli_PrintEnable("\nNetscape Extended ------------------------ ", extended_log);
+  if (extended_is_ascii == 1)
+    Cli_Printf("  File Type ------------------------------ %s\n", "ASCII");
+  else if (extended_is_ascii == 0)
+    Cli_Printf("  File Type ------------------------------ %s\n", "BINARY");
+  else
+    Cli_Debug(ERR_INVALID_PARAMETER);
+  Cli_Printf("  File Name ------------------------------ %s\n", extended_file_name);
+  Cli_Printf("  File Header ---------------------------- %s\n", extended_file_header);
+
+  Cli_PrintEnable("\nNetscape Extended2 ----------------------- ", extended2_log);
+  if (extended2_is_ascii == 1)
+    Cli_Printf("  File Type ------------------------------ %s\n", "ASCII");
+  else if (extended2_is_ascii == 0)
+    Cli_Printf("  File Type ------------------------------ %s\n", "BINARY");
+  else
+    Cli_Debug(ERR_INVALID_PARAMETER);
+  Cli_Printf("  File Name   ---------------------------- %s\n", extended2_file_name);
+  Cli_Printf("  File Header ---------------------------- %s\n", extended2_file_header);
+
+  Cli_Printf("\nSplitting\n");
+  Cli_PrintEnable("  ICP Log Splitting ---------------------- ", icp_log);
+  Cli_PrintEnable("  HTTP Host Log Splitting ---------------- ", http_host_log);
+  Cli_PrintEnable("\nCustom Logs ------------------------------ ", custom_log);
+  if (xml_log == 0)
+    Cli_Printf("Custom Log Definition Format ------------- %s\n", "Traditional");
+  Cli_PrintEnable("\nRolling ---------------------------------- ", rolling);
+  Cli_Printf("  Roll Offset Hour ----------------------- %d\n", roll_offset_hr);
+  Cli_Printf("  Roll Interval -------------------------- %d s\n", roll_interval);
+  Cli_PrintEnable("  Auto-delete rolled files (low space) --- ", auto_delete);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show ssl sub-command
+int
+ShowSsl()
+{
+  // declare and initialize variables
+
+  TSString connect_ports = NULL;
+
+  // retrieve value
+
+  Cli_RecordGetString("proxy.config.http.connect_ports", &connect_ports);
+
+  // display results
+  Cli_Printf("\n");
+  Cli_Printf("Restrict CONNECT connections to Ports -- %s\n", connect_ports);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+
+// show parents sub-command
+int
+ShowParents()
+{
+  TSError status = TS_ERR_OKAY;
+  TSInt parent_enabled = -1;
+  TSString parent_cache = NULL;
+
+  Cli_RecordGetInt("proxy.config.http.parent_proxy_routing_enable", &parent_enabled);
+  Cli_RecordGetString("proxy.config.http.parent_proxies", &parent_cache);
+  Cli_Printf("\n");
+  Cli_Printf("Parent Caching -- %s\n", (parent_enabled == 1) ? "on" : "off");
+  Cli_Printf("Parent Cache ---- %s\n", parent_cache);
+  Cli_Printf("\n");
+
+  return status;
+}
+
+// show:parent rules sub-command
+int
+ShowParentRules()
+{
+  // display rules from parent.config
+  Cli_Printf("\n");
+
+  Cli_Printf("parent.config rules\n" "-------------------\n");
+  TSError status = Cli_DisplayRules(TS_FNAME_PARENT_PROXY);
+  Cli_Printf("\n");
+
+  return status;
+}
+
+// show remap sub-command
+int
+ShowRemap()
+{
+  // display rules from remap.config
+  Cli_Printf("\n");
+
+  Cli_Printf("remap.config rules\n" "-------------------\n");
+  TSError status = Cli_DisplayRules(TS_FNAME_REMAP);
+  Cli_Printf("\n");
+
+  return status;
+}
+
+// show socks sub-command
+int
+ShowSocks()
+{
+  // declare and initialize variables
+
+  TSInt socks_enabled = 0;
+  TSInt version = -1;
+  TSString default_servers = NULL;
+  TSInt accept_enabled = -1;
+  TSInt accept_port = -1;
+
+  // retrieve values
+  Cli_RecordGetInt("proxy.config.socks.socks_needed", &socks_enabled);
+  Cli_RecordGetInt("proxy.config.socks.socks_version", &version);
+  Cli_RecordGetString("proxy.config.socks.default_servers", &default_servers);
+  Cli_RecordGetInt("proxy.config.socks.accept_enabled", &accept_enabled);
+  Cli_RecordGetInt("proxy.config.socks.accept_port", &accept_port);
+
+  // display results
+  Cli_Printf("\n");
+  Cli_PrintEnable("SOCKS -------------------- ", socks_enabled);
+  Cli_Printf("SOCKS Version ------------ %d\n", version);
+  Cli_Printf("SOCKS Default Servers ---- %s\n", default_servers);
+  Cli_PrintEnable("SOCKS Accept Enabled ----- ", accept_enabled);
+  Cli_Printf("SOCKS Accept Port -------- %d\n", accept_port);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show:socks rules sub-command
+int
+ShowSocksRules()
+{
+  // display rules from socks.config
+  Cli_Printf("\n");
+
+  Cli_Printf("socks.config rules\n" "-------------------\n");
+  TSError status = Cli_DisplayRules(TS_FNAME_SOCKS);
+  Cli_Printf("\n");
+
+  return status;
+}
+
+// show scheduled-update sub-command
+int
+ShowScheduledUpdate()
+{
+  // variable declaration
+  TSInt enabled = 0;
+  TSInt force = 0;
+  TSInt retry_count = -1;
+  TSInt retry_interval = -1;
+  TSInt concurrent_updates = 0;
+
+  // get value
+  Cli_RecordGetInt("proxy.config.update.enabled", &enabled);
+  Cli_RecordGetInt("proxy.config.update.retry_count", &retry_count);
+  Cli_RecordGetInt("proxy.config.update.retry_interval", &retry_interval);
+  Cli_RecordGetInt("proxy.config.update.concurrent_updates", &concurrent_updates);
+  Cli_RecordGetInt("proxy.config.update.force", &force);
+  //display values
+
+  // display rules from socks.config
+  Cli_Printf("\n");
+
+  if (Cli_PrintEnable("Scheduled Update ------------- ", enabled) == CLI_ERROR) {
+    return CLI_ERROR;
+  }
+
+  Cli_Printf("Update Error Retry Count ----- %d\n", retry_count);
+  Cli_Printf("Update Error Retry Interval -- %d s\n", retry_interval);
+  Cli_Printf("Maximum Concurrent Updates --- %d\n", concurrent_updates);
+
+  if (Cli_PrintEnable("Force Immediate Update ------- ", force) == CLI_ERROR) {
+    return CLI_ERROR;
+  }
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show:scheduled-update rules sub-command
+int
+ShowScheduledUpdateRules()
+{
+  Cli_Printf("\n");
+
+  Cli_Printf("update.config rules\n" "-------------------\n");
+  TSError status = Cli_DisplayRules(TS_FNAME_UPDATE_URL);
+  Cli_Printf("\n");
+
+  return status;
+}
+
+////////////////////////////////////////////////////////////////
+// statistics sub-commands
+//
+
+// show proxy-stats sub-command
+int
+ShowProxyStats()
+{
+
+  TSFloat cache_hit_ratio = -1.0;
+  TSFloat cache_hit_mem_ratio = -1.0;
+  TSFloat bandwidth_hit_ratio = -1.0;
+  TSFloat percent_free = -1.0;
+  TSInt current_server_connection = -1;
+  TSInt current_client_connection = -1;
+  TSInt current_cache_connection = -1;
+  TSFloat client_throughput_out = -1.0;
+  TSFloat xacts_per_second = -1.0;
+
+
+  //get value
+  Cli_RecordGetFloat("proxy.node.cache_hit_ratio", &cache_hit_ratio);
+  Cli_RecordGetFloat("proxy.node.cache_hit_mem_ratio", &cache_hit_mem_ratio);
+  Cli_RecordGetFloat("proxy.node.bandwidth_hit_ratio", &bandwidth_hit_ratio);
+  Cli_RecordGetFloat("proxy.node.cache.percent_free", &percent_free);
+  Cli_RecordGetInt("proxy.node.current_server_connections", &current_server_connection);
+  Cli_RecordGetInt("proxy.node.current_client_connections", &current_client_connection);
+  Cli_RecordGetInt("proxy.node.current_cache_connections", &current_cache_connection);
+  Cli_RecordGetFloat("proxy.node.client_throughput_out", &client_throughput_out);
+  Cli_RecordGetFloat("proxy.node.user_agent_xacts_per_second", &xacts_per_second);
+
+
+  //display values
+  Cli_Printf("\n");
+
+  Cli_Printf("Document Hit Rate -------- %f %%\t *\n", 100 * cache_hit_ratio);
+  Cli_Printf("Ram cache Hit Rate ------- %f %%\t *\n", 100 * cache_hit_mem_ratio);
+  Cli_Printf("Bandwidth Saving --------- %f %%\t *\n", 100 * bandwidth_hit_ratio);
+  Cli_Printf("Cache Percent Free ------- %f %%\n", 100 * percent_free);
+  Cli_Printf("Open Server Connections -- %d\n", current_server_connection);
+  Cli_Printf("Open Client Connections -- %d\n", current_client_connection);
+  Cli_Printf("Open Cache Connections --- %d\n", current_cache_connection);
+  Cli_Printf("Client Throughput -------- %f MBit/Sec\n", client_throughput_out);
+  Cli_Printf("Transaction Per Second --- %f\n", xacts_per_second);
+  Cli_Printf("\n* Value represents 10 second average.\n");
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show http-trans-stats sub-command
+int
+ShowHttpTransStats()
+{
+  //varialbles
+  TSFloat frac_avg_10s_hit_fresh = -1.0;
+  TSInt msec_avg_10s_hit_fresh = -1;
+  TSFloat frac_avg_10s_hit_revalidated = -1.0;
+  TSInt msec_avg_10s_hit_revalidated = -1;
+  TSFloat frac_avg_10s_miss_cold = -1.0;
+  TSInt msec_avg_10s_miss_cold = -1;
+  TSFloat frac_avg_10s_miss_not_cachable = -1.0;
+  TSInt msec_avg_10s_miss_not_cachable = -1;
+  TSFloat frac_avg_10s_miss_changed = -1.0;
+  TSInt msec_avg_10s_miss_changed = -1;
+  TSFloat frac_avg_10s_miss_client_no_cache = -1.0;
+  TSInt msec_avg_10s_miss_client_no_cache = -1;
+  TSFloat frac_avg_10s_errors_connect_failed = -1.0;
+  TSInt msec_avg_10s_errors_connect_failed = -1;
+  TSFloat frac_avg_10s_errors_other = -1.0;
+  TSInt msec_avg_10s_errors_other = -1;
+  TSFloat frac_avg_10s_errors_aborts = -1.0;
+  TSInt msec_avg_10s_errors_aborts = -1;
+  TSFloat frac_avg_10s_errors_possible_aborts = -1.0;
+  TSInt msec_avg_10s_errors_possible_aborts = -1;
+  TSFloat frac_avg_10s_errors_early_hangups = -1.0;
+  TSInt msec_avg_10s_errors_early_hangups = -1;
+  TSFloat frac_avg_10s_errors_empty_hangups = -1.0;
+  TSInt msec_avg_10s_errors_empty_hangups = -1;
+  TSFloat frac_avg_10s_errors_pre_accept_hangups = -1.0;
+  TSInt msec_avg_10s_errors_pre_accept_hangups = -1;
+  TSFloat frac_avg_10s_other_unclassified = -1.0;
+  TSInt msec_avg_10s_other_unclassified = -1;
+
+  //get values
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.hit_fresh", &frac_avg_10s_hit_fresh);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.hit_revalidated", &frac_avg_10s_hit_revalidated);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.miss_cold", &frac_avg_10s_miss_cold);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.miss_not_cacheable", &frac_avg_10s_miss_not_cachable);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.miss_changed", &frac_avg_10s_miss_changed);
+
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.miss_client_no_cache",
+                     &frac_avg_10s_miss_client_no_cache);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.connect_failed",
+                     &frac_avg_10s_errors_connect_failed);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.other", &frac_avg_10s_errors_other);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.aborts", &frac_avg_10s_errors_aborts);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.possible_aborts",
+                     &frac_avg_10s_errors_possible_aborts);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.early_hangups",
+                     &frac_avg_10s_errors_early_hangups);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.empty_hangups",
+                     &frac_avg_10s_errors_empty_hangups);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.errors.pre_accept_hangups",
+                     &frac_avg_10s_errors_pre_accept_hangups);
+  Cli_RecordGetFloat("proxy.node.http.transaction_frac_avg_10s.other.unclassified", &frac_avg_10s_other_unclassified);
+
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.hit_fresh", &msec_avg_10s_hit_fresh);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.hit_revalidated", &msec_avg_10s_hit_revalidated);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.miss_cold", &msec_avg_10s_miss_cold);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.miss_not_cacheable", &msec_avg_10s_miss_not_cachable);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.miss_changed", &msec_avg_10s_miss_changed);
+
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.miss_client_no_cache", &msec_avg_10s_miss_client_no_cache);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.connect_failed",
+                   &msec_avg_10s_errors_connect_failed);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.other", &msec_avg_10s_errors_other);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.aborts", &msec_avg_10s_errors_aborts);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.possible_aborts",
+                   &msec_avg_10s_errors_possible_aborts);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.early_hangups", &msec_avg_10s_errors_early_hangups);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.empty_hangups", &msec_avg_10s_errors_empty_hangups);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.errors.pre_accept_hangups",
+                   &msec_avg_10s_errors_pre_accept_hangups);
+  Cli_RecordGetInt("proxy.node.http.transaction_msec_avg_10s.other.unclassified", &msec_avg_10s_other_unclassified);
+
+  //display
+  Cli_Printf("\n");
+  Cli_Printf("HTTP Transaction Frequency and Speeds\n");
+  Cli_Printf("Transaction Type              Frequency   Speed(ms)\n");
+  Cli_Printf("--Hits--\n");
+  Cli_Printf("Fresh ----------------------- %f %%  %d\n", 100 * frac_avg_10s_hit_fresh, msec_avg_10s_hit_fresh);
+  Cli_Printf("Stale Revalidated ----------- %f %%  %d\n", 100 * frac_avg_10s_hit_revalidated,
+             msec_avg_10s_hit_revalidated);
+  Cli_Printf("--Misses--\n");
+  Cli_Printf("Now Cached ------------------ %f %%  %d\n", 100 * frac_avg_10s_miss_cold, msec_avg_10s_miss_cold);
+  Cli_Printf("Server No Cache ------------- %f %%  %d\n", 100 * frac_avg_10s_miss_not_cachable,
+             msec_avg_10s_miss_not_cachable);
+  Cli_Printf("Stale Reloaded -------------- %f %%  %d\n", 100 * frac_avg_10s_miss_changed, msec_avg_10s_miss_changed);
+  Cli_Printf("Client No Cache ------------- %f %%  %d\n", 100 * frac_avg_10s_miss_client_no_cache,
+             msec_avg_10s_miss_client_no_cache);
+  Cli_Printf("--Errors--\n");
+  Cli_Printf("Connection Failures --------- %f %%  %d\n", 100 * frac_avg_10s_errors_connect_failed,
+             msec_avg_10s_errors_connect_failed);
+  Cli_Printf("Other Errors ---------------- %f %%  %d\n", 100 * frac_avg_10s_errors_other, msec_avg_10s_errors_other);
+  Cli_Printf("--Aborted Transactions--\n");
+  Cli_Printf("Client Aborts --------------- %f %%  %d\n", 100 * frac_avg_10s_errors_aborts, msec_avg_10s_errors_aborts);
+  Cli_Printf("Questionable Client Aborts -- %f %%  %d\n", 100 * frac_avg_10s_errors_possible_aborts,
+             msec_avg_10s_errors_possible_aborts);
+  Cli_Printf("Partial Request Hangups ----- %f %%  %d\n", 100 * frac_avg_10s_errors_early_hangups,
+             msec_avg_10s_errors_possible_aborts);
+  Cli_Printf("Pre-Request Hangups --------- %f %%  %d\n", 100 * frac_avg_10s_errors_empty_hangups,
+             msec_avg_10s_errors_empty_hangups);
+  Cli_Printf("Pre-Connect Hangups --------- %f %%  %d\n", 100 * frac_avg_10s_errors_pre_accept_hangups,
+             msec_avg_10s_errors_pre_accept_hangups);
+  Cli_Printf("--Other Transactions--\n");
+  Cli_Printf("Unclassified ---------------- %f %%  %d\n", 100 * frac_avg_10s_other_unclassified,
+             msec_avg_10s_other_unclassified);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show http-stats sub-command
+int
+ShowHttpStats()
+{
+  //variable declaration
+  TSInt user_agent_response_document_total_size = -1;
+  TSInt user_agent_response_header_total_size = -1;
+  TSInt current_client_connections = -1;
+  TSInt current_client_transactions = -1;
+  TSInt origin_server_response_document_total_size = -1;
+  TSInt origin_server_response_header_total_size = -1;
+  TSInt current_server_connections = -1;
+  TSInt current_server_transactions = -1;
+  //get value
+  Cli_RecordGetInt("proxy.process.http.user_agent_response_document_total_size",
+                   &user_agent_response_document_total_size);
+  Cli_RecordGetInt("proxy.process.http.user_agent_response_header_total_size", &user_agent_response_header_total_size);
+  Cli_RecordGetInt("proxy.process.http.current_client_connections", &current_client_connections);
+  Cli_RecordGetInt("proxy.process.http.current_client_transactions", &current_client_transactions);
+  Cli_RecordGetInt("proxy.process.http.origin_server_response_document_total_size",
+                   &origin_server_response_document_total_size);
+  Cli_RecordGetInt("proxy.process.http.origin_server_response_header_total_size",
+                   &origin_server_response_header_total_size);
+  Cli_RecordGetInt("proxy.process.http.current_server_connections", &current_server_connections);
+  Cli_RecordGetInt("proxy.process.http.current_server_transactions", &current_server_transactions);
+
+  //display value
+  Cli_Printf("\n");
+  Cli_Printf("--Client--\n");
+  Cli_Printf("Total Document Bytes ----- %d MB\n", user_agent_response_document_total_size / (1024 * 1024));
+  Cli_Printf("Total Header Bytes ------- %d MB\n", user_agent_response_header_total_size / (1024 * 1024));
+  Cli_Printf("Total Connections -------- %d\n", current_client_connections);
+  Cli_Printf("Transactins In Progress -- %d\n", current_client_transactions);
+  Cli_Printf("--Server--\n");
+  Cli_Printf("Total Document Bytes ----- %d MB\n", origin_server_response_document_total_size / (1024 * 1024));
+  Cli_Printf("Total Header Bytes ------- %d MB\n", origin_server_response_header_total_size / (1024 * 1024));
+  Cli_Printf("Total Connections -------- %d\n", current_server_connections);
+  Cli_Printf("Transactins In Progress -- %d\n", current_server_transactions);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show proxy-stats sub-command
+int
+ShowIcpStats()
+{
+  //variable declaration
+
+  TSInt icp_query_requests = -1;
+  TSInt total_udp_send_queries = -1;
+  TSInt icp_query_hits = -1;
+  TSInt icp_query_misses = -1;
+  TSInt icp_remote_responses = -1;
+  TSFloat total_icp_response_time = -1.0;
+  TSFloat total_icp_request_time = -1.0;
+  TSInt icp_remote_query_requests = -1;
+  TSInt cache_lookup_success = -1;
+  TSInt cache_lookup_fail = -1;
+  TSInt query_response_write = -1;
+
+  //get values
+  Cli_RecordGetInt("proxy.process.icp.icp_query_requests", &icp_query_requests);
+  Cli_RecordGetInt("proxy.process.icp.total_udp_send_queries", &total_udp_send_queries);
+  Cli_RecordGetInt("proxy.process.icp.icp_query_hits", &icp_query_hits);
+  Cli_RecordGetInt("proxy.process.icp.icp_query_misses", &icp_query_misses);
+  Cli_RecordGetInt("proxy.process.icp.icp_remote_responses", &icp_remote_responses);
+  Cli_RecordGetFloat("proxy.process.icp.total_icp_response_time", &total_icp_response_time);
+  Cli_RecordGetFloat("proxy.process.icp.total_icp_request_time", &total_icp_request_time);
+  Cli_RecordGetInt("proxy.process.icp.icp_remote_query_requests", &icp_remote_query_requests);
+  Cli_RecordGetInt("proxy.process.icp.cache_lookup_success", &cache_lookup_success);
+  Cli_RecordGetInt("proxy.process.icp.cache_lookup_fail", &cache_lookup_fail);
+  Cli_RecordGetInt("proxy.process.icp.query_response_write", &query_response_write);
+
+  //display values
+  Cli_Printf("\n");
+  Cli_Printf("--Queries Originating From This Node--\n");
+  Cli_Printf("Query Requests ----------------------------- %d\n", icp_query_requests);
+  Cli_Printf("Query Messages Sent ------------------------ %d\n", total_udp_send_queries);
+  Cli_Printf("Peer Hit Messages Received ----------------- %d\n", icp_query_hits);
+  Cli_Printf("Peer Miss Messages Received ---------------- %d\n", icp_query_misses);
+  Cli_Printf("Total Responses Received ------------------- %d\n", icp_remote_responses);
+  Cli_Printf("Average ICP Message Response Time ---------- %f ms\n", total_icp_response_time);
+  Cli_Printf("Average ICP Request Time ------------------- %f ms\n", total_icp_request_time);
+  Cli_Printf("\n");
+  Cli_Printf("--Queries Originating from ICP Peers--\n");
+  Cli_Printf("Query Messages Received -------------------- %d\n", icp_remote_query_requests);
+  Cli_Printf("Remote Query Hits -------------------------- %d\n", cache_lookup_success);
+  Cli_Printf("Remote Query Misses ------------------------ %d\n", cache_lookup_fail);
+  Cli_Printf("Successful Response Message Sent to Peers -- %d\n", query_response_write);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show proxy-stats sub-command
+int
+ShowCacheStats()
+{
+  //variable delaration
+  TSInt bytes_used = -1;
+  TSInt bytes_total = -1;
+  TSInt ram_cache_total_bytes = -1;
+  TSInt ram_cache_bytes_used = -1;
+  TSInt ram_cache_hits = -1;
+  TSInt ram_cache_misses = -1;
+  TSInt lookup_active = -1;
+  TSInt lookup_success = -1;
+  TSInt lookup_failure = -1;
+  TSInt read_active = -1;
+  TSInt read_success = -1;
+  TSInt read_failure = -1;
+  TSInt write_active = -1;
+  TSInt write_success = -1;
+  TSInt write_failure = -1;
+  TSInt update_active = -1;
+  TSInt update_success = -1;
+  TSInt update_failure = -1;
+  TSInt remove_active = -1;
+  TSInt remove_success = -1;
+  TSInt remove_failure = -1;
+
+  //get values
+
+  Cli_RecordGetInt("proxy.process.cache.bytes_used", &bytes_used);
+  Cli_RecordGetInt("proxy.process.cache.bytes_total", &bytes_total);
+  Cli_RecordGetInt("proxy.process.cache.ram_cache.total_bytes", &ram_cache_total_bytes);
+  Cli_RecordGetInt("proxy.process.cache.ram_cache.bytes_used", &ram_cache_bytes_used);
+  Cli_RecordGetInt("proxy.process.cache.ram_cache.hits", &ram_cache_hits);
+  Cli_RecordGetInt("proxy.process.cache.ram_cache.misses", &ram_cache_misses);
+  Cli_RecordGetInt("proxy.process.cache.lookup.active", &lookup_active);
+  Cli_RecordGetInt("proxy.process.cache.lookup.success", &lookup_success);
+  Cli_RecordGetInt("proxy.process.cache.lookup.failure", &lookup_failure);
+  Cli_RecordGetInt("proxy.process.cache.read.active", &read_active);
+  Cli_RecordGetInt("proxy.process.cache.read.success", &read_success);
+  Cli_RecordGetInt("proxy.process.cache.read.failure", &read_failure);
+  Cli_RecordGetInt("proxy.process.cache.write.active", &write_active);
+  Cli_RecordGetInt("proxy.process.cache.write.success", &write_success);
+  Cli_RecordGetInt("proxy.process.cache.write.failure", &write_failure);
+  Cli_RecordGetInt("proxy.process.cache.update.active", &update_active);
+  Cli_RecordGetInt("proxy.process.cache.update.success", &update_success);
+  Cli_RecordGetInt("proxy.process.cache.update.failure", &update_failure);
+  Cli_RecordGetInt("proxy.process.cache.remove.active", &remove_active);
+  Cli_RecordGetInt("proxy.process.cache.remove.success", &remove_success);
+  Cli_RecordGetInt("proxy.process.cache.remove.failure", &remove_failure);
+
+  //display values
+  Cli_Printf("\n");
+  Cli_Printf("Bytes Used --- %d GB\n", bytes_used / (1024 * 1024 * 1024));
+  Cli_Printf("Cache Size --- %d GB\n", bytes_total / (1024 * 1024 * 1024));
+  Cli_Printf("--RAM Cache--\n");
+  Cli_Printf("Total Bytes -- %" PRId64 "\n", ram_cache_total_bytes);
+  Cli_Printf("Bytes Used --- %" PRId64 "\n", ram_cache_bytes_used);
+  Cli_Printf("Hits --------- %d\n", ram_cache_hits);
+  Cli_Printf("Misses ------- %d\n", ram_cache_misses);
+  Cli_Printf("--Lookups--\n");
+  Cli_Printf("In Progress -- %d\n", lookup_active);
+  Cli_Printf("Hits --------- %d\n", lookup_success);
+  Cli_Printf("Misses ------- %d\n", lookup_failure);
+  Cli_Printf("--Reads--\n");
+  Cli_Printf("In Progress -- %d\n", read_active);
+  Cli_Printf("Hits --------- %d\n", read_success);
+  Cli_Printf("Misses ------- %d\n", read_failure);
+  Cli_Printf("--Writes--\n");
+  Cli_Printf("In Progress -- %d\n", write_active);
+  Cli_Printf("Hits --------- %d\n", write_success);
+  Cli_Printf("Misses ------- %d\n", write_failure);
+  Cli_Printf("--Updates--\n");
+  Cli_Printf("In Progress -- %d\n", update_active);
+  Cli_Printf("Hits --------- %d\n", update_success);
+  Cli_Printf("Misses ------- %d\n", update_failure);
+  Cli_Printf("--Removes--\n");
+  Cli_Printf("In Progress -- %d\n", remove_active);
+  Cli_Printf("Hits --------- %d\n", remove_success);
+  Cli_Printf("Misses ------- %d\n", remove_failure);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show proxy-stats sub-command
+int
+ShowHostDbStats()
+{
+  //variables
+  TSFloat hit_ratio = -1.0;
+  TSFloat lookups_per_second = -1.0;
+
+  //get values
+  Cli_RecordGetFloat("proxy.node.hostdb.hit_ratio", &hit_ratio);
+  Cli_RecordGetFloat("proxy.node.dns.lookups_per_second", &lookups_per_second);
+
+  //display values
+  Cli_Printf("\n");
+  Cli_Printf("Host Database hit Rate -- %f %% *\n", 100 * hit_ratio);
+  Cli_Printf("DNS Lookups Per Second -- %f\n", lookups_per_second);
+  Cli_Printf("\n* Value reprensents 10 second average.\n");
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show proxy-stats sub-command
+int
+ShowDnsStats()
+{
+  TSFloat lookups_per_second = -1.0;
+
+  Cli_RecordGetFloat("proxy.node.dns.lookups_per_second", &lookups_per_second);
+  Cli_Printf("\n");
+  Cli_Printf("DNS Lookups Per Second -- %f\n", lookups_per_second);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show proxy-stats sub-command
+int
+ShowLoggingStats()
+{
+  TSCounter log_file_open = -1;
+  TSInt log_files_space_used = -1;
+  TSCounter event_log_access = -1;
+  TSCounter event_log_access_skip = -1;
+  TSCounter event_log_error = -1;
+
+  Cli_RecordGetCounter("proxy.process.log.log_files_open", &log_file_open);
+  Cli_RecordGetInt("proxy.process.log.log_files_space_used", &log_files_space_used);
+  Cli_RecordGetCounter("proxy.process.log.event_log_access", &event_log_access);
+  Cli_RecordGetCounter("proxy.process.log.event_log_access_skip", &event_log_access_skip);
+  Cli_RecordGetCounter("proxy.process.log.event_log_error", &event_log_error);
+
+  Cli_Printf("\n");
+  Cli_Printf("Current Open Log Files ----------- %d\n", log_file_open);
+  Cli_Printf("Space Used For Log Files --------- %d\n", log_files_space_used);
+  Cli_Printf("Number of Access Events Logged --- %d\n", event_log_access);
+  Cli_Printf("Number of Access Events Skipped -- %d\n", event_log_access_skip);
+  Cli_Printf("Number of Error Events Logged ---- %d\n", event_log_error);
+  Cli_Printf("\n");
+
+  return CLI_OK;
+}
+
+// show:alarms sub-command
+int
+ShowAlarms()
+{
+  TSList events;
+  int count, i;
+  char *name;
+
+  events = TSListCreate();
+  TSError status = TSActiveEventGetMlt(events);
+  if (status != TS_ERR_OKAY) {
+    if (events) {
+      TSListDestroy(events);
+    }
+    Cli_Error(ERR_ALARM_LIST);
+    return CLI_ERROR;
+  }
+
+  count = TSListLen(events);
+  if (count > 0) {
+    Cli_Printf("\nActive Alarms\n");
+    for (i = 0; i < count; i++) {
+      name = (char *) TSListDequeue(events);
+      Cli_Printf("  %d. %s\n", i + 1, name);
+    }
+    Cli_Printf("\n");
+  } else {
+    Cli_Printf("\nNo active alarms.\n\n");
+  }
+
+  TSListDestroy(events);
+
+  return CLI_OK;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/ShowCmd.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/ShowCmd.h b/cmd/traffic_shell/ShowCmd.h
new file mode 100644
index 0000000..ab9a8c6
--- /dev/null
+++ b/cmd/traffic_shell/ShowCmd.h
@@ -0,0 +1,247 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/****************************************************************
+ * Filename: ShowCmd.h
+ * Purpose: This file contains the CLI's "show" command definitions.
+ *
+ *
+ ****************************************************************/
+
+#include <tcl.h>
+#include "createArgument.h"
+#include "definitions.h"
+
+#ifndef __SHOW_CMD_H__
+#define __SHOW_CMD_H__
+
+// enumerated type which captures all "show" commands
+typedef enum
+{
+  CMD_SHOW_STATUS = 1,
+  CMD_SHOW_VERSION,
+  CMD_SHOW_PORTS,
+  CMD_SHOW_CLUSTER,
+  CMD_SHOW_SECURITY,
+  CMD_SHOW_HTTP,
+  CMD_SHOW_ICP,
+  CMD_SHOW_ICP_PEER,
+  CMD_SHOW_PROXY,
+  CMD_SHOW_CACHE,
+  CMD_SHOW_CACHE_RULES,
+  CMD_SHOW_CACHE_STORAGE,
+  CMD_SHOW_VIRTUAL_IP,
+  CMD_SHOW_HOSTDB,
+  CMD_SHOW_DNS_RESOLVER,
+  CMD_SHOW_LOGGING,
+  CMD_SHOW_SSL,
+  CMD_SHOW_FILTER,
+  CMD_SHOW_PARENTS,
+  CMD_SHOW_PARENT_RULES,
+  CMD_SHOW_REMAP,
+  CMD_SHOW_SOCKS,
+  CMD_SHOW_SOCKS_RULES,
+  CMD_SHOW_PORT_TUNNELS,
+  CMD_SHOW_SCHEDULED_UPDATE,
+  CMD_SHOW_UPDATE_RULES,
+  CMD_SHOW_PROXY_STATS,
+  CMD_SHOW_HTTP_TRANS_STATS,
+  CMD_SHOW_HTTP_STATS,
+  CMD_SHOW_ICP_STATS,
+  CMD_SHOW_CACHE_STATS,
+  CMD_SHOW_HOSTDB_STATS,
+  CMD_SHOW_DNS_STATS,
+  CMD_SHOW_LOGGING_STATS
+} cliShowCommand;
+
+////////////////////////////////////////////////////////////////
+// ShowCmd
+//
+// This is the callback function for the "show" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int ShowCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// ShowCmdArgs
+//
+// Register "show" command arguments with the Tcl interpreter.
+//
+int ShowCmdArgs();
+
+int Cmd_Show(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowStatus(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowVersion(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowPorts(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowCluster(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowSecurity(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowHttp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowIcp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int CmdArgs_ShowIcp();
+int Cmd_ShowProxy(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowCache(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int CmdArgs_ShowCache();
+int Cmd_ShowVirtualIp(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowHostDb(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowDnsResolver(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowLogging(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowSsl(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowParents(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int CmdArgs_ShowParents();
+int Cmd_ShowRemap(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowSocks(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int CmdArgs_ShowSocks();
+int Cmd_ShowScheduledUpdate(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int CmdArgs_ShowScheduledUpdate();
+int Cmd_ShowProxyStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowHttpTransStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowHttpStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowIcpStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowCacheStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowHostDbStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowDnsStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowLoggingStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowAlarms(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowRadius(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowNtlm(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int Cmd_ShowNtlmStats(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+int CmdArgs_None();
+
+int getnameserver(char *nameserver, int len);
+int getrouter(char *router, int len);
+
+////////////////////////////////////////////////////////////////
+//
+// "show" sub-command implementations
+//
+////////////////////////////////////////////////////////////////
+
+// show status sub-command
+int ShowStatus();
+
+// show version sub-command
+int ShowVersion();
+
+// show ports sub-command
+int ShowPorts();
+
+// show cluster sub-command
+int ShowCluster();
+
+// show security sub-command
+int ShowSecurity();
+
+// show http sub-command
+int ShowHttp();
+
+// show icp sub-command
+int ShowIcp();
+
+// show icp peer sub-command
+int ShowIcpPeer();
+
+// show proxy sub-command
+int ShowProxy();
+
+// show cache sub-command
+int ShowCache();
+
+// show cache rules sub-command
+int ShowCacheRules();
+
+// show cache storage sub-command
+int ShowCacheStorage();
+
+// show virtual-ip sub-command
+int ShowVirtualIp();
+
+// show hostdb sub-command
+int ShowHostDb();
+
+// show dns-resolver sub-command
+int ShowDnsResolver();
+
+// show logging sub-command
+int ShowLogging();
+
+// show ssl sub-command
+int ShowSsl();
+
+// show parents sub-command
+int ShowParents();
+
+// show:parent rules sub-command
+int ShowParentRules();
+
+// show remap sub-command
+int ShowRemap();
+
+// show socks sub-command
+int ShowSocks();
+
+// show:socks rules sub-command
+int ShowSocksRules();
+
+// show scheduled-update sub-command
+int ShowScheduledUpdate();
+
+// show:scheduled-update rules sub-command
+int ShowScheduledUpdateRules();
+
+////////////////////////////////////////////////////////////////
+// statistics sub-commands
+//
+
+// show proxy-stats sub-command
+int ShowProxyStats();
+
+// show proxy-stats sub-command
+int ShowHttpTransStats();
+
+// show proxy-stats sub-command
+int ShowHttpStats();
+
+// show proxy-stats sub-command
+int ShowIcpStats();
+
+// show proxy-stats sub-command
+int ShowCacheStats();
+
+// show proxy-stats sub-command
+int ShowHostDbStats();
+
+// show proxy-stats sub-command
+int ShowDnsStats();
+
+// show proxy-stats sub-command
+int ShowLoggingStats();
+
+// show:alarms sub-command
+int ShowAlarms();
+
+#endif // __SHOW_CMD_H__


[15/44] TS-2349: Move traffic_shell to the cmd subdirectory

Posted by zw...@apache.org.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/UtilCmds.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/UtilCmds.cc b/cmd/traffic_shell/UtilCmds.cc
new file mode 100644
index 0000000..74ed09e
--- /dev/null
+++ b/cmd/traffic_shell/UtilCmds.cc
@@ -0,0 +1,196 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/****************************************************************
+ * Filename: UtilCmds.cc
+ * Purpose: This file contains the CLI's utility commands.
+ *
+ *
+ ****************************************************************/
+
+#include "UtilCmds.h"
+#include "createArgument.h"
+#include "CliMgmtUtils.h"
+#include "CliDisplay.h"
+#include "ink_error.h"
+#include "ink_defs.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+////////////////////////////////////////////////////////////////
+// DebugCmd
+//
+// This is the callback function for the "debug" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+DebugCmd(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  cli_cmdCallbackInfo *cmdCallbackInfo;
+  cli_parsedArgInfo *argtable, *infoPtr;
+
+  cmdCallbackInfo = (cli_cmdCallbackInfo *) clientData;
+  argtable = cmdCallbackInfo->parsedArgTable;
+
+  Cli_Debug("DebugCmd\n");
+
+  for (infoPtr = argtable; (infoPtr->parsed_args != 0); infoPtr++) {
+
+    // call appropriate function based on the 1st argument
+
+    switch (infoPtr->parsed_args) {
+    case CMD_DEBUG_ON:
+      Cli_Debug("debug on sub-command\n");
+      return (DebugOn());
+
+    case CMD_DEBUG_OFF:
+      Cli_Debug("debug off sub-command\n");
+      return (DebugOff());
+    }
+  }
+  return CLI_OK;
+}
+
+
+////////////////////////////////////////////////////////////////
+// DebugCmdArgs
+//
+// Register "debug" command arguments with the Tcl interpreter.
+//
+int
+DebugCmdArgs()
+{
+  Cli_Debug("DebugCmdArgs\n");
+
+  createArgument("on", 1, CLI_ARGV_CONSTANT, (char *) NULL, CMD_DEBUG_ON, "Turn Debug Statements ON", (char *) NULL);
+
+  createArgument("off", 1, CLI_ARGV_CONSTANT, (char *) NULL, CMD_DEBUG_OFF, "Turn Debug Statements OFF", (char *) NULL);
+
+  return CLI_OK;
+}
+
+////////////////////////////////////////////////////////////////
+//
+// "debug" sub-command implementations
+//
+////////////////////////////////////////////////////////////////
+
+
+// debug on sub-command
+//   used to turn on debug print statements
+int
+DebugOn()
+{
+  CliPrintLevelT level = Cli_GetPrintLevel();
+  level = (CliPrintLevelT) ((int) level | (int) CLI_PRINT_DEBUG);
+  Cli_SetPrintLevel(level);
+  return CLI_OK;
+}
+
+// debug off sub-command
+//   used to turn off debug print statements
+int
+DebugOff()
+{
+  CliPrintLevelT level = Cli_GetPrintLevel();
+  level = (CliPrintLevelT) ((int) level & ~(int) CLI_PRINT_DEBUG);
+  Cli_SetPrintLevel(level);
+  return CLI_OK;
+}
+
+
+////////////////////////////////////////////////////////////////
+// Cmd_ConfigRoot
+//
+// This is the callback function for the "config:root" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int
+Cmd_ConfigRoot(ClientData /* clientData ATS_UNUSED */, Tcl_Interp * interp, int argc, const char *argv[])
+{
+  /* call to processArgForCommand must appear at the beginning
+   * of each command's callback function
+   */
+  if (processArgForCommand(interp, argc, argv) != CLI_OK) {
+    return CMD_ERROR;
+  }
+
+  if (processHelpCommand(argc, argv) == CLI_OK)
+    return CMD_OK;
+
+  if (cliCheckIfEnabled("config:root") == CLI_ERROR) {
+    return CMD_ERROR;
+  }
+
+  Cli_Debug("Cmd_ConfigRoot\n");
+
+  if (getuid() == 0) {
+    Cli_Printf("Already root user.\n");
+    return CLI_OK;
+
+  }
+  char ts_path[1024];
+  if (GetTSDirectory(ts_path,sizeof(ts_path))) {
+    return CLI_ERROR;
+  }
+
+  char command[1024];
+  snprintf(command, sizeof(command),
+           "/bin/su - root -c \"%s/start_traffic_shell\"", ts_path);
+
+  // start traffic_shell as root user
+  // su will prompt user for root password
+  int pid = fork();
+  if (pid == 0) {
+    if (system(command) == -1)
+      exit(2);
+    else
+      exit(1);
+  }
+
+  waitpid(pid, NULL, 0);
+
+  return CLI_OK;
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/UtilCmds.h
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/UtilCmds.h b/cmd/traffic_shell/UtilCmds.h
new file mode 100644
index 0000000..ad1c705
--- /dev/null
+++ b/cmd/traffic_shell/UtilCmds.h
@@ -0,0 +1,94 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/****************************************************************
+ * Filename: UtilCmds.h
+ * Purpose: This file contains the CLI's utility commands.
+ *
+ *
+ ****************************************************************/
+
+
+/* This includes a commited hacked version of tcl which has an external dependancy
+   on cli-specific code and thus, this tcl build cannot be used with other
+   code, and normal non-hacked tcl cannot be used with cli.  Even more beutiful
+   is the fact that the hacks are no-where documented.  I managed to scrape
+   them up and role them into a patch which can be found in
+   $CVSROOT/contrib/tcl-tclx/common/patches for reference in case someone
+   ever should feel like comming up with something a little more well thought out.
+   Oh, did I mention also that apperently, no thought was put toward how to make
+   this work with more than one platform, or is that obvious just by looking
+   at the structure?
+*/
+//#include "inktcl/include/tcl.h"
+/* There is is in all it's glory :( */
+
+
+#include "createArgument.h"
+#include "definitions.h"
+
+#ifndef __UTIL_CMDS_H__
+#define __UTIL_CMDS_H__
+
+// enumerated type which captures all "debug" command options
+typedef enum
+{
+  CMD_DEBUG_ON = 1,
+  CMD_DEBUG_OFF
+} cliDebugCommand;
+
+////////////////////////////////////////////////////////////////
+// DebugCmd
+//
+// This is the callback function for the "debug" command.
+//
+// Parameters:
+//    clientData -- information about parsed arguments
+//    interp -- the Tcl interpreter
+//    argc -- number of command arguments
+//    argv -- the command arguments
+//
+int DebugCmd(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+////////////////////////////////////////////////////////////////
+// DebugCmdArgs
+//
+// Register "debug" command arguments with the Tcl interpreter.
+//
+int DebugCmdArgs();
+
+////////////////////////////////////////////////////////////////
+//
+// "debug" sub-command implementations
+//
+////////////////////////////////////////////////////////////////
+
+// debug on sub-command
+int DebugOn();
+
+// debug off sub-command
+int DebugOff();
+
+int Cmd_ConfigRoot(ClientData clientData, Tcl_Interp * interp, int argc, const char *argv[]);
+
+#endif // __UTIL_CMDS_H__

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/cliAppInit.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/cliAppInit.cc b/cmd/traffic_shell/cliAppInit.cc
new file mode 100644
index 0000000..461b9f6
--- /dev/null
+++ b/cmd/traffic_shell/cliAppInit.cc
@@ -0,0 +1,165 @@
+/** @file
+
+  A brief file description
+
+  @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.
+ */
+
+/*
+ *   cliAppInit.c --
+ *
+ *
+ *    This file initiliazes the application by calling all
+ *    the new commands and thier respective arguments
+ *
+ *
+ *
+ *    Dated  : 12/13/2000.
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <iostream>
+
+//#include "tclExtend.h"
+#include "tcl.h"
+#include <unistd.h>
+#include <sys/types.h>
+#include "CliMgmtUtils.h"
+#include "createCommand.h"
+#include "hashtable.h"
+#include "createArgument.h"
+#include "definitions.h"
+#include "ShowCmd.h"
+#include "ConfigCmd.h"
+#include "CliCreateCommands.h"
+#include "ink_defs.h"
+
+#if HAVE_EDITLINE_READLINE_H
+#include <editline/readline.h>
+#elif HAVE_READLINE_READLINE_H
+#include <readline/readline.h>
+#if HAVE_READLINE_HISTORY_H
+#include <readline/history.h>
+#endif
+#endif
+
+
+Tcl_Interp *interp;
+extern Tcl_HashTable CommandHashtable;
+
+int
+Tcl_AppInit(Tcl_Interp * app_interp)
+{
+  /*
+   * Intialize the Tcl interpreter.
+   */
+  if (Tcl_Init(app_interp) == TCL_ERROR)
+    return TCL_ERROR;
+
+  interp = app_interp;
+
+#ifdef TCL_MEM_DEBUG
+  Tcl_InitMemory(interp);
+#endif
+
+  cliCreateCommandHashtable();
+
+  // root users are automatically enabled
+  if (getuid() == 0) {
+    enable_restricted_commands = true;
+  }
+
+
+  if (CliCreateCommands() != CLI_OK)
+    return CMD_ERROR;
+
+  Tcl_SetVar(interp, "tcl_rcFileName", "~/.tshellstartup", TCL_GLOBAL_ONLY);
+
+/* Evaluating a application specific tcl script After creating
+   all the commands and sourcing the statup file */
+/* Always this should be at the end of this function. */
+  /*
+   * Parse command-line arguments.  A leading "-file" argument is
+   * ignored (a historical relic from the distant past).  If the
+   * next argument doesn't start with a "-" then strip it off and
+   * use it as the name of a script file to process.
+   */
+
+  const char *fileName = Tcl_GetVar(interp, "argv", TCL_LEAVE_ERR_MSG);
+  /*
+   * Invoke the script specified on the command line, if any.
+   */
+
+  if (fileName[0] != '\0') {
+    int listArgc;
+    const char **listArgv;
+
+    if (Tcl_SplitList(interp, fileName, &listArgc, &listArgv) != TCL_OK) {
+      return TCL_ERROR;
+    }
+    int length = strlen(listArgv[0]);
+    if ((length >= 2) && (strncmp(listArgv[0], "-file", length) == 0)) {
+      for (int index = 1; index < listArgc; index++) {
+        Tcl_ResetResult(interp);
+        if (Tcl_EvalFile(interp, listArgv[index]) != TCL_OK) {
+          Tcl_AddErrorInfo(interp, "");
+          Tcl_DeleteInterp(interp);
+          Tcl_Exit(1);
+        }
+      }
+    }
+    ckfree((char *) listArgv);
+  }
+
+  Tcl_ResetResult(interp);
+
+  return TCL_OK;
+}
+
+#if HAVE_LIBREADLINE
+
+// TCL main read, eval, print loop. We don't use Tcl_Main because we want to
+// use readline to get line editing and command history.
+void Tcl_ReadlineMain(void)
+{
+  char * line;
+
+  for (;;) {
+    line = readline("trafficserver> ");
+    if (line == NULL) {
+      // Received EOF. Bound this into a TCL exit command just like Tcl_Main
+      // does.
+      Tcl_Eval(interp, "exit;");
+    }
+
+    if (*line) {
+      add_history(line);
+      Tcl_Eval(interp, line);
+    }
+
+    free(line);
+  }
+
+  exit(0);
+}
+
+#endif // HAVE_LIBREADLINE
+
+// vim: set ts=2 sw=2 et :

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/cliParseArg.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/cliParseArg.cc b/cmd/traffic_shell/cliParseArg.cc
new file mode 100644
index 0000000..72e6039
--- /dev/null
+++ b/cmd/traffic_shell/cliParseArg.cc
@@ -0,0 +1,457 @@
+/** @file
+
+  contains the implementation for parsing CLI arguments
+
+  @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.
+
+  @section Description
+  cliParseArgument(int argc,char **argv,cli_ArgvInfo *argTable)
+  compares the given arguments with the expected arguments and
+  returns error if they are not same
+  If arguments are are valid it converts string arguments to the proper type
+ */
+
+#include <tcl.h>
+#include <string.h>
+#include <stdlib.h>
+#include "createArgument.h"
+#include "definitions.h"
+#include "CliDisplay.h"
+#include "ink_string.h"
+#include "ink_defs.h"
+
+int checkintrange(char *range, int value);
+int checkfloatrange(char *range, float value);
+char **findRequired(cli_ArgvInfo * argtable);
+extern Tcl_Interp *interp;
+
+/*
+ * Forward declarations for procedures defined in this file:
+ */
+static void PrintUsage _ANSI_ARGS_((Tcl_Interp * interp, cli_CommandInfo * commandinfo));
+
+
+
+int
+cliParseArgument(int argc, const char **argv, cli_CommandInfo * commandInfo)
+{
+  cli_ArgvInfo *infoPtr, *prevMatchPtr = NULL, *prevPtr = NULL;
+  cli_parsedArgInfo *parsedInfoPtr, *prev_parsedInfoPtr = NULL;
+  int srcIndex = 1;
+  bool gotMatch = false, gotInt = false;
+  int missing = 0;
+  int length, i;
+  char curArg[256], buf[256];
+  char *endPtr;
+  bool got_required;
+  cli_ArgvInfo *argTable = commandInfo->argtable;
+  char **reqd_args = commandInfo->reqd_args;
+  cli_parsedArgInfo *parsedArgTable = commandInfo->parsedArgTable;
+
+
+
+  argc--;                       /*first argument is command name */
+
+
+/* Special option for help handled here, No need to create an -help */
+  /* I assume that the first thing will always start with - */
+
+  if (argc == 1) {
+    length = strlen(argv[1]);
+    if ((length >= 2) && ((strncmp(argv[1], "-help", length) == 0) || (strncmp(argv[1], "-h", length) == 0))) {
+      PrintUsage(interp, commandInfo);
+      return TCL_OK;
+    } else if (strcmp(argv[1], "----") == 0) {
+      /* Special case with readline options */
+      /* Readline always sends "----" */
+      return TCL_OK;
+    }
+  }
+
+
+  /* check for required arguments */
+  if (reqd_args != (char **) NULL) {
+    missing = 0;
+    for (i = 0; reqd_args[i] != NULL; i++) {
+      got_required = false;
+      srcIndex = 1;
+      while (srcIndex <= argc) {
+        if (!strcmp(reqd_args[i], argv[srcIndex])) {
+          got_required = true;
+          break;
+        }
+        srcIndex++;
+      }
+      if (got_required == false) {
+        missing++;
+        if (missing == 1)
+          Tcl_AppendResult(interp, reqd_args[i], (char *) NULL);
+        else
+          Tcl_AppendResult(interp, " , ", reqd_args[i], (char *) NULL);
+      }
+    }
+
+    if (missing == 1) {
+      Tcl_AppendResult(interp, " is required ", (char *) NULL);
+      return TCL_ERROR;
+    } else if (missing > 1) {
+      Tcl_AppendResult(interp, " are required ", (char *) NULL);
+      return TCL_ERROR;
+    }
+
+  }
+/* Initialise Parsed Argtable */
+  for (i = 0; i < 100; i++) {
+    parsedArgTable[i].parsed_args = CLI_PARSED_ARGV_DATA;
+    parsedArgTable[i].arg_float = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
+    parsedArgTable[i].arg_int = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
+
+    if (parsedArgTable[i].data && (parsedArgTable[i].data != (char *) NULL)) {
+      ats_free(parsedArgTable[i].data);
+      parsedArgTable[i].data = (char *) NULL;
+
+    }
+    if (parsedArgTable[i].arg_string && parsedArgTable[i].arg_string != (char *) NULL) {
+      ats_free(parsedArgTable[i].arg_string);
+      parsedArgTable[i].arg_string = (char *) NULL;
+    }
+  }
+
+/* Error checking for commandline arguments based on createargument options */
+  parsedInfoPtr = parsedArgTable;
+  srcIndex = 1;
+  while (argc > 0) {
+    ink_strlcpy(curArg, argv[srcIndex], sizeof(curArg));
+    argc--;
+    srcIndex++;
+    length = strlen(curArg);
+    gotMatch = false;
+    for (infoPtr = argTable; (infoPtr->key != NULL); infoPtr++) {
+      if (!strcmp(infoPtr->key, curArg)) {
+        gotMatch = true;
+        if (infoPtr->position != CLI_ARGV_NO_POS) {     /* Don't do position checking for
+                                                           CLI_ARGV_NO_POS */
+          /* check if the 1st position argument comes at 1st position */
+          if ((infoPtr->position == CLI_PARENT_ARGV) && (srcIndex - 1) != 1) {
+            Tcl_AppendResult(interp, "\"", curArg, "\" is at wrong place Try ", argv[0], " -help", (char *) NULL);
+            return TCL_ERROR;
+          }
+
+          if (infoPtr->position != CLI_PARENT_ARGV) {
+            if ((srcIndex - 1) == 1) {
+              Tcl_AppendResult(interp, "\"", curArg, "\" is at wrong place Try ", argv[0], " -help", (char *) NULL);
+              return TCL_ERROR;
+            } else {
+              if (prevMatchPtr != NULL) {
+                if (prevMatchPtr->arg_ref != infoPtr->position) {
+                  Tcl_AppendResult(interp, "\"", curArg, "\" is at wrong place Try ", argv[0], " -help", (char *) NULL);
+                  return TCL_ERROR;
+                }
+              }
+
+            }
+          }
+        }
+
+        if (prevMatchPtr != NULL && prevPtr == prevMatchPtr) {
+          if (prevMatchPtr->type == CLI_ARGV_OPTION_NAME_VALUE) {
+            if (prev_parsedInfoPtr->arg_string) {
+              ats_free(prev_parsedInfoPtr->arg_string);
+              prev_parsedInfoPtr->arg_string = NULL;
+            }
+          }
+        }
+
+        parsedInfoPtr->arg_usage = infoPtr->help;
+
+        /* Position checking over check for type */
+
+        switch (infoPtr->type) {
+        case CLI_ARGV_CONSTANT:
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          if (argc != 0) {
+            snprintf(buf, sizeof(buf), "Too many arguments Try %s -help", argv[0]);
+            Tcl_AppendResult(interp, buf, (char *) NULL);
+            return TCL_ERROR;
+          }
+          break;
+        case CLI_ARGV_INT:
+          if (argc <= 0) {
+            Tcl_AppendResult(interp, "\"", curArg, "\" option requires an additional integer argument", "\n",
+                             infoPtr->help, (char *) NULL);
+            return TCL_ERROR;
+          }
+          parsedInfoPtr->arg_int = strtol(argv[srcIndex], &endPtr, 0);
+          if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
+            Tcl_AppendResult(interp, infoPtr->key, " requires integer argument ", "\n", infoPtr->help, (char *) NULL);
+            return TCL_ERROR;
+          }
+          if (infoPtr->range_set == true) {
+            if (parsedInfoPtr->arg_int < infoPtr->l_range.int_r1 || parsedInfoPtr->arg_int > infoPtr->u_range.int_r2) {
+              snprintf(buf, sizeof(buf), "value of %s is out of range %d - %d", infoPtr->key, infoPtr->l_range.int_r1,
+                       infoPtr->u_range.int_r2);
+
+              Tcl_AppendResult(interp, buf, (char *) NULL);
+              return TCL_ERROR;
+            }
+
+          }
+          srcIndex++;
+          argc--;
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          break;
+
+        case CLI_ARGV_OPTION_INT_VALUE:
+          gotInt = 0;
+          if (argc > 0) {
+            parsedInfoPtr->arg_int = strtol(argv[srcIndex], &endPtr, 0);
+            if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
+              parsedInfoPtr->arg_int = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
+              parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+              break;
+            }
+            gotInt = 1;
+            if (infoPtr->range_set == true) {
+              if (parsedInfoPtr->arg_int < infoPtr->l_range.int_r1 || parsedInfoPtr->arg_int > infoPtr->u_range.int_r2) {
+                snprintf(buf, sizeof(buf), "value of %s is out of range %d - %d", infoPtr->key, infoPtr->l_range.int_r1,
+                         infoPtr->u_range.int_r2);
+
+                Tcl_AppendResult(interp, buf, (char *) NULL);
+                return TCL_ERROR;
+              }
+            }
+            srcIndex++;
+            argc--;
+          }
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          break;
+
+        case CLI_ARGV_STRING:
+          if (argc <= 0) {
+            Tcl_AppendResult(interp, "\"", curArg, "\" option requires an additional argument", (char *) NULL);
+            return TCL_ERROR;
+          }
+          parsedInfoPtr->arg_string = ats_strdup(argv[srcIndex]);
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          srcIndex++;
+          argc--;
+          break;
+        case CLI_ARGV_OPTION_NAME_VALUE:
+          if (argc > 0) {
+            parsedInfoPtr->arg_string = ats_strdup(argv[srcIndex]);
+          }
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          break;
+        case CLI_ARGV_FLOAT:
+          if (argc <= 0) {
+            Tcl_AppendResult(interp, "\"", curArg, "\" option requires an additional floating-point argument",
+                             (char *) NULL);
+            return TCL_ERROR;
+          }
+
+          // Solaris is messed up, in that strtod() does not honor C99/SUSv3 mode.
+          parsedInfoPtr->arg_float = strtold(argv[srcIndex], &endPtr);
+          if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
+            Tcl_AppendResult(interp, infoPtr->key, " requires floating-point argument",
+                             "\n", infoPtr->help, (char *) NULL);
+            return TCL_ERROR;
+          }
+          if (infoPtr->range_set == true) {
+            if (parsedInfoPtr->arg_float < infoPtr->l_range.float_r1 ||
+                parsedInfoPtr->arg_float > infoPtr->u_range.float_r2) {
+              snprintf(buf, sizeof(buf), "value of %s out of range %f - %f", infoPtr->key, infoPtr->l_range.float_r1,
+                       infoPtr->u_range.float_r2);
+              Tcl_AppendResult(interp, buf, (char *) NULL);
+              return TCL_ERROR;
+            }
+
+          }
+          srcIndex++;
+          argc--;
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          break;
+
+        case CLI_ARGV_OPTION_FLOAT_VALUE:
+          if (argc > 0) {
+            parsedInfoPtr->arg_float = strtold(argv[srcIndex], &endPtr);
+            if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
+              parsedInfoPtr->arg_float = CLI_DEFAULT_INT_OR_FLOAT_VALUE;
+              parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+              break;
+            }
+            if (infoPtr->range_set == true) {
+              if (parsedInfoPtr->arg_float < infoPtr->l_range.float_r1 ||
+                  parsedInfoPtr->arg_float > infoPtr->u_range.float_r2) {
+                snprintf(buf, sizeof(buf), "value of %s out of range %f - %f", infoPtr->key, infoPtr->l_range.float_r1,
+                         infoPtr->u_range.float_r2);
+                Tcl_AppendResult(interp, buf, (char *) NULL);
+                return TCL_ERROR;
+              }
+
+            }
+            srcIndex++;
+            argc--;
+          }
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          break;
+
+        case CLI_ARGV_FUNC:
+          break;
+
+        case CLI_ARGV_CONST_OPTION:
+
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          break;
+        default:
+          parsedInfoPtr->parsed_args = infoPtr->arg_ref;
+          break;
+
+
+        }
+        prevMatchPtr = infoPtr;
+      }
+      if (gotMatch == true)
+        break;
+
+    }
+    if (gotMatch == false) {
+      if (prevMatchPtr != NULL) {
+        /*if prev argument is of type CLI_ARGV_CONST_OPTION then this has to be valid
+           argument so return error */
+        if (prevMatchPtr->type == CLI_ARGV_CONST_OPTION) {
+          snprintf(buf, sizeof(buf), "unrecognized argument %s\n %s", curArg, prevMatchPtr->help);
+          Tcl_AppendResult(interp, buf, (char *) NULL);
+          return TCL_ERROR;
+        }
+
+        if ((prevPtr == prevMatchPtr) && (prevMatchPtr->type == CLI_ARGV_OPTION_FLOAT_VALUE)) {
+          Tcl_AppendResult(interp, prevMatchPtr->key, " requires floating point argument", "\n", prevMatchPtr->help,
+                           (char *) NULL);
+          return TCL_ERROR;
+        }
+
+        if ((prevPtr == prevMatchPtr) && (prevMatchPtr->type == CLI_ARGV_OPTION_INT_VALUE)) {
+          if (gotInt == 0) {
+            Tcl_AppendResult(interp, prevMatchPtr->key, " requires integer argument", "\n", prevMatchPtr->help,
+                             (char *) NULL);
+            return TCL_ERROR;
+          }
+        }
+
+
+        if (prevMatchPtr->type != CLI_ARGV_OPTION_NAME_VALUE) {
+          parsedInfoPtr->data = ats_strdup(curArg);
+          parsedInfoPtr->parsed_args = CLI_PARSED_ARGV_DATA;
+        } else
+          parsedInfoPtr--;
+
+      } else {
+        parsedInfoPtr->data = ats_strdup(curArg);
+        parsedInfoPtr->parsed_args = CLI_PARSED_ARGV_DATA;
+      }
+    }
+    prev_parsedInfoPtr = parsedInfoPtr;
+    parsedInfoPtr++;
+    prevPtr = infoPtr;
+
+  }
+  parsedInfoPtr->parsed_args = CLI_PARSED_ARGV_END;
+
+  return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * PrintUsage --
+ *
+ *	Generate a help string describing command-line options.
+ *
+ * Results:
+ *	The interp's result will be modified to hold a help string
+ *	describing all the options in argTable, plus all those
+ *	in the default table unless CLI_ARGV_NO_DEFAULTS is
+ *	specified in flags.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+static void
+PrintUsage(Tcl_Interp * /* interp ATS_UNUSED */, cli_CommandInfo * commandInfo)
+{
+  cli_ArgvInfo *infoPtr;
+  cli_ArgvInfo *argTable = commandInfo->argtable;
+  int width, numSpaces;
+
+  /*
+   * First, compute the width of the widest option key, so that we
+   * can make everything line up.
+   */
+  width = 4;
+  char *cmdHelpString = commandInfo->helpString;
+  int length = strlen(commandInfo->command_name);
+
+  if (length > width) {
+    width = length;
+  }
+
+  /* Now for arguments */
+
+  for (infoPtr = argTable; infoPtr->key != NULL; infoPtr++) {
+    length = strlen(infoPtr->key);
+    if (length > width) {
+      width = length;
+    }
+  }
+
+  // display command name
+  Cli_Printf("\n%s", commandInfo->command_name);
+  numSpaces = width + 1 - strlen(commandInfo->command_name);
+
+  while (numSpaces > 0) {
+    Cli_Printf(" ");
+    numSpaces--;
+  }
+
+  // display command help string
+  Cli_Printf("    %s", cmdHelpString);
+
+  for (infoPtr = argTable; infoPtr->key != NULL; infoPtr++) {
+    if (infoPtr->position >= 100) {
+      Cli_Printf("\n    ");
+    } else {
+      Cli_Printf("\n  ");
+    }
+
+    // display option name
+    Cli_Printf("%s", infoPtr->key);
+    numSpaces = width + 1 - strlen(infoPtr->key);
+
+    while (numSpaces > 0) {
+      Cli_Printf(" ");
+      numSpaces--;
+    }
+    // display option parameters
+    Cli_Printf("  %s", infoPtr->help);
+  }
+
+  Cli_Printf("\n\n");
+}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/775ad1dc/cmd/traffic_shell/cli_detailed_command_list.txt
----------------------------------------------------------------------
diff --git a/cmd/traffic_shell/cli_detailed_command_list.txt b/cmd/traffic_shell/cli_detailed_command_list.txt
new file mode 100644
index 0000000..54b2776
--- /dev/null
+++ b/cmd/traffic_shell/cli_detailed_command_list.txt
@@ -0,0 +1,1623 @@
+FEATURE INTRODUCTION
+
+Feature name:
+
+	traffic_shell
+
+Synopsis of Feature:
+
+	traffic_shell is a true "command line interface."  It accepts
+commands in a unix shell-like fashion.  traffic_shell supports command
+completion, command history, man pages, and context sensitive help.
+Not only is this type of interface more familiar to network engineers
+everywhere, but it is also easier to document, maintain, and extend.
+	traffic_shell is TCL-based which simplifies the development of new
+commands.  It also supports scripting which means that a user can
+source and execute a file that contains traffic_shell commands. 
+	traffic_shell currently provides full configuration and monitoring
+functionality for Traffic Server. 
+	traffic_shell is built on the same Management API as the
+Traffic Server WebUI.  The Management API (written in C code) handles
+updating config files and restarting TS or reloading config variables
+for changes to take effect. 
+ 
+Configurations of Traffic Server affected:
+
+	Platforms: Linux, Linux for OEMs, Solaris SPARC
+	Configurations: All TS configurations
+
+References on Feature:
+
+	Scroll down to the section of this document titled:
+	  COMPLETE COMMAND SET SPECIFICATION
+        This section contains an exhaustive list of all traffic_shell
+	commands, along with a description of syntax and sample output.
+
+ENGINEERING DESCRIPTION
+
+Modes of operation of Feature:
+
+	No special records.config setup is required.
+
+	The CLI supports the following operation modes.  Note that a
+	"user" can be a person, a script, or some other mechanism for remote
+	control of network devices via command line interface.
+
+   -- Interactive:
+         "traffic_shell"
+         Similar to unix shell, CLI can be the login shell for administrators.
+         User types command at a prompt.
+         CLI processes command and displays the result.
+         User can execute a file which contains a list of commands.
+
+   -- Execute file:
+         "traffic_shell -f filename" where file contains a list of CLI commands.
+         CLI runs commands and sends results to stdout.
+    
+	When entered at the Unix shell prompt, the "traffic_shell -f
+filename" command starts traffic_shell and runs a TCL script
+"filename" which typically contains traffic_shell commands.  Since
+traffic_shell is a TCL interpreter, the script can also contain any
+valid combination of TCL constructs.  If the TCL interpreter
+encounters the "exit" keyword, then control returns to the shell from
+which the user typed "traffic_shell -f <filename>".  If the
+interpreter reaches the end of script execution without encountering
+"exit", then the traffic_shell prompt appears and the user can
+continue to use traffic_shell interactively.
+
+Risk points of feature:
+
+	Certain configuration changes force a reset of Traffic
+	Server.  These restarts are performed by functions in the
+	Management API. 
+
+Effect on SDK/API:
+
+	None.  In the future, traffic_shell may be enhanced to provide
+	configurability of certain plugins.
+
+Module tests, diagnostic output, and statistics on feature
+
+	None.
+
+Engineering description of Feature:
+
+	The CLI is a standalone executable that is part of a Traffic
+	Server installation.  
+
+	The CLI is implemented in a combination of TCL and C++.  The
+	shell and parsing functionality uses TCL.  Commands themselves are
+	typically written in C++.  The CLI uses the traffic_manager Management
+	API to make Traffic Server configuration changes.
+
+ The overall CLI architecture is as follows:
+
+  - traffic_shell ---------------------------
+ |                                           |
+ |  ---------------------------------------  |
+ |  Shell and parser implemented in TCL/C++  |
+ |  ---------------------------------------  |
+ |                  ^                        |
+ |  ----------------|-------------------     |
+ |  CLI commands implemented in C++ (.a)     |
+ |  ------------------------------------     |
+ |                  ^                        |
+ |          --------|----------              |
+ |          Management API (.a)              |
+ |          -------------------              |
+ |                                           |
+  -------------------------------------------
+
+Notes and comments by developing engineer:
+
+	None.
+
+TESTS DESCRIPTIONS
+
+Test description:
+
+	QA developed expect scripts for each traffic_shell command to
+	simulate commands from user level, and also to check the output
+	of CLI.
+
+	Each script covers one command along with all of its
+	sub-commands and arguments. 
+
+  Each Config Command script has a flow as follows:
+  - Valid test:
+    . Send valid syntax command to CLI.
+    . Check the value of affected variable from either the CLI or 
+      from traffic_line -r <variable>.
+    . Set errors if the output of CLI does not match expected result.
+  - Negative test:
+    . Send commands with invalid arguments to CLI.
+    . CLI should handled unregconized arguments gracefully.
+    . Set error if CLI does not handle invalid arguments correctly.
+
+  Same logic flow for Show commands.
+
+
+   To run the test scripts:
+   ----------------------------
+   There are two files:
+	cli-config-tests.tar for config commands.
+	cli-show-tests.tar for show commands.
+
+Copy these files into a "cli" subdirectory of the traffic_server "bin"
+directory, and untar them.  Start traffic_server and run scripts
+within cli directory.
+
+- For Config, run cli-test.exp + <individual test>
+
+  For example:
+  cli% ./cli-test.exp config-name 
+  This will test config:name command
+      
+- For Show, run show-test.exp + <individual test>
+
+Test development notes:
+
+- These scripts are by no means complete.  Anyone can add more testcases 
+in by copying/modifying existing testcases. These tests are pretty primitive
+for now. 
+
+- When running tests, please make sure you enlarge your terminal as large as
+possible to accomodate the CLI output. The EOL character might affect string
+comparision in expect.
+
+- Some of variables are set to random values. So please be sure to save your
+config directory or install new traffic server after you complete CLI test :-)
+This will be make better in the future.
+
+*******************************************************
+COMPLETE COMMAND SET SPECIFICATION
+*******************************************************
+
+
+
+traffic_shell command set specification
+
+NOTE: This document does not distinguish phase-1 commands and functionality.
+
+There may be some inconsistencies between the command descriptions and the 
+actual implementation.  In particular, column alignment is not exactly specified 
+in this document.  Also, the values below are for example purposes only.
+
+==============
+CLI Features
+==============
+
+   1) CLI supports command completion i.e if the user types first one
+   or two characters of a valid command and presses tab key it completes
+   the command.
+
+   2) CLI supports command abbreviation i.e if user types first one or two
+   characters of a valid command and presses enter CLI will display all
+   the commands whic start with the abbreviation typed by user If there
+   is only one command matching the command abbreviation CLI directly
+   executes the command.
+
+   3) CLI supports history command which shows the history of previously
+   typed commands.
+
+   4) CLI supports up and down arrow keys to see through previous
+   commands.
+
+   5) All CLI commands can be classified in two catogories Show commands
+   and Config commands.  Show Commands display system information. Show
+   Commands can be executed in normal mode.  A list of possible show
+   commands described below can be seen by just typing show on command
+   line.
+
+   6) Config commands let the user configure or set system information
+   and settings Config commands can be executed in  privileged mode
+   enabled by admin password.  A list of possible  config commands
+   described below can be seen by just typing config on command line.
+
+
+================
+Command Overview
+================
+
+Normal mode commands
+  % prompt
+----------------------------
+
+enable		Enable privileged commands
+  Prompt for password.  Password can be blank.
+  syntax: enable
+  args:   none
+
+  ts> enable
+  Password: (no characters displayed)
+  ts#
+
+exit		Exit CLI
+  syntax: exit
+  args:   none
+
+  ts> exit
+
+help		Help
+  Display list of commands with one line description.
+  Or display help for a particular subcommand.
+  syntax: help [ subcommand ]
+  args:   subcommand (optional)
+
+show		Show system information
+
+  See "Show Command" below for list of subcommands.
+  syntax: show:< show-sub-command >
+  args:   show-sub-command = optional subcommand
+  behavior:  If show-sub-command is ommitted, then display the list of
+             possible show-sub-commands.
+
+Enable mode commands
+  includes all Normal mode commands
+  # prompt
+----------------------------
+
+config		Enter configuration mode
+  See "Configure Command" below for list of subcommands.
+  syntax: config:< config-sub-command >
+  args:   config-sub-command = optional subcommand
+  behavior:  If config-sub-command is ommitted, then display the list of
+             possible config-sub-commands.
+
+disable		Disable privileged commands
+  No parameters.  Puts CLI back into Normal Mode.
+  syntax: disable
+  args:   none
+  behavior:  Switch to Normal Mode.
+
+  ts# disable
+  ts>
+
+exit		Exit CLI
+  syntax: exit
+  args:   none
+
+help		Help
+  Same as Normal Mode but includes Configure Command.
+  Display list of commands with one line description.
+  Or display help for a particular subcommand.
+  syntax: help [ subcommand ]
+  args:   subcommand (optional)
+  
+show		Show system information
+  Same as Normal Mode but includes privileged commands.
+  See "Show Command" below for list of subcommands.
+  syntax: show:< show-sub-command >
+  args:   show-sub-command = optional subcommand
+  behavior:  If show-sub-command is ommitted, then display the list of
+             possible show-sub-commands.
+
+
+Show command
+------------
+Parameter		Description
+-----------------------------------
+status			Proxy status on/off
+  syntax: show:status
+  args:   none
+  behavior:  Display status as follows:
+
+    ts> show:status
+    Proxy -- on
+    ts>
+
+  implementation: Determine whether proxy is up and running.
+
+version			Traffic Server and Traffic Manager version
+  syntax: show:version
+  args:   none
+  behavior:  Display Traffic_Server and Traffic Manager version number as follows:
+
+    ts> show:version
+    traffic_server version --- 5.0.0
+    traffic_manager version -- 5.0.0
+    ts>
+
+security		Security Configuration (only in Enable Mode)
+			(TS IP allow, MGMT allow, Login allow)
+
+  syntax: show:security
+  args:   none
+  behavior:  Display IP address access lists for TS, MGMT, and login.
+
+    ts> show:security
+
+    Traffic Server Access
+    (ip_allow.config contents)
+
+    ts>
+
+  implementation:
+    Traffic Server Access specified in ip_allow.config (use MGMT API)
+
+cluster                Cluster Configuration
+
+   syntax: show:cluster
+   args:   none
+   behavior: Display cluster port
+
+  ts> show:cluster
+ 
+      Cluster Port ----------- 14988 (proxy.config.cluster.cluster_port)
+      Cluster RS Port -------- 14990 (proxy.config.cluster.rsport)
+      Cluster MC Port -------- 14991 (proxy.config.cluster.mcport)
+
+http			HTTP Configuration
+			(timeout values, headers, authorization)
+
+  syntax: show:http
+  args:   none
+  behavior:  Display HTTP Configuration
+
+    ts> show:http
+    HTTP Caching ------------------ on      (proxy.config.http.cache.http)
+    HTTP Server Port -------------- 14980   (proxy.config.http.server_port)
+
+    Keep-Alive Timeout Inbound ---- 10 s    (proxy.config.http.keep_alive_no_activity_timeout_in)
+    Keep-Alive Timeout Outbound --- 10 s    (proxy.config.http.keep_alive_no_activity_timeout_out)
+    Inactivity Timeout Inbound ---- 120 s   (proxy.config.http.transaction_no_activity_timeout_in)
+    Inactivity Timeout Outbound --- 120 s   (proxy.config.http.transaction_no_activity_timeout_out)
+    Activity Timeout Inbound ------ 7200 s  (proxy.config.http.transaction_active_timeout_in)
+    Activity Timeout Outbound ----- 7200 s  (proxy.config.http.transaction_active_timeout_out)
+    Maximum Number of Alternates -- 3       (proxy.config.cache.limits.http.max_alts)
+    Remove the following common headers
+      From         (proxy.config.http.anonymize_remove_from)
+      Referer      (proxy.config.http.anonymize_remove_referer)
+      User-Agent   (proxy.config.http.anonymize_remove_user_agent)
+      Cookie       (proxy.config.http.anonymize_remove_cookie)
+    Remove additional headers
+      list         (proxy.config.http.anonymize_other_header_list)
+    Insert or Remove Client IP address
+      Insert       (proxy.config.http.anonymize_insert_client_ip)
+      Remove       (proxy.config.http.anonymize_remove_client_ip)
+    ts>
+    
+icp			ICP Configuration
+			(on/off, rules, port, timeouts)
+  syntax: show:icp [ peers ]
+  args:   optional "peers" argument
+  behavior:  Display ICP Configuration
+
+  ts> show:icp
+  ICP Mode --------------- off   (proxy.config.icp.enabled)
+  ICP Port --------------- 3130  (proxy.config.icp.icp_port)
+  ICP Multicast Enabled -- off   (proxy.config.icp.multicast_enabled)
+  ICP Query Timeout ------ 2 s   (proxy.config.icp.query_timeout)
+  ts>
+
+  ts> show:icp peers
+  icp.config rules
+  ----------------
+  (Display rules from icp.config)
+  ts>
+
+proxy			Proxy Configuration
+
+  syntax: show:proxy
+  args:   none
+  behavior:  Display basic proxy configuration
+
+  ts> show:proxy
+  Name -- foo         (proxy.config.proxy_name)
+  ts>
+
+cache			Cache Configuration
+			(active protocols, bypass, storage, freshness, 
+			expires, variable content, rules)
+  syntax: show:cache [ rules | storage ]
+  args:   optional "rules" or "storage"
+
+  ts> show:cache
+  HTTP Caching ------------------- on    (proxy.config.http.cache.http)
+  Ignore User Requests To Bypass Cluster --- off  (proxy.config.http.cache.cluster_cache_local)
+  Ignore User Requests To Bypass Cache --- off  (proxy.config.http.cache.ignore_client_no_cache)
+  Maximum HTTP Object Size --- NONE        (proxy.config.cache.max_doc_size)
+
+  Freshness
+    Verify Freshness By Checking --   (proxy.config.http.cache.when_to_revalidate)
+      When the object has expired
+    Minimum freshness information for a document to be cacheable --  (proxy.config.http.cache.required_headers)
+      Nothing
+    If object has no expiration date:
+      leave it in cache for at least ---- 3600 s   (proxy.config.http.cache.heuristic_min_lifetime)
+      but no more than ------------------ 86400 s  (proxy.config.http.cache.heuristic_max_lifetime)
+
+  Variable Content
+    Do not cache responses to URLs that contain "?", ";", "cgi" or end in ".asp"  (proxy.config.http.cache.cache_urls_that_look_dynamic value)
+    Alternates ------------ on    (proxy.config.http.cache.enable_default_vary_headers)
+    Vary on HTTP Header Fields:
+      Text ---------------- Cookie  (proxy.config.http.cache.vary_default_text)
+      Images -------------- NULL    (proxy.config.http.cache.vary_default_images)
+      Other --------------- NULL    (proxy.config.http.cache.vary_default_other)
+    Cache responses to requests containing cookies for:  (proxy.config.http.cache.cache_responses_to_cookies)
+      content-types which are not text
+  ts>
+
+  ts> show:cache rules
+  Display rules from cache.config
+  ts>
+
+  ts> show:cache storage
+  Display rules from storage.config
+  ts>
+
+virtual-ip		Virtual IP Address Configuration
+  syntax: show:virtual-ip
+  args:   none
+  behavior:  Display virtual IP configuration
+
+
+  ts_shell>show:virtual-ip 
+
+  2 Elements in Record
+
+  0 1.1.1.1 23 23
+  1 1.1.1.1 23 24
+
+  ts>
+
+
+hostdb			Host Database Configuration
+  syntax: show:hostdb
+  args:   none
+  behavior:  Display Host DB Configuration
+
+  ts> show:hostdb
+  Lookup Timeout ----------- 120 s   (proxy.config.hostdb.lookup_timeout)
+  Foreground Timeout ------- 1440 s  (proxy.config.hostdb.timeout)
+  Background Timeout ------- 720 s   (proxy.config.hostdb.verify_after)
+  Invalid Host Timeout ----- 0 s     (proxy.config.hostdb.fail.timeout)
+  Re-DNS on Reload --------- off     (proxy.config.hostdb.re_dns_on_reload)
+  Resolve Attempt Timeout -- 20 s    (proxy.config.dns.lookup_timeout)
+  Number of Retries -------- 5       (proxy.config.dns.retries)
+  ts>
+
+dns-resolver		DNS Resolver Configuration
+  syntax: show:dns-resolver
+  args:   none
+  behavior:  Display DNS Resolver Configuration
+
+  ts> show:dns-resolver
+  Local Domain Expansion -- on   (proxy.config.dns.search_default_domains)
+  .com Domain Expansion --- on   (proxy.config.http.enable_url_expandomatic)
+  ts>
+
+logging			Logging Configuration
+  syntax: show:logging
+  args: none
+  behavior:  Display Logging Configuration
+
+  ts> show:logging
+  Logging Mode ------------- xxx       (proxy.config.log.logging_enabled)
+
+  Management  
+    Log Space Limit -------- 2000 MB  (proxy.config.log.max_space_mb_for_logs)
+    Log Space Headroom ----- 10 MB    (proxy.config.log.max_space_mb_headroom)
+
+  Log Collation ------------ off      (proxy.local.log.collation_mode)
+    Host ------------------- NULL     (proxy.config.log.collation_host)
+    Port ------------------- 8085     (proxy.config.log.collation_port)
+    Secret ----------------- foobar   (proxy.config.log.collation_secret)
+    Host Tagged ------------ off      (proxy.config.log.collation_host_tagged)
+    Space Limit for Orphan Files -- 25 MB   (proxy.config.log.max_space_mb_for_orphan_logs)
+
+  Squid Format ---- on             (proxy.config.log.squid_log_enabled)
+    File Type ----- ASCII          (proxy.config.log.squid_log_is_ascii)
+    File Name ----- squid          (proxy.config.log.squid_log_name)
+    File Header --- NULL           (proxy.config.log.squid_log_header)
+
+  Netscape Common -- off         (proxy.config.log.common_log_enabled)
+    File Type ------ ASCII       (proxy.config.log.common_log_is_ascii)
+    File Name ------ common      (proxy.config.log.common_log_name)
+    File Header ---- NULL        (proxy.config.log.common_log_header)
+
+  Netscape Extended -- off       (proxy.config.log.extended_log_enabled)
+    File Type -------- ASCII     (proxy.config.log.extended_log_is_ascii)
+    File Name -------- extended  (proxy.config.log.extended_log_name)
+    File Header ------ NULL      (proxy.config.log.extended_log_header)
+
+  Netscape Extended2 -- off       (proxy.config.log.extended2_log_enabled)
+    File Type --------- ASCII     (proxy.config.log.extended2_log_is_ascii)
+    File Name --------- extended2 (proxy.config.log.extended2_log_name)
+    File Header ------- NULL      (proxy.config.log.extended2_log_header)
+
+  Splitting
+    ICP Log Splitting -- off        (proxy.config.log.separate_icp_logs)
+    HTTP Host Log Splitting -- off  (proxy.config.log.separate_host_logs)
+
+  Custom Logs -- off              (proxy.config.log.custom_logs_enabled)
+
+  Rolling -------- on               (proxy.config.log.rolling_enabled)
+    Roll Offset Hour --- 0          (proxy.config.log.rolling_offset_hr)
+    Roll Interval ------ 86400 s               (proxy.config.log.rolling_interval_sec)
+  Auto-delete rolled files when space is low -- on  (proxy.config.log.auto_delete_rolled_files)
+  ts>
+
+ssl			SSL Ports
+  syntax: show:ssl
+  args:   none
+  behavior:  Display SSL Port related configuration.
+
+  ts> show:ssl
+  Restrict CONNECT connections to Ports -- 443 563   (proxy.config.http.connect_ports)
+  ts>
+
+parent			Parent Configuration
+			(on/off, parents, rules)
+  syntax: show:parent
+  args:   none
+  behavior:  Display Parent Configuration.
+
+  ts> show:parent
+  Parent Caching: OFF    (proxy.config.http.parent_proxy_routing_enable)
+  Parent Cache:   NONE   (proxy.config.http.parent_proxies)
+  ts>
+
+  syntax: show:parent rules
+  behavior: Display Parent configuration rules file.
+
+  ts> show:parent rules
+  parent.config rules
+  -------------------
+  Display rules from parent.config
+  ts>
+
+remap			Remap Rules
+  syntax: show:remap
+  args:   none
+  behavior:  Display remap configuration.
+
+  ts> show:remap
+  remap.config rules
+  ------------------
+  (Display rules from remap.config)
+  ts>
+
+socks			SOCKS Configuration
+			(on/off, stats)
+  syntax: show:socks [ rules ]
+  args:   none
+  behavior:  Display SOCKS Configuration.
+
+  ts> show:socks
+  SOCKS -------------------- off      (proxy.config.socks.socks_needed)
+  SOCKS Default Servers ---- x.x.x.x  (proxy.config.socks.default_servers)
+  SOCKS Accept Port -------- 1080     (proxy.config.socks.accept_port)
+  SOCKS HTTP Port ---------- 80       (proxy.config.socks.http_port)
+  SOCKS Timeout ------------ 100 s    (proxy.config.socks.socks_timeout)
+  ts>
+
+  ts> show:socks rules
+  socks.config rules
+  ------------------
+  (Display socks.config rules)
+  ts>
+
+port-tunnels		Port Tunnelling Configuration
+
+  syntax: show:port-tunnels 
+
+  ts# show:port-tunnels
+ 
+  server-other-ports -- 7890
+  
+  To view the corresponding rule of the remap.config file in the following format
+      map tunnel://<proxy_ip>:<port_num>/tunnel://<dest_server>:<dest_port>
+      Use show:remap
+
+scheduled-update        Scheduled Update Configuration
+  syntax: show:scheduled-update [ rules ]
+  args:   show update.config file
+  behavior:  Display Scheduled Update Configuration.
+
+  ts> show:scheduled-update
+  Scheduled Update -------------- on   (proxy.config.update.enabled)
+  Update Error Retry Count ------ 10   (proxy.config.update.retry_count)
+  Update Error Retry Interval --- 2 s  (proxy.config.update.retry_interval)
+  Maximum Concurrent Updates ---- 100  (proxy.config.update.concurrent_updates)
+  Force Immediate Update -------- off  (proxy.config.update.force)
+  ts>
+
+  ts> show:scheduled-update rules
+  update.config rules
+  ------------------- 
+  (Display list of rules from update.config)
+  ts>
+
+
+Status subcommands
+------------------
+Parameter		Description
+-----------------------------------
+proxy-stats		Proxy Vital Stats 
+			oldCLI->root->monitor->node
+			(hit rate, bandwidth savings, open connections)
+  syntax: show:proxy-stats
+  args:   none
+  behavior:  Display statistics related to the overall proxy.
+
+  ts> show:proxy-stats
+  Document Hit Rate ------------ 0% *    (proxy.node.cache_hit_ratio)
+  Bandwidth Savings ------------ 0% *    (proxy.node.bandwidth_hit_ratio)
+  Cache Percent Free ----------- 0%      (proxy.node.cache.percent_free)
+
+  Open Server Connections ------ 0       (proxy.node.current_server_connections)
+  Open Client Connections ------ 0       (proxy.node.current_client_connections)
+  Cache Transfers In Progress -- 0       (proxy.node.current_cache_connections)
+
+  Client Throughput ------------ 0.00 MBit/Sec  (proxy.node.client_throughput_out)
+  Transactions Per Second ------ 0       (proxy.node.user_agent_xacts_per_second)
+
+  * Value represents 10 second average.
+  ts>
+
+http-trans-stats	HTTP Transaction Summary
+			(hits, misses, aborts, other)
+			oldCLI->root->monitor->protocols->http-trans
+  syntax: show:http-trans-state
+  args:   none
+  behavior:  Display statistics related to HTTP transactions.
+
+  ts> show:http-trans-stats
+  HTTP Transaction Frequency and Speeds     (proxy.node.http.transaction_*)
+  Transaction Type              Frequency  Speed (ms)
+  --Hits--
+  Fresh ----------------------- 0%         0    (frac_avg_10s.hit_fresh, 
+                                                 msec_avg_10s.hit_fresh)
+  Stale Revalidated ----------- 0%         0    (frac_avg_10s.hit_revalidated, 
+                                                 msec_avg_10s.hit_revalidated)
+  --Misses--
+  Now Cached ------------------ 0%         0    (frac_avg_10s.miss_cold, 
+                                                 msec_avg_10s.miss_cold)
+  Server No Cache ------------- 0%         0    (frac_avg_10s.miss_not_cacheable, 
+                                                 msec_avg_10s.miss_not_cacheable)
+  Stale Reloaded -------------- 0%         0    (frac_avg_10s.miss_changed, 
+                                                 msec_avg_10s.miss_changed)
+  Client No Cache ------------- 0%         0    (frac_avg_10s.miss_client_no_cache, 
+                                                 msec_avg_10s.miss_client_no_cache)
+  --Errors--
+  Connection Failures --------- 0%         0    (frac_avg_10s.errors.connect_failed,
+                                                 msec_avg_10s.errors.connect_failed)
+  Other Errors ---------------- 0%         0    (frac_avg_10s.errors.other,
+                                                 msec_avg_10s.errors.other)
+  --Aborted Transactions--
+  Client Aborts --------------- 0%         0    (frac_avg_10s.errors.aborts,
+                                                 msec_avg_10s.errors.aborts)
+  Questionable Client Aborts -- 0%         0    (frac_avg_10s.errors.possible_aborts,
+                                                 msec_avg_10s.errors.possible_aborts)
+  Partial Request Hangups ----- 0%         0    (frac_avg_10s.errors.early_hangups,
+                                                 msec_avg_10s.errors.early_hangups)
+  Pre-Request Hangups --------- 0%         0    (frac_avg_10s.errors.empty_hangups,
+                                                 msec_avg_10s.errors.empty_hangups)
+  Pre-Connect Hangups --------- 0%         0    (frac_avg_10s.errors.pre_accept_hangups,
+                                                 msec_avg_10s.errors.pre_accept_hangups)
+  --Other Transactions--
+  Unclassified ---------------- 0%         0    (frac_avg_10s.other.unclassified,
+                                                 msec_avg_10s.other.unclassified)  
+  ts>
+
+http-stats		HTTP Protocol Summary
+			oldCLI->root->monitor->protocols->http
+  syntax: show:http-stats
+  args:   none
+  behavior:  Display HTTP Protocol statistics.
+
+  ts> show:http-stats
+  --Client--                          (proxy.process.http.*)
+  Total Document Bytes ------ 150.5 MB  (user_agent_response_document_total_size)
+  Total Header Bytes -------- 23.5 MB   (user_agent_response_header_total_size)
+  Total Connections --------- 0         (current_client_connections)
+  Transactions In Progress -- 0         (current_client_transactions)
+  --Server--
+  Total Document Bytes ------ 150.4 MB  (origin_server_response_document_total_size)
+  Total Header Bytes -------- 16.3 MB   (origin_server_response_header_total_size)
+  Total Connections --------- 0         (current_server_connections)
+  Transactions In Progress -- 0         (current_server_transactions)
+  ts>
+
+icp-stats		ICP Statistics
+  syntax: show:icp-stats
+  args:   none
+  behavior:  Display ICP statistics.
+
+  ts> show:icp-stats
+  --Queries Originating From This Node--      (proxy.process.icp.*)
+  Query Requests ------------------------------ 0    (icp_query_requests)
+  Query Messages Sent ------------------------- 0    (total_udp_send_queries)
+  Peer Hit Messages Received ------------------ 0    (icp_query_hits)
+  Peer Miss Messages Received ----------------- 0    (icp_query_misses)
+  Total Responses Received -------------------- 0    (icp_remote_responses)
+  Average ICP Message Response Time ----------- 0.00 ms (total_icp_response_time)
+  Average ICP Request Time -------------------- 0.00 ms (total_icp_request_time)
+  --Queries Originating from ICP Peers--
+  Query Messages Received --------------------- 0    (icp_remote_query_requests)
+  Remote Query Hits --------------------------- 0    (cache_lookup_success)
+  Remote Query Misses ------------------------- 0    (cache_lookup_fail)
+  Successful Response Messages Sent to Peers -- 0  (query_response_write)
+  ts>
+
+cache-stats		Overall Cache Statistics
+			oldCLI->root->monitor->cache
+  syntax: show:cache-stats
+  args:   none
+  behavior:  Display overall cache statistics.
+
+  ts> show:cache-stats     (proxy.process.cache.*)
+  Bytes Used --- 42.3 GB     (bytes_used)
+  Cache Size --- 42.4 GB     (bytes_total)
+  --RAM Cache--
+  Bytes -------- 45443072  (ram_cache.bytes)
+  Hits --------- 31339939  (ram_cache.hits)
+  Misses ------- 18382137  (ram_cache.misses)
+  --Lookups--
+  In Progress -- 0           (lookup.active)
+  Hits --------- 0           (lookup.success)
+  Misses ------- 0           (lookup.failure)
+  --Reads--
+  In Progress -- 0           (read.active)
+  Hits --------- 30116923  (read.success)
+  Misses ------- 26817128  (read.failure)
+  --Writes--
+  In Progress -- 1           (write.active)
+  Successes ---- 25354918  (write.success)
+  Failures ----- 75520      (write.failure)
+  --Updates--
+  In Progress -- 0           (update.active)
+  Successes ---- 101888     (update.success)
+  Failures ----- 1753       (update.failure)
+  --Removes--
+  In Progress -- 0           (remove.active)
+  Successes ---- 0           (remove.success)
+  Failures ----- 0           (remove.failure)
+  ts>
+
+hostdb-stats		Host Database Statistics
+  syntax: show:hostdb-stats
+  args:   none
+  behavior:  Display Host Database statistics.
+
+  ts> show:hostdb-stats
+  Host Database Hit Rate -- 100% *  (proxy.node.hostdb.hit_ratio)
+  DNS Lookups Per Second -- 0.00    (proxy.node.dns.lookups_per_second)
+
+  *Value represents 10 second average.
+  ts>
+
+dns-stats		DNS Statistics
+  syntax: show:dns-stats
+  args:   none
+  behavior:  Display DNS statistics.
+
+  ts> show:dns-stats
+  DNS Lookups Per Second -- 0.00    (proxy.node.dns.lookups_per_second)
+  ts>
+
+logging-stats		Logging Statistics
+  syntax: show:logging-stats
+  args:   none
+  behavior:  Display Logging statistics.
+
+  ts> show:logging-stats
+  Currently Open Log Files --------- 0       (proxy.process.log.log_files_open)
+  Space Used For Log Files --------- 0       (proxy.process.log.log_files_space_used)
+  Number of Access Events Logged --- 0       (proxy.process.log.event_log_access)
+  Number of Access Events Skipped -- 0       (proxy.process.log.event_log_access_skip)
+  Number of Error Events Logged ---- 0       (proxy.process.log.event_log_error)
+  ts>
+
+network                Network Settings
+   syntax:  show:network
+   args:    none
+   behavior:  Display information about different Network Parameters
+
+   traffic_shell> show:network 
+
+   Hostname ---------------- foo.example.com
+   Default Gateway --------- 192.168.0.1
+   Search Domain ----------- example.com
+   DNS IP Addresses--------- 192.168.0.2
+
+   NIC eth0
+     Status ---------------- up
+     Start on Boot --------- onboot
+     Start Protocol -------- none
+     IP Address ------------ 192.168.0.10
+     Netmask --------------- 255.255.255.0
+     Gateway --------------- default
+
+   NIC eth1
+     Status ---------------- up
+     Start on Boot --------- onboot
+     Start Protocol -------- none
+     IP Address ------------ 192.168.0.11
+     Netmask --------------- 255.255.255.0
+     Gateway --------------- default
+
+   traffic_shell> 
+
+
+Configure submodes (from Enable mode)
+
+Some config commands require hard restart or restart for changes to take effect.
+In these cases, one of the following messages will appear onscreen.
+
+Restart required.
+  Change will take effect after next Restart.
+  Use the "config:restart" command to restart now.
+
+Hard Restart required.
+  Change will take effect after next Hard Restart.
+  Use the "config:hard-restart" command to restart now.
+
+-------------------------------------
+Parameter		Description
+-----------------------------------
+get			Get records.config variable value
+  syntax: config:get <variable>
+  args:   <variable> = variable from records.config
+  behavior:  Retrieve and display the variable from records.config.
+
+  ts# config:get proxy.config.http.server_port
+  proxy.config.http.server_port = 8080
+  ts#
+
+set			Set records.config variable value
+  syntax: config:set <variable> <value>
+  args:   <variable> = variable from records.config
+          <value> = value of variable
+  behavior:  Set the variable from records.config to the specified value.
+
+  ts# config:set proxy.config.http.server_port 8080
+  +OK
+  ts#
+
+name			Proxy Name
+  syntax: config:name <proxyname>
+  args:   <proxyname> = name of proxy
+  behavior:  Set proxyname to <proxyname>
+
+  ts# config:name config1
+  +OK
+  ts#
+
+  ts# config:name
+  config1
+  ts#
+
+start			Start Proxy Software
+  syntax: config:start
+  args:   none
+  behavior:  Run start_traffic_server.
+
+  ts# config:start
+  +OK
+  ts#
+
+stop			Stop Proxy Software
+  syntax: config:stop
+  args:   none
+  behavior:  Run stop_traffic_server.
+
+  ts# config:stop
+  +OK
+  ts#
+
+write			Write Upgrade File (IFC file)
+  syntax: config:write ifc-head ts-version <ts_version> build-date <date> platform <platform> nodes <no_of_nodes> 
+	  config:write feature <feature-string>
+	  config:write tar <tarfilelist>
+	  config:write tar-info <tarball-name> filelist <filelist>
+	  config:write tar-common <filelist>
+	  config:write bin-dir <dir-file-lists> 
+	  config:write bin-group <filelist>
+	  config:write bin-common <filelist>
+	  config:write lib-dir <dir-file-lists>
+	  config:write lib-group <filelist>
+	  config:write lib-common <filelist> 
+	  config:write config-dir <dir-file-filelists>
+	  config:write config-group <filelist>
+	  config:write config-common <filelist>
+	  config:write common <filelist>
+  args: 
+	<ts_version> = <int>.<int>.<int>
+	<date> = <mm>:<dd>:<yy>
+	<platform> = <string>
+	<no_of_nodes> = -1 (default) | 0 (single node) | n (n+1 nodes)
+	<feature-string> = <string>
+        <filelists> = list of files, separated by ,
+	<dir-file-filelists> =  list of subdirectory, followed by filelists in each subdirectory. Subdirectories are separated by ; and file lists are separated by ,
+	
+behavior: Write the text IFC file according to the current install status.
+
+
+read			Read Update File
+  syntax: config:read path <path> file <filename> 
+  args: <path> = <string>
+	<filename> = <string>
+
+behavior: Read the upgrade file and display it. For debugging purpose only.
+	
+reset-stats		Reset Statistics
+  syntax: config:reset-stats
+  args:   none
+  behavior:  Reset all statistics.
+
+  ts# config:reset-stats
+  +OK
+  ts#
+
+http			HTTP Configuration
+			(timeout values, headers, authorization)
+  syntax: config:http status <on | off>
+  record: (proxy.config.http.cache.http)
+    
+    ts# config:http status on
+    ts#
+
+  syntax: config:http <timeout> <seconds>
+  args:   <timeout> can be one of the following
+          keep-alive-timeout-in    (proxy.config.http.keep_alive_no_activity_timeout_in)
+          keep-alive-timeout-out   (proxy.config.http.keep_alive_no_activity_timeout_out)
+          inactive-timeout-in      (proxy.config.http.transaction_no_activity_timeout_in)
+          inactive-timeout-out     (proxy.config.http.transaction_no_activity_timeout_out)
+          active-timeout-in        (proxy.config.http.transaction_active_timeout_in)
+          active-timeout-out       (proxy.config.http.transaction_active_timeout_out)
+
+    ts# config:http keep-alive-timeout-in 10
+    ts#
+          
+  syntax: config:http <remove-from | remove-referer | remove-user | remove-cookie> <on | off>
+  behavior: remove the specified header
+  args:   <remove-from>            (proxy.config.http.anonymize_remove_from)
+          <remove-referer>         (proxy.config.http.anonymize_remove_referer)
+          <remove-user>            (proxy.config.http.anonymize_remove_user_agent)
+          (remove-cookie>          (proxy.config.http.anonymize_remove_cookie)
+
+    ts# config:http remove-from on
+    ts#
+
+  syntax: config:http remove-header <headers>
+  behavior: remove headers specified in list of headers
+  args:     <headers>              (proxy.config.http.anonymize_other_header_list)
+
+    ts# config:http remove-header "field1 field2"
+    ts#
+
+  syntax: config:http <insert-ip | remove-ip> <on | off>
+  behavior: insert or remove client IP from header
+  args:     <insert-ip>            (proxy.config.http.anonymize_insert_client_ip)
+            <remove-ip>            (proxy.config.http.anonymize_remove_client_ip)
+
+  syntax: config:http proxy <fwd | rev | fwd-rev>
+  behavior: enable http proxying in fwd/rev/fwd-rev modes
+
+    ts# config:http proxy
+    fwd
+    ts# config:http proxy rev
+    ts#
+
+
+ssl			SSL Configuration
+                        (on,off,port)
+  syntax: config:ssl status <on | off>
+  record: (proxy.config.ssl.enabled)
+
+    ts# config:ssl status on
+    ts# config:ssl status off
+
+  syntax: config:ssl port <portnum>
+  record: (proxy.config.ssl.server_port)
+    
+    ts# config:ssl port 1234
+    ts#
+   
+
+icp			ICP Configuration
+			(on/off, rules, port, timeouts)
+  syntax: config:icp mode <receive | send-receive | disabled>
+  record: (proxy.config.icp.enabled value)
+          receive = 1, send-receive = 2, disabled = 0
+
+    ts# config:icp mode receive
+    ts#
+
+  syntax: config:icp port <portnum>
+  record: (proxy.config.icp.icp_port)
+
+    ts# config:icp port 3130
+    ts#
+
+  syntax: config:icp multicast <on | off>
+  record: (proxy.config.icp.multicast_enabled)
+  
+    ts# config:icp multicast on
+    ts#
+
+  syntax: config:icp query-timeout <seconds>
+  record: (proxy.config.icp.query_timeout)
+  
+    ts# config:icp query-timeout 2
+    ts#
+
+  syntax: config:icp peers <url>
+  behavior: Retrieve icp.config file from URL.
+
+    ts# config:icp peers http://example.com/icp.config
+    ts#
+
+cache			Cache Configuration
+			(active protocols, bypass, storage, freshness, 
+                         expires, variable content, rules, clear)
+  syntax: config:cache <protocol> <on | off>
+  args:   <protocol> = <http>
+          <on | off> specifies the given protocol is cached
+  behavior:  Enable/Disable caching of various protocols.
+
+    ts# config:cache http on      (proxy.config.http.cache.http)
+    +OK
+    ts#
+
+    ts# config:cache http
+    on
+    ts#
+
+  syntax: config:cache cluster-bypass <on | off>
+  args:   <on | off> turn cluster-bypass on/off.
+  
+    ts# config:cache cluster-bypass on   (proxy.config.http.cache.cluster_cache_local)
+    +OK
+    ts#
+
+    ts# config:cache cluster-bypass
+    on
+    ts#
+
+  syntax: config:cache ignore-bypass <on | off>
+  args:   <on | off> turn ignore-bypass on/off.
+  
+    ts# config:cache ignore-bypass on   (proxy.config.http.cache.ignore_client_no_cache)
+    +OK
+    ts#
+
+    ts# config:cache ignore-bypass
+    on
+    ts#
+
+  syntax: config:cache max-object-size <bytes>
+  args:   if bytes=0 then there is no maximum
+
+    ts# config:cache max-object-size 0  (proxy.config.cache.max_doc_size)
+    +OK
+    ts#
+
+    ts# config:cache max-object-size
+    0
+    ts#
+
+  syntax: config:cache max-alternates <num>
+  args:   if num=0 then there is no maximum
+
+    ts# config:cache max-alternates 0
+    +OK
+    ts#
+
+    ts# config:cache max-alternates
+    0
+    ts#
+
+  syntax: config:cache file [url]
+  args:   [url] = location of remote cache.config file
+  behavior:  Retrieve and install cache.config file from URL.
+
+    ts# config:cache file http://example.com/cache.config
+    +OK
+    ts#
+
+  syntax: config:cache freshness verify <when-expired | no-date | always | never>
+  records.config: proxy.config.http.cache.when_to_revalidate
+  args: when-expired = 0, no-date=1, always=2, never=3
+
+    ts# config:cache freshness verify when-expired
+    +OK
+    ts#
+
+  syntax: config:cache freshness minimum <explicit | last-modified | nothing>
+  records.config: proxy.config.http.cache.required_headers
+  args:   explicit = 2, last-modified = 1, nothing = 0
+
+    ts# config:cache freshness minimum explicit
+    +OK
+    ts#
+
+  syntax: config:cache freshness no-expire-limit greater-than <seconds> less-than <seconds>
+  records.config: proxy.config.http.cache.heuristic_min_lifetime, heuristic_max_lifetime
+  args:   <seconds> is an integer
+
+    ts# config:cache freshness no-expire-limit greater-than 900 less-than 7200
+    +OK
+    ts#
+
+  syntax: config:cache dynamic <on | off>
+  records: proxy.config.http.cache.cache_urls_that_look_dynamic
+  
+    ts# config:cache dynamic on
+    +OK
+    ts#
+
+  syntax: config:cache alternates <on | off>
+  records: proxy.config.http.cache.enable_default_vary_headers
+
+    ts# config:cache alternates on
+    +OK
+    ts#
+
+  syntax: config:cache vary <text | images | other> <field>
+  records: proxy.config.http.cache.vary_default_(text,images,other)
+  args:   <field> is a string
+
+    ts# config:cache vary text Cookie
+    +OK
+    ts#
+
+  syntax: config:cache cookies <none | all | images | non-text>
+  records: proxy.config.http.cache.cache_responses_to_cookies
+  args: none = 0, all = 1, images = 2, non-text = 3
+
+    ts# config:cache cookies none
+    +OK
+    ts#
+
+  syntax: config:cache clear (clear cache and start traffic server)
+  args: none
+
+   ts# config:cache clear
+   Traffic Server is running.
+   Clear Cache failed.
+   ts# config:cache clear
+   +OK
+
+
+hostdb			Host Database Configuration
+  syntax:  config:hostdb lookup-timeout <seconds>
+  records: proxy.config.hostdb.lookup_timeout
+
+    ts# config:hostdb lookup-timeout 30
+    +OK
+    ts#
+
+  syntax:  config:hostdb foreground-timeout <seconds>
+  records: proxy.config.hostdb.timeout (seconds)
+
+    ts# config:hostdb foreground-timeout 12
+    +OK
+    ts#
+
+  syntax:  config:hostdb background-timeout <seconds>
+  records: proxy.config.hostdb.verify_after 24
+
+    ts# config:hostdb background-timeout 24
+    +OK
+    ts#
+
+  syntax:  config:hostdb invalid-host-timeout <seconds>
+  records: proxy.config.hostdb.fail.timeout
+
+    ts# config:hostdb invalid-host-timeout 30
+    +OK
+    ts#
+
+  syntax:  config:hostdb re-dns-on-reload <on | off>
+  records: proxy.config.hostdb.re_dns_on_reload
+
+    ts# config:hostdb re-dns-on-reload on
+    +OK
+    ts#
+
+  syntax: config:hostdb clear  (clear hostdb and start traffic server)
+  args: none
+
+   ts# config:hostdb clear
+   Traffic Server is running.
+   Clear HostDB failed.
+
+   ts# config:hostdb clear 
+   +OK
+   ts#
+
+dns			DNS Configuration
+  syntax:  config:dns resolve-timeout <seconds>
+  records: proxy.config.dns.lookup_timeout
+
+    ts# config:dns resolve-timeout 10
+    +OK
+    ts#
+
+  syntax:  config:dns retries <number>
+  records: proxy.config.dns.retries
+
+    ts# config:dns retries 3
+    +OK
+    ts#
+
+logging			Logging Configuration
+  syntax:  config:logging event <enabled | trans-only | error-only | disabled>
+  records: proxy.config.log.logging_enabled
+
+    ts# config:logging event enabled
+    +OK
+    ts#
+
+    ts# config:logging event
+    enabled
+    ts#
+
+  syntax:  config:logging mgmt-directory <dir>
+  records: proxy.config.log.logfile_dir
+
+    ts# config:logging mgmt-directory /usr/local/var/log/trafficserver
+    +OK
+    ts#
+
+  syntax:  config:logging space-limit <mb>
+  args:    <mb> = log space limit (MB)
+  records: proxy.config.log.max_space_mb_for_logs
+
+    ts# config:logging space-limit 10
+    +OK
+    ts#
+
+  syntax:  config:logging space-headroom <mb>
+  args:    <mb> = log space headroom (MB)
+  records: proxy.config.log.max_space_mb_headroom
+
+    ts# config:logging space-headroom 100
+    +OK
+    ts#
+
+  syntax:  config:logging collation-status <inactive | host | send-standard | send-custom | send-all>
+  args:    inactive = 0, host = 1, send-standard = 2, send-custom = 3, send-all = 4
+  records: proxy.local.log.collation_mode
+
+    ts# config:logging collation-status inactive
+    +OK
+    ts#
+
+    ts# config:log collation-status send-custom 
+    +OK
+    ts#
+
+  syntax:  config:logging collation-host <host>
+  args:    <host> is a remote collation host
+  records: proxy.config.log.collation_host
+
+    ts# config:log collation-host config1
+    +OK
+    ts#
+
+  syntax:  config:logging collation secret <secret> tagged <on | off> orphan-limit <orphan>
+  args:    <secret> = string
+           <orphan> = size in MB
+  records: <secret> = proxy.config.log.collation_port
+           tagged   = proxy.config.log.collation_host_tagged
+           <orphan> = proxy.config.log.collation_secret
+
+    ts# config:logging collation secret foobar tagged on orphan-limit 10
+    +OK
+    ts#
+
+  syntax:  config:logging format <squid | netscape-common | netscape-ext | netscape-ext2> 
+                  <on | off> type <ascii | binary> file <file> header <header>
+
+  squid
+    args:    <on | off> = proxy.config.log.squid_log_enabled
+             type       = proxy.config.log.squid_log_is_ascii <ascii=1, binary=0>
+             file       = proxy.config.log.squid_log_name
+             header     = proxy.config.log.squid_log_header
+  netscape-common
+    args:    <on | off> = proxy.config.log.common_log_enabled
+             type       = proxy.config.log.common_log_is_ascii <ascii=1, binary=0>
+             file       = proxy.config.log.common_log_name
+             header     = proxy.config.log.common_log_header
+  netscape-ext
+    args:    <on | off> = proxy.config.log.extended_log_enabled
+             type       = proxy.config.log.extended_log_is_ascii <ascii=1, binary=0>
+             file       = proxy.config.log.extended_log_name
+             header     = proxy.config.log.extended_log_header
+  netscape-ext2
+    args:    <on | off> = proxy.config.log.extended2_log_enabled
+             type       = proxy.config.log.extended2_log_is_ascii <ascii=1, binary=0>
+             file       = proxy.config.log.extended2_log_name
+             header     = proxy.config.log.extended2_log_header
+
+    ts# config:log format squid on type ascii file squid.log
+    +OK
+    ts#
+
+  syntax:  config:logging splitting <icp | http> <on | off>
+  records:  proxy.config.log.separate_icp_logs  <icp>
+            proxy.config.log.separate_host_logs <http>
+
+    ts# config:log split icp on
+    +OK
+    ts#
+
+  syntax:  config:logging custom <on | off> format <traditional | xml>
+  records:  proxy.config.log.custom_logs_enabled
+
+    ts# config:logging custom on format xml
+    +OK
+    ts#
+
+  syntax:  config:logging rolling <on | off> offset <hour> interval <num-hours> auto-delete <on | off>
+  records: proxy.config.log.rolling_enabled
+           proxy.config.log.rolling_offset_hr (24hour format)
+           proxy.config.log.rolling_interval_sec (seconds)
+
+    ts# config:logging rolling on offset 0 interval 1 auto-delete off
+    +OK
+    ts#
+
+ssl			SSL Ports
+
+security		Security Configuration
+			(TS IP allow, MGMT allow, Admin Access)
+  syntax: config:security ip-allow <url>
+  
+    ts# config:security ip-allow http://example.com/ip_allow.config
+    ts#
+
+  syntax: config:security admin <url>
+
+    ts# config:parent status on 
+    ts#
+
+    ts# config:parent name parent.example.com
+    ts#
+
+    ts# config:parent rules http://example.com/parent.config
+    ts#
+
+remap			Remap Rules
+  syntax: config:remap <url>
+  args:   <url> = retrieve file and use as remap.config
+
+    ts# config:remap http://example.com/remap.config
+    ts#
+
+ports			Ports used by Traffic Server
+*** config:ports command is not implemented or supported ***
+			(including mgmt port)
+  syntax: config:ports <http-server | http-other | webui | cluster
+                        cluster-rs | cluster-mc |
+                        ssl | socks-server | icp> <port | ports>
+  args:   some variables are single-port while other can be a list of ports
+          <http-server>     (proxy.config.http.server_port) single
+          <cluster>         (proxy.config.cluster_port) single
+          <cluster-rs>      (proxy.config.cluster.rsport) single
+          <cluster-mc>      (proxy.config.cluster.mcport) single
+          <connect>         (proxy.config.http.connect_ports) list
+          <socks-server>    (proxy.config.socks.socks_server_port) single
+          <icp>             (proxy.config.icp.icp_port) single
+
+socks			SOCKS Configuration
+  syntax: config:socks status <on | off> version <int> default-servers <string> 
+                       accept <on | off> accept-port <port> 
+  args:   socks            (proxy.config.socks_socks_needed)
+          version          (proxy.config.socks.socks_version)
+          default-servers  (proxy.config.socks.default_servers)
+          accept           (proxy.config.socks.accept_enabled)
+          accept-port      (proxy.config.socks.accept_port)
+
+  ts# config:socks status on 
+  ts#
+  ts# config:socks version 4
+  ts#
+  ts# config:socks default-servers "s1.example.com:1080;socks2:4080"
+  ts#
+  ts# config:socks accept on
+  ts#
+  ts# config:socks accept-port 1080 
+  ts#
+
+
+
+scheduled-update        Scheduled Update Configuration
+  syntax: config:scheduled-update status <on | off>
+                                  retry-count <int>
+                                  retry-interval <sec>
+				  max-concurrent <value>
+				  force-immediate <on | off>
+				  rules <url>
+
+  args:   config update.config file
+  behavior: Scheduled Update Configuration.
+
+  ts> config:scheduled-update on
+  ts>
+
+  ts> config:scheduled-update retry-count 10 
+  ts>
+
+  ts> config:scheduled-update retry-interval 2
+
+  ts> config:scheduled-update force-immediate off
+  ts>
+
+  ts> config:scheduled-update rules http://example.com
+
+  ts> config:scheduled-update rules
+  update.config rules
+  ------------------- 
+  (Display list of rules from update.config)
+  ts>
+
+
+Appliance-Specific commands (Linux only)
+========================================
+
+Normal Mode
+-----------
+  ping		Send ICMP ECHO_REQUEST packets to host.
+    syntax: ping <host>
+    args:   hostname
+
+    ts> ping foo
+    foo is alive
+    ts>
+
+  traceroute    Display the route packets take to host.
+    syntax: traceroute <host>
+    args:   hostname
+
+    ts> traceroute foo
+    Traceroute output appears here...
+    ts>
+
+Configure Mode
+--------------
+
+config:network	Make System Network configuration changes
+
+   traffic_shell> config:network
+
+   Command Syntax: 
+   config:network hostname <string>
+   config:network defaultrouter <x.x.x.x>
+   config:network search-domain <string>
+   config:network dns [a.a.a.a] [b.b.b.b] [c.c.c.c]
+   config:network int <interface>
+   config:network int <interface> down
+   config:network int <interface> up <onboot | not-onboot>
+                 <static | dhcp> <ip> <netmask> <gateway>
+   config:network int <interface> <onboot | not-onboot>
+   config:network int <interface> <static | dhcp>
+   config:network int <interface> ip <x.x.x.x>
+   config:network int <interface> netmask <x.x.x.x>
+   config:network int <interface> gateway <x.x.x.x | default>
+
+   traffic_shell> 
+
+  hostname      Specify appliance hostname
+    syntax: config:network hostname <name>
+    ts# config:network hostname xxxx
+    ts# config:network hostname
+    xxxx
+    ts#
+
+  defaultrouter  Specify default router
+    syntax: config:network defaultrouter <x.x.x.x>
+
+    ts# config:network defaultrouter x.x.x.x
+    ts# config:network defaultrouter
+    x.x.x.x
+    ts#
+
+  search-domain  Specify DNS search domain
+    syntax: config:network search-domain <x.x.x.x>
+
+    ts# config:network search-domain example.com
+    ts# config:network search-domain
+    example.com
+    ts#
+
+  dns		Specify one or more DNS servers
+    syntax: config:network dns <string of IP addresses>
+
+    ts# config:network dns "192.168.0.2 192.168.0.3"
+    ts# config:network dns
+    192.168.0.2 192.168.0.3
+    ts#
+
+  int		Configure Network Interface Card
+
+	config:network int
+		List network interface cards by name.
+
+	config:network int <interface>
+		Display NIC configuration.
+
+	config:network int <interface> down
+		Bring down the specified interface.
+
+	config:network int <interface> up <onboot | not-onboot>
+			   <static | dhcp> <ip> <netmask> <gateway>
+		Bring up a NIC with the specified parameters.
+
+	config:network int <interface> <onboot | not-onboot>
+		Change the boot start status of a NIC that is already up.
+
+	config:network int <interface> <static | dhcp>
+		Change the static/dhcp status of a NIC that is already up.
+
+	config:network int <interface> ip <x.x.x.x>
+		Change the IP address of a NIC that is already up.
+
+	config:network int <interface> netmask <x.x.x.x>
+		Change the netmask of a NIC that is already up.
+
+	config:network int <interface> gateway <x.x.x.x | default>
+		Change the gateway of a NIC that is already up.
+
+   traffic_shell> config:network int     
+   eth0
+   eth1
+   traffic_shell> config:network int eth0
+
+   NIC eth0
+     Status -------------- up
+     Start on Boot ------- onboot
+     Start Protocol ------ none
+     IP Address ---------- 192.168.0.10
+     Netmask ------------- 255.255.255.0
+     Gateway ------------- default
+
+   traffic_shell> 
+    
+
+  date		Specify system date.
+    syntax: config:clock date <date>
+    args:   <date> = mm/dd/yyyy
+
+    ts# config:clock date 01/01/2001
+    ts# config:clock date
+    01/01/2001
+    ts#
+  
+  time		Specify system time.
+    syntax: config time <time>
+    args:   <time> = hh:mm:ss
+
+    ts# config:clock time 14:00:00
+    ts# config:clock time
+    14:00:03
+    ts#
+
+  timezone	Specify time zone.
+    syntax: config:clock timezone [zone | list]
+    args:   [zone] optional time zone from numbered list
+            if not present, display current time zones
+	    [list] display list of time zone
+
+    ts# config:clock timezone
+    Display numbered current timezones.
+
+    ts# config:clock timezone 3
+    ts#
+    
+    ts# config:clock timezone list
+    Display list of time zone. (85 in total currently)
+
+  halt		Halt appliance.
+    syntax: halt
+
+    ts# halt
+
+  reboot	Reboot appliance.
+    syntax: reboot
+
+    ts# reboot


[04/44] git commit: reliably recreate the same tar-ball from the same content

Posted by zw...@apache.org.
reliably recreate the same tar-ball from the same content

if the content of the tree is the same, we now create the same
tarballs with the same and sha1sums. We do this, by fixing the mtime of
all objects in the tarball to that of our ./configure.ac

In order for the content to be the same, we no longer rely on simply
calling $(MAKE) asf-dist-sign with a different version, but rather have
special targets, which simply inject the $(RC) variable.

These targets are entirely convinience wrappers for Release managers.

NOTE the GPG signature will always different, because it's a cryptographic
signature. In order to release 4.2.16-rc7 as 4.2.16, we can either call

    make release

or, simply rename the tar-ball. The content of the tar-ball will be the
same, regardless.


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

Branch: refs/heads/5.0.x
Commit: cdfe125a12129d39969a4f2a585351392b181ea3
Parents: b21deab
Author: Igor Galić <i....@brainsware.org>
Authored: Thu Nov 14 10:38:05 2013 +0100
Committer: Igor Galić <i....@brainsware.org>
Committed: Thu Nov 14 11:32:34 2013 +0100

----------------------------------------------------------------------
 Makefile.am | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cdfe125a/Makefile.am
----------------------------------------------------------------------
diff --git a/Makefile.am b/Makefile.am
index c92cdf7..2534837 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -62,7 +62,11 @@ asf-distdir:
 	rm -rf -- $(distdir)/autom4te.cache $(distdir)/.git $(distdir)/.gitignore $(distdir)/ci
 
 asf-dist: asf-distdir
-	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+	tardir=$(distdir) && $(am__tar) --mtime=./configure.ac | bzip2 -9 -c >$(distdir).tar.bz2
+	@$(am__remove_distdir)
+
+asf-dist-rc: asf-distdir
+	tardir=$(distdir) && $(am__tar) --mtime=./configure.ac | bzip2 -9 -c >$(distdir)-rc$(RC).tar.bz2
 	@$(am__remove_distdir)
 
 asf-dist-sign: asf-dist
@@ -70,11 +74,15 @@ asf-dist-sign: asf-dist
 	sha1sum -b $(distdir).tar.bz2 >$(distdir).tar.bz2.sha1
 	gpg --armor --output $(distdir).tar.bz2.asc  --detach-sig $(distdir).tar.bz2
 
+asf-dist-sign-rc: asf-dist-rc
+	md5sum -b $(distdir)-rc$(RC).tar.bz2 >$(distdir)-rc$(RC).tar.bz2.md5
+	sha1sum -b $(distdir)-rc$(RC).tar.bz2 >$(distdir)-rc$(RC).tar.bz2.sha1
+	gpg --armor --output $(distdir)-rc$(RC).tar.bz2.asc  --detach-sig $(distdir)-rc$(RC).tar.bz2
+
 release: asf-dist-sign
 	git tag -fs -m "Release $(VERSION)" $(VERSION)
 
-rel-candidate:
-	$(MAKE) asf-dist-sign VERSION=$(VERSION)-rc$(RC)
+rel-candidate: asf-dist-sign-rc
 	git tag -fs -m "Release Candidate $(VERSION)-rc$(RC)" $(VERSION)-rc$(RC)
 
 examples: all