GNUNET_break(0);
return GNUNET_SYSERR;
}
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- _("Received %s message\n"),
- "ATS_ADDRESSLIST_RESPONSE");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Received %s message\n"),
+ "ATS_ADDRESSLIST_RESPONSE");
pi = (const struct PeerInformationMessage *) msg;
id = ntohl (pi->id);
}
memset (&allzeros, '\0', sizeof(allzeros));
- if ((0 == memcmp (&allzeros, &pi->peer, sizeof(allzeros)))
- && (0 == plugin_name_length) && (0 == plugin_address_length)
- && (0 == ats_count))
+ if ( (0 == memcmp (&allzeros, &pi->peer, sizeof(allzeros))) &&
+ (0 == plugin_name_length) &&
+ (0 == plugin_address_length) &&
+ (0 == ats_count) )
{
/* Done */
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, _("Received last message for %s \n"),
- "ATS_ADDRESSLIST_RESPONSE");
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ _("Received last message for %s \n"),
+ "ATS_ADDRESSLIST_RESPONSE");
bandwidth_zero.value__ = htonl (0);
+ GNUNET_CONTAINER_DLL_remove (ph->addresslist_head,
+ ph->addresslist_tail,
+ alh);
if (NULL != alh->cb)
- alh->cb (ph->addr_info_cb_cls, NULL, GNUNET_NO, bandwidth_zero,
- bandwidth_zero, NULL, 0);
- GNUNET_CONTAINER_DLL_remove(ph->addresslist_head, ph->addresslist_tail,
- alh);
- GNUNET_free(alh);
+ alh->cb (ph->addr_info_cb_cls,
+ NULL,
+ GNUNET_NO,
+ bandwidth_zero,
+ bandwidth_zero,
+ NULL, 0);
+ GNUNET_free (alh);
return GNUNET_OK;
}
struct PendingMessage *p;
struct AddressListRequestMessage *m;
- GNUNET_assert(NULL != handle);
if (NULL == infocb)
- return NULL ;
-
+ return NULL;
alh = GNUNET_new (struct GNUNET_ATS_AddressListHandle);
alh->id = handle->id;
handle->id++;
alh->ph = handle;
alh->all_addresses = all;
if (NULL == peer)
+ {
alh->all_peers = GNUNET_YES;
+ }
else
{
alh->all_peers = GNUNET_NO;
alh->peer = (*peer);
}
-
- GNUNET_CONTAINER_DLL_insert(handle->addresslist_head,
- handle->addresslist_tail, alh);
+ GNUNET_CONTAINER_DLL_insert (handle->addresslist_head,
+ handle->addresslist_tail,
+ alh);
p = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct AddressListRequestMessage));
- p->size = sizeof(struct AddressListRequestMessage);
+ sizeof (struct AddressListRequestMessage));
+ p->size = sizeof (struct AddressListRequestMessage);
m = (struct AddressListRequestMessage *) &p[1];
m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST);
m->header.size = htons (sizeof(struct AddressListRequestMessage));
m->id = htonl (alh->id);
if (NULL != peer)
m->peer = *peer;
- else
- {
- memset (&m->peer, '\0', sizeof(struct GNUNET_PeerIdentity));
- }
GNUNET_CONTAINER_DLL_insert_tail(handle->pending_head,
handle->pending_tail,
p);
-
do_transmit (handle);
return alh;
/**
* Cancel a pending address listing operation
*
- * @param handle the GNUNET_ATS_AddressListHandle handle to cancel
+ * @param handle the handle of the request to cancel
*/
void
GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *handle)
/**
- * Convert a GNUNET_ATS_PreferenceType to a string
+ * Convert a `enum GNUNET_ATS_PreferenceType` to a string
*
* @param type the preference type
* @return a string or NULL if invalid
char *prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceTypeString;
if (type < GNUNET_ATS_PreferenceCount)
return prefs[type];
- return NULL ;
+ return NULL;
}
case GNUNET_ATS_PREFERENCE_BANDWIDTH:
count++;
(void) va_arg (ap, double);
-
break;
case GNUNET_ATS_PREFERENCE_LATENCY:
count++;
(void) va_arg (ap, double);
-
break;
default:
GNUNET_assert(0);
}
}
va_end(ap);
- GNUNET_CONTAINER_DLL_insert_tail(ph->pending_head, ph->pending_tail, p);
+ GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head,
+ ph->pending_tail,
+ p);
do_transmit (ph);
}
/**
- * FIXME.
+ * Send a #GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_RESPONSE with the
+ * given address details to the client identified in @a ai.
+ *
+ * @param ai our address information context (identifies the client)
+ * @param id the peer id this address is for
+ * @param plugin_name name of the plugin that supports this address
+ * @param plugin_addr address
+ * @param plugin_addr_len length of @a plugin_addr
+ * @param active #GNUNET_YES if this address is actively used
+ * @param atsi ats performance information
+ * @param atsi_count number of ats performance elements in @a atsi
+ * @param bandwidth_out current outbound bandwidth assigned to address
+ * @param bandwidth_in current inbound bandwidth assigned to address
*/
static void
transmit_req_addr (struct AddressIteration *ai,
const struct GNUNET_PeerIdentity *id,
const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
int active,
const struct GNUNET_ATS_Information *atsi,
uint32_t atsi_count,
/* Transmit result */
if ((GNUNET_YES == ai->all) || (GNUNET_YES == active))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending result for %s peer `%s' plugin `%s' BW out %u, BW in %u\n",
- (active == GNUNET_YES) ? "ACTIVE" : "INACTIVE",
- GNUNET_i2s (id),
- plugin_name,
- (unsigned int) ntohl (bandwidth_out.value__),
- (unsigned int) ntohl (bandwidth_in.value__));
- transmit_req_addr (cls,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending result for %s peer `%s' plugin `%s' BW out %u, BW in %u\n",
+ (active == GNUNET_YES) ? "ACTIVE" : "INACTIVE",
+ GNUNET_i2s (id),
+ plugin_name,
+ (unsigned int) ntohl (bandwidth_out.value__),
+ (unsigned int) ntohl (bandwidth_in.value__));
+ transmit_req_addr (ai,
id,
plugin_name,
plugin_addr, plugin_addr_len,
uint32_t ats_count)
{
static int counter = 0;
+
if (NULL == address)
{
- phal = 0;
+ phal = NULL;
if (2 == counter)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
}
else
{
+ fprintf (stderr,
+ "Expected 2 addresses, got %d\n",
+ counter);
GNUNET_break (0);
GNUNET_SCHEDULER_shutdown ();
}
static int
-stat_cb(void *cls, const char *subsystem,
- const char *name, uint64_t value,
- int is_persistent)
+stat_cb (void *cls, const char *subsystem,
+ const char *name, uint64_t value,
+ int is_persistent)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
if (NULL == (perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to connect to performance API\n");
+ "Failed to connect to performance API\n");
GNUNET_SCHEDULER_shutdown ();
return GNUNET_SYSERR;
}
phal = NULL;
}
- if (perf_ats != NULL)
+ if (NULL != perf_ats)
{
GNUNET_ATS_performance_done (perf_ats);
perf_ats = NULL;