};
+struct AddressUseMessage
+{
+ struct GNUNET_MessageHeader header;
+
+ struct GNUNET_PeerIdentity peer;
+
+ uint16_t in_use GNUNET_PACKED;
+
+ uint16_t address_length GNUNET_PACKED;
+
+ uint16_t plugin_name_length GNUNET_PACKED;
+
+ uint32_t session_id GNUNET_PACKED;
+
+ /* followed by:
+ - char address[address_length]
+ - char plugin_name[plugin_name_length] (including '\0'-termination).
+ */
+
+};
+
struct AddressDestroyedMessage
{
}
+/**
+ * An address is now in use or not used any more.
+ *
+ * @param sh handle
+ * @param peer identity of the peer
+ * @param plugin_name name of the transport plugin
+ * @param plugin_addr address (if available)
+ * @param plugin_addr_len number of bytes in plugin_addr
+ * @param session session handle
+ * @param in_use GNUNET_YES if this address is now used, GNUNET_NO
+ * if address is not used any more
+ */
+void
+GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ struct Session *session,
+ int in_use)
+{
+ struct PendingMessage *p;
+ struct AddressUseMessage *m;
+ char *pm;
+ size_t namelen;
+ size_t msize;
+
+ namelen = (plugin_name == NULL) ? 0 : strlen (plugin_name) + 1;
+ msize = sizeof (struct AddressUseMessage) + plugin_addr_len + namelen;
+ if ( (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (plugin_addr_len >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
+ (namelen >= GNUNET_SERVER_MAX_MESSAGE_SIZE) )
+ {
+ GNUNET_break (0);
+ return;
+ }
+ p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
+ p->size = msize;
+ p->is_init = GNUNET_NO;
+ m = (struct AddressUseMessage*) &p[1];
+ m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE);
+ m->header.size = htons (msize);
+ m->peer = *peer;
+ m->in_use = htons(in_use);
+ m->address_length = htons (plugin_addr_len);
+ m->plugin_name_length = htons (namelen);
+ m->session_id = htonl (get_session_id (sh, session, peer));
+ pm = (char *) &m[1];
+ memcpy (pm, plugin_addr, plugin_addr_len);
+ memcpy (&pm[plugin_addr_len], plugin_name, namelen);
+ GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head,
+ sh->pending_tail,
+ p);
+
+ do_transmit (sh);
+}
+
/**
* A session got destroyed, stop including it as a valid address.
*
GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS, sizeof (struct RequestAddressMessage)},
{ &GAS_handle_address_update, NULL,
GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, 0},
- { &GAS_handle_address_destroyed, NULL,
+ { &GAS_handle_address_in_use, NULL,
+ GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE, 0},
+ { &GAS_handle_address_destroyed, NULL,
GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, 0},
{ &GAS_handle_reservation_request, NULL,
GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST, sizeof (struct ReservationRequestMessage)},
}
+/**
+ * Handle 'address in use' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ const struct AddressUseMessage * m;
+ const char *address;
+ const char *plugin_name;
+ uint16_t address_length;
+ uint16_t plugin_name_length;
+
+ uint16_t size;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received `%s' message\n",
+ "ADDRESS_IN_USE");
+ size = ntohs (message->size);
+ if (size < sizeof (struct AddressUseMessage))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+ m = (const struct AddressUseMessage*) message;
+
+ address_length = ntohs (m->address_length);
+ plugin_name_length = ntohs (m->plugin_name_length);
+
+ address = (const char*) &m[1];
+ if (plugin_name_length != 0)
+ plugin_name = &address[address_length];
+ else
+ plugin_name = "";
+
+ if ( (address_length +
+ plugin_name_length +
+ sizeof (struct AddressUseMessage) != ntohs (message->size)) ||
+ (plugin_name[plugin_name_length - 1] != '\0') )
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+
+
+/*
+ GAS_addresses_update (&m->peer,
+ plugin_name,
+ address,
+ address_length,
+ ntohl (m->session_id),
+ atsi,
+ ats_count);
+*/
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
/**
* Handle 'address destroyed' messages from clients.
*
const struct GNUNET_MessageHeader *message);
+/**
+ * Handle 'address in use' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_address_in_use (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message);
+
/**
* Handle 'address destroyed' messages from clients.
*
uint32_t ats_count);
+/**
+ * An address is now in use or not used any more.
+ *
+ * @param sh handle
+ * @param peer identity of the peer
+ * @param plugin_name name of the transport plugin
+ * @param plugin_addr address (if available)
+ * @param plugin_addr_len number of bytes in plugin_addr
+ * @param session session handle
+ * @param in_use GNUNET_YES if this address is now used, GNUNET_NO
+ * if address is not used any more
+ */
+void
+GNUNET_ATS_address_in_use (struct GNUNET_ATS_SchedulingHandle *sh,
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ struct Session *session,
+ int in_use);
+
/**
* A session got destroyed, stop including it as a valid address.
*
*/
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE 349
+/**
+ * Type of the 'struct AddressUseMessage' sent by ATS to client
+ * to confirm that an address is used or not used anymore
+ */
+#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE 350
/*******************************************************************************
if (!is_connected(n))
change_state (n, S_CONNECTED);
+ GNUNET_ATS_address_in_use (GST_ats,
+ peer,
+ plugin_name,
+ sender_address,
+ sender_address_len,
+ session,
+ GNUNET_YES);
+
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Setting inbound quota of %u for peer `%s' to \n",
was_connected = is_connected(n);
change_state (n, S_CONNECTED);
+ GNUNET_ATS_address_in_use (GST_ats,
+ peer,
+ plugin_name,
+ sender_address,
+ sender_address_len,
+ session,
+ GNUNET_YES);
+
GST_neighbours_set_incoming_quota(&n->id, n->bandwidth_in);
if (n->keepalive_task == GNUNET_SCHEDULER_NO_TASK)
"Sending outbound quota of %u Bps for peer `%s' to all clients\n",
ntohl (n->bandwidth_out.value__), GNUNET_i2s (peer));
#endif
-
q_msg.header.size = htons (sizeof (struct QuotaSetMessage));
q_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA);
q_msg.quota = n->bandwidth_out;
q_msg.peer = (*peer);
GST_clients_broadcast (&q_msg.header, GNUNET_NO);
-
}
struct BlackListCheckContext