2 This file is part of GNUnet
3 Copyright (C) 2010, 2011 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @file transport/plugin_transport_wlan.h
21 * @brief header for transport plugin and the helper for wlan
22 * @author David Brodski
24 #ifndef PLUGIN_TRANSPORT_WLAN
25 #define PLUGIN_TRANSPORT_WLAN
27 #include "gnunet_crypto_lib.h"
28 #include "gnunet_common.h"
31 * Number fo bytes in a mac address.
34 #define MAC_ADDR_SIZE 8
35 typedef uint8_t u_int8_t;
37 #define MAC_ADDR_SIZE 6
41 * Value for "Management" in the 'frame_control' field of the
42 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
44 #define IEEE80211_FC0_TYPE_MGT 0x00
47 * Value for "Control" in the 'frame_control' field of the
48 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
50 #define IEEE80211_FC0_TYPE_CTL 0x04
53 * Value for DATA in the 'frame_control' field of the
54 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
56 #define IEEE80211_FC0_TYPE_DATA 0x08
59 GNUNET_NETWORK_STRUCT_BEGIN
64 struct GNUNET_TRANSPORT_WLAN_MacAddress
66 uint8_t mac[MAC_ADDR_SIZE];
70 * Format of a WLAN Control Message.
72 struct GNUNET_TRANSPORT_WLAN_HelperControlMessage
75 * Message header. Type is
76 * GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
78 struct GNUNET_MessageHeader hdr;
81 * MAC Address of the local WLAN interface.
83 struct GNUNET_TRANSPORT_WLAN_MacAddress mac;
87 * generic definitions for IEEE 802.3 frames
89 struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame
93 * Address 1: destination address in ad-hoc mode or AP, BSSID if station,
95 struct GNUNET_TRANSPORT_WLAN_MacAddress dst;
98 * Address 2: source address if in ad-hoc-mode or station, BSSID if AP
100 struct GNUNET_TRANSPORT_WLAN_MacAddress src;
111 * generic definitions for IEEE 802.11 frames
113 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame
116 * 802.11 Frame Control field. A bitmask. The overall field is a
117 * 16-bit mask of the respecitve fields. The lowest two bits should
118 * be 0, then comes the "type" (2 bits, see IEEE80211_FC0_TYPE_*
119 * constants), followed by 4-bit subtype (all zeros for ad-hoc),
120 * followed by various flags (to DS, from DS, more frag, retry,
121 * power management, more data, WEP, strict), all of which we also
124 uint16_t frame_control GNUNET_PACKED;
127 * Microseconds to reserve link (duration), 0 by default
129 uint16_t duration GNUNET_PACKED;
132 * Address 1: destination address in ad-hoc mode or AP, BSSID if station,
134 struct GNUNET_TRANSPORT_WLAN_MacAddress addr1;
137 * Address 2: source address if in ad-hoc-mode or station, BSSID if AP
139 struct GNUNET_TRANSPORT_WLAN_MacAddress addr2;
142 * Address 3: BSSID in ad-hoc mode, Destination if station, source if AP
144 struct GNUNET_TRANSPORT_WLAN_MacAddress addr3;
147 * 802.11 sequence control field; contains fragment number an sequence
148 * number (we set this to all zeros).
150 uint16_t sequence_control GNUNET_PACKED;
153 * Link layer control (LLC). Set to a GNUnet-specific value.
164 * Message from the plugin to the WLAN helper: send the given message with the
165 * given connection parameters.
167 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage
171 * Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER'.
173 struct GNUNET_MessageHeader header;
181 * Antenna; the first antenna is 0.
186 * Transmit power expressed as unitless distance from max power set at factory calibration.
187 * 0 is max power. Monotonically nondecreasing with lower power levels.
189 uint16_t tx_power GNUNET_PACKED;
192 * IEEE Frame to transmit (the sender MAC address will be overwritten by the helper as it does not
193 * trust the plugin to set it correctly).
195 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
197 /* actual payload follows */
202 * Message from the WLAN helper to the plugin: we have received the given message with the
203 * given performance characteristics.
206 * struct to represent infos gathered form the radiotap fields, see RadiotapHeader for more Infos
208 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage
212 * Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER'.
214 struct GNUNET_MessageHeader header;
217 * Information about which of the fields below are actually valid.
218 * 0 for none. FIXME: not properly initialized so far (always zero).
220 uint32_t ri_present GNUNET_PACKED;
223 * IEEE80211_RADIOTAP_TSFT, 0 if unknown.
225 uint64_t ri_mactime GNUNET_PACKED;
229 * either IEEE80211_RADIOTAP_DBM_ANTSIGNAL
230 * or IEEE80211_RADIOTAP_DB_ANTSIGNAL, 0 if unknown.
232 int32_t ri_power GNUNET_PACKED;
235 * either IEEE80211_RADIOTAP_DBM_ANTNOISE
236 * or IEEE80211_RADIOTAP_DB_ANTNOISE, 0 if unknown.
238 int32_t ri_noise GNUNET_PACKED;
241 * IEEE80211_RADIOTAP_CHANNEL, 0 if unknown.
243 uint32_t ri_channel GNUNET_PACKED;
246 * Frequency we use. 0 if unknown.
248 uint32_t ri_freq GNUNET_PACKED;
251 * IEEE80211_RADIOTAP_RATE * 50000, 0 if unknown.
253 uint32_t ri_rate GNUNET_PACKED;
256 * IEEE80211_RADIOTAP_ANTENNA, 0 if unknown.
258 uint32_t ri_antenna GNUNET_PACKED;
263 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
265 /* followed by payload */
268 GNUNET_NETWORK_STRUCT_END
273 static const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet = {
274 {0x13, 0x22, 0x33, 0x44, 0x55, 0x66}
281 static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac = {
282 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}