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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
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.
35 #define MAC_ADDR_SIZE 6
38 * Value for "Management" in the 'frame_control' field of the
39 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
41 #define IEEE80211_FC0_TYPE_MGT 0x00
44 * Value for "Control" in the 'frame_control' field of the
45 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
47 #define IEEE80211_FC0_TYPE_CTL 0x04
50 * Value for DATA in the 'frame_control' field of the
51 * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame.
53 #define IEEE80211_FC0_TYPE_DATA 0x08
56 GNUNET_NETWORK_STRUCT_BEGIN
61 struct GNUNET_TRANSPORT_WLAN_MacAddress {
62 uint8_t mac[MAC_ADDR_SIZE];
66 * Format of a WLAN Control Message.
68 struct GNUNET_TRANSPORT_WLAN_HelperControlMessage {
70 * Message header. Type is
71 * GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
73 struct GNUNET_MessageHeader hdr;
76 * MAC Address of the local WLAN interface.
78 struct GNUNET_TRANSPORT_WLAN_MacAddress mac;
82 * generic definitions for IEEE 802.3 frames
84 struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame {
86 * Address 1: destination address in ad-hoc mode or AP, BSSID if station,
88 struct GNUNET_TRANSPORT_WLAN_MacAddress dst;
91 * Address 2: source address if in ad-hoc-mode or station, BSSID if AP
93 struct GNUNET_TRANSPORT_WLAN_MacAddress src;
103 * generic definitions for IEEE 802.11 frames
105 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame {
107 * 802.11 Frame Control field. A bitmask. The overall field is a
108 * 16-bit mask of the respecitve fields. The lowest two bits should
109 * be 0, then comes the "type" (2 bits, see IEEE80211_FC0_TYPE_*
110 * constants), followed by 4-bit subtype (all zeros for ad-hoc),
111 * followed by various flags (to DS, from DS, more frag, retry,
112 * power management, more data, WEP, strict), all of which we also
115 uint16_t frame_control GNUNET_PACKED;
118 * Microseconds to reserve link (duration), 0 by default
120 uint16_t duration GNUNET_PACKED;
123 * Address 1: destination address in ad-hoc mode or AP, BSSID if station,
125 struct GNUNET_TRANSPORT_WLAN_MacAddress addr1;
128 * Address 2: source address if in ad-hoc-mode or station, BSSID if AP
130 struct GNUNET_TRANSPORT_WLAN_MacAddress addr2;
133 * Address 3: BSSID in ad-hoc mode, Destination if station, source if AP
135 struct GNUNET_TRANSPORT_WLAN_MacAddress addr3;
138 * 802.11 sequence control field; contains fragment number an sequence
139 * number (we set this to all zeros).
141 uint16_t sequence_control GNUNET_PACKED;
144 * Link layer control (LLC). Set to a GNUnet-specific value.
154 * Message from the plugin to the WLAN helper: send the given message with the
155 * given connection parameters.
157 struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage {
159 * Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER'.
161 struct GNUNET_MessageHeader header;
169 * Antenna; the first antenna is 0.
174 * Transmit power expressed as unitless distance from max power set at factory calibration.
175 * 0 is max power. Monotonically nondecreasing with lower power levels.
177 uint16_t tx_power GNUNET_PACKED;
180 * IEEE Frame to transmit (the sender MAC address will be overwritten by the helper as it does not
181 * trust the plugin to set it correctly).
183 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
185 /* actual payload follows */
190 * Message from the WLAN helper to the plugin: we have received the given message with the
191 * given performance characteristics.
194 * struct to represent infos gathered form the radiotap fields, see RadiotapHeader for more Infos
196 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage {
198 * Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER'.
200 struct GNUNET_MessageHeader header;
203 * Information about which of the fields below are actually valid.
204 * 0 for none. FIXME: not properly initialized so far (always zero).
206 uint32_t ri_present GNUNET_PACKED;
209 * IEEE80211_RADIOTAP_TSFT, 0 if unknown.
211 uint64_t ri_mactime GNUNET_PACKED;
215 * either IEEE80211_RADIOTAP_DBM_ANTSIGNAL
216 * or IEEE80211_RADIOTAP_DB_ANTSIGNAL, 0 if unknown.
218 int32_t ri_power GNUNET_PACKED;
221 * either IEEE80211_RADIOTAP_DBM_ANTNOISE
222 * or IEEE80211_RADIOTAP_DB_ANTNOISE, 0 if unknown.
224 int32_t ri_noise GNUNET_PACKED;
227 * IEEE80211_RADIOTAP_CHANNEL, 0 if unknown.
229 uint32_t ri_channel GNUNET_PACKED;
232 * Frequency we use. 0 if unknown.
234 uint32_t ri_freq GNUNET_PACKED;
237 * IEEE80211_RADIOTAP_RATE * 50000, 0 if unknown.
239 uint32_t ri_rate GNUNET_PACKED;
242 * IEEE80211_RADIOTAP_ANTENNA, 0 if unknown.
244 uint32_t ri_antenna GNUNET_PACKED;
249 struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame;
251 /* followed by payload */
254 GNUNET_NETWORK_STRUCT_END
259 static const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet = {
260 { 0x13, 0x22, 0x33, 0x44, 0x55, 0x66 }
267 static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac = {
268 { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }