trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wolfgang Walter <trafficser...@stwm.de>
Subject [PATCH 1/6] Logging: add %<pqsp>
Date Wed, 09 Apr 2014 20:25:50 GMT
>From 791f9bcdda4653626a1bd2ff844a525a5acebbd2 Mon Sep 17 00:00:00 2001
From: Wolfgang Walter <tintenfisch@stusta.de>
Date: Sun, 6 Apr 2014 13:20:04 +0200
Subject: [PATCH 1/6] Logging: add %<pqsp>

pqsp logs the port of the server request (as pqsi does for IP address)
---
 proxy/logging/Log.cc           |  7 +++++++
 proxy/logging/LogAccess.cc     |  9 +++++++++
 proxy/logging/LogAccess.h      |  1 +
 proxy/logging/LogAccessHttp.cc | 10 ++++++++++
 proxy/logging/LogAccessHttp.h  |  1 +
 5 files changed, 28 insertions(+)

diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 8a7d0d5..560085c 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -665,6 +665,13 @@ Log::init_fields()
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "pqsi", field);
 
+  field = NEW(new LogField("proxy_req_server_port", "pqsp",
+                           LogField::sINT,
+                           &LogAccess::marshal_proxy_req_server_port,
+                           &LogAccess::unmarshal_int_to_str));
+  global_field_list.add(field, false);
+  ink_hash_table_insert(field_symbol_hash, "pqsp", field);
+
   Ptr<LogFieldAliasTable> hierarchy_map = make_ptr(NEW(new LogFieldAliasTable));
   hierarchy_map->init(36,
                       SQUID_HIER_EMPTY, "EMPTY",
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index 20121f7..5db1740 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -331,6 +331,15 @@ LogAccess::marshal_proxy_req_server_ip(char *buf)
   -------------------------------------------------------------------------*/
 
 int
+LogAccess::marshal_proxy_req_server_port(char *buf)
+{
+  DEFAULT_INT_FIELD;
+}
+
+/*-------------------------------------------------------------------------
+  -------------------------------------------------------------------------*/
+
+int
 LogAccess::marshal_proxy_hierarchy_route(char *buf)
 {
   DEFAULT_INT_FIELD;
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index 35291aa..909efb7 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -205,6 +205,7 @@ public:
   inkcoreapi virtual int marshal_proxy_req_body_len(char *);    // INT
   inkcoreapi virtual int marshal_proxy_req_server_name(char *); // STR
   inkcoreapi virtual int marshal_proxy_req_server_ip(char *);   // INT
+  inkcoreapi virtual int marshal_proxy_req_server_port(char *);   // INT
   inkcoreapi virtual int marshal_proxy_hierarchy_route(char *); // INT
   inkcoreapi virtual int marshal_proxy_host_name(char *);       // STR
   inkcoreapi virtual int marshal_proxy_host_ip(char *); // STR
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index 5ad308b..626e672 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -687,6 +687,16 @@ LogAccessHttp::marshal_proxy_req_server_ip(char *buf)
   return marshal_ip(buf, m_http_sm->t_state.current.server != NULL ? &m_http_sm->t_state.current.server->addr.sa
: 0);
 }
 
+int
+LogAccessHttp::marshal_proxy_req_server_port(char *buf)
+{
+  if (buf) {
+    uint16_t port = m_http_sm->t_state.current.server != NULL ? m_http_sm->t_state.current.server->port
: 0;
+    marshal_int(buf, port);
+  }
+  return INK_MIN_ALIGN;
+}
+
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
diff --git a/proxy/logging/LogAccessHttp.h b/proxy/logging/LogAccessHttp.h
index 9235441..cfd9f0a 100644
--- a/proxy/logging/LogAccessHttp.h
+++ b/proxy/logging/LogAccessHttp.h
@@ -91,6 +91,7 @@ public:
   virtual int marshal_proxy_req_body_len(char *);       // INT
   virtual int marshal_proxy_req_server_name(char *);    // STR
   virtual int marshal_proxy_req_server_ip(char *);      // INT
+  virtual int marshal_proxy_req_server_port(char *);    // INT
   virtual int marshal_proxy_hierarchy_route(char *);    // INT
 
   //
-- 
1.9.1



Mime
View raw message