struct GNUNET_DV_ConnectMessage
{
/**
- * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_CONNECT
+ * Type: #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_CONNECT
*/
struct GNUNET_MessageHeader header;
uint32_t distance GNUNET_PACKED;
/**
- * The network the peer is in
+ * The other peer (at the given distance).
*/
- uint32_t network GNUNET_PACKED;
+ struct GNUNET_PeerIdentity peer;
/**
- * The other peer (at the given distance).
+ * The network the peer is in
*/
- struct GNUNET_PeerIdentity peer;
+ uint32_t network GNUNET_PACKED;
};
struct GNUNET_DV_DisconnectMessage
{
/**
- * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_DISCONNECT
+ * Type: #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_DISCONNECT
*/
struct GNUNET_MessageHeader header;
struct GNUNET_DV_ReceivedMessage
{
/**
- * Type: GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECV
+ * Type: #GNUNET_MESSAGE_TYPE_TRANSPORT_DV_RECV
*/
struct GNUNET_MessageHeader header;
struct GNUNET_DV_SendMessage
{
/**
- * Type: GNUNET_MESSAGE_TYPE_DV_SEND
+ * Type: #GNUNET_MESSAGE_TYPE_DV_SEND
*/
struct GNUNET_MessageHeader header;
struct GNUNET_DV_AckMessage
{
/**
- * Type: GNUNET_MESSAGE_TYPE_DV_SEND_ACK or
- * GNUNET_MESSAGE_TYPE_DV_SEND_NACK.
+ * Type: #GNUNET_MESSAGE_TYPE_DV_SEND_ACK or
+ * #GNUNET_MESSAGE_TYPE_DV_SEND_NACK.
*/
struct GNUNET_MessageHeader header;
struct GNUNET_DV_DistanceUpdateMessage
{
/**
- * Type: GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED.
+ * Type: #GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED.
*/
struct GNUNET_MessageHeader header;
*/
struct GNUNET_PeerIdentity peer;
+ /**
+ * The network the peer is in
+ */
+ uint32_t network GNUNET_PACKED;
+
};
dum = (const struct GNUNET_DV_DistanceUpdateMessage *) msg;
sh->distance_cb (sh->cls,
&dum->peer,
- ntohl (dum->distance));
+ ntohl (dum->distance),
+ ntohl (dum->network));
break;
case GNUNET_MESSAGE_TYPE_DV_DISCONNECT:
if (ntohs (msg->size) != sizeof (struct GNUNET_DV_DisconnectMessage))
* @param cls closure
* @param peer connected peer
* @param distance new distance to the peer
+ * @param network network used on first hop to peer
*/
static void
change_cb (void *cls,
const struct GNUNET_PeerIdentity *peer,
- uint32_t distance)
+ uint32_t distance,
+ uint32_t network)
{
fprintf (stderr, "Change: %s at %u\n",
GNUNET_i2s (peer),
*
* @param peer peer with a changed distance
* @param distance new distance to the peer
+ * @param network network used by the neighbor
*/
static void
send_distance_change_to_plugin (const struct GNUNET_PeerIdentity *peer,
- uint32_t distance)
+ uint32_t distance,
+ uint32_t network)
{
struct GNUNET_DV_DistanceUpdateMessage du_msg;
du_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISTANCE_CHANGED);
du_msg.distance = htonl (distance);
du_msg.peer = *peer;
+ du_msg.network = htonl (network);
send_control_to_plugin (&du_msg.header);
}
move_route (route, ntohl (target->distance) + 1);
route->next_hop = neighbor;
send_distance_change_to_plugin (&target->peer,
- ntohl (target->distance) + 1);
+ ntohl (target->distance) + 1,
+ neighbor->network);
}
return GNUNET_YES; /* got a route to this target already */
}
/* distance decreased, update route */
move_route (current_route,
ntohl (target->distance) + 1);
- send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 1);
+ send_distance_change_to_plugin (&target->peer,
+ ntohl (target->distance) + 1,
+ neighbor->network);
}
}
return GNUNET_OK;
move_route (current_route, ntohl (target->distance) + 1);
current_route->next_hop = neighbor;
- send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 1);
+ send_distance_change_to_plugin (&target->peer,
+ ntohl (target->distance) + 1,
+ neighbor->network);
return GNUNET_OK;
}
/* new route */
struct Session *session;
struct GNUNET_ATS_Information ats[2];
+ GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network);
/**
* This requires transport plugin to be linked to libgnunetats.
* If you remove it, also remove libgnunetats linkage from Makefile.am
* @param cls closure with `struct Plugin *`
* @param peer connected peer
* @param distance new distance to the peer
+ * @param network network type used for the connection
*/
static void
handle_dv_distance_changed (void *cls,
const struct GNUNET_PeerIdentity *peer,
- uint32_t distance)
+ uint32_t distance,
+ uint32_t network)
{
struct Plugin *plugin = cls;
struct Session *session;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message for peer `%s': new distance %u\n",
- "DV_DISTANCE_CHANGED",
- GNUNET_i2s (peer), distance);
-
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' message for peer `%s': new distance %u\n",
+ "DV_DISTANCE_CHANGED",
+ GNUNET_i2s (peer),
+ distance);
session = GNUNET_CONTAINER_multipeermap_get (plugin->sessions,
peer);
if (NULL == session)
{
GNUNET_break (0);
- /* FIXME */
- handle_dv_connect (plugin, peer, distance, 0);
+ handle_dv_connect (plugin, peer, distance, network);
return;
}
session->distance = distance;
*/
typedef void (*GNUNET_DV_ConnectCallback)(void *cls,
const struct GNUNET_PeerIdentity *peer,
- uint32_t distance, uint32_t network);
+ uint32_t distance,
+ uint32_t network);
/**
* @param cls closure
* @param peer connected peer
* @param distance new distance to the peer
+ * @param network this network will be used to reach the next hop
*/
typedef void (*GNUNET_DV_DistanceChangedCallback)(void *cls,
const struct GNUNET_PeerIdentity *peer,
- uint32_t distance);
+ uint32_t distance,
+ uint32_t network);
/**