aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transport/gnunet-transport-wlan-helper.c124
-rw-r--r--src/transport/plugin_transport_wlan.c104
-rw-r--r--src/transport/test_transport_api_wlan_peer1.conf5
-rw-r--r--src/transport/test_transport_api_wlan_peer2.conf5
4 files changed, 147 insertions, 91 deletions
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c
index aaa34284d..2cb14b4c6 100644
--- a/src/transport/gnunet-transport-wlan-helper.c
+++ b/src/transport/gnunet-transport-wlan-helper.c
@@ -31,6 +31,7 @@
31#include <sys/socket.h> 31#include <sys/socket.h>
32#include <sys/ioctl.h> 32#include <sys/ioctl.h>
33#include <sys/types.h> 33#include <sys/types.h>
34#include <unistd.h>
34#include <sys/wait.h> 35#include <sys/wait.h>
35#include <sys/time.h> 36#include <sys/time.h>
36#include <sys/stat.h> 37#include <sys/stat.h>
@@ -259,7 +260,6 @@ usage()
259 "1 = first loopback file\n" 260 "1 = first loopback file\n"
260 "2 = second loopback file\n" 261 "2 = second loopback file\n"
261 "\n"); 262 "\n");
262 exit(1);
263} 263}
264 264
265static unsigned long 265static unsigned long
@@ -412,7 +412,7 @@ static int
412linux_read(struct Hardware_Infos * dev, unsigned char *buf, int count, 412linux_read(struct Hardware_Infos * dev, unsigned char *buf, int count,
413 struct Radiotap_rx * ri) 413 struct Radiotap_rx * ri)
414{ 414{
415 unsigned char tmpbuf[4096]; 415 unsigned char tmpbuf[4096 * 4];
416 416
417 int caplen, n, got_signal, got_noise, got_channel, fcs_removed; 417 int caplen, n, got_signal, got_noise, got_channel, fcs_removed;
418 418
@@ -604,14 +604,15 @@ linux_read(struct Hardware_Infos * dev, unsigned char *buf, int count,
604static int 604static int
605linux_write(struct Hardware_Infos * dev, unsigned char *buf, unsigned int count) 605linux_write(struct Hardware_Infos * dev, unsigned char *buf, unsigned int count)
606{ 606{
607 int ret, usedrtap = 0; 607 int ret;
608 unsigned short int *p_rtlen; 608 //int usedrtap;
609 //unsigned short int *p_rtlen;
609 610
610 unsigned char * u8aRadiotap = buf; 611 //unsigned char * u8aRadiotap = buf;
611 612
612 /* Pointer to the radiotap header length field for later use. */ 613 /* Pointer to the radiotap header length field for later use. */
613 p_rtlen = (unsigned short int*) (u8aRadiotap + 2); 614 //p_rtlen = (unsigned short int*) (u8aRadiotap + 2);
614 usedrtap = 0; 615 //usedrtap = 0;
615 ret = write(dev->fd_out, buf, count); 616 ret = write(dev->fd_out, buf, count);
616 617
617 if (ret < 0) 618 if (ret < 0)
@@ -628,21 +629,21 @@ linux_write(struct Hardware_Infos * dev, unsigned char *buf, unsigned int count)
628 } 629 }
629 630
630 /* radiotap header length is stored little endian on all systems */ 631 /* radiotap header length is stored little endian on all systems */
631 if (usedrtap) 632 /*if (usedrtap)
632 ret -= letoh16(*p_rtlen); 633 ret -= letoh16(*p_rtlen);
633 634
634 if (ret < 0) 635 if (ret < 0)
635 { 636 {
636 if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || errno 637 if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || errno
637 == ENOMEM) 638 == ENOMEM)
638 { 639 {
639 usleep(10000); 640 usleep(10000);
640 return (0); 641 return (0);
641 } 642 }
642 643
643 perror("write failed"); 644 perror("write failed");
644 return (-1); 645 return (-1);
645 } 646 }*/
646 647
647 return (ret); 648 return (ret);
648} 649}
@@ -672,12 +673,7 @@ openraw(struct Hardware_Infos * dev, char * iface, int fd, int * arptype,
672 sll.sll_family = AF_PACKET; 673 sll.sll_family = AF_PACKET;
673 sll.sll_ifindex = ifr.ifr_ifindex; 674 sll.sll_ifindex = ifr.ifr_ifindex;
674 675
675 switch (dev->drivertype) 676 sll.sll_protocol = htons(ETH_P_ALL);
676 {
677 default:
678 sll.sll_protocol = htons(ETH_P_ALL);
679 break;
680 }
681 677
682 /* lookup the hardware type */ 678 /* lookup the hardware type */
683 679
@@ -886,12 +882,12 @@ mac_test(unsigned char * buf, struct Hardware_Infos * dev)
886 u8aIeeeHeader = (struct ieee80211_frame *) buf; 882 u8aIeeeHeader = (struct ieee80211_frame *) buf;
887 if (0 == memcmp(u8aIeeeHeader->i_addr3, &mac_bssid, 6)) 883 if (0 == memcmp(u8aIeeeHeader->i_addr3, &mac_bssid, 6))
888 { 884 {
889 if (0 == memcmp(u8aIeeeHeader->i_addr2, dev->pl_mac, 6)) 885 if (0 == memcmp(u8aIeeeHeader->i_addr1, dev->pl_mac, 6))
890 { 886 {
891 return 0; 887 return 0;
892 } 888 }
893 889
894 if (0 == memcmp(u8aIeeeHeader->i_addr2, &bc_all_mac, 6)) 890 if (0 == memcmp(u8aIeeeHeader->i_addr1, &bc_all_mac, 6))
895 { 891 {
896 return 0; 892 return 0;
897 } 893 }
@@ -912,7 +908,7 @@ mac_set(unsigned char * buf, struct Hardware_Infos * dev)
912 struct ieee80211_frame * u8aIeeeHeader; 908 struct ieee80211_frame * u8aIeeeHeader;
913 u8aIeeeHeader = (struct ieee80211_frame *) buf; 909 u8aIeeeHeader = (struct ieee80211_frame *) buf;
914 910
915 u8aIeeeHeader->i_fc[0] = 0x80; 911 u8aIeeeHeader->i_fc[0] = 0x08;
916 u8aIeeeHeader->i_fc[1] = 0x00; 912 u8aIeeeHeader->i_fc[1] = 0x00;
917 913
918 memcpy(u8aIeeeHeader->i_addr2, dev->pl_mac, 6); 914 memcpy(u8aIeeeHeader->i_addr2, dev->pl_mac, 6);
@@ -954,8 +950,7 @@ stdin_send_hw(void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
954 exit(1); 950 exit(1);
955 } 951 }
956 952
957 if (sendsize < sizeof(struct ieee80211_frame) + sizeof(struct WlanHeader) 953 if (sendsize < sizeof(struct ieee80211_frame)
958 + sizeof(struct FragmentationHeader)
959 + sizeof(struct GNUNET_MessageHeader)) 954 + sizeof(struct GNUNET_MessageHeader))
960 { 955 {
961 fprintf(stderr, "Function stdin_send: packet too small\n"); 956 fprintf(stderr, "Function stdin_send: packet too small\n");
@@ -970,9 +965,7 @@ stdin_send_hw(void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
970 965
971 case DT_MAC80211_RT: 966 case DT_MAC80211_RT:
972 memcpy(write_pout->buf, u8aRadiotap, sizeof(u8aRadiotap)); 967 memcpy(write_pout->buf, u8aRadiotap, sizeof(u8aRadiotap));
973 memcpy(write_pout->buf + sizeof(u8aRadiotap), write_pout->buf 968 memcpy(write_pout->buf + sizeof(u8aRadiotap), &header[1], sendsize);
974 + sizeof(struct Radiotap_Send) + sizeof(struct GNUNET_MessageHeader),
975 sendsize);
976 969
977 wlanheader = write_pout->buf + sizeof(u8aRadiotap); 970 wlanheader = write_pout->buf + sizeof(u8aRadiotap);
978 mac_set(wlanheader, dev); 971 mac_set(wlanheader, dev);
@@ -1067,12 +1060,15 @@ int
1067hardwaremode(int argc, char *argv[]) 1060hardwaremode(int argc, char *argv[])
1068{ 1061{
1069 1062
1063 uid_t uid;
1070 struct Hardware_Infos dev; 1064 struct Hardware_Infos dev;
1071 struct ifreq ifreq; 1065 //struct ifreq ifreq;
1072 struct Radiotap_rx * rxinfo; 1066 struct Radiotap_rx * rxinfo;
1073 uint8_t * mac = dev.pl_mac; 1067 uint8_t * mac = dev.pl_mac;
1074 int fdpin, fdpout; 1068 int fdpin, fdpout;
1075 1069
1070 struct GNUNET_MessageHeader * header;
1071
1076 signal(SIGINT, &sigfunc_hw); 1072 signal(SIGINT, &sigfunc_hw);
1077 signal(SIGTERM, &sigfunc_hw); 1073 signal(SIGTERM, &sigfunc_hw);
1078 1074
@@ -1081,9 +1077,16 @@ hardwaremode(int argc, char *argv[])
1081 return 1; 1077 return 1;
1082 } 1078 }
1083 1079
1084 printf("Device %s -> Ethernet %02x:%02x:%02x:%02x:%02x:%02x\n", 1080 uid = getuid();
1085 ifreq.ifr_name, (int) mac[0], (int) mac[1], (int) mac[2], (int) mac[3], 1081 //if (0 != setresuid(uid, uid, uid))
1086 (int) mac[4], (int) mac[5]); 1082 //{
1083 // fprintf(stderr, "Failed to setresuid: %s\n", strerror(errno));
1084 /* not critical, continue anyway */
1085 //}
1086
1087 /*printf("Device %s -> Ethernet %02x:%02x:%02x:%02x:%02x:%02x\n",
1088 ifreq.ifr_name, (int) mac[0], (int) mac[1], (int) mac[2], (int) mac[3],
1089 (int) mac[4], (int) mac[5]);*/
1087 1090
1088 //return 0; 1091 //return 0;
1089 1092
@@ -1127,10 +1130,10 @@ hardwaremode(int argc, char *argv[])
1127 while (0 == closeprog) 1130 while (0 == closeprog)
1128 { 1131 {
1129 1132
1130 write_pout.size = maketest(write_pout.buf, &dev); 1133 //write_pout.size = maketest(write_pout.buf, &dev);
1131 tv.tv_sec = 2; 1134 //tv.tv_sec = 2;
1132 tv.tv_usec = 0; 1135 //tv.tv_usec = 0;
1133 select(0, NULL, NULL, NULL, &tv); 1136 //select(0, NULL, NULL, NULL, &tv);
1134 1137
1135 maxfd = 0; 1138 maxfd = 0;
1136 1139
@@ -1147,8 +1150,8 @@ hardwaremode(int argc, char *argv[])
1147 } 1150 }
1148 if (0 == write_std.size) 1151 if (0 == write_std.size)
1149 { 1152 {
1150 //FD_SET(fdpin, &rfds); 1153 FD_SET(fdpin, &rfds);
1151 //maxfd = fdpin; 1154 maxfd = fdpin;
1152 } 1155 }
1153 FD_ZERO(&wfds); 1156 FD_ZERO(&wfds);
1154 // if there is something to write 1157 // if there is something to write
@@ -1253,12 +1256,13 @@ hardwaremode(int argc, char *argv[])
1253 1256
1254 if (FD_ISSET(fdpin, &rfds)) 1257 if (FD_ISSET(fdpin, &rfds))
1255 { 1258 {
1256 rxinfo = (struct Radiotap_rx *) (write_pout.buf 1259 rxinfo = (struct Radiotap_rx *) (write_std.buf
1257 + sizeof(struct GNUNET_MessageHeader)); 1260 + sizeof(struct GNUNET_MessageHeader));
1258 datastart = (unsigned char *) readbuf + sizeof(struct Radiotap_rx) 1261 datastart = (unsigned char *) write_std.buf
1262 + sizeof(struct Radiotap_rx)
1259 + sizeof(struct GNUNET_MessageHeader); 1263 + sizeof(struct GNUNET_MessageHeader);
1260 1264
1261 readsize = linux_read(&dev, datastart, sizeof(readbuf) 1265 readsize = linux_read(&dev, datastart, sizeof(write_std.buf)
1262 - sizeof(struct Radiotap_rx) 1266 - sizeof(struct Radiotap_rx)
1263 - sizeof(struct GNUNET_MessageHeader), rxinfo); 1267 - sizeof(struct GNUNET_MessageHeader), rxinfo);
1264 1268
@@ -1273,8 +1277,20 @@ hardwaremode(int argc, char *argv[])
1273 if (1 == mac_test(datastart, &dev)) 1277 if (1 == mac_test(datastart, &dev))
1274 { 1278 {
1275 // mac wrong 1279 // mac wrong
1276 write_pout.pos = 0; 1280 write_std.pos = 0;
1277 write_pout.size = 0; 1281 write_std.size = 0;
1282 }
1283 else
1284 {
1285 header = (struct GNUNET_MessageHeader *) write_std.buf;
1286 write_std.size = readsize
1287 + sizeof(struct GNUNET_MessageHeader)
1288 + sizeof(struct Radiotap_rx);
1289 header->size = htons(write_std.size);
1290 header->type = htons(GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
1291 fprintf(stderr, "Got packet with size: %u, size std %u\n",
1292 readsize, write_std.size);
1293
1278 } 1294 }
1279 } 1295 }
1280 else 1296 else
@@ -1297,6 +1313,7 @@ hardwaremode(int argc, char *argv[])
1297int 1313int
1298main(int argc, char *argv[]) 1314main(int argc, char *argv[])
1299{ 1315{
1316 int ret = 0;
1300 if (3 != argc) 1317 if (3 != argc)
1301 { 1318 {
1302 fprintf( 1319 fprintf(
@@ -1309,11 +1326,12 @@ main(int argc, char *argv[])
1309 if (strstr(argv[2], "1") || strstr(argv[2], "2")) 1326 if (strstr(argv[2], "1") || strstr(argv[2], "2"))
1310 { 1327 {
1311 1328
1312 return testmode(argc, argv); 1329 ret = testmode(argc, argv);
1313 } 1330 }
1314 else 1331 else
1315 { 1332 {
1316 return hardwaremode(argc, argv); 1333
1334 ret = hardwaremode(argc, argv);
1317 } 1335 }
1318 1336
1319#if 0 1337#if 0
@@ -1578,6 +1596,8 @@ main(int argc, char *argv[])
1578 } 1596 }
1579 1597
1580#endif 1598#endif
1581 return (0); 1599
1600 return ret;
1601 maketest(NULL, NULL);
1582} 1602}
1583 1603
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 0564e9127..f8178f101 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -60,7 +60,7 @@
60 60
61#define HALLO_BEACON_SCALING_FACTOR 900 61#define HALLO_BEACON_SCALING_FACTOR 900
62 62
63#define DEBUG_wlan GNUNET_NO 63#define DEBUG_wlan GNUNET_YES
64#define DEBUG_wlan_retransmission GNUNET_NO 64#define DEBUG_wlan_retransmission GNUNET_NO
65 65
66#define MESSAGE_LENGHT_UNKNOWN -1 66#define MESSAGE_LENGHT_UNKNOWN -1
@@ -811,12 +811,14 @@ set_next_beacon_time(struct Plugin * const plugin)
811} 811}
812 812
813//TODO doxigen 813//TODO doxigen
814static struct GNUNET_TIME_Relative 814/*
815get_next_frag_timeout(struct FragmentMessage * fm) 815 static struct GNUNET_TIME_Relative
816{ 816 get_next_frag_timeout(struct FragmentMessage * fm)
817 return GNUNET_TIME_relative_min(GNUNET_TIME_absolute_get_remaining( 817 {
818 fm->next_ack), GNUNET_TIME_absolute_get_remaining(fm->timeout)); 818 return GNUNET_TIME_relative_min(GNUNET_TIME_absolute_get_remaining(
819} 819 fm->next_ack), GNUNET_TIME_absolute_get_remaining(fm->timeout));
820 }
821 */
820 822
821//TODO doxigen 823//TODO doxigen
822/** 824/**
@@ -838,7 +840,8 @@ static void
838set_next_send(struct Plugin * const plugin) 840set_next_send(struct Plugin * const plugin)
839{ 841{
840 struct FragmentMessage * fm; 842 struct FragmentMessage * fm;
841 struct GNUNET_TIME_Relative next_send = GNUNET_TIME_UNIT_FOREVER_REL; 843 struct GNUNET_TIME_Relative next_send;
844 struct GNUNET_TIME_Absolute next_send_tmp;
842 845
843 //cancel old task 846 //cancel old task
844 if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK) 847 if (plugin->server_write_delay_task != GNUNET_SCHEDULER_NO_TASK)
@@ -861,15 +864,11 @@ set_next_send(struct Plugin * const plugin)
861 next_send = GNUNET_TIME_absolute_get_remaining(plugin->beacon_time); 864 next_send = GNUNET_TIME_absolute_get_remaining(plugin->beacon_time);
862 if (fm != NULL) 865 if (fm != NULL)
863 { 866 {
864 if (GNUNET_CONTAINER_node_get_cost(fm->node) != 0) 867 next_send_tmp.abs_value = GNUNET_CONTAINER_heap_node_get_cost(
865 { 868 fm->node);
866 next_send = GNUNET_TIME_relative_min(next_send, 869 next_send = GNUNET_TIME_relative_min(next_send,
867 get_next_frag_timeout(fm)); 870 GNUNET_TIME_absolute_get_remaining(next_send_tmp));
868 } 871
869 else
870 {
871 next_send = GNUNET_TIME_UNIT_ZERO;
872 }
873 } 872 }
874 } 873 }
875 874
@@ -898,10 +897,12 @@ get_next_queue_session(struct Plugin * plugin)
898 struct Sessionqueue * sessionqueue_alt; 897 struct Sessionqueue * sessionqueue_alt;
899 struct PendingMessage * pm; 898 struct PendingMessage * pm;
900 sessionqueue = plugin->pending_Sessions; 899 sessionqueue = plugin->pending_Sessions;
900
901 while (sessionqueue != NULL) 901 while (sessionqueue != NULL)
902 { 902 {
903 session = sessionqueue->content; 903 session = sessionqueue->content;
904 904
905 GNUNET_assert(session != NULL);
905 pm = session->pending_message; 906 pm = session->pending_message;
906 907
907#if DEBUG_wlan 908#if DEBUG_wlan
@@ -912,6 +913,7 @@ get_next_queue_session(struct Plugin * plugin)
912 session); 913 session);
913 } 914 }
914#endif 915#endif
916
915 GNUNET_assert(pm != NULL); 917 GNUNET_assert(pm != NULL);
916 918
917 //check for message timeout 919 //check for message timeout
@@ -1025,7 +1027,10 @@ check_fragment_queue(struct Plugin * plugin)
1025 fm->message_id_out = get_next_message_id(); 1027 fm->message_id_out = get_next_message_id();
1026 fm->ack_bitfield = 0; 1028 fm->ack_bitfield = 0;
1027 fm->node = GNUNET_CONTAINER_heap_insert( 1029 fm->node = GNUNET_CONTAINER_heap_insert(
1028 plugin->pending_Fragment_Messages, fm, 0); 1030 plugin->pending_Fragment_Messages, fm,
1031 GNUNET_TIME_absolute_get().abs_value);
1032
1033 GNUNET_assert(session !=NULL);
1029 1034
1030 if (pm->transmit_cont != NULL) 1035 if (pm->transmit_cont != NULL)
1031 { 1036 {
@@ -1093,8 +1098,6 @@ check_finished_fragment(struct Plugin * plugin, struct FragmentMessage * fm)
1093 1098
1094 free_fragment_message(plugin, fm); 1099 free_fragment_message(plugin, fm);
1095 1100
1096
1097
1098 check_fragment_queue(plugin); 1101 check_fragment_queue(plugin);
1099 1102
1100 } 1103 }
@@ -1170,13 +1173,21 @@ getRadiotapHeader(struct Plugin * plugin, struct Session * session,
1170 */ 1173 */
1171static int 1174static int
1172getWlanHeader(struct ieee80211_frame * Header, 1175getWlanHeader(struct ieee80211_frame * Header,
1173 const struct MacAddress * to_mac_addr, struct Plugin * plugin) 1176 const struct MacAddress * to_mac_addr, struct Plugin * plugin,
1177 unsigned int size)
1174{ 1178{
1175 Header->i_fc[0] = 0x80; 1179 uint16_t * tmp16;
1180 const int rate = 11000000;
1181
1182 Header->i_fc[0] = 0x08;
1176 Header->i_fc[1] = 0x00; 1183 Header->i_fc[1] = 0x00;
1177 memcpy(&Header->i_addr3, &mac_bssid, sizeof(mac_bssid)); 1184 memcpy(&Header->i_addr3, &mac_bssid, sizeof(mac_bssid));
1178 memcpy(&Header->i_addr2, plugin->mac_address.mac, sizeof(plugin->mac_address)); 1185 memcpy(&Header->i_addr2, plugin->mac_address.mac, sizeof(plugin->mac_address));
1179 memcpy(&Header->i_addr1, to_mac_addr, sizeof(plugin->mac_address)); 1186 memcpy(&Header->i_addr1, to_mac_addr, sizeof(struct MacAddress));
1187
1188 tmp16 = (uint16_t*) Header->i_dur;
1189 *tmp16 = (uint16_t) htole16((size * 1000000) / rate + 290);
1190
1180 return GNUNET_YES; 1191 return GNUNET_YES;
1181} 1192}
1182 1193
@@ -1241,7 +1252,7 @@ send_hello_beacon(struct Plugin * plugin)
1241 radioHeader = (struct Radiotap_Send*) &msgheader[1]; 1252 radioHeader = (struct Radiotap_Send*) &msgheader[1];
1242 getRadiotapHeader(plugin, NULL, radioHeader); 1253 getRadiotapHeader(plugin, NULL, radioHeader);
1243 ieeewlanheader = (struct ieee80211_frame*) &radioHeader[1]; 1254 ieeewlanheader = (struct ieee80211_frame*) &radioHeader[1];
1244 getWlanHeader(ieeewlanheader, &bc_all_mac, plugin); 1255 getWlanHeader(ieeewlanheader, &bc_all_mac, plugin, size);
1245 1256
1246 msgheader2 = (struct GNUNET_MessageHeader*) &ieeewlanheader[1]; 1257 msgheader2 = (struct GNUNET_MessageHeader*) &ieeewlanheader[1];
1247 msgheader2->size = htons(GNUNET_HELLO_size(*(plugin->env->our_hello)) 1258 msgheader2->size = htons(GNUNET_HELLO_size(*(plugin->env->our_hello))
@@ -1297,7 +1308,7 @@ send_ack(struct Plugin * plugin, struct AckSendQueue * ack)
1297 radioHeader = (struct Radiotap_Send*) &msgheader[1]; 1308 radioHeader = (struct Radiotap_Send*) &msgheader[1];
1298 getRadiotapHeader(plugin, ack->session, radioHeader); 1309 getRadiotapHeader(plugin, ack->session, radioHeader);
1299 ieeewlanheader = (struct ieee80211_frame*) &radioHeader[1]; 1310 ieeewlanheader = (struct ieee80211_frame*) &radioHeader[1];
1300 getWlanHeader(ieeewlanheader, &ack->session->addr, plugin); 1311 getWlanHeader(ieeewlanheader, &ack->session->addr, plugin, size);
1301 1312
1302 msgheader2 = (struct FragmentationAckHeader*) &ieeewlanheader[1]; 1313 msgheader2 = (struct FragmentationAckHeader*) &ieeewlanheader[1];
1303 msgheader2->header.size = htons(sizeof(struct FragmentationAckHeader)); 1314 msgheader2->header.size = htons(sizeof(struct FragmentationAckHeader));
@@ -1488,7 +1499,7 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1488 getRadiotapHeader(plugin, session, radioHeader); 1499 getRadiotapHeader(plugin, session, radioHeader);
1489 1500
1490 ieeewlanheader = (struct ieee80211_frame *) &radioHeader[1]; 1501 ieeewlanheader = (struct ieee80211_frame *) &radioHeader[1];
1491 getWlanHeader(ieeewlanheader, &fm->session->addr, plugin); 1502 getWlanHeader(ieeewlanheader, &(fm->session->addr), plugin, size);
1492 1503
1493 //could be faster if content is just send and not copyed before 1504 //could be faster if content is just send and not copyed before
1494 //fragmentheader is needed 1505 //fragmentheader is needed
@@ -1528,6 +1539,7 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1528 // if fragments have opimized timeouts 1539 // if fragments have opimized timeouts
1529 //sort_fragment_into_queue(plugin,fm); 1540 //sort_fragment_into_queue(plugin,fm);
1530 1541
1542
1531#if DEBUG_wlan_retransmission 1543#if DEBUG_wlan_retransmission
1532 GNUNET_log( 1544 GNUNET_log(
1533 GNUNET_ERROR_TYPE_DEBUG, 1545 GNUNET_ERROR_TYPE_DEBUG,
@@ -1537,6 +1549,12 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1537 fm->timeout)); 1549 fm->timeout));
1538#endif 1550#endif
1539 } 1551 }
1552 else
1553 {
1554 GNUNET_CONTAINER_heap_update_cost(
1555 plugin->pending_Fragment_Messages, fm->node,
1556 GNUNET_TIME_absolute_get().abs_value);
1557 }
1540 1558
1541 if (bytes != size) 1559 if (bytes != size)
1542 { 1560 {
@@ -1556,7 +1574,6 @@ do_transmit(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1556 } 1574 }
1557 else 1575 else
1558 { 1576 {
1559 GNUNET_assert(bytes == size);
1560 GNUNET_free(msgheader); 1577 GNUNET_free(msgheader);
1561 set_next_send(plugin); 1578 set_next_send(plugin);
1562 } 1579 }
@@ -1858,6 +1875,9 @@ free_session(struct Plugin * plugin, struct Sessionqueue * queue)
1858 struct PendingMessage * pm; 1875 struct PendingMessage * pm;
1859 struct Receive_Message_Queue * receive_queue; 1876 struct Receive_Message_Queue * receive_queue;
1860 struct Plugin_Session_pair pair; 1877 struct Plugin_Session_pair pair;
1878 int check = 0;
1879
1880 GNUNET_assert(queue != NULL);
1861 1881
1862 //session found 1882 //session found
1863 //is this session pending for send 1883 //is this session pending for send
@@ -1869,7 +1889,14 @@ free_session(struct Plugin * plugin, struct Sessionqueue * queue)
1869 GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions, 1889 GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions,
1870 plugin->pending_Sessions_tail, pendingsession); 1890 plugin->pending_Sessions_tail, pendingsession);
1871 GNUNET_free(pendingsession); 1891 GNUNET_free(pendingsession);
1872 break; 1892
1893 if (check == 1)
1894 {
1895 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
1896 "Session is more then once in pending session\n");
1897 }
1898
1899 check = 1;
1873 } 1900 }
1874 pendingsession = pendingsession->next; 1901 pendingsession = pendingsession->next;
1875 } 1902 }
@@ -1904,8 +1931,8 @@ free_session(struct Plugin * plugin, struct Sessionqueue * queue)
1904 GNUNET_free(pm); 1931 GNUNET_free(pm);
1905 } 1932 }
1906 1933
1907 GNUNET_free(queue->content);
1908 GNUNET_CONTAINER_DLL_remove(plugin->sessions, plugin->sessions_tail, queue); 1934 GNUNET_CONTAINER_DLL_remove(plugin->sessions, plugin->sessions_tail, queue);
1935 GNUNET_free(queue->content);
1909 GNUNET_free(queue); 1936 GNUNET_free(queue);
1910 plugin->session_count--; 1937 plugin->session_count--;
1911 1938
@@ -2681,7 +2708,7 @@ wlan_process_helper(void *cls, void *client,
2681 hdr->size), sizeof(struct ieee80211_frame) 2708 hdr->size), sizeof(struct ieee80211_frame)
2682 + sizeof(struct GNUNET_MessageHeader)); 2709 + sizeof(struct GNUNET_MessageHeader));
2683#endif 2710#endif
2684 GNUNET_break (0); 2711 //GNUNET_break (0);
2685 /* FIXME: restart SUID process */ 2712 /* FIXME: restart SUID process */
2686 return; 2713 return;
2687 } 2714 }
@@ -2892,6 +2919,7 @@ libgnunet_plugin_transport_wlan_done(void *cls)
2892 struct GNUNET_TRANSPORT_PluginFunctions *api = cls; 2919 struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
2893 struct Plugin *plugin = api->cls; 2920 struct Plugin *plugin = api->cls;
2894 struct Sessionqueue * queue = plugin->sessions; 2921 struct Sessionqueue * queue = plugin->sessions;
2922 struct Sessionqueue * queue_next;
2895 struct FragmentMessage * fm; 2923 struct FragmentMessage * fm;
2896 2924
2897#if DEBUG_wlan 2925#if DEBUG_wlan
@@ -2907,17 +2935,23 @@ libgnunet_plugin_transport_wlan_done(void *cls)
2907 if (plugin->data_tokenizer != NULL) 2935 if (plugin->data_tokenizer != NULL)
2908 GNUNET_SERVER_mst_destroy(plugin->data_tokenizer); 2936 GNUNET_SERVER_mst_destroy(plugin->data_tokenizer);
2909 2937
2938 fm = (struct FragmentMessage *) GNUNET_CONTAINER_heap_peek(
2939 plugin->pending_Fragment_Messages);
2910 2940
2911 fm = (struct FragmentMessage *) GNUNET_CONTAINER_heap_peek(plugin->pending_Fragment_Messages); 2941 while (fm != NULL)
2912 while (fm != NULL){ 2942 {
2913 free_fragment_message(plugin, fm); 2943 free_fragment_message(plugin, fm);
2914 fm = (struct FragmentMessage *) GNUNET_CONTAINER_heap_peek(plugin->pending_Fragment_Messages); 2944 fm = (struct FragmentMessage *) GNUNET_CONTAINER_heap_peek(
2915 } 2945 plugin->pending_Fragment_Messages);
2946 }
2916 2947
2917 //free sessions 2948 //free sessions
2918 while (queue != NULL) 2949 while (queue != NULL)
2919 { 2950 {
2951 queue_next = queue->next;
2920 free_session(plugin, queue); 2952 free_session(plugin, queue);
2953 queue = queue_next;
2954
2921 } 2955 }
2922 2956
2923 GNUNET_free_non_null(plugin->interface); 2957 GNUNET_free_non_null(plugin->interface);
diff --git a/src/transport/test_transport_api_wlan_peer1.conf b/src/transport/test_transport_api_wlan_peer1.conf
index ecfcebf64..683093ff7 100644
--- a/src/transport/test_transport_api_wlan_peer1.conf
+++ b/src/transport/test_transport_api_wlan_peer1.conf
@@ -8,8 +8,8 @@ AUTOSTART = NO
8AUTOSTART = NO 8AUTOSTART = NO
9 9
10[transport-wlan] 10[transport-wlan]
11INTERFACE = wlan0 11INTERFACE = mon0
12TESTMODE = 1 12TESTMODE = 0
13#PREFIX = gdbserver :2345 13#PREFIX = gdbserver :2345
14 14
15[hostlist] 15[hostlist]
@@ -45,6 +45,7 @@ PORT = 12365
45UNIXPATH = /tmp/gnunet-p1-service-transport.sock 45UNIXPATH = /tmp/gnunet-p1-service-transport.sock
46#PREFIX = xterm -T transport2 -e gdb --command=cmd --args 46#PREFIX = xterm -T transport2 -e gdb --command=cmd --args
47#PREFIX = valgrind --leak-check=full --show-reachable=yes --main-stacksize=104857600 47#PREFIX = valgrind --leak-check=full --show-reachable=yes --main-stacksize=104857600
48#PREFIX = valgrind --leak-check=full --show-reachable=yes
48#PREFIX = valgrind --leak-check=full 49#PREFIX = valgrind --leak-check=full
49#PREFIX = valgrind --tool=massif 50#PREFIX = valgrind --tool=massif
50#PREFIX = gdbserver :2345 51#PREFIX = gdbserver :2345
diff --git a/src/transport/test_transport_api_wlan_peer2.conf b/src/transport/test_transport_api_wlan_peer2.conf
index eff0c2516..22824e090 100644
--- a/src/transport/test_transport_api_wlan_peer2.conf
+++ b/src/transport/test_transport_api_wlan_peer2.conf
@@ -8,8 +8,8 @@ AUTOSTART = NO
8AUTOSTART = NO 8AUTOSTART = NO
9 9
10[transport-wlan] 10[transport-wlan]
11INTERFACE = wlan1 11INTERFACE = mon1
12TESTMODE = 2 12TESTMODE = 0
13#PREFIX = gdbserver :2346 13#PREFIX = gdbserver :2346
14 14
15[hostlist] 15[hostlist]
@@ -45,6 +45,7 @@ PORT = 22365
45UNIXPATH = /tmp/gnunet-p2-service-transport.sock 45UNIXPATH = /tmp/gnunet-p2-service-transport.sock
46#PREFIX = xterm -T transport1 -e gdb --command=cmd --args 46#PREFIX = xterm -T transport1 -e gdb --command=cmd --args
47#PREFIX = valgrind --leak-check=full --show-reachable=yes --main-stacksize=104857600 47#PREFIX = valgrind --leak-check=full --show-reachable=yes --main-stacksize=104857600
48#PREFIX = valgrind --leak-check=full --show-reachable=yes
48#PREFIX = valgrind --leak-check=full 49#PREFIX = valgrind --leak-check=full
49#PREFIX = valgrind --tool=massif 50#PREFIX = valgrind --tool=massif
50#PREFIX = gdbserver :2346 51#PREFIX = gdbserver :2346