diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-14 08:53:29 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-14 08:53:29 +0000 |
commit | 2a46bac24eaca8ce16d12359e88f4a9d3cf49c28 (patch) | |
tree | 832a1ebc38fd60e512fa69688f94abda5019741b /src/transport/gnunet-service-transport.c | |
parent | 47bd57c6a129474f51001cf02d15a04340d9b834 (diff) | |
download | gnunet-2a46bac24eaca8ce16d12359e88f4a9d3cf49c28.tar.gz gnunet-2a46bac24eaca8ce16d12359e88f4a9d3cf49c28.zip |
removing ats functions from plugins, instead provide callback function
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 644d27e24..8294f35dc 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -360,6 +360,40 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
360 | 360 | ||
361 | 361 | ||
362 | /** | 362 | /** |
363 | * Function that will be called to figure if an address is an loopback, | ||
364 | * LAN, WAN etc. address | ||
365 | * | ||
366 | * @param cls closure | ||
367 | * @param addr binary address | ||
368 | * @param addrlen length of the address | ||
369 | * @return ATS Information containing the network type | ||
370 | */ | ||
371 | static const struct GNUNET_ATS_Information | ||
372 | plugin_env_address_to_type (void *cls, | ||
373 | const struct sockaddr *addr, | ||
374 | size_t addrlen) | ||
375 | { | ||
376 | struct GNUNET_ATS_Information ats; | ||
377 | ats.type = htonl (GNUNET_ATS_NETWORK_TYPE); | ||
378 | ats.value = htonl (GNUNET_ATS_NET_UNSPECIFIED); | ||
379 | if (GST_ats == NULL) | ||
380 | { | ||
381 | GNUNET_break (0); | ||
382 | return ats; | ||
383 | } | ||
384 | if ((addrlen != sizeof (struct sockaddr_in)) && (addrlen != sizeof (struct sockaddr_in6))) | ||
385 | { | ||
386 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed address with length %u `%s'\n", | ||
387 | addrlen, | ||
388 | GNUNET_a2s(addr, addrlen)); | ||
389 | GNUNET_break (0); | ||
390 | return ats; | ||
391 | } | ||
392 | return GNUNET_ATS_address_get_type(GST_ats, addr, addrlen); | ||
393 | } | ||
394 | |||
395 | |||
396 | /** | ||
363 | * Function called by ATS to notify the callee that the | 397 | * Function called by ATS to notify the callee that the |
364 | * assigned bandwidth or address for a given peer was changed. If the | 398 | * assigned bandwidth or address for a given peer was changed. If the |
365 | * callback is called with address/bandwidth assignments of zero, the | 399 | * callback is called with address/bandwidth assignments of zero, the |
@@ -551,7 +585,8 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
551 | GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); | 585 | GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); |
552 | GST_plugins_load (&plugin_env_receive_callback, | 586 | GST_plugins_load (&plugin_env_receive_callback, |
553 | &plugin_env_address_change_notification, | 587 | &plugin_env_address_change_notification, |
554 | &plugin_env_session_end); | 588 | &plugin_env_session_end, |
589 | &plugin_env_address_to_type); | ||
555 | GST_neighbours_start (NULL, &neighbours_connect_notification, | 590 | GST_neighbours_start (NULL, &neighbours_connect_notification, |
556 | &neighbours_disconnect_notification); | 591 | &neighbours_disconnect_notification); |
557 | GST_clients_start (server); | 592 | GST_clients_start (server); |