diff --git a/README.md b/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc b/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc index 6e7974c451f..79607fbdfed 100644 --- a/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc +++ b/lib/atscppapi/examples/async_http_fetch/AsyncHttpFetch.cc @@ -214,6 +214,7 @@ void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { TS_DEBUG(TAG, "Loaded async_http_fetch_example plugin"); + RegisterGlobalPlugin("CPP_Example_AsyncHttpFetch", "apache", "users@trafficserver.apache.org"); GlobalPlugin *instance = new GlobalHookPlugin(); (void)instance; diff --git a/lib/atscppapi/examples/async_http_fetch_streaming/AsyncHttpFetchStreaming.cc b/lib/atscppapi/examples/async_http_fetch_streaming/AsyncHttpFetchStreaming.cc index 33902c3a9b4..fe27552b3a8 100644 --- a/lib/atscppapi/examples/async_http_fetch_streaming/AsyncHttpFetchStreaming.cc +++ b/lib/atscppapi/examples/async_http_fetch_streaming/AsyncHttpFetchStreaming.cc @@ -75,6 +75,7 @@ class InterceptInstaller : public GlobalPlugin void TSPluginInit(int /* argc ATS_UNUSED */, const char * /* argv ATS_UNUSED */ []) { + RegisterGlobalPlugin("CPP_Example_AsyncHttpFetchStreaming", "apache", "users@trafficserver.apache.org"); new InterceptInstaller(); } diff --git a/lib/atscppapi/examples/async_timer/AsyncTimer.cc b/lib/atscppapi/examples/async_timer/AsyncTimer.cc index 6faa0813439..3eb2211eb8f 100644 --- a/lib/atscppapi/examples/async_timer/AsyncTimer.cc +++ b/lib/atscppapi/examples/async_timer/AsyncTimer.cc @@ -60,6 +60,7 @@ class TimerEventReceiver : public AsyncReceiver void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_AsyncTimer", "apache", "users@trafficserver.apache.org"); int period_in_ms = 1000; TimerEventReceiver *timer1 = new TimerEventReceiver(AsyncTimer::TYPE_PERIODIC, period_in_ms); TS_DEBUG(TAG, "Created periodic timer %p with initial period 0, regular period %d and max instances 0", timer1, period_in_ms); diff --git a/lib/atscppapi/examples/boom/boom.cc b/lib/atscppapi/examples/boom/boom.cc index 4d8b9d45e14..41d4077b41c 100644 --- a/lib/atscppapi/examples/boom/boom.cc +++ b/lib/atscppapi/examples/boom/boom.cc @@ -415,6 +415,7 @@ BoomGlobalPlugin::handleReadResponseHeaders(Transaction &transaction) void TSPluginInit(int argc, const char *argv[]) { + RegisterGlobalPlugin("CPP_Example_Boom", "apache", "users@trafficserver.apache.org"); boom_counter.init(BOOM_COUNTER); BoomResponseRegistry *pregistry = new BoomResponseRegistry(); diff --git a/lib/atscppapi/examples/clientredirect/ClientRedirect.cc b/lib/atscppapi/examples/clientredirect/ClientRedirect.cc index b4fcbd11abf..34138cbb2d8 100644 --- a/lib/atscppapi/examples/clientredirect/ClientRedirect.cc +++ b/lib/atscppapi/examples/clientredirect/ClientRedirect.cc @@ -78,5 +78,6 @@ class ClientRedirectGlobalPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_ClientDirect", "apache", "users@trafficserver.apache.org"); new ClientRedirectGlobalPlugin(); } diff --git a/lib/atscppapi/examples/clientrequest/ClientRequest.cc b/lib/atscppapi/examples/clientrequest/ClientRequest.cc index 323870f0b4d..daa7e691905 100644 --- a/lib/atscppapi/examples/clientrequest/ClientRequest.cc +++ b/lib/atscppapi/examples/clientrequest/ClientRequest.cc @@ -135,5 +135,6 @@ class GlobalHookPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_ClientRequest", "apache", "users@trafficserver.apache.org"); new GlobalHookPlugin(); } diff --git a/lib/atscppapi/examples/customresponse/CustomResponse.cc b/lib/atscppapi/examples/customresponse/CustomResponse.cc index b6d3057aab9..ce6f5b15767 100644 --- a/lib/atscppapi/examples/customresponse/CustomResponse.cc +++ b/lib/atscppapi/examples/customresponse/CustomResponse.cc @@ -85,5 +85,6 @@ class ClientRedirectGlobalPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_CustomResponse", "apache", "users@trafficserver.apache.org"); new ClientRedirectGlobalPlugin(); } diff --git a/lib/atscppapi/examples/globalhook/GlobalHookPlugin.cc b/lib/atscppapi/examples/globalhook/GlobalHookPlugin.cc index 1602a05e4e8..ce84e1ef174 100644 --- a/lib/atscppapi/examples/globalhook/GlobalHookPlugin.cc +++ b/lib/atscppapi/examples/globalhook/GlobalHookPlugin.cc @@ -19,9 +19,7 @@ #include #include #include - using namespace atscppapi; - class GlobalHookPlugin : public GlobalPlugin { public: @@ -38,5 +36,7 @@ class GlobalHookPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_GlobalHookPplugin", "apache", "users@trafficserver.apache.org"); + std::cout << "Hello from " << argv[0] << std::endl; new GlobalHookPlugin(); } diff --git a/lib/atscppapi/examples/gzip_transformation/GzipTransformationPlugin.cc b/lib/atscppapi/examples/gzip_transformation/GzipTransformationPlugin.cc index 9f3a8d49b8c..d01715824de 100644 --- a/lib/atscppapi/examples/gzip_transformation/GzipTransformationPlugin.cc +++ b/lib/atscppapi/examples/gzip_transformation/GzipTransformationPlugin.cc @@ -192,6 +192,7 @@ class GlobalHookPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_GzipTransformation", "apache", "users@trafficserver.apache.org"); TS_DEBUG(TAG, "TSPluginInit"); new GlobalHookPlugin(); } diff --git a/lib/atscppapi/examples/helloworld/HelloWorldPlugin.cc b/lib/atscppapi/examples/helloworld/HelloWorldPlugin.cc index e7a43997744..7100487d8e4 100644 --- a/lib/atscppapi/examples/helloworld/HelloWorldPlugin.cc +++ b/lib/atscppapi/examples/helloworld/HelloWorldPlugin.cc @@ -20,16 +20,19 @@ #include #include #include - class HelloWorldPlugin : public atscppapi::GlobalPlugin { public: - HelloWorldPlugin() { std::cout << "Hello World!" << std::endl; } + HelloWorldPlugin() { + std::cout << "Hello World!" << std::endl; + } }; void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + std::cout << "Hello from " << argv[0] << std::endl; + atscppapi::RegisterGlobalPlugin("CPP_Example_HelloWorld", "apache", "users@trafficserver.apache.org"); new HelloWorldPlugin(); } diff --git a/lib/atscppapi/examples/intercept/intercept.cc b/lib/atscppapi/examples/intercept/intercept.cc index 9cb0005195e..9cf0758d799 100644 --- a/lib/atscppapi/examples/intercept/intercept.cc +++ b/lib/atscppapi/examples/intercept/intercept.cc @@ -55,6 +55,7 @@ class InterceptInstaller : public GlobalPlugin void TSPluginInit(int /* argc ATS_UNUSED */, const char * /* argv ATS_UNUSED */ []) { + RegisterGlobalPlugin("CPP_Example_Intercept", "apache", "users@trafficserver.apache.org"); new InterceptInstaller(); } diff --git a/lib/atscppapi/examples/internal_transaction_handling/InternalTransactionHandling.cc b/lib/atscppapi/examples/internal_transaction_handling/InternalTransactionHandling.cc index ee1ba0761cd..4ed9923a7e0 100644 --- a/lib/atscppapi/examples/internal_transaction_handling/InternalTransactionHandling.cc +++ b/lib/atscppapi/examples/internal_transaction_handling/InternalTransactionHandling.cc @@ -71,6 +71,7 @@ class NoInternalTransactionsGlobalPlugin : public GlobalPlugin, public AsyncRece void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_InternalTransactionHandling", "apache", "users@trafficserver.apache.org"); TS_DEBUG(TAG, "Loaded async_http_fetch_example plugin"); new AllTransactionsGlobalPlugin(); new NoInternalTransactionsGlobalPlugin(); diff --git a/lib/atscppapi/examples/logger_example/LoggerExample.cc b/lib/atscppapi/examples/logger_example/LoggerExample.cc index 02f4732ab34..7ec4ae3ce09 100644 --- a/lib/atscppapi/examples/logger_example/LoggerExample.cc +++ b/lib/atscppapi/examples/logger_example/LoggerExample.cc @@ -102,6 +102,7 @@ class GlobalHookPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_Logger", "apache", "users@trafficserver.apache.org"); // Create a new logger // This will create a log file with the name logger_example.log (since we left off // the extension it will automatically add .log) diff --git a/lib/atscppapi/examples/multiple_transaction_hooks/MultipleTransactionHookPlugins.cc b/lib/atscppapi/examples/multiple_transaction_hooks/MultipleTransactionHookPlugins.cc index d1c2e4097e0..a8bce04d3ea 100644 --- a/lib/atscppapi/examples/multiple_transaction_hooks/MultipleTransactionHookPlugins.cc +++ b/lib/atscppapi/examples/multiple_transaction_hooks/MultipleTransactionHookPlugins.cc @@ -105,5 +105,6 @@ class GlobalHookPlugin : public atscppapi::GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_MultipleTransactionHook", "apache", "users@trafficserver.apache.org"); new GlobalHookPlugin(); } diff --git a/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc b/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc index fa6e710e6ce..17b93a850c4 100644 --- a/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc +++ b/lib/atscppapi/examples/null_transformation_plugin/NullTransformationPlugin.cc @@ -99,6 +99,7 @@ class GlobalHookPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_NullTransformation", "apache", "users@trafficserver.apache.org"); TS_DEBUG(TAG, "TSPluginInit"); new GlobalHookPlugin(); } diff --git a/lib/atscppapi/examples/post_buffer/PostBuffer.cc b/lib/atscppapi/examples/post_buffer/PostBuffer.cc index 85131de76b9..d8aaa504134 100644 --- a/lib/atscppapi/examples/post_buffer/PostBuffer.cc +++ b/lib/atscppapi/examples/post_buffer/PostBuffer.cc @@ -80,5 +80,6 @@ class GlobalHookPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_PostBuffer", "apache", "users@trafficserver.apache.org"); new GlobalHookPlugin(); } diff --git a/lib/atscppapi/examples/remap_plugin/RemapPlugin.cc b/lib/atscppapi/examples/remap_plugin/RemapPlugin.cc index cd83117d3db..b04c4feb0b2 100644 --- a/lib/atscppapi/examples/remap_plugin/RemapPlugin.cc +++ b/lib/atscppapi/examples/remap_plugin/RemapPlugin.cc @@ -84,7 +84,7 @@ class MyRemapPlugin : public RemapPlugin } }; -TsReturnCode +TSReturnCode TSRemapNewInstance(int argc ATSCPPAPI_UNUSED, char *argv[] ATSCPPAPI_UNUSED, void **instance_handle, char *errbuf ATSCPPAPI_UNUSED, int errbuf_size ATSCPPAPI_UNUSED) { diff --git a/lib/atscppapi/examples/serverresponse/ServerResponse.cc b/lib/atscppapi/examples/serverresponse/ServerResponse.cc index b15121010ed..26b387b3e75 100644 --- a/lib/atscppapi/examples/serverresponse/ServerResponse.cc +++ b/lib/atscppapi/examples/serverresponse/ServerResponse.cc @@ -114,5 +114,6 @@ class ServerResponsePlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_ServerResponse", "apache", "users@trafficserver.apache.org"); new ServerResponsePlugin(); } diff --git a/lib/atscppapi/examples/stat_example/StatExample.cc b/lib/atscppapi/examples/stat_example/StatExample.cc index 12b10cbfdef..e2883ee8cd1 100644 --- a/lib/atscppapi/examples/stat_example/StatExample.cc +++ b/lib/atscppapi/examples/stat_example/StatExample.cc @@ -67,6 +67,7 @@ class GlobalHookPlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_Stat", "apache", "users@trafficserver.apache.org"); TS_DEBUG(TAG, "Loaded stat_example plugin"); // Since this stat is not persistent it will be initialized to 0. diff --git a/lib/atscppapi/examples/timeout_example/TimeoutExamplePlugin.cc b/lib/atscppapi/examples/timeout_example/TimeoutExamplePlugin.cc index 63c4b78bfad..98309a4d210 100644 --- a/lib/atscppapi/examples/timeout_example/TimeoutExamplePlugin.cc +++ b/lib/atscppapi/examples/timeout_example/TimeoutExamplePlugin.cc @@ -57,6 +57,7 @@ class TimeoutExamplePlugin : public GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin( "CPP_Example_Timeout", "apache", "users@trafficserver.apache.org"); TS_DEBUG(TAG, "TSPluginInit"); new TimeoutExamplePlugin(); } diff --git a/lib/atscppapi/examples/transactionhook/TransactionHookPlugin.cc b/lib/atscppapi/examples/transactionhook/TransactionHookPlugin.cc index 22adadfd52f..c46057168ac 100644 --- a/lib/atscppapi/examples/transactionhook/TransactionHookPlugin.cc +++ b/lib/atscppapi/examples/transactionhook/TransactionHookPlugin.cc @@ -65,5 +65,6 @@ class GlobalHookPlugin : public atscppapi::GlobalPlugin void TSPluginInit(int argc ATSCPPAPI_UNUSED, const char *argv[] ATSCPPAPI_UNUSED) { + RegisterGlobalPlugin("CPP_Example_TransactionHook", "apache", "users@trafficserver.apache.org"); new GlobalHookPlugin(); } diff --git a/lib/atscppapi/src/Plugin.cc b/lib/atscppapi/src/Plugin.cc index 9e319e51655..fb99a6ecffa 100644 --- a/lib/atscppapi/src/Plugin.cc +++ b/lib/atscppapi/src/Plugin.cc @@ -20,9 +20,18 @@ * @file Plugin.cc */ #include "atscppapi/Plugin.h" - +#include const std::string atscppapi::HOOK_TYPE_STRINGS[] = { std::string("HOOK_READ_REQUEST_HEADERS_PRE_REMAP"), std::string("HOOK_READ_REQUEST_HEADERS_POST_REMAP"), std::string("HOOK_SEND_REQUEST_HEADERS"), std::string("HOOK_READ_RESPONSE_HEADERS"), std::string("HOOK_SEND_RESPONSE_HEADERS"), std::string("HOOK_OS_DNS"), std::string("HOOK_READ_REQUEST_HEADERS"), std::string("HOOK_READ_CACHE_HEADERS"), std::string("HOOK_CACHE_LOOKUP_COMPLETE"), std::string("HOOK_SELECT_ALT")}; + +void atscppapi::RegisterGlobalPlugin(std::string name, std::string vendor, std::string email) +{ + TSPluginRegistrationInfo info; + info.plugin_name=const_cast(name.c_str()); + info.vendor_name=const_cast(vendor.c_str()); + info.support_email=const_cast(email.c_str()); + TSPluginRegister(TS_SDK_VERSION_3_0, &info); +} diff --git a/lib/atscppapi/src/Transaction.cc b/lib/atscppapi/src/Transaction.cc index b2a70f22058..443b044a262 100644 --- a/lib/atscppapi/src/Transaction.cc +++ b/lib/atscppapi/src/Transaction.cc @@ -25,13 +25,11 @@ #include #include #include -#include #include #include "atscppapi/shared_ptr.h" #include "logging_internal.h" #include "utils_internal.h" #include "atscppapi/noncopyable.h" - using std::map; using std::string; using namespace atscppapi; @@ -98,6 +96,48 @@ Transaction::~Transaction() delete state_; } +bool Transaction::configIntSet(TSOverridableConfigKey conf, int value) +{ + return (TS_SUCCESS==TSHttpTxnConfigIntSet(state_->txn_,conf,(TSMgmtInt)value)); +} +bool Transaction::configIntGet(TSOverridableConfigKey conf, int *value) +{ + return (TS_SUCCESS==TSHttpTxnConfigIntGet(state_->txn_, conf, (TSMgmtInt*)value)); +} + +bool Transaction::configFloatSet(TSOverridableConfigKey conf, float value) +{ + return (TS_SUCCESS==TSHttpTxnConfigFloatSet(state_->txn_,conf,(TSMgmtFloat)value)); +} + +bool Transaction::configFloatGet(TSOverridableConfigKey conf, float *value) +{ + return (TS_SUCCESS==TSHttpTxnConfigFloatGet(state_->txn_, conf, value)); +} + +bool Transaction::configStringSet(TSOverridableConfigKey conf, std::string const& value,int length) +{ + return (TS_SUCCESS==TSHttpTxnConfigStringSet(state_->txn_,conf,(TSMgmtString)value.c_str(),length)); +} + +bool Transaction::configStringGet(TSOverridableConfigKey conf,std::string& value, int* length) +{ + const char* svalue; + TSReturnCode res=TSHttpTxnConfigStringGet(state_->txn_, conf, &svalue,length); + if(res==TS_SUCCESS) + { + value.assign(svalue); + return true; + } + else + return false; +} + +bool Transaction::configFind(std::string const& name, int length, TSOverridableConfigKey *conf, TSRecordDataType *type) +{ + return (TS_SUCCESS==TSHttpTxnConfigFind(name.c_str(),length,conf,type)); +} + void Transaction::resume() { diff --git a/lib/atscppapi/src/include/atscppapi/Plugin.h b/lib/atscppapi/src/include/atscppapi/Plugin.h index 1800ea52014..eb72625dc1f 100644 --- a/lib/atscppapi/src/include/atscppapi/Plugin.h +++ b/lib/atscppapi/src/include/atscppapi/Plugin.h @@ -30,6 +30,7 @@ #include #include + namespace atscppapi { /** @@ -166,6 +167,7 @@ class Plugin : noncopyable /**< Human readable strings for each HookType, you can access them as HOOK_TYPE_STRINGS[HOOK_OS_DNS] for example. */ extern const std::string HOOK_TYPE_STRINGS[]; +void RegisterGlobalPlugin(std::string name, std::string vendor, std::string email); } /* atscppapi */ diff --git a/lib/atscppapi/src/include/atscppapi/PluginInit.h b/lib/atscppapi/src/include/atscppapi/PluginInit.h index a1249b843ec..f5a4a8a27d1 100644 --- a/lib/atscppapi/src/include/atscppapi/PluginInit.h +++ b/lib/atscppapi/src/include/atscppapi/PluginInit.h @@ -23,9 +23,8 @@ #pragma once #ifndef ATSCPPAPI_PLUGININIT_H_ #define ATSCPPAPI_PLUGININIT_H_ - +#include <../ts/apidefs.h> #include - extern "C" { /** @@ -36,12 +35,6 @@ extern "C" { * @param argv Array of pointers pointing to arguments */ void TSPluginInit(int argc, const char *argv[]); - -enum TsReturnCode { - TS_ERROR = -1, - TS_SUCCESS = 0, -}; - /** * Invoked for remap plugins - listed in remap.config. The arguments provided as @pparam * in the remap.config line are provided in this invocation. @@ -52,7 +45,7 @@ enum TsReturnCode { * @param errbuf Not used * @param errbuf_size Not used */ -TsReturnCode TSRemapNewInstance(int argc, char *argv[], void **instance_handle, char *errbuf, int errbuf_size); +TSReturnCode TSRemapNewInstance(int argc, char *argv[], void **instance_handle, char *errbuf, int errbuf_size); } diff --git a/lib/atscppapi/src/include/atscppapi/Transaction.h b/lib/atscppapi/src/include/atscppapi/Transaction.h index 771aa41e65e..b0e4afab10b 100644 --- a/lib/atscppapi/src/include/atscppapi/Transaction.h +++ b/lib/atscppapi/src/include/atscppapi/Transaction.h @@ -30,7 +30,7 @@ #include "atscppapi/shared_ptr.h" #include "atscppapi/ClientRequest.h" #include "atscppapi/Response.h" - +#include <../ts/apidefs.h> namespace atscppapi { // forward declarations @@ -321,6 +321,14 @@ class Transaction : noncopyable */ void redirectTo(std::string const &url); + bool configIntSet(TSOverridableConfigKey conf, int value); + bool configIntGet(TSOverridableConfigKey conf, int* value); + bool configFloatSet(TSOverridableConfigKey conf, float value); + bool configFloatGet(TSOverridableConfigKey conf, float* value); + bool configStringSet(TSOverridableConfigKey conf, std::string const& value,int length); + bool configStringGet(TSOverridableConfigKey conf,std::string& value, int* length); + bool configFind(std::string const& name, int length, TSOverridableConfigKey *conf, TSRecordDataType *type); + private: TransactionState *state_; //!< The internal TransactionState object tied to the current Transaction friend class TransactionPlugin; //!< TransactionPlugin is a friend so it can call addPlugin()