diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-13 16:02:44 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-13 16:02:44 +0000 |
commit | 2e2e5b4a8e5cebd71b880da8c613be4a49f44fe2 (patch) | |
tree | 270c64858fd4494c0d62970b7aa5926d185cef46 /src/transport/plugin_transport_wlan.c | |
parent | 5b9e61b9c3832e69164ee8574fff6711b2f18ef6 (diff) | |
download | gnunet-2e2e5b4a8e5cebd71b880da8c613be4a49f44fe2.tar.gz gnunet-2e2e5b4a8e5cebd71b880da8c613be4a49f44fe2.zip |
removing legacy send functions from plugins and renaming new send function
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 120 |
1 files changed, 1 insertions, 119 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 7bc345027..822a6701d 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -2329,123 +2329,6 @@ wlan_plugin_send (void *cls, | |||
2329 | 2329 | ||
2330 | 2330 | ||
2331 | /** | 2331 | /** |
2332 | * Function that can be used by the transport service to transmit | ||
2333 | * a message using the plugin. | ||
2334 | * | ||
2335 | * @param cls closure | ||
2336 | * @param target who should receive this message | ||
2337 | * @param priority how important is the message | ||
2338 | * @param msgbuf the message to transmit | ||
2339 | * @param msgbuf_size number of bytes in 'msgbuf' | ||
2340 | * @param timeout when should we time out | ||
2341 | * @param session which session must be used (or NULL for "any") | ||
2342 | * @param addr the address to use (can be NULL if the plugin | ||
2343 | * is "on its own" (i.e. re-use existing TCP connection)) | ||
2344 | * @param addrlen length of the address in bytes | ||
2345 | * @param force_address GNUNET_YES if the plugin MUST use the given address, | ||
2346 | * otherwise the plugin may use other addresses or | ||
2347 | * existing connections (if available) | ||
2348 | * @param cont continuation to call once the message has | ||
2349 | * been transmitted (or if the transport is ready | ||
2350 | * for the next transmission call; or if the | ||
2351 | * peer disconnected...) | ||
2352 | * @param cont_cls closure for cont | ||
2353 | * @return number of bytes used (on the physical network, with overheads); | ||
2354 | * -1 on hard errors (i.e. address invalid); 0 is a legal value | ||
2355 | * and does NOT mean that the message was not transmitted (DV) | ||
2356 | */ | ||
2357 | static ssize_t | ||
2358 | wlan_plugin_send_old (void *cls, const struct GNUNET_PeerIdentity *target, | ||
2359 | const char *msgbuf, size_t msgbuf_size, unsigned int priority, | ||
2360 | struct GNUNET_TIME_Relative timeout, struct Session *session, | ||
2361 | const void *addr, size_t addrlen, int force_address, | ||
2362 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | ||
2363 | { | ||
2364 | struct Plugin *plugin = cls; | ||
2365 | struct PendingMessage *newmsg; | ||
2366 | struct WlanHeader *wlanheader; | ||
2367 | |||
2368 | GNUNET_assert (plugin != NULL); | ||
2369 | //check if msglen > 0 | ||
2370 | GNUNET_assert (msgbuf_size > 0); | ||
2371 | |||
2372 | //get session if needed | ||
2373 | if (session == NULL) | ||
2374 | { | ||
2375 | if (wlan_plugin_address_suggested (plugin, addr, addrlen) == GNUNET_OK) | ||
2376 | { | ||
2377 | session = get_session (plugin, addr, target); | ||
2378 | } | ||
2379 | else | ||
2380 | { | ||
2381 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, | ||
2382 | _("Wlan Address len %d is wrong\n"), addrlen); | ||
2383 | return -1; | ||
2384 | } | ||
2385 | } | ||
2386 | |||
2387 | GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan messages queued"), 1, | ||
2388 | GNUNET_NO); | ||
2389 | |||
2390 | //queue message: | ||
2391 | |||
2392 | //queue message in session | ||
2393 | //test if there is no other message in the "queue" | ||
2394 | //FIXME: to many send requests | ||
2395 | if (session->pending_message_head != NULL) | ||
2396 | { | ||
2397 | newmsg = session->pending_message_head; | ||
2398 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
2399 | "wlan_plugin_send: a pending message is already in the queue for this client\n remaining time to send this message is %u, queued fragment messages for this mac connection %u\n", | ||
2400 | GNUNET_TIME_absolute_get_remaining (newmsg-> | ||
2401 | timeout).rel_value, | ||
2402 | session->mac->fragment_messages_out_count); | ||
2403 | } | ||
2404 | |||
2405 | newmsg = GNUNET_malloc (sizeof (struct PendingMessage)); | ||
2406 | newmsg->msg = GNUNET_malloc (msgbuf_size + sizeof (struct WlanHeader)); | ||
2407 | wlanheader = newmsg->msg; | ||
2408 | //copy msg to buffer, not fragmented / segmented yet, but with message header | ||
2409 | wlanheader->header.size = htons (msgbuf_size + sizeof (struct WlanHeader)); | ||
2410 | wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA); | ||
2411 | memcpy (&(wlanheader->target), target, sizeof (struct GNUNET_PeerIdentity)); | ||
2412 | memcpy (&(wlanheader->source), plugin->env->my_identity, | ||
2413 | sizeof (struct GNUNET_PeerIdentity)); | ||
2414 | wlanheader->crc = 0; | ||
2415 | memcpy (&wlanheader[1], msgbuf, msgbuf_size); | ||
2416 | wlanheader->crc = | ||
2417 | htonl (GNUNET_CRYPTO_crc32_n | ||
2418 | ((char *) wlanheader, msgbuf_size + sizeof (struct WlanHeader))); | ||
2419 | |||
2420 | newmsg->transmit_cont = cont; | ||
2421 | newmsg->transmit_cont_cls = cont_cls; | ||
2422 | newmsg->timeout = GNUNET_TIME_relative_to_absolute (timeout); | ||
2423 | |||
2424 | newmsg->timeout.abs_value = newmsg->timeout.abs_value - 500; | ||
2425 | |||
2426 | newmsg->message_size = msgbuf_size + sizeof (struct WlanHeader); | ||
2427 | |||
2428 | GNUNET_CONTAINER_DLL_insert_tail (session->pending_message_head, | ||
2429 | session->pending_message_tail, newmsg); | ||
2430 | |||
2431 | #if DEBUG_wlan | ||
2432 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
2433 | "New message for %p with size (incl wlan header) %u added\n", | ||
2434 | session, newmsg->message_size); | ||
2435 | #endif | ||
2436 | #if DEBUG_wlan_msg_dump > 1 | ||
2437 | hexdump (msgbuf, GNUNET_MIN (msgbuf_size, 256)); | ||
2438 | #endif | ||
2439 | //queue session | ||
2440 | queue_session (plugin, session); | ||
2441 | |||
2442 | check_fragment_queue (plugin); | ||
2443 | //FIXME not the correct size | ||
2444 | return msgbuf_size; | ||
2445 | |||
2446 | } | ||
2447 | |||
2448 | /** | ||
2449 | * function to free a mac endpoint | 2332 | * function to free a mac endpoint |
2450 | * @param plugin pointer to the plugin struct | 2333 | * @param plugin pointer to the plugin struct |
2451 | * @param endpoint pointer to the MacEndpoint to free | 2334 | * @param endpoint pointer to the MacEndpoint to free |
@@ -3396,8 +3279,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) | |||
3396 | 3279 | ||
3397 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 3280 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
3398 | api->cls = plugin; | 3281 | api->cls = plugin; |
3399 | api->send = &wlan_plugin_send_old; | 3282 | api->send = &wlan_plugin_send; |
3400 | api->send_with_session = &wlan_plugin_send; | ||
3401 | api->get_session = &wlan_plugin_get_session; | 3283 | api->get_session = &wlan_plugin_get_session; |
3402 | api->disconnect = &wlan_plugin_disconnect; | 3284 | api->disconnect = &wlan_plugin_disconnect; |
3403 | api->address_pretty_printer = &wlan_plugin_address_pretty_printer; | 3285 | api->address_pretty_printer = &wlan_plugin_address_pretty_printer; |