1/* SPDX-License-Identifier: (GPL-2.0 OR MPL-1.1) */ 2/* 3 * 4 * Ether/802.11 conversions and packet buffer routines 5 * 6 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved. 7 * -------------------------------------------------------------------- 8 * 9 * linux-wlan 10 * 11 * -------------------------------------------------------------------- 12 * 13 * Inquiries regarding the linux-wlan Open Source project can be 14 * made directly to: 15 * 16 * AbsoluteValue Systems Inc. 17 * info@linux-wlan.com 18 * http://www.linux-wlan.com 19 * 20 * -------------------------------------------------------------------- 21 * 22 * Portions of the development of this software were funded by 23 * Intersil Corporation as part of PRISM(R) chipset product development. 24 * 25 * -------------------------------------------------------------------- 26 * 27 * This file declares the functions, types and macros that perform 28 * Ethernet to/from 802.11 frame conversions. 29 * 30 * -------------------------------------------------------------------- 31 */ 32 33#ifndef _LINUX_P80211CONV_H 34#define _LINUX_P80211CONV_H 35 36#define WLAN_IEEE_OUI_LEN 3 37 38#define WLAN_ETHCONV_ENCAP 1 39#define WLAN_ETHCONV_8021h 3 40 41#define P80211CAPTURE_VERSION 0x80211001 42 43#define P80211_FRMMETA_MAGIC 0x802110 44 45struct p80211_rxmeta { 46 struct wlandevice *wlandev; 47 48 u64 mactime; /* Hi-rez MAC-supplied time value */ 49 u64 hosttime; /* Best-rez host supplied time value */ 50 51 unsigned int rxrate; /* Receive data rate in 100kbps */ 52 unsigned int priority; /* 0-15, 0=contention, 6=CF */ 53 int signal; /* An SSI, see p80211netdev.h */ 54 int noise; /* An SSI, see p80211netdev.h */ 55 unsigned int channel; /* Receive channel (mostly for snifs) */ 56 unsigned int preamble; /* P80211ENUM_preambletype_* */ 57 unsigned int encoding; /* P80211ENUM_encoding_* */ 58 59}; 60 61struct p80211_frmmeta { 62 unsigned int magic; 63 struct p80211_rxmeta *rx; 64}; 65 66void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb); 67int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb); 68void p80211skb_rxmeta_detach(struct sk_buff *skb); 69 70static inline struct p80211_frmmeta *p80211skb_frmmeta(struct sk_buff *skb) 71{ 72 struct p80211_frmmeta *frmmeta = (struct p80211_frmmeta *)skb->cb; 73 74 return frmmeta->magic == P80211_FRMMETA_MAGIC ? frmmeta : NULL; 75} 76 77static inline struct p80211_rxmeta *p80211skb_rxmeta(struct sk_buff *skb) 78{ 79 struct p80211_frmmeta *frmmeta = p80211skb_frmmeta(skb); 80 81 return frmmeta ? frmmeta->rx : NULL; 82} 83 84/* 85 * Frame capture header. (See doc/capturefrm.txt) 86 */ 87struct p80211_caphdr { 88 __be32 version; 89 __be32 length; 90 __be64 mactime; 91 __be64 hosttime; 92 __be32 phytype; 93 __be32 channel; 94 __be32 datarate; 95 __be32 antenna; 96 __be32 priority; 97 __be32 ssi_type; 98 __be32 ssi_signal; 99 __be32 ssi_noise; 100 __be32 preamble; 101 __be32 encoding; 102}; 103 104struct p80211_metawep { 105 void *data; 106 u8 iv[4]; 107 u8 icv[4]; 108}; 109 110/* local ether header type */ 111struct wlan_ethhdr { 112 u8 daddr[ETH_ALEN]; 113 u8 saddr[ETH_ALEN]; 114 __be16 type; 115} __packed; 116 117/* local llc header type */ 118struct wlan_llc { 119 u8 dsap; 120 u8 ssap; 121 u8 ctl; 122} __packed; 123 124/* local snap header type */ 125struct wlan_snap { 126 u8 oui[WLAN_IEEE_OUI_LEN]; 127 __be16 type; 128} __packed; 129 130/* Circular include trick */ 131struct wlandevice; 132 133int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv, 134 struct sk_buff *skb); 135int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv, 136 struct sk_buff *skb, struct p80211_hdr *p80211_hdr, 137 struct p80211_metawep *p80211_wep); 138 139int p80211_stt_findproto(u16 proto); 140 141#endif 142