/*
This file is part of GNUnet
- (C) 2002-2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2002-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
uint32_t tag;
/**
- * ATS network type in NBO
+ * ATS network type.
*/
- uint32_t ats_address_network_type;
+ enum GNUNET_ATS_Network_Type scope;
/**
* #GNUNET_YES if this session is known to the service.
plugin->env->session_end (plugin->env->cls,
s->address,
s);
+ s->known_to_service = GNUNET_NO;
}
if (NULL != s->msg_tk)
{
struct ServerRequest *sc = NULL;
const union MHD_ConnectionInfo *conn_info;
struct HttpAddress *addr;
- struct GNUNET_ATS_Information ats;
struct GNUNET_PeerIdentity target;
size_t addr_len;
struct SessionTagContext stc;
uint32_t options;
int direction = GNUNET_SYSERR;
unsigned int to;
+ enum GNUNET_ATS_Network_Type scope;
conn_info = MHD_get_connection_info (mhd_connection,
MHD_CONNECTION_INFO_CLIENT_ADDRESS);
conn_info->client_addr,
sizeof (struct sockaddr_in));
addr_len = http_common_address_get_size (addr);
- ats = plugin->env->get_address_type (plugin->env->cls,
- conn_info->client_addr,
- sizeof (struct sockaddr_in));
+ scope = plugin->env->get_address_type (plugin->env->cls,
+ conn_info->client_addr,
+ sizeof (struct sockaddr_in));
break;
case (AF_INET6):
addr = http_common_address_from_socket (plugin->protocol,
conn_info->client_addr,
sizeof (struct sockaddr_in6));
addr_len = http_common_address_get_size (addr);
- ats = plugin->env->get_address_type (plugin->env->cls,
- conn_info->client_addr,
- sizeof (struct sockaddr_in6));
+ scope = plugin->env->get_address_type (plugin->env->cls,
+ conn_info->client_addr,
+ sizeof (struct sockaddr_in6));
break;
default:
- /* external host name */
- ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
- ats.type = htonl (GNUNET_ATS_NET_WAN);
+ /* external host name */
return NULL;
}
s = GNUNET_new (struct Session);
s->target = target;
s->plugin = plugin;
+ s->scope = scope;
s->address = GNUNET_HELLO_address_allocate (&s->target,
PLUGIN_NAME,
addr,
addr_len,
GNUNET_HELLO_ADDRESS_INFO_INBOUND);
- s->ats_address_network_type = ats.value;
s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS;
s->tag = stc.tag;
s->timeout = GNUNET_TIME_relative_to_absolute (HTTP_SERVER_SESSION_TIMEOUT);
notify_session_monitor (plugin,
s,
GNUNET_TRANSPORT_SS_UP);
- plugin->env->session_start (NULL,
+ plugin->env->session_start (plugin->env->cls,
s->address,
s,
- NULL, 0);
+ s->scope);
}
- if ( (NULL == s->server_recv) ||
- (NULL == s->server_send) )
- {
- to = (HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL / 1000LL);
- MHD_set_connection_option (mhd_connection,
- MHD_CONNECTION_OPTION_TIMEOUT, to);
- server_reschedule (plugin, sc->mhd_daemon, GNUNET_NO);
- }
- else
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Session %p for peer `%s' fully connected\n",
- s, GNUNET_i2s (&target));
- to = (HTTP_SERVER_SESSION_TIMEOUT.rel_value_us / 1000LL / 1000LL);
- server_mhd_connection_timeout (plugin, s, to);
- }
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Setting timeout for %p to %u sec.\n", sc, to);
+ to = (HTTP_SERVER_SESSION_TIMEOUT.rel_value_us / 1000LL / 1000LL);
+ server_mhd_connection_timeout (plugin, s, to);
return sc;
}
{
struct Session *s = cls;
struct HTTP_Server_Plugin *plugin = s->plugin;
- struct GNUNET_ATS_Information atsi;
struct GNUNET_TIME_Relative delay;
char *stat_txt;
- atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE);
- atsi.value = s->ats_address_network_type;
- GNUNET_break (s->ats_address_network_type !=
- ntohl (GNUNET_ATS_NET_UNSPECIFIED));
-
if (GNUNET_NO == s->known_to_service)
{
s->known_to_service = GNUNET_YES;
- plugin->env->session_start (NULL,
+ plugin->env->session_start (plugin->env->cls,
s->address,
s,
- NULL,
- 0);
+ s->scope);
notify_session_monitor (plugin,
s,
GNUNET_TRANSPORT_SS_UP);
s->address,
s,
message);
- plugin->env->update_address_metrics (plugin->env->cls,
- s->address, s,
- &atsi, 1);
GNUNET_asprintf (&stat_txt,
"# bytes received via %s_server",
plugin->protocol);
http_server_plugin_get_network (void *cls,
struct Session *session)
{
- return ntohl (session->ats_address_network_type);
+ return session->scope;
}