Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 1 | /* 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 | |
| 56 | /*================================================================*/ |
| 57 | /* Constants */ |
| 58 | |
| 59 | #define WLAN_ETHADDR_LEN 6 |
| 60 | #define WLAN_IEEE_OUI_LEN 3 |
| 61 | |
| 62 | #define WLAN_ETHCONV_ENCAP 1 |
| 63 | #define WLAN_ETHCONV_RFC1042 2 |
| 64 | #define WLAN_ETHCONV_8021h 3 |
| 65 | |
| 66 | #define WLAN_MIN_ETHFRM_LEN 60 |
| 67 | #define WLAN_MAX_ETHFRM_LEN 1514 |
| 68 | #define WLAN_ETHHDR_LEN 14 |
| 69 | |
| 70 | #define P80211CAPTURE_VERSION 0x80211001 |
| 71 | |
| 72 | /*================================================================*/ |
| 73 | /* Macros */ |
| 74 | |
| 75 | #define P80211_FRMMETA_MAGIC 0x802110 |
| 76 | |
| 77 | #define P80211SKB_FRMMETA(s) \ |
| 78 | (((((p80211_frmmeta_t*)((s)->cb))->magic)==P80211_FRMMETA_MAGIC) ? \ |
| 79 | ((p80211_frmmeta_t*)((s)->cb)) : \ |
| 80 | (NULL)) |
| 81 | |
| 82 | #define P80211SKB_RXMETA(s) \ |
| 83 | (P80211SKB_FRMMETA((s)) ? P80211SKB_FRMMETA((s))->rx : ((p80211_rxmeta_t*)(NULL))) |
| 84 | |
| 85 | typedef struct p80211_rxmeta |
| 86 | { |
| 87 | struct wlandevice *wlandev; |
| 88 | |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 89 | u64 mactime; /* Hi-rez MAC-supplied time value */ |
| 90 | u64 hosttime; /* Best-rez host supplied time value */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 91 | |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 92 | unsigned int rxrate; /* Receive data rate in 100kbps */ |
| 93 | unsigned int priority; /* 0-15, 0=contention, 6=CF */ |
| 94 | int signal; /* An SSI, see p80211netdev.h */ |
| 95 | int noise; /* An SSI, see p80211netdev.h */ |
| 96 | unsigned int channel; /* Receive channel (mostly for snifs) */ |
| 97 | unsigned int preamble; /* P80211ENUM_preambletype_* */ |
| 98 | unsigned int encoding; /* P80211ENUM_encoding_* */ |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 99 | |
| 100 | } p80211_rxmeta_t; |
| 101 | |
| 102 | typedef struct p80211_frmmeta |
| 103 | { |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 104 | unsigned int magic; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 105 | p80211_rxmeta_t *rx; |
| 106 | } p80211_frmmeta_t; |
| 107 | |
| 108 | void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb); |
| 109 | int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb); |
| 110 | void p80211skb_rxmeta_detach(struct sk_buff *skb); |
| 111 | |
| 112 | /*================================================================*/ |
| 113 | /* Types */ |
| 114 | |
| 115 | /* |
| 116 | * Frame capture header. (See doc/capturefrm.txt) |
| 117 | */ |
| 118 | typedef struct p80211_caphdr |
| 119 | { |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 120 | u32 version; |
| 121 | u32 length; |
| 122 | u64 mactime; |
| 123 | u64 hosttime; |
| 124 | u32 phytype; |
| 125 | u32 channel; |
| 126 | u32 datarate; |
| 127 | u32 antenna; |
| 128 | u32 priority; |
| 129 | u32 ssi_type; |
| 130 | s32 ssi_signal; |
| 131 | s32 ssi_noise; |
| 132 | u32 preamble; |
| 133 | u32 encoding; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 134 | } p80211_caphdr_t; |
| 135 | |
| 136 | /* buffer free method pointer type */ |
| 137 | typedef void (* freebuf_method_t)(void *buf, int size); |
| 138 | |
| 139 | typedef struct p80211_metawep { |
| 140 | void *data; |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 141 | u8 iv[4]; |
| 142 | u8 icv[4]; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 143 | } p80211_metawep_t; |
| 144 | |
| 145 | /* local ether header type */ |
| 146 | typedef struct wlan_ethhdr |
| 147 | { |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 148 | u8 daddr[WLAN_ETHADDR_LEN]; |
| 149 | u8 saddr[WLAN_ETHADDR_LEN]; |
| 150 | u16 type; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 151 | } __WLAN_ATTRIB_PACK__ wlan_ethhdr_t; |
| 152 | |
| 153 | /* local llc header type */ |
| 154 | typedef struct wlan_llc |
| 155 | { |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 156 | u8 dsap; |
| 157 | u8 ssap; |
| 158 | u8 ctl; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 159 | } __WLAN_ATTRIB_PACK__ wlan_llc_t; |
| 160 | |
| 161 | /* local snap header type */ |
| 162 | typedef struct wlan_snap |
| 163 | { |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 164 | u8 oui[WLAN_IEEE_OUI_LEN]; |
| 165 | u16 type; |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 166 | } __WLAN_ATTRIB_PACK__ wlan_snap_t; |
| 167 | |
| 168 | /* Circular include trick */ |
| 169 | struct wlandevice; |
| 170 | |
| 171 | /*================================================================*/ |
| 172 | /* Externs */ |
| 173 | |
| 174 | /*================================================================*/ |
| 175 | /*Function Declarations */ |
| 176 | |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 177 | int skb_p80211_to_ether( struct wlandevice *wlandev, u32 ethconv, |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 178 | struct sk_buff *skb); |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 179 | int skb_ether_to_p80211( struct wlandevice *wlandev, u32 ethconv, |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 180 | struct sk_buff *skb, p80211_hdr_t *p80211_hdr, |
| 181 | p80211_metawep_t *p80211_wep ); |
| 182 | |
Solomon Peachy | aaad430 | 2008-10-29 10:42:53 -0400 | [diff] [blame] | 183 | int p80211_stt_findproto(u16 proto); |
| 184 | int p80211_stt_addproto(u16 proto); |
Greg Kroah-Hartman | 00b3ed1 | 2008-10-02 11:29:28 -0700 | [diff] [blame] | 185 | |
| 186 | #endif |