aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-25 10:30:55 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-25 10:30:55 +0000
commit30af794cbf2a4153a7c27a82666836952eb59123 (patch)
tree94b1a6e70fe4d08a8ddbc45f58ac77f498673cc2 /src/transport
parent1a617e053559c470faedffc2055ad49e958f5e16 (diff)
downloadgnunet-30af794cbf2a4153a7c27a82666836952eb59123.tar.gz
gnunet-30af794cbf2a4153a7c27a82666836952eb59123.zip
-some more wlan code cleanup
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_wlan.c59
1 files changed, 10 insertions, 49 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index db2272ca2..f2b38b0e8 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -38,8 +38,6 @@
38#include "gnunet_crypto_lib.h" 38#include "gnunet_crypto_lib.h"
39#include "gnunet_fragmentation_lib.h" 39#include "gnunet_fragmentation_lib.h"
40#include "gnunet_constants.h" 40#include "gnunet_constants.h"
41//#include "wlan/ieee80211.h"
42//#include <netinet/ip.h>
43 41
44#include <string.h> 42#include <string.h>
45 43
@@ -482,7 +480,6 @@ struct AckSendQueue
482/** 480/**
483 * Session infos gathered from a messages 481 * Session infos gathered from a messages
484 */ 482 */
485
486struct Session_light 483struct Session_light
487{ 484{
488 /** 485 /**
@@ -647,14 +644,12 @@ struct MacEndpoint
647/** 644/**
648 * Struct for Messages in the fragment queue 645 * Struct for Messages in the fragment queue
649 */ 646 */
650
651struct FragmentMessage 647struct FragmentMessage
652{ 648{
653 649
654 /** 650 /**
655 * Session this message belongs to 651 * Session this message belongs to
656 */ 652 */
657
658 struct Session *session; 653 struct Session *session;
659 654
660 /** 655 /**
@@ -704,9 +699,11 @@ struct FragmentMessage
704 699
705static void 700static void
706do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 701do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
702
707static void 703static void
708free_session (struct Plugin *plugin, struct Sessionqueue *queue, 704free_session (struct Plugin *plugin, struct Sessionqueue *queue,
709 int do_free_macendpoint); 705 int do_free_macendpoint);
706
710static struct MacEndpoint * 707static struct MacEndpoint *
711create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr); 708create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr);
712 709
@@ -899,7 +896,6 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
899 * @param peer peer identity to use for this session 896 * @param peer peer identity to use for this session
900 * @return returns the session 897 * @return returns the session
901 */ 898 */
902
903static struct Session * 899static struct Session *
904create_session (struct Plugin *plugin, struct MacEndpoint *endpoint, 900create_session (struct Plugin *plugin, struct MacEndpoint *endpoint,
905 const struct GNUNET_PeerIdentity *peer) 901 const struct GNUNET_PeerIdentity *peer)
@@ -1025,7 +1021,6 @@ delay_fragment_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1025 * Function to calculate the time of the next periodic "hello-beacon" 1021 * Function to calculate the time of the next periodic "hello-beacon"
1026 * @param plugin pointer to the plugin struct 1022 * @param plugin pointer to the plugin struct
1027 */ 1023 */
1028
1029static void 1024static void
1030set_next_beacon_time (struct Plugin *const plugin) 1025set_next_beacon_time (struct Plugin *const plugin)
1031{ 1026{
@@ -1062,7 +1057,6 @@ set_next_beacon_time (struct Plugin *const plugin)
1062 * Function to set the timer for the next timeout of the fragment queue 1057 * Function to set the timer for the next timeout of the fragment queue
1063 * @param plugin the handle to the plugin struct 1058 * @param plugin the handle to the plugin struct
1064 */ 1059 */
1065
1066static void 1060static void
1067set_next_send (struct Plugin *const plugin) 1061set_next_send (struct Plugin *const plugin)
1068{ 1062{
@@ -1359,45 +1353,13 @@ getWlanHeader (struct ieee80211_frame *Header,
1359 return GNUNET_YES; 1353 return GNUNET_YES;
1360} 1354}
1361 1355
1362/**
1363 * 32bit CRC
1364 *
1365 * @param msgbuf pointer tor the data
1366 * @param msgbuf_size size of the data
1367 *
1368 * @return 32bit crc value
1369 */
1370
1371uint32_t
1372getcrc32 (const char *msgbuf, size_t msgbuf_size)
1373{
1374
1375 return GNUNET_CRYPTO_crc32_n (msgbuf, msgbuf_size);;
1376}
1377
1378/**
1379 * 16bit CRC
1380 *
1381 * @param msgbuf pointer tor the data
1382 * @param msgbuf_size size of the data
1383 *
1384 * @return 16bit crc value
1385 */
1386
1387uint16_t
1388getcrc16 (const char *msgbuf, size_t msgbuf_size)
1389{
1390 //TODO calc some crc
1391 return 0;
1392}
1393 1356
1394/** 1357/**
1395 * function to add a fragment of a message to send 1358 * function to add a fragment of a message to send
1396 * @param cls FragmentMessage this message belongs to 1359 * @param cls FragmentMessage this message belongs to
1397 * @param hdr pointer to the start of the message 1360 * @param hdr pointer to the start of the message
1398 */ 1361 */
1399 1362static void
1400void
1401add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr) 1363add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr)
1402{ 1364{
1403 1365
@@ -1900,7 +1862,6 @@ send_hello_beacon (struct Plugin *plugin)
1900 * @param hdr pointer to the hdr where the ack is stored 1862 * @param hdr pointer to the hdr where the ack is stored
1901 * 1863 *
1902 */ 1864 */
1903
1904static void 1865static void
1905add_ack_for_send (void *cls, uint32_t msg_id, 1866add_ack_for_send (void *cls, uint32_t msg_id,
1906 const struct GNUNET_MessageHeader *hdr) 1867 const struct GNUNET_MessageHeader *hdr)
@@ -2344,10 +2305,8 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
2344 wlanheader->crc = 0; 2305 wlanheader->crc = 0;
2345 memcpy (&wlanheader[1], msgbuf, msgbuf_size); 2306 memcpy (&wlanheader[1], msgbuf, msgbuf_size);
2346 wlanheader->crc = 2307 wlanheader->crc =
2347 htonl (getcrc32 2308 htonl (GNUNET_CRYPTO_crc32_n
2348 ((char *) wlanheader, msgbuf_size + sizeof (struct WlanHeader))); 2309 ((char *) wlanheader, msgbuf_size + sizeof (struct WlanHeader)));
2349 //GNUNET_log_from(GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, "Wlan message Header crc: %u, %u\n",getcrc32((char*) wlanheader, msgbuf_size + sizeof(struct WlanHeader)), wlanheader->crc);
2350 //hexdump(newmsg->msg, msgbuf_size + sizeof(struct WlanHeader));
2351 2310
2352 newmsg->transmit_cont = cont; 2311 newmsg->transmit_cont = cont;
2353 newmsg->transmit_cont_cls = cont_cls; 2312 newmsg->transmit_cont_cls = cont_cls;
@@ -2642,13 +2601,13 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2642 temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1]; 2601 temp_hdr = (const struct GNUNET_MessageHeader *) &wlanheader[1];
2643 crc = ntohl (wlanheader->crc); 2602 crc = ntohl (wlanheader->crc);
2644 wlanheader->crc = 0; 2603 wlanheader->crc = 0;
2645 if (getcrc32 ((char *) wlanheader, ntohs (wlanheader->header.size)) != crc) 2604 if (GNUNET_CRYPTO_crc32_n ((char *) wlanheader, ntohs (wlanheader->header.size)) != crc)
2646 { 2605 {
2647 //wrong crc, dispose message 2606 //wrong crc, dispose message
2648 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME, 2607 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, PLUGIN_LOG_NAME,
2649 "Wlan message header crc was wrong: %u != %u\n", 2608 "Wlan message header crc was wrong: %u != %u\n",
2650 getcrc32 ((char *) wlanheader, 2609 GNUNET_CRYPTO_crc32_n ((char *) wlanheader,
2651 ntohs (wlanheader->header.size)), crc); 2610 ntohs (wlanheader->header.size)), crc);
2652 hexdump ((void *) hdr, ntohs (hdr->size)); 2611 hexdump ((void *) hdr, ntohs (hdr->size));
2653 return; 2612 return;
2654 } 2613 }
@@ -2980,12 +2939,13 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2980 2939
2981} 2940}
2982 2941
2942#if DEBUG_wlan
2983/** 2943/**
2984 * Function to print mac addresses nice * 2944 * Function to print mac addresses nice *
2985 * @param pointer to 6 byte with the mac address 2945 * @param pointer to 6 byte with the mac address
2986 * @return pointer to the chars which hold the print out 2946 * @return pointer to the chars which hold the print out
2987 */ 2947 */
2988const char * 2948static const char *
2989macprinter (const u_int8_t * mac) 2949macprinter (const u_int8_t * mac)
2990{ 2950{
2991 static char macstr[20]; 2951 static char macstr[20];
@@ -2994,6 +2954,7 @@ macprinter (const u_int8_t * mac)
2994 mac[2], mac[3], mac[4], mac[5]); 2954 mac[2], mac[3], mac[4], mac[5]);
2995 return macstr; 2955 return macstr;
2996} 2956}
2957#endif
2997 2958
2998/** 2959/**
2999 * Function for the scheduler if a mac endpoint times out 2960 * Function for the scheduler if a mac endpoint times out