projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
curly wars / auto-indentation
[oweals/gnunet.git]
/
src
/
transport
/
transport_api_address_iterate.c
diff --git
a/src/transport/transport_api_address_iterate.c
b/src/transport/transport_api_address_iterate.c
index 4f442fda08253c06334426f27b75d72d48e693b7..3c3f97c283745a083a624c2fbf581bf47f23f9cf 100644
(file)
--- a/
src/transport/transport_api_address_iterate.c
+++ b/
src/transport/transport_api_address_iterate.c
@@
-47,7
+47,7
@@
struct AddressLookupCtx
/**
* Function to call with the human-readable address.
*/
/**
* Function to call with the human-readable address.
*/
- GNUNET_TRANSPORT_AddressLookUpCallback cb;
+ GNUNET_TRANSPORT_AddressLookUp
Binary
Callback cb;
/**
* Closure for cb.
/**
* Closure for cb.
@@
-78,42
+78,55
@@
peer_address_response_processor (void *cls,
const struct GNUNET_MessageHeader *msg)
{
struct AddressLookupCtx *alucb = cls;
const struct GNUNET_MessageHeader *msg)
{
struct AddressLookupCtx *alucb = cls;
-
const char
*address;
+
struct AddressIterateResponseMessage
*address;
uint16_t size;
uint16_t size;
+ char *transport;
+
+ //size_t transport_len;
+ //void * addr;
+ size_t addrlen;
if (msg == NULL)
{
if (msg == NULL)
{
- alucb->cb (alucb->cb_cls, NULL);
+ alucb->cb (alucb->cb_cls, NULL
, NULL, NULL, 0
);
GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO);
GNUNET_free (alucb);
return;
}
GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO);
GNUNET_free (alucb);
return;
}
+
GNUNET_break (ntohs (msg->type) ==
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
size = ntohs (msg->size);
GNUNET_break (ntohs (msg->type) ==
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY);
size = ntohs (msg->size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message type %u size %u\n",
+ ntohs (msg->type), size);
if (size == sizeof (struct GNUNET_MessageHeader))
{
/* done! */
if (size == sizeof (struct GNUNET_MessageHeader))
{
/* done! */
- alucb->cb (alucb->cb_cls, NULL);
+ alucb->cb (alucb->cb_cls, NULL
, NULL, NULL, 0
);
GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO);
GNUNET_free (alucb);
return;
}
GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO);
GNUNET_free (alucb);
return;
}
- address = (const char *) &msg[1];
- if (address[size - sizeof (struct GNUNET_MessageHeader) - 1] != '\0')
+ if (size < sizeof (struct AddressIterateResponseMessage))
{
/* invalid reply */
GNUNET_break (0);
{
/* invalid reply */
GNUNET_break (0);
- alucb->cb (alucb->cb_cls, NULL);
+ alucb->cb (alucb->cb_cls, NULL
, NULL, NULL, 0
);
GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO);
GNUNET_free (alucb);
return;
}
GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO);
GNUNET_free (alucb);
return;
}
+
+ address = (struct AddressIterateResponseMessage *) &msg[1];
+
+ transport = (char *) &address[0];
+ //transport_len = ntohs(address->pluginlen);
+ addrlen = ntohs (address->addrlen);
+
/* expect more replies */
/* expect more replies */
- GNUNET_CLIENT_receive (alucb->client,
- &peer_address_response_processor, alucb,
+ GNUNET_CLIENT_receive (alucb->client, &peer_address_response_processor, alucb,
GNUNET_TIME_absolute_get_remaining (alucb->timeout));
GNUNET_TIME_absolute_get_remaining (alucb->timeout));
- alucb->cb (alucb->cb_cls,
address
);
+ alucb->cb (alucb->cb_cls,
&address->peer, transport, NULL, addrlen
);
}
}
@@
-128,7
+141,7
@@
peer_address_response_processor (void *cls,
void
GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TIME_Relative timeout,
void
GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TIME_Relative timeout,
- GNUNET_TRANSPORT_AddressLookUpCallback
+ GNUNET_TRANSPORT_AddressLookUp
Binary
Callback
peer_address_callback,
void *peer_address_callback_cls)
{
peer_address_callback,
void *peer_address_callback_cls)
{
@@
-140,12
+153,12
@@
GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
client = GNUNET_CLIENT_connect ("transport", cfg);
if (client == NULL)
{
client = GNUNET_CLIENT_connect ("transport", cfg);
if (client == NULL)
{
- peer_address_callback (peer_address_callback_cls, NULL);
+ peer_address_callback (peer_address_callback_cls, NULL
, NULL, NULL, 0
);
return;
}
abs_timeout = GNUNET_TIME_relative_to_absolute (timeout);
return;
}
abs_timeout = GNUNET_TIME_relative_to_absolute (timeout);
- msg.header.size = htons (sizeof (struct Address
Lookup
Message));
+ msg.header.size = htons (sizeof (struct Address
Iterate
Message));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE);
msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout);
peer_address_lookup_cb = GNUNET_malloc (sizeof (struct AddressLookupCtx));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE);
msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout);
peer_address_lookup_cb = GNUNET_malloc (sizeof (struct AddressLookupCtx));
@@
-154,10
+167,8
@@
GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
peer_address_lookup_cb->timeout = abs_timeout;
peer_address_lookup_cb->client = client;
GNUNET_assert (GNUNET_OK ==
peer_address_lookup_cb->timeout = abs_timeout;
peer_address_lookup_cb->client = client;
GNUNET_assert (GNUNET_OK ==
- GNUNET_CLIENT_transmit_and_get_response (client,
- &msg.header,
- timeout,
- GNUNET_YES,
+ GNUNET_CLIENT_transmit_and_get_response (client, &msg.header,
+ timeout, GNUNET_YES,
&peer_address_response_processor,
peer_address_lookup_cb));
}
&peer_address_response_processor,
peer_address_lookup_cb));
}