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