diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-11-14 13:18:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-11-14 13:18:49 +0000 |
commit | f9ff7db9da2213e1a643df8d27c0a959a289590b (patch) | |
tree | 4108e8438199baa936d0c0cdd3c33105c1ed81b1 /src/transport | |
parent | 560d7c072e4b894cb5b5b2e873df0fb16d603d21 (diff) | |
download | gnunet-f9ff7db9da2213e1a643df8d27c0a959a289590b.tar.gz gnunet-f9ff7db9da2213e1a643df8d27c0a959a289590b.zip |
-fix warnings, use proper types for addr
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index d69390055..896dc66b7 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -2213,7 +2213,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
2213 | static void | 2213 | static void |
2214 | read_process_msg (struct Plugin *plugin, | 2214 | read_process_msg (struct Plugin *plugin, |
2215 | const struct GNUNET_MessageHeader *msg, | 2215 | const struct GNUNET_MessageHeader *msg, |
2216 | const char *addr, | 2216 | const struct sockaddr *addr, |
2217 | socklen_t fromlen) | 2217 | socklen_t fromlen) |
2218 | { | 2218 | { |
2219 | if (ntohs (msg->size) < sizeof (struct UDPMessage)) | 2219 | if (ntohs (msg->size) < sizeof (struct UDPMessage)) |
@@ -2222,14 +2222,14 @@ read_process_msg (struct Plugin *plugin, | |||
2222 | return; | 2222 | return; |
2223 | } | 2223 | } |
2224 | process_udp_message (plugin, (const struct UDPMessage *) msg, | 2224 | process_udp_message (plugin, (const struct UDPMessage *) msg, |
2225 | (const struct sockaddr *) addr, fromlen); | 2225 | addr, fromlen); |
2226 | } | 2226 | } |
2227 | 2227 | ||
2228 | 2228 | ||
2229 | static void | 2229 | static void |
2230 | read_process_ack (struct Plugin *plugin, | 2230 | read_process_ack (struct Plugin *plugin, |
2231 | const struct GNUNET_MessageHeader *msg, | 2231 | const struct GNUNET_MessageHeader *msg, |
2232 | char *addr, | 2232 | const struct sockaddr *addr, |
2233 | socklen_t fromlen) | 2233 | socklen_t fromlen) |
2234 | { | 2234 | { |
2235 | const struct GNUNET_MessageHeader *ack; | 2235 | const struct GNUNET_MessageHeader *ack; |
@@ -2282,7 +2282,7 @@ read_process_ack (struct Plugin *plugin, | |||
2282 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2282 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2283 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", | 2283 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", |
2284 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), | 2284 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), |
2285 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 2285 | GNUNET_a2s (addr, fromlen)); |
2286 | /* Expect more ACKs to arrive */ | 2286 | /* Expect more ACKs to arrive */ |
2287 | return; | 2287 | return; |
2288 | } | 2288 | } |
@@ -2290,7 +2290,7 @@ read_process_ack (struct Plugin *plugin, | |||
2290 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2290 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2291 | "Message full ACK'ed\n", | 2291 | "Message full ACK'ed\n", |
2292 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), | 2292 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), |
2293 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 2293 | GNUNET_a2s (addr, fromlen)); |
2294 | 2294 | ||
2295 | /* Remove fragmented message after successful sending */ | 2295 | /* Remove fragmented message after successful sending */ |
2296 | fragmented_message_done (s->frag_ctx, GNUNET_OK); | 2296 | fragmented_message_done (s->frag_ctx, GNUNET_OK); |
@@ -2300,7 +2300,7 @@ read_process_ack (struct Plugin *plugin, | |||
2300 | static void | 2300 | static void |
2301 | read_process_fragment (struct Plugin *plugin, | 2301 | read_process_fragment (struct Plugin *plugin, |
2302 | const struct GNUNET_MessageHeader *msg, | 2302 | const struct GNUNET_MessageHeader *msg, |
2303 | char *addr, | 2303 | const struct sockaddr *addr, |
2304 | socklen_t fromlen) | 2304 | socklen_t fromlen) |
2305 | { | 2305 | { |
2306 | struct DefragContext *d_ctx; | 2306 | struct DefragContext *d_ctx; |
@@ -2308,12 +2308,12 @@ read_process_fragment (struct Plugin *plugin, | |||
2308 | struct FindReceiveContext frc; | 2308 | struct FindReceiveContext frc; |
2309 | 2309 | ||
2310 | frc.rc = NULL; | 2310 | frc.rc = NULL; |
2311 | frc.addr = (const struct sockaddr *) addr; | 2311 | frc.addr = addr; |
2312 | frc.addr_len = fromlen; | 2312 | frc.addr_len = fromlen; |
2313 | 2313 | ||
2314 | LOG (GNUNET_ERROR_TYPE_DEBUG, "UDP processes %u-byte fragment from `%s'\n", | 2314 | LOG (GNUNET_ERROR_TYPE_DEBUG, "UDP processes %u-byte fragment from `%s'\n", |
2315 | (unsigned int) ntohs (msg->size), | 2315 | (unsigned int) ntohs (msg->size), |
2316 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 2316 | GNUNET_a2s (addr, fromlen)); |
2317 | /* Lookup existing receive context for this address */ | 2317 | /* Lookup existing receive context for this address */ |
2318 | GNUNET_CONTAINER_heap_iterate (plugin->defrag_ctxs, | 2318 | GNUNET_CONTAINER_heap_iterate (plugin->defrag_ctxs, |
2319 | &find_receive_context, | 2319 | &find_receive_context, |
@@ -2340,14 +2340,14 @@ read_process_fragment (struct Plugin *plugin, | |||
2340 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2340 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2341 | "Created new defragmentation context for %u-byte fragment from `%s'\n", | 2341 | "Created new defragmentation context for %u-byte fragment from `%s'\n", |
2342 | (unsigned int) ntohs (msg->size), | 2342 | (unsigned int) ntohs (msg->size), |
2343 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 2343 | GNUNET_a2s (addr, fromlen)); |
2344 | } | 2344 | } |
2345 | else | 2345 | else |
2346 | { | 2346 | { |
2347 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2347 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2348 | "Found existing defragmentation context for %u-byte fragment from `%s'\n", | 2348 | "Found existing defragmentation context for %u-byte fragment from `%s'\n", |
2349 | (unsigned int) ntohs (msg->size), | 2349 | (unsigned int) ntohs (msg->size), |
2350 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 2350 | GNUNET_a2s (addr, fromlen)); |
2351 | } | 2351 | } |
2352 | 2352 | ||
2353 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag, msg)) | 2353 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag, msg)) |
@@ -2379,7 +2379,7 @@ static void | |||
2379 | udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | 2379 | udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) |
2380 | { | 2380 | { |
2381 | socklen_t fromlen; | 2381 | socklen_t fromlen; |
2382 | char addr[32]; | 2382 | struct sockaddr_storage addr; |
2383 | char buf[65536] GNUNET_ALIGN; | 2383 | char buf[65536] GNUNET_ALIGN; |
2384 | ssize_t size; | 2384 | ssize_t size; |
2385 | const struct GNUNET_MessageHeader *msg; | 2385 | const struct GNUNET_MessageHeader *msg; |
@@ -2387,7 +2387,7 @@ udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
2387 | fromlen = sizeof (addr); | 2387 | fromlen = sizeof (addr); |
2388 | memset (&addr, 0, sizeof (addr)); | 2388 | memset (&addr, 0, sizeof (addr)); |
2389 | size = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), | 2389 | size = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), |
2390 | (struct sockaddr *) &addr, &fromlen); | 2390 | (struct sockaddr *) &addr, &fromlen); |
2391 | #if MINGW | 2391 | #if MINGW |
2392 | /* On SOCK_DGRAM UDP sockets recvfrom might fail with a | 2392 | /* On SOCK_DGRAM UDP sockets recvfrom might fail with a |
2393 | * WSAECONNRESET error to indicate that previous sendto() (yes, sendto!) | 2393 | * WSAECONNRESET error to indicate that previous sendto() (yes, sendto!) |
@@ -2422,8 +2422,10 @@ udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
2422 | msg = (const struct GNUNET_MessageHeader *) buf; | 2422 | msg = (const struct GNUNET_MessageHeader *) buf; |
2423 | 2423 | ||
2424 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2424 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2425 | "UDP received %u-byte message from `%s' type %i\n", (unsigned int) size, | 2425 | "UDP received %u-byte message from `%s' type %u\n", |
2426 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs (msg->type)); | 2426 | (unsigned int) size, |
2427 | GNUNET_a2s ((const struct sockaddr *) &addr, fromlen), | ||
2428 | ntohs (msg->type)); | ||
2427 | 2429 | ||
2428 | if (size != ntohs (msg->size)) | 2430 | if (size != ntohs (msg->size)) |
2429 | { | 2431 | { |
@@ -2438,21 +2440,21 @@ udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
2438 | switch (ntohs (msg->type)) | 2440 | switch (ntohs (msg->type)) |
2439 | { | 2441 | { |
2440 | case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON: | 2442 | case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON: |
2441 | udp_broadcast_receive (plugin, buf, size, addr, fromlen); | 2443 | udp_broadcast_receive (plugin, buf, size, |
2444 | (const struct sockaddr *) &addr, fromlen); | ||
2442 | return; | 2445 | return; |
2443 | |||
2444 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE: | 2446 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE: |
2445 | read_process_msg (plugin, msg, addr, fromlen); | 2447 | read_process_msg (plugin, msg, |
2448 | (const struct sockaddr *) &addr, fromlen); | ||
2446 | return; | 2449 | return; |
2447 | |||
2448 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK: | 2450 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK: |
2449 | read_process_ack (plugin, msg, addr, fromlen); | 2451 | read_process_ack (plugin, msg, |
2452 | (const struct sockaddr *) &addr, fromlen); | ||
2450 | return; | 2453 | return; |
2451 | |||
2452 | case GNUNET_MESSAGE_TYPE_FRAGMENT: | 2454 | case GNUNET_MESSAGE_TYPE_FRAGMENT: |
2453 | read_process_fragment (plugin, msg, addr, fromlen); | 2455 | read_process_fragment (plugin, msg, |
2456 | (const struct sockaddr *) &addr, fromlen); | ||
2454 | return; | 2457 | return; |
2455 | |||
2456 | default: | 2458 | default: |
2457 | GNUNET_break_op (0); | 2459 | GNUNET_break_op (0); |
2458 | return; | 2460 | return; |