summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/hello/hello.c45
-rw-r--r--src/hostlist/hostlist-server.c3
-rw-r--r--src/include/gnunet_hello_lib.h5
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c4
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c2
-rw-r--r--src/topology/gnunet-daemon-topology.c3
-rw-r--r--src/transport/gnunet-service-transport.c49
-rw-r--r--src/transport/plugin_transport.h4
-rw-r--r--src/transport/test_plugin_transport_http.c5
10 files changed, 70 insertions, 56 deletions
diff --git a/ChangeLog b/ChangeLog
index 4ea48e931..8f14863eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun May 2 13:49:10 CEST 2010
+ Fixed problem with platform-dependence of format for IP addresses
+ in HELLOs for TCP and UDP transport.
+ Reduced address length field in HELLOs to 16 bit (was 32 bit).
+ These changes break transport compatibility.
+
Fri Apr 16 18:19:05 CEST 2010
Nearly complete rewrite and new overall architecture. Many
features are still missing, but basic system seems to be
diff --git a/src/hello/hello.c b/src/hello/hello.c
index 51575ebaf..5b30dc167 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -35,7 +35,7 @@
* the format:
*
* 1) transport-name (0-terminated)
- * 2) address-length (uint32_t, network byte order; possibly
+ * 2) address-length (uint16_t, network byte order; possibly
* unaligned!)
* 3) address expiration (GNUNET_TIME_AbsoluteNBO); possibly
* unaligned!)
@@ -78,21 +78,21 @@ size_t
GNUNET_HELLO_add_address (const char *tname,
struct GNUNET_TIME_Absolute expiration,
const void *addr,
- size_t addr_len, char *target, size_t max)
+ uint16_t addr_len, char *target, size_t max)
{
- uint32_t alen;
+ uint16_t alen;
size_t slen;
struct GNUNET_TIME_AbsoluteNBO exp;
slen = strlen (tname) + 1;
- if (slen + sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) +
+ if (slen + sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) +
addr_len > max)
return 0;
exp = GNUNET_TIME_absolute_hton (expiration);
- alen = htonl ((uint32_t) addr_len);
+ alen = htons (addr_len);
memcpy (target, tname, slen);
- memcpy (&target[slen], &alen, sizeof (uint32_t));
- slen += sizeof (uint32_t);
+ memcpy (&target[slen], &alen, sizeof (uint16_t));
+ slen += sizeof (uint16_t);
memcpy (&target[slen], &exp, sizeof (struct GNUNET_TIME_AbsoluteNBO));
slen += sizeof (struct GNUNET_TIME_AbsoluteNBO);
memcpy (&target[slen], addr, addr_len);
@@ -110,10 +110,10 @@ GNUNET_HELLO_add_address (const char *tname,
* @return size of the entry, or 0 if max is not large enough
*/
static size_t
-get_hello_address_size (const char *buf, size_t max, uint32_t * ralen)
+get_hello_address_size (const char *buf, size_t max, uint16_t * ralen)
{
const char *pos;
- uint32_t alen;
+ uint16_t alen;
size_t left;
size_t slen;
@@ -134,16 +134,16 @@ get_hello_address_size (const char *buf, size_t max, uint32_t * ralen)
return 0;
}
pos++;
- if (left < sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO))
+ if (left < sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO))
{
/* not enough space for addrlen */
GNUNET_break_op (0);
return 0;
}
- memcpy (&alen, pos, sizeof (uint32_t));
- alen = ntohl (alen);
+ memcpy (&alen, pos, sizeof (uint16_t));
+ alen = ntohs (alen);
*ralen = alen;
- slen += alen + sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO);
+ slen += alen + sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO);
if (max < slen)
{
/* not enough space for addr */
@@ -215,7 +215,7 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg,
size_t esize;
size_t wpos;
char *woff;
- uint32_t alen;
+ uint16_t alen;
struct GNUNET_TIME_AbsoluteNBO expire;
int iret;
@@ -275,7 +275,7 @@ struct ExpireContext
{
const void *addr;
const char *tname;
- size_t addrlen;
+ uint16_t addrlen;
int found;
struct GNUNET_TIME_Absolute expiration;
};
@@ -285,7 +285,7 @@ static int
get_match_exp (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr, uint16_t addrlen)
{
struct ExpireContext *ec = cls;
@@ -318,7 +318,7 @@ static int
copy_latest (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr, uint16_t addrlen)
{
struct MergeContext *mc = cls;
struct ExpireContext ec;
@@ -400,7 +400,7 @@ static int
delta_match (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr, uint16_t addrlen)
{
struct DeltaContext *dc = cls;
int ret;
@@ -545,9 +545,10 @@ struct EqualsContext
struct GNUNET_TIME_Absolute expiration;
- size_t addrlen;
-
int found;
+
+ uint16_t addrlen;
+
};
@@ -555,7 +556,7 @@ static int
find_other_matching (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr, uint16_t addrlen)
{
struct EqualsContext *ec = cls;
@@ -584,7 +585,7 @@ static int
find_matching (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr, uint16_t addrlen)
{
struct EqualsContext *ec = cls;
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c
index b2e939ce0..098d766dd 100644
--- a/src/hostlist/hostlist-server.c
+++ b/src/hostlist/hostlist-server.c
@@ -163,7 +163,8 @@ static int
check_has_addr (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr,
+ uint16_t addrlen)
{
int *arg = cls;
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index ca5e29284..58cf185de 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -64,7 +64,7 @@ size_t
GNUNET_HELLO_add_address (const char *tname,
struct GNUNET_TIME_Absolute expiration,
const void *addr,
- size_t addr_len, char *target, size_t max);
+ uint16_t addr_len, char *target, size_t max);
/**
@@ -160,7 +160,8 @@ typedef int
(*GNUNET_HELLO_AddressIterator) (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen);
+ const void *addr,
+ uint16_t addrlen);
/**
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index ba9832099..a3fa98fa9 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -116,7 +116,7 @@ static int
count_address (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr, uint16_t addrlen)
{
struct PrintContext *pc = cls;
pc->off++;
@@ -138,7 +138,7 @@ static int
print_address (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr, uint16_t addrlen)
{
struct PrintContext *pc = cls;
GNUNET_TRANSPORT_address_lookup (sched,
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 14c914beb..8402e7b23 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -151,7 +151,7 @@ static int
discard_expired (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr, uint16_t addrlen)
{
const struct GNUNET_TIME_Absolute *now = cls;
if (now->value > expiration.value)
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index 7ebd43ab9..e827fad2c 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -841,7 +841,8 @@ static int
address_iterator (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr,
+ uint16_t addrlen)
{
int *flag = cls;
*flag = GNUNET_YES;
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index e927a11f5..7dddb42f5 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -166,11 +166,6 @@ struct ForeignAddressList
GNUNET_SCHEDULER_TaskIdentifier revalidate_task;
/**
- * Length of addr.
- */
- size_t addrlen;
-
- /**
* The address.
*/
const void *addr;
@@ -209,6 +204,11 @@ struct ForeignAddressList
uint32_t distance;
/**
+ * Length of addr.
+ */
+ uint16_t addrlen;
+
+ /**
* Have we ever estimated the latency of this address? Used to
* ensure that the first time we add an address, we immediately
* probe its latency.
@@ -264,7 +264,7 @@ struct OwnAddressList
/**
* Length of addr.
*/
- size_t addrlen;
+ uint16_t addrlen;
};
@@ -623,7 +623,7 @@ struct TransportPongMessage
/**
* Size of address appended to this message
*/
- size_t addrlen;
+ uint16_t addrlen;
};
@@ -734,14 +734,14 @@ struct ValidationEntry
struct Session *session;
/**
- * Length of addr.
+ * Challenge number we used.
*/
- size_t addrlen;
+ uint32_t challenge;
/**
- * Challenge number we used.
+ * Length of addr.
*/
- uint32_t challenge;
+ uint16_t addrlen;
};
@@ -1403,7 +1403,7 @@ transmit_send_continuation (void *cls,
static const char*
a2s (const char *plugin,
const void *addr,
- size_t addr_len)
+ uint16_t addr_len)
{
struct TransportPlugin *p;
@@ -2040,7 +2040,7 @@ static void
plugin_env_notify_address (void *cls,
const char *name,
const void *addr,
- size_t addrlen,
+ uint16_t addrlen,
struct GNUNET_TIME_Relative expires)
{
struct TransportPlugin *p = cls;
@@ -2156,7 +2156,7 @@ find_peer_address(struct NeighbourList *neighbour,
const char *tname,
struct Session *session,
const char *addr,
- size_t addrlen)
+ uint16_t addrlen)
{
struct ReadyList *head;
struct ForeignAddressList *pos;
@@ -2202,7 +2202,7 @@ add_peer_address (struct NeighbourList *neighbour,
const char *tname,
struct Session *session,
const char *addr,
- size_t addrlen)
+ uint16_t addrlen)
{
struct ReadyList *head;
struct ForeignAddressList *ret;
@@ -2315,14 +2315,15 @@ struct CheckAddressExistsClosure
struct Session *session;
/**
- * Length of addr.
+ * Set to GNUNET_YES if the address exists.
*/
- size_t addrlen;
+ int exists;
/**
- * Set to GNUNET_YES if the address exists.
+ * Length of addr.
*/
- int exists;
+ uint16_t addrlen;
+
};
@@ -2437,7 +2438,8 @@ static int
add_to_foreign_address_list (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr,
+ uint16_t addrlen)
{
struct NeighbourList *n = cls;
struct ForeignAddressList *fal;
@@ -3492,7 +3494,8 @@ static int
run_validation (void *cls,
const char *tname,
struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
+ const void *addr,
+ uint16_t addrlen)
{
struct CheckHelloValidatedContext *chvc = cls;
struct GNUNET_PeerIdentity id;
@@ -3932,7 +3935,7 @@ static int
handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
const struct GNUNET_PeerIdentity *peer,
const char *sender_address,
- size_t sender_address_len)
+ uint16_t sender_address_len)
{
struct TransportPlugin *plugin = cls;
struct TransportPingMessage *ping;
@@ -4072,7 +4075,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
uint32_t distance,
struct Session *session,
const char *sender_address,
- size_t sender_address_len)
+ uint16_t sender_address_len)
{
struct TransportPlugin *plugin = cls;
struct ReadyList *service_context;
diff --git a/src/transport/plugin_transport.h b/src/transport/plugin_transport.h
index 034520cb3..43b59e6cf 100644
--- a/src/transport/plugin_transport.h
+++ b/src/transport/plugin_transport.h
@@ -90,7 +90,7 @@ typedef struct GNUNET_TIME_Relative (*GNUNET_TRANSPORT_PluginReceiveCallback) (v
uint32_t distance,
struct Session *session,
const char *sender_address,
- size_t sender_address_len);
+ uint16_t sender_address_len);
/**
@@ -107,7 +107,7 @@ typedef struct GNUNET_TIME_Relative (*GNUNET_TRANSPORT_PluginReceiveCallback) (v
typedef void (*GNUNET_TRANSPORT_AddressNotification) (void *cls,
const char *name,
const void *addr,
- size_t addrlen,
+ uint16_t addrlen,
struct
GNUNET_TIME_Relative
expires);
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c
index 328e70683..f8b5e4dba 100644
--- a/src/transport/test_plugin_transport_http.c
+++ b/src/transport/test_plugin_transport_http.c
@@ -98,7 +98,7 @@ receive (void *cls,
uint32_t distance,
struct Session *session,
const char *sender_address,
- size_t sender_address_len)
+ uint16_t sender_address_len)
{
/* do nothing */
return GNUNET_TIME_UNIT_ZERO;
@@ -108,7 +108,8 @@ void
notify_address (void *cls,
const char *name,
const void *addr,
- size_t addrlen, struct GNUNET_TIME_Relative expires)
+ uint16_t addrlen,
+ struct GNUNET_TIME_Relative expires)
{
}