diff options
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 202 |
1 files changed, 116 insertions, 86 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 9bc579b2f..99d4f9fb1 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -138,6 +138,7 @@ enum UDP_MessageType | |||
138 | MSG_BEACON = 5 | 138 | MSG_BEACON = 5 |
139 | }; | 139 | }; |
140 | 140 | ||
141 | |||
141 | struct Session | 142 | struct Session |
142 | { | 143 | { |
143 | /** | 144 | /** |
@@ -145,7 +146,15 @@ struct Session | |||
145 | */ | 146 | */ |
146 | struct GNUNET_PeerIdentity target; | 147 | struct GNUNET_PeerIdentity target; |
147 | 148 | ||
148 | struct UDP_FragmentationContext * frag_ctx; | 149 | /** |
150 | * Plugin this session belongs to. | ||
151 | */ | ||
152 | struct Plugin *plugin; | ||
153 | |||
154 | /** | ||
155 | * Context for dealing with fragments. | ||
156 | */ | ||
157 | struct UDP_FragmentationContext *frag_ctx; | ||
149 | 158 | ||
150 | /** | 159 | /** |
151 | * Address of the other peer | 160 | * Address of the other peer |
@@ -179,9 +188,11 @@ struct Session | |||
179 | 188 | ||
180 | struct GNUNET_ATS_Information ats; | 189 | struct GNUNET_ATS_Information ats; |
181 | 190 | ||
191 | /** | ||
192 | * Number of bytes in @e sock_addr. | ||
193 | */ | ||
182 | size_t addrlen; | 194 | size_t addrlen; |
183 | 195 | ||
184 | |||
185 | unsigned int rc; | 196 | unsigned int rc; |
186 | 197 | ||
187 | int in_destroy; | 198 | int in_destroy; |
@@ -214,6 +225,7 @@ struct SourceInformation | |||
214 | const void *arg; | 225 | const void *arg; |
215 | 226 | ||
216 | struct Session *session; | 227 | struct Session *session; |
228 | |||
217 | /** | 229 | /** |
218 | * Number of bytes in source address. | 230 | * Number of bytes in source address. |
219 | */ | 231 | */ |
@@ -240,7 +252,7 @@ struct FindReceiveContext | |||
240 | struct Session *session; | 252 | struct Session *session; |
241 | 253 | ||
242 | /** | 254 | /** |
243 | * Number of bytes in 'addr'. | 255 | * Number of bytes in @e addr. |
244 | */ | 256 | */ |
245 | socklen_t addr_len; | 257 | socklen_t addr_len; |
246 | 258 | ||
@@ -292,27 +304,27 @@ struct UDP_FragmentationContext | |||
292 | /** | 304 | /** |
293 | * Next in linked list | 305 | * Next in linked list |
294 | */ | 306 | */ |
295 | struct UDP_FragmentationContext * next; | 307 | struct UDP_FragmentationContext *next; |
296 | 308 | ||
297 | /** | 309 | /** |
298 | * Previous in linked list | 310 | * Previous in linked list |
299 | */ | 311 | */ |
300 | struct UDP_FragmentationContext * prev; | 312 | struct UDP_FragmentationContext *prev; |
301 | 313 | ||
302 | /** | 314 | /** |
303 | * The plugin | 315 | * The plugin |
304 | */ | 316 | */ |
305 | struct Plugin * plugin; | 317 | struct Plugin *plugin; |
306 | 318 | ||
307 | /** | 319 | /** |
308 | * Handle for GNUNET_FRAGMENT context | 320 | * Handle for GNUNET_FRAGMENT context |
309 | */ | 321 | */ |
310 | struct GNUNET_FRAGMENT_Context * frag; | 322 | struct GNUNET_FRAGMENT_Context *frag; |
311 | 323 | ||
312 | /** | 324 | /** |
313 | * The session this fragmentation context belongs to | 325 | * The session this fragmentation context belongs to |
314 | */ | 326 | */ |
315 | struct Session * session; | 327 | struct Session *session; |
316 | 328 | ||
317 | /** | 329 | /** |
318 | * Function to call upon completion of the transmission. | 330 | * Function to call upon completion of the transmission. |
@@ -320,7 +332,7 @@ struct UDP_FragmentationContext | |||
320 | GNUNET_TRANSPORT_TransmitContinuation cont; | 332 | GNUNET_TRANSPORT_TransmitContinuation cont; |
321 | 333 | ||
322 | /** | 334 | /** |
323 | * Closure for 'cont'. | 335 | * Closure for @e cont. |
324 | */ | 336 | */ |
325 | void *cont_cls; | 337 | void *cont_cls; |
326 | 338 | ||
@@ -1110,7 +1122,8 @@ free_session (struct Session *s) | |||
1110 | 1122 | ||
1111 | 1123 | ||
1112 | static void | 1124 | static void |
1113 | dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | 1125 | dequeue (struct Plugin *plugin, |
1126 | struct UDP_MessageWrapper * udpw) | ||
1114 | { | 1127 | { |
1115 | if (plugin->bytes_in_buffer < udpw->msg_size) | 1128 | if (plugin->bytes_in_buffer < udpw->msg_size) |
1116 | GNUNET_break (0); | 1129 | GNUNET_break (0); |
@@ -1195,28 +1208,33 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result) | |||
1195 | &s->last_expected_msg_delay, | 1208 | &s->last_expected_msg_delay, |
1196 | &s->last_expected_ack_delay); | 1209 | &s->last_expected_ack_delay); |
1197 | s->frag_ctx = NULL; | 1210 | s->frag_ctx = NULL; |
1198 | GNUNET_free (fc ); | 1211 | GNUNET_free (fc); |
1199 | } | 1212 | } |
1200 | 1213 | ||
1214 | |||
1201 | /** | 1215 | /** |
1202 | * Functions with this signature are called whenever we need | 1216 | * Functions with this signature are called whenever we need |
1203 | * to close a session due to a disconnect or failure to | 1217 | * to close a session due to a disconnect or failure to |
1204 | * establish a connection. | 1218 | * establish a connection. |
1205 | * | 1219 | * |
1220 | * @param cls closure with the `struct Plugin` | ||
1206 | * @param s session to close down | 1221 | * @param s session to close down |
1222 | * @return #GNUNET_OK on success | ||
1207 | */ | 1223 | */ |
1208 | static void | 1224 | static int |
1209 | disconnect_session (struct Session *s) | 1225 | udp_disconnect_session (void *cls, |
1226 | struct Session *s) | ||
1210 | { | 1227 | { |
1228 | struct Plugin *plugin = cls; | ||
1211 | struct UDP_MessageWrapper *udpw; | 1229 | struct UDP_MessageWrapper *udpw; |
1212 | struct UDP_MessageWrapper *next; | 1230 | struct UDP_MessageWrapper *next; |
1213 | 1231 | ||
1214 | GNUNET_assert (GNUNET_YES != s->in_destroy); | 1232 | GNUNET_assert (GNUNET_YES != s->in_destroy); |
1215 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1233 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1216 | "Session %p to peer `%s' address ended \n", | 1234 | "Session %p to peer `%s' address ended\n", |
1217 | s, | 1235 | s, |
1218 | GNUNET_i2s (&s->target), | 1236 | GNUNET_i2s (&s->target), |
1219 | GNUNET_a2s (s->sock_addr, s->addrlen)); | 1237 | GNUNET_a2s (s->sock_addr, s->addrlen)); |
1220 | stop_session_timeout (s); | 1238 | stop_session_timeout (s); |
1221 | 1239 | ||
1222 | if (NULL != s->frag_ctx) | 1240 | if (NULL != s->frag_ctx) |
@@ -1232,7 +1250,7 @@ disconnect_session (struct Session *s) | |||
1232 | if (udpw->session == s) | 1250 | if (udpw->session == s) |
1233 | { | 1251 | { |
1234 | dequeue (plugin, udpw); | 1252 | dequeue (plugin, udpw); |
1235 | call_continuation(udpw, GNUNET_SYSERR); | 1253 | call_continuation (udpw, GNUNET_SYSERR); |
1236 | GNUNET_free (udpw); | 1254 | GNUNET_free (udpw); |
1237 | } | 1255 | } |
1238 | } | 1256 | } |
@@ -1243,7 +1261,7 @@ disconnect_session (struct Session *s) | |||
1243 | if (udpw->session == s) | 1261 | if (udpw->session == s) |
1244 | { | 1262 | { |
1245 | dequeue (plugin, udpw); | 1263 | dequeue (plugin, udpw); |
1246 | call_continuation(udpw, GNUNET_SYSERR); | 1264 | call_continuation (udpw, GNUNET_SYSERR); |
1247 | GNUNET_free (udpw); | 1265 | GNUNET_free (udpw); |
1248 | } | 1266 | } |
1249 | } | 1267 | } |
@@ -1265,48 +1283,55 @@ disconnect_session (struct Session *s) | |||
1265 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, | 1283 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, |
1266 | &s->target, | 1284 | &s->target, |
1267 | s)); | 1285 | s)); |
1268 | GNUNET_STATISTICS_set(plugin->env->stats, | 1286 | GNUNET_STATISTICS_set (plugin->env->stats, |
1269 | "# UDP, sessions active", | 1287 | "# UDP, sessions active", |
1270 | GNUNET_CONTAINER_multipeermap_size(plugin->sessions), | 1288 | GNUNET_CONTAINER_multipeermap_size(plugin->sessions), |
1271 | GNUNET_NO); | 1289 | GNUNET_NO); |
1272 | if (s->rc > 0) | 1290 | if (s->rc > 0) |
1273 | s->in_destroy = GNUNET_YES; | 1291 | s->in_destroy = GNUNET_YES; |
1274 | else | 1292 | else |
1275 | free_session (s); | 1293 | free_session (s); |
1294 | return GNUNET_OK; | ||
1276 | } | 1295 | } |
1277 | 1296 | ||
1297 | |||
1278 | /** | 1298 | /** |
1279 | * Destroy a session, plugin is being unloaded. | 1299 | * Destroy a session, plugin is being unloaded. |
1280 | * | 1300 | * |
1281 | * @param cls unused | 1301 | * @param cls the `struct Plugin` |
1282 | * @param key hash of public key of target peer | 1302 | * @param key hash of public key of target peer |
1283 | * @param value a 'struct PeerSession*' to clean up | 1303 | * @param value a `struct PeerSession *` to clean up |
1284 | * @return GNUNET_OK (continue to iterate) | 1304 | * @return #GNUNET_OK (continue to iterate) |
1285 | */ | 1305 | */ |
1286 | static int | 1306 | static int |
1287 | disconnect_and_free_it (void *cls, const struct GNUNET_PeerIdentity * key, void *value) | 1307 | disconnect_and_free_it (void *cls, |
1308 | const struct GNUNET_PeerIdentity *key, | ||
1309 | void *value) | ||
1288 | { | 1310 | { |
1289 | disconnect_session(value); | 1311 | struct Plugin *plugin = cls; |
1312 | |||
1313 | udp_disconnect_session (plugin, value); | ||
1290 | return GNUNET_OK; | 1314 | return GNUNET_OK; |
1291 | } | 1315 | } |
1292 | 1316 | ||
1293 | 1317 | ||
1294 | /** | 1318 | /** |
1295 | * Disconnect from a remote node. Clean up session if we have one for this peer | 1319 | * Disconnect from a remote node. Clean up session if we have one for |
1320 | * this peer. | ||
1296 | * | 1321 | * |
1297 | * @param cls closure for this call (should be handle to Plugin) | 1322 | * @param cls closure for this call (should be handle to Plugin) |
1298 | * @param target the peeridentity of the peer to disconnect | 1323 | * @param target the peeridentity of the peer to disconnect |
1299 | * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed | 1324 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed |
1300 | */ | 1325 | */ |
1301 | static void | 1326 | static void |
1302 | udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | 1327 | udp_disconnect (void *cls, |
1328 | const struct GNUNET_PeerIdentity *target) | ||
1303 | { | 1329 | { |
1304 | struct Plugin *plugin = cls; | 1330 | struct Plugin *plugin = cls; |
1305 | GNUNET_assert (plugin != NULL); | ||
1306 | 1331 | ||
1307 | GNUNET_assert (target != NULL); | ||
1308 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1332 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1309 | "Disconnecting from peer `%s'\n", GNUNET_i2s (target)); | 1333 | "Disconnecting from peer `%s'\n", |
1334 | GNUNET_i2s (target)); | ||
1310 | /* Clean up sessions */ | 1335 | /* Clean up sessions */ |
1311 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessions, target, | 1336 | GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessions, target, |
1312 | &disconnect_and_free_it, plugin); | 1337 | &disconnect_and_free_it, plugin); |
@@ -1317,9 +1342,9 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
1317 | * Session was idle, so disconnect it | 1342 | * Session was idle, so disconnect it |
1318 | */ | 1343 | */ |
1319 | static void | 1344 | static void |
1320 | session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1345 | session_timeout (void *cls, |
1346 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1321 | { | 1347 | { |
1322 | GNUNET_assert (NULL != cls); | ||
1323 | struct Session *s = cls; | 1348 | struct Session *s = cls; |
1324 | 1349 | ||
1325 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1350 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -1329,7 +1354,8 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1329 | GNUNET_STRINGS_relative_time_to_string (UDP_SESSION_TIME_OUT, | 1354 | GNUNET_STRINGS_relative_time_to_string (UDP_SESSION_TIME_OUT, |
1330 | GNUNET_YES)); | 1355 | GNUNET_YES)); |
1331 | /* call session destroy function */ | 1356 | /* call session destroy function */ |
1332 | disconnect_session (s); | 1357 | udp_disconnect_session (s->plugin, |
1358 | s); | ||
1333 | } | 1359 | } |
1334 | 1360 | ||
1335 | 1361 | ||
@@ -1374,7 +1400,8 @@ reschedule_session_timeout (struct Session *s) | |||
1374 | 1400 | ||
1375 | 1401 | ||
1376 | static struct Session * | 1402 | static struct Session * |
1377 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | 1403 | create_session (struct Plugin *plugin, |
1404 | const struct GNUNET_PeerIdentity *target, | ||
1378 | const void *addr, size_t addrlen, | 1405 | const void *addr, size_t addrlen, |
1379 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 1406 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
1380 | { | 1407 | { |
@@ -1387,8 +1414,8 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
1387 | 1414 | ||
1388 | if (NULL == addr) | 1415 | if (NULL == addr) |
1389 | { | 1416 | { |
1390 | GNUNET_break (0); | 1417 | GNUNET_break (0); |
1391 | return NULL; | 1418 | return NULL; |
1392 | } | 1419 | } |
1393 | 1420 | ||
1394 | switch (addrlen) | 1421 | switch (addrlen) |
@@ -1399,11 +1426,12 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
1399 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1426 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1400 | "Could not create session for peer `%s' address `%s': IPv4 is not enabled\n", | 1427 | "Could not create session for peer `%s' address `%s': IPv4 is not enabled\n", |
1401 | GNUNET_i2s(target), | 1428 | GNUNET_i2s(target), |
1402 | udp_address_to_string(NULL, addr, addrlen)); | 1429 | udp_address_to_string (NULL, addr, addrlen)); |
1403 | return NULL; | 1430 | return NULL; |
1404 | } | 1431 | } |
1405 | t4 = addr; | 1432 | t4 = addr; |
1406 | s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in)); | 1433 | s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in)); |
1434 | s->plugin = plugin; | ||
1407 | len = sizeof (struct sockaddr_in); | 1435 | len = sizeof (struct sockaddr_in); |
1408 | v4 = (struct sockaddr_in *) &s[1]; | 1436 | v4 = (struct sockaddr_in *) &s[1]; |
1409 | v4->sin_family = AF_INET; | 1437 | v4->sin_family = AF_INET; |
@@ -1425,6 +1453,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
1425 | } | 1453 | } |
1426 | t6 = addr; | 1454 | t6 = addr; |
1427 | s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6)); | 1455 | s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6)); |
1456 | s->plugin = plugin; | ||
1428 | len = sizeof (struct sockaddr_in6); | 1457 | len = sizeof (struct sockaddr_in6); |
1429 | v6 = (struct sockaddr_in6 *) &s[1]; | 1458 | v6 = (struct sockaddr_in6 *) &s[1]; |
1430 | v6->sin6_family = AF_INET6; | 1459 | v6->sin6_family = AF_INET6; |
@@ -1512,7 +1541,7 @@ session_cmp_it (void *cls, | |||
1512 | * | 1541 | * |
1513 | * @param cls closure ('struct Plugin*') | 1542 | * @param cls closure ('struct Plugin*') |
1514 | * @param session the session | 1543 | * @param session the session |
1515 | * @return the network type in HBO or GNUNET_SYSERR | 1544 | * @return the network type in HBO or #GNUNET_SYSERR |
1516 | */ | 1545 | */ |
1517 | static enum GNUNET_ATS_Network_Type | 1546 | static enum GNUNET_ATS_Network_Type |
1518 | udp_get_network (void *cls, | 1547 | udp_get_network (void *cls, |
@@ -2991,7 +3020,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2991 | { | 3020 | { |
2992 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully | 3021 | /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully |
2993 | initialze the plugin or the API */ | 3022 | initialze the plugin or the API */ |
2994 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 3023 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); |
2995 | api->cls = NULL; | 3024 | api->cls = NULL; |
2996 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; | 3025 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; |
2997 | api->address_to_string = &udp_address_to_string; | 3026 | api->address_to_string = &udp_address_to_string; |
@@ -3002,8 +3031,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3002 | GNUNET_assert (NULL != env->stats); | 3031 | GNUNET_assert (NULL != env->stats); |
3003 | 3032 | ||
3004 | /* Get port number: port == 0 : autodetect a port, | 3033 | /* Get port number: port == 0 : autodetect a port, |
3005 | * > 0 : use this port, | 3034 | * > 0 : use this port, not given : 2086 default */ |
3006 | * not given : 2086 default */ | ||
3007 | if (GNUNET_OK != | 3035 | if (GNUNET_OK != |
3008 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "PORT", | 3036 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "PORT", |
3009 | &port)) | 3037 | &port)) |
@@ -3097,7 +3125,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3097 | udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */ | 3125 | udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */ |
3098 | } | 3126 | } |
3099 | 3127 | ||
3100 | p = GNUNET_malloc (sizeof (struct Plugin)); | 3128 | p = GNUNET_new (struct Plugin); |
3101 | p->port = port; | 3129 | p->port = port; |
3102 | p->aport = aport; | 3130 | p->aport = aport; |
3103 | p->broadcast_interval = interval; | 3131 | p->broadcast_interval = interval; |
@@ -3130,10 +3158,11 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3130 | setup_broadcast (p, &server_addrv6, &server_addrv4); | 3158 | setup_broadcast (p, &server_addrv6, &server_addrv4); |
3131 | } | 3159 | } |
3132 | 3160 | ||
3133 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 3161 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); |
3134 | api->cls = p; | 3162 | api->cls = p; |
3135 | api->send = NULL; | 3163 | api->send = NULL; |
3136 | api->disconnect = &udp_disconnect; | 3164 | api->disconnect_session = &udp_disconnect_session; |
3165 | api->disconnect_peer = &udp_disconnect; | ||
3137 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; | 3166 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; |
3138 | api->address_to_string = &udp_address_to_string; | 3167 | api->address_to_string = &udp_address_to_string; |
3139 | api->string_to_address = &udp_string_to_address; | 3168 | api->string_to_address = &udp_string_to_address; |
@@ -3148,10 +3177,9 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3148 | 3177 | ||
3149 | static int | 3178 | static int |
3150 | heap_cleanup_iterator (void *cls, | 3179 | heap_cleanup_iterator (void *cls, |
3151 | struct GNUNET_CONTAINER_HeapNode * | 3180 | struct GNUNET_CONTAINER_HeapNode *node, |
3152 | node, void *element, | 3181 | void *element, |
3153 | GNUNET_CONTAINER_HeapCostType | 3182 | GNUNET_CONTAINER_HeapCostType cost) |
3154 | cost) | ||
3155 | { | 3183 | { |
3156 | struct DefragContext * d_ctx = element; | 3184 | struct DefragContext * d_ctx = element; |
3157 | 3185 | ||
@@ -3197,35 +3225,37 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
3197 | } | 3225 | } |
3198 | 3226 | ||
3199 | /* Closing sockets */ | 3227 | /* Closing sockets */ |
3200 | if (GNUNET_YES ==plugin->enable_ipv4) | 3228 | if (GNUNET_YES == plugin->enable_ipv4) |
3201 | { | 3229 | { |
3202 | if (plugin->sockv4 != NULL) | 3230 | if (NULL != plugin->sockv4) |
3203 | { | 3231 | { |
3204 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4)); | 3232 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4)); |
3205 | plugin->sockv4 = NULL; | 3233 | plugin->sockv4 = NULL; |
3206 | } | 3234 | } |
3207 | GNUNET_NETWORK_fdset_destroy (plugin->rs_v4); | 3235 | GNUNET_NETWORK_fdset_destroy (plugin->rs_v4); |
3208 | GNUNET_NETWORK_fdset_destroy (plugin->ws_v4); | 3236 | GNUNET_NETWORK_fdset_destroy (plugin->ws_v4); |
3209 | } | 3237 | } |
3210 | if (GNUNET_YES ==plugin->enable_ipv6) | 3238 | if (GNUNET_YES == plugin->enable_ipv6) |
3211 | { | 3239 | { |
3212 | if (plugin->sockv6 != NULL) | 3240 | if (NULL != plugin->sockv6) |
3213 | { | 3241 | { |
3214 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv6)); | 3242 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv6)); |
3215 | plugin->sockv6 = NULL; | 3243 | plugin->sockv6 = NULL; |
3216 | 3244 | ||
3217 | GNUNET_NETWORK_fdset_destroy (plugin->rs_v6); | 3245 | GNUNET_NETWORK_fdset_destroy (plugin->rs_v6); |
3218 | GNUNET_NETWORK_fdset_destroy (plugin->ws_v6); | 3246 | GNUNET_NETWORK_fdset_destroy (plugin->ws_v6); |
3219 | } | 3247 | } |
3220 | } | 3248 | } |
3221 | if (NULL != plugin->nat) | 3249 | if (NULL != plugin->nat) |
3222 | GNUNET_NAT_unregister (plugin->nat); | ||
3223 | |||
3224 | if (plugin->defrag_ctxs != NULL) | ||
3225 | { | 3250 | { |
3226 | GNUNET_CONTAINER_heap_iterate(plugin->defrag_ctxs, | 3251 | GNUNET_NAT_unregister (plugin->nat); |
3227 | heap_cleanup_iterator, NULL); | 3252 | plugin->nat = NULL; |
3228 | GNUNET_CONTAINER_heap_destroy(plugin->defrag_ctxs); | 3253 | } |
3254 | if (NULL != plugin->defrag_ctxs) | ||
3255 | { | ||
3256 | GNUNET_CONTAINER_heap_iterate (plugin->defrag_ctxs, | ||
3257 | heap_cleanup_iterator, NULL); | ||
3258 | GNUNET_CONTAINER_heap_destroy (plugin->defrag_ctxs); | ||
3229 | plugin->defrag_ctxs = NULL; | 3259 | plugin->defrag_ctxs = NULL; |
3230 | } | 3260 | } |
3231 | if (plugin->mst != NULL) | 3261 | if (plugin->mst != NULL) |
@@ -3266,12 +3296,12 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
3266 | next = ppc_dll_head; | 3296 | next = ppc_dll_head; |
3267 | for (cur = next; NULL != cur; cur = next) | 3297 | for (cur = next; NULL != cur; cur = next) |
3268 | { | 3298 | { |
3269 | next = cur->next; | 3299 | next = cur->next; |
3270 | GNUNET_CONTAINER_DLL_remove (ppc_dll_head, ppc_dll_tail, cur); | 3300 | GNUNET_CONTAINER_DLL_remove (ppc_dll_head, ppc_dll_tail, cur); |
3271 | GNUNET_RESOLVER_request_cancel (cur->resolver_handle); | 3301 | GNUNET_RESOLVER_request_cancel (cur->resolver_handle); |
3272 | GNUNET_SCHEDULER_cancel (cur->timeout_task); | 3302 | GNUNET_SCHEDULER_cancel (cur->timeout_task); |
3273 | GNUNET_free (cur); | 3303 | GNUNET_free (cur); |
3274 | GNUNET_break (0); | 3304 | GNUNET_break (0); |
3275 | } | 3305 | } |
3276 | 3306 | ||
3277 | plugin->nat = NULL; | 3307 | plugin->nat = NULL; |
@@ -3281,16 +3311,16 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
3281 | struct Allocation *allocation; | 3311 | struct Allocation *allocation; |
3282 | while (NULL != ahead) | 3312 | while (NULL != ahead) |
3283 | { | 3313 | { |
3284 | allocation = ahead; | 3314 | allocation = ahead; |
3285 | GNUNET_CONTAINER_DLL_remove (ahead, atail, allocation); | 3315 | GNUNET_CONTAINER_DLL_remove (ahead, atail, allocation); |
3286 | GNUNET_free (allocation); | 3316 | GNUNET_free (allocation); |
3287 | } | 3317 | } |
3288 | struct Allocator *allocator; | 3318 | struct Allocator *allocator; |
3289 | while (NULL != aehead) | 3319 | while (NULL != aehead) |
3290 | { | 3320 | { |
3291 | allocator = aehead; | 3321 | allocator = aehead; |
3292 | GNUNET_CONTAINER_DLL_remove (aehead, aetail, allocator); | 3322 | GNUNET_CONTAINER_DLL_remove (aehead, aetail, allocator); |
3293 | GNUNET_free (allocator); | 3323 | GNUNET_free (allocator); |
3294 | } | 3324 | } |
3295 | #endif | 3325 | #endif |
3296 | return NULL; | 3326 | return NULL; |