aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-01-31 13:46:10 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-01-31 13:46:10 +0000
commita2ce5881437a0a9e0c4bb58c939c5e7819ef4009 (patch)
treeedd24a74a7e199060556710d46f9b4a53a788586 /src/transport/plugin_transport_wlan.c
parentc8b9d46688bca0d65c5319041228e95de7a19dab (diff)
downloadgnunet-a2ce5881437a0a9e0c4bb58c939c5e7819ef4009.tar.gz
gnunet-a2ce5881437a0a9e0c4bb58c939c5e7819ef4009.zip
session based sending for wlan
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c87
1 files changed, 81 insertions, 6 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index cf971ca80..7bc345027 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -2205,9 +2205,25 @@ static struct Session *
2205wlan_plugin_get_session (void *cls, 2205wlan_plugin_get_session (void *cls,
2206 const struct GNUNET_HELLO_Address *address) 2206 const struct GNUNET_HELLO_Address *address)
2207{ 2207{
2208 struct Plugin *plugin = cls;
2208 struct Session * s = NULL; 2209 struct Session * s = NULL;
2209 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "To be implemented\n"); 2210
2210 GNUNET_break (0); 2211 GNUNET_assert (plugin != NULL);
2212 GNUNET_assert (address != NULL);
2213
2214 if (GNUNET_OK == wlan_plugin_address_suggested (plugin,
2215 address->address,
2216 address->address_length))
2217 {
2218 s = get_session (plugin, address->address, &address->peer);
2219 }
2220 else
2221 {
2222 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
2223 _("Wlan Address len %d is wrong\n"), address->address_length);
2224 return s;
2225 }
2226
2211 return s; 2227 return s;
2212} 2228}
2213 2229
@@ -2246,10 +2262,69 @@ wlan_plugin_send (void *cls,
2246 struct GNUNET_TIME_Relative to, 2262 struct GNUNET_TIME_Relative to,
2247 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) 2263 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
2248{ 2264{
2249 ssize_t sent = -1; 2265 struct Plugin *plugin = cls;
2250 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "To be implemented\n"); 2266 struct PendingMessage *newmsg;
2251 GNUNET_break (0); 2267 struct WlanHeader *wlanheader;
2252 return sent; 2268
2269 GNUNET_assert (plugin != NULL);
2270 GNUNET_assert (session != NULL);
2271 GNUNET_assert (msgbuf_size > 0);
2272
2273 //queue message:
2274
2275 //queue message in session
2276 //test if there is no other message in the "queue"
2277 //FIXME: to many send requests
2278 if (session->pending_message_head != NULL)
2279 {
2280 newmsg = session->pending_message_head;
2281 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2282 "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",
2283 GNUNET_TIME_absolute_get_remaining (newmsg->
2284 timeout).rel_value,
2285 session->mac->fragment_messages_out_count);
2286 }
2287
2288 newmsg = GNUNET_malloc (sizeof (struct PendingMessage));
2289 newmsg->msg = GNUNET_malloc (msgbuf_size + sizeof (struct WlanHeader));
2290 wlanheader = newmsg->msg;
2291 //copy msg to buffer, not fragmented / segmented yet, but with message header
2292 wlanheader->header.size = htons (msgbuf_size + sizeof (struct WlanHeader));
2293 wlanheader->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA);
2294 memcpy (&(wlanheader->target), &session->target, sizeof (struct GNUNET_PeerIdentity));
2295 memcpy (&(wlanheader->source), plugin->env->my_identity,
2296 sizeof (struct GNUNET_PeerIdentity));
2297 wlanheader->crc = 0;
2298 memcpy (&wlanheader[1], msgbuf, msgbuf_size);
2299 wlanheader->crc =
2300 htonl (GNUNET_CRYPTO_crc32_n
2301 ((char *) wlanheader, msgbuf_size + sizeof (struct WlanHeader)));
2302
2303 newmsg->transmit_cont = cont;
2304 newmsg->transmit_cont_cls = cont_cls;
2305 newmsg->timeout = GNUNET_TIME_relative_to_absolute (to);
2306
2307 newmsg->timeout.abs_value = newmsg->timeout.abs_value - 500;
2308
2309 newmsg->message_size = msgbuf_size + sizeof (struct WlanHeader);
2310
2311 GNUNET_CONTAINER_DLL_insert_tail (session->pending_message_head,
2312 session->pending_message_tail, newmsg);
2313
2314#if DEBUG_wlan
2315 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2316 "New message for %p with size (incl wlan header) %u added\n",
2317 session, newmsg->message_size);
2318#endif
2319#if DEBUG_wlan_msg_dump > 1
2320 hexdump (msgbuf, GNUNET_MIN (msgbuf_size, 256));
2321#endif
2322 //queue session
2323 queue_session (plugin, session);
2324
2325 check_fragment_queue (plugin);
2326 //FIXME not the correct size
2327 return msgbuf_size;
2253} 2328}
2254 2329
2255 2330