remove send on connect
[oweals/gnunet.git] / src / transport / plugin_transport_wlan.h
1 /*
2  This file is part of GNUnet
3  (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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
27 #ifndef PLUGIN_TRANSPORT_WLAN
28 #define PLUGIN_TRANSPORT_WLAN
29
30 #include <stdint.h>
31 #include "gnunet_common.h"
32
33 struct MacAddress
34 {
35   u_int8_t mac[6];
36 };
37
38 struct Wlan_Helper_Control_Message
39 {
40   struct GNUNET_MessageHeader hdr;
41   struct MacAddress mac;
42 };
43
44 /**
45  * Header for messages which need fragmentation
46  */
47 struct FragmentationHeader
48 {
49
50   struct GNUNET_MessageHeader header;
51
52   /**
53    * ID of message, to distinguish between the messages, picked randomly.
54    */
55   uint32_t message_id GNUNET_PACKED;
56
57   /**
58    * Offset or number of this fragment, for fragmentation/segmentation (design choice, TBD)
59    */
60   uint16_t fragment_off_or_num GNUNET_PACKED;
61
62   /**
63    * CRC of fragment (for error checking)
64    */
65   uint16_t message_crc GNUNET_PACKED;
66
67 // followed by payload
68
69 };
70
71 /**
72  * Header for messages which need fragmentation
73  */
74 struct WlanHeader
75 {
76
77   struct GNUNET_MessageHeader header;
78
79   /**
80    * checksum/error correction
81    */
82   uint32_t crc GNUNET_PACKED;
83
84   /**
85    * To whom are we talking to (set to our identity
86    * if we are still waiting for the welcome message)
87    */
88   struct GNUNET_PeerIdentity target;
89
90   /**
91    *  Where the packet came from
92    */
93   struct GNUNET_PeerIdentity source;
94
95 // followed by payload
96
97 };
98
99 /* Wlan IEEE80211 header default */
100 //Informations (in German) http://www.umtslink.at/content/WLAN_macheader-196.html
101 static const uint8_t u8aIeeeHeader[] =
102   { 0x08, 0x01, // Frame Control 0x08= 00001000 -> | b1,2 = 0 -> Version 0;
103       //      b3,4 = 10 -> Data; b5-8 = 0 -> Normal Data
104       //        0x01 = 00000001 -> | b1 = 1 to DS; b2 = 0 not from DS;
105       0x00, 0x00, // Duration/ID
106       0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // mac1 - in this case receiver
107       0x13, 0x22, 0x33, 0x44, 0x55, 0x66, // mac2 - in this case sender
108       0x13, 0x22, 0x33, 0x44, 0x55, 0x66, // mac3 - in this case bssid
109       0x10, 0x86, //Sequence Control
110     };
111
112 // gnunet bssid
113 static const struct MacAddress mac_bssid =
114   {
115     { 0x13, 0x22, 0x33, 0x44, 0x55, 0x66 } };
116
117 // broadcast mac
118 static const struct MacAddress bc_all_mac =
119   {
120     { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } };
121
122 /* this is the template radiotap header we send packets out with */
123
124 static const uint8_t u8aRadiotapHeader[] =
125   { 0x00, 0x00, // <-- radiotap version
126       0x19, 0x00, // <- radiotap header length
127       0x6f, 0x08, 0x00, 0x00, // <-- bitmap
128       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // <-- timestamp
129       0x00, // <-- flags (Offset +0x10)
130       0x6c, // <-- rate (0ffset +0x11)
131       0x71, 0x09, 0xc0, 0x00, // <-- channel
132       0xde, // <-- antsignal
133       0x00, // <-- antnoise
134       0x01, // <-- antenna
135     };
136
137 struct Radiotap_Send
138 {
139   /**
140    * wlan send rate
141    */
142   uint8_t rate;
143
144   /**
145    * antenna
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
154   uint16_t tx_power;
155 };
156
157 // bit field defines for ri_present
158
159 #define has_noise 1
160 #define has_power 2
161 #define has_channel 4
162
163 /**
164  * struct to represent infos gathered form the radiotap fields
165  */
166
167 struct Radiotap_rx
168 {
169   uint32_t ri_present;
170   uint64_t ri_mactime;
171   int32_t ri_power;
172   int32_t ri_noise;
173   uint32_t ri_channel;
174   uint32_t ri_freq;
175   uint32_t ri_rate;
176   uint32_t ri_antenna;
177 };
178
179 /**
180  * Radiotap Header
181  */
182 struct RadiotapHeader
183 {
184   /**
185    * radiotap version
186    */
187   u_int8_t version;
188
189   u_int8_t pad_version;
190
191   /**
192    * radiotap header length
193    */
194   uint16_t length GNUNET_PACKED;
195
196   /**
197    * bitmap, fields present
198    */
199   uint32_t bitmap GNUNET_PACKED;
200
201   /**
202    * timestamp
203    */
204   uint64_t timestamp GNUNET_PACKED;
205
206   /**
207    * radiotap flags
208    */
209   uint8_t flags;
210
211   /**
212    * wlan send rate
213    */
214   uint8_t rate;
215
216   // FIXME: unaligned here, is this OK?
217   /**
218    * Wlan channel
219    */
220   uint32_t channel GNUNET_PACKED;
221
222   /**
223    * antsignal
224    */
225   uint8_t antsignal;
226
227   /**
228    * antnoise
229    */
230   uint8_t antnoise;
231
232   /**
233    * antenna
234    */
235   uint8_t antenna;
236 };
237
238 #endif