int broadcast_ipv6_mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; struct Mstv6Context *mc = client; const struct GNUNET_MessageHeader *hello; struct UDP_Beacon_Message *msg; msg = (struct UDP_Beacon_Message *) message; if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON != ntohs (msg->header.type)) return GNUNET_OK; LOG (GNUNET_ERROR_TYPE_DEBUG, "Received beacon with %u bytes from peer `%s' via address `%s'\n", ntohs (msg->header.size), GNUNET_i2s (&msg->sender), udp_address_to_string (NULL, &mc->addr, sizeof (mc->addr))); struct GNUNET_ATS_Information atsi[2]; /* setup ATS */ atsi[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); atsi[0].value = htonl (1); atsi[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); atsi[1].value = mc->ats_address_network_type; GNUNET_break (ntohl(mc->ats_address_network_type) != GNUNET_ATS_NET_UNSPECIFIED); hello = (struct GNUNET_MessageHeader *) &msg[1]; plugin->env->receive (plugin->env->cls, &msg->sender, hello, (const struct GNUNET_ATS_Information *) &atsi, 2, NULL, (const char *) &mc->addr, sizeof (mc->addr)); GNUNET_STATISTICS_update (plugin->env->stats, _ ("# IPv6 multicast HELLO beacons received via udp"), 1, GNUNET_NO); GNUNET_free (mc); return GNUNET_OK; }
/** * Parse broadcast message received. * * @param cls the `struct Plugin` * @param client the `struct MstContext` with sender address * @param message the message we received * @return #GNUNET_OK (always) */ static int broadcast_mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message) { struct Plugin *plugin = cls; struct MstContext *mc = client; struct GNUNET_HELLO_Address *address; const struct GNUNET_MessageHeader *hello; const struct UDP_Beacon_Message *msg; msg = (const struct UDP_Beacon_Message *) message; if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON != ntohs (msg->header.type)) return GNUNET_OK; LOG (GNUNET_ERROR_TYPE_DEBUG, "Received beacon with %u bytes from peer `%s' via address `%s'\n", ntohs (msg->header.size), GNUNET_i2s (&msg->sender), udp_address_to_string (NULL, mc->udp_addr, mc->udp_addr_len)); hello = (struct GNUNET_MessageHeader *) &msg[1]; address = GNUNET_HELLO_address_allocate (&msg->sender, PLUGIN_NAME, mc->udp_addr, mc->udp_addr_len, GNUNET_HELLO_ADDRESS_INFO_NONE); plugin->env->receive (plugin->env->cls, address, NULL, hello); GNUNET_HELLO_address_free (address); GNUNET_STATISTICS_update (plugin->env->stats, _("# Multicast HELLO beacons received via UDP"), 1, GNUNET_NO); return GNUNET_OK; }