/**
* Hashmap with all routes that we currently support; contains
* routing information for all peers from distance 2
- * up to distance DEFAULT_FISHEYE_DEPTH.
+ * up to distance #DEFAULT_FISHEYE_DEPTH.
*/
static struct GNUNET_CONTAINER_MultiPeerMap *all_routes;
dn->cth =
GNUNET_CORE_notify_transmit_ready (core_api,
GNUNET_YES /* cork */,
- 0 /* priority */,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_TIME_UNIT_FOREVER_REL,
&dn->peer,
msize,
if (NULL == target->cth)
target->cth = GNUNET_CORE_notify_transmit_ready (core_api,
GNUNET_YES /* cork */,
- 0 /* priority */,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_TIME_UNIT_FOREVER_REL,
&target->peer,
msize,
*
* @param cls closure
* @param address the address
- * @param active is this address in active use
+ * @param active #GNUNET_YES if this address is actively used
+ * to maintain a connection to a peer;
+ * #GNUNET_NO if the address is not actively used;
+ * #GNUNET_SYSERR if this address is no longer available for ATS
* @param bandwidth_out assigned outbound bandwidth for the connection
* @param bandwidth_in assigned inbound bandwidth for the connection
* @param ats performance data for the address (as far as known)
uint32_t distance;
enum GNUNET_ATS_Network_Type network = GNUNET_ATS_NET_UNSPECIFIED;
- if (GNUNET_NO == active)
+ if (NULL == address)
+ {
+ /* ATS service temporarily disconnected */
+ return;
+ }
+
+ if (GNUNET_YES != active)
+ {
+ // FIXME: handle disconnect/inactive case too!
return;
+ }
distance = get_atsi_distance (ats, ats_count);
network = get_atsi_network (ats, ats_count);
GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network);
enum GNUNET_SET_Status status)
{
struct DirectNeighbor *neighbor = cls;
+ struct DirectNeighbor *dn;
struct Target *target;
char *status_str;
GNUNET_break_op (0);
return;
}
- if (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_contains (direct_neighbors,
- &((struct Target *) element->data)->peer))
+ if ( (NULL != (dn = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, &((struct Target *) element->data)->peer))) && (DIRECT_NEIGHBOR_COST == dn->distance) )
{
/* this is a direct neighbor of ours, we do not care about routes
to this peer */
const struct GNUNET_MessageHeader *payload;
struct Route *route;
struct DirectNeighbor *neighbor;
+ struct DirectNeighbor *dn;
struct Target *target;
uint32_t distance;
char me[5];
&my_identity,
sizeof (struct GNUNET_PeerIdentity)))
{
+ if ((NULL
+ != (dn = GNUNET_CONTAINER_multipeermap_get (direct_neighbors,
+ &rm->sender))) && (DIRECT_NEIGHBOR_COST == dn->distance))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Discarding DV message, as %s is a direct neighbor\n",
+ GNUNET_i2s (&rm->sender));
+ GNUNET_STATISTICS_update (stats,
+ "# messages discarded (direct neighbor)",
+ 1, GNUNET_NO);
+ return GNUNET_OK;
+ }
/* message is for me, check reverse route! */
route = GNUNET_CONTAINER_multipeermap_get (all_routes,
&rm->sender);
if ( (NULL == route) &&
- (NULL == GNUNET_CONTAINER_multipeermap_get (direct_neighbors,
- &rm->sender)) &&
(distance < DEFAULT_FISHEYE_DEPTH) )
{
/* don't have reverse route yet, learn it! */
{
GNUNET_break_op (0);
GNUNET_free (target);
+ return GNUNET_SYSERR;
}
add_new_route (target, neighbor);
}
if (NULL == route)
{
/* got disconnected */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No route to %s, dropping local message of type %u\n",
+ GNUNET_i2s (&msg->target),
+ ntohs (payload->type));
GNUNET_STATISTICS_update (stats,
"# local messages discarded (no route)",
1, GNUNET_NO);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Forwarding %u bytes to %s\n",
+ "Forwarding %u bytes of type %u to %s\n",
ntohs (payload->size),
+ ntohs (payload->type),
GNUNET_i2s (&msg->target));
forward_payload (route->next_hop,
- ntohl (route->target.distance),
+ 0 /* first hop, distance is zero */,
htonl (msg->uid),
&my_identity,
&msg->target,