aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r--src/transport/plugin_transport_http_server.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index 9d956b29d..9d34ef291 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -255,9 +255,9 @@ struct Session
255 uint32_t tag; 255 uint32_t tag;
256 256
257 /** 257 /**
258 * ATS network type in NBO 258 * ATS network type.
259 */ 259 */
260 uint32_t ats_address_network_type; 260 enum GNUNET_ATS_Network_Type scope;
261 261
262 /** 262 /**
263 * #GNUNET_YES if this session is known to the service. 263 * #GNUNET_YES if this session is known to the service.
@@ -1363,13 +1363,13 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin,
1363 struct ServerRequest *sc = NULL; 1363 struct ServerRequest *sc = NULL;
1364 const union MHD_ConnectionInfo *conn_info; 1364 const union MHD_ConnectionInfo *conn_info;
1365 struct HttpAddress *addr; 1365 struct HttpAddress *addr;
1366 struct GNUNET_ATS_Information ats;
1367 struct GNUNET_PeerIdentity target; 1366 struct GNUNET_PeerIdentity target;
1368 size_t addr_len; 1367 size_t addr_len;
1369 struct SessionTagContext stc; 1368 struct SessionTagContext stc;
1370 uint32_t options; 1369 uint32_t options;
1371 int direction = GNUNET_SYSERR; 1370 int direction = GNUNET_SYSERR;
1372 unsigned int to; 1371 unsigned int to;
1372 enum GNUNET_ATS_Network_Type scope;
1373 1373
1374 conn_info = MHD_get_connection_info (mhd_connection, 1374 conn_info = MHD_get_connection_info (mhd_connection,
1375 MHD_CONNECTION_INFO_CLIENT_ADDRESS); 1375 MHD_CONNECTION_INFO_CLIENT_ADDRESS);
@@ -1424,36 +1424,32 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin,
1424 conn_info->client_addr, 1424 conn_info->client_addr,
1425 sizeof (struct sockaddr_in)); 1425 sizeof (struct sockaddr_in));
1426 addr_len = http_common_address_get_size (addr); 1426 addr_len = http_common_address_get_size (addr);
1427 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); 1427 scope = plugin->env->get_address_type (plugin->env->cls,
1428 ats.value = htonl (plugin->env->get_address_type (plugin->env->cls, 1428 conn_info->client_addr,
1429 conn_info->client_addr, 1429 sizeof (struct sockaddr_in));
1430 sizeof (struct sockaddr_in)));
1431 break; 1430 break;
1432 case (AF_INET6): 1431 case (AF_INET6):
1433 addr = http_common_address_from_socket (plugin->protocol, 1432 addr = http_common_address_from_socket (plugin->protocol,
1434 conn_info->client_addr, 1433 conn_info->client_addr,
1435 sizeof (struct sockaddr_in6)); 1434 sizeof (struct sockaddr_in6));
1436 addr_len = http_common_address_get_size (addr); 1435 addr_len = http_common_address_get_size (addr);
1437 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); 1436 scope = plugin->env->get_address_type (plugin->env->cls,
1438 ats.value = htonl (plugin->env->get_address_type (plugin->env->cls, 1437 conn_info->client_addr,
1439 conn_info->client_addr, 1438 sizeof (struct sockaddr_in6));
1440 sizeof (struct sockaddr_in6)));
1441 break; 1439 break;
1442 default: 1440 default:
1443 /* external host name */ 1441 /* external host name */
1444 ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
1445 ats.value = htonl (GNUNET_ATS_NET_WAN);
1446 return NULL; 1442 return NULL;
1447 } 1443 }
1448 s = GNUNET_new (struct Session); 1444 s = GNUNET_new (struct Session);
1449 s->target = target; 1445 s->target = target;
1450 s->plugin = plugin; 1446 s->plugin = plugin;
1447 s->scope = scope;
1451 s->address = GNUNET_HELLO_address_allocate (&s->target, 1448 s->address = GNUNET_HELLO_address_allocate (&s->target,
1452 PLUGIN_NAME, 1449 PLUGIN_NAME,
1453 addr, 1450 addr,
1454 addr_len, 1451 addr_len,
1455 GNUNET_HELLO_ADDRESS_INFO_INBOUND); 1452 GNUNET_HELLO_ADDRESS_INFO_INBOUND);
1456 s->ats_address_network_type = ats.value;
1457 s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS; 1453 s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS;
1458 s->tag = stc.tag; 1454 s->tag = stc.tag;
1459 s->timeout = GNUNET_TIME_relative_to_absolute (HTTP_SERVER_SESSION_TIMEOUT); 1455 s->timeout = GNUNET_TIME_relative_to_absolute (HTTP_SERVER_SESSION_TIMEOUT);
@@ -1526,7 +1522,7 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin,
1526 plugin->env->session_start (plugin->env->cls, 1522 plugin->env->session_start (plugin->env->cls,
1527 s->address, 1523 s->address,
1528 s, 1524 s,
1529 NULL, 0); 1525 s->scope);
1530 } 1526 }
1531 1527
1532 if ( (NULL == s->server_recv) || 1528 if ( (NULL == s->server_recv) ||
@@ -1659,23 +1655,16 @@ server_receive_mst_cb (void *cls,
1659{ 1655{
1660 struct Session *s = cls; 1656 struct Session *s = cls;
1661 struct HTTP_Server_Plugin *plugin = s->plugin; 1657 struct HTTP_Server_Plugin *plugin = s->plugin;
1662 struct GNUNET_ATS_Information atsi;
1663 struct GNUNET_TIME_Relative delay; 1658 struct GNUNET_TIME_Relative delay;
1664 char *stat_txt; 1659 char *stat_txt;
1665 1660
1666 atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE);
1667 atsi.value = s->ats_address_network_type;
1668 GNUNET_break (s->ats_address_network_type !=
1669 ntohl (GNUNET_ATS_NET_UNSPECIFIED));
1670
1671 if (GNUNET_NO == s->known_to_service) 1661 if (GNUNET_NO == s->known_to_service)
1672 { 1662 {
1673 s->known_to_service = GNUNET_YES; 1663 s->known_to_service = GNUNET_YES;
1674 plugin->env->session_start (plugin->env->cls, 1664 plugin->env->session_start (plugin->env->cls,
1675 s->address, 1665 s->address,
1676 s, 1666 s,
1677 NULL, 1667 s->scope);
1678 0);
1679 notify_session_monitor (plugin, 1668 notify_session_monitor (plugin,
1680 s, 1669 s,
1681 GNUNET_TRANSPORT_SS_UP); 1670 GNUNET_TRANSPORT_SS_UP);
@@ -1684,9 +1673,6 @@ server_receive_mst_cb (void *cls,
1684 s->address, 1673 s->address,
1685 s, 1674 s,
1686 message); 1675 message);
1687 plugin->env->update_address_metrics (plugin->env->cls,
1688 s->address, s,
1689 &atsi, 1);
1690 GNUNET_asprintf (&stat_txt, 1676 GNUNET_asprintf (&stat_txt,
1691 "# bytes received via %s_server", 1677 "# bytes received via %s_server",
1692 plugin->protocol); 1678 plugin->protocol);
@@ -3287,7 +3273,7 @@ static enum GNUNET_ATS_Network_Type
3287http_server_plugin_get_network (void *cls, 3273http_server_plugin_get_network (void *cls,
3288 struct Session *session) 3274 struct Session *session)
3289{ 3275{
3290 return ntohl (session->ats_address_network_type); 3276 return session->scope;
3291} 3277}
3292 3278
3293 3279