aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-helper-transport-wlan-dummy.c19
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c86
-rw-r--r--src/transport/gnunet-transport-wlan-sender.c76
-rw-r--r--src/transport/plugin_transport_wlan.c428
-rw-r--r--src/transport/plugin_transport_wlan.h69
5 files changed, 308 insertions, 370 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c
index 6fff758c5..3f17b04dd 100644
--- a/src/transport/gnunet-helper-transport-wlan-dummy.c
+++ b/src/transport/gnunet-helper-transport-wlan-dummy.c
@@ -72,6 +72,7 @@ send_mac_to_plugin (char *buffer, struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
72 return sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage); 72 return sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage);
73} 73}
74 74
75
75static void 76static void
76stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) 77stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
77{ 78{
@@ -83,8 +84,9 @@ stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
83 char *to_start; 84 char *to_start;
84 85
85 sendsize = 86 sendsize =
86 ntohs (hdr->size) - sizeof (struct Radiotap_Send) + 87 ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) +
87 sizeof (struct Radiotap_rx); 88 sizeof (struct Radiotap_rx) + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) +
89 sizeof (struct GNUNET_MessageHeader);
88 90
89 if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type)) 91 if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type))
90 { 92 {
@@ -110,13 +112,14 @@ stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
110 112
111 to_data = to_radiotap + sizeof (struct Radiotap_rx); 113 to_data = to_radiotap + sizeof (struct Radiotap_rx);
112 memcpy (to_data, 114 memcpy (to_data,
113 ((char *) hdr) + sizeof (struct Radiotap_Send) + 115 ((char *) hdr) +
114 sizeof (struct GNUNET_MessageHeader), 116 sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) -
115 ntohs (hdr->size) - sizeof (struct Radiotap_Send) - 117 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame),
116 sizeof (struct GNUNET_MessageHeader)); 118 ntohs (hdr->size) - (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)
119 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)));
117 write_pout->size += 120 write_pout->size +=
118 ntohs (hdr->size) - sizeof (struct Radiotap_Send) - 121 ntohs (hdr->size) - (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)
119 sizeof (struct GNUNET_MessageHeader); 122 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame));
120} 123}
121 124
122 125
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c
index 582df7cf5..03862cc1c 100644
--- a/src/transport/gnunet-helper-transport-wlan.c
+++ b/src/transport/gnunet-helper-transport-wlan.c
@@ -297,6 +297,10 @@ struct ieee80211_radiotap_header
297 * compatible new fields does not count. 297 * compatible new fields does not count.
298 */ 298 */
299 uint8_t it_version; 299 uint8_t it_version;
300
301 /**
302 *
303 */
300 uint8_t it_pad; 304 uint8_t it_pad;
301 305
302 /** 306 /**
@@ -375,23 +379,6 @@ static struct SendBuffer write_pout;
375static struct SendBuffer write_std; 379static struct SendBuffer write_std;
376 380
377 381
378GNUNET_NETWORK_STRUCT_BEGIN
379
380/**
381 * generic definitions for IEEE 802.11 frames
382 */
383struct ieee80211_frame
384{
385 uint8_t i_fc[2];
386 uint8_t i_dur[2];
387 uint8_t i_addr1[IEEE80211_ADDR_LEN];
388 uint8_t i_addr2[IEEE80211_ADDR_LEN];
389 uint8_t i_addr3[IEEE80211_ADDR_LEN];
390 uint8_t i_seq[2];
391 /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */
392 /* see below */
393} GNUNET_PACKED;
394GNUNET_NETWORK_STRUCT_END
395 382
396 383
397/** 384/**
@@ -1439,19 +1426,19 @@ test_wlan_interface (const char *iface)
1439/** 1426/**
1440 * Function to test incoming packets mac for being our own. 1427 * Function to test incoming packets mac for being our own.
1441 * 1428 *
1442 * @param uint8_taIeeeHeader buffer of the packet 1429 * @param taIeeeHeader buffer of the packet
1443 * @param dev the Hardware_Infos struct 1430 * @param dev the Hardware_Infos struct
1444 * @return 0 if mac belongs to us, 1 if mac is for another target 1431 * @return 0 if mac belongs to us, 1 if mac is for another target
1445 */ 1432 */
1446static int 1433static int
1447mac_test (const struct ieee80211_frame *uint8_taIeeeHeader, 1434mac_test (const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader,
1448 const struct HardwareInfos *dev) 1435 const struct HardwareInfos *dev)
1449{ 1436{
1450 if (0 != memcmp (uint8_taIeeeHeader->i_addr3, &mac_bssid_gnunet, MAC_ADDR_SIZE)) 1437 if (0 != memcmp (&taIeeeHeader->addr3, &mac_bssid_gnunet, MAC_ADDR_SIZE))
1451 return 1; 1438 return 1;
1452 if (0 == memcmp (uint8_taIeeeHeader->i_addr1, &dev->pl_mac, MAC_ADDR_SIZE)) 1439 if (0 == memcmp (&taIeeeHeader->addr1, &dev->pl_mac, MAC_ADDR_SIZE))
1453 return 0; 1440 return 0;
1454 if (0 == memcmp (uint8_taIeeeHeader->i_addr1, &bc_all_mac, MAC_ADDR_SIZE)) 1441 if (0 == memcmp (&taIeeeHeader->addr1, &bc_all_mac, MAC_ADDR_SIZE))
1455 return 0; 1442 return 0;
1456 return 1; 1443 return 1;
1457} 1444}
@@ -1459,17 +1446,16 @@ mac_test (const struct ieee80211_frame *uint8_taIeeeHeader,
1459 1446
1460/** 1447/**
1461 * function to set the wlan header to make attacks more difficult 1448 * function to set the wlan header to make attacks more difficult
1462 * @param uint8_taIeeeHeader pointer to the header of the packet 1449 * @param taIeeeHeader pointer to the header of the packet
1463 * @param dev pointer to the Hardware_Infos struct 1450 * @param dev pointer to the Hardware_Infos struct
1464 */ 1451 */
1465static void 1452static void
1466mac_set (struct ieee80211_frame *uint8_taIeeeHeader, 1453mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader,
1467 const struct HardwareInfos *dev) 1454 const struct HardwareInfos *dev)
1468{ 1455{
1469 uint8_taIeeeHeader->i_fc[0] = 0x08; 1456 taIeeeHeader->frame_control = ntohs (0x08); // FIXME: need to shift by 8?
1470 uint8_taIeeeHeader->i_fc[1] = 0x00; 1457 taIeeeHeader->addr2 = dev->pl_mac;
1471 memcpy (uint8_taIeeeHeader->i_addr2, &dev->pl_mac, MAC_ADDR_SIZE); 1458 taIeeeHeader->addr3 = mac_bssid_gnunet;
1472 memcpy (uint8_taIeeeHeader->i_addr3, &mac_bssid_gnunet, MAC_ADDR_SIZE);
1473} 1459}
1474 1460
1475 1461
@@ -1482,47 +1468,39 @@ static void
1482stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) 1468stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
1483{ 1469{
1484 struct HardwareInfos *dev = cls; 1470 struct HardwareInfos *dev = cls;
1485 struct Radiotap_Send *header = (struct Radiotap_Send *) &hdr[1]; 1471 const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header;
1486 struct ieee80211_frame *wlanheader; 1472 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *wlanheader;
1487 size_t sendsize; 1473 size_t sendsize;
1488 struct RadioTapheader rtheader; 1474 struct RadioTapheader rtheader;
1489 1475
1490 rtheader.header.it_version = 0; /* radiotap version */
1491 rtheader.header.it_len = GNUNET_htole16 (0x0c); /* radiotap header length */
1492 rtheader.header.it_present = GNUNET_le16toh (0x00008004); /* our bitmap */
1493 rtheader.rate = 0x00;
1494 rtheader.pad1 = 0x00;
1495 rtheader.txflags =
1496 GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
1497
1498 sendsize = ntohs (hdr->size); 1476 sendsize = ntohs (hdr->size);
1499 if (sendsize < 1477 if ( (sendsize <
1500 sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader)) 1478 sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) ||
1479 (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type)) )
1501 { 1480 {
1502 fprintf (stderr, "Function stdin_send_hw: malformed packet (too small)\n"); 1481 fprintf (stderr, "Received malformed message\n");
1503 exit (1); 1482 exit (1);
1504 } 1483 }
1505 sendsize -= 1484 sendsize -= (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame));
1506 sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader);
1507
1508 if (MAXLINE < sendsize) 1485 if (MAXLINE < sendsize)
1509 { 1486 {
1510 fprintf (stderr, "Function stdin_send_hw: Packet too big for buffer\n"); 1487 fprintf (stderr, "Function stdin_send_hw: Packet too big for buffer\n");
1511 exit (1); 1488 exit (1);
1512 } 1489 }
1513 if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type)) 1490 header = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr;
1514 { 1491 rtheader.header.it_version = 0; /* radiotap version */
1515 fprintf (stderr, "Function stdin_send_hw: wrong packet type\n"); 1492 rtheader.header.it_len = GNUNET_htole16 (0x0c); /* radiotap header length */
1516 exit (1); 1493 rtheader.header.it_present = GNUNET_htole16 (0x00008004); /* our bitmap */
1517 } 1494 rtheader.rate = 0x00;
1518 1495 rtheader.pad1 = 0x00;
1496 rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
1519 rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); 1497 rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader));
1520 rtheader.rate = header->rate; 1498 rtheader.rate = header->rate;
1521 memcpy (write_pout.buf, &rtheader, sizeof (rtheader)); 1499 memcpy (write_pout.buf, &rtheader, sizeof (rtheader));
1522 memcpy (write_pout.buf + sizeof (rtheader), &header[1], sendsize); 1500 wlanheader = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &write_pout.buf[sizeof (rtheader)];
1501 memcpy (wlanheader, &header->frame, sendsize);
1523 /* payload contains MAC address, but we don't trust it, so we'll 1502 /* payload contains MAC address, but we don't trust it, so we'll
1524 * overwrite it with OUR MAC address again to prevent mischief */ 1503 * overwrite it with OUR MAC address again to prevent mischief */
1525 wlanheader = (struct ieee80211_frame *) (write_pout.buf + sizeof (rtheader));
1526 mac_set (wlanheader, dev); 1504 mac_set (wlanheader, dev);
1527 write_pout.size = sendsize + sizeof (rtheader); 1505 write_pout.size = sendsize + sizeof (rtheader);
1528} 1506}
@@ -1723,12 +1701,12 @@ main (int argc, char *argv[])
1723 { 1701 {
1724 struct GNUNET_MessageHeader *header; 1702 struct GNUNET_MessageHeader *header;
1725 struct Radiotap_rx *rxinfo; 1703 struct Radiotap_rx *rxinfo;
1726 struct ieee80211_frame *datastart; 1704 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *datastart;
1727 ssize_t ret; 1705 ssize_t ret;
1728 1706
1729 header = (struct GNUNET_MessageHeader *) write_std.buf; 1707 header = (struct GNUNET_MessageHeader *) write_std.buf;
1730 rxinfo = (struct Radiotap_rx *) &header[1]; 1708 rxinfo = (struct Radiotap_rx *) &header[1];
1731 datastart = (struct ieee80211_frame *) &rxinfo[1]; 1709 datastart = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &rxinfo[1];
1732 ret = 1710 ret =
1733 linux_read (&dev, (unsigned char *) datastart, 1711 linux_read (&dev, (unsigned char *) datastart,
1734 sizeof (write_std.buf) - sizeof (struct Radiotap_rx) - 1712 sizeof (write_std.buf) - sizeof (struct Radiotap_rx) -
diff --git a/src/transport/gnunet-transport-wlan-sender.c b/src/transport/gnunet-transport-wlan-sender.c
index 651b4d413..a6280bc7d 100644
--- a/src/transport/gnunet-transport-wlan-sender.c
+++ b/src/transport/gnunet-transport-wlan-sender.c
@@ -46,35 +46,22 @@
46#define IEEE80211_FC0_TYPE_CTL 0x04 46#define IEEE80211_FC0_TYPE_CTL 0x04
47#define IEEE80211_FC0_TYPE_DATA 0x08 47#define IEEE80211_FC0_TYPE_DATA 0x08
48 48
49GNUNET_NETWORK_STRUCT_BEGIN
50
51/*
52 * generic definitions for IEEE 802.11 frames
53 */
54struct ieee80211_frame
55{
56 u_int8_t i_fc[2];
57 u_int8_t i_dur[2];
58 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
59 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
60 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
61 u_int8_t i_seq[2];
62 u_int8_t llc[4];
63} GNUNET_PACKED;
64GNUNET_NETWORK_STRUCT_END
65 49
66/** 50/**
67 * function to fill the radiotap header 51 * function to fill the radiotap header
68 * @param header pointer to the radiotap header 52 * @param header pointer to the radiotap header
53 * @param size total message size
69 * @return GNUNET_YES at success 54 * @return GNUNET_YES at success
70 */ 55 */
71static int 56static int
72getRadiotapHeader (struct Radiotap_Send *header) 57getRadiotapHeader (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header,
58 uint16_t size)
73{ 59{
60 header->header.size = htons (size);
61 header->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
74 header->rate = 255; 62 header->rate = 255;
75 header->tx_power = 0; 63 header->tx_power = 0;
76 header->antenna = 0; 64 header->antenna = 0;
77
78 return GNUNET_YES; 65 return GNUNET_YES;
79} 66}
80 67
@@ -87,23 +74,21 @@ getRadiotapHeader (struct Radiotap_Send *header)
87 * @return GNUNET_YES if there was no error 74 * @return GNUNET_YES if there was no error
88 */ 75 */
89static int 76static int
90getWlanHeader (struct ieee80211_frame *Header, const char *to_mac_addr, 77getWlanHeader (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *Header,
91 const char *mac, unsigned int size) 78 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr,
79 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac, unsigned int size)
92{ 80{
93 uint16_t *tmp16;
94 const int rate = 11000000; 81 const int rate = 11000000;
95 82
96 Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA; 83 Header->frame_control = htons (IEEE80211_FC0_TYPE_DATA);
97 Header->i_fc[1] = 0x00; 84 Header->addr3 = mac_bssid_gnunet;
98 memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet)); 85 Header->addr2 = *mac;
99 memcpy (&Header->i_addr2, mac, sizeof (mac_bssid_gnunet)); 86 Header->addr1 = *to_mac_addr;
100 memcpy (&Header->i_addr1, to_mac_addr, sizeof (mac_bssid_gnunet)); 87 Header->duration = GNUNET_htole16 ((size * 1000000) / rate + 290);
101
102 tmp16 = (uint16_t *) Header->i_dur;
103 *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
104 Header->llc[0] = WLAN_LLC_DSAP_FIELD; 88 Header->llc[0] = WLAN_LLC_DSAP_FIELD;
105 Header->llc[1] = WLAN_LLC_SSAP_FIELD; 89 Header->llc[1] = WLAN_LLC_SSAP_FIELD;
106 90 Header->llc[2] = 0; // FIXME
91 Header->llc[3] = 0; // FIXME
107 return GNUNET_YES; 92 return GNUNET_YES;
108} 93}
109 94
@@ -112,13 +97,10 @@ int
112main (int argc, char *argv[]) 97main (int argc, char *argv[])
113{ 98{
114 char msg_buf[WLAN_MTU]; 99 char msg_buf[WLAN_MTU];
115 struct GNUNET_MessageHeader *msg; 100 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radiotap;
116 struct ieee80211_frame *wlan_header;
117 struct Radiotap_Send *radiotap;
118
119 unsigned int temp[6]; 101 unsigned int temp[6];
120 char inmac[6]; 102 struct GNUNET_TRANSPORT_WLAN_MacAddress inmac;
121 char outmac[6]; 103 struct GNUNET_TRANSPORT_WLAN_MacAddress outmac;
122 int pos; 104 int pos;
123 long long count; 105 long long count;
124 double bytes_per_s; 106 double bytes_per_s;
@@ -144,6 +126,8 @@ main (int argc, char *argv[])
144 "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n"); 126 "e.g. mon0 11-22-33-44-55-66 12-34-56-78-90-ab\n");
145 return 1; 127 return 1;
146 } 128 }
129 for (i = 0; i < 6; i++)
130 outmac.mac[i] = temp[i];
147 if (6 != 131 if (6 !=
148 SSCANF (argv[2], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2], 132 SSCANF (argv[2], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2],
149 &temp[3], &temp[4], &temp[5])) 133 &temp[3], &temp[4], &temp[5]))
@@ -154,9 +138,7 @@ main (int argc, char *argv[])
154 return 1; 138 return 1;
155 } 139 }
156 for (i = 0; i < 6; i++) 140 for (i = 0; i < 6; i++)
157 inmac[i] = temp[i]; 141 inmac.mac[i] = temp[i];
158 for (i = 0; i < 6; i++)
159 outmac[i] = temp[i];
160 142
161 pid_t pid; 143 pid_t pid;
162 int commpipe[2]; /* This holds the fd for the input & output of the pipe */ 144 int commpipe[2]; /* This holds the fd for the input & output of the pipe */
@@ -185,22 +167,16 @@ main (int argc, char *argv[])
185 setvbuf (stdout, (char *) NULL, _IONBF, 0); /* Set non-buffered output on stdout */ 167 setvbuf (stdout, (char *) NULL, _IONBF, 0); /* Set non-buffered output on stdout */
186 168
187 169
188 msg = (struct GNUNET_MessageHeader *) msg_buf; 170 radiotap = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) msg_buf;
189 msg->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); 171 getRadiotapHeader (radiotap, WLAN_MTU);
190 msg->size = htons (WLAN_MTU);
191 radiotap = (struct Radiotap_Send *) &msg[1];
192 wlan_header = (struct ieee80211_frame *) &radiotap[1];
193 pos = 0; 172 pos = 0;
194 173 getWlanHeader (&radiotap->frame, &outmac, &inmac,
195 getRadiotapHeader (radiotap); 174 WLAN_MTU);
196 getWlanHeader (wlan_header, outmac, inmac,
197 WLAN_MTU - sizeof (struct GNUNET_MessageHeader));
198
199 start = time (NULL); 175 start = time (NULL);
200 count = 0; 176 count = 0;
201 while (1) 177 while (1)
202 { 178 {
203 pos += write (commpipe[1], msg, WLAN_MTU - pos); 179 pos += write (commpipe[1], msg_buf, WLAN_MTU - pos);
204 if (pos % WLAN_MTU == 0) 180 if (pos % WLAN_MTU == 0)
205 { 181 {
206 pos = 0; 182 pos = 0;
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 084fc611c..1dc2713ed 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -98,7 +98,8 @@
98#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 1 98#define MESSAGES_IN_DEFRAG_QUEUE_PER_MAC 1
99 99
100/** 100/**
101 * LLC fields for better compatibility 101 * Link layer control fields for better compatibility
102 * (i.e. GNUnet over WLAN is not IP-over-WLAN).
102 */ 103 */
103#define WLAN_LLC_DSAP_FIELD 0x1f 104#define WLAN_LLC_DSAP_FIELD 0x1f
104#define WLAN_LLC_SSAP_FIELD 0x1f 105#define WLAN_LLC_SSAP_FIELD 0x1f
@@ -115,22 +116,6 @@
115#define IEEE80211_FC0_TYPE_CTL 0x04 116#define IEEE80211_FC0_TYPE_CTL 0x04
116#define IEEE80211_FC0_TYPE_DATA 0x08 117#define IEEE80211_FC0_TYPE_DATA 0x08
117 118
118GNUNET_NETWORK_STRUCT_BEGIN
119
120/*
121 * generic definitions for IEEE 802.11 frames
122 */
123struct ieee80211_frame
124{
125 u_int8_t i_fc[2];
126 u_int8_t i_dur[2];
127 u_int8_t i_addr1[IEEE80211_ADDR_LEN];
128 u_int8_t i_addr2[IEEE80211_ADDR_LEN];
129 u_int8_t i_addr3[IEEE80211_ADDR_LEN];
130 u_int8_t i_seq[2];
131 u_int8_t llc[4];
132} GNUNET_PACKED;
133GNUNET_NETWORK_STRUCT_END
134 119
135/** 120/**
136 * Encapsulation of all of the state of the plugin. 121 * Encapsulation of all of the state of the plugin.
@@ -248,10 +233,12 @@ struct Plugin
248 * messages ready for send, head 233 * messages ready for send, head
249 */ 234 */
250 struct FragmentMessage_queue *sending_messages_head; 235 struct FragmentMessage_queue *sending_messages_head;
236
251 /** 237 /**
252 * messages ready for send, tail 238 * messages ready for send, tail
253 */ 239 */
254 struct FragmentMessage_queue *sending_messages_tail; 240 struct FragmentMessage_queue *sending_messages_tail;
241
255 /** 242 /**
256 * time of the next "hello-beacon" 243 * time of the next "hello-beacon"
257 */ 244 */
@@ -291,7 +278,7 @@ struct Finish_send
291 /** 278 /**
292 * head of the next part to send to the helper 279 * head of the next part to send to the helper
293 */ 280 */
294 char *head_of_next_write; 281 const char *head_of_next_write;
295 282
296 /** 283 /**
297 * Start of the message to send, needed for free 284 * Start of the message to send, needed for free
@@ -400,6 +387,7 @@ struct PendingMessage
400 * dll next 387 * dll next
401 */ 388 */
402 struct PendingMessage *next; 389 struct PendingMessage *next;
390
403 /** 391 /**
404 * dll prev 392 * dll prev
405 */ 393 */
@@ -434,6 +422,7 @@ struct PendingMessage
434 422
435}; 423};
436 424
425
437/** 426/**
438 * Queue for acks to send for fragments recived 427 * Queue for acks to send for fragments recived
439 */ 428 */
@@ -444,33 +433,29 @@ struct AckSendQueue
444 * next ack in the ack send queue 433 * next ack in the ack send queue
445 */ 434 */
446 struct AckSendQueue *next; 435 struct AckSendQueue *next;
436
447 /** 437 /**
448 * previous ack in the ack send queue 438 * previous ack in the ack send queue
449 */ 439 */
450 struct AckSendQueue *prev; 440 struct AckSendQueue *prev;
441
451 /** 442 /**
452 * pointer to the session this ack belongs to 443 * pointer to the session this ack belongs to
453 */ 444 */
454 struct MacEndpoint *endpoint; 445 struct MacEndpoint *endpoint;
446
455 /** 447 /**
456 * ID of message, to distinguish between the messages, picked randomly. 448 * ID of message, to distinguish between the messages, picked randomly.
457 */ 449 */
458 uint32_t message_id; 450 uint32_t message_id;
459 451
460 /** 452 /**
461 * msg to send 453 * pointer to the radiotap header with the ACK Message.
462 */
463 struct GNUNET_MessageHeader *hdr;
464 /**
465 * pointer to the ieee wlan header
466 */ 454 */
467 struct ieee80211_frame *ieeewlanheader; 455 const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
468 /**
469 * pointer to the radiotap header
470 */
471 struct Radiotap_Send *radioHeader;
472}; 456};
473 457
458
474/** 459/**
475 * Session infos gathered from a messages 460 * Session infos gathered from a messages
476 */ 461 */
@@ -559,14 +544,17 @@ struct MacEndpoint
559 * Pointer to the global plugin struct. 544 * Pointer to the global plugin struct.
560 */ 545 */
561 struct Plugin *plugin; 546 struct Plugin *plugin;
547
562 /** 548 /**
563 * Struct to hold the session reachable over this mac; head 549 * Struct to hold the session reachable over this mac; head
564 */ 550 */
565 struct Sessionqueue *sessions_head; 551 struct Sessionqueue *sessions_head;
552
566 /** 553 /**
567 * Struct to hold the session reachable over this mac; tail 554 * Struct to hold the session reachable over this mac; tail
568 */ 555 */
569 struct Sessionqueue *sessions_tail; 556 struct Sessionqueue *sessions_tail;
557
570 /** 558 /**
571 * Messages currently sending 559 * Messages currently sending
572 * to a peer, if any. 560 * to a peer, if any.
@@ -578,10 +566,12 @@ struct MacEndpoint
578 * to a peer (tail), if any. 566 * to a peer (tail), if any.
579 */ 567 */
580 struct FragmentMessage *sending_messages_tail; 568 struct FragmentMessage *sending_messages_tail;
569
581 /** 570 /**
582 * dll next 571 * dll next
583 */ 572 */
584 struct MacEndpoint *next; 573 struct MacEndpoint *next;
574
585 /** 575 /**
586 * dll prev 576 * dll prev
587 */ 577 */
@@ -600,7 +590,6 @@ struct MacEndpoint
600 /** 590 /**
601 * count of messages in the fragment out queue for this mac endpoint 591 * count of messages in the fragment out queue for this mac endpoint
602 */ 592 */
603
604 int fragment_messages_out_count; 593 int fragment_messages_out_count;
605 594
606 //TODO DOXIGEN 595 //TODO DOXIGEN
@@ -672,38 +661,29 @@ struct FragmentMessage
672 GNUNET_SCHEDULER_TaskIdentifier timeout_task; 661 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
673 662
674 /** 663 /**
675 * Fragment to send
676 */
677 char *frag;
678
679 /**
680 * size of message
681 */
682 size_t size;
683
684 /**
685 * pointer to the ieee wlan header
686 */
687 struct ieee80211_frame *ieeewlanheader;
688 /**
689 * pointer to the radiotap header 664 * pointer to the radiotap header
690 */ 665 */
691 struct Radiotap_Send *radioHeader; 666 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
692}; 667};
693 668
669
694static void 670static void
695do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 671do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
696 672
673
697static void 674static void
698free_session (struct Plugin *plugin, struct Sessionqueue *queue, 675free_session (struct Plugin *plugin, struct Sessionqueue *queue,
699 int do_free_macendpoint); 676 int do_free_macendpoint);
700 677
678
701static struct MacEndpoint * 679static struct MacEndpoint *
702create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr); 680create_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAddress *addr);
703 681
682
704static void 683static void
705finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 684finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
706 685
686
707/** 687/**
708 * Generates a nice hexdump of a memory area. 688 * Generates a nice hexdump of a memory area.
709 * 689 *
@@ -758,6 +738,7 @@ hexdump (const void *mem, unsigned length)
758 } 738 }
759} 739}
760 740
741
761/** 742/**
762 * Function to find a MacEndpoint with a specific mac addr 743 * Function to find a MacEndpoint with a specific mac addr
763 * @param plugin pointer to the plugin struct 744 * @param plugin pointer to the plugin struct
@@ -787,9 +768,9 @@ get_macendpoint (struct Plugin *plugin, const struct GNUNET_TRANSPORT_WLAN_MacAd
787 { 768 {
788 return NULL; 769 return NULL;
789 } 770 }
790
791} 771}
792 772
773
793/** 774/**
794 * search for a session with the macendpoint and peer id 775 * search for a session with the macendpoint and peer id
795 * 776 *
@@ -1227,7 +1208,7 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm)
1227 fmq = fmq_next; 1208 fmq = fmq_next;
1228 } 1209 }
1229 1210
1230 (session->mac->fragment_messages_out_count)--; 1211 session->mac->fragment_messages_out_count--;
1231 session->fragment_messages_out_count--; 1212 session->fragment_messages_out_count--;
1232 plugin->pending_Fragment_Messages--; 1213 plugin->pending_Fragment_Messages--;
1233 GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending fragments"), 1214 GNUNET_STATISTICS_set (plugin->env->stats, _("# wlan pending fragments"),
@@ -1240,27 +1221,30 @@ free_fragment_message (struct Plugin *plugin, struct FragmentMessage *fm)
1240 GNUNET_SCHEDULER_cancel (fm->timeout_task); 1221 GNUNET_SCHEDULER_cancel (fm->timeout_task);
1241 fm->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1222 fm->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1242 } 1223 }
1243
1244 GNUNET_free (fm); 1224 GNUNET_free (fm);
1245
1246 queue_session (plugin, session); 1225 queue_session (plugin, session);
1247 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1226 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1248 "Free pending fragment messages %p, session %p\n", fm, 1227 "Free pending fragment messages %p, session %p\n", fm,
1249 session); 1228 session);
1250} 1229}
1251 1230
1231
1252/** 1232/**
1253 * function to fill the radiotap header 1233 * function to fill the radiotap header
1234 *
1254 * @param plugin pointer to the plugin struct 1235 * @param plugin pointer to the plugin struct
1255 * @param endpoint pointer to the endpoint 1236 * @param endpoint pointer to the endpoint
1256 * @param header pointer to the radiotap header 1237 * @param header pointer to the radiotap header
1238 * @param size total message size
1257 * @return GNUNET_YES at success 1239 * @return GNUNET_YES at success
1258 */ 1240 */
1259static int 1241static int
1260getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint, 1242getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint,
1261 struct Radiotap_Send *header) 1243 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header,
1244 uint16_t size)
1262{ 1245{
1263 1246 header->header.type = ntohs (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
1247 header->header.size = ntohs (size);
1264 if (endpoint != NULL) 1248 if (endpoint != NULL)
1265 { 1249 {
1266 header->rate = endpoint->rate; 1250 header->rate = endpoint->rate;
@@ -1277,34 +1261,33 @@ getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint,
1277 return GNUNET_YES; 1261 return GNUNET_YES;
1278} 1262}
1279 1263
1264
1280/** 1265/**
1281 * function to generate the wlan hardware header for one packet 1266 * function to generate the wlan hardware header for one packet
1282 * @param Header address to write the header to 1267 * @param Header address to write the header to
1283 * @param to_mac_addr address of the recipient 1268 * @param to_mac_addr address of the recipient
1284 * @param plugin pointer to the plugin struct 1269 * @param plugin pointer to the plugin struct
1285 * @param size size of the whole packet, needed to calculate the time to send the packet 1270 * @param size size of the whole packet, needed to calculate the time to send the packet
1271 * FIXME: 'size' is initialized inconsistently throughout the code (sometimes payload, sometimes everything)
1286 * @return GNUNET_YES if there was no error 1272 * @return GNUNET_YES if there was no error
1287 */ 1273 */
1288static int 1274static int
1289getWlanHeader (struct ieee80211_frame *Header, 1275getWlanHeader (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *Header,
1290 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, struct Plugin *plugin, 1276 const struct GNUNET_TRANSPORT_WLAN_MacAddress *to_mac_addr, struct Plugin *plugin,
1291 unsigned int size) 1277 unsigned int size)
1292{ 1278{
1293 uint16_t *tmp16;
1294 const int rate = 11000000; 1279 const int rate = 11000000;
1295 1280
1296 Header->i_fc[0] = IEEE80211_FC0_TYPE_DATA; 1281 Header->frame_control = htons (IEEE80211_FC0_TYPE_DATA); // FIXME: check: might need to shift by 8?
1297 Header->i_fc[1] = 0x00; 1282 Header->addr1 = *to_mac_addr;
1298 memcpy (&Header->i_addr3, &mac_bssid_gnunet, sizeof (mac_bssid_gnunet)); 1283 Header->addr2 = plugin->mac_address;
1299 memcpy (&Header->i_addr2, plugin->mac_address.mac, 1284 Header->addr3 = mac_bssid_gnunet;
1300 sizeof (plugin->mac_address)); 1285 Header->duration = GNUNET_htole16 ((size * 1000000) / rate + 290);
1301 memcpy (&Header->i_addr1, to_mac_addr, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); 1286 Header->sequence_control = 0; // FIXME?
1302
1303 tmp16 = (uint16_t *) Header->i_dur;
1304 *tmp16 = (uint16_t) GNUNET_htole16 ((size * 1000000) / rate + 290);
1305 Header->llc[0] = WLAN_LLC_DSAP_FIELD; 1287 Header->llc[0] = WLAN_LLC_DSAP_FIELD;
1306 Header->llc[1] = WLAN_LLC_SSAP_FIELD; 1288 Header->llc[1] = WLAN_LLC_SSAP_FIELD;
1307 1289 Header->llc[2] = 0; // FIXME?
1290 Header->llc[3] = 0; // FIXME?
1308 return GNUNET_YES; 1291 return GNUNET_YES;
1309} 1292}
1310 1293
@@ -1317,39 +1300,28 @@ getWlanHeader (struct ieee80211_frame *Header,
1317static void 1300static void
1318add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr) 1301add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr)
1319{ 1302{
1320
1321 struct FragmentMessage *fm = cls; 1303 struct FragmentMessage *fm = cls;
1322 struct FragmentMessage_queue *fmqueue; 1304 struct FragmentMessage_queue *fmqueue;
1305 struct MacEndpoint *endpoint;
1306 struct Plugin *plugin;
1307 uint16_t size;
1323 1308
1324 GNUNET_assert (cls != NULL); 1309 GNUNET_assert (cls != NULL);
1325 GNUNET_assert (fm->frag == NULL); 1310 endpoint = fm->session->mac;
1326 struct MacEndpoint *endpoint = fm->session->mac; 1311 plugin = endpoint->plugin;
1327 struct Plugin *plugin = endpoint->plugin;
1328 struct GNUNET_MessageHeader *msgheader;
1329 struct GNUNET_MessageHeader *msgheader2;
1330 uint16_t size;
1331 1312
1332 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1313 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1333 "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n", 1314 "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n",
1334 fm, fm->session, endpoint, hdr->type); 1315 fm, fm->session, endpoint, hdr->type);
1335 size = 1316 size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + ntohs (hdr->size);
1336 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + 1317 fm->radioHeader = GNUNET_malloc (size);
1337 sizeof (struct ieee80211_frame) + ntohs (hdr->size); 1318 getRadiotapHeader (plugin, fm->session->mac, fm->radioHeader, size);
1338 fm->frag = GNUNET_malloc (size); 1319 getWlanHeader (&fm->radioHeader->frame, &(fm->session->mac->addr), plugin,
1339 fm->size = size; 1320 size);
1340 1321 memcpy (&fm->radioHeader[1], hdr, ntohs (hdr->size));
1341 msgheader = (struct GNUNET_MessageHeader *) fm->frag; 1322 // FIXME: yucky allocation structure!
1342 msgheader->size = htons (size);
1343 msgheader->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
1344
1345 fm->radioHeader = (struct Radiotap_Send *) &msgheader[1];
1346 fm->ieeewlanheader = (struct ieee80211_frame *) &fm->radioHeader[1];
1347 msgheader2 = (struct GNUNET_MessageHeader *) &fm->ieeewlanheader[1];
1348 memcpy (msgheader2, hdr, ntohs (hdr->size));
1349
1350 fmqueue = GNUNET_malloc (sizeof (struct FragmentMessage_queue)); 1323 fmqueue = GNUNET_malloc (sizeof (struct FragmentMessage_queue));
1351 fmqueue->content = fm; 1324 fmqueue->content = fm;
1352
1353 GNUNET_CONTAINER_DLL_insert_tail (plugin->sending_messages_head, 1325 GNUNET_CONTAINER_DLL_insert_tail (plugin->sending_messages_head,
1354 plugin->sending_messages_tail, fmqueue); 1326 plugin->sending_messages_tail, fmqueue);
1355 set_next_send (plugin); 1327 set_next_send (plugin);
@@ -1707,6 +1679,7 @@ finish_sending (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1707 } 1679 }
1708} 1680}
1709 1681
1682
1710/** 1683/**
1711 * function to send a hello beacon 1684 * function to send a hello beacon
1712 * @param plugin pointer to the plugin struct 1685 * @param plugin pointer to the plugin struct
@@ -1717,47 +1690,26 @@ send_hello_beacon (struct Plugin *plugin)
1717 uint16_t size; 1690 uint16_t size;
1718 ssize_t bytes; 1691 ssize_t bytes;
1719 uint16_t hello_size; 1692 uint16_t hello_size;
1720 struct GNUNET_MessageHeader *msgheader; 1693 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *radioHeader;
1721 struct ieee80211_frame *ieeewlanheader;
1722 struct Radiotap_Send *radioHeader;
1723 struct GNUNET_MessageHeader *msgheader2;
1724 const struct GNUNET_MessageHeader *hello; 1694 const struct GNUNET_MessageHeader *hello;
1725 struct Finish_send *finish; 1695 struct Finish_send *finish;
1726 1696
1697 GNUNET_assert (plugin != NULL);
1727 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1698 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1728 "Sending hello beacon\n"); 1699 "Sending hello beacon\n");
1729
1730 GNUNET_assert (plugin != NULL);
1731
1732 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"), 1700 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan hello beacons send"),
1733 1, GNUNET_NO); 1701 1, GNUNET_NO);
1734
1735 hello = plugin->env->get_our_hello (); 1702 hello = plugin->env->get_our_hello ();
1736 hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); 1703 hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello);
1737 GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU); 1704 GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU);
1738 size =
1739 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) +
1740 sizeof (struct ieee80211_frame) + hello_size;
1741
1742 msgheader = GNUNET_malloc (size);
1743 msgheader->size = htons (size);
1744 msgheader->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
1745
1746 radioHeader = (struct Radiotap_Send *) &msgheader[1];
1747 getRadiotapHeader (plugin, NULL, radioHeader);
1748 ieeewlanheader = (struct ieee80211_frame *) &radioHeader[1];
1749 getWlanHeader (ieeewlanheader, &bc_all_mac, plugin, size);
1750
1751 msgheader2 = (struct GNUNET_MessageHeader *) &ieeewlanheader[1];
1752 /*msgheader2->size =
1753 * htons (GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello) +
1754 * sizeof (struct GNUNET_MessageHeader));
1755 *
1756 * msgheader2->type = htons (GNUNET_MESSAGE_TYPE_WLAN_ADVERTISEMENT); */
1757 memcpy (msgheader2, hello, hello_size);
1758
1759 bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, msgheader, size);
1760 1705
1706 size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size;
1707 radioHeader = GNUNET_malloc (size);
1708 getRadiotapHeader (plugin, NULL, radioHeader, size);
1709 getWlanHeader (&radioHeader->frame, &bc_all_mac, plugin, size);
1710 memcpy (&radioHeader[1], hello, hello_size);
1711 bytes = GNUNET_DISK_file_write (plugin->server_stdin_handle, radioHeader, size);
1712 GNUNET_free (radioHeader);
1761 if (bytes == GNUNET_SYSERR) 1713 if (bytes == GNUNET_SYSERR)
1762 { 1714 {
1763 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1715 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
@@ -1770,9 +1722,7 @@ send_hello_beacon (struct Plugin *plugin)
1770 finish->size = 0; 1722 finish->size = 0;
1771 finish->msgstart = NULL; 1723 finish->msgstart = NULL;
1772 restart_helper (plugin, finish); 1724 restart_helper (plugin, finish);
1773
1774 set_next_beacon_time (plugin); 1725 set_next_beacon_time (plugin);
1775
1776 } 1726 }
1777 else 1727 else
1778 { 1728 {
@@ -1780,64 +1730,51 @@ send_hello_beacon (struct Plugin *plugin)
1780 set_next_beacon_time (plugin); 1730 set_next_beacon_time (plugin);
1781 set_next_send (plugin); 1731 set_next_send (plugin);
1782 } 1732 }
1783 GNUNET_free (msgheader);
1784
1785
1786} 1733}
1787 1734
1735
1788/** 1736/**
1789 * function to add an ack to send it for a received fragment 1737 * function to add an ack to send it for a received fragment
1738 *
1790 * @param cls MacEndpoint this ack belongs to 1739 * @param cls MacEndpoint this ack belongs to
1791 * @param msg_id id of the message 1740 * @param msg_id id of the message
1792 * @param hdr pointer to the hdr where the ack is stored 1741 * @param hdr pointer to the hdr where the ack is stored
1793 *
1794 */ 1742 */
1795static void 1743static void
1796add_ack_for_send (void *cls, uint32_t msg_id, 1744add_ack_for_send (void *cls, uint32_t msg_id,
1797 const struct GNUNET_MessageHeader *hdr) 1745 const struct GNUNET_MessageHeader *hdr)
1798{ 1746{
1799
1800 struct AckSendQueue *ack;
1801
1802 GNUNET_assert (cls != NULL);
1803 struct MacEndpoint *endpoint = cls; 1747 struct MacEndpoint *endpoint = cls;
1804 struct Plugin *plugin = endpoint->plugin; 1748 struct Plugin *plugin = endpoint->plugin;
1749 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage* radioHeader;
1750 struct AckSendQueue *ack;
1805 struct GNUNET_MessageHeader *msgheader; 1751 struct GNUNET_MessageHeader *msgheader;
1806 struct GNUNET_MessageHeader *msgheader2;
1807 uint16_t size; 1752 uint16_t size;
1808 1753
1809 size = 1754 GNUNET_assert (endpoint != NULL);
1810 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + 1755 size = sizeof (struct AckSendQueue) + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + ntohs (hdr->size);
1811 sizeof (struct ieee80211_frame) + ntohs (hdr->size) +
1812 sizeof (struct AckSendQueue);
1813
1814 ack = GNUNET_malloc (size); 1756 ack = GNUNET_malloc (size);
1815 ack->message_id = msg_id; 1757 ack->message_id = msg_id;
1816 ack->endpoint = endpoint; 1758 ack->endpoint = endpoint;
1817 1759 radioHeader = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage*) &ack[1];
1818 size = 1760 ack->radioHeader = radioHeader;
1819 sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_Send) + 1761 getRadiotapHeader (plugin, ack->endpoint, radioHeader, size - sizeof (struct AckSendQueue));
1820 sizeof (struct ieee80211_frame) + ntohs (hdr->size); 1762 size = ntohs (hdr->size);
1821 1763 getWlanHeader (&radioHeader->frame,
1822 msgheader = (struct GNUNET_MessageHeader *) &ack[1]; 1764 &ack->endpoint->addr,
1823 ack->hdr = (struct GNUNET_MessageHeader *) &ack[1]; 1765 plugin,
1824 msgheader->size = htons (size); 1766 size);
1825 msgheader->type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); 1767 msgheader = (struct GNUNET_MessageHeader *) &radioHeader[1];
1826 1768 memcpy (msgheader, hdr, size);
1827 ack->radioHeader = (struct Radiotap_Send *) &msgheader[1];
1828 ack->ieeewlanheader = (struct ieee80211_frame *) &(ack->radioHeader)[1];
1829 msgheader2 = (struct GNUNET_MessageHeader *) &(ack->ieeewlanheader)[1];
1830 memcpy (msgheader2, hdr, ntohs (hdr->size));
1831
1832 GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head, 1769 GNUNET_CONTAINER_DLL_insert_tail (plugin->ack_send_queue_head,
1833 plugin->ack_send_queue_tail, ack); 1770 plugin->ack_send_queue_tail, ack);
1834
1835 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1771 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1836 "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n", 1772 "Adding ack with message id %u to send, AckSendQueue %p, endpoint %p\n",
1837 msg_id, ack, endpoint); 1773 msg_id, ack, endpoint);
1838 set_next_send (plugin); 1774 set_next_send (plugin);
1839} 1775}
1840 1776
1777
1841/** 1778/**
1842 * Function for the scheduler if a FragmentMessage times out 1779 * Function for the scheduler if a FragmentMessage times out
1843 * @param cls pointer to the FragmentMessage 1780 * @param cls pointer to the FragmentMessage
@@ -1891,7 +1828,6 @@ check_fragment_queue (struct Plugin *plugin)
1891 fm = GNUNET_malloc (sizeof (struct FragmentMessage)); 1828 fm = GNUNET_malloc (sizeof (struct FragmentMessage));
1892 fm->session = session; 1829 fm->session = session;
1893 fm->timeout.abs_value = pm->timeout.abs_value; 1830 fm->timeout.abs_value = pm->timeout.abs_value;
1894 fm->frag = NULL;
1895 fm->fragcontext = 1831 fm->fragcontext =
1896 GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU, 1832 GNUNET_FRAGMENT_context_create (plugin->env->stats, WLAN_MTU,
1897 &plugin->tracker, 1833 &plugin->tracker,
@@ -1933,6 +1869,7 @@ check_fragment_queue (struct Plugin *plugin)
1933 set_next_send (plugin); 1869 set_next_send (plugin);
1934} 1870}
1935 1871
1872
1936/** 1873/**
1937 * Function to send an ack, does not free the ack 1874 * Function to send an ack, does not free the ack
1938 * @param plugin pointer to the plugin 1875 * @param plugin pointer to the plugin
@@ -1940,27 +1877,21 @@ check_fragment_queue (struct Plugin *plugin)
1940static void 1877static void
1941send_ack (struct Plugin *plugin) 1878send_ack (struct Plugin *plugin)
1942{ 1879{
1943
1944 ssize_t bytes; 1880 ssize_t bytes;
1945 struct AckSendQueue *ack; 1881 struct AckSendQueue *ack;
1946 struct Finish_send *finish; 1882 struct Finish_send *finish;
1947 1883
1884 GNUNET_assert (plugin != NULL);
1948 ack = plugin->ack_send_queue_head; 1885 ack = plugin->ack_send_queue_head;
1949 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1886 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1950 "Sending ack for message_id %u for mac endpoint %p, size %u\n", 1887 "Sending ack for message_id %u for mac endpoint %p, size %u\n",
1951 ack->message_id, ack->endpoint, 1888 ack->message_id, ack->endpoint,
1952 ntohs (ack->hdr->size) - sizeof (struct Radiotap_Send)); 1889 ntohs (ack->radioHeader->header.size));
1953 GNUNET_assert (plugin != NULL);
1954 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1, 1890 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan acks send"), 1,
1955 GNUNET_NO); 1891 GNUNET_NO);
1956
1957 getRadiotapHeader (plugin, ack->endpoint, ack->radioHeader);
1958 getWlanHeader (ack->ieeewlanheader, &ack->endpoint->addr, plugin,
1959 ntohs (ack->hdr->size));
1960
1961 bytes = 1892 bytes =
1962 GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->hdr, 1893 GNUNET_DISK_file_write (plugin->server_stdin_handle, ack->radioHeader,
1963 ntohs (ack->hdr->size)); 1894 ntohs (ack->radioHeader->header.size));
1964 if (bytes == GNUNET_SYSERR) 1895 if (bytes == GNUNET_SYSERR)
1965 { 1896 {
1966 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1897 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
@@ -1973,17 +1904,16 @@ send_ack (struct Plugin *plugin)
1973 finish->size = 0; 1904 finish->size = 0;
1974 finish->msgstart = NULL; 1905 finish->msgstart = NULL;
1975 restart_helper (plugin, finish); 1906 restart_helper (plugin, finish);
1907 return;
1976 } 1908 }
1977 else 1909 GNUNET_assert (bytes == ntohs (ack->radioHeader->header.size));
1978 { 1910 GNUNET_CONTAINER_DLL_remove (plugin->ack_send_queue_head,
1979 GNUNET_assert (bytes == ntohs (ack->hdr->size)); 1911 plugin->ack_send_queue_tail, ack);
1980 GNUNET_CONTAINER_DLL_remove (plugin->ack_send_queue_head, 1912 GNUNET_free (ack);
1981 plugin->ack_send_queue_tail, ack); 1913 set_next_send (plugin);
1982 GNUNET_free (ack);
1983 set_next_send (plugin);
1984 }
1985} 1914}
1986 1915
1916
1987/** 1917/**
1988 * Function called when wlan helper is ready to get some data 1918 * Function called when wlan helper is ready to get some data
1989 * 1919 *
@@ -1994,104 +1924,89 @@ static void
1994do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1924do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1995{ 1925{
1996 struct Plugin *plugin = cls; 1926 struct Plugin *plugin = cls;
1997
1998 GNUNET_assert (plugin != NULL);
1999
2000 plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK;
2001 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
2002 return;
2003
2004 struct Session *session; 1927 struct Session *session;
2005 struct FragmentMessage *fm; 1928 struct FragmentMessage *fm;
2006 struct Finish_send *finish; 1929 struct Finish_send *finish;
2007 struct FragmentMessage_queue *fmq; 1930 struct FragmentMessage_queue *fmq;
2008 ssize_t bytes; 1931 ssize_t bytes;
2009 1932
1933
1934 GNUNET_assert (plugin != NULL);
1935 plugin->server_write_task = GNUNET_SCHEDULER_NO_TASK;
1936 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1937 return;
2010 if (plugin->ack_send_queue_head != NULL) 1938 if (plugin->ack_send_queue_head != NULL)
2011 { 1939 {
2012 send_ack (plugin); 1940 send_ack (plugin);
2013 return; 1941 return;
2014 } 1942 }
2015
2016 //test if a "hello-beacon" has to be send 1943 //test if a "hello-beacon" has to be send
2017 if (GNUNET_TIME_absolute_get_remaining (plugin->beacon_time).rel_value == 0) 1944 if (GNUNET_TIME_absolute_get_remaining (plugin->beacon_time).rel_value == 0)
2018 { 1945 {
2019 send_hello_beacon (plugin); 1946 send_hello_beacon (plugin);
2020 return; 1947 return;
2021 } 1948 }
2022 1949 if (NULL == plugin->sending_messages_head)
2023 if (plugin->sending_messages_head != NULL)
2024 { 1950 {
2025 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments send"), 1, 1951 /* do_transmit did nothing, should not happen */
2026 GNUNET_NO); 1952 GNUNET_break (0);
2027 1953 set_next_send (plugin);
2028 fmq = plugin->sending_messages_head; 1954 return;
2029 fm = fmq->content; 1955 }
2030 GNUNET_CONTAINER_DLL_remove (plugin->sending_messages_head, 1956 GNUNET_STATISTICS_update (plugin->env->stats, _("# wlan fragments send"), 1,
2031 plugin->sending_messages_tail, fmq); 1957 GNUNET_NO);
2032 GNUNET_free (fmq); 1958
2033 1959 fmq = plugin->sending_messages_head;
2034 session = fm->session; 1960 fm = fmq->content;
2035 GNUNET_assert (session != NULL); 1961 GNUNET_CONTAINER_DLL_remove (plugin->sending_messages_head,
2036 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1962 plugin->sending_messages_tail, fmq);
2037 "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n", 1963 GNUNET_free (fmq);
2038 fm, fm->size); 1964
2039 getRadiotapHeader (plugin, session->mac, fm->radioHeader); 1965 session = fm->session;
2040 getWlanHeader (fm->ieeewlanheader, &(fm->session->mac->addr), plugin, 1966 GNUNET_assert (session != NULL);
2041 fm->size); 1967 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2042 1968 "Sending GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT for fragment message %p, size: %u\n",
2043 bytes = 1969 fm, ntohs (fm->radioHeader->header.size));
2044 GNUNET_DISK_file_write (plugin->server_stdin_handle, fm->frag, 1970 bytes =
2045 fm->size); 1971 GNUNET_DISK_file_write (plugin->server_stdin_handle,
2046 1972 fm->radioHeader,
2047 1973 ntohs (fm->radioHeader->header.size));
2048 if (bytes != fm->size) 1974 if (bytes != ntohs (fm->radioHeader->header.size))
1975 {
1976 finish = GNUNET_malloc (sizeof (struct Finish_send));
1977 finish->plugin = plugin;
1978 finish->msgstart = &fm->radioHeader->header;
1979 GNUNET_assert (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK);
1980 if (bytes == GNUNET_SYSERR)
2049 { 1981 {
2050 finish = GNUNET_malloc (sizeof (struct Finish_send)); 1982 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
2051 finish->plugin = plugin; 1983 _
2052 finish->msgstart = (struct GNUNET_MessageHeader *) fm->frag; 1984 ("Error writing to wlan helper. errno == %d, ERROR: %s\n"),
2053 GNUNET_assert (plugin->server_write_task == GNUNET_SCHEDULER_NO_TASK); 1985 errno, strerror (errno));
2054 1986 finish->head_of_next_write = (char*) fm->radioHeader;
2055 if (bytes == GNUNET_SYSERR) 1987 finish->size = ntohs (fm->radioHeader->header.size);
2056 { 1988 restart_helper (plugin, finish);
2057 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
2058 _
2059 ("Error writing to wlan helper. errno == %d, ERROR: %s\n"),
2060 errno, strerror (errno));
2061
2062 finish->head_of_next_write = fm->frag;
2063 finish->size = fm->size;
2064 restart_helper (plugin, finish);
2065 }
2066 else
2067 {
2068 finish->head_of_next_write = fm->frag + bytes;
2069 finish->size = fm->size - bytes;
2070 plugin->server_write_task =
2071 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
2072 plugin->server_stdin_handle,
2073 &finish_sending, finish);
2074 }
2075
2076 fm->frag = NULL;
2077 } 1989 }
2078 else 1990 else
2079 { 1991 {
2080 GNUNET_free (fm->frag); 1992 finish->head_of_next_write = ((char*) fm->radioHeader) + bytes;
2081 fm->frag = NULL; 1993 finish->size = ntohs (fm->radioHeader->header.size) - bytes;
2082 set_next_send (plugin); 1994 plugin->server_write_task =
2083 } 1995 GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL,
2084 GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext); 1996 plugin->server_stdin_handle,
2085 return; 1997 &finish_sending, finish);
1998 }
2086 } 1999 }
2087 2000 else
2088#if 1 2001 {
2089 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2002 GNUNET_free (fm->radioHeader);
2090 "do_transmit did nothing, should not happen!\n"); 2003 fm->radioHeader = NULL;
2091#endif 2004 set_next_send (plugin);
2092 set_next_send (plugin); 2005 }
2006 GNUNET_FRAGMENT_context_transmission_done (fm->fragcontext);
2093} 2007}
2094 2008
2009
2095/** 2010/**
2096 * Another peer has suggested an address for this 2011 * Another peer has suggested an address for this
2097 * peer and transport plugin. Check that this could be a valid 2012 * peer and transport plugin. Check that this could be a valid
@@ -2846,12 +2761,12 @@ wlan_data_helper (void *cls, struct Session_light *session_light,
2846 * @return string to a static buffer with the human-readable mac, will be overwritten during the next call to this function 2761 * @return string to a static buffer with the human-readable mac, will be overwritten during the next call to this function
2847 */ 2762 */
2848static const char * 2763static const char *
2849macprinter (const u_int8_t * mac) 2764macprinter (const struct GNUNET_TRANSPORT_WLAN_MacAddress * mac)
2850{ 2765{
2851 static char macstr[20]; 2766 static char macstr[20];
2852 2767
2853 GNUNET_snprintf (macstr, sizeof (macstr), "%X:%X:%X:%X:%X:%X", mac[0], mac[1], 2768 GNUNET_snprintf (macstr, sizeof (macstr), "%2X:%2X:%2X:%2X:%2X:%2X", mac->mac[0], mac->mac[1],
2854 mac[2], mac[3], mac[4], mac[5]); 2769 mac->mac[2], mac->mac[3], mac->mac[4], mac->mac[5]);
2855 return macstr; 2770 return macstr;
2856} 2771}
2857 2772
@@ -2938,9 +2853,9 @@ wlan_process_helper (void *cls, void *client,
2938 const struct GNUNET_MessageHeader *hdr) 2853 const struct GNUNET_MessageHeader *hdr)
2939{ 2854{
2940 struct Plugin *plugin = cls; 2855 struct Plugin *plugin = cls;
2941 struct ieee80211_frame *wlanIeeeHeader = NULL; 2856 const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *wlanIeeeHeader;
2942 struct Session_light *session_light = NULL; 2857 struct Session_light *session_light = NULL;
2943 struct Radiotap_rx *rxinfo; 2858 const struct Radiotap_rx *rxinfo;
2944 const struct GNUNET_MessageHeader *temp_hdr = NULL; 2859 const struct GNUNET_MessageHeader *temp_hdr = NULL;
2945 2860
2946 int datasize = 0; 2861 int datasize = 0;
@@ -2958,40 +2873,40 @@ wlan_process_helper (void *cls, void *client,
2958 GNUNET_NO); 2873 GNUNET_NO);
2959 //call wlan_process_helper with the message inside, later with wlan: analyze signal 2874 //call wlan_process_helper with the message inside, later with wlan: analyze signal
2960 if (ntohs (hdr->size) < 2875 if (ntohs (hdr->size) <
2961 sizeof (struct ieee80211_frame) + 2876 sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) +
2962 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx)) 2877 2 * sizeof (struct GNUNET_MessageHeader) + sizeof (struct Radiotap_rx))
2963 { 2878 {
2964 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2879 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
2965 "Size of packet is too small; size: %u min size: %u\n", 2880 "Size of packet is too small; size: %u min size: %u\n",
2966 ntohs (hdr->size), 2881 ntohs (hdr->size),
2967 sizeof (struct ieee80211_frame) + 2882 sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) +
2968 sizeof (struct GNUNET_MessageHeader)); 2883 sizeof (struct GNUNET_MessageHeader));
2969 //GNUNET_break (0); 2884 //GNUNET_break (0);
2970 /* FIXME: restart SUID process */ 2885 /* FIXME: restart SUID process */
2971 return; 2886 return;
2972 } 2887 }
2973 2888
2974 rxinfo = (struct Radiotap_rx *) &hdr[1]; 2889 rxinfo = (const struct Radiotap_rx *) &hdr[1];
2975 wlanIeeeHeader = (struct ieee80211_frame *) &rxinfo[1]; 2890 wlanIeeeHeader = (const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &rxinfo[1];
2976 2891
2977 //process only if it is an broadcast or for this computer both with the gnunet bssid 2892 //process only if it is an broadcast or for this computer both with the gnunet bssid
2978 2893
2979 //check for bssid 2894 //check for bssid
2980 if (memcmp 2895 if (memcmp
2981 (&(wlanIeeeHeader->i_addr3), &mac_bssid_gnunet, 2896 (&wlanIeeeHeader->addr3, &mac_bssid_gnunet,
2982 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) 2897 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)
2983 { 2898 {
2984 //check for broadcast or mac 2899 //check for broadcast or mac
2985 if ((memcmp 2900 if ((memcmp
2986 (&(wlanIeeeHeader->i_addr1), &bc_all_mac, 2901 (&wlanIeeeHeader->addr1, &bc_all_mac,
2987 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) || 2902 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0) ||
2988 (memcmp 2903 (memcmp
2989 (&(wlanIeeeHeader->i_addr1), &(plugin->mac_address), 2904 (&wlanIeeeHeader->addr1, &(plugin->mac_address),
2990 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) 2905 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0))
2991 { 2906 {
2992 //if packet is from us return 2907 //if packet is from us return
2993 if ((memcmp 2908 if ((memcmp
2994 (&(wlanIeeeHeader->i_addr2), &(plugin->mac_address), 2909 (&wlanIeeeHeader->addr2, &(plugin->mac_address),
2995 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0)) 2910 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)) == 0))
2996 { 2911 {
2997 return; 2912 return;
@@ -3000,12 +2915,11 @@ wlan_process_helper (void *cls, void *client,
3000 2915
3001 2916
3002 datasize = 2917 datasize =
3003 ntohs (hdr->size) - sizeof (struct ieee80211_frame) - 2918 ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) -
3004 sizeof (struct GNUNET_MessageHeader) - sizeof (struct Radiotap_rx); 2919 sizeof (struct GNUNET_MessageHeader) - sizeof (struct Radiotap_rx);
3005 2920
3006 session_light = GNUNET_malloc (sizeof (struct Session_light)); 2921 session_light = GNUNET_malloc (sizeof (struct Session_light));
3007 memcpy (&session_light->addr, &(wlanIeeeHeader->i_addr2), 2922 session_light->addr = wlanIeeeHeader->addr2;
3008 sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
3009 //session_light->session = search_session(plugin,session_light->addr); 2923 //session_light->session = search_session(plugin,session_light->addr);
3010 GNUNET_STATISTICS_update (plugin->env->stats, 2924 GNUNET_STATISTICS_update (plugin->env->stats,
3011 _("# wlan messages for this client received"), 2925 _("# wlan messages for this client received"),
@@ -3040,14 +2954,14 @@ wlan_process_helper (void *cls, void *client,
3040 { 2954 {
3041 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2955 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3042 "Func wlan_process_helper got wrong MAC: %s\n", 2956 "Func wlan_process_helper got wrong MAC: %s\n",
3043 macprinter (wlanIeeeHeader->i_addr1)); 2957 macprinter (&wlanIeeeHeader->addr1));
3044 } 2958 }
3045 } 2959 }
3046 else 2960 else
3047 { 2961 {
3048 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 2962 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
3049 "Func wlan_process_helper got wrong BSSID: %s\n", 2963 "Func wlan_process_helper got wrong BSSID: %s\n",
3050 macprinter (wlanIeeeHeader->i_addr2)); 2964 macprinter (&wlanIeeeHeader->addr2));
3051 } 2965 }
3052 break; 2966 break;
3053 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: 2967 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h
index 9e1bc4f22..c220c829d 100644
--- a/src/transport/plugin_transport_wlan.h
+++ b/src/transport/plugin_transport_wlan.h
@@ -76,10 +76,67 @@ static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac = {
76 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} 76 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
77}; 77};
78 78
79GNUNET_NETWORK_STRUCT_BEGIN
79 80
80struct Radiotap_Send 81/**
82 * generic definitions for IEEE 802.11 frames
83 */
84struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame
81{ 85{
82 /** 86 /**
87 * 802.11 Frame Control field,
88 */
89 uint16_t frame_control;
90
91 /**
92 * Microseconds to reserve link (duration), 0 by default
93 */
94 uint16_t duration;
95
96 /**
97 * Address 1: destination address in ad-hoc mode or AP, BSSID if station,
98 */
99 struct GNUNET_TRANSPORT_WLAN_MacAddress addr1;
100
101 /**
102 * Address 2: source address if in ad-hoc-mode or station, BSSID if AP
103 */
104 struct GNUNET_TRANSPORT_WLAN_MacAddress addr2;
105
106 /**
107 * Address 3: BSSID in ad-hoc mode, Destination if station, source if AP
108 */
109 struct GNUNET_TRANSPORT_WLAN_MacAddress addr3;
110
111 /**
112 * 802.11 sequence control field.
113 */
114 uint16_t sequence_control;
115
116 /**
117 * Link layer control (LLC). Set to a GNUnet-specific value.
118 */
119 u_int8_t llc[4];
120
121 /* payload */
122
123} GNUNET_PACKED;
124
125
126
127/**
128 * Message from the plugin to the WLAN helper: send the given message with the
129 * given connection parameters.
130 */
131struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage
132{
133
134 /**
135 * Type is 'GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA'.
136 */
137 struct GNUNET_MessageHeader header;
138
139 /**
83 * wlan send rate 140 * wlan send rate
84 */ 141 */
85 uint8_t rate; 142 uint8_t rate;
@@ -94,8 +151,18 @@ struct Radiotap_Send
94 * 0 is max power. Monotonically nondecreasing with lower power levels. 151 * 0 is max power. Monotonically nondecreasing with lower power levels.
95 */ 152 */
96 uint16_t tx_power; 153 uint16_t tx_power;
154
155 /**
156 * IEEE Frame to transmit (the sender MAC address will be overwritten by the helper as it does not
157 * trust the plugin to set it correctly).
158 */
159 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
160
161 /* actual payload follows */
97}; 162};
98 163
164GNUNET_NETWORK_STRUCT_END
165
99 166
100/** 167/**
101 * struct to represent infos gathered form the radiotap fields, see RadiotapHeader for more Infos 168 * struct to represent infos gathered form the radiotap fields, see RadiotapHeader for more Infos