diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-01 18:00:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-01 18:00:31 +0000 |
commit | 3629ff42683654fe6dcc6463a77faaeb27ae3203 (patch) | |
tree | b550ea4d979ebcb68e39f44df82ddb0ec7b9b055 /src/transport/plugin_transport_udp.h | |
parent | 079d2f0b130d3f6e830a4d8567f43e03782ae2cb (diff) | |
download | gnunet-3629ff42683654fe6dcc6463a77faaeb27ae3203.tar.gz gnunet-3629ff42683654fe6dcc6463a77faaeb27ae3203.zip |
cleaning up UDP code to use only on address format throughout the code as much as possible
Diffstat (limited to 'src/transport/plugin_transport_udp.h')
-rw-r--r-- | src/transport/plugin_transport_udp.h | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/src/transport/plugin_transport_udp.h b/src/transport/plugin_transport_udp.h index 2e77b9010..88a3a9997 100644 --- a/src/transport/plugin_transport_udp.h +++ b/src/transport/plugin_transport_udp.h | |||
@@ -102,6 +102,23 @@ struct IPv6UdpAddress | |||
102 | }; | 102 | }; |
103 | GNUNET_NETWORK_STRUCT_END | 103 | GNUNET_NETWORK_STRUCT_END |
104 | 104 | ||
105 | /** | ||
106 | * Either an IPv4 or IPv6 UDP address. Note that without a "length", | ||
107 | * one cannot tell which one of the two types this address represents. | ||
108 | */ | ||
109 | union UdpAddress | ||
110 | { | ||
111 | /** | ||
112 | * IPv4 case. | ||
113 | */ | ||
114 | struct IPv4UdpAddress v4; | ||
115 | |||
116 | /** | ||
117 | * IPv6 case. | ||
118 | */ | ||
119 | struct IPv6UdpAddress v6; | ||
120 | }; | ||
121 | |||
105 | 122 | ||
106 | /** | 123 | /** |
107 | * UDP Message-Packet header (after defragmentation). | 124 | * UDP Message-Packet header (after defragmentation). |
@@ -155,12 +172,12 @@ struct Plugin | |||
155 | /** | 172 | /** |
156 | * ID of select task for IPv4 | 173 | * ID of select task for IPv4 |
157 | */ | 174 | */ |
158 | struct GNUNET_SCHEDULER_Task * select_task; | 175 | struct GNUNET_SCHEDULER_Task *select_task; |
159 | 176 | ||
160 | /** | 177 | /** |
161 | * ID of select task for IPv6 | 178 | * ID of select task for IPv6 |
162 | */ | 179 | */ |
163 | struct GNUNET_SCHEDULER_Task * select_task_v6; | 180 | struct GNUNET_SCHEDULER_Task *select_task_v6; |
164 | 181 | ||
165 | /** | 182 | /** |
166 | * Tokenizer for inbound messages. | 183 | * Tokenizer for inbound messages. |
@@ -218,14 +235,9 @@ struct Plugin | |||
218 | struct GNUNET_NETWORK_Handle *sockv6; | 235 | struct GNUNET_NETWORK_Handle *sockv6; |
219 | 236 | ||
220 | /** | 237 | /** |
221 | * Tokenizer for inbound IPv6 messages. | 238 | * Tokenizer for inbound messages. |
222 | */ | ||
223 | struct GNUNET_SERVER_MessageStreamTokenizer *broadcast_ipv6_mst; | ||
224 | |||
225 | /** | ||
226 | * Tokenizer for inbound IPv4 messages. | ||
227 | */ | 239 | */ |
228 | struct GNUNET_SERVER_MessageStreamTokenizer *broadcast_ipv4_mst; | 240 | struct GNUNET_SERVER_MessageStreamTokenizer *broadcast_mst; |
229 | 241 | ||
230 | /** | 242 | /** |
231 | * Head of DLL of broadcast addresses | 243 | * Head of DLL of broadcast addresses |
@@ -336,20 +348,37 @@ struct Plugin | |||
336 | 348 | ||
337 | 349 | ||
338 | const char * | 350 | const char * |
339 | udp_address_to_string (void *cls, const void *addr, size_t addrlen); | 351 | udp_address_to_string (void *cls, |
352 | const void *addr, | ||
353 | size_t addrlen); | ||
354 | |||
340 | 355 | ||
356 | /** | ||
357 | * We received a broadcast message. Process it and all subsequent | ||
358 | * messages in the same packet. | ||
359 | * | ||
360 | * @param plugin the UDP plugin | ||
361 | * @param buf the buffer with the message(s) | ||
362 | * @param size number of bytes in @a buf | ||
363 | * @param udp_addr address of the sender | ||
364 | * @param udp_addr_len number of bytes in @a udp_addr | ||
365 | * @param network_type network type of the sender's address | ||
366 | */ | ||
341 | void | 367 | void |
342 | udp_broadcast_receive (struct Plugin *plugin, | 368 | udp_broadcast_receive (struct Plugin *plugin, |
343 | const char * buf, | 369 | const char *buf, |
344 | ssize_t size, | 370 | ssize_t size, |
345 | const struct sockaddr *addr, | 371 | const union UdpAddress *udp_addr, |
346 | size_t addrlen); | 372 | size_t udp_addr_len, |
373 | enum GNUNET_ATS_Network_Type network_type); | ||
374 | |||
347 | 375 | ||
348 | void | 376 | void |
349 | setup_broadcast (struct Plugin *plugin, | 377 | setup_broadcast (struct Plugin *plugin, |
350 | struct sockaddr_in6 *server_addrv6, | 378 | struct sockaddr_in6 *server_addrv6, |
351 | struct sockaddr_in *server_addrv4); | 379 | struct sockaddr_in *server_addrv4); |
352 | 380 | ||
381 | |||
353 | void | 382 | void |
354 | stop_broadcast (struct Plugin *plugin); | 383 | stop_broadcast (struct Plugin *plugin); |
355 | 384 | ||