3f8e824049175a45a6f9b9ef44277b5982961c73
[oweals/gnunet.git] / src / transport / plugin_transport_wlan.h
1 /*
2  This file is part of GNUnet
3  (C) 2010, 2011 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 #ifndef PLUGIN_TRANSPORT_WLAN
27 #define PLUGIN_TRANSPORT_WLAN
28
29 #include <stdint.h>
30 #include "gnunet_common.h"
31
32 /**
33  * Number fo bytes in a mac address.
34  */
35 #define MAC_ADDR_SIZE 6
36
37 GNUNET_NETWORK_STRUCT_BEGIN
38
39 /**
40  * A MAC Address.
41  */
42 struct GNUNET_TRANSPORT_WLAN_MacAddress
43 {
44   uint8_t mac[MAC_ADDR_SIZE];
45 };
46
47 /**
48  * Format of a WLAN Control Message.
49  */
50 struct GNUNET_TRANSPORT_WLAN_HelperControlMessage
51 {
52   /**
53    * Message header.  Type is
54    * GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
55    */
56   struct GNUNET_MessageHeader hdr;
57
58   /**
59    * MAC Address of the local WLAN interface.
60    */
61   struct GNUNET_TRANSPORT_WLAN_MacAddress mac;
62 };
63
64
65 /**
66  * generic definitions for IEEE 802.11 frames
67  */
68 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame
69 {
70   /**
71    * 802.11 Frame Control field,
72    */
73   uint16_t frame_control GNUNET_PACKED;
74
75   /**
76    * Microseconds to reserve link (duration), 0 by default
77    */
78   uint16_t duration GNUNET_PACKED;
79
80   /**
81    * Address 1: destination address in ad-hoc mode or AP, BSSID if station,
82    */
83   struct GNUNET_TRANSPORT_WLAN_MacAddress addr1;
84
85   /**
86    * Address 2: source address if in ad-hoc-mode or station, BSSID if AP
87    */
88   struct GNUNET_TRANSPORT_WLAN_MacAddress addr2;
89
90   /**
91    * Address 3: BSSID in ad-hoc mode, Destination if station, source if AP
92    */
93   struct GNUNET_TRANSPORT_WLAN_MacAddress addr3;
94
95   /**
96    * 802.11 sequence control field.
97    */
98   uint16_t sequence_control GNUNET_PACKED;
99
100   /**
101    * Link layer control (LLC).  Set to a GNUnet-specific value.
102    */
103   u_int8_t llc[4];
104
105   /* payload */
106
107 } GNUNET_PACKED;
108
109
110
111 /**
112  * Message from the plugin to the WLAN helper: send the given message with the
113  * given connection parameters.
114  */
115 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage
116 {
117
118   /**
119    * Type is 'GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA'.
120    */
121   struct GNUNET_MessageHeader header;
122
123   /**
124    * wlan send rate
125    */
126   uint8_t rate;
127
128   /**
129    * Antenna; the first antenna is 0.
130    */
131   uint8_t antenna;
132
133   /**
134    * Transmit power expressed as unitless distance from max power set at factory calibration.
135    * 0 is max power. Monotonically nondecreasing with lower power levels.
136    */
137   uint16_t tx_power GNUNET_PACKED;
138
139   /**
140    * IEEE Frame to transmit (the sender MAC address will be overwritten by the helper as it does not
141    * trust the plugin to set it correctly).
142    */
143   struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
144
145   /* actual payload follows */
146 };
147
148
149 /**
150  * Message from the WLAN helper to the plugin: we have received the given message with the
151  * given performance characteristics.
152  */
153 /**
154  * struct to represent infos gathered form the radiotap fields, see RadiotapHeader for more Infos
155  */
156 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage
157 {
158
159   /**
160    * Type is 'GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA'.
161    */
162   struct GNUNET_MessageHeader header;
163
164   /**
165    * FIXME: not initialized properly so far. (supposed to contain
166    * information about which of the fields below are actually valid).
167    */
168   uint32_t ri_present GNUNET_PACKED;
169
170   /**
171    * IEEE80211_RADIOTAP_TSFT
172    */
173   uint64_t ri_mactime GNUNET_PACKED;
174
175   /**
176    * from radiotap
177    * either IEEE80211_RADIOTAP_DBM_ANTSIGNAL
178    * or IEEE80211_RADIOTAP_DB_ANTSIGNAL
179    */
180   int32_t ri_power GNUNET_PACKED;
181
182   /**
183    * either IEEE80211_RADIOTAP_DBM_ANTNOISE
184    * or IEEE80211_RADIOTAP_DB_ANTNOISE
185    */
186   int32_t ri_noise GNUNET_PACKED;
187
188   /**
189    * IEEE80211_RADIOTAP_CHANNEL
190    */
191   uint32_t ri_channel GNUNET_PACKED;
192
193   /**
194    * Frequency we use.  FIXME: not properly initialized so far!
195    */
196   uint32_t ri_freq GNUNET_PACKED;
197
198   /**
199    * IEEE80211_RADIOTAP_RATE * 50000
200    */
201   uint32_t ri_rate GNUNET_PACKED;
202
203   /**
204    * IEEE80211_RADIOTAP_ANTENNA
205    */
206   uint32_t ri_antenna GNUNET_PACKED;
207
208   /**
209    * IEEE Frame.
210    */
211   struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
212
213   /* followed by payload */
214 };
215
216 GNUNET_NETWORK_STRUCT_END
217
218 /**
219  * GNUnet bssid
220  */
221 static const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet = {
222   {0x13, 0x22, 0x33, 0x44, 0x55, 0x66}
223 };
224
225
226 /**
227  * Broadcast MAC
228  */
229 static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac = {
230   {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
231 };
232
233 #endif