blob: 8c10357bedf0f51dda4212964c8959a33c91c59e [file] [log] [blame]
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -07001/* p80211conv.h
2*
3* Ether/802.11 conversions and packet buffer routines
4*
5* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6* --------------------------------------------------------------------
7*
8* linux-wlan
9*
10* The contents of this file are subject to the Mozilla Public
11* License Version 1.1 (the "License"); you may not use this file
12* except in compliance with the License. You may obtain a copy of
13* the License at http://www.mozilla.org/MPL/
14*
15* Software distributed under the License is distributed on an "AS
16* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17* implied. See the License for the specific language governing
18* rights and limitations under the License.
19*
20* Alternatively, the contents of this file may be used under the
21* terms of the GNU Public License version 2 (the "GPL"), in which
22* case the provisions of the GPL are applicable instead of the
23* above. If you wish to allow the use of your version of this file
24* only under the terms of the GPL and not to allow others to use
25* your version of this file under the MPL, indicate your decision
26* by deleting the provisions above and replace them with the notice
27* and other provisions required by the GPL. If you do not delete
28* the provisions above, a recipient may use your version of this
29* file under either the MPL or the GPL.
30*
31* --------------------------------------------------------------------
32*
33* Inquiries regarding the linux-wlan Open Source project can be
34* made directly to:
35*
36* AbsoluteValue Systems Inc.
37* info@linux-wlan.com
38* http://www.linux-wlan.com
39*
40* --------------------------------------------------------------------
41*
42* Portions of the development of this software were funded by
43* Intersil Corporation as part of PRISM(R) chipset product development.
44*
45* --------------------------------------------------------------------
46*
47* This file declares the functions, types and macros that perform
48* Ethernet to/from 802.11 frame conversions.
49*
50* --------------------------------------------------------------------
51*/
52
53#ifndef _LINUX_P80211CONV_H
54#define _LINUX_P80211CONV_H
55
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070056#define WLAN_IEEE_OUI_LEN 3
57
58#define WLAN_ETHCONV_ENCAP 1
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070059#define WLAN_ETHCONV_8021h 3
60
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070061#define P80211CAPTURE_VERSION 0x80211001
62
Edgardo Hames51e48962010-07-31 13:06:52 -030063#define P80211_FRMMETA_MAGIC 0x802110
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070064
65#define P80211SKB_FRMMETA(s) \
Johan Meiring869c4b42010-11-06 15:59:50 +020066 (((((struct p80211_frmmeta *)((s)->cb))->magic) == \
67 P80211_FRMMETA_MAGIC) ? \
Edgardo Hames51e48962010-07-31 13:06:52 -030068 ((struct p80211_frmmeta *)((s)->cb)) : \
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070069 (NULL))
70
71#define P80211SKB_RXMETA(s) \
Johan Meiring869c4b42010-11-06 15:59:50 +020072 (P80211SKB_FRMMETA((s)) ? P80211SKB_FRMMETA((s))->rx : \
73 ((struct p80211_rxmeta *)(NULL)))
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070074
Edgardo Hames51e48962010-07-31 13:06:52 -030075struct p80211_rxmeta {
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +010076 struct wlandevice *wlandev;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070077
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +010078 u64 mactime; /* Hi-rez MAC-supplied time value */
79 u64 hosttime; /* Best-rez host supplied time value */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070080
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +010081 unsigned int rxrate; /* Receive data rate in 100kbps */
82 unsigned int priority; /* 0-15, 0=contention, 6=CF */
83 int signal; /* An SSI, see p80211netdev.h */
84 int noise; /* An SSI, see p80211netdev.h */
85 unsigned int channel; /* Receive channel (mostly for snifs) */
86 unsigned int preamble; /* P80211ENUM_preambletype_* */
87 unsigned int encoding; /* P80211ENUM_encoding_* */
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070088
Edgardo Hames51e48962010-07-31 13:06:52 -030089};
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070090
Edgardo Hames51e48962010-07-31 13:06:52 -030091struct p80211_frmmeta {
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +010092 unsigned int magic;
Edgardo Hames51e48962010-07-31 13:06:52 -030093 struct p80211_rxmeta *rx;
94};
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -070095
96void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb);
97int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb);
98void p80211skb_rxmeta_detach(struct sk_buff *skb);
99
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700100/*
101 * Frame capture header. (See doc/capturefrm.txt)
102 */
Edgardo Hames51e48962010-07-31 13:06:52 -0300103struct p80211_caphdr {
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +0100104 u32 version;
105 u32 length;
106 u64 mactime;
107 u64 hosttime;
108 u32 phytype;
109 u32 channel;
110 u32 datarate;
111 u32 antenna;
112 u32 priority;
113 u32 ssi_type;
114 s32 ssi_signal;
115 s32 ssi_noise;
116 u32 preamble;
117 u32 encoding;
Edgardo Hames51e48962010-07-31 13:06:52 -0300118};
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700119
120/* buffer free method pointer type */
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +0100121typedef void (*freebuf_method_t) (void *buf, int size);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700122
Edgardo Hames51e48962010-07-31 13:06:52 -0300123struct p80211_metawep {
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +0100124 void *data;
Solomon Peachyaaad4302008-10-29 10:42:53 -0400125 u8 iv[4];
126 u8 icv[4];
Edgardo Hames51e48962010-07-31 13:06:52 -0300127};
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700128
129/* local ether header type */
Edgardo Hames51e48962010-07-31 13:06:52 -0300130struct wlan_ethhdr {
Anish Bhatt242850f2015-09-04 14:00:30 -0700131 u8 daddr[ETH_ALEN];
132 u8 saddr[ETH_ALEN];
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +0100133 u16 type;
Bas van den Berg7d3864d2011-02-03 21:37:16 +0100134} __packed;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700135
136/* local llc header type */
Edgardo Hames51e48962010-07-31 13:06:52 -0300137struct wlan_llc {
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +0100138 u8 dsap;
139 u8 ssap;
140 u8 ctl;
Bas van den Berg7d3864d2011-02-03 21:37:16 +0100141} __packed;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700142
143/* local snap header type */
Edgardo Hames51e48962010-07-31 13:06:52 -0300144struct wlan_snap {
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +0100145 u8 oui[WLAN_IEEE_OUI_LEN];
146 u16 type;
Bas van den Berg7d3864d2011-02-03 21:37:16 +0100147} __packed;
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700148
149/* Circular include trick */
150struct wlandevice;
151
Moritz Muehlenhoffc979aec2009-02-08 02:20:55 +0100152int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv,
153 struct sk_buff *skb);
154int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv,
Edgardo Hames93df38e2010-07-30 22:51:55 -0300155 struct sk_buff *skb, union p80211_hdr *p80211_hdr,
Edgardo Hames51e48962010-07-31 13:06:52 -0300156 struct p80211_metawep *p80211_wep);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700157
Solomon Peachyaaad4302008-10-29 10:42:53 -0400158int p80211_stt_findproto(u16 proto);
Greg Kroah-Hartman00b3ed12008-10-02 11:29:28 -0700159
160#endif