-static void
-wlan_data_helper(void *cls, struct Session_light * session_light,
- const struct GNUNET_MessageHeader * hdr, const struct Radiotap_rx * rxinfo)
-{
- struct Plugin *plugin = cls;
- struct FragmentMessage * fm;
- struct FragmentMessage * fm2;
-
- //ADVERTISEMENT
- if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT)
- {
-
- //TODO better DOS protection, error handling
- //TODO test first than create session
- GNUNET_assert(session_light != NULL);
-
-#if DEBUG_wlan
- GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT size: %u; %s\n",
- ntohs(hdr->size),
- wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6));
-#endif
-
- if (session_light->macendpoint == NULL)
- {
- session_light->macendpoint = get_macendpoint(plugin,
- &session_light->addr, GNUNET_NO);
- }
- GNUNET_assert(GNUNET_HELLO_get_id(
- (const struct GNUNET_HELLO_Message *) &hdr[1],
- &(session_light->session->target) ) != GNUNET_SYSERR);
-
- }
-
- //FRAGMENT
-
- else if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_FRAGMENT)
- {
-
- GNUNET_assert(session_light != NULL);
- if (session_light->macendpoint == NULL)
- {
- session_light->macendpoint = get_macendpoint(plugin,
- &session_light->addr, GNUNET_YES);
- }
-
-#if DEBUG_wlan
- GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT with size: %u; mac endpoint %p: %s\n",
- ntohs(hdr->size), session_light->macendpoint,
- wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6));
-#endif
-
- int ret = GNUNET_DEFRAGMENT_process_fragment(
- session_light->macendpoint->defrag, hdr);
- if (ret == GNUNET_NO)
- {
- session_light->macendpoint->dups++;
- }
- else if (ret == GNUNET_OK)
- {
- session_light->macendpoint->fragc++;
- }
- set_next_send(plugin);
-
- }
-
- //ACK
-
- else if (ntohs(hdr->type) == GNUNET_MESSAGE_TYPE_FRAGMENT_ACK)
- {
- GNUNET_assert(session_light != NULL);
- if (session_light->macendpoint == NULL)
- {
- session_light->macendpoint = get_macendpoint(plugin,
- &session_light->addr, GNUNET_NO);
- }
-
- if (session_light->macendpoint == NULL)
- {
-#if DEBUG_wlan
- GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Macendpoint does not exist for this GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; %s\n",
- ntohs(hdr->size),
- wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6));
-#endif
- return;
- }
-
-#if DEBUG_wlan
- GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Func wlan_data_helper got GNUNET_MESSAGE_TYPE_FRAGMENT_ACK size: %u; mac endpoint: %p; %s\n",
- ntohs(hdr->size), session_light->macendpoint,
- wlan_plugin_address_to_string(NULL, session_light->addr.mac, 6));
-#endif
- fm = session_light->macendpoint->sending_messages_head;
- while (fm != NULL)
- {
- fm2 = fm->next;
- int ret = GNUNET_FRAGMENT_process_ack(fm->fragcontext, hdr);
- if (ret == GNUNET_OK)
- {
-#if DEBUG_wlan_retransmission
- GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Got last ack, finished fragment message %p\n", fm);
-#endif
- session_light->macendpoint->acks++;
- fm->session->last_activity = GNUNET_TIME_absolute_get();
- session_light->macendpoint->last_activity = fm->session->last_activity;
- free_fragment_message(plugin, fm);
- check_fragment_queue(plugin);
- return;
- }
- if (ret == GNUNET_NO)
- {
-#if DEBUG_wlan_retransmission
- GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, "Got ack for: %p\n", fm);
-#endif
- session_light->macendpoint->acks++;
- return;
- }
- if (ret == GNUNET_SYSERR)
- {
-
- }
-
- fm = fm2;
- }
-
-#if DEBUG_wlan_retransmission
- GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "WLAN fragment not in fragment list\n");
-#endif
- return;
-
- }
- else
- {
- // TODO Wrong data?
- GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
- "WLAN packet inside the WLAN helper packet has not the right type: %u size: %u\n",
- ntohs(hdr->type), ntohs(hdr->size));
- GNUNET_break(0);
- return;
- }
-
-#if 0
- GNUNET_log_from(GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
- "Helper finished\n");
-#endif
-
-}
-
-//TODO DOXIGEN
-const char *
-macprinter(const u_int8_t * mac)