/** * Function that will be called for each address the transport * is aware that it might be reachable under. Update our HELLO. * * @param cls name of the plugin (const char*) * @param add_remove should the address added (YES) or removed (NO) from the * set of valid addresses? * @param addr one of the addresses of the host * the specific address format depends on the transport * @param addrlen length of the address */ static void plugin_env_address_change_notification (void *cls, int add_remove, const void *addr, size_t addrlen) { const char *plugin_name = cls; struct GNUNET_HELLO_Address address; address.peer = GST_my_identity; address.transport_name = plugin_name; address.address = addr; address.address_length = addrlen; GST_hello_modify_addresses (add_remove, &address); }
/** * Function that will be called for each address the transport * is aware that it might be reachable under. Update our HELLO. * * @param cls name of the plugin (const char*) * @param add_remove should the address added (YES) or removed (NO) from the * set of valid addresses? * @param address the address to add or remove */ static void plugin_env_address_change_notification (void *cls, int add_remove, const struct GNUNET_HELLO_Address *address) { static int addresses = 0; struct GNUNET_STATISTICS_Handle *cfg = GST_stats; if (GNUNET_YES == add_remove) { addresses ++; GNUNET_STATISTICS_update (cfg, "# transport addresses", 1, GNUNET_NO); } else if (GNUNET_NO == add_remove) { if (0 == addresses) { GNUNET_break (0); } else { addresses --; GNUNET_STATISTICS_update (cfg, "# transport addresses", -1, GNUNET_NO); } } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Transport now has %u addresses to communicate\n", addresses); GST_hello_modify_addresses (add_remove, address); }