First test of wlan driver, sends beacon every 2 seconds
[oweals/gnunet.git] / src / transport / plugin_transport_wlan.h
1 /*
2      This file is part of GNUnet
3      (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file transport/plugin_transport_wlan.h
23  * @brief header for transport plugin and the helper for wlan
24  * @author David Brodski
25  */
26
27 #ifndef PLUGIN_TRANSPORT_WLAN
28 #define PLUGIN_TRANSPORT_WLAN
29
30 #include <stdint.h>
31 #include "gnunet_common.h"
32
33
34
35 struct MacAddress
36 {
37   u_int8_t mac[6];
38 };
39
40 struct Wlan_Helper_Control_Message
41 {
42   struct GNUNET_MessageHeader hdr;
43   struct MacAddress mac ;
44 };
45
46
47
48 /* Wlan IEEE80211 header default */
49 //Informations (in German) http://www.umtslink.at/content/WLAN_macheader-196.html
50 static const uint8_t u8aIeeeHeader[] = 
51   {
52     0x08, 0x01, // Frame Control 0x08= 00001000 -> | b1,2 = 0 -> Version 0;
53                 //      b3,4 = 10 -> Data; b5-8 = 0 -> Normal Data
54                 //      0x01 = 00000001 -> | b1 = 1 to DS; b2 = 0 not from DS;
55     0x00, 0x00, // Duration/ID
56     0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // mac1 - in this case receiver
57     0x13, 0x22, 0x33, 0x44, 0x55, 0x66, // mac2 - in this case sender
58     0x13, 0x22, 0x33, 0x44, 0x55, 0x66, // mac3 - in this case bssid
59     0x10, 0x86, //Sequence Control
60   };
61
62 // gnunet bssid
63 static const char mac_bssid[] =
64   { 0x13, 0x22, 0x33, 0x44, 0x55, 0x66 };
65
66 // broadcast mac
67 static const char bc_all_mac[] =
68    { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
69
70
71 /* this is the template radiotap header we send packets out with */
72
73 static const uint8_t u8aRadiotapHeader[] = 
74   {
75     0x00, 0x00, // <-- radiotap version
76     0x19, 0x00, // <- radiotap header length
77     0x6f, 0x08, 0x00, 0x00, // <-- bitmap
78     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // <-- timestamp
79     0x00, // <-- flags (Offset +0x10)
80     0x6c, // <-- rate (0ffset +0x11)
81     0x71, 0x09, 0xc0, 0x00, // <-- channel
82     0xde, // <-- antsignal
83     0x00, // <-- antnoise
84     0x01, // <-- antenna
85 };
86
87 struct Radiotap_Send
88 {
89   /**
90      * wlan send rate
91      */
92     uint8_t rate;
93
94     /**
95      * antenna
96      */
97     uint8_t antenna;
98
99     /**
100      * Transmit power expressed as unitless distance from max power set at factory calibration.
101      * 0 is max power. Monotonically nondecreasing with lower power levels.
102      */
103
104     uint16_t tx_power;
105 };
106
107 struct rx_info {
108         uint64_t ri_mactime;
109         int32_t ri_power;
110         int32_t ri_noise;
111         uint32_t ri_channel;
112         uint32_t ri_freq;
113         uint32_t ri_rate;
114         uint32_t ri_antenna;
115 };
116
117 /**
118  * Radiotap Header
119  */
120 struct RadiotapHeader
121 {
122   /**
123    * radiotap version
124    */
125   u_int8_t version;
126
127   u_int8_t pad_version;
128   
129   /**
130    * radiotap header length
131    */
132   uint16_t length GNUNET_PACKED;
133   
134   /**
135    * bitmap, fields present
136    */
137   uint32_t bitmap GNUNET_PACKED;
138   
139   /**
140    * timestamp
141    */
142   uint64_t timestamp GNUNET_PACKED;
143   
144   /**
145    * radiotap flags
146    */
147   uint8_t flags;
148   
149   /**
150    * wlan send rate
151    */
152   uint8_t rate;
153   
154   // FIXME: unaligned here, is this OK?
155   /**
156    * Wlan channel
157    */
158   uint32_t channel GNUNET_PACKED;
159   
160   /**
161    * antsignal
162    */
163   uint8_t antsignal;
164   
165   /**
166    * antnoise
167    */
168   uint8_t antnoise;
169   
170   /**
171    * antenna
172    */
173   uint8_t antenna;
174 };
175
176 #endif