// SPDX-License-Identifier: GPL-2.0 /* * Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved. * * Contact Information: * James P. Ketrenos <[email protected]> * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 * * Few modifications for Realtek's Wi-Fi drivers by * Andrea Merello <[email protected]> * * A special thanks goes to Realtek for their support ! */ #include <linux/compiler.h> #include <linux/errno.h> #include <linux/if_arp.h> #include <linux/in6.h> #include <linux/in.h> #include <linux/ip.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/netdevice.h> #include <linux/pci.h> #include <linux/proc_fs.h> #include <linux/skbuff.h> #include <linux/slab.h> #include <linux/tcp.h> #include <linux/types.h> #include <linux/wireless.h> #include <linux/etherdevice.h> #include <linux/uaccess.h> #include <linux/if_vlan.h> #include "rtllib.h" /* 802.11 Data Frame * * * 802.11 frame_control for data frames - 2 bytes * ,--------------------------------------------------------------------. * bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | * |---|---|---|---|---|---|---|---|---|----|----|-----|-----|-----|----| * val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x | * |---|---|---|---|---|---|---|---|---|----|----|-----|-----|-----|----| * desc | ver | type | ^-subtype-^ |to |from|more|retry| pwr |more |wep | * | | | x=0 data |DS | DS |frag| | mgm |data | | * | | | x=1 data+ack | | | | | | | | * '--------------------------------------------------------------------' * /\ * | * 802.11 Data Frame | * ,--------- 'ctrl' expands to >---' * | * ,--'---,-------------------------------------------------------------. * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | * |------|------|---------|---------|---------|------|---------|------| * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs | * | | tion | (BSSID) | | | ence | data | | * `--------------------------------------------------| |------' * Total: 28 non-data bytes `----.----' * | * .- 'Frame data' expands to <---------------------------' * | * V * ,---------------------------------------------------. * Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 | * |------|------|---------|----------|------|---------| * Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP | * | DSAP | SSAP | | | | Packet | * | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | * `-----------------------------------------| | * Total: 8 non-data bytes `----.----' * | * .- 'IP Packet' expands, if WEP enabled, to <--' * | * V * ,-----------------------. * Bytes | 4 | 0-2296 | 4 | * |-----|-----------|-----| * Desc. | IV | Encrypted | ICV | * | | IP Packet | | * `-----------------------' * Total: 8 non-data bytes * * * 802.3 Ethernet Data Frame * * ,-----------------------------------------. * Bytes | 6 | 6 | 2 | Variable | 4 | * |-------|-------|------|-----------|------| * Desc. | Dest. | Source| Type | IP Packet | fcs | * | MAC | MAC | | | | * `-----------------------------------------' * Total: 18 non-data bytes * * In the event that fragmentation is required, the incoming payload is split * into N parts of size ieee->fts. The first fragment contains the SNAP header * and the remaining packets are just data. * * If encryption is enabled, each fragment payload size is reduced by enough * space to add the prefix and postfix (IV and ICV totalling 8 bytes in * the case of WEP) So if you have 1500 bytes of payload with ieee->fts set to * 500 without encryption it will take 3 frames. With WEP it will take 4 frames * as the payload of each frame is reduced to 492 bytes. * * SKB visualization * * ,- skb->data * | * | ETHERNET HEADER ,-<-- PAYLOAD * | | 14 bytes from skb->data * | 2 bytes for Type --> ,T. | (sizeof ethhdr) * | | | | * |,-Dest.--. ,--Src.---. | | | * | 6 bytes| | 6 bytes | | | | * v | | | | | | * 0 | v 1 | v | v 2 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 * ^ | ^ | ^ | * | | | | | | * | | | | `T' <---- 2 bytes for Type * | | | | * | | '---SNAP--' <-------- 6 bytes for SNAP * | | * `-IV--' <-------------------- 4 bytes for IV (WEP) * * SNAP HEADER * */ static u8 P802_1H_OUI[P80211_OUI_LEN] = …; static u8 RFC1042_OUI[P80211_OUI_LEN] = …; static int rtllib_put_snap(u8 *data, u16 h_proto) { … } int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag, int hdr_len) { … } void rtllib_txb_free(struct rtllib_txb *txb) { … } static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, gfp_t gfp_mask) { … } static int rtllib_classify(struct sk_buff *skb) { … } static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, struct sk_buff *skb, struct cb_desc *tcb_desc) { … } static void rtllib_query_short_preamble_mode(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { … } static void rtllib_query_ht_cap_short_gi(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { … } static void rtllib_query_bandwidth_mode(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { … } static void rtllib_query_protectionmode(struct rtllib_device *ieee, struct cb_desc *tcb_desc, struct sk_buff *skb) { … } static void rtllib_txrate_selectmode(struct rtllib_device *ieee, struct cb_desc *tcb_desc) { … } static u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb, u8 *dst) { … } static int wme_downgrade_ac(struct sk_buff *skb) { … } static u8 rtllib_current_rate(struct rtllib_device *ieee) { … } static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) { … } netdev_tx_t rtllib_xmit(struct sk_buff *skb, struct net_device *dev) { … } EXPORT_SYMBOL(…);