struct GNUNET_CONTAINER_MultiHashMap *blacklist;
};
-struct NeighbourList;
+struct NeighbourMapEntry;
/**
* For each neighbour we keep a list of messages
/**
* To which neighbour does this ready list belong to?
*/
- struct NeighbourList *neighbour;
+ struct NeighbourMapEntry *neighbour;
};
/**
- * Entry in neighbours. (not a 'List' -- bad name!)
+ * Entry in neighbours.
*/
-struct NeighbourList
+struct NeighbourMapEntry
{
/**
* disconnected or must we ask all plugins to
* disconnect?
*/
-static void disconnect_neighbour (struct NeighbourList *n, int check);
+static void disconnect_neighbour (struct NeighbourMapEntry *n, int check);
/**
* Check the ready list for the given neighbour and if a plugin is
*
* @param nexi target peer for which to transmit
*/
-static void try_transmission_to_peer (struct NeighbourList *n);
+static void try_transmission_to_peer (struct NeighbourMapEntry *n);
struct ForeignAddressList * get_preferred_ats_address (
- struct NeighbourList *n);
+ struct NeighbourMapEntry *n);
/**
* Find an entry in the neighbour list for a particular peer.
*
* @return NULL if not found.
*/
-static struct NeighbourList *
+static struct NeighbourMapEntry *
find_neighbour (const struct GNUNET_PeerIdentity *key)
{
return GNUNET_CONTAINER_multihashmap_get (neighbours, &key->hashPubKey);
p = find_transport (plugin);
if ((p == NULL) || (addr_len == 0) || (addr == NULL))
return NULL;
-
return p->api->address_to_string (NULL,
addr,
addr_len);
- return NULL;
}
struct ClientMessageQueueEntry *q;
uint16_t msize;
+ /* Client==NULL when GNUNET_SERVER_Client disconnected and was
+ * freed in client_disconnect_notification
+ */
+ if (client->client == NULL)
+ {
+ GNUNET_break (0);
+ return;
+ }
+
if ((client->message_count >= MAX_PENDING) && (GNUNET_YES == may_drop))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
*/
static void
transmit_send_ok (struct TransportClient *client,
- struct NeighbourList *n,
+ struct NeighbourMapEntry *n,
const struct GNUNET_PeerIdentity *target,
int result)
{
retry_transmission_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct NeighbourList *n = cls;
+ struct NeighbourMapEntry *n = cls;
n->retry_task = GNUNET_SCHEDULER_NO_TASK;
try_transmission_to_peer (n);
int result)
{
struct MessageQueue *mq = cls;
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# bytes pending with plugins"),
* @param neighbour target peer for which to transmit
*/
static void
-try_transmission_to_peer (struct NeighbourList *n)
+try_transmission_to_peer (struct NeighbourMapEntry *n)
{
struct ReadyList *rl;
struct MessageQueue *mq;
struct GNUNET_TIME_Relative timeout,
const char *message_buf,
size_t message_buf_size,
- int is_internal, struct NeighbourList *neighbour)
+ int is_internal, struct NeighbourMapEntry *neighbour)
{
struct MessageQueue *mq;
* @param n neighbour to PING
*/
static void
-transmit_plain_ping (struct NeighbourList *n)
+transmit_plain_ping (struct NeighbourMapEntry *n)
{
struct ValidationEntry *ve;
struct TransportPingMessage ping;
* @return selected address, NULL if we have none
*/
struct ForeignAddressList *
-find_ready_address(struct NeighbourList *neighbour)
+find_ready_address(struct NeighbourMapEntry *neighbour)
{
struct ReadyList *head = neighbour->plugins;
struct ForeignAddressList *addresses;
const GNUNET_HashCode *key,
void *value)
{
- struct NeighbourList *npos = value;
+ struct NeighbourMapEntry *npos = value;
if (GNUNET_YES != npos->received_pong)
return GNUNET_OK;
*/
static void
try_fast_reconnect (struct TransportPlugin *p,
- struct NeighbourList *nl)
+ struct NeighbourMapEntry *nl)
{
/* FIXME-MW: fast reconnect / transport switching not implemented... */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
struct Session *session)
{
struct TransportPlugin *p = cls;
- struct NeighbourList *nl;
+ struct NeighbourMapEntry *nl;
struct ReadyList *rl;
struct ForeignAddressList *pos;
struct ForeignAddressList *prev;
* @return NULL if no such entry exists
*/
static struct ForeignAddressList *
-find_peer_address(struct NeighbourList *neighbour,
+find_peer_address(struct NeighbourMapEntry *neighbour,
const char *tname,
struct Session *session,
const char *addr,
* @return NULL if we do not have a transport plugin for 'tname'
*/
static struct ForeignAddressList *
-add_peer_address (struct NeighbourList *neighbour,
+add_peer_address (struct NeighbourMapEntry *neighbour,
const char *tname,
struct Session *session,
const char *addr,
neighbour_timeout_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct NeighbourList *n = cls;
+ struct NeighbourMapEntry *n = cls;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
* Add the given address to the list of foreign addresses
* available for the given peer (check for duplicates).
*
- * @param cls the respective 'struct NeighbourList' to update
+ * @param cls the respective 'struct NeighbourMapEntry' to update
* @param tname name of the transport
* @param expiration expiration time
* @param addr the address
const void *addr,
uint16_t addrlen)
{
- struct NeighbourList *n = cls;
+ struct NeighbourMapEntry *n = cls;
struct ForeignAddressList *fal;
int try;
* Add addresses in validated HELLO "h" to the set of addresses
* we have for this peer.
*
- * @param cls closure ('struct NeighbourList*')
+ * @param cls closure ('struct NeighbourMapEntry*')
* @param peer id of the peer, NULL for last call
* @param h hello message for the peer (can be NULL)
* @param err_msg NULL if successful, otherwise contains error message
const struct GNUNET_HELLO_Message *h,
const char *err_msg)
{
- struct NeighbourList *n = cls;
+ struct NeighbourMapEntry *n = cls;
if (err_msg != NULL)
{
* @param do_hello should we schedule transmitting a HELLO
* @return the new neighbour list entry
*/
-static struct NeighbourList *
+static struct NeighbourMapEntry *
setup_new_neighbour (const struct GNUNET_PeerIdentity *peer,
int do_hello)
{
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
struct TransportPlugin *tp;
struct ReadyList *rl;
gettext_noop ("# active neighbours"),
1,
GNUNET_NO);
- n = GNUNET_malloc (sizeof (struct NeighbourList));
+ n = GNUNET_malloc (sizeof (struct NeighbourMapEntry));
n->id = *peer;
n->peer_timeout =
GNUNET_TIME_relative_to_absolute
* @param n NULL if communication is not acceptable
*/
typedef void (*SetupContinuation)(void *cls,
- struct NeighbourList *n);
+ struct NeighbourMapEntry *n);
/**
/**
- * Obtain a 'struct NeighbourList' for the given peer. If such an entry
+ * Obtain a 'struct NeighbourMapEntry' for the given peer. If such an entry
* does not yet exist, check the blacklist. If the blacklist says creating
* one is acceptable, create one and call the continuation; otherwise
* call the continuation with NULL.
*
- * @param peer peer to setup or look up a struct NeighbourList for
+ * @param peer peer to setup or look up a struct NeighbourMapEntry for
* @param do_hello should we also schedule sending our HELLO to the peer
* if this is a new record
* @param cont function to call with the 'struct NeigbhbourList*'
SetupContinuation cont,
void *cont_cls)
{
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
struct BlacklistCheck *bc;
n = find_neighbour(peer);
* Function called with the result of querying a new blacklister about
* it being allowed (or not) to continue to talk to an existing neighbour.
*
- * @param cls the original 'struct NeighbourList'
+ * @param cls the original 'struct NeighbourMapEntry'
* @param n NULL if we need to disconnect
*/
static void
confirm_or_drop_neighbour (void *cls,
- struct NeighbourList *n)
+ struct NeighbourMapEntry *n)
{
- struct NeighbourList * orig = cls;
+ struct NeighbourMapEntry * orig = cls;
if (n == NULL)
{
void *value)
{
struct TestConnectionContext *tcc = cls;
- struct NeighbourList *n = value;
+ struct NeighbourMapEntry *n = value;
struct BlacklistCheck *bc;
struct ForeignAddressList *peer_address = cls;
struct TransportPlugin *tp;
struct ValidationEntry *va;
- struct NeighbourList *neighbour;
+ struct NeighbourMapEntry *neighbour;
struct TransportPingMessage ping;
struct CheckAddressExistsClosure caec;
char * message_buf;
*/
static void
handle_payload_message (const struct GNUNET_MessageHeader *message,
- struct NeighbourList *n)
+ struct NeighbourMapEntry *n)
{
struct InboundMessage *im;
struct TransportClient *cpos;
unsigned int challenge = ntohl(pong->challenge);
struct GNUNET_HELLO_Message *hello;
struct GNUNET_PeerIdentity target;
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
struct ForeignAddressList *fal;
struct OwnAddressList *oal;
struct TransportPlugin *tp;
*/
static void
transmit_hello_and_ping (void *cls,
- struct NeighbourList *neighbour)
+ struct NeighbourMapEntry *neighbour)
{
struct ValidationEntry *va = cls;
struct ForeignAddressList *peer_address;
struct GNUNET_HELLO_Message *plain_hello;
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pk;
struct GNUNET_PeerIdentity target;
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
if (err_msg != NULL)
{
const struct GNUNET_HELLO_Message *hello;
struct CheckHelloValidatedContext *chvc;
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded publicKey;
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
#if DEBUG_TRANSPORT_HELLO > 2
char *my_id;
#endif
}
#if BREAK_TESTS
- struct NeighbourList *temp_neighbor = find_neighbour(&target);
+ struct NeighbourMapEntry *temp_neighbor = find_neighbour(&target);
if ((NULL != temp_neighbor))
{
fprintf(stderr, "Already know peer, ignoring hello\n");
* regardless of whether other addresses exist.
*/
static void
-disconnect_neighbour (struct NeighbourList *n, int check)
+disconnect_neighbour (struct NeighbourMapEntry *n, int check)
{
struct ReadyList *rpos;
struct MessageQueue *mq;
struct SessionHeader *session_header = (struct SessionHeader*) session;
struct TransportPingMessage *ping;
struct TransportPongMessage *pong;
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
struct ReadyList *rl;
struct ForeignAddressList *fal;
struct OwnAddressList *oal;
struct ReadyList *service_context;
struct ForeignAddressList *peer_address;
uint16_t msize;
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
struct GNUNET_TIME_Relative ret;
uint32_t distance;
int c;
void *value)
{
struct TransportClient *c = cls;
- struct NeighbourList *n = value;
+ struct NeighbourMapEntry *n = value;
struct ConnectInfoMessage * cim;
uint32_t ats_count;
size_t size;
*/
static void
transmit_client_message (void *cls,
- struct NeighbourList *n)
+ struct NeighbourMapEntry *n)
{
struct TransmitClientMessageContext *tcmc = cls;
struct TransportClient *tc;
{
const struct QuotaSetMessage *qsm =
(const struct QuotaSetMessage *) message;
- struct NeighbourList *n;
+ struct NeighbourMapEntry *n;
GNUNET_STATISTICS_update (stats,
gettext_noop ("# SET QUOTA messages received"),
}
else
{
+ GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
}
}
const char *address;
uint16_t size;
struct GNUNET_SERVER_TransmitContext *tc;
- struct GNUNET_TIME_Absolute timeout;
struct GNUNET_TIME_Relative rtimeout;
int32_t numeric;
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- timeout = GNUNET_TIME_absolute_ntoh (alum->timeout);
- rtimeout = GNUNET_TIME_absolute_get_remaining (timeout);
+ rtimeout = GNUNET_TIME_relative_ntoh (alum->timeout);
numeric = ntohl (alum->numeric_only);
lsPlugin = find_transport (nameTransport);
if (NULL == lsPlugin)
const struct GNUNET_MessageHeader *message)
{
const struct PeerAddressLookupMessage *peer_address_lookup;
- struct NeighbourList *neighbor_iterator;
+ struct NeighbourMapEntry *neighbor_iterator;
struct ReadyList *ready_iterator;
struct ForeignAddressList *foreign_address_iterator;
struct TransportPlugin *transport_plugin;
uint16_t size;
struct GNUNET_SERVER_TransmitContext *tc;
- struct GNUNET_TIME_Absolute timeout;
struct GNUNET_TIME_Relative rtimeout;
char *addr_buf;
}
peer_address_lookup = (const struct PeerAddressLookupMessage *) message;
- timeout = GNUNET_TIME_absolute_ntoh (peer_address_lookup->timeout);
- rtimeout = GNUNET_TIME_absolute_get_remaining (timeout);
+ rtimeout = GNUNET_TIME_relative_ntoh (peer_address_lookup->timeout);
neighbor_iterator = find_neighbour (&peer_address_lookup->peer);
void *value)
{
struct GNUNET_SERVER_TransmitContext *tc = cls;
- struct NeighbourList *neighbor_iterator = value;
+ struct NeighbourMapEntry *neighbor_iterator = value;
struct ForeignAddressList *foreign_address_iterator;
struct TransportPlugin *transport_plugin;
struct ReadyList *ready_iterator;
}
+static const struct GNUNET_MessageHeader *
+do_get_our_hello ()
+{
+ return (const struct GNUNET_MessageHeader*) our_hello;
+}
+
+
/**
* Setup the environment for this plugin.
*/
{
plug->env.cfg = cfg;
plug->env.my_identity = &my_identity;
- plug->env.our_hello = &our_hello;
+ plug->env.get_our_hello = &do_get_our_hello;
plug->env.cls = plug;
plug->env.receive = &plugin_env_receive;
plug->env.notify_address = &plugin_env_notify_address;
void *value)
{
struct TransportClient *pos = cls;
- struct NeighbourList *n = value;
+ struct NeighbourMapEntry *n = value;
struct MessageQueue *mq;
for (mq = n->messages_head; mq != NULL; mq = mq->next)
pos->message_count--;
GNUNET_free (mqe);
}
- GNUNET_CONTAINER_multihashmap_iterate (neighbours,
- &null_mq_client_pointers,
- pos);
+ if (NULL != neighbours)
+ GNUNET_CONTAINER_multihashmap_iterate (neighbours,
+ &null_mq_client_pointers,
+ pos);
if (prev == NULL)
clients = pos->next;
else
const GNUNET_HashCode *key,
void *value)
{
- struct NeighbourList *n = value;
+ struct NeighbourMapEntry *n = value;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
void *value)
{
struct AtsBuildContext *abc = cls;
- struct NeighbourList *next = value;
+ struct NeighbourMapEntry *next = value;
int found_addresses = GNUNET_NO;
struct ReadyList *r_next = next->plugins;
void *value)
{
struct AtsBuildContext *abc = cls;
- struct NeighbourList *next = value;
+ struct NeighbourMapEntry *next = value;
int found_addresses = GNUNET_NO;
struct ReadyList *r_next = next->plugins;
struct ForeignAddressList * get_preferred_ats_address (
- struct NeighbourList *n)
+ struct NeighbourMapEntry *n)
{
// TODO get ATS prefered address
return find_ready_address(n);