aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorDavid Brodski <david@brodski.eu>2011-03-02 17:32:43 +0000
committerDavid Brodski <david@brodski.eu>2011-03-02 17:32:43 +0000
commitef147778f4ada88486a3d0584b34ba8889742249 (patch)
treec8bce28e1aab82da3bb49605a38c15b0f73400d8 /src/transport/plugin_transport_wlan.c
parentc02ded5c6ae07691831a734d285f6bd7eeff3d59 (diff)
downloadgnunet-ef147778f4ada88486a3d0584b34ba8889742249.tar.gz
gnunet-ef147778f4ada88486a3d0584b34ba8889742249.zip
messages are split correctly, test works now
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c79
1 files changed, 58 insertions, 21 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index bb55058ff..c4903dd9c 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -51,7 +51,7 @@
51 51
52#define HALLO_BEACON_SCALING_FACTOR 900 52#define HALLO_BEACON_SCALING_FACTOR 900
53 53
54#define DEBUG_wlan GNUNET_YES 54#define DEBUG_wlan GNUNET_NO
55 55
56#define MESSAGE_LENGHT_UNKNOWN -1 56#define MESSAGE_LENGHT_UNKNOWN -1
57#define NO_MESSAGE_OR_MESSAGE_FINISHED -2 57#define NO_MESSAGE_OR_MESSAGE_FINISHED -2
@@ -107,10 +107,16 @@ struct Plugin
107 int session_count; 107 int session_count;
108 108
109 /** 109 /**
110 * encapsulation to the local wlan server prog 110 * encapsulation of data from the local wlan helper program
111 */ 111 */
112 112
113 struct GNUNET_SERVER_MessageStreamTokenizer * consoltoken; 113 struct GNUNET_SERVER_MessageStreamTokenizer * suid_tokenizer;
114
115 /**
116 * encapsulation of packets received
117 */
118
119 struct GNUNET_SERVER_MessageStreamTokenizer * data_tokenizer;
114 120
115 /** 121 /**
116 * stdout pipe handle for the gnunet-wlan-helper process 122 * stdout pipe handle for the gnunet-wlan-helper process
@@ -1978,6 +1984,7 @@ check_rec_finished_msg(struct Plugin* plugin,
1978 aktnum = 0; 1984 aktnum = 0;
1979 while (rec_queue != NULL) 1985 while (rec_queue != NULL)
1980 { 1986 {
1987 //TODO SAVE SOME COPY OPS AND CHECK CRC WITHOUT COPY
1981 memcpy(msg + aktnum, rec_queue->msg, rec_queue->size); 1988 memcpy(msg + aktnum, rec_queue->msg, rec_queue->size);
1982 aktnum += rec_queue->size; 1989 aktnum += rec_queue->size;
1983 rec_queue = rec_queue->next; 1990 rec_queue = rec_queue->next;
@@ -1993,6 +2000,38 @@ check_rec_finished_msg(struct Plugin* plugin,
1993} 2000}
1994 2001
1995static void 2002static void
2003process_data(void *cls, void *client,
2004 const struct GNUNET_MessageHeader *hdr){
2005
2006 GNUNET_assert(client != NULL);
2007 GNUNET_assert(cls != NULL);
2008 struct Session * session = (struct Session * )client;
2009 struct Plugin * plugin = (struct Plugin * ) cls;
2010
2011 struct GNUNET_TRANSPORT_ATS_Information distance[2];
2012 distance[0].type = htonl(GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
2013 distance[0].value = htonl(1);
2014 distance[1].type = htonl(GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
2015 distance[1].value = htonl(0);
2016
2017#if DEBUG_wlan
2018 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2019 "Calling plugin->env->receive for session %p; %s\n", session,
2020 wlan_plugin_address_to_string(NULL, session->addr, 6));
2021#endif
2022
2023 plugin->env->receive(plugin->env->cls, &(session->target), hdr,
2024 (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2,
2025 session, session->addr, sizeof(session->addr));
2026}
2027
2028/**
2029 * handels the data after all fragments are put together
2030 * @param plugin
2031 * @param session_light
2032 * @param hdr pointer to the data
2033 */
2034static void
1996wlan_data_massage_handler(struct Plugin * plugin, 2035wlan_data_massage_handler(struct Plugin * plugin,
1997 struct Session_light * session_light, 2036 struct Session_light * session_light,
1998 const struct GNUNET_MessageHeader * hdr) 2037 const struct GNUNET_MessageHeader * hdr)
@@ -2084,20 +2123,12 @@ wlan_data_massage_handler(struct Plugin * plugin,
2084 } 2123 }
2085 2124
2086 //"receive" the message 2125 //"receive" the message
2087 struct GNUNET_TRANSPORT_ATS_Information distance[2];
2088 distance[0].type = htonl(GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
2089 distance[0].value = htonl(1);
2090 distance[1].type = htonl(GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
2091 distance[1].value = htonl(0);
2092 2126
2093#if DEBUG_wlan 2127
2094 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2128 GNUNET_SERVER_mst_receive(plugin->data_tokenizer, session, (const char *) temp_hdr,
2095 "Calling plugin->env->receive for session %p; %s\n", session, 2129 ntohs(hdr->size) - sizeof(struct WlanHeader), GNUNET_YES, GNUNET_NO);
2096 wlan_plugin_address_to_string(NULL, session->addr, 6)); 2130
2097#endif 2131
2098 plugin->env->receive(plugin->env->cls, &(session->target), temp_hdr,
2099 (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2,
2100 session, session->addr, sizeof(session->addr));
2101 return; 2132 return;
2102 } 2133 }
2103 else 2134 else
@@ -2260,7 +2291,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light,
2260 else 2291 else
2261 { 2292 {
2262 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 2293 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
2263 "WLAN client not in session list and it is a fragment message\n"); 2294 "WLAN client not in session list\n");
2264 wlan_data_massage_handler(plugin, session_light, 2295 wlan_data_massage_handler(plugin, session_light,
2265 (struct GNUNET_MessageHeader *) tempmsg); 2296 (struct GNUNET_MessageHeader *) tempmsg);
2266 session = session_light->session; 2297 session = session_light->session;
@@ -2549,7 +2580,7 @@ wlan_plugin_helper_read(void *cls,
2549#endif 2580#endif
2550 return; 2581 return;
2551 } 2582 }
2552 GNUNET_SERVER_mst_receive(plugin->consoltoken, NULL, mybuf, bytes, GNUNET_NO, 2583 GNUNET_SERVER_mst_receive(plugin->suid_tokenizer, NULL, mybuf, bytes, GNUNET_NO,
2553 GNUNET_NO); 2584 GNUNET_NO);
2554 2585
2555 GNUNET_assert(plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK); 2586 GNUNET_assert(plugin->server_read_task == GNUNET_SCHEDULER_NO_TASK);
@@ -2642,8 +2673,12 @@ libgnunet_plugin_transport_wlan_done(void *cls)
2642 2673
2643 GNUNET_assert(cls !=NULL); 2674 GNUNET_assert(cls !=NULL);
2644 2675
2645 if (plugin->consoltoken != NULL) 2676 if (plugin->suid_tokenizer != NULL)
2646 GNUNET_SERVER_mst_destroy(plugin->consoltoken); 2677 GNUNET_SERVER_mst_destroy(plugin->suid_tokenizer);
2678
2679 if (plugin->data_tokenizer != NULL)
2680 GNUNET_SERVER_mst_destroy(plugin->data_tokenizer);
2681
2647 2682
2648 GNUNET_free_non_null(plugin->interface); 2683 GNUNET_free_non_null(plugin->interface);
2649 GNUNET_free (plugin); 2684 GNUNET_free (plugin);
@@ -2696,7 +2731,9 @@ libgnunet_plugin_transport_wlan_init(void *cls)
2696 } 2731 }
2697 2732
2698 wlan_transport_start_wlan_helper(plugin, testmode); 2733 wlan_transport_start_wlan_helper(plugin, testmode);
2699 plugin->consoltoken = GNUNET_SERVER_mst_create(&wlan_process_helper, plugin); 2734 plugin->suid_tokenizer = GNUNET_SERVER_mst_create(&wlan_process_helper, plugin);
2735
2736 plugin->data_tokenizer = GNUNET_SERVER_mst_create(&process_data, plugin);
2700 2737
2701 //plugin->sessions = GNUNET_malloc (sizeof (struct Sessionqueue)); 2738 //plugin->sessions = GNUNET_malloc (sizeof (struct Sessionqueue));
2702 //plugin->pending_Sessions = GNUNET_malloc (sizeof (struct Sessionqueue)); 2739 //plugin->pending_Sessions = GNUNET_malloc (sizeof (struct Sessionqueue));