return;
}
}
+
+ if (NULL == sh->suggest_cb)
+ return;
+
address.peer = m->peer;
address.address = plugin_address;
address.address_length = plugin_address_length;
return NULL;
}
+/**
+ * Convert a ATS property to a string
+ *
+ * @param type the atsi type
+ * @return a string or NULL if invalid
+ */
+const char *
+GNUNET_ATS_print_property_type (uint32_t type)
+{
+ char *props[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings;
+ if ((type > 0) && (type < GNUNET_ATS_PropertyCount))
+ return props[type];
+ return NULL;
+}
+
/**
* Returns where the address is located: LAN or WAN or ...
}
+/**
+ * Test if a address and a session is known to ATS
+ *
+ * @param sh the scheduling handle
+ * @param address the address
+ * @param session the session
+ * @return GNUNET_YES or GNUNET_NO
+ */
+int
+GNUNET_ATS_session_known (struct GNUNET_ATS_SchedulingHandle *sh,
+ const struct GNUNET_HELLO_Address *address,
+ struct Session *session)
+{
+ int s;
+ if (NULL != session)
+ {
+ if (NOT_FOUND != (s = find_session_id (sh, session, &address->peer)))
+ {
+ /* Existing */
+ return GNUNET_YES;
+ }
+ return GNUNET_NO;
+ }
+ return GNUNET_NO;
+}
+
/**
* We have a new address ATS should know. Addresses have to be added with this
* function before they can be: updated, set in use and destroyed
if (NULL != session)
{
- s = find_session_id (sh, session, &address->peer);
- if (NOT_FOUND != s)
+ if (NOT_FOUND != (s = find_session_id (sh, session, &address->peer)))
{
/* Already existing, nothing todo */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding duplicate address for peer `%s', plugin `%s', session %p id %u\n",
- GNUNET_i2s (&address->peer),
- address->transport_name, session, s);
return GNUNET_SYSERR;
}
s = find_empty_session_slot (sh, session, &address->peer);
* @param session session handle, can be NULL
* @param ats performance data for the address
* @param ats_count number of performance records in 'ats'
+ * @return GNUNET_YES on success, GNUNET_NO if address or session are unknown,
+ * GNUNET_SYSERR on hard failure
*/
-void
+int
GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
const struct GNUNET_HELLO_Address *address,
struct Session *session,
size_t msize;
uint32_t s = 0;
- if (address == NULL)
+ if (NULL == address)
{
GNUNET_break (0);
- return;
+ return GNUNET_SYSERR;
+ }
+ if (NULL == sh)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
}
- namelen =
- (address->transport_name ==
+ namelen = (address->transport_name ==
NULL) ? 0 : strlen (address->transport_name) + 1;
msize =
sizeof (struct AddressUpdateMessage) + address->address_length +
GNUNET_SERVER_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_ATS_Information)))
{
GNUNET_break (0);
- return;
+ return GNUNET_SYSERR;
}
if (NULL != session)
{
s = find_session_id (sh, session, &address->peer);
if (NOT_FOUND == s)
- {
- return;
- /* FIXME */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Update for unknown address for peer `%s', plugin `%s', session %p id %u\n",
- GNUNET_i2s (&address->peer),
- address->transport_name, session, s);
-
- GNUNET_break (0);
- }
+ return GNUNET_NO;
}
p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
memcpy (&pm[address->address_length], address->transport_name, namelen);
GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p);
do_transmit (sh);
- return;
+ return GNUNET_YES;
}