2 This file is part of GNUnet
3 Copyright (C) 2010, 2011 Christian Grothoff (and other contributing authors)
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.
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.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file transport/plugin_transport_wlan.h
23 * @brief header for transport plugin and the helper for wlan
24 * @author David Brodski
26 #ifndef PLUGIN_TRANSPORT_WLAN
27 #define PLUGIN_TRANSPORT_WLAN
29 #include "gnunet_crypto_lib.h"
30 #include "gnunet_common.h"
33 * Number fo bytes in a mac address.
36 #define MAC_ADDR_SIZE 8
37 typedef uint8_t u_int8_t;
39 #define MAC_ADDR_SIZE 6
43 * Value for "Management" in the 'frame_control' field of the
44 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
46 #define IEEE80211_FC0_TYPE_MGT 0x00
49 * Value for "Control" in the 'frame_control' field of the
50 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
52 #define IEEE80211_FC0_TYPE_CTL 0x04
55 * Value for DATA in the 'frame_control' field of the
56 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
58 #define IEEE80211_FC0_TYPE_DATA 0x08
61 GNUNET_NETWORK_STRUCT_BEGIN
66 struct GNUNET_TRANSPORT_WLAN_MacAddress
68 uint8_t mac[MAC_ADDR_SIZE];
72 * Format of a WLAN Control Message.
74 struct GNUNET_TRANSPORT_WLAN_HelperControlMessage
77 * Message header. Type is
78 * GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
80 struct GNUNET_MessageHeader hdr;
83 * MAC Address of the local WLAN interface.
85 struct GNUNET_TRANSPORT_WLAN_MacAddress mac;
89 * generic definitions for IEEE 802.3 frames
91 struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame
95 * Address 1: destination address in ad-hoc mode or AP, BSSID if station,
97 struct GNUNET_TRANSPORT_WLAN_MacAddress dst;
100 * Address 2: source address if in ad-hoc-mode or station, BSSID if AP
102 struct GNUNET_TRANSPORT_WLAN_MacAddress src;
113 * generic definitions for IEEE 802.11 frames
115 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame
118 * 802.11 Frame Control field. A bitmask. The overall field is a
119 * 16-bit mask of the respecitve fields. The lowest two bits should
120 * be 0, then comes the "type" (2 bits, see IEEE80211_FC0_TYPE_*
121 * constants), followed by 4-bit subtype (all zeros for ad-hoc),
122 * followed by various flags (to DS, from DS, more frag, retry,
123 * power management, more data, WEP, strict), all of which we also
126 uint16_t frame_control GNUNET_PACKED;
129 * Microseconds to reserve link (duration), 0 by default
131 uint16_t duration GNUNET_PACKED;
134 * Address 1: destination address in ad-hoc mode or AP, BSSID if station,
136 struct GNUNET_TRANSPORT_WLAN_MacAddress addr1;
139 * Address 2: source address if in ad-hoc-mode or station, BSSID if AP
141 struct GNUNET_TRANSPORT_WLAN_MacAddress addr2;
144 * Address 3: BSSID in ad-hoc mode, Destination if station, source if AP
146 struct GNUNET_TRANSPORT_WLAN_MacAddress addr3;
149 * 802.11 sequence control field; contains fragment number an sequence
150 * number (we set this to all zeros).
152 uint16_t sequence_control GNUNET_PACKED;
155 * Link layer control (LLC). Set to a GNUnet-specific value.
166 * Message from the plugin to the WLAN helper: send the given message with the
167 * given connection parameters.
169 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage
173 * Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER'.
175 struct GNUNET_MessageHeader header;
183 * Antenna; the first antenna is 0.
188 * Transmit power expressed as unitless distance from max power set at factory calibration.
189 * 0 is max power. Monotonically nondecreasing with lower power levels.
191 uint16_t tx_power GNUNET_PACKED;
194 * IEEE Frame to transmit (the sender MAC address will be overwritten by the helper as it does not
195 * trust the plugin to set it correctly).
197 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
199 /* actual payload follows */
204 * Message from the WLAN helper to the plugin: we have received the given message with the
205 * given performance characteristics.
208 * struct to represent infos gathered form the radiotap fields, see RadiotapHeader for more Infos
210 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage
214 * Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER'.
216 struct GNUNET_MessageHeader header;
219 * Information about which of the fields below are actually valid.
220 * 0 for none. FIXME: not properly initialized so far (always zero).
222 uint32_t ri_present GNUNET_PACKED;
225 * IEEE80211_RADIOTAP_TSFT, 0 if unknown.
227 uint64_t ri_mactime GNUNET_PACKED;
231 * either IEEE80211_RADIOTAP_DBM_ANTSIGNAL
232 * or IEEE80211_RADIOTAP_DB_ANTSIGNAL, 0 if unknown.
234 int32_t ri_power GNUNET_PACKED;
237 * either IEEE80211_RADIOTAP_DBM_ANTNOISE
238 * or IEEE80211_RADIOTAP_DB_ANTNOISE, 0 if unknown.
240 int32_t ri_noise GNUNET_PACKED;
243 * IEEE80211_RADIOTAP_CHANNEL, 0 if unknown.
245 uint32_t ri_channel GNUNET_PACKED;
248 * Frequency we use. 0 if unknown.
250 uint32_t ri_freq GNUNET_PACKED;
253 * IEEE80211_RADIOTAP_RATE * 50000, 0 if unknown.
255 uint32_t ri_rate GNUNET_PACKED;
258 * IEEE80211_RADIOTAP_ANTENNA, 0 if unknown.
260 uint32_t ri_antenna GNUNET_PACKED;
265 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
267 /* followed by payload */
270 GNUNET_NETWORK_STRUCT_END
275 static const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet = {
276 {0x13, 0x22, 0x33, 0x44, 0x55, 0x66}
283 static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac = {
284 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}