aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-04-06 08:51:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-04-06 08:51:35 +0000
commit64e50b6dfbf852eb19d1b5d55ca8709422199a44 (patch)
treef458e87372a02d98c81ef6e57ee516495252d397 /src
parentb6d387d71221528ec703a375548eb375b8389f01 (diff)
downloadgnunet-64e50b6dfbf852eb19d1b5d55ca8709422199a44.tar.gz
gnunet-64e50b6dfbf852eb19d1b5d55ca8709422199a44.zip
nicer
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-transport-wlan-helper.c8
-rw-r--r--src/transport/plugin_transport_wlan.c790
-rw-r--r--src/transport/plugin_transport_wlan.h8
3 files changed, 352 insertions, 454 deletions
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c
index 0c48b765e..e18a6e7c8 100644
--- a/src/transport/gnunet-transport-wlan-helper.c
+++ b/src/transport/gnunet-transport-wlan-helper.c
@@ -251,7 +251,7 @@ Dump(u8 * pu8, int nLength)
251void 251void
252usage() 252usage()
253{ 253{
254 printf("Usage: interface-name optins\n" 254 printf("Usage: interface-name options\n"
255 "options: 0 = with hardware\n" 255 "options: 0 = with hardware\n"
256 "1 = first loopback file\n" 256 "1 = first loopback file\n"
257 "2 = second loopback file\n" 257 "2 = second loopback file\n"
@@ -871,14 +871,14 @@ mac_test(unsigned char * buf, struct Hardware_Infos * dev)
871{ 871{
872 struct ieee80211_frame * u8aIeeeHeader; 872 struct ieee80211_frame * u8aIeeeHeader;
873 u8aIeeeHeader = (struct ieee80211_frame *) buf; 873 u8aIeeeHeader = (struct ieee80211_frame *) buf;
874 if (0 == memcmp(u8aIeeeHeader->i_addr3, mac_bssid, 6)) 874 if (0 == memcmp(u8aIeeeHeader->i_addr3, &mac_bssid, 6))
875 { 875 {
876 if (0 == memcmp(u8aIeeeHeader->i_addr2, dev->pl_mac, 6)) 876 if (0 == memcmp(u8aIeeeHeader->i_addr2, dev->pl_mac, 6))
877 { 877 {
878 return 0; 878 return 0;
879 } 879 }
880 880
881 if (0 == memcmp(u8aIeeeHeader->i_addr2, bc_all_mac, 6)) 881 if (0 == memcmp(u8aIeeeHeader->i_addr2, &bc_all_mac, 6))
882 { 882 {
883 return 0; 883 return 0;
884 } 884 }
@@ -903,7 +903,7 @@ mac_set(unsigned char * buf, struct Hardware_Infos * dev)
903 u8aIeeeHeader->i_fc[1] = 0x00; 903 u8aIeeeHeader->i_fc[1] = 0x00;
904 904
905 memcpy(u8aIeeeHeader->i_addr2, dev->pl_mac, 6); 905 memcpy(u8aIeeeHeader->i_addr2, dev->pl_mac, 6);
906 memcpy(u8aIeeeHeader->i_addr3, mac_bssid, 6); 906 memcpy(u8aIeeeHeader->i_addr3, &mac_bssid, 6);
907 907
908} 908}
909 909
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 9d79e2d01..7325a5b52 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -411,7 +411,7 @@ struct Session_light
411 /** 411 /**
412 * peer mac address 412 * peer mac address
413 */ 413 */
414 uint8_t addr[6]; 414 struct MacAddress addr;
415}; 415};
416 416
417/** 417/**
@@ -451,7 +451,7 @@ struct Session
451 /** 451 /**
452 * peer mac address 452 * peer mac address
453 */ 453 */
454 char addr[6]; 454 struct MacAddress addr;
455 455
456 /** 456 /**
457 * Address of the other peer (either based on our 'connect' 457 * Address of the other peer (either based on our 'connect'
@@ -564,71 +564,11 @@ struct FragmentationAckHeader
564 564
565}; 565};
566 566
567int
568getRadiotapHeader(struct Plugin * plugin, struct Session * session,
569 struct Radiotap_Send * Header);
570
571int
572getWlanHeader(struct ieee80211_frame * Header, const char * to_mac_addr,
573 struct Plugin * plugin);
574
575static int
576wlan_plugin_address_suggested(void *cls, const void *addr, size_t addrlen);
577
578uint16_t
579getcrc16(const char *msgbuf, size_t msgbuf_size);
580
581static void
582do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
583
584static void
585check_fragment_queue(struct Plugin * plugin);
586
587uint32_t
588getcrc32(const char *msgbuf, size_t msgbuf_size);
589
590static void
591free_receive_message(struct Plugin* plugin,
592 struct Receive_Message_Queue * rx_message);
593
594struct Receive_Message_Queue *
595get_receive_message_from_session(struct Plugin * plugin,
596 struct Session * session);
597
598static void 567static void
599wlan_data_helper(void *cls, struct Session_light * session_light, 568do_transmit(void *cls,
600 const struct GNUNET_MessageHeader * hdr, const struct Radiotap_rx * rxinfo); 569 const struct GNUNET_SCHEDULER_TaskContext *tc);
601 570
602static void
603wlan_process_helper(void *cls, void *client,
604 const struct GNUNET_MessageHeader *hdr);
605 571
606static void
607finish_sending(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
608
609static void
610wlan_data_massage_handler(struct Plugin * plugin,
611 struct Session_light * session_light,
612 const struct GNUNET_MessageHeader * hdr);
613
614static const char *
615wlan_plugin_address_to_string(void *cls, const void *addr, size_t addrlen);
616
617struct Receive_Message_Queue *
618get_receive_message(struct Plugin * plugin, struct Session * session,
619 uint32_t message_id);
620
621static uint64_t
622htonll(uint64_t input)
623{
624 return input;
625}
626
627static uint64_t
628ntohll(uint64_t input)
629{
630 return input;
631}
632 572
633/** 573/**
634 * Sets a bit active in the bitArray. Increment bit-specific 574 * Sets a bit active in the bitArray. Increment bit-specific
@@ -648,23 +588,6 @@ setBit(char *bitArray, unsigned int bitIdx)
648 bitArray[arraySlot] |= targetBit; 588 bitArray[arraySlot] |= targetBit;
649} 589}
650 590
651/**
652 * Clears a bit from bitArray. Bit is cleared from the array
653 * only if the respective usage counter on the disk hits/is zero.
654 *
655 * @param bitArray memory area to set the bit in
656 * @param bitIdx which bit to unset
657 */
658/*static void
659 clearBit(char *bitArray, unsigned int bitIdx)
660 {
661 size_t slot;
662 unsigned int targetBit;
663
664 slot = bitIdx / 8;
665 targetBit = (1L << (bitIdx % 8));
666 bitArray[slot] = bitArray[slot] & (~targetBit);
667 }*/
668 591
669/** 592/**
670 * Checks if a bit is active in the bitArray 593 * Checks if a bit is active in the bitArray
@@ -683,29 +606,19 @@ testBit(char *bitArray, unsigned int bitIdx)
683 targetBit = (1L << (bitIdx % 8)); 606 targetBit = (1L << (bitIdx % 8));
684 if (bitArray[slot] & targetBit) 607 if (bitArray[slot] & targetBit)
685 return GNUNET_YES; 608 return GNUNET_YES;
686 else 609 return GNUNET_NO;
687 return GNUNET_NO;
688} 610}
689 611
690/** 612/**
691 * get the next message number, at the moment just a random one 613 * get the next message number, at the moment just a random one
692 * @return returns the next valid message-number for sending packets 614 * @return returns the next valid message-number for sending packets
693 */ 615 */
694uint32_t 616static uint32_t
695get_next_message_id() 617get_next_message_id()
696{ 618{
697 return GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX); 619 return GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
698} 620}
699 621
700/**
701 * start next message number generator
702 * (not necessary at the moment)
703 */
704void
705start_next_message_id()
706{
707 //GNUNET_CRYPTO_random_init;
708}
709 622
710/** 623/**
711 * search for a session with the addr 624 * search for a session with the addr
@@ -714,26 +627,17 @@ start_next_message_id()
714 * @param addr pointer to the mac address of the peer 627 * @param addr pointer to the mac address of the peer
715 * @return returns the session 628 * @return returns the session
716 */ 629 */
717
718static struct Session * 630static struct Session *
719search_session(struct Plugin *plugin, const uint8_t * addr) 631search_session(struct Plugin *plugin,
632 const struct MacAddress *addr)
720{ 633{
721 struct Sessionqueue * queue = plugin->sessions; 634 struct Sessionqueue * queue = plugin->sessions;
722 struct Sessionqueue * lastitem = NULL;
723 635
724 //just look at all the session for the needed one
725 while (queue != NULL) 636 while (queue != NULL)
726 { 637 {
727 // content is never NULL
728 GNUNET_assert (queue->content != NULL); 638 GNUNET_assert (queue->content != NULL);
729 char * addr2 = queue->content->addr; 639 if (memcmp(addr, &queue->content->addr, sizeof (struct MacAddress)) == 0)
730 if (memcmp(addr, addr2, 6) == 0) 640 return queue->content; /* session found */
731 {
732 //sesion found
733 return queue->content;
734 }
735 // try next
736 lastitem = queue;
737 queue = queue->next; 641 queue = queue->next;
738 } 642 }
739 return NULL; 643 return NULL;
@@ -748,7 +652,8 @@ search_session(struct Plugin *plugin, const uint8_t * addr)
748 */ 652 */
749 653
750static struct Session * 654static struct Session *
751create_session(struct Plugin *plugin, const uint8_t * addr) 655create_session(struct Plugin *plugin,
656 const struct MacAddress * addr)
752{ 657{
753 struct Sessionqueue * queue = GNUNET_malloc (sizeof (struct Sessionqueue)); 658 struct Sessionqueue * queue = GNUNET_malloc (sizeof (struct Sessionqueue));
754 659
@@ -756,7 +661,7 @@ create_session(struct Plugin *plugin, const uint8_t * addr)
756 661
757 queue->content = GNUNET_malloc (sizeof (struct Session)); 662 queue->content = GNUNET_malloc (sizeof (struct Session));
758 queue->content->plugin = plugin; 663 queue->content->plugin = plugin;
759 memcpy(queue->content->addr, addr, 6); 664 queue->content->addr = *addr;
760 queue->content->fragment_messages_out_count = 0; 665 queue->content->fragment_messages_out_count = 0;
761 queue->content->fragment_messages_in_count = 0; 666 queue->content->fragment_messages_in_count = 0;
762 667
@@ -770,45 +675,25 @@ create_session(struct Plugin *plugin, const uint8_t * addr)
770 return queue->content; 675 return queue->content;
771} 676}
772 677
678
773/** 679/**
774 * get Session from address, create if no session exists 680 * Get session from address, create if no session exists
775 * 681 *
776 * @param plugin pointer to the plugin struct 682 * @param plugin pointer to the plugin struct
777 * @param addr pointer to the mac address of the peer 683 * @param addr pointer to the mac address of the peer
778 * @return returns the session 684 * @return returns the session
779 */ 685 */
780//TODO add other possibilities to find the right session (are there other?)
781static struct Session * 686static struct Session *
782get_Session(struct Plugin *plugin, const uint8_t * addr) 687get_Session (struct Plugin *plugin,
688 const struct MacAddress *addr)
783{ 689{
784 struct Session * session = search_session(plugin, addr); 690 struct Session * session = search_session(plugin, addr);
785 if (session != NULL) 691 if (session != NULL)
786 { 692 return session;
787 return session;
788 }
789 // new session
790 return create_session(plugin, addr); 693 return create_session(plugin, addr);
791
792 /* -- not needed, layer above already has it--
793 //queue welcome message for new sessions, not realy needed
794 //struct WelcomeMessage welcome;
795 struct PendingMessage *pm;
796 pm = GNUNET_malloc (sizeof (struct PendingMessage));
797 pm->msg = GNUNET_malloc(GNUNET_HELLO_size(* (plugin->env->our_hello)));
798 pm->message_size = GNUNET_HELLO_size(* (plugin->env->our_hello));
799 //welcome.header.size = htons (GNUNET_HELLO_size(* (plugin->env->our_hello)));
800 //welcome.header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT);
801 //welcome.clientIdentity = *plugin->env->my_identity;
802 memcpy ( (pm->msg), * plugin->env->our_hello, GNUNET_HELLO_size(* (plugin->env->our_hello)));
803 pm->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
804 queue->content->pending_message = pm;
805 plugin->pendingsessions ++;
806 GNUNET_CONTAINER_DLL_insert_tail(plugin->pending_Sessions, plugin->pending_Sessions_tail, queue);
807
808 check_fragment_queue(plugin);
809 */
810} 694}
811 695
696
812/** 697/**
813 * Queue the session to send data 698 * Queue the session to send data
814 */ 699 */
@@ -1203,7 +1088,7 @@ check_finished_fragment(struct Plugin * plugin, struct FragmentMessage * fm)
1203 * @param fm use this FragmentMessage 1088 * @param fm use this FragmentMessage
1204 */ 1089 */
1205 1090
1206void 1091static void
1207set_next_message_fragment_pos(struct FragmentMessage * fm) 1092set_next_message_fragment_pos(struct FragmentMessage * fm)
1208{ 1093{
1209 1094
@@ -1226,7 +1111,82 @@ set_next_message_fragment_pos(struct FragmentMessage * fm)
1226 1111
1227} 1112}
1228 1113
1229void 1114int
1115getRadiotapHeader(struct Plugin * plugin, struct Session * session,
1116 struct Radiotap_Send * header)
1117{
1118
1119 if (session != NULL)
1120 {
1121 header->rate = session->rate;
1122 header->tx_power = session->tx_power;
1123 header->antenna = session->antenna;
1124 }
1125 else
1126 {
1127 header->rate = 255;
1128 header->tx_power = 0;
1129 header->antenna = 0;
1130 }
1131
1132 return GNUNET_YES;
1133}
1134
1135
1136/**
1137 * function to generate the wlan hardware header for one packet
1138 * @param Header address to write the header to
1139 * @param to_mac_addr address of the recipient
1140 * @param plugin pointer to the plugin struct
1141 * @return GNUNET_YES if there was no error
1142 */
1143int
1144getWlanHeader(struct ieee80211_frame * Header,
1145 const struct MacAddress * to_mac_addr,
1146 struct Plugin * plugin)
1147{
1148 Header->i_fc[0] = 0x80;
1149 Header->i_fc[1] = 0x00;
1150 memcpy(&Header->i_addr3, &mac_bssid, sizeof(mac_bssid));
1151 memcpy(&Header->i_addr2, plugin->mac_address.mac, sizeof(plugin->mac_address));
1152 memcpy(&Header->i_addr1, to_mac_addr, sizeof(plugin->mac_address));
1153 return GNUNET_YES;
1154}
1155
1156/**
1157 * 32bit CRC
1158 *
1159 * @param msgbuf pointer tor the data
1160 * @param msgbuf_size size of the data
1161 *
1162 * @return 32bit crc value
1163 */
1164
1165uint32_t
1166getcrc32(const char *msgbuf, size_t msgbuf_size)
1167{
1168 //TODO calc some crc
1169 return 0;
1170}
1171
1172/**
1173 * 16bit CRC
1174 *
1175 * @param msgbuf pointer tor the data
1176 * @param msgbuf_size size of the data
1177 *
1178 * @return 16bit crc value
1179 */
1180
1181uint16_t
1182getcrc16(const char *msgbuf, size_t msgbuf_size)
1183{
1184 //TODO calc some crc
1185 return 0;
1186}
1187
1188
1189static void
1230send_hello_beacon(struct Plugin * plugin) 1190send_hello_beacon(struct Plugin * plugin)
1231{ 1191{
1232 1192
@@ -1254,7 +1214,7 @@ send_hello_beacon(struct Plugin * plugin)
1254 radioHeader = (struct Radiotap_Send*) &msgheader[1]; 1214 radioHeader = (struct Radiotap_Send*) &msgheader[1];
1255 getRadiotapHeader(plugin, NULL, radioHeader); 1215 getRadiotapHeader(plugin, NULL, radioHeader);
1256 ieeewlanheader = (struct ieee80211_frame*) &radioHeader[1]; 1216 ieeewlanheader = (struct ieee80211_frame*) &radioHeader[1];
1257 getWlanHeader(ieeewlanheader, bc_all_mac, plugin); 1217 getWlanHeader(ieeewlanheader, &bc_all_mac, plugin);
1258 1218
1259 msgheader2 = (struct GNUNET_MessageHeader*) &ieeewlanheader[1]; 1219 msgheader2 = (struct GNUNET_MessageHeader*) &ieeewlanheader[1];
1260 msgheader2->size = htons(GNUNET_HELLO_size(*(plugin->env->our_hello)) 1220 msgheader2->size = htons(GNUNET_HELLO_size(*(plugin->env->our_hello))
@@ -1311,13 +1271,13 @@ send_ack(struct Plugin * plugin, struct AckSendQueue * ack)
1311 radioHeader = (struct Radiotap_Send*) &msgheader[1]; 1271 radioHeader = (struct Radiotap_Send*) &msgheader[1];
1312 getRadiotapHeader(plugin, ack->session, radioHeader); 1272 getRadiotapHeader(plugin, ack->session, radioHeader);
1313 ieeewlanheader = (struct ieee80211_frame*) &radioHeader[1]; 1273 ieeewlanheader = (struct ieee80211_frame*) &radioHeader[1];
1314 getWlanHeader(ieeewlanheader, ack->session->addr, plugin); 1274 getWlanHeader(ieeewlanheader, &ack->session->addr, plugin);
1315 1275
1316 msgheader2 = (struct FragmentationAckHeader*) &ieeewlanheader[1]; 1276 msgheader2 = (struct FragmentationAckHeader*) &ieeewlanheader[1];
1317 msgheader2->header.size = htons(sizeof(struct FragmentationAckHeader)); 1277 msgheader2->header.size = htons(sizeof(struct FragmentationAckHeader));
1318 msgheader2->header.type = htons(GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT_ACK); 1278 msgheader2->header.type = htons(GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT_ACK);
1319 msgheader2->message_id = htonl(ack->message_id); 1279 msgheader2->message_id = htonl(ack->message_id);
1320 msgheader2->fragment_field = htonll(ack->fragments_field); 1280 msgheader2->fragment_field = GNUNET_htonll(ack->fragments_field);
1321 1281
1322 bytes = GNUNET_DISK_file_write(plugin->server_stdin_handle, msgheader, size); 1282 bytes = GNUNET_DISK_file_write(plugin->server_stdin_handle, msgheader, size);
1323 if (bytes == GNUNET_SYSERR) 1283 if (bytes == GNUNET_SYSERR)
@@ -1333,13 +1293,49 @@ send_ack(struct Plugin * plugin, struct AckSendQueue * ack)
1333 check_next_fragment_timeout(plugin); 1293 check_next_fragment_timeout(plugin);
1334} 1294}
1335 1295
1296static void
1297finish_sending(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1298{
1299 struct Finish_send * finish;
1300 struct Plugin * plugin;
1301 ssize_t bytes;
1302
1303 finish = cls;
1304 plugin = finish->plugin;
1305
1306 plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK;
1307
1308 bytes = GNUNET_DISK_file_write(plugin->server_stdin_handle,
1309 finish->msgheader, finish->size);
1310 GNUNET_assert(bytes != GNUNET_SYSERR);
1311
1312 GNUNET_assert(plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK);
1313 if (bytes != finish->size)
1314 {
1315
1316 finish->msgheader = finish->msgheader + bytes;
1317 finish->size = finish->size - bytes;
1318 plugin->server_write_task = GNUNET_SCHEDULER_add_write_file(
1319 GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdin_handle,
1320 &finish_sending, finish);
1321 }
1322 else
1323 {
1324 GNUNET_free(finish->msgstart);
1325 GNUNET_free(finish);
1326 check_next_fragment_timeout(plugin);
1327 }
1328
1329}
1330
1331
1332
1336/** 1333/**
1337 * Function called when wlan helper is ready to get some data 1334 * Function called when wlan helper is ready to get some data
1338 * 1335 *
1339 * @param cls closure 1336 * @param cls closure
1340 * @param tc GNUNET_SCHEDULER_TaskContext 1337 * @param tc GNUNET_SCHEDULER_TaskContext
1341 */ 1338 */
1342
1343static void 1339static void
1344do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1340do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1345{ 1341{
@@ -1467,7 +1463,7 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1467 getRadiotapHeader(plugin, session, radioHeader); 1463 getRadiotapHeader(plugin, session, radioHeader);
1468 1464
1469 ieeewlanheader = (struct ieee80211_frame *) &radioHeader[1]; 1465 ieeewlanheader = (struct ieee80211_frame *) &radioHeader[1];
1470 getWlanHeader(ieeewlanheader, fm->session->addr, plugin); 1466 getWlanHeader(ieeewlanheader, &fm->session->addr, plugin);
1471 1467
1472 //could be faster if content is just send and not copyed before 1468 //could be faster if content is just send and not copyed before
1473 //fragmentheader is needed 1469 //fragmentheader is needed
@@ -1541,114 +1537,40 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1541 "do_transmit did nothing, should not happen!\n"); 1537 "do_transmit did nothing, should not happen!\n");
1542} 1538}
1543 1539
1544static void
1545finish_sending(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1546{
1547 struct Finish_send * finish;
1548 struct Plugin * plugin;
1549 ssize_t bytes;
1550
1551 finish = cls;
1552 plugin = finish->plugin;
1553
1554 plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK;
1555
1556 bytes = GNUNET_DISK_file_write(plugin->server_stdin_handle,
1557 finish->msgheader, finish->size);
1558 GNUNET_assert(bytes != GNUNET_SYSERR);
1559
1560 GNUNET_assert(plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK);
1561 if (bytes != finish->size)
1562 {
1563
1564 finish->msgheader = finish->msgheader + bytes;
1565 finish->size = finish->size - bytes;
1566 plugin->server_write_task = GNUNET_SCHEDULER_add_write_file(
1567 GNUNET_TIME_UNIT_FOREVER_REL, plugin->server_stdin_handle,
1568 &finish_sending, finish);
1569 }
1570 else
1571 {
1572 GNUNET_free(finish->msgstart);
1573 GNUNET_free(finish);
1574 check_next_fragment_timeout(plugin);
1575 }
1576
1577}
1578
1579int
1580getRadiotapHeader(struct Plugin * plugin, struct Session * session,
1581 struct Radiotap_Send * header)
1582{
1583
1584 if (session != NULL)
1585 {
1586 header->rate = session->rate;
1587 header->tx_power = session->tx_power;
1588 header->antenna = session->antenna;
1589 }
1590 else
1591 {
1592 header->rate = 255;
1593 header->tx_power = 0;
1594 header->antenna = 0;
1595 }
1596
1597 return GNUNET_YES;
1598}
1599;
1600 1540
1601/** 1541/**
1602 * function to generate the wlan hardware header for one packet 1542 * Another peer has suggested an address for this
1603 * @param Header address to write the header to 1543 * peer and transport plugin. Check that this could be a valid
1604 * @param to_mac_addr address of the recipient 1544 * address. If so, consider adding it to the list
1605 * @param plugin pointer to the plugin struct 1545 * of addresses.
1606 * @return GNUNET_YES if there was no error 1546 *
1547 * @param cls closure
1548 * @param addr pointer to the address
1549 * @param addrlen length of addr
1550 * @return GNUNET_OK if this is a plausible address for this peer
1551 * and transport
1607 */ 1552 */
1608 1553static int
1609int 1554wlan_plugin_address_suggested(void *cls, const void *addr, size_t addrlen)
1610getWlanHeader(struct ieee80211_frame * Header, const char * const to_mac_addr,
1611 struct Plugin * plugin)
1612{ 1555{
1613 Header->i_fc[0] = 0x80; 1556 //struct Plugin *plugin = cls;
1614 Header->i_fc[1] = 0x00;
1615 memcpy(&Header->i_addr3, mac_bssid, sizeof(mac_bssid));
1616 memcpy(&Header->i_addr2, plugin->mac_address.mac, sizeof(plugin->mac_address));
1617 memcpy(&Header->i_addr1, to_mac_addr, sizeof(plugin->mac_address));
1618 return GNUNET_YES;
1619}
1620 1557
1621/** 1558 /* check if the address is plausible; if so,
1622 * 32bit CRC 1559 add it to our list! */
1623 *
1624 * @param msgbuf pointer tor the data
1625 * @param msgbuf_size size of the data
1626 *
1627 * @return 32bit crc value
1628 */
1629 1560
1630uint32_t 1561 GNUNET_assert(cls !=NULL);
1631getcrc32(const char *msgbuf, size_t msgbuf_size) 1562 //FIXME mitm is not checked
1632{ 1563 //Mac Address has 6 bytes
1633 //TODO calc some crc 1564 if (addrlen == 6)
1634 return 0; 1565 {
1566 /* TODO check for bad addresses like multicast, broadcast, etc */
1567 return GNUNET_OK;
1568 }
1569
1570 return GNUNET_SYSERR;
1635} 1571}
1636 1572
1637/**
1638 * 16bit CRC
1639 *
1640 * @param msgbuf pointer tor the data
1641 * @param msgbuf_size size of the data
1642 *
1643 * @return 16bit crc value
1644 */
1645 1573
1646uint16_t
1647getcrc16(const char *msgbuf, size_t msgbuf_size)
1648{
1649 //TODO calc some crc
1650 return 0;
1651}
1652 1574
1653/** 1575/**
1654 * Function that can be used by the transport service to transmit 1576 * Function that can be used by the transport service to transmit
@@ -1819,6 +1741,60 @@ get_fragment_message_from_session_and_id(struct Session * session,
1819 return NULL; 1741 return NULL;
1820} 1742}
1821 1743
1744
1745/**
1746 * function to get the receive message of a session
1747 * @param plugin pointer to the plugin struct
1748 * @param session session this fragment belongs to
1749 */
1750struct Receive_Message_Queue *
1751get_receive_message_from_session(struct Plugin * plugin,
1752 struct Session * session)
1753{
1754 struct Receive_Message_Queue * rec_message = plugin->receive_messages_head;
1755 while (rec_message != NULL)
1756 {
1757 if (rec_message->session == session)
1758 {
1759 return rec_message;
1760 }
1761 rec_message = rec_message->next;
1762 }
1763 return NULL;
1764}
1765
1766
1767/**
1768 * Function to dispose the fragments received for a message and the message
1769 * @param plugin pointer to the plugin struct
1770 * @param rec_message pointer to the struct holding the message which should be freed
1771 */
1772static void
1773free_receive_message(struct Plugin* plugin,
1774 struct Receive_Message_Queue * rx_message)
1775{
1776 GNUNET_assert(rx_message !=NULL);
1777 struct Receive_Fragment_Queue * rec_queue = rx_message->frag_head;
1778 struct Receive_Fragment_Queue * rec_queue2;
1779
1780 while (rec_queue != NULL)
1781 {
1782 rec_queue2 = rec_queue;
1783 rec_queue = rec_queue->next;
1784 GNUNET_free(rec_queue2);
1785 }
1786
1787 GNUNET_CONTAINER_DLL_remove(plugin->receive_messages_head,plugin->receive_messages_teil, rx_message);
1788
1789 GNUNET_assert(plugin->pending_receive_messages > 0);
1790 GNUNET_assert(rx_message->session->fragment_messages_in_count > 0);
1791
1792 plugin->pending_receive_messages--;
1793 rx_message->session->fragment_messages_in_count--;
1794 GNUNET_free(rx_message);
1795}
1796
1797
1822/** 1798/**
1823 * Function that can be used to force the plugin to disconnect 1799 * Function that can be used to force the plugin to disconnect
1824 * from the given peer and cancel all previous transmissions 1800 * from the given peer and cancel all previous transmissions
@@ -1937,38 +1913,7 @@ wlan_plugin_address_pretty_printer(void *cls, const char *type,
1937 asc(asc_cls, ret); 1913 asc(asc_cls, ret);
1938} 1914}
1939 1915
1940/**
1941 * Another peer has suggested an address for this
1942 * peer and transport plugin. Check that this could be a valid
1943 * address. If so, consider adding it to the list
1944 * of addresses.
1945 *
1946 * @param cls closure
1947 * @param addr pointer to the address
1948 * @param addrlen length of addr
1949 * @return GNUNET_OK if this is a plausible address for this peer
1950 * and transport
1951 */
1952
1953static int
1954wlan_plugin_address_suggested(void *cls, const void *addr, size_t addrlen)
1955{
1956 //struct Plugin *plugin = cls;
1957 1916
1958 /* check if the address is plausible; if so,
1959 add it to our list! */
1960
1961 GNUNET_assert(cls !=NULL);
1962 //FIXME mitm is not checked
1963 //Mac Address has 6 bytes
1964 if (addrlen == 6)
1965 {
1966 /* TODO check for bad addresses like multicast, broadcast, etc */
1967 return GNUNET_OK;
1968 }
1969
1970 return GNUNET_SYSERR;
1971}
1972 1917
1973/** 1918/**
1974 * Function called for a quick conversion of the binary address to 1919 * Function called for a quick conversion of the binary address to
@@ -2084,151 +2029,9 @@ insert_fragment_in_queue(struct Receive_Message_Queue * rx_message,
2084 setBit((char *) &rx_message->received_fragments, rx_frag->num); 2029 setBit((char *) &rx_message->received_fragments, rx_frag->num);
2085} 2030}
2086 2031
2087/**
2088 * Function to dispose the fragments received for a message and the message
2089 * @param plugin pointer to the plugin struct
2090 * @param rec_message pointer to the struct holding the message which should be freed
2091 */
2092 2032
2093static void
2094free_receive_message(struct Plugin* plugin,
2095 struct Receive_Message_Queue * rx_message)
2096{
2097 GNUNET_assert(rx_message !=NULL);
2098 struct Receive_Fragment_Queue * rec_queue = rx_message->frag_head;
2099 struct Receive_Fragment_Queue * rec_queue2;
2100
2101 while (rec_queue != NULL)
2102 {
2103 rec_queue2 = rec_queue;
2104 rec_queue = rec_queue->next;
2105 GNUNET_free(rec_queue2);
2106 }
2107
2108 GNUNET_CONTAINER_DLL_remove(plugin->receive_messages_head,plugin->receive_messages_teil, rx_message);
2109 2033
2110 GNUNET_assert(plugin->pending_receive_messages > 0);
2111 GNUNET_assert(rx_message->session->fragment_messages_in_count > 0);
2112 2034
2113 plugin->pending_receive_messages--;
2114 rx_message->session->fragment_messages_in_count--;
2115 GNUNET_free(rx_message);
2116}
2117
2118/**
2119 * Function to check if all fragments of a message have been received
2120 * @param plugin the plugin handle
2121 * @param session_light information of the message sender
2122 * @param session session the message belongs to
2123 * @param rec_message pointer to the message that should be checked
2124 */
2125
2126static void
2127check_rec_finished_msg(struct Plugin* plugin,
2128 struct Session_light * session_light, struct Session * session,
2129 struct Receive_Message_Queue * rx_message)
2130{
2131 GNUNET_assert(rx_message !=NULL);
2132
2133 struct Receive_Fragment_Queue * rx_frag = rx_message->frag_head;
2134 int packetsize = rx_message->rec_size;
2135 int sum = 0;
2136 int aktnum = 0;
2137 uint64_t bitfield = 0;
2138 char * msg;
2139
2140 //check if first fragment is present
2141 if (packetsize == MESSAGE_LENGHT_UNKNOWN)
2142 {
2143 return;
2144 }
2145 // test if message has at least the size of the WlanHeader and a GNUNET_MessageHeader
2146 else if (packetsize < sizeof(struct WlanHeader)
2147 + sizeof(struct GNUNET_MessageHeader))
2148 {
2149#if DEBUG_wlan
2150 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Message not big enough\n");
2151#endif
2152 free_receive_message(plugin, rx_message);
2153 return;
2154 }
2155
2156#if DEBUG_wlan
2157 check_message_fragment_bitfield(rx_message);
2158#endif
2159
2160 // if (rx_message->frag_tail->num == ffsl(rx_message->received_fragments))
2161 // {
2162 bitfield = ~bitfield;
2163 bitfield = bitfield >> (63 - rx_message->frag_tail->num);
2164 if (rx_message->received_fragments == bitfield)
2165 {
2166
2167 while (rx_frag != NULL)
2168 {
2169 sum += rx_frag->size;
2170 rx_frag = rx_frag->next;
2171 }
2172 //sum should always be smaller or equal of
2173 GNUNET_assert(sum <= packetsize);
2174 if (sum == packetsize)
2175 {
2176
2177#if DEBUG_wlan
2178 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2179 "check_rec_finished_msg: A message for %p is complete\n", session);
2180#endif
2181
2182 //TODO use mst
2183 //copy fragments together
2184 msg = GNUNET_malloc(packetsize);
2185 rx_frag = rx_message->frag_head;
2186 aktnum = 0;
2187 while (rx_frag != NULL)
2188 {
2189 //TODO SAVE SOME COPY OPS AND CHECK CRC WITHOUT COPY
2190 memcpy(msg + aktnum, rx_frag->msg, rx_frag->size);
2191 aktnum += rx_frag->size;
2192 rx_frag = rx_frag->next;
2193 }
2194
2195 free_receive_message(plugin, rx_message);
2196 //call wlan_process_helper to process the message
2197 wlan_data_massage_handler(plugin, session_light,
2198 (struct GNUNET_MessageHeader*) msg);
2199 //wlan_data_helper (plugin, session_light, (struct GNUNET_MessageHeader*) msg);
2200
2201 GNUNET_free(msg);
2202 }
2203 }
2204 // }
2205}
2206
2207static void
2208process_data(void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
2209{
2210
2211 GNUNET_assert(client != NULL);
2212 GNUNET_assert(cls != NULL);
2213 struct Session * session = (struct Session *) client;
2214 struct Plugin * plugin = (struct Plugin *) cls;
2215
2216 struct GNUNET_TRANSPORT_ATS_Information distance[2];
2217 distance[0].type = htonl(GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
2218 distance[0].value = htonl(1);
2219 distance[1].type = htonl(GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
2220 distance[1].value = htonl(0);
2221
2222#if DEBUG_wlan
2223 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2224 "Calling plugin->env->receive for session %p; %s; size: %u\n", session,
2225 wlan_plugin_address_to_string(NULL, session->addr, 6), htons(hdr->size));
2226#endif
2227
2228 plugin->env->receive(plugin->env->cls, &(session->target), hdr,
2229 (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, session,
2230 session->addr, sizeof(session->addr));
2231}
2232 2035
2233/** 2036/**
2234 * handels the data after all fragments are put together 2037 * handels the data after all fragments are put together
@@ -2267,7 +2070,7 @@ wlan_data_massage_handler(struct Plugin * plugin,
2267 GNUNET_assert(session_light != NULL); 2070 GNUNET_assert(session_light != NULL);
2268 if (session_light->session == NULL) 2071 if (session_light->session == NULL)
2269 { 2072 {
2270 session_light->session = search_session(plugin, session_light->addr); 2073 session_light->session = search_session(plugin, &session_light->addr);
2271 } 2074 }
2272 session = session_light->session; 2075 session = session_light->session;
2273 wlanheader = (struct WlanHeader *) hdr; 2076 wlanheader = (struct WlanHeader *) hdr;
@@ -2304,7 +2107,7 @@ wlan_data_massage_handler(struct Plugin * plugin,
2304 (const struct GNUNET_HELLO_Message *) temp_hdr, 2107 (const struct GNUNET_HELLO_Message *) temp_hdr,
2305 &tmptarget) == GNUNET_OK) 2108 &tmptarget) == GNUNET_OK)
2306 { 2109 {
2307 session = create_session(plugin, session_light->addr); 2110 session = create_session(plugin, &session_light->addr);
2308 session_light->session = session; 2111 session_light->session = session;
2309 memcpy(&session->target, &tmptarget, 2112 memcpy(&session->target, &tmptarget,
2310 sizeof(struct GNUNET_PeerIdentity)); 2113 sizeof(struct GNUNET_PeerIdentity));
@@ -2352,6 +2155,123 @@ wlan_data_massage_handler(struct Plugin * plugin,
2352 } 2155 }
2353} 2156}
2354 2157
2158
2159
2160/**
2161 * Function to check if all fragments of a message have been received
2162 * @param plugin the plugin handle
2163 * @param session_light information of the message sender
2164 * @param session session the message belongs to
2165 * @param rec_message pointer to the message that should be checked
2166 */
2167
2168static void
2169check_rec_finished_msg(struct Plugin* plugin,
2170 struct Session_light * session_light, struct Session * session,
2171 struct Receive_Message_Queue * rx_message)
2172{
2173 GNUNET_assert(rx_message !=NULL);
2174
2175 struct Receive_Fragment_Queue * rx_frag = rx_message->frag_head;
2176 int packetsize = rx_message->rec_size;
2177 int sum = 0;
2178 int aktnum = 0;
2179 uint64_t bitfield = 0;
2180 char * msg;
2181
2182 //check if first fragment is present
2183 if (packetsize == MESSAGE_LENGHT_UNKNOWN)
2184 {
2185 return;
2186 }
2187 // test if message has at least the size of the WlanHeader and a GNUNET_MessageHeader
2188 else if (packetsize < sizeof(struct WlanHeader)
2189 + sizeof(struct GNUNET_MessageHeader))
2190 {
2191#if DEBUG_wlan
2192 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Message not big enough\n");
2193#endif
2194 free_receive_message(plugin, rx_message);
2195 return;
2196 }
2197
2198#if DEBUG_wlan
2199 check_message_fragment_bitfield(rx_message);
2200#endif
2201
2202 // if (rx_message->frag_tail->num == ffsl(rx_message->received_fragments))
2203 // {
2204 bitfield = ~bitfield;
2205 bitfield = bitfield >> (63 - rx_message->frag_tail->num);
2206 if (rx_message->received_fragments == bitfield)
2207 {
2208
2209 while (rx_frag != NULL)
2210 {
2211 sum += rx_frag->size;
2212 rx_frag = rx_frag->next;
2213 }
2214 //sum should always be smaller or equal of
2215 GNUNET_assert(sum <= packetsize);
2216 if (sum == packetsize)
2217 {
2218
2219#if DEBUG_wlan
2220 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2221 "check_rec_finished_msg: A message for %p is complete\n", session);
2222#endif
2223
2224 //TODO use mst
2225 //copy fragments together
2226 msg = GNUNET_malloc(packetsize);
2227 rx_frag = rx_message->frag_head;
2228 aktnum = 0;
2229 while (rx_frag != NULL)
2230 {
2231 //TODO SAVE SOME COPY OPS AND CHECK CRC WITHOUT COPY
2232 memcpy(msg + aktnum, rx_frag->msg, rx_frag->size);
2233 aktnum += rx_frag->size;
2234 rx_frag = rx_frag->next;
2235 }
2236
2237 free_receive_message(plugin, rx_message);
2238 //call wlan_process_helper to process the message
2239 wlan_data_massage_handler(plugin, session_light,
2240 (struct GNUNET_MessageHeader*) msg);
2241 //wlan_data_helper (plugin, session_light, (struct GNUNET_MessageHeader*) msg);
2242
2243 GNUNET_free(msg);
2244 }
2245 }
2246 // }
2247}
2248
2249static void
2250process_data(void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
2251{
2252
2253 GNUNET_assert(client != NULL);
2254 GNUNET_assert(cls != NULL);
2255 struct Session * session = (struct Session *) client;
2256 struct Plugin * plugin = (struct Plugin *) cls;
2257
2258 struct GNUNET_TRANSPORT_ATS_Information distance[2];
2259 distance[0].type = htonl(GNUNET_TRANSPORT_ATS_QUALITY_NET_DISTANCE);
2260 distance[0].value = htonl(1);
2261 distance[1].type = htonl(GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR);
2262 distance[1].value = htonl(0);
2263
2264#if DEBUG_wlan
2265 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2266 "Calling plugin->env->receive for session %p; %s; size: %u\n", session,
2267 wlan_plugin_address_to_string(NULL, session->addr, 6), htons(hdr->size));
2268#endif
2269
2270 plugin->env->receive(plugin->env->cls, &(session->target), hdr,
2271 (const struct GNUNET_TRANSPORT_ATS_Information *) &distance, 2, session,
2272 (const char*) &session->addr, sizeof(session->addr));
2273}
2274
2355/** 2275/**
2356 * function to add an ack to send it for a received fragment 2276 * function to add an ack to send it for a received fragment
2357 * @param plugin pointer to the global plugin structure 2277 * @param plugin pointer to the global plugin structure
@@ -2404,27 +2324,7 @@ get_receive_message(struct Plugin * plugin, struct Session * session,
2404 return NULL; 2324 return NULL;
2405} 2325}
2406 2326
2407/**
2408 * function to get the receive message of a session
2409 * @param plugin pointer to the plugin struct
2410 * @param session session this fragment belongs to
2411 */
2412 2327
2413struct Receive_Message_Queue *
2414get_receive_message_from_session(struct Plugin * plugin,
2415 struct Session * session)
2416{
2417 struct Receive_Message_Queue * rec_message = plugin->receive_messages_head;
2418 while (rec_message != NULL)
2419 {
2420 if (rec_message->session == session)
2421 {
2422 return rec_message;
2423 }
2424 rec_message = rec_message->next;
2425 }
2426 return NULL;
2427}
2428 2328
2429/** 2329/**
2430 * function to insert a received fragment into the right fragment queue of the right message 2330 * function to insert a received fragment into the right fragment queue of the right message
@@ -2567,7 +2467,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light,
2567 2467
2568 if (session_light->session == NULL) 2468 if (session_light->session == NULL)
2569 { 2469 {
2570 session_light->session = get_Session(plugin, session_light->addr); 2470 session_light->session = get_Session(plugin, &session_light->addr);
2571 } 2471 }
2572 GNUNET_assert(GNUNET_HELLO_get_id( 2472 GNUNET_assert(GNUNET_HELLO_get_id(
2573 (const struct GNUNET_HELLO_Message *) &hdr[1], 2473 (const struct GNUNET_HELLO_Message *) &hdr[1],
@@ -2582,7 +2482,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light,
2582 GNUNET_assert(session_light != NULL); 2482 GNUNET_assert(session_light != NULL);
2583 if (session_light->session == NULL) 2483 if (session_light->session == NULL)
2584 { 2484 {
2585 session_light->session = search_session(plugin, session_light->addr); 2485 session_light->session = search_session(plugin, &session_light->addr);
2586 } 2486 }
2587 session = session_light->session; 2487 session = session_light->session;
2588 2488
@@ -2649,7 +2549,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light,
2649 GNUNET_assert(session_light != NULL); 2549 GNUNET_assert(session_light != NULL);
2650 if (session_light->session == NULL) 2550 if (session_light->session == NULL)
2651 { 2551 {
2652 session_light->session = search_session(plugin, session_light->addr); 2552 session_light->session = search_session(plugin, &session_light->addr);
2653 GNUNET_assert(session_light->session != NULL); 2553 GNUNET_assert(session_light->session != NULL);
2654 } 2554 }
2655 session = session_light->session; 2555 session = session_light->session;
@@ -2659,7 +2559,7 @@ wlan_data_helper(void *cls, struct Session_light * session_light,
2659 if (fm != NULL) 2559 if (fm != NULL)
2660 { 2560 {
2661 2561
2662 fm->ack_bitfield = fm->ack_bitfield | ntohll(fah->fragment_field); 2562 fm->ack_bitfield = fm->ack_bitfield | GNUNET_ntohll(fah->fragment_field);
2663 check_finished_fragment(plugin, fm); 2563 check_finished_fragment(plugin, fm);
2664 } 2564 }
2665 else 2565 else
@@ -2749,11 +2649,11 @@ wlan_process_helper(void *cls, void *client,
2749 //process only if it is an broadcast or for this computer both with the gnunet bssid 2649 //process only if it is an broadcast or for this computer both with the gnunet bssid
2750 2650
2751 //check for bssid 2651 //check for bssid
2752 if (memcmp(&(wlanIeeeHeader->i_addr3), mac_bssid, sizeof(struct MacAddress)) 2652 if (memcmp(&(wlanIeeeHeader->i_addr3), &mac_bssid, sizeof(struct MacAddress))
2753 == 0) 2653 == 0)
2754 { 2654 {
2755 //check for broadcast or mac 2655 //check for broadcast or mac
2756 if (memcmp(&(wlanIeeeHeader->i_addr1), bc_all_mac, 2656 if (memcmp(&(wlanIeeeHeader->i_addr1), &bc_all_mac,
2757 sizeof(struct MacAddress) == 0) || memcmp( 2657 sizeof(struct MacAddress) == 0) || memcmp(
2758 &(wlanIeeeHeader->i_addr1), &(plugin->mac_address), 2658 &(wlanIeeeHeader->i_addr1), &(plugin->mac_address),
2759 sizeof(struct MacAddress)) == 0) 2659 sizeof(struct MacAddress)) == 0)
@@ -2767,8 +2667,8 @@ wlan_process_helper(void *cls, void *client,
2767 - sizeof(struct Radiotap_rx); 2667 - sizeof(struct Radiotap_rx);
2768 2668
2769 session_light = GNUNET_malloc(sizeof(struct Session_light)); 2669 session_light = GNUNET_malloc(sizeof(struct Session_light));
2770 memcpy(session_light->addr, &(wlanIeeeHeader->i_addr2), 2670 memcpy(&session_light->addr, &(wlanIeeeHeader->i_addr2),
2771 sizeof(struct MacAddress)); 2671 sizeof(struct MacAddress));
2772 //session_light->session = search_session(plugin,session_light->addr); 2672 //session_light->session = search_session(plugin,session_light->addr);
2773 2673
2774 pos = 0; 2674 pos = 0;
@@ -3037,8 +2937,6 @@ libgnunet_plugin_transport_wlan_init(void *cls)
3037 2937
3038 wlan_transport_start_wlan_helper(plugin, testmode); 2938 wlan_transport_start_wlan_helper(plugin, testmode);
3039 2939
3040 start_next_message_id();
3041
3042#if DEBUG_wlan 2940#if DEBUG_wlan
3043 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "wlan init finished\n"); 2941 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "wlan init finished\n");
3044#endif 2942#endif
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h
index 979e466bf..3baa4d79d 100644
--- a/src/transport/plugin_transport_wlan.h
+++ b/src/transport/plugin_transport_wlan.h
@@ -108,12 +108,12 @@ static const uint8_t u8aIeeeHeader[] =
108 }; 108 };
109 109
110// gnunet bssid 110// gnunet bssid
111static const char mac_bssid[] = 111static const struct MacAddress mac_bssid =
112 { 0x13, 0x22, 0x33, 0x44, 0x55, 0x66 }; 112 { { 0x13, 0x22, 0x33, 0x44, 0x55, 0x66 } } ;
113 113
114// broadcast mac 114// broadcast mac
115static const char bc_all_mac[] = 115static const struct MacAddress bc_all_mac =
116 { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 116 { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
117 117
118 118
119/* this is the template radiotap header we send packets out with */ 119/* this is the template radiotap header we send packets out with */