doxygen
[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 "gnunet_common.h"
31
32 typedef unsigned int uint32_t;
33 typedef unsigned short uint16_t;
34
35
36 struct MacAddress
37 {
38   char mac[6];
39 };
40
41 struct Wlan_Helper_Control_Message
42 {
43   struct GNUNET_MessageHeader hdr;
44   struct MacAddress mac ;
45 };
46
47
48
49 /* Wlan IEEE80211 header default */
50 //Informations (in German) http://www.umtslink.at/content/WLAN_macheader-196.html
51 static const uint8_t u8aIeeeHeader[] = 
52   {
53     0x08, 0x01, // Frame Control 0x08= 00001000 -> | b1,2 = 0 -> Version 0;
54                 //      b3,4 = 10 -> Data; b5-8 = 0 -> Normal Data
55                 //      0x01 = 00000001 -> | b1 = 1 to DS; b2 = 0 not from DS;
56     0x00, 0x00, // Duration/ID
57     0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // mac1 - in this case receiver
58     0x13, 0x22, 0x33, 0x44, 0x55, 0x66, // mac2 - in this case bssid
59     0x13, 0x22, 0x33, 0x44, 0x55, 0x66, // mac3 - in this case sender
60     0x10, 0x86, //Sequence Control
61   };
62
63 // gnunet bssid
64 static const char macbc[] =
65   { 0x13, 0x22, 0x33, 0x44, 0x55, 0x66 };
66
67 // broadcast mac
68 static const char bc_all_mac[] =
69    { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
70
71 /**
72  * Wlan header
73  */
74
75 struct IeeeHeader
76 {
77   /**
78    * Wlan flags
79    */
80   uint16_t frame_control GNUNET_PACKED;
81
82   /**
83    * Duration / ID
84    */
85
86   uint16_t duration_id GNUNET_PACKED;
87   
88   /**
89    * first mac byte 1
90    */
91   struct MacAddress mac1;
92
93   
94   /**
95    * second mac
96    */
97   struct MacAddress mac2;
98   
99   /**
100    * third mac
101    */
102   struct MacAddress mac3;
103   
104   /**
105    * Wlan Sequence Control
106    */
107   uint16_t sequence_control GNUNET_PACKED;
108 };
109
110 /* this is the template radiotap header we send packets out with */
111
112 static const uint8_t u8aRadiotapHeader[] = 
113   {
114     0x00, 0x00, // <-- radiotap version
115     0x19, 0x00, // <- radiotap header length
116     0x6f, 0x08, 0x00, 0x00, // <-- bitmap
117     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // <-- timestamp
118     0x00, // <-- flags (Offset +0x10)
119     0x6c, // <-- rate (0ffset +0x11)
120     0x71, 0x09, 0xc0, 0x00, // <-- channel
121     0xde, // <-- antsignal
122     0x00, // <-- antnoise
123     0x01, // <-- antenna
124 };
125
126 /**
127  * Radiotap Header
128  */
129 struct RadiotapHeader
130 {
131   /**
132    * radiotap version
133    */
134   uint16_t version GNUNET_PACKED;
135   
136   /**
137    * radiotap header length
138    */
139   uint16_t length GNUNET_PACKED;
140   
141   /**
142    * bitmap
143    */
144   uint32_t bitmap GNUNET_PACKED;
145   
146   /**
147    * timestamp
148    */
149   uint64_t timestamp GNUNET_PACKED;
150   
151   /**
152    * radiotap flags
153    */
154   uint8_t flags;
155   
156   /**
157    * wlan send rate
158    */
159   uint8_t rate;
160   
161   // FIXME: unaligned here, is this OK?
162   /**
163    * Wlan channel
164    */
165   uint32_t channel GNUNET_PACKED;
166   
167   /**
168    * antsignal
169    */
170   uint8_t antsignal;
171   
172   /**
173    * antnoise
174    */
175   uint8_t antnoise;
176   
177   /**
178    * antenna
179    */
180   uint8_t antenna;
181 };
182
183 #endif