HttpTransact::HandleICPLookup(State* s)
{
  SET_VIA_STRING(VIA_DETAIL_CACHE_TYPE, VIA_DETAIL_ICP);
  if (s->icp_lookup_success == true) {
    HTTP_INCREMENT_TRANS_STAT(http_icp_suggested_lookups_stat);
    DebugTxn("http_trans", "[HandleICPLookup] Success, sending request to icp suggested host.");
    ats_ip4_set(&s->icp_info.addr, s->icp_ip_result.sin_addr.s_addr);
    s->icp_info.port = ntohs(s->icp_ip_result.sin_port);

    // TODO in this case we should go to the miss case
    // just a little shy about using goto's, that's all.
    ink_release_assert(
        (s->icp_info.port != s->client_info.port) ||
        (ats_ip_addr_cmp(&s->icp_info.addr.sa, &Machine::instance()->ip.sa) != 0)
    );

    // Since the ICPDNSLookup is not called, these two
    //   values are not initialized.
    // Force them to be initialized
    s->icp_info.http_version.set(1, 0);
    if (!s->txn_conf->keep_alive_enabled_out) {
      s->icp_info.keep_alive = HTTP_NO_KEEPALIVE;
    } else {
      s->icp_info.keep_alive = HTTP_KEEPALIVE;
    }

    s->icp_info.name = (char *) s->arena.alloc(17);
    unsigned char *p = (unsigned char *) &s->icp_ip_result.sin_addr.s_addr;
    snprintf(s->icp_info.name, 17, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);

    update_current_info(&s->current, &s->icp_info, ICP_SUGGESTED_HOST, 1);
    s->next_hop_scheme = URL_WKSIDX_HTTP;
  } else {
    SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_NOT_CACHED);
    DebugTxn("http_trans", "[HandleICPLookup] Failure, sending request to forward server.");
    s->parent_info.name = NULL;
    ink_zero(s->parent_info.addr);

    find_server_and_update_current_info(s);
    if (!ats_is_ip(&s->current.server->addr)) {
      if (s->current.request_to == PARENT_PROXY) {
        TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, PPDNSLookup);
      } else {
        ink_release_assert(0);
      }
      return;
    }
  }
  if (!s->stale_icp_lookup) {
    build_request(s, &s->hdr_info.client_request, &s->hdr_info.server_request, s->current.server->http_version);
  } else {
    ink_assert(s->hdr_info.server_request.valid());
    s->stale_icp_lookup = false;
  }
  s->next_action = how_to_open_connection(s);

  return;
}
HttpTransact::HandleICPLookup(State* s)
{
  SET_VIA_STRING(VIA_DETAIL_CACHE_TYPE, VIA_DETAIL_ICP);
  if (s->icp_lookup_success == true) {
    HTTP_INCREMENT_TRANS_STAT(http_icp_suggested_lookups_stat);
    DebugTxn("http_trans", "[HandleICPLookup] Success, sending request to icp suggested host.");
    ats_ip4_set(&s->icp_info.addr, s->icp_ip_result.sin_addr.s_addr);
    s->icp_info.port = ntohs(s->icp_ip_result.sin_port);

     
     
    ink_release_assert(
        (s->icp_info.port != s->client_info.port) ||
        (ats_ip_addr_cmp(&s->icp_info.addr.sa, &Machine::instance()->ip.sa) != 0)
    );

     
     
     
    s->icp_info.http_version.set(1, 0);
    if (!s->txn_conf->keep_alive_enabled_out) {
      s->icp_info.keep_alive = HTTP_NO_KEEPALIVE;
    } else {
      s->icp_info.keep_alive = HTTP_KEEPALIVE;
    }

    s->icp_info.name = (char *) s->arena.alloc(17);
    unsigned char *p = (unsigned char *) &s->icp_ip_result.sin_addr.s_addr;
    snprintf(s->icp_info.name, 17, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);

    update_current_info(&s->current, &s->icp_info, ICP_SUGGESTED_HOST, 1);
    s->next_hop_scheme = URL_WKSIDX_HTTP;
  } else {
    SET_VIA_STRING(VIA_DETAIL_CACHE_LOOKUP, VIA_DETAIL_MISS_NOT_CACHED);
    DebugTxn("http_trans", "[HandleICPLookup] Failure, sending request to forward server.");
    s->parent_info.name = NULL;
    ink_zero(s->parent_info.addr);

    find_server_and_update_current_info(s);
    if (!ats_is_ip(&s->current.server->addr)) {
      if (s->current.request_to == PARENT_PROXY) {
        TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, PPDNSLookup);
      } else {
        ink_release_assert(0);
      }
      return;
    }
  }
  if (!s->stale_icp_lookup) {
    build_request(s, &s->hdr_info.client_request, &s->hdr_info.server_request, s->current.server->http_version);
  } else {
    ink_assert(s->hdr_info.server_request.valid());
    s->stale_icp_lookup = false;
  }
  s->next_action = how_to_open_connection(s);

  return;
}