aboutsummaryrefslogtreecommitdiff
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 @@
1Sun May 2 13:49:10 CEST 2010
2 Fixed problem with platform-dependence of format for IP addresses
3 in HELLOs for TCP and UDP transport.
4 Reduced address length field in HELLOs to 16 bit (was 32 bit).
5 These changes break transport compatibility.
6
1Fri Apr 16 18:19:05 CEST 2010 7Fri Apr 16 18:19:05 CEST 2010
2 Nearly complete rewrite and new overall architecture. Many 8 Nearly complete rewrite and new overall architecture. Many
3 features are still missing, but basic system seems to be 9 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 @@
35 * the format: 35 * the format:
36 * 36 *
37 * 1) transport-name (0-terminated) 37 * 1) transport-name (0-terminated)
38 * 2) address-length (uint32_t, network byte order; possibly 38 * 2) address-length (uint16_t, network byte order; possibly
39 * unaligned!) 39 * unaligned!)
40 * 3) address expiration (GNUNET_TIME_AbsoluteNBO); possibly 40 * 3) address expiration (GNUNET_TIME_AbsoluteNBO); possibly
41 * unaligned!) 41 * unaligned!)
@@ -78,21 +78,21 @@ size_t
78GNUNET_HELLO_add_address (const char *tname, 78GNUNET_HELLO_add_address (const char *tname,
79 struct GNUNET_TIME_Absolute expiration, 79 struct GNUNET_TIME_Absolute expiration,
80 const void *addr, 80 const void *addr,
81 size_t addr_len, char *target, size_t max) 81 uint16_t addr_len, char *target, size_t max)
82{ 82{
83 uint32_t alen; 83 uint16_t alen;
84 size_t slen; 84 size_t slen;
85 struct GNUNET_TIME_AbsoluteNBO exp; 85 struct GNUNET_TIME_AbsoluteNBO exp;
86 86
87 slen = strlen (tname) + 1; 87 slen = strlen (tname) + 1;
88 if (slen + sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + 88 if (slen + sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO) +
89 addr_len > max) 89 addr_len > max)
90 return 0; 90 return 0;
91 exp = GNUNET_TIME_absolute_hton (expiration); 91 exp = GNUNET_TIME_absolute_hton (expiration);
92 alen = htonl ((uint32_t) addr_len); 92 alen = htons (addr_len);
93 memcpy (target, tname, slen); 93 memcpy (target, tname, slen);
94 memcpy (&target[slen], &alen, sizeof (uint32_t)); 94 memcpy (&target[slen], &alen, sizeof (uint16_t));
95 slen += sizeof (uint32_t); 95 slen += sizeof (uint16_t);
96 memcpy (&target[slen], &exp, sizeof (struct GNUNET_TIME_AbsoluteNBO)); 96 memcpy (&target[slen], &exp, sizeof (struct GNUNET_TIME_AbsoluteNBO));
97 slen += sizeof (struct GNUNET_TIME_AbsoluteNBO); 97 slen += sizeof (struct GNUNET_TIME_AbsoluteNBO);
98 memcpy (&target[slen], addr, addr_len); 98 memcpy (&target[slen], addr, addr_len);
@@ -110,10 +110,10 @@ GNUNET_HELLO_add_address (const char *tname,
110 * @return size of the entry, or 0 if max is not large enough 110 * @return size of the entry, or 0 if max is not large enough
111 */ 111 */
112static size_t 112static size_t
113get_hello_address_size (const char *buf, size_t max, uint32_t * ralen) 113get_hello_address_size (const char *buf, size_t max, uint16_t * ralen)
114{ 114{
115 const char *pos; 115 const char *pos;
116 uint32_t alen; 116 uint16_t alen;
117 size_t left; 117 size_t left;
118 size_t slen; 118 size_t slen;
119 119
@@ -134,16 +134,16 @@ get_hello_address_size (const char *buf, size_t max, uint32_t * ralen)
134 return 0; 134 return 0;
135 } 135 }
136 pos++; 136 pos++;
137 if (left < sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO)) 137 if (left < sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO))
138 { 138 {
139 /* not enough space for addrlen */ 139 /* not enough space for addrlen */
140 GNUNET_break_op (0); 140 GNUNET_break_op (0);
141 return 0; 141 return 0;
142 } 142 }
143 memcpy (&alen, pos, sizeof (uint32_t)); 143 memcpy (&alen, pos, sizeof (uint16_t));
144 alen = ntohl (alen); 144 alen = ntohs (alen);
145 *ralen = alen; 145 *ralen = alen;
146 slen += alen + sizeof (uint32_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO); 146 slen += alen + sizeof (uint16_t) + sizeof (struct GNUNET_TIME_AbsoluteNBO);
147 if (max < slen) 147 if (max < slen)
148 { 148 {
149 /* not enough space for addr */ 149 /* not enough space for addr */
@@ -215,7 +215,7 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg,
215 size_t esize; 215 size_t esize;
216 size_t wpos; 216 size_t wpos;
217 char *woff; 217 char *woff;
218 uint32_t alen; 218 uint16_t alen;
219 struct GNUNET_TIME_AbsoluteNBO expire; 219 struct GNUNET_TIME_AbsoluteNBO expire;
220 int iret; 220 int iret;
221 221
@@ -275,7 +275,7 @@ struct ExpireContext
275{ 275{
276 const void *addr; 276 const void *addr;
277 const char *tname; 277 const char *tname;
278 size_t addrlen; 278 uint16_t addrlen;
279 int found; 279 int found;
280 struct GNUNET_TIME_Absolute expiration; 280 struct GNUNET_TIME_Absolute expiration;
281}; 281};
@@ -285,7 +285,7 @@ static int
285get_match_exp (void *cls, 285get_match_exp (void *cls,
286 const char *tname, 286 const char *tname,
287 struct GNUNET_TIME_Absolute expiration, 287 struct GNUNET_TIME_Absolute expiration,
288 const void *addr, size_t addrlen) 288 const void *addr, uint16_t addrlen)
289{ 289{
290 struct ExpireContext *ec = cls; 290 struct ExpireContext *ec = cls;
291 291
@@ -318,7 +318,7 @@ static int
318copy_latest (void *cls, 318copy_latest (void *cls,
319 const char *tname, 319 const char *tname,
320 struct GNUNET_TIME_Absolute expiration, 320 struct GNUNET_TIME_Absolute expiration,
321 const void *addr, size_t addrlen) 321 const void *addr, uint16_t addrlen)
322{ 322{
323 struct MergeContext *mc = cls; 323 struct MergeContext *mc = cls;
324 struct ExpireContext ec; 324 struct ExpireContext ec;
@@ -400,7 +400,7 @@ static int
400delta_match (void *cls, 400delta_match (void *cls,
401 const char *tname, 401 const char *tname,
402 struct GNUNET_TIME_Absolute expiration, 402 struct GNUNET_TIME_Absolute expiration,
403 const void *addr, size_t addrlen) 403 const void *addr, uint16_t addrlen)
404{ 404{
405 struct DeltaContext *dc = cls; 405 struct DeltaContext *dc = cls;
406 int ret; 406 int ret;
@@ -545,9 +545,10 @@ struct EqualsContext
545 545
546 struct GNUNET_TIME_Absolute expiration; 546 struct GNUNET_TIME_Absolute expiration;
547 547
548 size_t addrlen;
549
550 int found; 548 int found;
549
550 uint16_t addrlen;
551
551}; 552};
552 553
553 554
@@ -555,7 +556,7 @@ static int
555find_other_matching (void *cls, 556find_other_matching (void *cls,
556 const char *tname, 557 const char *tname,
557 struct GNUNET_TIME_Absolute expiration, 558 struct GNUNET_TIME_Absolute expiration,
558 const void *addr, size_t addrlen) 559 const void *addr, uint16_t addrlen)
559{ 560{
560 struct EqualsContext *ec = cls; 561 struct EqualsContext *ec = cls;
561 562
@@ -584,7 +585,7 @@ static int
584find_matching (void *cls, 585find_matching (void *cls,
585 const char *tname, 586 const char *tname,
586 struct GNUNET_TIME_Absolute expiration, 587 struct GNUNET_TIME_Absolute expiration,
587 const void *addr, size_t addrlen) 588 const void *addr, uint16_t addrlen)
588{ 589{
589 struct EqualsContext *ec = cls; 590 struct EqualsContext *ec = cls;
590 591
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
163check_has_addr (void *cls, 163check_has_addr (void *cls,
164 const char *tname, 164 const char *tname,
165 struct GNUNET_TIME_Absolute expiration, 165 struct GNUNET_TIME_Absolute expiration,
166 const void *addr, size_t addrlen) 166 const void *addr,
167 uint16_t addrlen)
167{ 168{
168 int *arg = cls; 169 int *arg = cls;
169 170
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
64GNUNET_HELLO_add_address (const char *tname, 64GNUNET_HELLO_add_address (const char *tname,
65 struct GNUNET_TIME_Absolute expiration, 65 struct GNUNET_TIME_Absolute expiration,
66 const void *addr, 66 const void *addr,
67 size_t addr_len, char *target, size_t max); 67 uint16_t addr_len, char *target, size_t max);
68 68
69 69
70/** 70/**
@@ -160,7 +160,8 @@ typedef int
160 (*GNUNET_HELLO_AddressIterator) (void *cls, 160 (*GNUNET_HELLO_AddressIterator) (void *cls,
161 const char *tname, 161 const char *tname,
162 struct GNUNET_TIME_Absolute expiration, 162 struct GNUNET_TIME_Absolute expiration,
163 const void *addr, size_t addrlen); 163 const void *addr,
164 uint16_t addrlen);
164 165
165 166
166/** 167/**
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
116count_address (void *cls, 116count_address (void *cls,
117 const char *tname, 117 const char *tname,
118 struct GNUNET_TIME_Absolute expiration, 118 struct GNUNET_TIME_Absolute expiration,
119 const void *addr, size_t addrlen) 119 const void *addr, uint16_t addrlen)
120{ 120{
121 struct PrintContext *pc = cls; 121 struct PrintContext *pc = cls;
122 pc->off++; 122 pc->off++;
@@ -138,7 +138,7 @@ static int
138print_address (void *cls, 138print_address (void *cls,
139 const char *tname, 139 const char *tname,
140 struct GNUNET_TIME_Absolute expiration, 140 struct GNUNET_TIME_Absolute expiration,
141 const void *addr, size_t addrlen) 141 const void *addr, uint16_t addrlen)
142{ 142{
143 struct PrintContext *pc = cls; 143 struct PrintContext *pc = cls;
144 GNUNET_TRANSPORT_address_lookup (sched, 144 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
151discard_expired (void *cls, 151discard_expired (void *cls,
152 const char *tname, 152 const char *tname,
153 struct GNUNET_TIME_Absolute expiration, 153 struct GNUNET_TIME_Absolute expiration,
154 const void *addr, size_t addrlen) 154 const void *addr, uint16_t addrlen)
155{ 155{
156 const struct GNUNET_TIME_Absolute *now = cls; 156 const struct GNUNET_TIME_Absolute *now = cls;
157 if (now->value > expiration.value) 157 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
841address_iterator (void *cls, 841address_iterator (void *cls,
842 const char *tname, 842 const char *tname,
843 struct GNUNET_TIME_Absolute expiration, 843 struct GNUNET_TIME_Absolute expiration,
844 const void *addr, size_t addrlen) 844 const void *addr,
845 uint16_t addrlen)
845{ 846{
846 int *flag = cls; 847 int *flag = cls;
847 *flag = GNUNET_YES; 848 *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
166 GNUNET_SCHEDULER_TaskIdentifier revalidate_task; 166 GNUNET_SCHEDULER_TaskIdentifier revalidate_task;
167 167
168 /** 168 /**
169 * Length of addr.
170 */
171 size_t addrlen;
172
173 /**
174 * The address. 169 * The address.
175 */ 170 */
176 const void *addr; 171 const void *addr;
@@ -209,6 +204,11 @@ struct ForeignAddressList
209 uint32_t distance; 204 uint32_t distance;
210 205
211 /** 206 /**
207 * Length of addr.
208 */
209 uint16_t addrlen;
210
211 /**
212 * Have we ever estimated the latency of this address? Used to 212 * Have we ever estimated the latency of this address? Used to
213 * ensure that the first time we add an address, we immediately 213 * ensure that the first time we add an address, we immediately
214 * probe its latency. 214 * probe its latency.
@@ -264,7 +264,7 @@ struct OwnAddressList
264 /** 264 /**
265 * Length of addr. 265 * Length of addr.
266 */ 266 */
267 size_t addrlen; 267 uint16_t addrlen;
268 268
269}; 269};
270 270
@@ -623,7 +623,7 @@ struct TransportPongMessage
623 /** 623 /**
624 * Size of address appended to this message 624 * Size of address appended to this message
625 */ 625 */
626 size_t addrlen; 626 uint16_t addrlen;
627 627
628}; 628};
629 629
@@ -734,14 +734,14 @@ struct ValidationEntry
734 struct Session *session; 734 struct Session *session;
735 735
736 /** 736 /**
737 * Length of addr. 737 * Challenge number we used.
738 */ 738 */
739 size_t addrlen; 739 uint32_t challenge;
740 740
741 /** 741 /**
742 * Challenge number we used. 742 * Length of addr.
743 */ 743 */
744 uint32_t challenge; 744 uint16_t addrlen;
745 745
746}; 746};
747 747
@@ -1403,7 +1403,7 @@ transmit_send_continuation (void *cls,
1403static const char* 1403static const char*
1404a2s (const char *plugin, 1404a2s (const char *plugin,
1405 const void *addr, 1405 const void *addr,
1406 size_t addr_len) 1406 uint16_t addr_len)
1407{ 1407{
1408 struct TransportPlugin *p; 1408 struct TransportPlugin *p;
1409 1409
@@ -2040,7 +2040,7 @@ static void
2040plugin_env_notify_address (void *cls, 2040plugin_env_notify_address (void *cls,
2041 const char *name, 2041 const char *name,
2042 const void *addr, 2042 const void *addr,
2043 size_t addrlen, 2043 uint16_t addrlen,
2044 struct GNUNET_TIME_Relative expires) 2044 struct GNUNET_TIME_Relative expires)
2045{ 2045{
2046 struct TransportPlugin *p = cls; 2046 struct TransportPlugin *p = cls;
@@ -2156,7 +2156,7 @@ find_peer_address(struct NeighbourList *neighbour,
2156 const char *tname, 2156 const char *tname,
2157 struct Session *session, 2157 struct Session *session,
2158 const char *addr, 2158 const char *addr,
2159 size_t addrlen) 2159 uint16_t addrlen)
2160{ 2160{
2161 struct ReadyList *head; 2161 struct ReadyList *head;
2162 struct ForeignAddressList *pos; 2162 struct ForeignAddressList *pos;
@@ -2202,7 +2202,7 @@ add_peer_address (struct NeighbourList *neighbour,
2202 const char *tname, 2202 const char *tname,
2203 struct Session *session, 2203 struct Session *session,
2204 const char *addr, 2204 const char *addr,
2205 size_t addrlen) 2205 uint16_t addrlen)
2206{ 2206{
2207 struct ReadyList *head; 2207 struct ReadyList *head;
2208 struct ForeignAddressList *ret; 2208 struct ForeignAddressList *ret;
@@ -2315,14 +2315,15 @@ struct CheckAddressExistsClosure
2315 struct Session *session; 2315 struct Session *session;
2316 2316
2317 /** 2317 /**
2318 * Length of addr. 2318 * Set to GNUNET_YES if the address exists.
2319 */ 2319 */
2320 size_t addrlen; 2320 int exists;
2321 2321
2322 /** 2322 /**
2323 * Set to GNUNET_YES if the address exists. 2323 * Length of addr.
2324 */ 2324 */
2325 int exists; 2325 uint16_t addrlen;
2326
2326}; 2327};
2327 2328
2328 2329
@@ -2437,7 +2438,8 @@ static int
2437add_to_foreign_address_list (void *cls, 2438add_to_foreign_address_list (void *cls,
2438 const char *tname, 2439 const char *tname,
2439 struct GNUNET_TIME_Absolute expiration, 2440 struct GNUNET_TIME_Absolute expiration,
2440 const void *addr, size_t addrlen) 2441 const void *addr,
2442 uint16_t addrlen)
2441{ 2443{
2442 struct NeighbourList *n = cls; 2444 struct NeighbourList *n = cls;
2443 struct ForeignAddressList *fal; 2445 struct ForeignAddressList *fal;
@@ -3492,7 +3494,8 @@ static int
3492run_validation (void *cls, 3494run_validation (void *cls,
3493 const char *tname, 3495 const char *tname,
3494 struct GNUNET_TIME_Absolute expiration, 3496 struct GNUNET_TIME_Absolute expiration,
3495 const void *addr, size_t addrlen) 3497 const void *addr,
3498 uint16_t addrlen)
3496{ 3499{
3497 struct CheckHelloValidatedContext *chvc = cls; 3500 struct CheckHelloValidatedContext *chvc = cls;
3498 struct GNUNET_PeerIdentity id; 3501 struct GNUNET_PeerIdentity id;
@@ -3932,7 +3935,7 @@ static int
3932handle_ping(void *cls, const struct GNUNET_MessageHeader *message, 3935handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
3933 const struct GNUNET_PeerIdentity *peer, 3936 const struct GNUNET_PeerIdentity *peer,
3934 const char *sender_address, 3937 const char *sender_address,
3935 size_t sender_address_len) 3938 uint16_t sender_address_len)
3936{ 3939{
3937 struct TransportPlugin *plugin = cls; 3940 struct TransportPlugin *plugin = cls;
3938 struct TransportPingMessage *ping; 3941 struct TransportPingMessage *ping;
@@ -4072,7 +4075,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
4072 uint32_t distance, 4075 uint32_t distance,
4073 struct Session *session, 4076 struct Session *session,
4074 const char *sender_address, 4077 const char *sender_address,
4075 size_t sender_address_len) 4078 uint16_t sender_address_len)
4076{ 4079{
4077 struct TransportPlugin *plugin = cls; 4080 struct TransportPlugin *plugin = cls;
4078 struct ReadyList *service_context; 4081 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
90 uint32_t distance, 90 uint32_t distance,
91 struct Session *session, 91 struct Session *session,
92 const char *sender_address, 92 const char *sender_address,
93 size_t sender_address_len); 93 uint16_t sender_address_len);
94 94
95 95
96/** 96/**
@@ -107,7 +107,7 @@ typedef struct GNUNET_TIME_Relative (*GNUNET_TRANSPORT_PluginReceiveCallback) (v
107typedef void (*GNUNET_TRANSPORT_AddressNotification) (void *cls, 107typedef void (*GNUNET_TRANSPORT_AddressNotification) (void *cls,
108 const char *name, 108 const char *name,
109 const void *addr, 109 const void *addr,
110 size_t addrlen, 110 uint16_t addrlen,
111 struct 111 struct
112 GNUNET_TIME_Relative 112 GNUNET_TIME_Relative
113 expires); 113 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,
98 uint32_t distance, 98 uint32_t distance,
99 struct Session *session, 99 struct Session *session,
100 const char *sender_address, 100 const char *sender_address,
101 size_t sender_address_len) 101 uint16_t sender_address_len)
102{ 102{
103 /* do nothing */ 103 /* do nothing */
104 return GNUNET_TIME_UNIT_ZERO; 104 return GNUNET_TIME_UNIT_ZERO;
@@ -108,7 +108,8 @@ void
108notify_address (void *cls, 108notify_address (void *cls,
109 const char *name, 109 const char *name,
110 const void *addr, 110 const void *addr,
111 size_t addrlen, struct GNUNET_TIME_Relative expires) 111 uint16_t addrlen,
112 struct GNUNET_TIME_Relative expires)
112{ 113{
113} 114}
114 115