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