Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (_HttpSessionAccept_h_)
00025 #define _HttpSessionAccept_h_
00026
00027 #include "libts.h"
00028 #include "P_EventSystem.h"
00029 #include "HttpConfig.h"
00030 #include "HTTP.h"
00031 #include "I_Net.h"
00032 #include <records/I_RecHttp.h>
00033
00034 namespace detail {
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 class HttpSessionAcceptOptions {
00053 private:
00054 typedef HttpSessionAcceptOptions self;
00055 public:
00056 HttpSessionAcceptOptions();
00057
00058
00059 int transport_type;
00060
00061 self& setTransportType(int);
00062
00063 IpAddr outbound_ip4;
00064
00065 IpAddr outbound_ip6;
00066
00067 self& setOutboundIp(IpAddr& ip);
00068
00069 self& setOutboundIp(IpEndpoint* ip);
00070
00071 uint16_t outbound_port;
00072
00073 self& setOutboundPort(uint16_t);
00074
00075 bool f_outbound_transparent;
00076
00077 self& setOutboundTransparent(bool);
00078
00079 bool f_transparent_passthrough;
00080
00081 self& setTransparentPassthrough(bool);
00082
00083 bool backdoor;
00084
00085 self& setBackdoor(bool);
00086
00087 HostResPreferenceOrder host_res_preference;
00088
00089 self& setHostResPreference(HostResPreferenceOrder const);
00090
00091 SessionProtocolSet session_protocol_preference;
00092
00093 self& setSessionProtocolPreference(SessionProtocolSet const&);
00094 };
00095
00096 inline HttpSessionAcceptOptions::HttpSessionAcceptOptions()
00097 : transport_type(0)
00098 , outbound_port(0)
00099 , f_outbound_transparent(false)
00100 , f_transparent_passthrough(false)
00101 , backdoor(false)
00102 {
00103 memcpy(host_res_preference, host_res_default_preference_order, sizeof(host_res_preference));
00104 }
00105
00106 inline HttpSessionAcceptOptions&
00107 HttpSessionAcceptOptions::setTransportType(int type) {
00108 transport_type = type;
00109 return *this;
00110 }
00111
00112 inline HttpSessionAcceptOptions&
00113 HttpSessionAcceptOptions::setOutboundIp(IpAddr& ip) {
00114 if (ip.isIp4()) outbound_ip4 = ip;
00115 else if (ip.isIp6()) outbound_ip6 = ip;
00116 return *this;
00117 }
00118
00119 inline HttpSessionAcceptOptions&
00120 HttpSessionAcceptOptions::setOutboundIp(IpEndpoint* ip) {
00121 if (ip->isIp4()) outbound_ip4 = *ip;
00122 else if (ip->isIp6()) outbound_ip6 = *ip;
00123 return *this;
00124 }
00125
00126 inline HttpSessionAcceptOptions&
00127 HttpSessionAcceptOptions::setOutboundPort(uint16_t port) {
00128 outbound_port = port;
00129 return *this;
00130 }
00131
00132 inline HttpSessionAcceptOptions&
00133 HttpSessionAcceptOptions::setOutboundTransparent(bool flag) {
00134 f_outbound_transparent = flag;
00135 return *this;
00136 }
00137
00138 inline HttpSessionAcceptOptions&
00139 HttpSessionAcceptOptions::setTransparentPassthrough(bool flag) {
00140 f_transparent_passthrough = flag;
00141 return *this;
00142 }
00143
00144 inline HttpSessionAcceptOptions&
00145 HttpSessionAcceptOptions::setBackdoor(bool flag) {
00146 backdoor = flag;
00147 return *this;
00148 }
00149
00150 inline HttpSessionAcceptOptions&
00151 HttpSessionAcceptOptions::setHostResPreference(HostResPreferenceOrder const order) {
00152 memcpy(host_res_preference, order, sizeof(host_res_preference));
00153 return *this;
00154 }
00155
00156 inline HttpSessionAcceptOptions&
00157 HttpSessionAcceptOptions::setSessionProtocolPreference(SessionProtocolSet const& sp_set) {
00158 session_protocol_preference = sp_set;
00159 return *this;
00160 }
00161 }
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 class HttpSessionAccept: public SessionAccept, private detail::HttpSessionAcceptOptions
00175 {
00176 private:
00177 typedef HttpSessionAccept self;
00178 public:
00179
00180
00181
00182 typedef detail::HttpSessionAcceptOptions Options;
00183
00184
00185
00186
00187
00188
00189 HttpSessionAccept(Options const& opt = Options())
00190 : SessionAccept(NULL)
00191 , detail::HttpSessionAcceptOptions(opt)
00192 {
00193 SET_HANDLER(&HttpSessionAccept::mainEvent);
00194 return;
00195 }
00196
00197 ~HttpSessionAccept()
00198 {
00199 return;
00200 }
00201
00202 void accept(NetVConnection *, MIOBuffer *, IOBufferReader *);
00203 int mainEvent(int event, void *netvc);
00204
00205 private:
00206 HttpSessionAccept(const HttpSessionAccept &);
00207 HttpSessionAccept & operator =(const HttpSessionAccept &);
00208 };
00209
00210 #endif