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 #include "HttpSessionAccept.h"
00025 #include "IPAllow.h"
00026 #include "HttpClientSession.h"
00027 #include "I_Machine.h"
00028 #include "Error.h"
00029 
00030 void
00031 HttpSessionAccept::accept(NetVConnection * netvc, MIOBuffer * iobuf, IOBufferReader * reader)
00032 {
00033   sockaddr const* client_ip = netvc->get_remote_addr();
00034   const AclRecord *acl_record = NULL;
00035   ip_port_text_buffer ipb;
00036   IpAllow::scoped_config ipallow;
00037 
00038   
00039   
00040   if (backdoor) {
00041     acl_record = IpAllow::AllMethodAcl();
00042   } else if (ipallow && (((acl_record = ipallow->match(client_ip)) == NULL) || (acl_record->isEmpty()))) {
00043 
00044     
00045 
00046     Warning("client '%s' prohibited by ip-allow policy", ats_ip_ntop(client_ip, ipb, sizeof(ipb)));
00047     netvc->do_io_close();
00048 
00049     return;
00050   }
00051 
00052   netvc->attributes = transport_type;
00053 
00054   if (is_debug_tag_set("http_seq")) {
00055     Debug("http_seq", "[HttpSessionAccept:mainEvent %p] accepted connection from %s transport type = %d", netvc, ats_ip_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes);
00056   }
00057 
00058   HttpClientSession *new_session = THREAD_ALLOC_INIT(httpClientSessionAllocator, this_ethread());
00059 
00060   
00061   new_session->f_outbound_transparent = f_outbound_transparent;
00062   new_session->f_transparent_passthrough = f_transparent_passthrough;
00063   new_session->outbound_ip4 = outbound_ip4;
00064   new_session->outbound_ip6 = outbound_ip6;
00065   new_session->outbound_port = outbound_port;
00066   new_session->host_res_style = ats_host_res_from(client_ip->sa_family, host_res_preference);
00067   new_session->acl_record = acl_record;
00068 
00069   new_session->new_connection(netvc, iobuf, reader, backdoor);
00070 
00071   return;
00072 }
00073 
00074 int
00075 HttpSessionAccept::mainEvent(int event, void *data)
00076 {
00077   ink_release_assert(event == NET_EVENT_ACCEPT || event == EVENT_ERROR);
00078   ink_release_assert((event == NET_EVENT_ACCEPT) ? (data != 0) : (1));
00079 
00080   if (event == NET_EVENT_ACCEPT) {
00081     this->accept(static_cast<NetVConnection *>(data), NULL, NULL);
00082     return EVENT_CONT;
00083   }
00084 
00085 
00086   
00087 
00088   if (((long) data) == -ECONNABORTED) {
00089 
00090     
00091     
00092     
00093     
00094     
00095     
00096     
00097 
00098 
00099     
00100     HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_pre_accept_hangups_stat, 0);
00101   }
00102 
00103   MachineFatal("HTTP accept received fatal error: errno = %d", -((int)(intptr_t)data));
00104   return EVENT_CONT;
00105 }