• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

ProxyClientSession.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   ProxyClientSession - Base class for protocol client sessions.
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef __PROXY_CLIENT_SESSION_H__
00025 #define __PROXY_CLIENT_SESSION_H__
00026 
00027 #include "libts.h"
00028 #include "P_Net.h"
00029 #include "InkAPIInternal.h"
00030 
00031 // Emit a debug message conditional on whether this particular client session
00032 // has debugging enabled. This should only be called from within a client session
00033 // member function.
00034 #define DebugSsn(ssn, tag, ...) DebugSpecific((ssn)->debug(), tag, __VA_ARGS__)
00035 
00036 class ProxyClientSession : public VConnection
00037 {
00038 public:
00039   ProxyClientSession();
00040 
00041   virtual void destroy() = 0;
00042   virtual void start() = 0;
00043 
00044   virtual void new_connection(NetVConnection * new_vc, MIOBuffer * iobuf, IOBufferReader * reader, bool backdoor) = 0;
00045 
00046   virtual void ssn_hook_append(TSHttpHookID id, INKContInternal * cont) {
00047     this->api_hooks.prepend(id, cont);
00048   }
00049 
00050   virtual void ssn_hook_prepend(TSHttpHookID id, INKContInternal * cont) {
00051     this->api_hooks.prepend(id, cont);
00052   }
00053 
00054   APIHook * ssn_hook_get(TSHttpHookID id) const {
00055     return this->api_hooks.get(id);
00056   }
00057 
00058   void * get_user_arg(unsigned ix) const {
00059     ink_assert(ix < countof(user_args));
00060     return this->user_args[ix];
00061   }
00062 
00063   void set_user_arg(unsigned ix, void * arg) {
00064     ink_assert(ix < countof(user_args));
00065     user_args[ix] = arg;
00066   }
00067 
00068   // Return whether debugging is enabled for this session.
00069   bool debug() const {
00070     return this->debug_on;
00071   }
00072 
00073   bool hooks_enabled() const {
00074     return this->hooks_on;
00075   }
00076 
00077   bool has_hooks() const {
00078     return this->api_hooks.has_hooks() || http_global_hooks->has_hooks();
00079   }
00080 
00081   // Initiate an API hook invocation.
00082   void do_api_callout(TSHttpHookID id);
00083 
00084   void cleanup();
00085 
00086   static int64_t next_connection_id();
00087 
00088 protected:
00089 
00090   // XXX Consider using a bitwise flags variable for the following flags, so that we can make the best
00091   // use of internal alignment padding.
00092 
00093   // Session specific debug flag.
00094   bool debug_on;
00095   bool hooks_on;
00096 
00097 private:
00098   APIHookScope  api_scope;
00099   TSHttpHookID  api_hookid;
00100   APIHook *     api_current;
00101   HttpAPIHooks  api_hooks;
00102   void *        user_args[HTTP_SSN_TXN_MAX_USER_ARG];
00103 
00104   ProxyClientSession(ProxyClientSession &); // noncopyable
00105   ProxyClientSession& operator=(const ProxyClientSession &); // noncopyable
00106 
00107   int state_api_callout(int event, void * edata);
00108   void handle_api_return(int event);
00109 
00110   friend void TSHttpSsnDebugSet(TSHttpSsn, int);
00111 };
00112 
00113 #endif // __PROXY_CLIENT_SESSION_H__

Generated by  doxygen 1.7.1