diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-10-13 08:06:28 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-10-13 08:06:28 +0000 |
commit | f9d82cbcd81da81a3e78bada99f54ccc7c9ac50b (patch) | |
tree | 24635e8bad579f156f4c8f2153c2d213a20f1850 /src/transport/plugin_transport_http.c | |
parent | 1a7597ebe84660f31cb5f5b22904641940ca86ab (diff) | |
download | gnunet-f9d82cbcd81da81a3e78bada99f54ccc7c9ac50b.tar.gz gnunet-f9d82cbcd81da81a3e78bada99f54ccc7c9ac50b.zip |
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 11ce54331..3f7ff2a40 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -34,38 +34,6 @@ | |||
34 | #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6) | 34 | #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 6) |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * IPv4 addresses | ||
38 | */ | ||
39 | struct IPv4HttpAddress | ||
40 | { | ||
41 | /** | ||
42 | * IPv4 address, in network byte order. | ||
43 | */ | ||
44 | uint32_t ipv4_addr GNUNET_PACKED; | ||
45 | |||
46 | /** | ||
47 | * Port number, in network byte order. | ||
48 | */ | ||
49 | uint16_t u4_port GNUNET_PACKED; | ||
50 | }; | ||
51 | |||
52 | /** | ||
53 | * IPv4 addresses | ||
54 | */ | ||
55 | struct IPv6HttpAddress | ||
56 | { | ||
57 | /** | ||
58 | * IPv6 address. | ||
59 | */ | ||
60 | struct in6_addr ipv6_addr GNUNET_PACKED; | ||
61 | |||
62 | /** | ||
63 | * Port number, in network byte order. | ||
64 | */ | ||
65 | uint16_t u6_port GNUNET_PACKED; | ||
66 | }; | ||
67 | |||
68 | /** | ||
69 | * Wrapper to manage IPv4 addresses | 37 | * Wrapper to manage IPv4 addresses |
70 | */ | 38 | */ |
71 | struct IPv4HttpAddressWrapper | 39 | struct IPv4HttpAddressWrapper |
@@ -189,7 +157,6 @@ http_plugin_address_pretty_printer (void *cls, const char *type, | |||
189 | size_t sbs; | 157 | size_t sbs; |
190 | uint16_t port = 0 ; | 158 | uint16_t port = 0 ; |
191 | 159 | ||
192 | // BUG! Transport addrs over the network must NOT be 'struct sockaddr*'s! | ||
193 | if (addrlen == sizeof (struct IPv6HttpAddress)) | 160 | if (addrlen == sizeof (struct IPv6HttpAddress)) |
194 | { | 161 | { |
195 | struct IPv6HttpAddress * a6 = (struct IPv6HttpAddress *) addr; | 162 | struct IPv6HttpAddress * a6 = (struct IPv6HttpAddress *) addr; |
@@ -341,6 +308,7 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
341 | else | 308 | else |
342 | { | 309 | { |
343 | /* invalid address */ | 310 | /* invalid address */ |
311 | GNUNET_break (0); | ||
344 | return NULL; | 312 | return NULL; |
345 | } | 313 | } |
346 | #if !BUILD_HTTPS | 314 | #if !BUILD_HTTPS |
@@ -450,7 +418,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
450 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 418 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
451 | { | 419 | { |
452 | struct Session *s = NULL; | 420 | struct Session *s = NULL; |
453 | 421 | GNUNET_assert ((addrlen == sizeof (struct IPv6HttpAddress)) || (addrlen == sizeof (struct IPv4HttpAddress))); | |
454 | s = GNUNET_malloc (sizeof (struct Session)); | 422 | s = GNUNET_malloc (sizeof (struct Session)); |
455 | memcpy (&s->target, target, sizeof (struct GNUNET_PeerIdentity)); | 423 | memcpy (&s->target, target, sizeof (struct GNUNET_PeerIdentity)); |
456 | s->plugin = plugin; | 424 | s->plugin = plugin; |
@@ -532,6 +500,11 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
532 | 500 | ||
533 | struct Session *s = NULL; | 501 | struct Session *s = NULL; |
534 | 502 | ||
503 | |||
504 | if (addrlen != 0) | ||
505 | GNUNET_assert ((addrlen == sizeof (struct IPv4HttpAddress)) || | ||
506 | (addrlen == sizeof (struct IPv6HttpAddress))); | ||
507 | |||
535 | /* look for existing connection */ | 508 | /* look for existing connection */ |
536 | s = lookup_session (plugin, target, session, addr, addrlen, 1); | 509 | s = lookup_session (plugin, target, session, addr, addrlen, 1); |
537 | #if DEBUG_HTTP | 510 | #if DEBUG_HTTP |