diff options
Diffstat (limited to 'include/compat/net')
-rwxr-xr-x | include/compat/net/bluetooth/bluetooth.h | 276 | ||||
-rwxr-xr-x | include/compat/net/bluetooth/hci.h | 1334 | ||||
-rwxr-xr-x | include/compat/net/bluetooth/hci_core.h | 988 | ||||
-rwxr-xr-x | include/compat/net/bluetooth/l2cap.h | 814 | ||||
-rwxr-xr-x | include/compat/net/bluetooth/mgmt.h | 324 | ||||
-rwxr-xr-x | include/compat/net/bluetooth/rfcomm.h | 372 | ||||
-rwxr-xr-x | include/compat/net/bluetooth/smp.h | 140 | ||||
-rwxr-xr-x | include/compat/net/cfg80211-wext.h | 55 | ||||
-rwxr-xr-x | include/compat/net/cfg80211.h | 3417 | ||||
-rwxr-xr-x | include/compat/net/ieee80211_radiotap.h | 283 | ||||
-rwxr-xr-x | include/compat/net/lib80211.h | 124 | ||||
-rwxr-xr-x | include/compat/net/mac80211.h | 3686 | ||||
-rwxr-xr-x | include/compat/net/net_namespace.h | 10 | ||||
-rwxr-xr-x | include/compat/net/regulatory.h | 116 |
14 files changed, 0 insertions, 11939 deletions
diff --git a/include/compat/net/bluetooth/bluetooth.h b/include/compat/net/bluetooth/bluetooth.h deleted file mode 100755 index f045a32..0000000 --- a/include/compat/net/bluetooth/bluetooth.h +++ /dev/null @@ -1,276 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - Copyright (C) 2000-2001 Qualcomm Incorporated - - Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#ifndef __BLUETOOTH_H -#define __BLUETOOTH_H - -#include <asm/types.h> -#include <asm/byteorder.h> -#include <linux/list.h> -#include <linux/poll.h> -#include <net/sock.h> - -#ifndef AF_BLUETOOTH -#define AF_BLUETOOTH 31 -#define PF_BLUETOOTH AF_BLUETOOTH -#endif - -/* Reserv for core and drivers use */ -#define BT_SKB_RESERVE 8 - -#define BTPROTO_L2CAP 0 -#define BTPROTO_HCI 1 -#define BTPROTO_SCO 2 -#define BTPROTO_RFCOMM 3 -#define BTPROTO_BNEP 4 -#define BTPROTO_CMTP 5 -#define BTPROTO_HIDP 6 -#define BTPROTO_AVDTP 7 - -#define SOL_HCI 0 -#define SOL_L2CAP 6 -#define SOL_SCO 17 -#define SOL_RFCOMM 18 - -#define BT_SECURITY 4 -struct bt_security { - __u8 level; - __u8 key_size; -}; -#define BT_SECURITY_SDP 0 -#define BT_SECURITY_LOW 1 -#define BT_SECURITY_MEDIUM 2 -#define BT_SECURITY_HIGH 3 - -#define BT_DEFER_SETUP 7 - -#define BT_FLUSHABLE 8 - -#define BT_FLUSHABLE_OFF 0 -#define BT_FLUSHABLE_ON 1 - -#define BT_POWER 9 -struct bt_power { - __u8 force_active; -}; -#define BT_POWER_FORCE_ACTIVE_OFF 0 -#define BT_POWER_FORCE_ACTIVE_ON 1 - -#define BT_CHANNEL_POLICY 10 - -/* BR/EDR only (default policy) - * AMP controllers cannot be used. - * Channel move requests from the remote device are denied. - * If the L2CAP channel is currently using AMP, move the channel to BR/EDR. - */ -#define BT_CHANNEL_POLICY_BREDR_ONLY 0 - -/* BR/EDR Preferred - * Allow use of AMP controllers. - * If the L2CAP channel is currently on AMP, move it to BR/EDR. - * Channel move requests from the remote device are allowed. - */ -#define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 - -/* AMP Preferred - * Allow use of AMP controllers - * If the L2CAP channel is currently on BR/EDR and AMP controller - * resources are available, initiate a channel move to AMP. - * Channel move requests from the remote device are allowed. - * If the L2CAP socket has not been connected yet, try to create - * and configure the channel directly on an AMP controller rather - * than BR/EDR. - */ -#define BT_CHANNEL_POLICY_AMP_PREFERRED 2 - -__printf(2, 3) -int bt_printk(const char *level, const char *fmt, ...); - -#define BT_INFO(fmt, arg...) bt_printk(KERN_INFO, pr_fmt(fmt), ##arg) -#define BT_ERR(fmt, arg...) bt_printk(KERN_ERR, pr_fmt(fmt), ##arg) -#define BT_DBG(fmt, arg...) pr_debug(fmt "\n", ##arg) - -/* Connection and socket states */ -enum { - BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ - BT_OPEN, - BT_BOUND, - BT_LISTEN, - BT_CONNECT, - BT_CONNECT2, - BT_CONFIG, - BT_DISCONN, - BT_CLOSED -}; - -/* BD Address */ -typedef struct { - __u8 b[6]; -} __packed bdaddr_t; - -#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) -#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) - -/* Copy, swap, convert BD Address */ -static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) -{ - return memcmp(ba1, ba2, sizeof(bdaddr_t)); -} -static inline void bacpy(bdaddr_t *dst, bdaddr_t *src) -{ - memcpy(dst, src, sizeof(bdaddr_t)); -} - -void baswap(bdaddr_t *dst, bdaddr_t *src); -char *batostr(bdaddr_t *ba); -bdaddr_t *strtoba(char *str); - -/* Common socket structures and functions */ - -#define bt_sk(__sk) ((struct bt_sock *) __sk) - -struct bt_sock { - struct sock sk; - bdaddr_t src; - bdaddr_t dst; - struct list_head accept_q; - struct sock *parent; - u32 defer_setup; -}; - -struct bt_sock_list { - struct hlist_head head; - rwlock_t lock; -}; - -int bt_sock_register(int proto, const struct net_proto_family *ops); -int bt_sock_unregister(int proto); -void bt_sock_link(struct bt_sock_list *l, struct sock *s); -void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); -int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len, int flags); -int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, - struct msghdr *msg, size_t len, int flags); -uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); -int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); -int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); - -void bt_accept_enqueue(struct sock *parent, struct sock *sk); -void bt_accept_unlink(struct sock *sk); -struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock); - -/* Skb helpers */ -struct bt_skb_cb { - __u8 pkt_type; - __u8 incoming; - __u16 expect; - __u16 tx_seq; - __u8 retries; - __u8 sar; - unsigned short channel; - __u8 force_active; -}; -#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) - -static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how) -{ - struct sk_buff *skb; - - if ((skb = alloc_skb(len + BT_SKB_RESERVE, how))) { - skb_reserve(skb, BT_SKB_RESERVE); - bt_cb(skb)->incoming = 0; - } - return skb; -} - -static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, - unsigned long len, int nb, int *err) -{ - struct sk_buff *skb; - - release_sock(sk); - if ((skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err))) { - skb_reserve(skb, BT_SKB_RESERVE); - bt_cb(skb)->incoming = 0; - } - lock_sock(sk); - - if (!skb && *err) - return NULL; - - *err = sock_error(sk); - if (*err) - goto out; - - if (sk->sk_shutdown) { - *err = -ECONNRESET; - goto out; - } - - return skb; - -out: - kfree_skb(skb); - return NULL; -} - -int bt_to_errno(__u16 code); - -extern int hci_sock_init(void); -extern void hci_sock_cleanup(void); - -extern int bt_sysfs_init(void); -extern void bt_sysfs_cleanup(void); - -extern struct dentry *bt_debugfs; - -#ifdef CONFIG_COMPAT_BT_L2CAP -int l2cap_init(void); -void l2cap_exit(void); -#else -static inline int l2cap_init(void) -{ - return 0; -} - -static inline void l2cap_exit(void) -{ -} -#endif - -#ifdef CONFIG_COMPAT_BT_SCO -int sco_init(void); -void sco_exit(void); -#else -static inline int sco_init(void) -{ - return 0; -} - -static inline void sco_exit(void) -{ -} -#endif - -#endif /* __BLUETOOTH_H */ diff --git a/include/compat/net/bluetooth/hci.h b/include/compat/net/bluetooth/hci.h deleted file mode 100755 index 139ce2a..0000000 --- a/include/compat/net/bluetooth/hci.h +++ /dev/null @@ -1,1334 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - Copyright (C) 2000-2001 Qualcomm Incorporated - - Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#ifndef __HCI_H -#define __HCI_H - -#define HCI_MAX_ACL_SIZE 1024 -#define HCI_MAX_SCO_SIZE 255 -#define HCI_MAX_EVENT_SIZE 260 -#define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) - -/* HCI dev events */ -#define HCI_DEV_REG 1 -#define HCI_DEV_UNREG 2 -#define HCI_DEV_UP 3 -#define HCI_DEV_DOWN 4 -#define HCI_DEV_SUSPEND 5 -#define HCI_DEV_RESUME 6 - -/* HCI notify events */ -#define HCI_NOTIFY_CONN_ADD 1 -#define HCI_NOTIFY_CONN_DEL 2 -#define HCI_NOTIFY_VOICE_SETTING 3 - -/* HCI bus types */ -#define HCI_VIRTUAL 0 -#define HCI_USB 1 -#define HCI_PCCARD 2 -#define HCI_UART 3 -#define HCI_RS232 4 -#define HCI_PCI 5 -#define HCI_SDIO 6 - -/* HCI controller types */ -#define HCI_BREDR 0x00 -#define HCI_AMP 0x01 - -/* HCI device quirks */ -enum { - HCI_QUIRK_NO_RESET, - HCI_QUIRK_RAW_DEVICE, - HCI_QUIRK_FIXUP_BUFFER_SIZE -}; - -/* HCI device flags */ -enum { - HCI_UP, - HCI_INIT, - HCI_RUNNING, - - HCI_PSCAN, - HCI_ISCAN, - HCI_AUTH, - HCI_ENCRYPT, - HCI_INQUIRY, - - HCI_RAW, - - HCI_SETUP, - HCI_AUTO_OFF, - HCI_MGMT, - HCI_PAIRABLE, - HCI_SERVICE_CACHE, - HCI_LINK_KEYS, - HCI_DEBUG_KEYS, - - HCI_RESET, -}; - -/* HCI ioctl defines */ -#define HCIDEVUP _IOW('H', 201, int) -#define HCIDEVDOWN _IOW('H', 202, int) -#define HCIDEVRESET _IOW('H', 203, int) -#define HCIDEVRESTAT _IOW('H', 204, int) - -#define HCIGETDEVLIST _IOR('H', 210, int) -#define HCIGETDEVINFO _IOR('H', 211, int) -#define HCIGETCONNLIST _IOR('H', 212, int) -#define HCIGETCONNINFO _IOR('H', 213, int) -#define HCIGETAUTHINFO _IOR('H', 215, int) - -#define HCISETRAW _IOW('H', 220, int) -#define HCISETSCAN _IOW('H', 221, int) -#define HCISETAUTH _IOW('H', 222, int) -#define HCISETENCRYPT _IOW('H', 223, int) -#define HCISETPTYPE _IOW('H', 224, int) -#define HCISETLINKPOL _IOW('H', 225, int) -#define HCISETLINKMODE _IOW('H', 226, int) -#define HCISETACLMTU _IOW('H', 227, int) -#define HCISETSCOMTU _IOW('H', 228, int) - -#define HCIBLOCKADDR _IOW('H', 230, int) -#define HCIUNBLOCKADDR _IOW('H', 231, int) - -#define HCIINQUIRY _IOR('H', 240, int) - -/* HCI timeouts */ -#define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ -#define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ -#define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ -#define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ -#define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ -#define HCI_CMD_TIMEOUT (1000) /* 1 seconds */ - -/* HCI data types */ -#define HCI_COMMAND_PKT 0x01 -#define HCI_ACLDATA_PKT 0x02 -#define HCI_SCODATA_PKT 0x03 -#define HCI_EVENT_PKT 0x04 -#define HCI_VENDOR_PKT 0xff - -/* HCI packet types */ -#define HCI_DM1 0x0008 -#define HCI_DM3 0x0400 -#define HCI_DM5 0x4000 -#define HCI_DH1 0x0010 -#define HCI_DH3 0x0800 -#define HCI_DH5 0x8000 - -#define HCI_HV1 0x0020 -#define HCI_HV2 0x0040 -#define HCI_HV3 0x0080 - -#define SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3) -#define ACL_PTYPE_MASK (~SCO_PTYPE_MASK) - -/* eSCO packet types */ -#define ESCO_HV1 0x0001 -#define ESCO_HV2 0x0002 -#define ESCO_HV3 0x0004 -#define ESCO_EV3 0x0008 -#define ESCO_EV4 0x0010 -#define ESCO_EV5 0x0020 -#define ESCO_2EV3 0x0040 -#define ESCO_3EV3 0x0080 -#define ESCO_2EV5 0x0100 -#define ESCO_3EV5 0x0200 - -#define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3) -#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) - -/* ACL flags */ -#define ACL_START_NO_FLUSH 0x00 -#define ACL_CONT 0x01 -#define ACL_START 0x02 -#define ACL_ACTIVE_BCAST 0x04 -#define ACL_PICO_BCAST 0x08 - -/* Baseband links */ -#define SCO_LINK 0x00 -#define ACL_LINK 0x01 -#define ESCO_LINK 0x02 -/* Low Energy links do not have defined link type. Use invented one */ -#define LE_LINK 0x80 - -/* LMP features */ -#define LMP_3SLOT 0x01 -#define LMP_5SLOT 0x02 -#define LMP_ENCRYPT 0x04 -#define LMP_SOFFSET 0x08 -#define LMP_TACCURACY 0x10 -#define LMP_RSWITCH 0x20 -#define LMP_HOLD 0x40 -#define LMP_SNIFF 0x80 - -#define LMP_PARK 0x01 -#define LMP_RSSI 0x02 -#define LMP_QUALITY 0x04 -#define LMP_SCO 0x08 -#define LMP_HV2 0x10 -#define LMP_HV3 0x20 -#define LMP_ULAW 0x40 -#define LMP_ALAW 0x80 - -#define LMP_CVSD 0x01 -#define LMP_PSCHEME 0x02 -#define LMP_PCONTROL 0x04 - -#define LMP_RSSI_INQ 0x40 -#define LMP_ESCO 0x80 - -#define LMP_EV4 0x01 -#define LMP_EV5 0x02 -#define LMP_LE 0x40 - -#define LMP_SNIFF_SUBR 0x02 -#define LMP_PAUSE_ENC 0x04 -#define LMP_EDR_ESCO_2M 0x20 -#define LMP_EDR_ESCO_3M 0x40 -#define LMP_EDR_3S_ESCO 0x80 - -#define LMP_EXT_INQ 0x01 -#define LMP_SIMUL_LE_BR 0x02 -#define LMP_SIMPLE_PAIR 0x08 -#define LMP_NO_FLUSH 0x40 - -#define LMP_LSTO 0x01 -#define LMP_INQ_TX_PWR 0x02 -#define LMP_EXTFEATURES 0x80 - -/* Extended LMP features */ -#define LMP_HOST_LE 0x02 - -/* Connection modes */ -#define HCI_CM_ACTIVE 0x0000 -#define HCI_CM_HOLD 0x0001 -#define HCI_CM_SNIFF 0x0002 -#define HCI_CM_PARK 0x0003 - -/* Link policies */ -#define HCI_LP_RSWITCH 0x0001 -#define HCI_LP_HOLD 0x0002 -#define HCI_LP_SNIFF 0x0004 -#define HCI_LP_PARK 0x0008 - -/* Link modes */ -#define HCI_LM_ACCEPT 0x8000 -#define HCI_LM_MASTER 0x0001 -#define HCI_LM_AUTH 0x0002 -#define HCI_LM_ENCRYPT 0x0004 -#define HCI_LM_TRUSTED 0x0008 -#define HCI_LM_RELIABLE 0x0010 -#define HCI_LM_SECURE 0x0020 - -/* Authentication types */ -#define HCI_AT_NO_BONDING 0x00 -#define HCI_AT_NO_BONDING_MITM 0x01 -#define HCI_AT_DEDICATED_BONDING 0x02 -#define HCI_AT_DEDICATED_BONDING_MITM 0x03 -#define HCI_AT_GENERAL_BONDING 0x04 -#define HCI_AT_GENERAL_BONDING_MITM 0x05 - -/* Link Key types */ -#define HCI_LK_COMBINATION 0x00 -#define HCI_LK_LOCAL_UNIT 0x01 -#define HCI_LK_REMOTE_UNIT 0x02 -#define HCI_LK_DEBUG_COMBINATION 0x03 -#define HCI_LK_UNAUTH_COMBINATION 0x04 -#define HCI_LK_AUTH_COMBINATION 0x05 -#define HCI_LK_CHANGED_COMBINATION 0x06 -/* The spec doesn't define types for SMP keys */ -#define HCI_LK_SMP_LTK 0x81 -#define HCI_LK_SMP_IRK 0x82 -#define HCI_LK_SMP_CSRK 0x83 - -/* ---- HCI Error Codes ---- */ -#define HCI_ERROR_AUTH_FAILURE 0x05 -#define HCI_ERROR_REJ_BAD_ADDR 0x0f -#define HCI_ERROR_REMOTE_USER_TERM 0x13 -#define HCI_ERROR_LOCAL_HOST_TERM 0x16 -#define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 - -/* ----- HCI Commands ---- */ -#define HCI_OP_NOP 0x0000 - -#define HCI_OP_INQUIRY 0x0401 -struct hci_cp_inquiry { - __u8 lap[3]; - __u8 length; - __u8 num_rsp; -} __packed; - -#define HCI_OP_INQUIRY_CANCEL 0x0402 - -#define HCI_OP_EXIT_PERIODIC_INQ 0x0404 - -#define HCI_OP_CREATE_CONN 0x0405 -struct hci_cp_create_conn { - bdaddr_t bdaddr; - __le16 pkt_type; - __u8 pscan_rep_mode; - __u8 pscan_mode; - __le16 clock_offset; - __u8 role_switch; -} __packed; - -#define HCI_OP_DISCONNECT 0x0406 -struct hci_cp_disconnect { - __le16 handle; - __u8 reason; -} __packed; - -#define HCI_OP_ADD_SCO 0x0407 -struct hci_cp_add_sco { - __le16 handle; - __le16 pkt_type; -} __packed; - -#define HCI_OP_CREATE_CONN_CANCEL 0x0408 -struct hci_cp_create_conn_cancel { - bdaddr_t bdaddr; -} __packed; - -#define HCI_OP_ACCEPT_CONN_REQ 0x0409 -struct hci_cp_accept_conn_req { - bdaddr_t bdaddr; - __u8 role; -} __packed; - -#define HCI_OP_REJECT_CONN_REQ 0x040a -struct hci_cp_reject_conn_req { - bdaddr_t bdaddr; - __u8 reason; -} __packed; - -#define HCI_OP_LINK_KEY_REPLY 0x040b -struct hci_cp_link_key_reply { - bdaddr_t bdaddr; - __u8 link_key[16]; -} __packed; - -#define HCI_OP_LINK_KEY_NEG_REPLY 0x040c -struct hci_cp_link_key_neg_reply { - bdaddr_t bdaddr; -} __packed; - -#define HCI_OP_PIN_CODE_REPLY 0x040d -struct hci_cp_pin_code_reply { - bdaddr_t bdaddr; - __u8 pin_len; - __u8 pin_code[16]; -} __packed; -struct hci_rp_pin_code_reply { - __u8 status; - bdaddr_t bdaddr; -} __packed; - -#define HCI_OP_PIN_CODE_NEG_REPLY 0x040e -struct hci_cp_pin_code_neg_reply { - bdaddr_t bdaddr; -} __packed; -struct hci_rp_pin_code_neg_reply { - __u8 status; - bdaddr_t bdaddr; -} __packed; - -#define HCI_OP_CHANGE_CONN_PTYPE 0x040f -struct hci_cp_change_conn_ptype { - __le16 handle; - __le16 pkt_type; -} __packed; - -#define HCI_OP_AUTH_REQUESTED 0x0411 -struct hci_cp_auth_requested { - __le16 handle; -} __packed; - -#define HCI_OP_SET_CONN_ENCRYPT 0x0413 -struct hci_cp_set_conn_encrypt { - __le16 handle; - __u8 encrypt; -} __packed; - -#define HCI_OP_CHANGE_CONN_LINK_KEY 0x0415 -struct hci_cp_change_conn_link_key { - __le16 handle; -} __packed; - -#define HCI_OP_REMOTE_NAME_REQ 0x0419 -struct hci_cp_remote_name_req { - bdaddr_t bdaddr; - __u8 pscan_rep_mode; - __u8 pscan_mode; - __le16 clock_offset; -} __packed; - -#define HCI_OP_REMOTE_NAME_REQ_CANCEL 0x041a -struct hci_cp_remote_name_req_cancel { - bdaddr_t bdaddr; -} __packed; - -#define HCI_OP_READ_REMOTE_FEATURES 0x041b -struct hci_cp_read_remote_features { - __le16 handle; -} __packed; - -#define HCI_OP_READ_REMOTE_EXT_FEATURES 0x041c -struct hci_cp_read_remote_ext_features { - __le16 handle; - __u8 page; -} __packed; - -#define HCI_OP_READ_REMOTE_VERSION 0x041d -struct hci_cp_read_remote_version { - __le16 handle; -} __packed; - -#define HCI_OP_SETUP_SYNC_CONN 0x0428 -struct hci_cp_setup_sync_conn { - __le16 handle; - __le32 tx_bandwidth; - __le32 rx_bandwidth; - __le16 max_latency; - __le16 voice_setting; - __u8 retrans_effort; - __le16 pkt_type; -} __packed; - -#define HCI_OP_ACCEPT_SYNC_CONN_REQ 0x0429 -struct hci_cp_accept_sync_conn_req { - bdaddr_t bdaddr; - __le32 tx_bandwidth; - __le32 rx_bandwidth; - __le16 max_latency; - __le16 content_format; - __u8 retrans_effort; - __le16 pkt_type; -} __packed; - -#define HCI_OP_REJECT_SYNC_CONN_REQ 0x042a -struct hci_cp_reject_sync_conn_req { - bdaddr_t bdaddr; - __u8 reason; -} __packed; - -#define HCI_OP_IO_CAPABILITY_REPLY 0x042b -struct hci_cp_io_capability_reply { - bdaddr_t bdaddr; - __u8 capability; - __u8 oob_data; - __u8 authentication; -} __packed; - -#define HCI_OP_USER_CONFIRM_REPLY 0x042c -struct hci_cp_user_confirm_reply { - bdaddr_t bdaddr; -} __packed; -struct hci_rp_user_confirm_reply { - __u8 status; - bdaddr_t bdaddr; -} __packed; - -#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d - -#define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430 -struct hci_cp_remote_oob_data_reply { - bdaddr_t bdaddr; - __u8 hash[16]; - __u8 randomizer[16]; -} __packed; - -#define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433 -struct hci_cp_remote_oob_data_neg_reply { - bdaddr_t bdaddr; -} __packed; - -#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434 -struct hci_cp_io_capability_neg_reply { - bdaddr_t bdaddr; - __u8 reason; -} __packed; - -#define HCI_OP_SNIFF_MODE 0x0803 -struct hci_cp_sniff_mode { - __le16 handle; - __le16 max_interval; - __le16 min_interval; - __le16 attempt; - __le16 timeout; -} __packed; - -#define HCI_OP_EXIT_SNIFF_MODE 0x0804 -struct hci_cp_exit_sniff_mode { - __le16 handle; -} __packed; - -#define HCI_OP_ROLE_DISCOVERY 0x0809 -struct hci_cp_role_discovery { - __le16 handle; -} __packed; -struct hci_rp_role_discovery { - __u8 status; - __le16 handle; - __u8 role; -} __packed; - -#define HCI_OP_SWITCH_ROLE 0x080b -struct hci_cp_switch_role { - bdaddr_t bdaddr; - __u8 role; -} __packed; - -#define HCI_OP_READ_LINK_POLICY 0x080c -struct hci_cp_read_link_policy { - __le16 handle; -} __packed; -struct hci_rp_read_link_policy { - __u8 status; - __le16 handle; - __le16 policy; -} __packed; - -#define HCI_OP_WRITE_LINK_POLICY 0x080d -struct hci_cp_write_link_policy { - __le16 handle; - __le16 policy; -} __packed; -struct hci_rp_write_link_policy { - __u8 status; - __le16 handle; -} __packed; - -#define HCI_OP_READ_DEF_LINK_POLICY 0x080e -struct hci_rp_read_def_link_policy { - __u8 status; - __le16 policy; -} __packed; - -#define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f -struct hci_cp_write_def_link_policy { - __le16 policy; -} __packed; - -#define HCI_OP_SNIFF_SUBRATE 0x0811 -struct hci_cp_sniff_subrate { - __le16 handle; - __le16 max_latency; - __le16 min_remote_timeout; - __le16 min_local_timeout; -} __packed; - -#define HCI_OP_SET_EVENT_MASK 0x0c01 -struct hci_cp_set_event_mask { - __u8 mask[8]; -} __packed; - -#define HCI_OP_RESET 0x0c03 - -#define HCI_OP_SET_EVENT_FLT 0x0c05 -struct hci_cp_set_event_flt { - __u8 flt_type; - __u8 cond_type; - __u8 condition[0]; -} __packed; - -/* Filter types */ -#define HCI_FLT_CLEAR_ALL 0x00 -#define HCI_FLT_INQ_RESULT 0x01 -#define HCI_FLT_CONN_SETUP 0x02 - -/* CONN_SETUP Condition types */ -#define HCI_CONN_SETUP_ALLOW_ALL 0x00 -#define HCI_CONN_SETUP_ALLOW_CLASS 0x01 -#define HCI_CONN_SETUP_ALLOW_BDADDR 0x02 - -/* CONN_SETUP Conditions */ -#define HCI_CONN_SETUP_AUTO_OFF 0x01 -#define HCI_CONN_SETUP_AUTO_ON 0x02 - -#define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12 -struct hci_cp_delete_stored_link_key { - bdaddr_t bdaddr; - __u8 delete_all; -} __packed; - -#define HCI_MAX_NAME_LENGTH 248 - -#define HCI_OP_WRITE_LOCAL_NAME 0x0c13 -struct hci_cp_write_local_name { - __u8 name[HCI_MAX_NAME_LENGTH]; -} __packed; - -#define HCI_OP_READ_LOCAL_NAME 0x0c14 -struct hci_rp_read_local_name { - __u8 status; - __u8 name[HCI_MAX_NAME_LENGTH]; -} __packed; - -#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16 - -#define HCI_OP_WRITE_PG_TIMEOUT 0x0c18 - -#define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a - #define SCAN_DISABLED 0x00 - #define SCAN_INQUIRY 0x01 - #define SCAN_PAGE 0x02 - -#define HCI_OP_READ_AUTH_ENABLE 0x0c1f - -#define HCI_OP_WRITE_AUTH_ENABLE 0x0c20 - #define AUTH_DISABLED 0x00 - #define AUTH_ENABLED 0x01 - -#define HCI_OP_READ_ENCRYPT_MODE 0x0c21 - -#define HCI_OP_WRITE_ENCRYPT_MODE 0x0c22 - #define ENCRYPT_DISABLED 0x00 - #define ENCRYPT_P2P 0x01 - #define ENCRYPT_BOTH 0x02 - -#define HCI_OP_READ_CLASS_OF_DEV 0x0c23 -struct hci_rp_read_class_of_dev { - __u8 status; - __u8 dev_class[3]; -} __packed; - -#define HCI_OP_WRITE_CLASS_OF_DEV 0x0c24 -struct hci_cp_write_class_of_dev { - __u8 dev_class[3]; -} __packed; - -#define HCI_OP_READ_VOICE_SETTING 0x0c25 -struct hci_rp_read_voice_setting { - __u8 status; - __le16 voice_setting; -} __packed; - -#define HCI_OP_WRITE_VOICE_SETTING 0x0c26 -struct hci_cp_write_voice_setting { - __le16 voice_setting; -} __packed; - -#define HCI_OP_HOST_BUFFER_SIZE 0x0c33 -struct hci_cp_host_buffer_size { - __le16 acl_mtu; - __u8 sco_mtu; - __le16 acl_max_pkt; - __le16 sco_max_pkt; -} __packed; - -#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45 - -#define HCI_MAX_EIR_LENGTH 240 - -#define HCI_OP_WRITE_EIR 0x0c52 -struct hci_cp_write_eir { - uint8_t fec; - uint8_t data[HCI_MAX_EIR_LENGTH]; -} __packed; - -#define HCI_OP_READ_SSP_MODE 0x0c55 -struct hci_rp_read_ssp_mode { - __u8 status; - __u8 mode; -} __packed; - -#define HCI_OP_WRITE_SSP_MODE 0x0c56 -struct hci_cp_write_ssp_mode { - __u8 mode; -} __packed; - -#define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57 -struct hci_rp_read_local_oob_data { - __u8 status; - __u8 hash[16]; - __u8 randomizer[16]; -} __packed; - -#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58 - -#define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d -struct hci_cp_write_le_host_supported { - __u8 le; - __u8 simul; -} __packed; - -#define HCI_OP_READ_LOCAL_VERSION 0x1001 -struct hci_rp_read_local_version { - __u8 status; - __u8 hci_ver; - __le16 hci_rev; - __u8 lmp_ver; - __le16 manufacturer; - __le16 lmp_subver; -} __packed; - -#define HCI_OP_READ_LOCAL_COMMANDS 0x1002 -struct hci_rp_read_local_commands { - __u8 status; - __u8 commands[64]; -} __packed; - -#define HCI_OP_READ_LOCAL_FEATURES 0x1003 -struct hci_rp_read_local_features { - __u8 status; - __u8 features[8]; -} __packed; - -#define HCI_OP_READ_LOCAL_EXT_FEATURES 0x1004 -struct hci_cp_read_local_ext_features { - __u8 page; -} __packed; -struct hci_rp_read_local_ext_features { - __u8 status; - __u8 page; - __u8 max_page; - __u8 features[8]; -} __packed; - -#define HCI_OP_READ_BUFFER_SIZE 0x1005 -struct hci_rp_read_buffer_size { - __u8 status; - __le16 acl_mtu; - __u8 sco_mtu; - __le16 acl_max_pkt; - __le16 sco_max_pkt; -} __packed; - -#define HCI_OP_READ_BD_ADDR 0x1009 -struct hci_rp_read_bd_addr { - __u8 status; - bdaddr_t bdaddr; -} __packed; - -#define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c -struct hci_cp_write_page_scan_activity { - __le16 interval; - __le16 window; -} __packed; - -#define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47 - #define PAGE_SCAN_TYPE_STANDARD 0x00 - #define PAGE_SCAN_TYPE_INTERLACED 0x01 - -#define HCI_OP_READ_LOCAL_AMP_INFO 0x1409 -struct hci_rp_read_local_amp_info { - __u8 status; - __u8 amp_status; - __le32 total_bw; - __le32 max_bw; - __le32 min_latency; - __le32 max_pdu; - __u8 amp_type; - __le16 pal_cap; - __le16 max_assoc_size; - __le32 max_flush_to; - __le32 be_flush_to; -} __packed; - -#define HCI_OP_LE_SET_EVENT_MASK 0x2001 -struct hci_cp_le_set_event_mask { - __u8 mask[8]; -} __packed; - -#define HCI_OP_LE_READ_BUFFER_SIZE 0x2002 -struct hci_rp_le_read_buffer_size { - __u8 status; - __le16 le_mtu; - __u8 le_max_pkt; -} __packed; - -#define HCI_OP_LE_SET_SCAN_ENABLE 0x200c -struct hci_cp_le_set_scan_enable { - __u8 enable; - __u8 filter_dup; -} __packed; - -#define HCI_OP_LE_CREATE_CONN 0x200d -struct hci_cp_le_create_conn { - __le16 scan_interval; - __le16 scan_window; - __u8 filter_policy; - __u8 peer_addr_type; - bdaddr_t peer_addr; - __u8 own_address_type; - __le16 conn_interval_min; - __le16 conn_interval_max; - __le16 conn_latency; - __le16 supervision_timeout; - __le16 min_ce_len; - __le16 max_ce_len; -} __packed; - -#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e - -#define HCI_OP_LE_CONN_UPDATE 0x2013 -struct hci_cp_le_conn_update { - __le16 handle; - __le16 conn_interval_min; - __le16 conn_interval_max; - __le16 conn_latency; - __le16 supervision_timeout; - __le16 min_ce_len; - __le16 max_ce_len; -} __packed; - -#define HCI_OP_LE_START_ENC 0x2019 -struct hci_cp_le_start_enc { - __le16 handle; - __u8 rand[8]; - __le16 ediv; - __u8 ltk[16]; -} __packed; - -#define HCI_OP_LE_LTK_REPLY 0x201a -struct hci_cp_le_ltk_reply { - __le16 handle; - __u8 ltk[16]; -} __packed; -struct hci_rp_le_ltk_reply { - __u8 status; - __le16 handle; -} __packed; - -#define HCI_OP_LE_LTK_NEG_REPLY 0x201b -struct hci_cp_le_ltk_neg_reply { - __le16 handle; -} __packed; -struct hci_rp_le_ltk_neg_reply { - __u8 status; - __le16 handle; -} __packed; - -/* ---- HCI Events ---- */ -#define HCI_EV_INQUIRY_COMPLETE 0x01 - -#define HCI_EV_INQUIRY_RESULT 0x02 -struct inquiry_info { - bdaddr_t bdaddr; - __u8 pscan_rep_mode; - __u8 pscan_period_mode; - __u8 pscan_mode; - __u8 dev_class[3]; - __le16 clock_offset; -} __packed; - -#define HCI_EV_CONN_COMPLETE 0x03 -struct hci_ev_conn_complete { - __u8 status; - __le16 handle; - bdaddr_t bdaddr; - __u8 link_type; - __u8 encr_mode; -} __packed; - -#define HCI_EV_CONN_REQUEST 0x04 -struct hci_ev_conn_request { - bdaddr_t bdaddr; - __u8 dev_class[3]; - __u8 link_type; -} __packed; - -#define HCI_EV_DISCONN_COMPLETE 0x05 -struct hci_ev_disconn_complete { - __u8 status; - __le16 handle; - __u8 reason; -} __packed; - -#define HCI_EV_AUTH_COMPLETE 0x06 -struct hci_ev_auth_complete { - __u8 status; - __le16 handle; -} __packed; - -#define HCI_EV_REMOTE_NAME 0x07 -struct hci_ev_remote_name { - __u8 status; - bdaddr_t bdaddr; - __u8 name[HCI_MAX_NAME_LENGTH]; -} __packed; - -#define HCI_EV_ENCRYPT_CHANGE 0x08 -struct hci_ev_encrypt_change { - __u8 status; - __le16 handle; - __u8 encrypt; -} __packed; - -#define HCI_EV_CHANGE_LINK_KEY_COMPLETE 0x09 -struct hci_ev_change_link_key_complete { - __u8 status; - __le16 handle; -} __packed; - -#define HCI_EV_REMOTE_FEATURES 0x0b -struct hci_ev_remote_features { - __u8 status; - __le16 handle; - __u8 features[8]; -} __packed; - -#define HCI_EV_REMOTE_VERSION 0x0c -struct hci_ev_remote_version { - __u8 status; - __le16 handle; - __u8 lmp_ver; - __le16 manufacturer; - __le16 lmp_subver; -} __packed; - -#define HCI_EV_QOS_SETUP_COMPLETE 0x0d -struct hci_qos { - __u8 service_type; - __u32 token_rate; - __u32 peak_bandwidth; - __u32 latency; - __u32 delay_variation; -} __packed; -struct hci_ev_qos_setup_complete { - __u8 status; - __le16 handle; - struct hci_qos qos; -} __packed; - -#define HCI_EV_CMD_COMPLETE 0x0e -struct hci_ev_cmd_complete { - __u8 ncmd; - __le16 opcode; -} __packed; - -#define HCI_EV_CMD_STATUS 0x0f -struct hci_ev_cmd_status { - __u8 status; - __u8 ncmd; - __le16 opcode; -} __packed; - -#define HCI_EV_ROLE_CHANGE 0x12 -struct hci_ev_role_change { - __u8 status; - bdaddr_t bdaddr; - __u8 role; -} __packed; - -#define HCI_EV_NUM_COMP_PKTS 0x13 -struct hci_ev_num_comp_pkts { - __u8 num_hndl; - /* variable length part */ -} __packed; - -#define HCI_EV_MODE_CHANGE 0x14 -struct hci_ev_mode_change { - __u8 status; - __le16 handle; - __u8 mode; - __le16 interval; -} __packed; - -#define HCI_EV_PIN_CODE_REQ 0x16 -struct hci_ev_pin_code_req { - bdaddr_t bdaddr; -} __packed; - -#define HCI_EV_LINK_KEY_REQ 0x17 -struct hci_ev_link_key_req { - bdaddr_t bdaddr; -} __packed; - -#define HCI_EV_LINK_KEY_NOTIFY 0x18 -struct hci_ev_link_key_notify { - bdaddr_t bdaddr; - __u8 link_key[16]; - __u8 key_type; -} __packed; - -#define HCI_EV_CLOCK_OFFSET 0x1c -struct hci_ev_clock_offset { - __u8 status; - __le16 handle; - __le16 clock_offset; -} __packed; - -#define HCI_EV_PKT_TYPE_CHANGE 0x1d -struct hci_ev_pkt_type_change { - __u8 status; - __le16 handle; - __le16 pkt_type; -} __packed; - -#define HCI_EV_PSCAN_REP_MODE 0x20 -struct hci_ev_pscan_rep_mode { - bdaddr_t bdaddr; - __u8 pscan_rep_mode; -} __packed; - -#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22 -struct inquiry_info_with_rssi { - bdaddr_t bdaddr; - __u8 pscan_rep_mode; - __u8 pscan_period_mode; - __u8 dev_class[3]; - __le16 clock_offset; - __s8 rssi; -} __packed; -struct inquiry_info_with_rssi_and_pscan_mode { - bdaddr_t bdaddr; - __u8 pscan_rep_mode; - __u8 pscan_period_mode; - __u8 pscan_mode; - __u8 dev_class[3]; - __le16 clock_offset; - __s8 rssi; -} __packed; - -#define HCI_EV_REMOTE_EXT_FEATURES 0x23 -struct hci_ev_remote_ext_features { - __u8 status; - __le16 handle; - __u8 page; - __u8 max_page; - __u8 features[8]; -} __packed; - -#define HCI_EV_SYNC_CONN_COMPLETE 0x2c -struct hci_ev_sync_conn_complete { - __u8 status; - __le16 handle; - bdaddr_t bdaddr; - __u8 link_type; - __u8 tx_interval; - __u8 retrans_window; - __le16 rx_pkt_len; - __le16 tx_pkt_len; - __u8 air_mode; -} __packed; - -#define HCI_EV_SYNC_CONN_CHANGED 0x2d -struct hci_ev_sync_conn_changed { - __u8 status; - __le16 handle; - __u8 tx_interval; - __u8 retrans_window; - __le16 rx_pkt_len; - __le16 tx_pkt_len; -} __packed; - -#define HCI_EV_SNIFF_SUBRATE 0x2e -struct hci_ev_sniff_subrate { - __u8 status; - __le16 handle; - __le16 max_tx_latency; - __le16 max_rx_latency; - __le16 max_remote_timeout; - __le16 max_local_timeout; -} __packed; - -#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2f -struct extended_inquiry_info { - bdaddr_t bdaddr; - __u8 pscan_rep_mode; - __u8 pscan_period_mode; - __u8 dev_class[3]; - __le16 clock_offset; - __s8 rssi; - __u8 data[240]; -} __packed; - -#define HCI_EV_IO_CAPA_REQUEST 0x31 -struct hci_ev_io_capa_request { - bdaddr_t bdaddr; -} __packed; - -#define HCI_EV_IO_CAPA_REPLY 0x32 -struct hci_ev_io_capa_reply { - bdaddr_t bdaddr; - __u8 capability; - __u8 oob_data; - __u8 authentication; -} __packed; - -#define HCI_EV_USER_CONFIRM_REQUEST 0x33 -struct hci_ev_user_confirm_req { - bdaddr_t bdaddr; - __le32 passkey; -} __packed; - -#define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35 -struct hci_ev_remote_oob_data_request { - bdaddr_t bdaddr; -} __packed; - -#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36 -struct hci_ev_simple_pair_complete { - __u8 status; - bdaddr_t bdaddr; -} __packed; - -#define HCI_EV_REMOTE_HOST_FEATURES 0x3d -struct hci_ev_remote_host_features { - bdaddr_t bdaddr; - __u8 features[8]; -} __packed; - -#define HCI_EV_LE_META 0x3e -struct hci_ev_le_meta { - __u8 subevent; -} __packed; - -/* Low energy meta events */ -#define HCI_EV_LE_CONN_COMPLETE 0x01 -struct hci_ev_le_conn_complete { - __u8 status; - __le16 handle; - __u8 role; - __u8 bdaddr_type; - bdaddr_t bdaddr; - __le16 interval; - __le16 latency; - __le16 supervision_timeout; - __u8 clk_accurancy; -} __packed; - -#define HCI_EV_LE_LTK_REQ 0x05 -struct hci_ev_le_ltk_req { - __le16 handle; - __u8 random[8]; - __le16 ediv; -} __packed; - -/* Advertising report event types */ -#define ADV_IND 0x00 -#define ADV_DIRECT_IND 0x01 -#define ADV_SCAN_IND 0x02 -#define ADV_NONCONN_IND 0x03 -#define ADV_SCAN_RSP 0x04 - -#define ADDR_LE_DEV_PUBLIC 0x00 -#define ADDR_LE_DEV_RANDOM 0x01 - -#define HCI_EV_LE_ADVERTISING_REPORT 0x02 -struct hci_ev_le_advertising_info { - __u8 evt_type; - __u8 bdaddr_type; - bdaddr_t bdaddr; - __u8 length; - __u8 data[0]; -} __packed; - -/* Internal events generated by Bluetooth stack */ -#define HCI_EV_STACK_INTERNAL 0xfd -struct hci_ev_stack_internal { - __u16 type; - __u8 data[0]; -} __packed; - -#define HCI_EV_SI_DEVICE 0x01 -struct hci_ev_si_device { - __u16 event; - __u16 dev_id; -} __packed; - -#define HCI_EV_SI_SECURITY 0x02 -struct hci_ev_si_security { - __u16 event; - __u16 proto; - __u16 subproto; - __u8 incoming; -} __packed; - -/* ---- HCI Packet structures ---- */ -#define HCI_COMMAND_HDR_SIZE 3 -#define HCI_EVENT_HDR_SIZE 2 -#define HCI_ACL_HDR_SIZE 4 -#define HCI_SCO_HDR_SIZE 3 - -struct hci_command_hdr { - __le16 opcode; /* OCF & OGF */ - __u8 plen; -} __packed; - -struct hci_event_hdr { - __u8 evt; - __u8 plen; -} __packed; - -struct hci_acl_hdr { - __le16 handle; /* Handle & Flags(PB, BC) */ - __le16 dlen; -} __packed; - -struct hci_sco_hdr { - __le16 handle; - __u8 dlen; -} __packed; - -#include <linux/skbuff.h> -static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) -{ - return (struct hci_event_hdr *) skb->data; -} - -static inline struct hci_acl_hdr *hci_acl_hdr(const struct sk_buff *skb) -{ - return (struct hci_acl_hdr *) skb->data; -} - -static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) -{ - return (struct hci_sco_hdr *) skb->data; -} - -/* Command opcode pack/unpack */ -#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) -#define hci_opcode_ogf(op) (op >> 10) -#define hci_opcode_ocf(op) (op & 0x03ff) - -/* ACL handle and flags pack/unpack */ -#define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12)) -#define hci_handle(h) (h & 0x0fff) -#define hci_flags(h) (h >> 12) - -/* ---- HCI Sockets ---- */ - -/* Socket options */ -#define HCI_DATA_DIR 1 -#define HCI_FILTER 2 -#define HCI_TIME_STAMP 3 - -/* CMSG flags */ -#define HCI_CMSG_DIR 0x0001 -#define HCI_CMSG_TSTAMP 0x0002 - -struct sockaddr_hci { - sa_family_t hci_family; - unsigned short hci_dev; - unsigned short hci_channel; -}; -#define HCI_DEV_NONE 0xffff - -#define HCI_CHANNEL_RAW 0 -#define HCI_CHANNEL_CONTROL 1 - -struct hci_filter { - unsigned long type_mask; - unsigned long event_mask[2]; - __le16 opcode; -}; - -struct hci_ufilter { - __u32 type_mask; - __u32 event_mask[2]; - __le16 opcode; -}; - -#define HCI_FLT_TYPE_BITS 31 -#define HCI_FLT_EVENT_BITS 63 -#define HCI_FLT_OGF_BITS 63 -#define HCI_FLT_OCF_BITS 127 - -/* ---- HCI Ioctl requests structures ---- */ -struct hci_dev_stats { - __u32 err_rx; - __u32 err_tx; - __u32 cmd_tx; - __u32 evt_rx; - __u32 acl_tx; - __u32 acl_rx; - __u32 sco_tx; - __u32 sco_rx; - __u32 byte_rx; - __u32 byte_tx; -}; - -struct hci_dev_info { - __u16 dev_id; - char name[8]; - - bdaddr_t bdaddr; - - __u32 flags; - __u8 type; - - __u8 features[8]; - - __u32 pkt_type; - __u32 link_policy; - __u32 link_mode; - - __u16 acl_mtu; - __u16 acl_pkts; - __u16 sco_mtu; - __u16 sco_pkts; - - struct hci_dev_stats stat; -}; - -struct hci_conn_info { - __u16 handle; - bdaddr_t bdaddr; - __u8 type; - __u8 out; - __u16 state; - __u32 link_mode; -}; - -struct hci_dev_req { - __u16 dev_id; - __u32 dev_opt; -}; - -struct hci_dev_list_req { - __u16 dev_num; - struct hci_dev_req dev_req[0]; /* hci_dev_req structures */ -}; - -struct hci_conn_list_req { - __u16 dev_id; - __u16 conn_num; - struct hci_conn_info conn_info[0]; -}; - -struct hci_conn_info_req { - bdaddr_t bdaddr; - __u8 type; - struct hci_conn_info conn_info[0]; -}; - -struct hci_auth_info_req { - bdaddr_t bdaddr; - __u8 type; -}; - -struct hci_inquiry_req { - __u16 dev_id; - __u16 flags; - __u8 lap[3]; - __u8 length; - __u8 num_rsp; -}; -#define IREQ_CACHE_FLUSH 0x0001 - -#endif /* __HCI_H */ diff --git a/include/compat/net/bluetooth/hci_core.h b/include/compat/net/bluetooth/hci_core.h deleted file mode 100755 index f333e76..0000000 --- a/include/compat/net/bluetooth/hci_core.h +++ /dev/null @@ -1,988 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved. - - Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#ifndef __HCI_CORE_H -#define __HCI_CORE_H - -#include <linux/interrupt.h> -#include <net/bluetooth/hci.h> - -/* HCI upper protocols */ -#define HCI_PROTO_L2CAP 0 -#define HCI_PROTO_SCO 1 - -/* HCI priority */ -#define HCI_PRIO_MAX 7 - -/* HCI Core structures */ -struct inquiry_data { - bdaddr_t bdaddr; - __u8 pscan_rep_mode; - __u8 pscan_period_mode; - __u8 pscan_mode; - __u8 dev_class[3]; - __le16 clock_offset; - __s8 rssi; - __u8 ssp_mode; -}; - -struct inquiry_entry { - struct inquiry_entry *next; - __u32 timestamp; - struct inquiry_data data; -}; - -struct inquiry_cache { - spinlock_t lock; - __u32 timestamp; - struct inquiry_entry *list; -}; - -struct hci_conn_hash { - struct list_head list; - spinlock_t lock; - unsigned int acl_num; - unsigned int sco_num; - unsigned int le_num; -}; - -struct hci_chan_hash { - struct list_head list; - spinlock_t lock; - unsigned int num; -}; - -struct bdaddr_list { - struct list_head list; - bdaddr_t bdaddr; -}; - -struct bt_uuid { - struct list_head list; - u8 uuid[16]; - u8 svc_hint; -}; - -struct key_master_id { - __le16 ediv; - u8 rand[8]; -} __packed; - -struct link_key_data { - bdaddr_t bdaddr; - u8 type; - u8 val[16]; - u8 pin_len; - u8 dlen; - u8 data[0]; -} __packed; - -struct link_key { - struct list_head list; - bdaddr_t bdaddr; - u8 type; - u8 val[16]; - u8 pin_len; - u8 dlen; - u8 data[0]; -}; - -struct oob_data { - struct list_head list; - bdaddr_t bdaddr; - u8 hash[16]; - u8 randomizer[16]; -}; - -struct adv_entry { - struct list_head list; - bdaddr_t bdaddr; - u8 bdaddr_type; -}; - -#define NUM_REASSEMBLY 4 -struct hci_dev { - struct list_head list; - spinlock_t lock; - atomic_t refcnt; - - char name[8]; - unsigned long flags; - __u16 id; - __u8 bus; - __u8 dev_type; - bdaddr_t bdaddr; - __u8 dev_name[HCI_MAX_NAME_LENGTH]; - __u8 eir[HCI_MAX_EIR_LENGTH]; - __u8 dev_class[3]; - __u8 major_class; - __u8 minor_class; - __u8 features[8]; - __u8 extfeatures[8]; - __u8 commands[64]; - __u8 ssp_mode; - __u8 hci_ver; - __u16 hci_rev; - __u8 lmp_ver; - __u16 manufacturer; - __le16 lmp_subver; - __u16 voice_setting; - __u8 io_capability; - - __u16 pkt_type; - __u16 esco_type; - __u16 link_policy; - __u16 link_mode; - - __u32 idle_timeout; - __u16 sniff_min_interval; - __u16 sniff_max_interval; - - __u8 amp_status; - __u32 amp_total_bw; - __u32 amp_max_bw; - __u32 amp_min_latency; - __u32 amp_max_pdu; - __u8 amp_type; - __u16 amp_pal_cap; - __u16 amp_assoc_size; - __u32 amp_max_flush_to; - __u32 amp_be_flush_to; - - unsigned int auto_accept_delay; - - unsigned long quirks; - - atomic_t cmd_cnt; - unsigned int acl_cnt; - unsigned int sco_cnt; - unsigned int le_cnt; - - unsigned int acl_mtu; - unsigned int sco_mtu; - unsigned int le_mtu; - unsigned int acl_pkts; - unsigned int sco_pkts; - unsigned int le_pkts; - - unsigned long acl_last_tx; - unsigned long sco_last_tx; - unsigned long le_last_tx; - - struct workqueue_struct *workqueue; - - struct work_struct power_on; - struct delayed_work power_off; - - __u16 discov_timeout; - struct delayed_work discov_off; - - struct timer_list cmd_timer; - struct tasklet_struct cmd_task; - struct tasklet_struct rx_task; - struct tasklet_struct tx_task; - - struct sk_buff_head rx_q; - struct sk_buff_head raw_q; - struct sk_buff_head cmd_q; - - struct sk_buff *sent_cmd; - struct sk_buff *reassembly[NUM_REASSEMBLY]; - - struct mutex req_lock; - wait_queue_head_t req_wait_q; - __u32 req_status; - __u32 req_result; - - __u16 init_last_cmd; - - struct list_head mgmt_pending; - - struct inquiry_cache inq_cache; - struct hci_conn_hash conn_hash; - struct list_head blacklist; - - struct list_head uuids; - - struct list_head link_keys; - - struct list_head remote_oob_data; - - struct list_head adv_entries; - struct timer_list adv_timer; - - struct hci_dev_stats stat; - - struct sk_buff_head driver_init; - - void *driver_data; - void *core_data; - - atomic_t promisc; - - struct dentry *debugfs; - - struct device *parent; - struct device dev; - - struct rfkill *rfkill; - - struct module *owner; - - int (*open)(struct hci_dev *hdev); - int (*close)(struct hci_dev *hdev); - int (*flush)(struct hci_dev *hdev); - int (*send)(struct sk_buff *skb); - void (*destruct)(struct hci_dev *hdev); - void (*notify)(struct hci_dev *hdev, unsigned int evt); - int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); -}; - -struct hci_conn { - struct list_head list; - - atomic_t refcnt; - - bdaddr_t dst; - __u8 dst_type; - __u16 handle; - __u16 state; - __u8 mode; - __u8 type; - __u8 out; - __u8 attempt; - __u8 dev_class[3]; - __u8 features[8]; - __u8 ssp_mode; - __u16 interval; - __u16 pkt_type; - __u16 link_policy; - __u32 link_mode; - __u8 key_type; - __u8 auth_type; - __u8 sec_level; - __u8 pending_sec_level; - __u8 pin_length; - __u8 enc_key_size; - __u8 io_capability; - __u8 power_save; - __u16 disc_timeout; - unsigned long pend; - - __u8 remote_cap; - __u8 remote_oob; - __u8 remote_auth; - - unsigned int sent; - - struct sk_buff_head data_q; - struct hci_chan_hash chan_hash; - - struct timer_list disc_timer; - struct timer_list idle_timer; - struct timer_list auto_accept_timer; - - struct work_struct work_add; - struct work_struct work_del; - - struct device dev; - atomic_t devref; - - struct hci_dev *hdev; - void *l2cap_data; - void *sco_data; - - struct hci_conn *link; - - void (*connect_cfm_cb) (struct hci_conn *conn, u8 status); - void (*security_cfm_cb) (struct hci_conn *conn, u8 status); - void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); -}; - -struct hci_chan { - struct list_head list; - - struct hci_conn *conn; - struct sk_buff_head data_q; - unsigned int sent; -}; - -extern struct hci_proto *hci_proto[]; -extern struct list_head hci_dev_list; -extern struct list_head hci_cb_list; -extern rwlock_t hci_dev_list_lock; -extern rwlock_t hci_cb_list_lock; - -/* ----- Inquiry cache ----- */ -#define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ -#define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ - -#define inquiry_cache_lock(c) spin_lock(&c->lock) -#define inquiry_cache_unlock(c) spin_unlock(&c->lock) -#define inquiry_cache_lock_bh(c) spin_lock_bh(&c->lock) -#define inquiry_cache_unlock_bh(c) spin_unlock_bh(&c->lock) - -static inline void inquiry_cache_init(struct hci_dev *hdev) -{ - struct inquiry_cache *c = &hdev->inq_cache; - spin_lock_init(&c->lock); - c->list = NULL; -} - -static inline int inquiry_cache_empty(struct hci_dev *hdev) -{ - struct inquiry_cache *c = &hdev->inq_cache; - return c->list == NULL; -} - -static inline long inquiry_cache_age(struct hci_dev *hdev) -{ - struct inquiry_cache *c = &hdev->inq_cache; - return jiffies - c->timestamp; -} - -static inline long inquiry_entry_age(struct inquiry_entry *e) -{ - return jiffies - e->timestamp; -} - -struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, - bdaddr_t *bdaddr); -void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data); - -/* ----- HCI Connections ----- */ -enum { - HCI_CONN_AUTH_PEND, - HCI_CONN_REAUTH_PEND, - HCI_CONN_ENCRYPT_PEND, - HCI_CONN_RSWITCH_PEND, - HCI_CONN_MODE_CHANGE_PEND, - HCI_CONN_SCO_SETUP_PEND, - HCI_CONN_LE_SMP_PEND, -}; - -static inline void hci_conn_hash_init(struct hci_dev *hdev) -{ - struct hci_conn_hash *h = &hdev->conn_hash; - INIT_LIST_HEAD(&h->list); - spin_lock_init(&h->lock); - h->acl_num = 0; - h->sco_num = 0; -} - -static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) -{ - struct hci_conn_hash *h = &hdev->conn_hash; - list_add(&c->list, &h->list); - switch (c->type) { - case ACL_LINK: - h->acl_num++; - break; - case LE_LINK: - h->le_num++; - break; - case SCO_LINK: - case ESCO_LINK: - h->sco_num++; - break; - } -} - -static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) -{ - struct hci_conn_hash *h = &hdev->conn_hash; - list_del(&c->list); - switch (c->type) { - case ACL_LINK: - h->acl_num--; - break; - case LE_LINK: - h->le_num--; - break; - case SCO_LINK: - case ESCO_LINK: - h->sco_num--; - break; - } -} - -static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type) -{ - struct hci_conn_hash *h = &hdev->conn_hash; - switch (type) { - case ACL_LINK: - return h->acl_num; - case LE_LINK: - return h->le_num; - case SCO_LINK: - case ESCO_LINK: - return h->sco_num; - default: - return 0; - } -} - -static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, - __u16 handle) -{ - struct hci_conn_hash *h = &hdev->conn_hash; - struct list_head *p; - struct hci_conn *c; - - list_for_each(p, &h->list) { - c = list_entry(p, struct hci_conn, list); - if (c->handle == handle) - return c; - } - return NULL; -} - -static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, - __u8 type, bdaddr_t *ba) -{ - struct hci_conn_hash *h = &hdev->conn_hash; - struct list_head *p; - struct hci_conn *c; - - list_for_each(p, &h->list) { - c = list_entry(p, struct hci_conn, list); - if (c->type == type && !bacmp(&c->dst, ba)) - return c; - } - return NULL; -} - -static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, - __u8 type, __u16 state) -{ - struct hci_conn_hash *h = &hdev->conn_hash; - struct list_head *p; - struct hci_conn *c; - - list_for_each(p, &h->list) { - c = list_entry(p, struct hci_conn, list); - if (c->type == type && c->state == state) - return c; - } - return NULL; -} - -static inline void hci_chan_hash_init(struct hci_conn *c) -{ - struct hci_chan_hash *h = &c->chan_hash; - INIT_LIST_HEAD(&h->list); - spin_lock_init(&h->lock); - h->num = 0; -} - -static inline void hci_chan_hash_add(struct hci_conn *c, struct hci_chan *chan) -{ - struct hci_chan_hash *h = &c->chan_hash; - list_add(&chan->list, &h->list); - h->num++; -} - -static inline void hci_chan_hash_del(struct hci_conn *c, struct hci_chan *chan) -{ - struct hci_chan_hash *h = &c->chan_hash; - list_del(&chan->list); - h->num--; -} - -void hci_acl_connect(struct hci_conn *conn); -void hci_acl_disconn(struct hci_conn *conn, __u8 reason); -void hci_add_sco(struct hci_conn *conn, __u16 handle); -void hci_setup_sync(struct hci_conn *conn, __u16 handle); -void hci_sco_setup(struct hci_conn *conn, __u8 status); - -struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); -int hci_conn_del(struct hci_conn *conn); -void hci_conn_hash_flush(struct hci_dev *hdev); -void hci_conn_check_pending(struct hci_dev *hdev); - -struct hci_chan *hci_chan_create(struct hci_conn *conn); -int hci_chan_del(struct hci_chan *chan); -void hci_chan_hash_flush(struct hci_conn *conn); - -struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, - __u8 sec_level, __u8 auth_type); -int hci_conn_check_link_mode(struct hci_conn *conn); -int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); -int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); -int hci_conn_change_link_key(struct hci_conn *conn); -int hci_conn_switch_role(struct hci_conn *conn, __u8 role); - -void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); -void hci_conn_enter_sniff_mode(struct hci_conn *conn); - -void hci_conn_hold_device(struct hci_conn *conn); -void hci_conn_put_device(struct hci_conn *conn); - -static inline void hci_conn_hold(struct hci_conn *conn) -{ - atomic_inc(&conn->refcnt); - del_timer(&conn->disc_timer); -} - -static inline void hci_conn_put(struct hci_conn *conn) -{ - if (atomic_dec_and_test(&conn->refcnt)) { - unsigned long timeo; - if (conn->type == ACL_LINK || conn->type == LE_LINK) { - del_timer(&conn->idle_timer); - if (conn->state == BT_CONNECTED) { - timeo = msecs_to_jiffies(conn->disc_timeout); - if (!conn->out) - timeo *= 2; - } else { - timeo = msecs_to_jiffies(10); - } - } else { - timeo = msecs_to_jiffies(10); - } - mod_timer(&conn->disc_timer, jiffies + timeo); - } -} - -/* ----- HCI Devices ----- */ -static inline void __hci_dev_put(struct hci_dev *d) -{ - if (atomic_dec_and_test(&d->refcnt)) - d->destruct(d); -} - -/* - * hci_dev_put and hci_dev_hold are macros to avoid dragging all the - * overhead of all the modular infrastructure into this header. - */ -#define hci_dev_put(d) \ -do { \ - __hci_dev_put(d); \ - module_put(d->owner); \ -} while (0) - -static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) -{ - atomic_inc(&d->refcnt); - return d; -} - -#define hci_dev_hold(d) \ -({ \ - try_module_get(d->owner) ? __hci_dev_hold(d) : NULL; \ -}) - -#define hci_dev_lock(d) spin_lock(&d->lock) -#define hci_dev_unlock(d) spin_unlock(&d->lock) -#define hci_dev_lock_bh(d) spin_lock_bh(&d->lock) -#define hci_dev_unlock_bh(d) spin_unlock_bh(&d->lock) - -struct hci_dev *hci_dev_get(int index); -struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); - -struct hci_dev *hci_alloc_dev(void); -void hci_free_dev(struct hci_dev *hdev); -int hci_register_dev(struct hci_dev *hdev); -void hci_unregister_dev(struct hci_dev *hdev); -int hci_suspend_dev(struct hci_dev *hdev); -int hci_resume_dev(struct hci_dev *hdev); -int hci_dev_open(__u16 dev); -int hci_dev_close(__u16 dev); -int hci_dev_reset(__u16 dev); -int hci_dev_reset_stat(__u16 dev); -int hci_dev_cmd(unsigned int cmd, void __user *arg); -int hci_get_dev_list(void __user *arg); -int hci_get_dev_info(void __user *arg); -int hci_get_conn_list(void __user *arg); -int hci_get_conn_info(struct hci_dev *hdev, void __user *arg); -int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); -int hci_inquiry(void __user *arg); - -struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); -int hci_blacklist_clear(struct hci_dev *hdev); -int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr); -int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr); - -int hci_uuids_clear(struct hci_dev *hdev); - -int hci_link_keys_clear(struct hci_dev *hdev); -struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); -int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, - bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); -struct link_key *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); -struct link_key *hci_find_link_key_type(struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 type); -int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, - u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]); -int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); - -int hci_remote_oob_data_clear(struct hci_dev *hdev); -struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, - bdaddr_t *bdaddr); -int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, - u8 *randomizer); -int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); - -#define ADV_CLEAR_TIMEOUT (3*60*HZ) /* Three minutes */ -int hci_adv_entries_clear(struct hci_dev *hdev); -struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr); -int hci_add_adv_entry(struct hci_dev *hdev, - struct hci_ev_le_advertising_info *ev); - -void hci_del_off_timer(struct hci_dev *hdev); - -void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); - -int hci_recv_frame(struct sk_buff *skb); -int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); -int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); - -void hci_init_sysfs(struct hci_dev *hdev); -int hci_add_sysfs(struct hci_dev *hdev); -void hci_del_sysfs(struct hci_dev *hdev); -void hci_conn_init_sysfs(struct hci_conn *conn); -void hci_conn_add_sysfs(struct hci_conn *conn); -void hci_conn_del_sysfs(struct hci_conn *conn); - -#define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->parent = (pdev)) - -/* ----- LMP capabilities ----- */ -#define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH) -#define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT) -#define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF) -#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) -#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) -#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) -#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) -#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) - -/* ----- Extended LMP capabilities ----- */ -#define lmp_host_le_capable(dev) ((dev)->extfeatures[0] & LMP_HOST_LE) - -/* ----- HCI protocols ----- */ -struct hci_proto { - char *name; - unsigned int id; - unsigned long flags; - - void *priv; - - int (*connect_ind) (struct hci_dev *hdev, bdaddr_t *bdaddr, - __u8 type); - int (*connect_cfm) (struct hci_conn *conn, __u8 status); - int (*disconn_ind) (struct hci_conn *conn); - int (*disconn_cfm) (struct hci_conn *conn, __u8 reason); - int (*recv_acldata) (struct hci_conn *conn, struct sk_buff *skb, - __u16 flags); - int (*recv_scodata) (struct hci_conn *conn, struct sk_buff *skb); - int (*security_cfm) (struct hci_conn *conn, __u8 status, - __u8 encrypt); -}; - -static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, - __u8 type) -{ - register struct hci_proto *hp; - int mask = 0; - - hp = hci_proto[HCI_PROTO_L2CAP]; - if (hp && hp->connect_ind) - mask |= hp->connect_ind(hdev, bdaddr, type); - - hp = hci_proto[HCI_PROTO_SCO]; - if (hp && hp->connect_ind) - mask |= hp->connect_ind(hdev, bdaddr, type); - - return mask; -} - -static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) -{ - register struct hci_proto *hp; - - hp = hci_proto[HCI_PROTO_L2CAP]; - if (hp && hp->connect_cfm) - hp->connect_cfm(conn, status); - - hp = hci_proto[HCI_PROTO_SCO]; - if (hp && hp->connect_cfm) - hp->connect_cfm(conn, status); - - if (conn->connect_cfm_cb) - conn->connect_cfm_cb(conn, status); -} - -static inline int hci_proto_disconn_ind(struct hci_conn *conn) -{ - register struct hci_proto *hp; - int reason = HCI_ERROR_REMOTE_USER_TERM; - - hp = hci_proto[HCI_PROTO_L2CAP]; - if (hp && hp->disconn_ind) - reason = hp->disconn_ind(conn); - - hp = hci_proto[HCI_PROTO_SCO]; - if (hp && hp->disconn_ind) - reason = hp->disconn_ind(conn); - - return reason; -} - -static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) -{ - register struct hci_proto *hp; - - hp = hci_proto[HCI_PROTO_L2CAP]; - if (hp && hp->disconn_cfm) - hp->disconn_cfm(conn, reason); - - hp = hci_proto[HCI_PROTO_SCO]; - if (hp && hp->disconn_cfm) - hp->disconn_cfm(conn, reason); - - if (conn->disconn_cfm_cb) - conn->disconn_cfm_cb(conn, reason); -} - -static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) -{ - register struct hci_proto *hp; - __u8 encrypt; - - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) - return; - - encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; - - hp = hci_proto[HCI_PROTO_L2CAP]; - if (hp && hp->security_cfm) - hp->security_cfm(conn, status, encrypt); - - hp = hci_proto[HCI_PROTO_SCO]; - if (hp && hp->security_cfm) - hp->security_cfm(conn, status, encrypt); - - if (conn->security_cfm_cb) - conn->security_cfm_cb(conn, status); -} - -static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, - __u8 encrypt) -{ - register struct hci_proto *hp; - - hp = hci_proto[HCI_PROTO_L2CAP]; - if (hp && hp->security_cfm) - hp->security_cfm(conn, status, encrypt); - - hp = hci_proto[HCI_PROTO_SCO]; - if (hp && hp->security_cfm) - hp->security_cfm(conn, status, encrypt); - - if (conn->security_cfm_cb) - conn->security_cfm_cb(conn, status); -} - -int hci_register_proto(struct hci_proto *hproto); -int hci_unregister_proto(struct hci_proto *hproto); - -/* ----- HCI callbacks ----- */ -struct hci_cb { - struct list_head list; - - char *name; - - void (*security_cfm) (struct hci_conn *conn, __u8 status, - __u8 encrypt); - void (*key_change_cfm) (struct hci_conn *conn, __u8 status); - void (*role_switch_cfm) (struct hci_conn *conn, __u8 status, __u8 role); -}; - -static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) -{ - struct list_head *p; - __u8 encrypt; - - hci_proto_auth_cfm(conn, status); - - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) - return; - - encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; - - read_lock_bh(&hci_cb_list_lock); - list_for_each(p, &hci_cb_list) { - struct hci_cb *cb = list_entry(p, struct hci_cb, list); - if (cb->security_cfm) - cb->security_cfm(conn, status, encrypt); - } - read_unlock_bh(&hci_cb_list_lock); -} - -static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, - __u8 encrypt) -{ - struct list_head *p; - - if (conn->sec_level == BT_SECURITY_SDP) - conn->sec_level = BT_SECURITY_LOW; - - if (conn->pending_sec_level > conn->sec_level) - conn->sec_level = conn->pending_sec_level; - - hci_proto_encrypt_cfm(conn, status, encrypt); - - read_lock_bh(&hci_cb_list_lock); - list_for_each(p, &hci_cb_list) { - struct hci_cb *cb = list_entry(p, struct hci_cb, list); - if (cb->security_cfm) - cb->security_cfm(conn, status, encrypt); - } - read_unlock_bh(&hci_cb_list_lock); -} - -static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) -{ - struct list_head *p; - - read_lock_bh(&hci_cb_list_lock); - list_for_each(p, &hci_cb_list) { - struct hci_cb *cb = list_entry(p, struct hci_cb, list); - if (cb->key_change_cfm) - cb->key_change_cfm(conn, status); - } - read_unlock_bh(&hci_cb_list_lock); -} - -static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, - __u8 role) -{ - struct list_head *p; - - read_lock_bh(&hci_cb_list_lock); - list_for_each(p, &hci_cb_list) { - struct hci_cb *cb = list_entry(p, struct hci_cb, list); - if (cb->role_switch_cfm) - cb->role_switch_cfm(conn, status, role); - } - read_unlock_bh(&hci_cb_list_lock); -} - -int hci_register_cb(struct hci_cb *hcb); -int hci_unregister_cb(struct hci_cb *hcb); - -int hci_register_notifier(struct notifier_block *nb); -int hci_unregister_notifier(struct notifier_block *nb); - -int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); -void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); -void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); - -void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); - -void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); - -/* ----- HCI Sockets ----- */ -void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, - struct sock *skip_sk); - -/* Management interface */ -int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); -int mgmt_index_added(struct hci_dev *hdev); -int mgmt_index_removed(struct hci_dev *hdev); -int mgmt_powered(struct hci_dev *hdev, u8 powered); -int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); -int mgmt_connectable(struct hci_dev *hdev, u8 connectable); -int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); -int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, - u8 persistent); -int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); -int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); -int mgmt_disconnect_failed(struct hci_dev *hdev); -int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, - u8 status); -int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); -int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status); -int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status); -int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, - __le32 value, u8 confirm_hint); -int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, - u8 status); -int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, - bdaddr_t *bdaddr, u8 status); -int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); -int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); -int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, - u8 *randomizer, u8 status); -int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, - u8 *dev_class, s8 rssi, u8 *eir); -int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); -int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status); -int mgmt_discovering(struct hci_dev *hdev, u8 discovering); -int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr); -int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr); - -/* HCI info for socket */ -#define hci_pi(sk) ((struct hci_pinfo *) sk) - -struct hci_pinfo { - struct bt_sock bt; - struct hci_dev *hdev; - struct hci_filter filter; - __u32 cmsg_mask; - unsigned short channel; -}; - -/* HCI security filter */ -#define HCI_SFLT_MAX_OGF 5 - -struct hci_sec_filter { - __u32 type_mask; - __u32 event_mask[2]; - __u32 ocf_mask[HCI_SFLT_MAX_OGF + 1][4]; -}; - -/* ----- HCI requests ----- */ -#define HCI_REQ_DONE 0 -#define HCI_REQ_PEND 1 -#define HCI_REQ_CANCELED 2 - -#define hci_req_lock(d) mutex_lock(&d->req_lock) -#define hci_req_unlock(d) mutex_unlock(&d->req_lock) - -void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result); - -void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, - u16 latency, u16 to_multiplier); -void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], - __u8 ltk[16]); -void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); -void hci_le_ltk_neg_reply(struct hci_conn *conn); - -int hci_do_inquiry(struct hci_dev *hdev, u8 length); -int hci_cancel_inquiry(struct hci_dev *hdev); - -#endif /* __HCI_CORE_H */ diff --git a/include/compat/net/bluetooth/l2cap.h b/include/compat/net/bluetooth/l2cap.h deleted file mode 100755 index 875021a..0000000 --- a/include/compat/net/bluetooth/l2cap.h +++ /dev/null @@ -1,814 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - Copyright (C) 2000-2001 Qualcomm Incorporated - Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> - Copyright (C) 2010 Google Inc. - - Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#ifndef __L2CAP_H -#define __L2CAP_H - -#include <asm/unaligned.h> - -/* L2CAP defaults */ -#define L2CAP_DEFAULT_MTU 672 -#define L2CAP_DEFAULT_MIN_MTU 48 -#define L2CAP_DEFAULT_FLUSH_TO 0xffff -#define L2CAP_DEFAULT_TX_WINDOW 63 -#define L2CAP_DEFAULT_EXT_WINDOW 0x3FFF -#define L2CAP_DEFAULT_MAX_TX 3 -#define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ -#define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ -#define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ -#define L2CAP_DEFAULT_ACK_TO 200 -#define L2CAP_LE_DEFAULT_MTU 23 -#define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF -#define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF -#define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF - -#define L2CAP_DISC_TIMEOUT (100) -#define L2CAP_DISC_REJ_TIMEOUT (5000) /* 5 seconds */ -#define L2CAP_ENC_TIMEOUT (5000) /* 5 seconds */ -#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ -#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ - -/* L2CAP socket address */ -struct sockaddr_l2 { - sa_family_t l2_family; - __le16 l2_psm; - bdaddr_t l2_bdaddr; - __le16 l2_cid; -}; - -/* L2CAP socket options */ -#define L2CAP_OPTIONS 0x01 -struct l2cap_options { - __u16 omtu; - __u16 imtu; - __u16 flush_to; - __u8 mode; - __u8 fcs; - __u8 max_tx; - __u16 txwin_size; -}; - -#define L2CAP_CONNINFO 0x02 -struct l2cap_conninfo { - __u16 hci_handle; - __u8 dev_class[3]; -}; - -#define L2CAP_LM 0x03 -#define L2CAP_LM_MASTER 0x0001 -#define L2CAP_LM_AUTH 0x0002 -#define L2CAP_LM_ENCRYPT 0x0004 -#define L2CAP_LM_TRUSTED 0x0008 -#define L2CAP_LM_RELIABLE 0x0010 -#define L2CAP_LM_SECURE 0x0020 - -/* L2CAP command codes */ -#define L2CAP_COMMAND_REJ 0x01 -#define L2CAP_CONN_REQ 0x02 -#define L2CAP_CONN_RSP 0x03 -#define L2CAP_CONF_REQ 0x04 -#define L2CAP_CONF_RSP 0x05 -#define L2CAP_DISCONN_REQ 0x06 -#define L2CAP_DISCONN_RSP 0x07 -#define L2CAP_ECHO_REQ 0x08 -#define L2CAP_ECHO_RSP 0x09 -#define L2CAP_INFO_REQ 0x0a -#define L2CAP_INFO_RSP 0x0b -#define L2CAP_CREATE_CHAN_REQ 0x0c -#define L2CAP_CREATE_CHAN_RSP 0x0d -#define L2CAP_MOVE_CHAN_REQ 0x0e -#define L2CAP_MOVE_CHAN_RSP 0x0f -#define L2CAP_MOVE_CHAN_CFM 0x10 -#define L2CAP_MOVE_CHAN_CFM_RSP 0x11 -#define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 -#define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 - -/* L2CAP extended feature mask */ -#define L2CAP_FEAT_FLOWCTL 0x00000001 -#define L2CAP_FEAT_RETRANS 0x00000002 -#define L2CAP_FEAT_BIDIR_QOS 0x00000004 -#define L2CAP_FEAT_ERTM 0x00000008 -#define L2CAP_FEAT_STREAMING 0x00000010 -#define L2CAP_FEAT_FCS 0x00000020 -#define L2CAP_FEAT_EXT_FLOW 0x00000040 -#define L2CAP_FEAT_FIXED_CHAN 0x00000080 -#define L2CAP_FEAT_EXT_WINDOW 0x00000100 -#define L2CAP_FEAT_UCD 0x00000200 - -/* L2CAP checksum option */ -#define L2CAP_FCS_NONE 0x00 -#define L2CAP_FCS_CRC16 0x01 - -/* L2CAP fixed channels */ -#define L2CAP_FC_L2CAP 0x02 -#define L2CAP_FC_A2MP 0x08 - -/* L2CAP Control Field bit masks */ -#define L2CAP_CTRL_SAR 0xC000 -#define L2CAP_CTRL_REQSEQ 0x3F00 -#define L2CAP_CTRL_TXSEQ 0x007E -#define L2CAP_CTRL_SUPERVISE 0x000C - -#define L2CAP_CTRL_RETRANS 0x0080 -#define L2CAP_CTRL_FINAL 0x0080 -#define L2CAP_CTRL_POLL 0x0010 -#define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ - -#define L2CAP_CTRL_TXSEQ_SHIFT 1 -#define L2CAP_CTRL_SUPER_SHIFT 2 -#define L2CAP_CTRL_REQSEQ_SHIFT 8 -#define L2CAP_CTRL_SAR_SHIFT 14 - -/* L2CAP Extended Control Field bit mask */ -#define L2CAP_EXT_CTRL_TXSEQ 0xFFFC0000 -#define L2CAP_EXT_CTRL_SAR 0x00030000 -#define L2CAP_EXT_CTRL_SUPERVISE 0x00030000 -#define L2CAP_EXT_CTRL_REQSEQ 0x0000FFFC - -#define L2CAP_EXT_CTRL_POLL 0x00040000 -#define L2CAP_EXT_CTRL_FINAL 0x00000002 -#define L2CAP_EXT_CTRL_FRAME_TYPE 0x00000001 /* I- or S-Frame */ - -#define L2CAP_EXT_CTRL_REQSEQ_SHIFT 2 -#define L2CAP_EXT_CTRL_SAR_SHIFT 16 -#define L2CAP_EXT_CTRL_SUPER_SHIFT 16 -#define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18 - -/* L2CAP Supervisory Function */ -#define L2CAP_SUPER_RR 0x00 -#define L2CAP_SUPER_REJ 0x01 -#define L2CAP_SUPER_RNR 0x02 -#define L2CAP_SUPER_SREJ 0x03 - -/* L2CAP Segmentation and Reassembly */ -#define L2CAP_SAR_UNSEGMENTED 0x00 -#define L2CAP_SAR_START 0x01 -#define L2CAP_SAR_END 0x02 -#define L2CAP_SAR_CONTINUE 0x03 - -/* L2CAP Command rej. reasons */ -#define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 -#define L2CAP_REJ_MTU_EXCEEDED 0x0001 -#define L2CAP_REJ_INVALID_CID 0x0002 - -/* L2CAP structures */ -struct l2cap_hdr { - __le16 len; - __le16 cid; -} __packed; -#define L2CAP_HDR_SIZE 4 -#define L2CAP_ENH_HDR_SIZE 6 -#define L2CAP_EXT_HDR_SIZE 8 - -#define L2CAP_FCS_SIZE 2 -#define L2CAP_SDULEN_SIZE 2 -#define L2CAP_PSMLEN_SIZE 2 - -struct l2cap_cmd_hdr { - __u8 code; - __u8 ident; - __le16 len; -} __packed; -#define L2CAP_CMD_HDR_SIZE 4 - -struct l2cap_cmd_rej_unk { - __le16 reason; -} __packed; - -struct l2cap_cmd_rej_mtu { - __le16 reason; - __le16 max_mtu; -} __packed; - -struct l2cap_cmd_rej_cid { - __le16 reason; - __le16 scid; - __le16 dcid; -} __packed; - -struct l2cap_conn_req { - __le16 psm; - __le16 scid; -} __packed; - -struct l2cap_conn_rsp { - __le16 dcid; - __le16 scid; - __le16 result; - __le16 status; -} __packed; - -/* channel indentifier */ -#define L2CAP_CID_SIGNALING 0x0001 -#define L2CAP_CID_CONN_LESS 0x0002 -#define L2CAP_CID_LE_DATA 0x0004 -#define L2CAP_CID_LE_SIGNALING 0x0005 -#define L2CAP_CID_SMP 0x0006 -#define L2CAP_CID_DYN_START 0x0040 -#define L2CAP_CID_DYN_END 0xffff - -/* connect/create channel results */ -#define L2CAP_CR_SUCCESS 0x0000 -#define L2CAP_CR_PEND 0x0001 -#define L2CAP_CR_BAD_PSM 0x0002 -#define L2CAP_CR_SEC_BLOCK 0x0003 -#define L2CAP_CR_NO_MEM 0x0004 -#define L2CAP_CR_BAD_AMP 0x0005 - -/* connect/create channel status */ -#define L2CAP_CS_NO_INFO 0x0000 -#define L2CAP_CS_AUTHEN_PEND 0x0001 -#define L2CAP_CS_AUTHOR_PEND 0x0002 - -struct l2cap_conf_req { - __le16 dcid; - __le16 flags; - __u8 data[0]; -} __packed; - -struct l2cap_conf_rsp { - __le16 scid; - __le16 flags; - __le16 result; - __u8 data[0]; -} __packed; - -#define L2CAP_CONF_SUCCESS 0x0000 -#define L2CAP_CONF_UNACCEPT 0x0001 -#define L2CAP_CONF_REJECT 0x0002 -#define L2CAP_CONF_UNKNOWN 0x0003 -#define L2CAP_CONF_PENDING 0x0004 -#define L2CAP_CONF_EFS_REJECT 0x0005 - -struct l2cap_conf_opt { - __u8 type; - __u8 len; - __u8 val[0]; -} __packed; -#define L2CAP_CONF_OPT_SIZE 2 - -#define L2CAP_CONF_HINT 0x80 -#define L2CAP_CONF_MASK 0x7f - -#define L2CAP_CONF_MTU 0x01 -#define L2CAP_CONF_FLUSH_TO 0x02 -#define L2CAP_CONF_QOS 0x03 -#define L2CAP_CONF_RFC 0x04 -#define L2CAP_CONF_FCS 0x05 -#define L2CAP_CONF_EFS 0x06 -#define L2CAP_CONF_EWS 0x07 - -#define L2CAP_CONF_MAX_SIZE 22 - -struct l2cap_conf_rfc { - __u8 mode; - __u8 txwin_size; - __u8 max_transmit; - __le16 retrans_timeout; - __le16 monitor_timeout; - __le16 max_pdu_size; -} __packed; - -#define L2CAP_MODE_BASIC 0x00 -#define L2CAP_MODE_RETRANS 0x01 -#define L2CAP_MODE_FLOWCTL 0x02 -#define L2CAP_MODE_ERTM 0x03 -#define L2CAP_MODE_STREAMING 0x04 - -struct l2cap_conf_efs { - __u8 id; - __u8 stype; - __le16 msdu; - __le32 sdu_itime; - __le32 acc_lat; - __le32 flush_to; -} __packed; - -#define L2CAP_SERV_NOTRAFIC 0x00 -#define L2CAP_SERV_BESTEFFORT 0x01 -#define L2CAP_SERV_GUARANTEED 0x02 - -#define L2CAP_BESTEFFORT_ID 0x01 - -struct l2cap_disconn_req { - __le16 dcid; - __le16 scid; -} __packed; - -struct l2cap_disconn_rsp { - __le16 dcid; - __le16 scid; -} __packed; - -struct l2cap_info_req { - __le16 type; -} __packed; - -struct l2cap_info_rsp { - __le16 type; - __le16 result; - __u8 data[0]; -} __packed; - -struct l2cap_create_chan_req { - __le16 psm; - __le16 scid; - __u8 amp_id; -} __packed; - -struct l2cap_create_chan_rsp { - __le16 dcid; - __le16 scid; - __le16 result; - __le16 status; -} __packed; - -struct l2cap_move_chan_req { - __le16 icid; - __u8 dest_amp_id; -} __packed; - -struct l2cap_move_chan_rsp { - __le16 icid; - __le16 result; -} __packed; - -#define L2CAP_MR_SUCCESS 0x0000 -#define L2CAP_MR_PEND 0x0001 -#define L2CAP_MR_BAD_ID 0x0002 -#define L2CAP_MR_SAME_ID 0x0003 -#define L2CAP_MR_NOT_SUPP 0x0004 -#define L2CAP_MR_COLLISION 0x0005 -#define L2CAP_MR_NOT_ALLOWED 0x0006 - -struct l2cap_move_chan_cfm { - __le16 icid; - __le16 result; -} __packed; - -#define L2CAP_MC_CONFIRMED 0x0000 -#define L2CAP_MC_UNCONFIRMED 0x0001 - -struct l2cap_move_chan_cfm_rsp { - __le16 icid; -} __packed; - -/* info type */ -#define L2CAP_IT_CL_MTU 0x0001 -#define L2CAP_IT_FEAT_MASK 0x0002 -#define L2CAP_IT_FIXED_CHAN 0x0003 - -/* info result */ -#define L2CAP_IR_SUCCESS 0x0000 -#define L2CAP_IR_NOTSUPP 0x0001 - -struct l2cap_conn_param_update_req { - __le16 min; - __le16 max; - __le16 latency; - __le16 to_multiplier; -} __packed; - -struct l2cap_conn_param_update_rsp { - __le16 result; -} __packed; - -/* Connection Parameters result */ -#define L2CAP_CONN_PARAM_ACCEPTED 0x0000 -#define L2CAP_CONN_PARAM_REJECTED 0x0001 - -/* ----- L2CAP channels and connections ----- */ -struct srej_list { - __u16 tx_seq; - struct list_head list; -}; - -struct l2cap_chan { - struct sock *sk; - - struct l2cap_conn *conn; - - __u8 state; - - atomic_t refcnt; - - __le16 psm; - __u16 dcid; - __u16 scid; - - __u16 imtu; - __u16 omtu; - __u16 flush_to; - __u8 mode; - __u8 chan_type; - __u8 chan_policy; - - __le16 sport; - - __u8 sec_level; - - __u8 ident; - - __u8 conf_req[64]; - __u8 conf_len; - __u8 num_conf_req; - __u8 num_conf_rsp; - - __u8 fcs; - - __u16 tx_win; - __u16 tx_win_max; - __u8 max_tx; - __u16 retrans_timeout; - __u16 monitor_timeout; - __u16 mps; - - unsigned long conf_state; - unsigned long conn_state; - unsigned long flags; - - __u16 next_tx_seq; - __u16 expected_ack_seq; - __u16 expected_tx_seq; - __u16 buffer_seq; - __u16 buffer_seq_srej; - __u16 srej_save_reqseq; - __u16 frames_sent; - __u16 unacked_frames; - __u8 retry_count; - __u8 num_acked; - __u16 sdu_len; - struct sk_buff *sdu; - struct sk_buff *sdu_last_frag; - - __u16 remote_tx_win; - __u8 remote_max_tx; - __u16 remote_mps; - - __u8 local_id; - __u8 local_stype; - __u16 local_msdu; - __u32 local_sdu_itime; - __u32 local_acc_lat; - __u32 local_flush_to; - - __u8 remote_id; - __u8 remote_stype; - __u16 remote_msdu; - __u32 remote_sdu_itime; - __u32 remote_acc_lat; - __u32 remote_flush_to; - - struct timer_list chan_timer; - struct timer_list retrans_timer; - struct timer_list monitor_timer; - struct timer_list ack_timer; - struct sk_buff *tx_send_head; - struct sk_buff_head tx_q; - struct sk_buff_head srej_q; - struct list_head srej_l; - - struct list_head list; - struct list_head global_l; - - void *data; - struct l2cap_ops *ops; -}; - -struct l2cap_ops { - char *name; - - struct l2cap_chan *(*new_connection) (void *data); - int (*recv) (void *data, struct sk_buff *skb); - void (*close) (void *data); - void (*state_change) (void *data, int state); -}; - -struct l2cap_conn { - struct hci_conn *hcon; - struct hci_chan *hchan; - - bdaddr_t *dst; - bdaddr_t *src; - - unsigned int mtu; - - __u32 feat_mask; - - __u8 info_state; - __u8 info_ident; - - struct timer_list info_timer; - - spinlock_t lock; - - struct sk_buff *rx_skb; - __u32 rx_len; - __u8 tx_ident; - - __u8 disc_reason; - - struct timer_list security_timer; - struct smp_chan *smp_chan; - - struct list_head chan_l; - rwlock_t chan_lock; -}; - -#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 -#define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 -#define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 - -#define L2CAP_CHAN_RAW 1 -#define L2CAP_CHAN_CONN_LESS 2 -#define L2CAP_CHAN_CONN_ORIENTED 3 - -/* ----- L2CAP socket info ----- */ -#define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) - -struct l2cap_pinfo { - struct bt_sock bt; - struct l2cap_chan *chan; - struct sk_buff *rx_busy_skb; -}; - -enum { - CONF_REQ_SENT, - CONF_INPUT_DONE, - CONF_OUTPUT_DONE, - CONF_MTU_DONE, - CONF_MODE_DONE, - CONF_CONNECT_PEND, - CONF_NO_FCS_RECV, - CONF_STATE2_DEVICE, - CONF_EWS_RECV, - CONF_LOC_CONF_PEND, - CONF_REM_CONF_PEND, -}; - -#define L2CAP_CONF_MAX_CONF_REQ 2 -#define L2CAP_CONF_MAX_CONF_RSP 2 - -enum { - CONN_SREJ_SENT, - CONN_WAIT_F, - CONN_SREJ_ACT, - CONN_SEND_PBIT, - CONN_REMOTE_BUSY, - CONN_LOCAL_BUSY, - CONN_REJ_ACT, - CONN_SEND_FBIT, - CONN_RNR_SENT, -}; - -/* Definitions for flags in l2cap_chan */ -enum { - FLAG_ROLE_SWITCH, - FLAG_FORCE_ACTIVE, - FLAG_FORCE_RELIABLE, - FLAG_FLUSHABLE, - FLAG_EXT_CTRL, - FLAG_EFS_ENABLE, -}; - -#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) -#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) -#define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ - L2CAP_DEFAULT_RETRANS_TO); -#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) -#define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ - L2CAP_DEFAULT_MONITOR_TO); -#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) -#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ - L2CAP_DEFAULT_ACK_TO); -#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) - -static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) -{ - int offset; - - offset = (seq1 - seq2) % (chan->tx_win_max + 1); - if (offset < 0) - offset += (chan->tx_win_max + 1); - - return offset; -} - -static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) -{ - return (seq + 1) % (chan->tx_win_max + 1); -} - -static inline int l2cap_tx_window_full(struct l2cap_chan *ch) -{ - int sub; - - sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; - - if (sub < 0) - sub += 64; - - return sub == ch->remote_tx_win; -} - -static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return (ctrl & L2CAP_EXT_CTRL_REQSEQ) >> - L2CAP_EXT_CTRL_REQSEQ_SHIFT; - else - return (ctrl & L2CAP_CTRL_REQSEQ) >> L2CAP_CTRL_REQSEQ_SHIFT; -} - -static inline __u32 __set_reqseq(struct l2cap_chan *chan, __u32 reqseq) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return (reqseq << L2CAP_EXT_CTRL_REQSEQ_SHIFT) & - L2CAP_EXT_CTRL_REQSEQ; - else - return (reqseq << L2CAP_CTRL_REQSEQ_SHIFT) & L2CAP_CTRL_REQSEQ; -} - -static inline __u16 __get_txseq(struct l2cap_chan *chan, __u32 ctrl) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return (ctrl & L2CAP_EXT_CTRL_TXSEQ) >> - L2CAP_EXT_CTRL_TXSEQ_SHIFT; - else - return (ctrl & L2CAP_CTRL_TXSEQ) >> L2CAP_CTRL_TXSEQ_SHIFT; -} - -static inline __u32 __set_txseq(struct l2cap_chan *chan, __u32 txseq) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return (txseq << L2CAP_EXT_CTRL_TXSEQ_SHIFT) & - L2CAP_EXT_CTRL_TXSEQ; - else - return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; -} - -static inline bool __is_sframe(struct l2cap_chan *chan, __u32 ctrl) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return ctrl & L2CAP_EXT_CTRL_FRAME_TYPE; - else - return ctrl & L2CAP_CTRL_FRAME_TYPE; -} - -static inline __u32 __set_sframe(struct l2cap_chan *chan) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return L2CAP_EXT_CTRL_FRAME_TYPE; - else - return L2CAP_CTRL_FRAME_TYPE; -} - -static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return (ctrl & L2CAP_EXT_CTRL_SAR) >> L2CAP_EXT_CTRL_SAR_SHIFT; - else - return (ctrl & L2CAP_CTRL_SAR) >> L2CAP_CTRL_SAR_SHIFT; -} - -static inline __u32 __set_ctrl_sar(struct l2cap_chan *chan, __u32 sar) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return (sar << L2CAP_EXT_CTRL_SAR_SHIFT) & L2CAP_EXT_CTRL_SAR; - else - return (sar << L2CAP_CTRL_SAR_SHIFT) & L2CAP_CTRL_SAR; -} - -static inline bool __is_sar_start(struct l2cap_chan *chan, __u32 ctrl) -{ - return __get_ctrl_sar(chan, ctrl) == L2CAP_SAR_START; -} - -static inline __u32 __get_sar_mask(struct l2cap_chan *chan) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return L2CAP_EXT_CTRL_SAR; - else - return L2CAP_CTRL_SAR; -} - -static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return (ctrl & L2CAP_EXT_CTRL_SUPERVISE) >> - L2CAP_EXT_CTRL_SUPER_SHIFT; - else - return (ctrl & L2CAP_CTRL_SUPERVISE) >> L2CAP_CTRL_SUPER_SHIFT; -} - -static inline __u32 __set_ctrl_super(struct l2cap_chan *chan, __u32 super) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return (super << L2CAP_EXT_CTRL_SUPER_SHIFT) & - L2CAP_EXT_CTRL_SUPERVISE; - else - return (super << L2CAP_CTRL_SUPER_SHIFT) & - L2CAP_CTRL_SUPERVISE; -} - -static inline __u32 __set_ctrl_final(struct l2cap_chan *chan) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return L2CAP_EXT_CTRL_FINAL; - else - return L2CAP_CTRL_FINAL; -} - -static inline bool __is_ctrl_final(struct l2cap_chan *chan, __u32 ctrl) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return ctrl & L2CAP_EXT_CTRL_FINAL; - else - return ctrl & L2CAP_CTRL_FINAL; -} - -static inline __u32 __set_ctrl_poll(struct l2cap_chan *chan) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return L2CAP_EXT_CTRL_POLL; - else - return L2CAP_CTRL_POLL; -} - -static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return ctrl & L2CAP_EXT_CTRL_POLL; - else - return ctrl & L2CAP_CTRL_POLL; -} - -static inline __u32 __get_control(struct l2cap_chan *chan, void *p) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return get_unaligned_le32(p); - else - return get_unaligned_le16(p); -} - -static inline void __put_control(struct l2cap_chan *chan, __u32 control, - void *p) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return put_unaligned_le32(control, p); - else - return put_unaligned_le16(control, p); -} - -static inline __u8 __ctrl_size(struct l2cap_chan *chan) -{ - if (test_bit(FLAG_EXT_CTRL, &chan->flags)) - return L2CAP_EXT_HDR_SIZE - L2CAP_HDR_SIZE; - else - return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE; -} - -extern int disable_ertm; -extern int enable_hs; - -int l2cap_init_sockets(void); -void l2cap_cleanup_sockets(void); - -void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); -int __l2cap_wait_ack(struct sock *sk); - -int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); -int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); - -struct l2cap_chan *l2cap_chan_create(struct sock *sk); -void l2cap_chan_close(struct l2cap_chan *chan, int reason); -void l2cap_chan_destroy(struct l2cap_chan *chan); -int l2cap_chan_connect(struct l2cap_chan *chan); -int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, - u32 priority); -void l2cap_chan_busy(struct l2cap_chan *chan, int busy); - -#endif /* __L2CAP_H */ diff --git a/include/compat/net/bluetooth/mgmt.h b/include/compat/net/bluetooth/mgmt.h deleted file mode 100755 index 3e320c9..0000000 --- a/include/compat/net/bluetooth/mgmt.h +++ /dev/null @@ -1,324 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - - Copyright (C) 2010 Nokia Corporation - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#define MGMT_INDEX_NONE 0xFFFF - -struct mgmt_hdr { - __le16 opcode; - __le16 index; - __le16 len; -} __packed; - -#define MGMT_OP_READ_VERSION 0x0001 -struct mgmt_rp_read_version { - __u8 version; - __le16 revision; -} __packed; - -#define MGMT_OP_READ_INDEX_LIST 0x0003 -struct mgmt_rp_read_index_list { - __le16 num_controllers; - __le16 index[0]; -} __packed; - -/* Reserve one extra byte for names in management messages so that they - * are always guaranteed to be nul-terminated */ -#define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1) - -#define MGMT_OP_READ_INFO 0x0004 -struct mgmt_rp_read_info { - __u8 type; - __u8 powered; - __u8 connectable; - __u8 discoverable; - __u8 pairable; - __u8 sec_mode; - bdaddr_t bdaddr; - __u8 dev_class[3]; - __u8 features[8]; - __u16 manufacturer; - __u8 hci_ver; - __u16 hci_rev; - __u8 name[MGMT_MAX_NAME_LENGTH]; -} __packed; - -struct mgmt_mode { - __u8 val; -} __packed; - -#define MGMT_OP_SET_POWERED 0x0005 - -#define MGMT_OP_SET_DISCOVERABLE 0x0006 -struct mgmt_cp_set_discoverable { - __u8 val; - __u16 timeout; -} __packed; - -#define MGMT_OP_SET_CONNECTABLE 0x0007 - -#define MGMT_OP_SET_PAIRABLE 0x0008 - -#define MGMT_OP_ADD_UUID 0x0009 -struct mgmt_cp_add_uuid { - __u8 uuid[16]; - __u8 svc_hint; -} __packed; - -#define MGMT_OP_REMOVE_UUID 0x000A -struct mgmt_cp_remove_uuid { - __u8 uuid[16]; -} __packed; - -#define MGMT_OP_SET_DEV_CLASS 0x000B -struct mgmt_cp_set_dev_class { - __u8 major; - __u8 minor; -} __packed; - -#define MGMT_OP_SET_SERVICE_CACHE 0x000C -struct mgmt_cp_set_service_cache { - __u8 enable; -} __packed; - -struct mgmt_link_key_info { - bdaddr_t bdaddr; - u8 type; - u8 val[16]; - u8 pin_len; -} __packed; - -#define MGMT_OP_LOAD_LINK_KEYS 0x000D -struct mgmt_cp_load_link_keys { - __u8 debug_keys; - __le16 key_count; - struct mgmt_link_key_info keys[0]; -} __packed; - -#define MGMT_OP_REMOVE_KEYS 0x000E -struct mgmt_cp_remove_keys { - bdaddr_t bdaddr; - __u8 disconnect; -} __packed; - -#define MGMT_OP_DISCONNECT 0x000F -struct mgmt_cp_disconnect { - bdaddr_t bdaddr; -} __packed; -struct mgmt_rp_disconnect { - bdaddr_t bdaddr; -} __packed; - -#define MGMT_ADDR_BREDR 0x00 -#define MGMT_ADDR_LE 0x01 -#define MGMT_ADDR_BREDR_LE 0x02 -#define MGMT_ADDR_INVALID 0xff - -struct mgmt_addr_info { - bdaddr_t bdaddr; - __u8 type; -} __packed; - -#define MGMT_OP_GET_CONNECTIONS 0x0010 -struct mgmt_rp_get_connections { - __le16 conn_count; - struct mgmt_addr_info addr[0]; -} __packed; - -#define MGMT_OP_PIN_CODE_REPLY 0x0011 -struct mgmt_cp_pin_code_reply { - bdaddr_t bdaddr; - __u8 pin_len; - __u8 pin_code[16]; -} __packed; -struct mgmt_rp_pin_code_reply { - bdaddr_t bdaddr; - uint8_t status; -} __packed; - -#define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012 -struct mgmt_cp_pin_code_neg_reply { - bdaddr_t bdaddr; -} __packed; - -#define MGMT_OP_SET_IO_CAPABILITY 0x0013 -struct mgmt_cp_set_io_capability { - __u8 io_capability; -} __packed; - -#define MGMT_OP_PAIR_DEVICE 0x0014 -struct mgmt_cp_pair_device { - bdaddr_t bdaddr; - __u8 io_cap; -} __packed; -struct mgmt_rp_pair_device { - bdaddr_t bdaddr; - __u8 status; -} __packed; - -#define MGMT_OP_USER_CONFIRM_REPLY 0x0015 -struct mgmt_cp_user_confirm_reply { - bdaddr_t bdaddr; -} __packed; -struct mgmt_rp_user_confirm_reply { - bdaddr_t bdaddr; - __u8 status; -} __packed; - -#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016 - -#define MGMT_OP_SET_LOCAL_NAME 0x0017 -struct mgmt_cp_set_local_name { - __u8 name[MGMT_MAX_NAME_LENGTH]; -} __packed; - -#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018 -struct mgmt_rp_read_local_oob_data { - __u8 hash[16]; - __u8 randomizer[16]; -} __packed; - -#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019 -struct mgmt_cp_add_remote_oob_data { - bdaddr_t bdaddr; - __u8 hash[16]; - __u8 randomizer[16]; -} __packed; - -#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A -struct mgmt_cp_remove_remote_oob_data { - bdaddr_t bdaddr; -} __packed; - -#define MGMT_OP_START_DISCOVERY 0x001B - -#define MGMT_OP_STOP_DISCOVERY 0x001C - -#define MGMT_OP_BLOCK_DEVICE 0x001D -struct mgmt_cp_block_device { - bdaddr_t bdaddr; -} __packed; - -#define MGMT_OP_UNBLOCK_DEVICE 0x001E -struct mgmt_cp_unblock_device { - bdaddr_t bdaddr; -} __packed; - -#define MGMT_OP_SET_FAST_CONNECTABLE 0x001F -struct mgmt_cp_set_fast_connectable { - __u8 enable; -} __packed; - -#define MGMT_EV_CMD_COMPLETE 0x0001 -struct mgmt_ev_cmd_complete { - __le16 opcode; - __u8 data[0]; -} __packed; - -#define MGMT_EV_CMD_STATUS 0x0002 -struct mgmt_ev_cmd_status { - __u8 status; - __le16 opcode; -} __packed; - -#define MGMT_EV_CONTROLLER_ERROR 0x0003 -struct mgmt_ev_controller_error { - __u8 error_code; -} __packed; - -#define MGMT_EV_INDEX_ADDED 0x0004 - -#define MGMT_EV_INDEX_REMOVED 0x0005 - -#define MGMT_EV_POWERED 0x0006 - -#define MGMT_EV_DISCOVERABLE 0x0007 - -#define MGMT_EV_CONNECTABLE 0x0008 - -#define MGMT_EV_PAIRABLE 0x0009 - -#define MGMT_EV_NEW_LINK_KEY 0x000A -struct mgmt_ev_new_link_key { - __u8 store_hint; - struct mgmt_link_key_info key; -} __packed; - -#define MGMT_EV_CONNECTED 0x000B - -#define MGMT_EV_DISCONNECTED 0x000C - -#define MGMT_EV_CONNECT_FAILED 0x000D -struct mgmt_ev_connect_failed { - struct mgmt_addr_info addr; - __u8 status; -} __packed; - -#define MGMT_EV_PIN_CODE_REQUEST 0x000E -struct mgmt_ev_pin_code_request { - bdaddr_t bdaddr; - __u8 secure; -} __packed; - -#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F -struct mgmt_ev_user_confirm_request { - bdaddr_t bdaddr; - __u8 confirm_hint; - __le32 value; -} __packed; - -#define MGMT_EV_AUTH_FAILED 0x0010 -struct mgmt_ev_auth_failed { - bdaddr_t bdaddr; - __u8 status; -} __packed; - -#define MGMT_EV_LOCAL_NAME_CHANGED 0x0011 -struct mgmt_ev_local_name_changed { - __u8 name[MGMT_MAX_NAME_LENGTH]; -} __packed; - -#define MGMT_EV_DEVICE_FOUND 0x0012 -struct mgmt_ev_device_found { - struct mgmt_addr_info addr; - __u8 dev_class[3]; - __s8 rssi; - __u8 eir[HCI_MAX_EIR_LENGTH]; -} __packed; - -#define MGMT_EV_REMOTE_NAME 0x0013 -struct mgmt_ev_remote_name { - bdaddr_t bdaddr; - __u8 name[MGMT_MAX_NAME_LENGTH]; -} __packed; - -#define MGMT_EV_DISCOVERING 0x0014 - -#define MGMT_EV_DEVICE_BLOCKED 0x0015 -struct mgmt_ev_device_blocked { - bdaddr_t bdaddr; -} __packed; - -#define MGMT_EV_DEVICE_UNBLOCKED 0x0016 -struct mgmt_ev_device_unblocked { - bdaddr_t bdaddr; -} __packed; diff --git a/include/compat/net/bluetooth/rfcomm.h b/include/compat/net/bluetooth/rfcomm.h deleted file mode 100755 index e2e3eca..0000000 --- a/include/compat/net/bluetooth/rfcomm.h +++ /dev/null @@ -1,372 +0,0 @@ -/* - RFCOMM implementation for Linux Bluetooth stack (BlueZ) - Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com> - Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#ifndef __RFCOMM_H -#define __RFCOMM_H - -#define RFCOMM_PSM 3 - -#define RFCOMM_CONN_TIMEOUT (HZ * 30) -#define RFCOMM_DISC_TIMEOUT (HZ * 20) -#define RFCOMM_AUTH_TIMEOUT (HZ * 25) -#define RFCOMM_IDLE_TIMEOUT (HZ * 2) - -#define RFCOMM_DEFAULT_MTU 127 -#define RFCOMM_DEFAULT_CREDITS 7 - -#define RFCOMM_MAX_L2CAP_MTU 1013 -#define RFCOMM_MAX_CREDITS 40 - -#define RFCOMM_SKB_HEAD_RESERVE 8 -#define RFCOMM_SKB_TAIL_RESERVE 2 -#define RFCOMM_SKB_RESERVE (RFCOMM_SKB_HEAD_RESERVE + RFCOMM_SKB_TAIL_RESERVE) - -#define RFCOMM_SABM 0x2f -#define RFCOMM_DISC 0x43 -#define RFCOMM_UA 0x63 -#define RFCOMM_DM 0x0f -#define RFCOMM_UIH 0xef - -#define RFCOMM_TEST 0x08 -#define RFCOMM_FCON 0x28 -#define RFCOMM_FCOFF 0x18 -#define RFCOMM_MSC 0x38 -#define RFCOMM_RPN 0x24 -#define RFCOMM_RLS 0x14 -#define RFCOMM_PN 0x20 -#define RFCOMM_NSC 0x04 - -#define RFCOMM_V24_FC 0x02 -#define RFCOMM_V24_RTC 0x04 -#define RFCOMM_V24_RTR 0x08 -#define RFCOMM_V24_IC 0x40 -#define RFCOMM_V24_DV 0x80 - -#define RFCOMM_RPN_BR_2400 0x0 -#define RFCOMM_RPN_BR_4800 0x1 -#define RFCOMM_RPN_BR_7200 0x2 -#define RFCOMM_RPN_BR_9600 0x3 -#define RFCOMM_RPN_BR_19200 0x4 -#define RFCOMM_RPN_BR_38400 0x5 -#define RFCOMM_RPN_BR_57600 0x6 -#define RFCOMM_RPN_BR_115200 0x7 -#define RFCOMM_RPN_BR_230400 0x8 - -#define RFCOMM_RPN_DATA_5 0x0 -#define RFCOMM_RPN_DATA_6 0x1 -#define RFCOMM_RPN_DATA_7 0x2 -#define RFCOMM_RPN_DATA_8 0x3 - -#define RFCOMM_RPN_STOP_1 0 -#define RFCOMM_RPN_STOP_15 1 - -#define RFCOMM_RPN_PARITY_NONE 0x0 -#define RFCOMM_RPN_PARITY_ODD 0x1 -#define RFCOMM_RPN_PARITY_EVEN 0x3 -#define RFCOMM_RPN_PARITY_MARK 0x5 -#define RFCOMM_RPN_PARITY_SPACE 0x7 - -#define RFCOMM_RPN_FLOW_NONE 0x00 - -#define RFCOMM_RPN_XON_CHAR 0x11 -#define RFCOMM_RPN_XOFF_CHAR 0x13 - -#define RFCOMM_RPN_PM_BITRATE 0x0001 -#define RFCOMM_RPN_PM_DATA 0x0002 -#define RFCOMM_RPN_PM_STOP 0x0004 -#define RFCOMM_RPN_PM_PARITY 0x0008 -#define RFCOMM_RPN_PM_PARITY_TYPE 0x0010 -#define RFCOMM_RPN_PM_XON 0x0020 -#define RFCOMM_RPN_PM_XOFF 0x0040 -#define RFCOMM_RPN_PM_FLOW 0x3F00 - -#define RFCOMM_RPN_PM_ALL 0x3F7F - -struct rfcomm_hdr { - u8 addr; - u8 ctrl; - u8 len; /* Actual size can be 2 bytes */ -} __packed; - -struct rfcomm_cmd { - u8 addr; - u8 ctrl; - u8 len; - u8 fcs; -} __packed; - -struct rfcomm_mcc { - u8 type; - u8 len; -} __packed; - -struct rfcomm_pn { - u8 dlci; - u8 flow_ctrl; - u8 priority; - u8 ack_timer; - __le16 mtu; - u8 max_retrans; - u8 credits; -} __packed; - -struct rfcomm_rpn { - u8 dlci; - u8 bit_rate; - u8 line_settings; - u8 flow_ctrl; - u8 xon_char; - u8 xoff_char; - __le16 param_mask; -} __packed; - -struct rfcomm_rls { - u8 dlci; - u8 status; -} __packed; - -struct rfcomm_msc { - u8 dlci; - u8 v24_sig; -} __packed; - -/* ---- Core structures, flags etc ---- */ - -struct rfcomm_session { - struct list_head list; - struct socket *sock; - struct timer_list timer; - unsigned long state; - unsigned long flags; - atomic_t refcnt; - int initiator; - - /* Default DLC parameters */ - int cfc; - uint mtu; - - struct list_head dlcs; -}; - -struct rfcomm_dlc { - struct list_head list; - struct rfcomm_session *session; - struct sk_buff_head tx_queue; - struct timer_list timer; - - spinlock_t lock; - unsigned long state; - unsigned long flags; - atomic_t refcnt; - u8 dlci; - u8 addr; - u8 priority; - u8 v24_sig; - u8 remote_v24_sig; - u8 mscex; - u8 out; - u8 sec_level; - u8 role_switch; - u32 defer_setup; - - uint mtu; - uint cfc; - uint rx_credits; - uint tx_credits; - - void *owner; - - void (*data_ready)(struct rfcomm_dlc *d, struct sk_buff *skb); - void (*state_change)(struct rfcomm_dlc *d, int err); - void (*modem_status)(struct rfcomm_dlc *d, u8 v24_sig); -}; - -/* DLC and session flags */ -#define RFCOMM_RX_THROTTLED 0 -#define RFCOMM_TX_THROTTLED 1 -#define RFCOMM_TIMED_OUT 2 -#define RFCOMM_MSC_PENDING 3 -#define RFCOMM_SEC_PENDING 4 -#define RFCOMM_AUTH_PENDING 5 -#define RFCOMM_AUTH_ACCEPT 6 -#define RFCOMM_AUTH_REJECT 7 -#define RFCOMM_DEFER_SETUP 8 -#define RFCOMM_ENC_DROP 9 - -/* Scheduling flags and events */ -#define RFCOMM_SCHED_WAKEUP 31 - -/* MSC exchange flags */ -#define RFCOMM_MSCEX_TX 1 -#define RFCOMM_MSCEX_RX 2 -#define RFCOMM_MSCEX_OK (RFCOMM_MSCEX_TX + RFCOMM_MSCEX_RX) - -/* CFC states */ -#define RFCOMM_CFC_UNKNOWN -1 -#define RFCOMM_CFC_DISABLED 0 -#define RFCOMM_CFC_ENABLED RFCOMM_MAX_CREDITS - -/* ---- RFCOMM SEND RPN ---- */ -int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, - u8 bit_rate, u8 data_bits, u8 stop_bits, - u8 parity, u8 flow_ctrl_settings, - u8 xon_char, u8 xoff_char, u16 param_mask); - -/* ---- RFCOMM DLCs (channels) ---- */ -struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio); -void rfcomm_dlc_free(struct rfcomm_dlc *d); -int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, - u8 channel); -int rfcomm_dlc_close(struct rfcomm_dlc *d, int reason); -int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb); -int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig); -int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig); -void rfcomm_dlc_accept(struct rfcomm_dlc *d); - -#define rfcomm_dlc_lock(d) spin_lock(&d->lock) -#define rfcomm_dlc_unlock(d) spin_unlock(&d->lock) - -static inline void rfcomm_dlc_hold(struct rfcomm_dlc *d) -{ - atomic_inc(&d->refcnt); -} - -static inline void rfcomm_dlc_put(struct rfcomm_dlc *d) -{ - if (atomic_dec_and_test(&d->refcnt)) - rfcomm_dlc_free(d); -} - -extern void __rfcomm_dlc_throttle(struct rfcomm_dlc *d); -extern void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d); - -static inline void rfcomm_dlc_throttle(struct rfcomm_dlc *d) -{ - if (!test_and_set_bit(RFCOMM_RX_THROTTLED, &d->flags)) - __rfcomm_dlc_throttle(d); -} - -static inline void rfcomm_dlc_unthrottle(struct rfcomm_dlc *d) -{ - if (test_and_clear_bit(RFCOMM_RX_THROTTLED, &d->flags)) - __rfcomm_dlc_unthrottle(d); -} - -/* ---- RFCOMM sessions ---- */ -void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, - bdaddr_t *dst); - -static inline void rfcomm_session_hold(struct rfcomm_session *s) -{ - atomic_inc(&s->refcnt); -} - -/* ---- RFCOMM sockets ---- */ -struct sockaddr_rc { - sa_family_t rc_family; - bdaddr_t rc_bdaddr; - u8 rc_channel; -}; - -#define RFCOMM_CONNINFO 0x02 -struct rfcomm_conninfo { - __u16 hci_handle; - __u8 dev_class[3]; -}; - -#define RFCOMM_LM 0x03 -#define RFCOMM_LM_MASTER 0x0001 -#define RFCOMM_LM_AUTH 0x0002 -#define RFCOMM_LM_ENCRYPT 0x0004 -#define RFCOMM_LM_TRUSTED 0x0008 -#define RFCOMM_LM_RELIABLE 0x0010 -#define RFCOMM_LM_SECURE 0x0020 - -#define rfcomm_pi(sk) ((struct rfcomm_pinfo *) sk) - -struct rfcomm_pinfo { - struct bt_sock bt; - struct rfcomm_dlc *dlc; - u8 channel; - u8 sec_level; - u8 role_switch; -}; - -int rfcomm_init_sockets(void); -void rfcomm_cleanup_sockets(void); - -int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, - struct rfcomm_dlc **d); - -/* ---- RFCOMM TTY ---- */ -#define RFCOMM_MAX_DEV 256 - -#define RFCOMMCREATEDEV _IOW('R', 200, int) -#define RFCOMMRELEASEDEV _IOW('R', 201, int) -#define RFCOMMGETDEVLIST _IOR('R', 210, int) -#define RFCOMMGETDEVINFO _IOR('R', 211, int) -#define RFCOMMSTEALDLC _IOW('R', 220, int) - -#define RFCOMM_REUSE_DLC 0 -#define RFCOMM_RELEASE_ONHUP 1 -#define RFCOMM_HANGUP_NOW 2 -#define RFCOMM_TTY_ATTACHED 3 -#define RFCOMM_TTY_RELEASED 4 - -struct rfcomm_dev_req { - s16 dev_id; - u32 flags; - bdaddr_t src; - bdaddr_t dst; - u8 channel; -}; - -struct rfcomm_dev_info { - s16 id; - u32 flags; - u16 state; - bdaddr_t src; - bdaddr_t dst; - u8 channel; -}; - -struct rfcomm_dev_list_req { - u16 dev_num; - struct rfcomm_dev_info dev_info[0]; -}; - -int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); - -#ifdef CONFIG_BT_RFCOMM_TTY -int rfcomm_init_ttys(void); -void rfcomm_cleanup_ttys(void); -#else -static inline int rfcomm_init_ttys(void) -{ - return 0; -} -static inline void rfcomm_cleanup_ttys(void) -{ -} -#endif -#endif /* __RFCOMM_H */ diff --git a/include/compat/net/bluetooth/smp.h b/include/compat/net/bluetooth/smp.h deleted file mode 100755 index 15b97d5..0000000 --- a/include/compat/net/bluetooth/smp.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#ifndef __SMP_H -#define __SMP_H - -struct smp_command_hdr { - __u8 code; -} __packed; - -#define SMP_CMD_PAIRING_REQ 0x01 -#define SMP_CMD_PAIRING_RSP 0x02 -struct smp_cmd_pairing { - __u8 io_capability; - __u8 oob_flag; - __u8 auth_req; - __u8 max_key_size; - __u8 init_key_dist; - __u8 resp_key_dist; -} __packed; - -#define SMP_IO_DISPLAY_ONLY 0x00 -#define SMP_IO_DISPLAY_YESNO 0x01 -#define SMP_IO_KEYBOARD_ONLY 0x02 -#define SMP_IO_NO_INPUT_OUTPUT 0x03 -#define SMP_IO_KEYBOARD_DISPLAY 0x04 - -#define SMP_OOB_NOT_PRESENT 0x00 -#define SMP_OOB_PRESENT 0x01 - -#define SMP_DIST_ENC_KEY 0x01 -#define SMP_DIST_ID_KEY 0x02 -#define SMP_DIST_SIGN 0x04 - -#define SMP_AUTH_NONE 0x00 -#define SMP_AUTH_BONDING 0x01 -#define SMP_AUTH_MITM 0x04 - -#define SMP_CMD_PAIRING_CONFIRM 0x03 -struct smp_cmd_pairing_confirm { - __u8 confirm_val[16]; -} __packed; - -#define SMP_CMD_PAIRING_RANDOM 0x04 -struct smp_cmd_pairing_random { - __u8 rand_val[16]; -} __packed; - -#define SMP_CMD_PAIRING_FAIL 0x05 -struct smp_cmd_pairing_fail { - __u8 reason; -} __packed; - -#define SMP_CMD_ENCRYPT_INFO 0x06 -struct smp_cmd_encrypt_info { - __u8 ltk[16]; -} __packed; - -#define SMP_CMD_MASTER_IDENT 0x07 -struct smp_cmd_master_ident { - __u16 ediv; - __u8 rand[8]; -} __packed; - -#define SMP_CMD_IDENT_INFO 0x08 -struct smp_cmd_ident_info { - __u8 irk[16]; -} __packed; - -#define SMP_CMD_IDENT_ADDR_INFO 0x09 -struct smp_cmd_ident_addr_info { - __u8 addr_type; - bdaddr_t bdaddr; -} __packed; - -#define SMP_CMD_SIGN_INFO 0x0a -struct smp_cmd_sign_info { - __u8 csrk[16]; -} __packed; - -#define SMP_CMD_SECURITY_REQ 0x0b -struct smp_cmd_security_req { - __u8 auth_req; -} __packed; - -#define SMP_PASSKEY_ENTRY_FAILED 0x01 -#define SMP_OOB_NOT_AVAIL 0x02 -#define SMP_AUTH_REQUIREMENTS 0x03 -#define SMP_CONFIRM_FAILED 0x04 -#define SMP_PAIRING_NOTSUPP 0x05 -#define SMP_ENC_KEY_SIZE 0x06 -#define SMP_CMD_NOTSUPP 0x07 -#define SMP_UNSPECIFIED 0x08 -#define SMP_REPEATED_ATTEMPTS 0x09 - -#define SMP_MIN_ENC_KEY_SIZE 7 -#define SMP_MAX_ENC_KEY_SIZE 16 - -struct smp_chan { - struct l2cap_conn *conn; - u8 preq[7]; /* SMP Pairing Request */ - u8 prsp[7]; /* SMP Pairing Response */ - u8 prnd[16]; /* SMP Pairing Random (local) */ - u8 rrnd[16]; /* SMP Pairing Random (remote) */ - u8 pcnf[16]; /* SMP Pairing Confirm */ - u8 tk[16]; /* SMP Temporary Key */ - u8 smp_key_size; - struct crypto_blkcipher *tfm; - struct work_struct confirm; - struct work_struct random; - -}; - -/* SMP Commands */ -int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level); -int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb); -int smp_distribute_keys(struct l2cap_conn *conn, __u8 force); - -void smp_chan_destroy(struct l2cap_conn *conn); - -#endif /* __SMP_H */ diff --git a/include/compat/net/cfg80211-wext.h b/include/compat/net/cfg80211-wext.h deleted file mode 100755 index 25baddc..0000000 --- a/include/compat/net/cfg80211-wext.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __NET_CFG80211_WEXT_H -#define __NET_CFG80211_WEXT_H -/* - * 802.11 device and configuration interface -- wext handlers - * - * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include <linux/netdevice.h> -#include <linux/wireless.h> -#include <net/iw_handler.h> - -/* - * Temporary wext handlers & helper functions - * - * These are used only by drivers that aren't yet fully - * converted to cfg80211. - */ -int cfg80211_wext_giwname(struct net_device *dev, - struct iw_request_info *info, - char *name, char *extra); -int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info, - u32 *mode, char *extra); -int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info, - u32 *mode, char *extra); -int cfg80211_wext_siwscan(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); -int cfg80211_wext_giwscan(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *data, char *extra); -int cfg80211_wext_giwrange(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *data, char *extra); -int cfg80211_wext_siwrts(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *rts, char *extra); -int cfg80211_wext_giwrts(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *rts, char *extra); -int cfg80211_wext_siwfrag(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *frag, char *extra); -int cfg80211_wext_giwfrag(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *frag, char *extra); -int cfg80211_wext_giwretry(struct net_device *dev, - struct iw_request_info *info, - struct iw_param *retry, char *extra); - -#endif /* __NET_CFG80211_WEXT_H */ diff --git a/include/compat/net/cfg80211.h b/include/compat/net/cfg80211.h deleted file mode 100755 index a5ac8ff..0000000 --- a/include/compat/net/cfg80211.h +++ /dev/null @@ -1,3417 +0,0 @@ -#ifndef __NET_CFG80211_H -#define __NET_CFG80211_H -/* - * 802.11 device and configuration interface - * - * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include <linux/netdevice.h> -#include <linux/debugfs.h> -#include <linux/list.h> -#include <linux/netlink.h> -#include <linux/skbuff.h> -#include <linux/nl80211.h> -#include <linux/if_ether.h> -#include <linux/ieee80211.h> -#include <net/regulatory.h> - -/** - * DOC: Introduction - * - * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges - * userspace and drivers, and offers some utility functionality associated - * with 802.11. cfg80211 must, directly or indirectly via mac80211, be used - * by all modern wireless drivers in Linux, so that they offer a consistent - * API through nl80211. For backward compatibility, cfg80211 also offers - * wireless extensions to userspace, but hides them from drivers completely. - * - * Additionally, cfg80211 contains code to help enforce regulatory spectrum - * use restrictions. - */ - - -/** - * DOC: Device registration - * - * In order for a driver to use cfg80211, it must register the hardware device - * with cfg80211. This happens through a number of hardware capability structs - * described below. - * - * The fundamental structure for each device is the 'wiphy', of which each - * instance describes a physical wireless device connected to the system. Each - * such wiphy can have zero, one, or many virtual interfaces associated with - * it, which need to be identified as such by pointing the network interface's - * @ieee80211_ptr pointer to a &struct wireless_dev which further describes - * the wireless part of the interface, normally this struct is embedded in the - * network interface's private data area. Drivers can optionally allow creating - * or destroying virtual interfaces on the fly, but without at least one or the - * ability to create some the wireless device isn't useful. - * - * Each wiphy structure contains device capability information, and also has - * a pointer to the various operations the driver offers. The definitions and - * structures here describe these capabilities in detail. - */ - -/* - * wireless hardware capability structures - */ - -/** - * enum ieee80211_band - supported frequency bands - * - * The bands are assigned this way because the supported - * bitrates differ in these bands. - * - * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band - * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7) - * @IEEE80211_NUM_BANDS: number of defined bands - */ -enum ieee80211_band { - IEEE80211_BAND_2GHZ = NL80211_BAND_2GHZ, - IEEE80211_BAND_5GHZ = NL80211_BAND_5GHZ, - - /* keep last */ - IEEE80211_NUM_BANDS -}; - -/** - * enum ieee80211_channel_flags - channel flags - * - * Channel flags set by the regulatory control code. - * - * @IEEE80211_CHAN_DISABLED: This channel is disabled. - * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted - * on this channel. - * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. - * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel. - * @IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel - * is not permitted. - * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel - * is not permitted. - */ -enum ieee80211_channel_flags { - IEEE80211_CHAN_DISABLED = 1<<0, - IEEE80211_CHAN_PASSIVE_SCAN = 1<<1, - IEEE80211_CHAN_NO_IBSS = 1<<2, - IEEE80211_CHAN_RADAR = 1<<3, - IEEE80211_CHAN_NO_HT40PLUS = 1<<4, - IEEE80211_CHAN_NO_HT40MINUS = 1<<5, -}; - -#define IEEE80211_CHAN_NO_HT40 \ - (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) - -/** - * struct ieee80211_channel - channel definition - * - * This structure describes a single channel for use - * with cfg80211. - * - * @center_freq: center frequency in MHz - * @hw_value: hardware-specific value for the channel - * @flags: channel flags from &enum ieee80211_channel_flags. - * @orig_flags: channel flags at registration time, used by regulatory - * code to support devices with additional restrictions - * @band: band this channel belongs to. - * @max_antenna_gain: maximum antenna gain in dBi - * @max_power: maximum transmission power (in dBm) - * @beacon_found: helper to regulatory code to indicate when a beacon - * has been found on this channel. Use regulatory_hint_found_beacon() - * to enable this, this is useful only on 5 GHz band. - * @orig_mag: internal use - * @orig_mpwr: internal use - */ -struct ieee80211_channel { - enum ieee80211_band band; - u16 center_freq; - u16 hw_value; - u32 flags; - int max_antenna_gain; - int max_power; - bool beacon_found; - u32 orig_flags; - int orig_mag, orig_mpwr; -}; - -/** - * enum ieee80211_rate_flags - rate flags - * - * Hardware/specification flags for rates. These are structured - * in a way that allows using the same bitrate structure for - * different bands/PHY modes. - * - * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short - * preamble on this bitrate; only relevant in 2.4GHz band and - * with CCK rates. - * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate - * when used with 802.11a (on the 5 GHz band); filled by the - * core code when registering the wiphy. - * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate - * when used with 802.11b (on the 2.4 GHz band); filled by the - * core code when registering the wiphy. - * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate - * when used with 802.11g (on the 2.4 GHz band); filled by the - * core code when registering the wiphy. - * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode. - */ -enum ieee80211_rate_flags { - IEEE80211_RATE_SHORT_PREAMBLE = 1<<0, - IEEE80211_RATE_MANDATORY_A = 1<<1, - IEEE80211_RATE_MANDATORY_B = 1<<2, - IEEE80211_RATE_MANDATORY_G = 1<<3, - IEEE80211_RATE_ERP_G = 1<<4, -}; - -/** - * struct ieee80211_rate - bitrate definition - * - * This structure describes a bitrate that an 802.11 PHY can - * operate with. The two values @hw_value and @hw_value_short - * are only for driver use when pointers to this structure are - * passed around. - * - * @flags: rate-specific flags - * @bitrate: bitrate in units of 100 Kbps - * @hw_value: driver/hardware value for this rate - * @hw_value_short: driver/hardware value for this rate when - * short preamble is used - */ -struct ieee80211_rate { - u32 flags; - u16 bitrate; - u16 hw_value, hw_value_short; -}; - -/** - * struct ieee80211_sta_ht_cap - STA's HT capabilities - * - * This structure describes most essential parameters needed - * to describe 802.11n HT capabilities for an STA. - * - * @ht_supported: is HT supported by the STA - * @cap: HT capabilities map as described in 802.11n spec - * @ampdu_factor: Maximum A-MPDU length factor - * @ampdu_density: Minimum A-MPDU spacing - * @mcs: Supported MCS rates - */ -struct ieee80211_sta_ht_cap { - u16 cap; /* use IEEE80211_HT_CAP_ */ - bool ht_supported; - u8 ampdu_factor; - u8 ampdu_density; - struct ieee80211_mcs_info mcs; -}; - -/** - * struct ieee80211_supported_band - frequency band definition - * - * This structure describes a frequency band a wiphy - * is able to operate in. - * - * @channels: Array of channels the hardware can operate in - * in this band. - * @band: the band this structure represents - * @n_channels: Number of channels in @channels - * @bitrates: Array of bitrates the hardware can operate with - * in this band. Must be sorted to give a valid "supported - * rates" IE, i.e. CCK rates first, then OFDM. - * @n_bitrates: Number of bitrates in @bitrates - * @ht_cap: HT capabilities in this band - */ -struct ieee80211_supported_band { - struct ieee80211_channel *channels; - struct ieee80211_rate *bitrates; - enum ieee80211_band band; - int n_channels; - int n_bitrates; - struct ieee80211_sta_ht_cap ht_cap; -}; - -/* - * Wireless hardware/device configuration structures and methods - */ - -/** - * DOC: Actions and configuration - * - * Each wireless device and each virtual interface offer a set of configuration - * operations and other actions that are invoked by userspace. Each of these - * actions is described in the operations structure, and the parameters these - * operations use are described separately. - * - * Additionally, some operations are asynchronous and expect to get status - * information via some functions that drivers need to call. - * - * Scanning and BSS list handling with its associated functionality is described - * in a separate chapter. - */ - -/** - * struct vif_params - describes virtual interface parameters - * @use_4addr: use 4-address frames - */ -struct vif_params { - int use_4addr; -}; - -/** - * struct key_params - key information - * - * Information about a key - * - * @key: key material - * @key_len: length of key material - * @cipher: cipher suite selector - * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used - * with the get_key() callback, must be in little endian, - * length given by @seq_len. - * @seq_len: length of @seq. - */ -struct key_params { - u8 *key; - u8 *seq; - int key_len; - int seq_len; - u32 cipher; -}; - -/** - * enum survey_info_flags - survey information flags - * - * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in - * @SURVEY_INFO_IN_USE: channel is currently being used - * @SURVEY_INFO_CHANNEL_TIME: channel active time (in ms) was filled in - * @SURVEY_INFO_CHANNEL_TIME_BUSY: channel busy time was filled in - * @SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: extension channel busy time was filled in - * @SURVEY_INFO_CHANNEL_TIME_RX: channel receive time was filled in - * @SURVEY_INFO_CHANNEL_TIME_TX: channel transmit time was filled in - * - * Used by the driver to indicate which info in &struct survey_info - * it has filled in during the get_survey(). - */ -enum survey_info_flags { - SURVEY_INFO_NOISE_DBM = 1<<0, - SURVEY_INFO_IN_USE = 1<<1, - SURVEY_INFO_CHANNEL_TIME = 1<<2, - SURVEY_INFO_CHANNEL_TIME_BUSY = 1<<3, - SURVEY_INFO_CHANNEL_TIME_EXT_BUSY = 1<<4, - SURVEY_INFO_CHANNEL_TIME_RX = 1<<5, - SURVEY_INFO_CHANNEL_TIME_TX = 1<<6, -}; - -/** - * struct survey_info - channel survey response - * - * @channel: the channel this survey record reports, mandatory - * @filled: bitflag of flags from &enum survey_info_flags - * @noise: channel noise in dBm. This and all following fields are - * optional - * @channel_time: amount of time in ms the radio spent on the channel - * @channel_time_busy: amount of time the primary channel was sensed busy - * @channel_time_ext_busy: amount of time the extension channel was sensed busy - * @channel_time_rx: amount of time the radio spent receiving data - * @channel_time_tx: amount of time the radio spent transmitting data - * - * Used by dump_survey() to report back per-channel survey information. - * - * This structure can later be expanded with things like - * channel duty cycle etc. - */ -struct survey_info { - struct ieee80211_channel *channel; - u64 channel_time; - u64 channel_time_busy; - u64 channel_time_ext_busy; - u64 channel_time_rx; - u64 channel_time_tx; - u32 filled; - s8 noise; -}; - -/** - * struct cfg80211_crypto_settings - Crypto settings - * @wpa_versions: indicates which, if any, WPA versions are enabled - * (from enum nl80211_wpa_versions) - * @cipher_group: group key cipher suite (or 0 if unset) - * @n_ciphers_pairwise: number of AP supported unicast ciphers - * @ciphers_pairwise: unicast key cipher suites - * @n_akm_suites: number of AKM suites - * @akm_suites: AKM suites - * @control_port: Whether user space controls IEEE 802.1X port, i.e., - * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is - * required to assume that the port is unauthorized until authorized by - * user space. Otherwise, port is marked authorized by default. - * @control_port_ethertype: the control port protocol that should be - * allowed through even on unauthorized ports - * @control_port_no_encrypt: TRUE to prevent encryption of control port - * protocol frames. - */ -struct cfg80211_crypto_settings { - u32 wpa_versions; - u32 cipher_group; - int n_ciphers_pairwise; - u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES]; - int n_akm_suites; - u32 akm_suites[NL80211_MAX_NR_AKM_SUITES]; - bool control_port; - __be16 control_port_ethertype; - bool control_port_no_encrypt; -}; - -/** - * struct beacon_parameters - beacon parameters - * - * Used to configure the beacon for an interface. - * - * @head: head portion of beacon (before TIM IE) - * or %NULL if not changed - * @tail: tail portion of beacon (after TIM IE) - * or %NULL if not changed - * @interval: beacon interval or zero if not changed - * @dtim_period: DTIM period or zero if not changed - * @head_len: length of @head - * @tail_len: length of @tail - * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from - * user space) - * @ssid_len: length of @ssid - * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames - * @crypto: crypto settings - * @privacy: the BSS uses privacy - * @auth_type: Authentication type (algorithm) - * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL - * @beacon_ies_len: length of beacon_ies in octets - * @proberesp_ies: extra information element(s) to add into Probe Response - * frames or %NULL - * @proberesp_ies_len: length of proberesp_ies in octets - * @assocresp_ies: extra information element(s) to add into (Re)Association - * Response frames or %NULL - * @assocresp_ies_len: length of assocresp_ies in octets - * @probe_resp_len: length of probe response template (@probe_resp) - * @probe_resp: probe response template (AP mode only) - */ -struct beacon_parameters { - u8 *head, *tail; - int interval, dtim_period; - int head_len, tail_len; - const u8 *ssid; - size_t ssid_len; - enum nl80211_hidden_ssid hidden_ssid; - struct cfg80211_crypto_settings crypto; - bool privacy; - enum nl80211_auth_type auth_type; - const u8 *beacon_ies; - size_t beacon_ies_len; - const u8 *proberesp_ies; - size_t proberesp_ies_len; - const u8 *assocresp_ies; - size_t assocresp_ies_len; - int probe_resp_len; - u8 *probe_resp; -}; - -/** - * enum plink_action - actions to perform in mesh peers - * - * @PLINK_ACTION_INVALID: action 0 is reserved - * @PLINK_ACTION_OPEN: start mesh peer link establishment - * @PLINK_ACTION_BLOCK: block traffic from this mesh peer - */ -enum plink_actions { - PLINK_ACTION_INVALID, - PLINK_ACTION_OPEN, - PLINK_ACTION_BLOCK, -}; - -/** - * enum station_parameters_apply_mask - station parameter values to apply - * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp) - * - * Not all station parameters have in-band "no change" signalling, - * for those that don't these flags will are used. - */ -enum station_parameters_apply_mask { - STATION_PARAM_APPLY_UAPSD = BIT(0), -}; - -/** - * struct station_parameters - station parameters - * - * Used to change and create a new station. - * - * @vlan: vlan interface station should belong to - * @supported_rates: supported rates in IEEE 802.11 format - * (or NULL for no change) - * @supported_rates_len: number of supported rates - * @sta_flags_mask: station flags that changed - * (bitmask of BIT(NL80211_STA_FLAG_...)) - * @sta_flags_set: station flags values - * (bitmask of BIT(NL80211_STA_FLAG_...)) - * @listen_interval: listen interval or -1 for no change - * @aid: AID or zero for no change - * @plink_action: plink action to take - * @plink_state: set the peer link state for a station - * @ht_capa: HT capabilities of station - * @uapsd_queues: bitmap of queues configured for uapsd. same format - * as the AC bitmap in the QoS info field - * @max_sp: max Service Period. same format as the MAX_SP in the - * QoS info field (but already shifted down) - * @sta_modify_mask: bitmap indicating which parameters changed - * (for those that don't have a natural "no change" value), - * see &enum station_parameters_apply_mask - */ -struct station_parameters { - u8 *supported_rates; - struct net_device *vlan; - u32 sta_flags_mask, sta_flags_set; - u32 sta_modify_mask; - int listen_interval; - u16 aid; - u8 supported_rates_len; - u8 plink_action; - u8 plink_state; - struct ieee80211_ht_cap *ht_capa; - u8 uapsd_queues; - u8 max_sp; -}; - -/** - * enum station_info_flags - station information flags - * - * Used by the driver to indicate which info in &struct station_info - * it has filled in during get_station() or dump_station(). - * - * @STATION_INFO_INACTIVE_TIME: @inactive_time filled - * @STATION_INFO_RX_BYTES: @rx_bytes filled - * @STATION_INFO_TX_BYTES: @tx_bytes filled - * @STATION_INFO_LLID: @llid filled - * @STATION_INFO_PLID: @plid filled - * @STATION_INFO_PLINK_STATE: @plink_state filled - * @STATION_INFO_SIGNAL: @signal filled - * @STATION_INFO_TX_BITRATE: @txrate fields are filled - * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs) - * @STATION_INFO_RX_PACKETS: @rx_packets filled - * @STATION_INFO_TX_PACKETS: @tx_packets filled - * @STATION_INFO_TX_RETRIES: @tx_retries filled - * @STATION_INFO_TX_FAILED: @tx_failed filled - * @STATION_INFO_RX_DROP_MISC: @rx_dropped_misc filled - * @STATION_INFO_SIGNAL_AVG: @signal_avg filled - * @STATION_INFO_RX_BITRATE: @rxrate fields are filled - * @STATION_INFO_BSS_PARAM: @bss_param filled - * @STATION_INFO_CONNECTED_TIME: @connected_time filled - * @STATION_INFO_ASSOC_REQ_IES: @assoc_req_ies filled - * @STATION_INFO_STA_FLAGS: @sta_flags filled - */ -enum station_info_flags { - STATION_INFO_INACTIVE_TIME = 1<<0, - STATION_INFO_RX_BYTES = 1<<1, - STATION_INFO_TX_BYTES = 1<<2, - STATION_INFO_LLID = 1<<3, - STATION_INFO_PLID = 1<<4, - STATION_INFO_PLINK_STATE = 1<<5, - STATION_INFO_SIGNAL = 1<<6, - STATION_INFO_TX_BITRATE = 1<<7, - STATION_INFO_RX_PACKETS = 1<<8, - STATION_INFO_TX_PACKETS = 1<<9, - STATION_INFO_TX_RETRIES = 1<<10, - STATION_INFO_TX_FAILED = 1<<11, - STATION_INFO_RX_DROP_MISC = 1<<12, - STATION_INFO_SIGNAL_AVG = 1<<13, - STATION_INFO_RX_BITRATE = 1<<14, - STATION_INFO_BSS_PARAM = 1<<15, - STATION_INFO_CONNECTED_TIME = 1<<16, - STATION_INFO_ASSOC_REQ_IES = 1<<17, - STATION_INFO_STA_FLAGS = 1<<18 -}; - -/** - * enum station_info_rate_flags - bitrate info flags - * - * Used by the driver to indicate the specific rate transmission - * type for 802.11n transmissions. - * - * @RATE_INFO_FLAGS_MCS: @tx_bitrate_mcs filled - * @RATE_INFO_FLAGS_40_MHZ_WIDTH: 40 Mhz width transmission - * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval - */ -enum rate_info_flags { - RATE_INFO_FLAGS_MCS = 1<<0, - RATE_INFO_FLAGS_40_MHZ_WIDTH = 1<<1, - RATE_INFO_FLAGS_SHORT_GI = 1<<2, -}; - -/** - * struct rate_info - bitrate information - * - * Information about a receiving or transmitting bitrate - * - * @flags: bitflag of flags from &enum rate_info_flags - * @mcs: mcs index if struct describes a 802.11n bitrate - * @legacy: bitrate in 100kbit/s for 802.11abg - */ -struct rate_info { - u8 flags; - u8 mcs; - u16 legacy; -}; - -/** - * enum station_info_rate_flags - bitrate info flags - * - * Used by the driver to indicate the specific rate transmission - * type for 802.11n transmissions. - * - * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled - * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled - * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled - */ -enum bss_param_flags { - BSS_PARAM_FLAGS_CTS_PROT = 1<<0, - BSS_PARAM_FLAGS_SHORT_PREAMBLE = 1<<1, - BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 1<<2, -}; - -/** - * struct sta_bss_parameters - BSS parameters for the attached station - * - * Information about the currently associated BSS - * - * @flags: bitflag of flags from &enum bss_param_flags - * @dtim_period: DTIM period for the BSS - * @beacon_interval: beacon interval - */ -struct sta_bss_parameters { - u8 flags; - u8 dtim_period; - u16 beacon_interval; -}; - -/** - * struct station_info - station information - * - * Station information filled by driver for get_station() and dump_station. - * - * @filled: bitflag of flags from &enum station_info_flags - * @connected_time: time(in secs) since a station is last connected - * @inactive_time: time since last station activity (tx/rx) in milliseconds - * @rx_bytes: bytes received from this station - * @tx_bytes: bytes transmitted to this station - * @llid: mesh local link id - * @plid: mesh peer link id - * @plink_state: mesh peer link state - * @signal: signal strength of last received packet in dBm - * @signal_avg: signal strength average in dBm - * @txrate: current unicast bitrate from this station - * @rxrate: current unicast bitrate to this station - * @rx_packets: packets received from this station - * @tx_packets: packets transmitted to this station - * @tx_retries: cumulative retry counts - * @tx_failed: number of failed transmissions (retries exceeded, no ACK) - * @rx_dropped_misc: Dropped for un-specified reason. - * @bss_param: current BSS parameters - * @generation: generation number for nl80211 dumps. - * This number should increase every time the list of stations - * changes, i.e. when a station is added or removed, so that - * userspace can tell whether it got a consistent snapshot. - * @assoc_req_ies: IEs from (Re)Association Request. - * This is used only when in AP mode with drivers that do not use - * user space MLME/SME implementation. The information is provided for - * the cfg80211_new_sta() calls to notify user space of the IEs. - * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets. - * @sta_flags: station flags mask & values - */ -struct station_info { - u32 filled; - u32 connected_time; - u32 inactive_time; - u32 rx_bytes; - u32 tx_bytes; - u16 llid; - u16 plid; - u8 plink_state; - s8 signal; - s8 signal_avg; - struct rate_info txrate; - struct rate_info rxrate; - u32 rx_packets; - u32 tx_packets; - u32 tx_retries; - u32 tx_failed; - u32 rx_dropped_misc; - struct sta_bss_parameters bss_param; - struct nl80211_sta_flag_update sta_flags; - - int generation; - - const u8 *assoc_req_ies; - size_t assoc_req_ies_len; - - /* - * Note: Add a new enum station_info_flags value for each new field and - * use it to check which fields are initialized. - */ -}; - -/** - * enum monitor_flags - monitor flags - * - * Monitor interface configuration flags. Note that these must be the bits - * according to the nl80211 flags. - * - * @MONITOR_FLAG_FCSFAIL: pass frames with bad FCS - * @MONITOR_FLAG_PLCPFAIL: pass frames with bad PLCP - * @MONITOR_FLAG_CONTROL: pass control frames - * @MONITOR_FLAG_OTHER_BSS: disable BSSID filtering - * @MONITOR_FLAG_COOK_FRAMES: report frames after processing - */ -enum monitor_flags { - MONITOR_FLAG_FCSFAIL = 1<<NL80211_MNTR_FLAG_FCSFAIL, - MONITOR_FLAG_PLCPFAIL = 1<<NL80211_MNTR_FLAG_PLCPFAIL, - MONITOR_FLAG_CONTROL = 1<<NL80211_MNTR_FLAG_CONTROL, - MONITOR_FLAG_OTHER_BSS = 1<<NL80211_MNTR_FLAG_OTHER_BSS, - MONITOR_FLAG_COOK_FRAMES = 1<<NL80211_MNTR_FLAG_COOK_FRAMES, -}; - -/** - * enum mpath_info_flags - mesh path information flags - * - * Used by the driver to indicate which info in &struct mpath_info it has filled - * in during get_station() or dump_station(). - * - * @MPATH_INFO_FRAME_QLEN: @frame_qlen filled - * @MPATH_INFO_SN: @sn filled - * @MPATH_INFO_METRIC: @metric filled - * @MPATH_INFO_EXPTIME: @exptime filled - * @MPATH_INFO_DISCOVERY_TIMEOUT: @discovery_timeout filled - * @MPATH_INFO_DISCOVERY_RETRIES: @discovery_retries filled - * @MPATH_INFO_FLAGS: @flags filled - */ -enum mpath_info_flags { - MPATH_INFO_FRAME_QLEN = BIT(0), - MPATH_INFO_SN = BIT(1), - MPATH_INFO_METRIC = BIT(2), - MPATH_INFO_EXPTIME = BIT(3), - MPATH_INFO_DISCOVERY_TIMEOUT = BIT(4), - MPATH_INFO_DISCOVERY_RETRIES = BIT(5), - MPATH_INFO_FLAGS = BIT(6), -}; - -/** - * struct mpath_info - mesh path information - * - * Mesh path information filled by driver for get_mpath() and dump_mpath(). - * - * @filled: bitfield of flags from &enum mpath_info_flags - * @frame_qlen: number of queued frames for this destination - * @sn: target sequence number - * @metric: metric (cost) of this mesh path - * @exptime: expiration time for the mesh path from now, in msecs - * @flags: mesh path flags - * @discovery_timeout: total mesh path discovery timeout, in msecs - * @discovery_retries: mesh path discovery retries - * @generation: generation number for nl80211 dumps. - * This number should increase every time the list of mesh paths - * changes, i.e. when a station is added or removed, so that - * userspace can tell whether it got a consistent snapshot. - */ -struct mpath_info { - u32 filled; - u32 frame_qlen; - u32 sn; - u32 metric; - u32 exptime; - u32 discovery_timeout; - u8 discovery_retries; - u8 flags; - - int generation; -}; - -/** - * struct bss_parameters - BSS parameters - * - * Used to change BSS parameters (mainly for AP mode). - * - * @use_cts_prot: Whether to use CTS protection - * (0 = no, 1 = yes, -1 = do not change) - * @use_short_preamble: Whether the use of short preambles is allowed - * (0 = no, 1 = yes, -1 = do not change) - * @use_short_slot_time: Whether the use of short slot time is allowed - * (0 = no, 1 = yes, -1 = do not change) - * @basic_rates: basic rates in IEEE 802.11 format - * (or NULL for no change) - * @basic_rates_len: number of basic rates - * @ap_isolate: do not forward packets between connected stations - * @ht_opmode: HT Operation mode - * (u16 = opmode, -1 = do not change) - */ -struct bss_parameters { - int use_cts_prot; - int use_short_preamble; - int use_short_slot_time; - u8 *basic_rates; - u8 basic_rates_len; - int ap_isolate; - int ht_opmode; -}; - -/* - * struct mesh_config - 802.11s mesh configuration - * - * These parameters can be changed while the mesh is active. - */ -struct mesh_config { - /* Timeouts in ms */ - /* Mesh plink management parameters */ - u16 dot11MeshRetryTimeout; - u16 dot11MeshConfirmTimeout; - u16 dot11MeshHoldingTimeout; - u16 dot11MeshMaxPeerLinks; - u8 dot11MeshMaxRetries; - u8 dot11MeshTTL; - /* ttl used in path selection information elements */ - u8 element_ttl; - bool auto_open_plinks; - /* HWMP parameters */ - u8 dot11MeshHWMPmaxPREQretries; - u32 path_refresh_time; - u16 min_discovery_timeout; - u32 dot11MeshHWMPactivePathTimeout; - u16 dot11MeshHWMPpreqMinInterval; - u16 dot11MeshHWMPnetDiameterTraversalTime; - u8 dot11MeshHWMPRootMode; - u16 dot11MeshHWMPRannInterval; - /* This is missnamed in draft 12.0: dot11MeshGateAnnouncementProtocol - * set to true only means that the station will announce others it's a - * mesh gate, but not necessarily using the gate announcement protocol. - * Still keeping the same nomenclature to be in sync with the spec. */ - bool dot11MeshGateAnnouncementProtocol; -}; - -/** - * struct mesh_setup - 802.11s mesh setup configuration - * @mesh_id: the mesh ID - * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes - * @path_sel_proto: which path selection protocol to use - * @path_metric: which metric to use - * @ie: vendor information elements (optional) - * @ie_len: length of vendor information elements - * @is_authenticated: this mesh requires authentication - * @is_secure: this mesh uses security - * - * These parameters are fixed when the mesh is created. - */ -struct mesh_setup { - const u8 *mesh_id; - u8 mesh_id_len; - u8 path_sel_proto; - u8 path_metric; - const u8 *ie; - u8 ie_len; - bool is_authenticated; - bool is_secure; -}; - -/** - * struct ieee80211_txq_params - TX queue parameters - * @queue: TX queue identifier (NL80211_TXQ_Q_*) - * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled - * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range - * 1..32767] - * @cwmax: Maximum contention window [a value of the form 2^n-1 in the range - * 1..32767] - * @aifs: Arbitration interframe space [0..255] - */ -struct ieee80211_txq_params { - enum nl80211_txq_q queue; - u16 txop; - u16 cwmin; - u16 cwmax; - u8 aifs; -}; - -/* from net/wireless.h */ -struct wiphy; - -/** - * DOC: Scanning and BSS list handling - * - * The scanning process itself is fairly simple, but cfg80211 offers quite - * a bit of helper functionality. To start a scan, the scan operation will - * be invoked with a scan definition. This scan definition contains the - * channels to scan, and the SSIDs to send probe requests for (including the - * wildcard, if desired). A passive scan is indicated by having no SSIDs to - * probe. Additionally, a scan request may contain extra information elements - * that should be added to the probe request. The IEs are guaranteed to be - * well-formed, and will not exceed the maximum length the driver advertised - * in the wiphy structure. - * - * When scanning finds a BSS, cfg80211 needs to be notified of that, because - * it is responsible for maintaining the BSS list; the driver should not - * maintain a list itself. For this notification, various functions exist. - * - * Since drivers do not maintain a BSS list, there are also a number of - * functions to search for a BSS and obtain information about it from the - * BSS structure cfg80211 maintains. The BSS list is also made available - * to userspace. - */ - -/** - * struct cfg80211_ssid - SSID description - * @ssid: the SSID - * @ssid_len: length of the ssid - */ -struct cfg80211_ssid { - u8 ssid[IEEE80211_MAX_SSID_LEN]; - u8 ssid_len; -}; - -/** - * struct cfg80211_scan_request - scan request description - * - * @ssids: SSIDs to scan for (active scan only) - * @n_ssids: number of SSIDs - * @channels: channels to scan on. - * @n_channels: total number of channels to scan - * @ie: optional information element(s) to add into Probe Request or %NULL - * @ie_len: length of ie in octets - * @rates: bitmap of rates to advertise for each band - * @wiphy: the wiphy this was for - * @dev: the interface - * @aborted: (internal) scan request was notified as aborted - * @no_cck: used to send probe requests at non CCK rate in 2GHz band - */ -struct cfg80211_scan_request { - struct cfg80211_ssid *ssids; - int n_ssids; - u32 n_channels; - const u8 *ie; - size_t ie_len; - - u32 rates[IEEE80211_NUM_BANDS]; - - /* internal */ - struct wiphy *wiphy; - struct net_device *dev; - bool aborted; - bool no_cck; - - /* keep last */ - struct ieee80211_channel *channels[0]; -}; - -/** - * struct cfg80211_match_set - sets of attributes to match - * - * @ssid: SSID to be matched - */ -struct cfg80211_match_set { - struct cfg80211_ssid ssid; -}; - -/** - * struct cfg80211_sched_scan_request - scheduled scan request description - * - * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans) - * @n_ssids: number of SSIDs - * @n_channels: total number of channels to scan - * @interval: interval between each scheduled scan cycle - * @ie: optional information element(s) to add into Probe Request or %NULL - * @ie_len: length of ie in octets - * @match_sets: sets of parameters to be matched for a scan result - * entry to be considered valid and to be passed to the host - * (others are filtered out). - * If ommited, all results are passed. - * @n_match_sets: number of match sets - * @wiphy: the wiphy this was for - * @dev: the interface - * @channels: channels to scan - */ -struct cfg80211_sched_scan_request { - struct cfg80211_ssid *ssids; - int n_ssids; - u32 n_channels; - u32 interval; - const u8 *ie; - size_t ie_len; - struct cfg80211_match_set *match_sets; - int n_match_sets; - - /* internal */ - struct wiphy *wiphy; - struct net_device *dev; - - /* keep last */ - struct ieee80211_channel *channels[0]; -}; - -/** - * enum cfg80211_signal_type - signal type - * - * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available - * @CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm) - * @CFG80211_SIGNAL_TYPE_UNSPEC: signal strength, increasing from 0 through 100 - */ -enum cfg80211_signal_type { - CFG80211_SIGNAL_TYPE_NONE, - CFG80211_SIGNAL_TYPE_MBM, - CFG80211_SIGNAL_TYPE_UNSPEC, -}; - -/** - * struct cfg80211_bss - BSS description - * - * This structure describes a BSS (which may also be a mesh network) - * for use in scan results and similar. - * - * @channel: channel this BSS is on - * @bssid: BSSID of the BSS - * @tsf: timestamp of last received update - * @beacon_interval: the beacon interval as from the frame - * @capability: the capability field in host byte order - * @information_elements: the information elements (Note that there - * is no guarantee that these are well-formed!); this is a pointer to - * either the beacon_ies or proberesp_ies depending on whether Probe - * Response frame has been received - * @len_information_elements: total length of the information elements - * @beacon_ies: the information elements from the last Beacon frame - * @len_beacon_ies: total length of the beacon_ies - * @proberesp_ies: the information elements from the last Probe Response frame - * @len_proberesp_ies: total length of the proberesp_ies - * @signal: signal strength value (type depends on the wiphy's signal_type) - * @free_priv: function pointer to free private data - * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes - */ -struct cfg80211_bss { - struct ieee80211_channel *channel; - - u8 bssid[ETH_ALEN]; - u64 tsf; - u16 beacon_interval; - u16 capability; - u8 *information_elements; - size_t len_information_elements; - u8 *beacon_ies; - size_t len_beacon_ies; - u8 *proberesp_ies; - size_t len_proberesp_ies; - - s32 signal; - - void (*free_priv)(struct cfg80211_bss *bss); - u8 priv[0] __attribute__((__aligned__(sizeof(void *)))); -}; - -/** - * ieee80211_bss_get_ie - find IE with given ID - * @bss: the bss to search - * @ie: the IE ID - * Returns %NULL if not found. - */ -const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie); - - -/** - * struct cfg80211_auth_request - Authentication request data - * - * This structure provides information needed to complete IEEE 802.11 - * authentication. - * - * @bss: The BSS to authenticate with. - * @auth_type: Authentication type (algorithm) - * @ie: Extra IEs to add to Authentication frame or %NULL - * @ie_len: Length of ie buffer in octets - * @key_len: length of WEP key for shared key authentication - * @key_idx: index of WEP key for shared key authentication - * @key: WEP key for shared key authentication - * @local_state_change: This is a request for a local state only, i.e., no - * Authentication frame is to be transmitted and authentication state is - * to be changed without having to wait for a response from the peer STA - * (AP). - */ -struct cfg80211_auth_request { - struct cfg80211_bss *bss; - const u8 *ie; - size_t ie_len; - enum nl80211_auth_type auth_type; - const u8 *key; - u8 key_len, key_idx; - bool local_state_change; -}; - -/** - * struct cfg80211_assoc_request - (Re)Association request data - * - * This structure provides information needed to complete IEEE 802.11 - * (re)association. - * @bss: The BSS to associate with. - * @ie: Extra IEs to add to (Re)Association Request frame or %NULL - * @ie_len: Length of ie buffer in octets - * @use_mfp: Use management frame protection (IEEE 802.11w) in this association - * @crypto: crypto settings - * @prev_bssid: previous BSSID, if not %NULL use reassociate frame - */ -struct cfg80211_assoc_request { - struct cfg80211_bss *bss; - const u8 *ie, *prev_bssid; - size_t ie_len; - struct cfg80211_crypto_settings crypto; - bool use_mfp; -}; - -/** - * struct cfg80211_deauth_request - Deauthentication request data - * - * This structure provides information needed to complete IEEE 802.11 - * deauthentication. - * - * @bss: the BSS to deauthenticate from - * @ie: Extra IEs to add to Deauthentication frame or %NULL - * @ie_len: Length of ie buffer in octets - * @reason_code: The reason code for the deauthentication - * @local_state_change: This is a request for a local state only, i.e., no - * Deauthentication frame is to be transmitted. - */ -struct cfg80211_deauth_request { - struct cfg80211_bss *bss; - const u8 *ie; - size_t ie_len; - u16 reason_code; - bool local_state_change; -}; - -/** - * struct cfg80211_disassoc_request - Disassociation request data - * - * This structure provides information needed to complete IEEE 802.11 - * disassocation. - * - * @bss: the BSS to disassociate from - * @ie: Extra IEs to add to Disassociation frame or %NULL - * @ie_len: Length of ie buffer in octets - * @reason_code: The reason code for the disassociation - * @local_state_change: This is a request for a local state only, i.e., no - * Disassociation frame is to be transmitted. - */ -struct cfg80211_disassoc_request { - struct cfg80211_bss *bss; - const u8 *ie; - size_t ie_len; - u16 reason_code; - bool local_state_change; -}; - -/** - * struct cfg80211_ibss_params - IBSS parameters - * - * This structure defines the IBSS parameters for the join_ibss() - * method. - * - * @ssid: The SSID, will always be non-null. - * @ssid_len: The length of the SSID, will always be non-zero. - * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not - * search for IBSSs with a different BSSID. - * @channel: The channel to use if no IBSS can be found to join. - * @channel_fixed: The channel should be fixed -- do not search for - * IBSSs to join on other channels. - * @ie: information element(s) to include in the beacon - * @ie_len: length of that - * @beacon_interval: beacon interval to use - * @privacy: this is a protected network, keys will be configured - * after joining - * @basic_rates: bitmap of basic rates to use when creating the IBSS - * @mcast_rate: per-band multicast rate index + 1 (0: disabled) - */ -struct cfg80211_ibss_params { - u8 *ssid; - u8 *bssid; - struct ieee80211_channel *channel; - u8 *ie; - u8 ssid_len, ie_len; - u16 beacon_interval; - u32 basic_rates; - bool channel_fixed; - bool privacy; - int mcast_rate[IEEE80211_NUM_BANDS]; -}; - -/** - * struct cfg80211_connect_params - Connection parameters - * - * This structure provides information needed to complete IEEE 802.11 - * authentication and association. - * - * @channel: The channel to use or %NULL if not specified (auto-select based - * on scan results) - * @bssid: The AP BSSID or %NULL if not specified (auto-select based on scan - * results) - * @ssid: SSID - * @ssid_len: Length of ssid in octets - * @auth_type: Authentication type (algorithm) - * @ie: IEs for association request - * @ie_len: Length of assoc_ie in octets - * @privacy: indicates whether privacy-enabled APs should be used - * @crypto: crypto settings - * @key_len: length of WEP key for shared key authentication - * @key_idx: index of WEP key for shared key authentication - * @key: WEP key for shared key authentication - */ -struct cfg80211_connect_params { - struct ieee80211_channel *channel; - u8 *bssid; - u8 *ssid; - size_t ssid_len; - enum nl80211_auth_type auth_type; - u8 *ie; - size_t ie_len; - bool privacy; - struct cfg80211_crypto_settings crypto; - const u8 *key; - u8 key_len, key_idx; -}; - -/** - * enum wiphy_params_flags - set_wiphy_params bitfield values - * @WIPHY_PARAM_RETRY_SHORT: wiphy->retry_short has changed - * @WIPHY_PARAM_RETRY_LONG: wiphy->retry_long has changed - * @WIPHY_PARAM_FRAG_THRESHOLD: wiphy->frag_threshold has changed - * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed - * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed - */ -enum wiphy_params_flags { - WIPHY_PARAM_RETRY_SHORT = 1 << 0, - WIPHY_PARAM_RETRY_LONG = 1 << 1, - WIPHY_PARAM_FRAG_THRESHOLD = 1 << 2, - WIPHY_PARAM_RTS_THRESHOLD = 1 << 3, - WIPHY_PARAM_COVERAGE_CLASS = 1 << 4, -}; - -/* - * cfg80211_bitrate_mask - masks for bitrate control - */ -struct cfg80211_bitrate_mask { - struct { - u32 legacy; - /* TODO: add support for masking MCS rates; e.g.: */ - /* u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; */ - } control[IEEE80211_NUM_BANDS]; -}; -/** - * struct cfg80211_pmksa - PMK Security Association - * - * This structure is passed to the set/del_pmksa() method for PMKSA - * caching. - * - * @bssid: The AP's BSSID. - * @pmkid: The PMK material itself. - */ -struct cfg80211_pmksa { - u8 *bssid; - u8 *pmkid; -}; - -/** - * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern - * @mask: bitmask where to match pattern and where to ignore bytes, - * one bit per byte, in same format as nl80211 - * @pattern: bytes to match where bitmask is 1 - * @pattern_len: length of pattern (in bytes) - * - * Internal note: @mask and @pattern are allocated in one chunk of - * memory, free @mask only! - */ -struct cfg80211_wowlan_trig_pkt_pattern { - u8 *mask, *pattern; - int pattern_len; -}; - -/** - * struct cfg80211_wowlan - Wake on Wireless-LAN support info - * - * This structure defines the enabled WoWLAN triggers for the device. - * @any: wake up on any activity -- special trigger if device continues - * operating as normal during suspend - * @disconnect: wake up if getting disconnected - * @magic_pkt: wake up on receiving magic packet - * @patterns: wake up on receiving packet matching a pattern - * @n_patterns: number of patterns - * @gtk_rekey_failure: wake up on GTK rekey failure - * @eap_identity_req: wake up on EAP identity request packet - * @four_way_handshake: wake up on 4-way handshake - * @rfkill_release: wake up when rfkill is released - */ -struct cfg80211_wowlan { - bool any, disconnect, magic_pkt, gtk_rekey_failure, - eap_identity_req, four_way_handshake, - rfkill_release; - struct cfg80211_wowlan_trig_pkt_pattern *patterns; - int n_patterns; -}; - -/** - * struct cfg80211_gtk_rekey_data - rekey data - * @kek: key encryption key - * @kck: key confirmation key - * @replay_ctr: replay counter - */ -struct cfg80211_gtk_rekey_data { - u8 kek[NL80211_KEK_LEN]; - u8 kck[NL80211_KCK_LEN]; - u8 replay_ctr[NL80211_REPLAY_CTR_LEN]; -}; - -/** - * struct cfg80211_ops - backend description for wireless configuration - * - * This struct is registered by fullmac card drivers and/or wireless stacks - * in order to handle configuration requests on their interfaces. - * - * All callbacks except where otherwise noted should return 0 - * on success or a negative error code. - * - * All operations are currently invoked under rtnl for consistency with the - * wireless extensions but this is subject to reevaluation as soon as this - * code is used more widely and we have a first user without wext. - * - * @suspend: wiphy device needs to be suspended. The variable @wow will - * be %NULL or contain the enabled Wake-on-Wireless triggers that are - * configured for the device. - * @resume: wiphy device needs to be resumed - * - * @add_virtual_intf: create a new virtual interface with the given name, - * must set the struct wireless_dev's iftype. Beware: You must create - * the new netdev in the wiphy's network namespace! Returns the netdev, - * or an ERR_PTR. - * - * @del_virtual_intf: remove the virtual interface determined by ifindex. - * - * @change_virtual_intf: change type/configuration of virtual interface, - * keep the struct wireless_dev's iftype updated. - * - * @add_key: add a key with the given parameters. @mac_addr will be %NULL - * when adding a group key. - * - * @get_key: get information about the key with the given parameters. - * @mac_addr will be %NULL when requesting information for a group - * key. All pointers given to the @callback function need not be valid - * after it returns. This function should return an error if it is - * not possible to retrieve the key, -ENOENT if it doesn't exist. - * - * @del_key: remove a key given the @mac_addr (%NULL for a group key) - * and @key_index, return -ENOENT if the key doesn't exist. - * - * @set_default_key: set the default key on an interface - * - * @set_default_mgmt_key: set the default management frame key on an interface - * - * @set_rekey_data: give the data necessary for GTK rekeying to the driver - * - * @add_beacon: Add a beacon with given parameters, @head, @interval - * and @dtim_period will be valid, @tail is optional. - * @set_beacon: Change the beacon parameters for an access point mode - * interface. This should reject the call when no beacon has been - * configured. - * @del_beacon: Remove beacon configuration and stop sending the beacon. - * - * @add_station: Add a new station. - * @del_station: Remove a station; @mac may be NULL to remove all stations. - * @change_station: Modify a given station. - * @get_station: get station information for the station identified by @mac - * @dump_station: dump station callback -- resume dump at index @idx - * - * @add_mpath: add a fixed mesh path - * @del_mpath: delete a given mesh path - * @change_mpath: change a given mesh path - * @get_mpath: get a mesh path for the given parameters - * @dump_mpath: dump mesh path callback -- resume dump at index @idx - * @join_mesh: join the mesh network with the specified parameters - * @leave_mesh: leave the current mesh network - * - * @get_mesh_config: Get the current mesh configuration - * - * @update_mesh_config: Update mesh parameters on a running mesh. - * The mask is a bitfield which tells us which parameters to - * set, and which to leave alone. - * - * @change_bss: Modify parameters for a given BSS. - * - * @set_txq_params: Set TX queue parameters - * - * @set_channel: Set channel for a given wireless interface. Some devices - * may support multi-channel operation (by channel hopping) so cfg80211 - * doesn't verify much. Note, however, that the passed netdev may be - * %NULL as well if the user requested changing the channel for the - * device itself, or for a monitor interface. - * @get_channel: Get the current operating channel, should return %NULL if - * there's no single defined operating channel if for example the - * device implements channel hopping for multi-channel virtual interfaces. - * - * @scan: Request to do a scan. If returning zero, the scan request is given - * the driver, and will be valid until passed to cfg80211_scan_done(). - * For scan results, call cfg80211_inform_bss(); you can call this outside - * the scan/scan_done bracket too. - * - * @auth: Request to authenticate with the specified peer - * @assoc: Request to (re)associate with the specified peer - * @deauth: Request to deauthenticate from the specified peer - * @disassoc: Request to disassociate from the specified peer - * - * @connect: Connect to the ESS with the specified parameters. When connected, - * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS. - * If the connection fails for some reason, call cfg80211_connect_result() - * with the status from the AP. - * @disconnect: Disconnect from the BSS/ESS. - * - * @join_ibss: Join the specified IBSS (or create if necessary). Once done, call - * cfg80211_ibss_joined(), also call that function when changing BSSID due - * to a merge. - * @leave_ibss: Leave the IBSS. - * - * @set_wiphy_params: Notify that wiphy parameters have changed; - * @changed bitfield (see &enum wiphy_params_flags) describes which values - * have changed. The actual parameter values are available in - * struct wiphy. If returning an error, no value should be changed. - * - * @set_tx_power: set the transmit power according to the parameters - * @get_tx_power: store the current TX power into the dbm variable; - * return 0 if successful - * - * @set_wds_peer: set the WDS peer for a WDS interface - * - * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting - * functions to adjust rfkill hw state - * - * @dump_survey: get site survey information. - * - * @remain_on_channel: Request the driver to remain awake on the specified - * channel for the specified duration to complete an off-channel - * operation (e.g., public action frame exchange). When the driver is - * ready on the requested channel, it must indicate this with an event - * notification by calling cfg80211_ready_on_channel(). - * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation. - * This allows the operation to be terminated prior to timeout based on - * the duration value. - * @mgmt_tx: Transmit a management frame. - * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management - * frame on another channel - * - * @testmode_cmd: run a test mode command - * @testmode_dump: Implement a test mode dump. The cb->args[2] and up may be - * used by the function, but 0 and 1 must not be touched. Additionally, - * return error codes other than -ENOBUFS and -ENOENT will terminate the - * dump and return to userspace with an error, so be careful. If any data - * was passed in from userspace then the data/len arguments will be present - * and point to the data contained in %NL80211_ATTR_TESTDATA. - * - * @set_bitrate_mask: set the bitrate mask configuration - * - * @set_pmksa: Cache a PMKID for a BSSID. This is mostly useful for fullmac - * devices running firmwares capable of generating the (re) association - * RSN IE. It allows for faster roaming between WPA2 BSSIDs. - * @del_pmksa: Delete a cached PMKID. - * @flush_pmksa: Flush all cached PMKIDs. - * @set_power_mgmt: Configure WLAN power management. A timeout value of -1 - * allows the driver to adjust the dynamic ps timeout value. - * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold. - * @sched_scan_start: Tell the driver to start a scheduled scan. - * @sched_scan_stop: Tell the driver to stop an ongoing scheduled - * scan. The driver_initiated flag specifies whether the driver - * itself has informed that the scan has stopped. - * - * @mgmt_frame_register: Notify driver that a management frame type was - * registered. Note that this callback may not sleep, and cannot run - * concurrently with itself. - * - * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device. - * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may - * reject TX/RX mask combinations they cannot support by returning -EINVAL - * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX). - * - * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant). - * - * @set_ringparam: Set tx and rx ring sizes. - * - * @get_ringparam: Get tx and rx ring current and maximum sizes. - * - * @tdls_mgmt: Transmit a TDLS management frame. - * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup). - * - * @probe_client: probe an associated client, must return a cookie that it - * later passes to cfg80211_probe_status(). - * - * @notify_btcoex_inq_status: Notify the Bluetooth inquiry status in - * case of a Bleutooth co-ex device. - * - * @notify_btcoex_sco_status: Notify the Bluetooth SCO connection status in - * case of a Bluetooth co-ex device. - * - * @notify_btcoex_a2dp_status: Notify the Bluetooth A2DP connection status in - * case of a Bluetooth co-ex device. - * - * @notify_btcoex_acl_info: Notify the Bluetooth chip's ACL connction - * information - * - * @notify_btcoex_antenna_config: Notify the Bluetooth WiFi chip antenna - * configuration - * - * @notify_btcoex_bt_vendor: Notify the Bluetooth chip vendor in case of using - * different Bluetooth chip vendor - */ - -struct cfg80211_ops { - int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); - int (*resume)(struct wiphy *wiphy); - - struct net_device * (*add_virtual_intf)(struct wiphy *wiphy, - char *name, - enum nl80211_iftype type, - u32 *flags, - struct vif_params *params); - int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev); - int (*change_virtual_intf)(struct wiphy *wiphy, - struct net_device *dev, - enum nl80211_iftype type, u32 *flags, - struct vif_params *params); - - int (*add_key)(struct wiphy *wiphy, struct net_device *netdev, - u8 key_index, bool pairwise, const u8 *mac_addr, - struct key_params *params); - int (*get_key)(struct wiphy *wiphy, struct net_device *netdev, - u8 key_index, bool pairwise, const u8 *mac_addr, - void *cookie, - void (*callback)(void *cookie, struct key_params*)); - int (*del_key)(struct wiphy *wiphy, struct net_device *netdev, - u8 key_index, bool pairwise, const u8 *mac_addr); - int (*set_default_key)(struct wiphy *wiphy, - struct net_device *netdev, - u8 key_index, bool unicast, bool multicast); - int (*set_default_mgmt_key)(struct wiphy *wiphy, - struct net_device *netdev, - u8 key_index); - - int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info); - int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev, - struct beacon_parameters *info); - int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev); - - - int (*add_station)(struct wiphy *wiphy, struct net_device *dev, - u8 *mac, struct station_parameters *params); - int (*del_station)(struct wiphy *wiphy, struct net_device *dev, - u8 *mac); - int (*change_station)(struct wiphy *wiphy, struct net_device *dev, - u8 *mac, struct station_parameters *params); - int (*get_station)(struct wiphy *wiphy, struct net_device *dev, - u8 *mac, struct station_info *sinfo); - int (*dump_station)(struct wiphy *wiphy, struct net_device *dev, - int idx, u8 *mac, struct station_info *sinfo); - - int (*add_mpath)(struct wiphy *wiphy, struct net_device *dev, - u8 *dst, u8 *next_hop); - int (*del_mpath)(struct wiphy *wiphy, struct net_device *dev, - u8 *dst); - int (*change_mpath)(struct wiphy *wiphy, struct net_device *dev, - u8 *dst, u8 *next_hop); - int (*get_mpath)(struct wiphy *wiphy, struct net_device *dev, - u8 *dst, u8 *next_hop, - struct mpath_info *pinfo); - int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev, - int idx, u8 *dst, u8 *next_hop, - struct mpath_info *pinfo); - int (*get_mesh_config)(struct wiphy *wiphy, - struct net_device *dev, - struct mesh_config *conf); - int (*update_mesh_config)(struct wiphy *wiphy, - struct net_device *dev, u32 mask, - const struct mesh_config *nconf); - int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev, - const struct mesh_config *conf, - const struct mesh_setup *setup); - int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev); - - int (*change_bss)(struct wiphy *wiphy, struct net_device *dev, - struct bss_parameters *params); - - int (*set_txq_params)(struct wiphy *wiphy, struct net_device *dev, - struct ieee80211_txq_params *params); - - int (*set_channel)(struct wiphy *wiphy, struct net_device *dev, - struct ieee80211_channel *chan, - enum nl80211_channel_type channel_type); - - int (*scan)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_scan_request *request); - - int (*auth)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_auth_request *req); - int (*assoc)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_assoc_request *req); - int (*deauth)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_deauth_request *req, - void *cookie); - int (*disassoc)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_disassoc_request *req, - void *cookie); - - int (*connect)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_connect_params *sme); - int (*disconnect)(struct wiphy *wiphy, struct net_device *dev, - u16 reason_code); - - int (*join_ibss)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_ibss_params *params); - int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev); - - int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed); - - int (*set_tx_power)(struct wiphy *wiphy, - enum nl80211_tx_power_setting type, int mbm); - int (*get_tx_power)(struct wiphy *wiphy, int *dbm); - - int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, - const u8 *addr); - - void (*rfkill_poll)(struct wiphy *wiphy); - -#ifdef CONFIG_NL80211_TESTMODE - int (*testmode_cmd)(struct wiphy *wiphy, void *data, int len); - int (*testmode_dump)(struct wiphy *wiphy, struct sk_buff *skb, - struct netlink_callback *cb, - void *data, int len); -#endif - - int (*set_bitrate_mask)(struct wiphy *wiphy, - struct net_device *dev, - const u8 *peer, - const struct cfg80211_bitrate_mask *mask); - - int (*dump_survey)(struct wiphy *wiphy, struct net_device *netdev, - int idx, struct survey_info *info); - - int (*set_pmksa)(struct wiphy *wiphy, struct net_device *netdev, - struct cfg80211_pmksa *pmksa); - int (*del_pmksa)(struct wiphy *wiphy, struct net_device *netdev, - struct cfg80211_pmksa *pmksa); - int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev); - - int (*remain_on_channel)(struct wiphy *wiphy, - struct net_device *dev, - struct ieee80211_channel *chan, - enum nl80211_channel_type channel_type, - unsigned int duration, - u64 *cookie); - int (*cancel_remain_on_channel)(struct wiphy *wiphy, - struct net_device *dev, - u64 cookie); - - int (*mgmt_tx)(struct wiphy *wiphy, struct net_device *dev, - struct ieee80211_channel *chan, bool offchan, - enum nl80211_channel_type channel_type, - bool channel_type_valid, unsigned int wait, - const u8 *buf, size_t len, bool no_cck, - bool dont_wait_for_ack, u64 *cookie); - int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy, - struct net_device *dev, - u64 cookie); - - int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev, - bool enabled, int timeout); - - int (*set_cqm_rssi_config)(struct wiphy *wiphy, - struct net_device *dev, - s32 rssi_thold, u32 rssi_hyst); - - void (*mgmt_frame_register)(struct wiphy *wiphy, - struct net_device *dev, - u16 frame_type, bool reg); - - int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant); - int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant); - - int (*set_ringparam)(struct wiphy *wiphy, u32 tx, u32 rx); - void (*get_ringparam)(struct wiphy *wiphy, - u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max); - - int (*sched_scan_start)(struct wiphy *wiphy, - struct net_device *dev, - struct cfg80211_sched_scan_request *request); - int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev); - - int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_gtk_rekey_data *data); - - int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev, - u8 *peer, u8 action_code, u8 dialog_token, - u16 status_code, const u8 *buf, size_t len); - int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev, - u8 *peer, enum nl80211_tdls_operation oper); - - int (*probe_client)(struct wiphy *wiphy, struct net_device *dev, - const u8 *peer, u64 *cookie); - - struct ieee80211_channel *(*get_channel)(struct wiphy *wiphy); - - int (*notify_btcoex_inq_status)(struct wiphy *wiphy, bool status); - int (*notify_btcoex_sco_status)(struct wiphy *wiphy, bool status, - bool esco, u32 tx_interval, - u32 tx_pkt_len); - int (*notify_btcoex_a2dp_status)(struct wiphy *wiphy, bool status); - int (*notify_btcoex_acl_info)(struct wiphy *wiphy, - enum nl80211_btcoex_acl_role role, - u32 remote_lmp_ver); - int (*notify_btcoex_antenna_config)(struct wiphy *wiphy, - enum nl80211_btcoex_antenna_config); - int (*notify_btcoex_bt_vendor)(struct wiphy *wiphy, - enum nl80211_btcoex_vendor_list); - int (*notify_btcoex)(struct wiphy *wiphy, - u8 *buf, int len); - int (*priv_cmd)(struct wiphy *wiphy, struct net_device *dev, - char *priv_cmd); - int (*notify_p2p_flush)(struct wiphy *wiphy); -}; - -/* - * wireless hardware and networking interfaces structures - * and registration/helper functions - */ - -/** - * enum wiphy_flags - wiphy capability flags - * - * @WIPHY_FLAG_CUSTOM_REGULATORY: tells us the driver for this device - * has its own custom regulatory domain and cannot identify the - * ISO / IEC 3166 alpha2 it belongs to. When this is enabled - * we will disregard the first regulatory hint (when the - * initiator is %REGDOM_SET_BY_CORE). - * @WIPHY_FLAG_STRICT_REGULATORY: tells us the driver for this device will - * ignore regulatory domain settings until it gets its own regulatory - * domain via its regulatory_hint() unless the regulatory hint is - * from a country IE. After its gets its own regulatory domain it will - * only allow further regulatory domain settings to further enhance - * compliance. For example if channel 13 and 14 are disabled by this - * regulatory domain no user regulatory domain can enable these channels - * at a later time. This can be used for devices which do not have - * calibration information guaranteed for frequencies or settings - * outside of its regulatory domain. - * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure - * that passive scan flags and beaconing flags may not be lifted by - * cfg80211 due to regulatory beacon hints. For more information on beacon - * hints read the documenation for regulatory_hint_found_beacon() - * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this - * wiphy at all - * @WIPHY_FLAG_ENFORCE_COMBINATIONS: Set this flag to enforce interface - * combinations for this device. This flag is used for backward - * compatibility only until all drivers advertise combinations and - * they will always be enforced. - * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled - * by default -- this flag will be set depending on the kernel's default - * on wiphy_new(), but can be changed by the driver if it has a good - * reason to override the default - * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station - * on a VLAN interface) - * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station - * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the - * control port protocol ethertype. The device also honours the - * control_port_no_encrypt flag. - * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN. - * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing - * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH. - * @WIPHY_FLAG_SUPPORTS_SCHED_SCAN: The device supports scheduled scans. - * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the - * firmware. - * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP. - * @WIPHY_FLAG_SUPPORTS_TDLS: The device supports TDLS (802.11z) operation. - * @WIPHY_FLAG_TDLS_EXTERNAL_SETUP: The device does not handle TDLS (802.11z) - * link setup/discovery operations internally. Setup, discovery and - * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT - * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be - * used for asking the driver/firmware to perform a TDLS operation. - * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME - * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes - * when there are virtual interfaces in AP mode by calling - * cfg80211_report_obss_beacon(). - * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device - * responds to probe-requests in hardware. - */ -enum wiphy_flags { - WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), - WIPHY_FLAG_STRICT_REGULATORY = BIT(1), - WIPHY_FLAG_DISABLE_BEACON_HINTS = BIT(2), - WIPHY_FLAG_NETNS_OK = BIT(3), - WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4), - WIPHY_FLAG_4ADDR_AP = BIT(5), - WIPHY_FLAG_4ADDR_STATION = BIT(6), - WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7), - WIPHY_FLAG_IBSS_RSN = BIT(8), - WIPHY_FLAG_MESH_AUTH = BIT(10), - WIPHY_FLAG_SUPPORTS_SCHED_SCAN = BIT(11), - WIPHY_FLAG_ENFORCE_COMBINATIONS = BIT(12), - WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(13), - WIPHY_FLAG_AP_UAPSD = BIT(14), - WIPHY_FLAG_SUPPORTS_TDLS = BIT(15), - WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16), - WIPHY_FLAG_HAVE_AP_SME = BIT(17), - WIPHY_FLAG_REPORTS_OBSS = BIT(18), - WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19), -}; - -/** - * struct ieee80211_iface_limit - limit on certain interface types - * @max: maximum number of interfaces of these types - * @types: interface types (bits) - */ -struct ieee80211_iface_limit { - u16 max; - u16 types; -}; - -/** - * struct ieee80211_iface_combination - possible interface combination - * @limits: limits for the given interface types - * @n_limits: number of limitations - * @num_different_channels: can use up to this many different channels - * @max_interfaces: maximum number of interfaces in total allowed in this - * group - * @beacon_int_infra_match: In this combination, the beacon intervals - * between infrastructure and AP types must match. This is required - * only in special cases. - * - * These examples can be expressed as follows: - * - * Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total: - * - * struct ieee80211_iface_limit limits1[] = { - * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, - * { .max = 1, .types = BIT(NL80211_IFTYPE_AP}, }, - * }; - * struct ieee80211_iface_combination combination1 = { - * .limits = limits1, - * .n_limits = ARRAY_SIZE(limits1), - * .max_interfaces = 2, - * .beacon_int_infra_match = true, - * }; - * - * - * Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total: - * - * struct ieee80211_iface_limit limits2[] = { - * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) | - * BIT(NL80211_IFTYPE_P2P_GO), }, - * }; - * struct ieee80211_iface_combination combination2 = { - * .limits = limits2, - * .n_limits = ARRAY_SIZE(limits2), - * .max_interfaces = 8, - * .num_different_channels = 1, - * }; - * - * - * Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total. - * This allows for an infrastructure connection and three P2P connections. - * - * struct ieee80211_iface_limit limits3[] = { - * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, - * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) | - * BIT(NL80211_IFTYPE_P2P_CLIENT), }, - * }; - * struct ieee80211_iface_combination combination3 = { - * .limits = limits3, - * .n_limits = ARRAY_SIZE(limits3), - * .max_interfaces = 4, - * .num_different_channels = 2, - * }; - */ -struct ieee80211_iface_combination { - const struct ieee80211_iface_limit *limits; - u32 num_different_channels; - u16 max_interfaces; - u8 n_limits; - bool beacon_int_infra_match; -}; - -struct mac_address { - u8 addr[ETH_ALEN]; -}; - -struct ieee80211_txrx_stypes { - u16 tx, rx; -}; - -/** - * enum wiphy_wowlan_support_flags - WoWLAN support flags - * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any" - * trigger that keeps the device operating as-is and - * wakes up the host on any activity, for example a - * received packet that passed filtering; note that the - * packet should be preserved in that case - * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet - * (see nl80211.h) - * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect - * @WIPHY_WOWLAN_SUPPORTS_GTK_REKEY: supports GTK rekeying while asleep - * @WIPHY_WOWLAN_GTK_REKEY_FAILURE: supports wakeup on GTK rekey failure - * @WIPHY_WOWLAN_EAP_IDENTITY_REQ: supports wakeup on EAP identity request - * @WIPHY_WOWLAN_4WAY_HANDSHAKE: supports wakeup on 4-way handshake failure - * @WIPHY_WOWLAN_RFKILL_RELEASE: supports wakeup on RF-kill release - */ -enum wiphy_wowlan_support_flags { - WIPHY_WOWLAN_ANY = BIT(0), - WIPHY_WOWLAN_MAGIC_PKT = BIT(1), - WIPHY_WOWLAN_DISCONNECT = BIT(2), - WIPHY_WOWLAN_SUPPORTS_GTK_REKEY = BIT(3), - WIPHY_WOWLAN_GTK_REKEY_FAILURE = BIT(4), - WIPHY_WOWLAN_EAP_IDENTITY_REQ = BIT(5), - WIPHY_WOWLAN_4WAY_HANDSHAKE = BIT(6), - WIPHY_WOWLAN_RFKILL_RELEASE = BIT(7), -}; - -/** - * struct wiphy_wowlan_support - WoWLAN support data - * @flags: see &enum wiphy_wowlan_support_flags - * @n_patterns: number of supported wakeup patterns - * (see nl80211.h for the pattern definition) - * @pattern_max_len: maximum length of each pattern - * @pattern_min_len: minimum length of each pattern - */ -struct wiphy_wowlan_support { - u32 flags; - int n_patterns; - int pattern_max_len; - int pattern_min_len; -}; - -/** - * struct wiphy - wireless hardware description - * @reg_notifier: the driver's regulatory notification callback, - * note that if your driver uses wiphy_apply_custom_regulatory() - * the reg_notifier's request can be passed as NULL - * @regd: the driver's regulatory domain, if one was requested via - * the regulatory_hint() API. This can be used by the driver - * on the reg_notifier() if it chooses to ignore future - * regulatory domain changes caused by other drivers. - * @signal_type: signal type reported in &struct cfg80211_bss. - * @cipher_suites: supported cipher suites - * @n_cipher_suites: number of supported cipher suites - * @retry_short: Retry limit for short frames (dot11ShortRetryLimit) - * @retry_long: Retry limit for long frames (dot11LongRetryLimit) - * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold); - * -1 = fragmentation disabled, only odd values >= 256 used - * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled - * @_net: the network namespace this wiphy currently lives in - * @perm_addr: permanent MAC address of this device - * @addr_mask: If the device supports multiple MAC addresses by masking, - * set this to a mask with variable bits set to 1, e.g. if the last - * four bits are variable then set it to 00:...:00:0f. The actual - * variable bits shall be determined by the interfaces added, with - * interfaces not matching the mask being rejected to be brought up. - * @n_addresses: number of addresses in @addresses. - * @addresses: If the device has more than one address, set this pointer - * to a list of addresses (6 bytes each). The first one will be used - * by default for perm_addr. In this case, the mask should be set to - * all-zeroes. In this case it is assumed that the device can handle - * the same number of arbitrary MAC addresses. - * @registered: protects ->resume and ->suspend sysfs callbacks against - * unregister hardware - * @debugfsdir: debugfs directory used for this wiphy, will be renamed - * automatically on wiphy renames - * @dev: (virtual) struct device for this wiphy - * @registered: helps synchronize suspend/resume with wiphy unregister - * @wext: wireless extension handlers - * @priv: driver private data (sized according to wiphy_new() parameter) - * @interface_modes: bitmask of interfaces types valid for this wiphy, - * must be set by driver - * @iface_combinations: Valid interface combinations array, should not - * list single interface types. - * @n_iface_combinations: number of entries in @iface_combinations array. - * @software_iftypes: bitmask of software interface types, these are not - * subject to any restrictions since they are purely managed in SW. - * @flags: wiphy flags, see &enum wiphy_flags - * @features: features advertised to nl80211, see &enum nl80211_feature_flags. - * @bss_priv_size: each BSS struct has private data allocated with it, - * this variable determines its size - * @max_scan_ssids: maximum number of SSIDs the device can scan for in - * any given scan - * @max_sched_scan_ssids: maximum number of SSIDs the device can scan - * for in any given scheduled scan - * @max_match_sets: maximum number of match sets the device can handle - * when performing a scheduled scan, 0 if filtering is not - * supported. - * @max_scan_ie_len: maximum length of user-controlled IEs device can - * add to probe request frames transmitted during a scan, must not - * include fixed IEs like supported rates - * @max_sched_scan_ie_len: same as max_scan_ie_len, but for scheduled - * scans - * @coverage_class: current coverage class - * @fw_version: firmware version for ethtool reporting - * @hw_version: hardware version for ethtool reporting - * @max_num_pmkids: maximum number of PMKIDs supported by device - * @privid: a pointer that drivers can use to identify if an arbitrary - * wiphy is theirs, e.g. in global notifiers - * @bands: information about bands/channels supported by this device - * - * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or - * transmitted through nl80211, points to an array indexed by interface - * type - * - * @available_antennas_tx: bitmap of antennas which are available to be - * configured as TX antennas. Antenna configuration commands will be - * rejected unless this or @available_antennas_rx is set. - * - * @available_antennas_rx: bitmap of antennas which are available to be - * configured as RX antennas. Antenna configuration commands will be - * rejected unless this or @available_antennas_tx is set. - * - * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation - * may request, if implemented. - * - * @wowlan: WoWLAN support information - * - * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features. - */ -struct wiphy { - /* assign these fields before you register the wiphy */ - -#define WIPHY_COMPAT_PAD_SIZE 2048 - u8 padding[WIPHY_COMPAT_PAD_SIZE]; - - /* permanent MAC address(es) */ - u8 perm_addr[ETH_ALEN]; - u8 addr_mask[ETH_ALEN]; - - struct mac_address *addresses; - - const struct ieee80211_txrx_stypes *mgmt_stypes; - - const struct ieee80211_iface_combination *iface_combinations; - int n_iface_combinations; - u16 software_iftypes; - - u16 n_addresses; - - /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ - u16 interface_modes; - - u32 flags, features; - - u32 ap_sme_capa; - - enum cfg80211_signal_type signal_type; - - int bss_priv_size; - u8 max_scan_ssids; - u8 max_sched_scan_ssids; - u8 max_match_sets; - u16 max_scan_ie_len; - u16 max_sched_scan_ie_len; - - int n_cipher_suites; - const u32 *cipher_suites; - - u8 retry_short; - u8 retry_long; - u32 frag_threshold; - u32 rts_threshold; - u8 coverage_class; - - char fw_version[ETHTOOL_BUSINFO_LEN]; - u32 hw_version; - - struct wiphy_wowlan_support wowlan; - - u16 max_remain_on_channel_duration; - - u8 max_num_pmkids; - - u32 available_antennas_tx; - u32 available_antennas_rx; - - /* - * Bitmap of supported protocols for probe response offloading - * see &enum nl80211_probe_resp_offload_support_attr. Only valid - * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set. - */ - u32 probe_resp_offload; - - /* If multiple wiphys are registered and you're handed e.g. - * a regular netdev with assigned ieee80211_ptr, you won't - * know whether it points to a wiphy your driver has registered - * or not. Assign this to something global to your driver to - * help determine whether you own this wiphy or not. */ - const void *privid; - - struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS]; - - /* Lets us get back the wiphy on the callback */ - int (*reg_notifier)(struct wiphy *wiphy, - struct regulatory_request *request); - - /* fields below are read-only, assigned by cfg80211 */ - - const struct ieee80211_regdomain *regd; - - /* the item in /sys/class/ieee80211/ points to this, - * you need use set_wiphy_dev() (see below) */ - struct device dev; - - /* protects ->resume, ->suspend sysfs callbacks against unregister hw */ - bool registered; - - /* dir in debugfs: ieee80211/<wiphyname> */ - struct dentry *debugfsdir; - -#ifdef CONFIG_NET_NS - /* the network namespace this phy lives in currently */ - struct net *_net; -#endif - -#ifdef CONFIG_CFG80211_WEXT - const struct iw_handler_def *wext; -#endif - - char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); -}; - -static inline struct net *wiphy_net(struct wiphy *wiphy) -{ - return read_pnet(&wiphy->_net); -} - -static inline void wiphy_net_set(struct wiphy *wiphy, struct net *net) -{ - write_pnet(&wiphy->_net, net); -} - -/** - * wiphy_priv - return priv from wiphy - * - * @wiphy: the wiphy whose priv pointer to return - */ -static inline void *wiphy_priv(struct wiphy *wiphy) -{ - BUG_ON(!wiphy); - return &wiphy->priv; -} - -/** - * priv_to_wiphy - return the wiphy containing the priv - * - * @priv: a pointer previously returned by wiphy_priv - */ -static inline struct wiphy *priv_to_wiphy(void *priv) -{ - BUG_ON(!priv); - return container_of(priv, struct wiphy, priv); -} - -/** - * set_wiphy_dev - set device pointer for wiphy - * - * @wiphy: The wiphy whose device to bind - * @dev: The device to parent it to - */ -static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev) -{ - wiphy->dev.parent = dev; -} - -/** - * wiphy_dev - get wiphy dev pointer - * - * @wiphy: The wiphy whose device struct to look up - */ -static inline struct device *wiphy_dev(struct wiphy *wiphy) -{ - return wiphy->dev.parent; -} - -/** - * wiphy_name - get wiphy name - * - * @wiphy: The wiphy whose name to return - */ -static inline const char *wiphy_name(const struct wiphy *wiphy) -{ - return dev_name(&wiphy->dev); -} - -/** - * wiphy_new - create a new wiphy for use with cfg80211 - * - * @ops: The configuration operations for this device - * @sizeof_priv: The size of the private area to allocate - * - * Create a new wiphy and associate the given operations with it. - * @sizeof_priv bytes are allocated for private use. - * - * The returned pointer must be assigned to each netdev's - * ieee80211_ptr for proper operation. - */ -struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv); - -/** - * wiphy_register - register a wiphy with cfg80211 - * - * @wiphy: The wiphy to register. - * - * Returns a non-negative wiphy index or a negative error code. - */ -extern int wiphy_register(struct wiphy *wiphy); - -/** - * wiphy_unregister - deregister a wiphy from cfg80211 - * - * @wiphy: The wiphy to unregister. - * - * After this call, no more requests can be made with this priv - * pointer, but the call may sleep to wait for an outstanding - * request that is being handled. - */ -extern void wiphy_unregister(struct wiphy *wiphy); - -/** - * wiphy_free - free wiphy - * - * @wiphy: The wiphy to free - */ -extern void wiphy_free(struct wiphy *wiphy); - -/* internal structs */ -struct cfg80211_conn; -struct cfg80211_internal_bss; -struct cfg80211_cached_keys; - -#define MAX_AUTH_BSSES 4 - -/** - * struct wireless_dev - wireless per-netdev state - * - * This structure must be allocated by the driver/stack - * that uses the ieee80211_ptr field in struct net_device - * (this is intentional so it can be allocated along with - * the netdev.) - * - * @wiphy: pointer to hardware description - * @iftype: interface type - * @list: (private) Used to collect the interfaces - * @netdev: (private) Used to reference back to the netdev - * @current_bss: (private) Used by the internal configuration code - * @channel: (private) Used by the internal configuration code to track - * user-set AP, monitor and WDS channels for wireless extensions - * @bssid: (private) Used by the internal configuration code - * @ssid: (private) Used by the internal configuration code - * @ssid_len: (private) Used by the internal configuration code - * @mesh_id_len: (private) Used by the internal configuration code - * @mesh_id_up_len: (private) Used by the internal configuration code - * @wext: (private) Used by the internal wireless extensions compat code - * @use_4addr: indicates 4addr mode is used on this interface, must be - * set by driver (if supported) on add_interface BEFORE registering the - * netdev and may otherwise be used by driver read-only, will be update - * by cfg80211 on change_interface - * @mgmt_registrations: list of registrations for management frames - * @mgmt_registrations_lock: lock for the list - * @mtx: mutex used to lock data in this struct - * @cleanup_work: work struct used for cleanup that can't be done directly - * @beacon_interval: beacon interval used on this device for transmitting - * beacons, 0 when not valid - */ -struct wireless_dev { - struct wiphy *wiphy; - enum nl80211_iftype iftype; - - /* the remainder of this struct should be private to cfg80211 */ - struct list_head list; - struct net_device *netdev; - - struct list_head mgmt_registrations; - spinlock_t mgmt_registrations_lock; - - struct mutex mtx; - - struct work_struct cleanup_work; - - bool use_4addr; - - /* currently used for IBSS and SME - might be rearranged later */ - u8 ssid[IEEE80211_MAX_SSID_LEN]; - u8 ssid_len, mesh_id_len, mesh_id_up_len; - enum { - CFG80211_SME_IDLE, - CFG80211_SME_CONNECTING, - CFG80211_SME_CONNECTED, - } sme_state; - struct cfg80211_conn *conn; - struct cfg80211_cached_keys *connect_keys; - - struct list_head event_list; - spinlock_t event_lock; - - struct cfg80211_internal_bss *authtry_bsses[MAX_AUTH_BSSES]; - struct cfg80211_internal_bss *auth_bsses[MAX_AUTH_BSSES]; - struct cfg80211_internal_bss *current_bss; /* associated / joined */ - struct ieee80211_channel *channel; - - bool ps; - int ps_timeout; - - int beacon_interval; - - u32 ap_unexpected_nlpid; - -#ifdef CONFIG_CFG80211_WEXT - /* wext data */ - struct { - struct cfg80211_ibss_params ibss; - struct cfg80211_connect_params connect; - struct cfg80211_cached_keys *keys; - u8 *ie; - size_t ie_len; - u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; - u8 ssid[IEEE80211_MAX_SSID_LEN]; - s8 default_key, default_mgmt_key; - bool prev_bssid_valid; - } wext; -#endif -}; - -/** - * wdev_priv - return wiphy priv from wireless_dev - * - * @wdev: The wireless device whose wiphy's priv pointer to return - */ -static inline void *wdev_priv(struct wireless_dev *wdev) -{ - BUG_ON(!wdev); - return wiphy_priv(wdev->wiphy); -} - -/** - * DOC: Utility functions - * - * cfg80211 offers a number of utility functions that can be useful. - */ - -/** - * ieee80211_channel_to_frequency - convert channel number to frequency - * @chan: channel number - * @band: band, necessary due to channel number overlap - */ -extern int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band); - -/** - * ieee80211_frequency_to_channel - convert frequency to channel number - * @freq: center frequency - */ -extern int ieee80211_frequency_to_channel(int freq); - -/* - * Name indirection necessary because the ieee80211 code also has - * a function named "ieee80211_get_channel", so if you include - * cfg80211's header file you get cfg80211's version, if you try - * to include both header files you'll (rightfully!) get a symbol - * clash. - */ -extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy, - int freq); -/** - * ieee80211_get_channel - get channel struct from wiphy for specified frequency - * @wiphy: the struct wiphy to get the channel for - * @freq: the center frequency of the channel - */ -static inline struct ieee80211_channel * -ieee80211_get_channel(struct wiphy *wiphy, int freq) -{ - return __ieee80211_get_channel(wiphy, freq); -} - -/** - * ieee80211_get_response_rate - get basic rate for a given rate - * - * @sband: the band to look for rates in - * @basic_rates: bitmap of basic rates - * @bitrate: the bitrate for which to find the basic rate - * - * This function returns the basic rate corresponding to a given - * bitrate, that is the next lower bitrate contained in the basic - * rate map, which is, for this function, given as a bitmap of - * indices of rates in the band's bitrate table. - */ -struct ieee80211_rate * -ieee80211_get_response_rate(struct ieee80211_supported_band *sband, - u32 basic_rates, int bitrate); - -/* - * Radiotap parsing functions -- for controlled injection support - * - * Implemented in net/wireless/radiotap.c - * Documentation in Documentation/networking/radiotap-headers.txt - */ - -struct radiotap_align_size { - uint8_t align:4, size:4; -}; - -struct ieee80211_radiotap_namespace { - const struct radiotap_align_size *align_size; - int n_bits; - uint32_t oui; - uint8_t subns; -}; - -struct ieee80211_radiotap_vendor_namespaces { - const struct ieee80211_radiotap_namespace *ns; - int n_ns; -}; - -/** - * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args - * @this_arg_index: index of current arg, valid after each successful call - * to ieee80211_radiotap_iterator_next() - * @this_arg: pointer to current radiotap arg; it is valid after each - * call to ieee80211_radiotap_iterator_next() but also after - * ieee80211_radiotap_iterator_init() where it will point to - * the beginning of the actual data portion - * @this_arg_size: length of the current arg, for convenience - * @current_namespace: pointer to the current namespace definition - * (or internally %NULL if the current namespace is unknown) - * @is_radiotap_ns: indicates whether the current namespace is the default - * radiotap namespace or not - * - * @_rtheader: pointer to the radiotap header we are walking through - * @_max_length: length of radiotap header in cpu byte ordering - * @_arg_index: next argument index - * @_arg: next argument pointer - * @_next_bitmap: internal pointer to next present u32 - * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present - * @_vns: vendor namespace definitions - * @_next_ns_data: beginning of the next namespace's data - * @_reset_on_ext: internal; reset the arg index to 0 when going to the - * next bitmap word - * - * Describes the radiotap parser state. Fields prefixed with an underscore - * must not be used by users of the parser, only by the parser internally. - */ - -struct ieee80211_radiotap_iterator { - struct ieee80211_radiotap_header *_rtheader; - const struct ieee80211_radiotap_vendor_namespaces *_vns; - const struct ieee80211_radiotap_namespace *current_namespace; - - unsigned char *_arg, *_next_ns_data; - __le32 *_next_bitmap; - - unsigned char *this_arg; - int this_arg_index; - int this_arg_size; - - int is_radiotap_ns; - - int _max_length; - int _arg_index; - uint32_t _bitmap_shifter; - int _reset_on_ext; -}; - -extern int ieee80211_radiotap_iterator_init( - struct ieee80211_radiotap_iterator *iterator, - struct ieee80211_radiotap_header *radiotap_header, - int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns); - -extern int ieee80211_radiotap_iterator_next( - struct ieee80211_radiotap_iterator *iterator); - - -extern const unsigned char rfc1042_header[6]; -extern const unsigned char bridge_tunnel_header[6]; - -/* Parsed Information Elements */ -struct ieee802_11_elems { - u8 *ie_start; - size_t total_len; - - /* pointers to IEs */ - u8 *ssid; - u8 *supp_rates; - u8 *fh_params; - u8 *ds_params; - u8 *cf_params; - struct ieee80211_tim_ie *tim; - u8 *ibss_params; - u8 *challenge; - u8 *wpa; - u8 *rsn; - u8 *erp_info; - u8 *ext_supp_rates; - u8 *wmm_info; - u8 *wmm_param; - struct ieee80211_ht_cap *ht_cap_elem; - struct ieee80211_ht_info *ht_info_elem; - struct ieee80211_meshconf_ie *mesh_config; - u8 *mesh_id; - u8 *peering; - u8 *preq; - u8 *prep; - u8 *perr; - struct ieee80211_rann_ie *rann; - u8 *ch_switch_elem; - u8 *country_elem; - u8 *pwr_constr_elem; - u8 *quiet_elem; /* first quite element */ - u8 *timeout_int; - - /* length of them, respectively */ - u8 ssid_len; - u8 supp_rates_len; - u8 fh_params_len; - u8 ds_params_len; - u8 cf_params_len; - u8 tim_len; - u8 ibss_params_len; - u8 challenge_len; - u8 wpa_len; - u8 rsn_len; - u8 erp_info_len; - u8 ext_supp_rates_len; - u8 wmm_info_len; - u8 wmm_param_len; - u8 mesh_id_len; - u8 peering_len; - u8 preq_len; - u8 prep_len; - u8 perr_len; - u8 ch_switch_elem_len; - u8 country_elem_len; - u8 pwr_constr_elem_len; - u8 quiet_elem_len; - u8 num_of_quiet_elem; /* can be more the one */ - u8 timeout_int_len; -}; - -/** - * ieee80211_get_hdrlen_from_skb - get header length from data - * - * Given an skb with a raw 802.11 header at the data pointer this function - * returns the 802.11 header length in bytes (not including encryption - * headers). If the data in the sk_buff is too short to contain a valid 802.11 - * header the function returns 0. - * - * @skb: the frame - */ -unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); - -/** - * ieee80211_hdrlen - get header length in bytes from frame control - * @fc: frame control field in little-endian format - */ -unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc); - -/** - * DOC: Data path helpers - * - * In addition to generic utilities, cfg80211 also offers - * functions that help implement the data path for devices - * that do not do the 802.11/802.3 conversion on the device. - */ - -/** - * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3 - * @skb: the 802.11 data frame - * @addr: the device MAC address - * @iftype: the virtual interface type - */ -int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, - enum nl80211_iftype iftype); - -/** - * ieee80211_data_from_8023 - convert an 802.3 frame to 802.11 - * @skb: the 802.3 frame - * @addr: the device MAC address - * @iftype: the virtual interface type - * @bssid: the network bssid (used only for iftype STATION and ADHOC) - * @qos: build 802.11 QoS data frame - */ -int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, - enum nl80211_iftype iftype, u8 *bssid, bool qos); - -/** - * ieee80211_amsdu_to_8023s - decode an IEEE 802.11n A-MSDU frame - * - * Decode an IEEE 802.11n A-MSDU frame and convert it to a list of - * 802.3 frames. The @list will be empty if the decode fails. The - * @skb is consumed after the function returns. - * - * @skb: The input IEEE 802.11n A-MSDU frame. - * @list: The output list of 802.3 frames. It must be allocated and - * initialized by by the caller. - * @addr: The device MAC address. - * @iftype: The device interface type. - * @extra_headroom: The hardware extra headroom for SKBs in the @list. - * @has_80211_header: Set it true if SKB is with IEEE 802.11 header. - */ -void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, - const u8 *addr, enum nl80211_iftype iftype, - const unsigned int extra_headroom, - bool has_80211_header); - -/** - * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame - * @skb: the data frame - */ -unsigned int cfg80211_classify8021d(struct sk_buff *skb); - -/** - * cfg80211_find_ie - find information element in data - * - * @eid: element ID - * @ies: data consisting of IEs - * @len: length of data - * - * This function will return %NULL if the element ID could - * not be found or if the element is invalid (claims to be - * longer than the given data), or a pointer to the first byte - * of the requested element, that is the byte containing the - * element ID. There are no checks on the element length - * other than having to fit into the given data. - */ -const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len); - -/** - * cfg80211_find_vendor_ie - find vendor specific information element in data - * - * @oui: vendor OUI - * @oui_type: vendor-specific OUI type - * @ies: data consisting of IEs - * @len: length of data - * - * This function will return %NULL if the vendor specific element ID - * could not be found or if the element is invalid (claims to be - * longer than the given data), or a pointer to the first byte - * of the requested element, that is the byte containing the - * element ID. There are no checks on the element length - * other than having to fit into the given data. - */ -const u8 *cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type, - const u8 *ies, int len); - -/** - * DOC: Regulatory enforcement infrastructure - * - * TODO - */ - -/** - * regulatory_hint - driver hint to the wireless core a regulatory domain - * @wiphy: the wireless device giving the hint (used only for reporting - * conflicts) - * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain - * should be in. If @rd is set this should be NULL. Note that if you - * set this to NULL you should still set rd->alpha2 to some accepted - * alpha2. - * - * Wireless drivers can use this function to hint to the wireless core - * what it believes should be the current regulatory domain by - * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory - * domain should be in or by providing a completely build regulatory domain. - * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried - * for a regulatory domain structure for the respective country. - * - * The wiphy must have been registered to cfg80211 prior to this call. - * For cfg80211 drivers this means you must first use wiphy_register(), - * for mac80211 drivers you must first use ieee80211_register_hw(). - * - * Drivers should check the return value, its possible you can get - * an -ENOMEM. - */ -extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2); - -/** - * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain - * @wiphy: the wireless device we want to process the regulatory domain on - * @regd: the custom regulatory domain to use for this wiphy - * - * Drivers can sometimes have custom regulatory domains which do not apply - * to a specific country. Drivers can use this to apply such custom regulatory - * domains. This routine must be called prior to wiphy registration. The - * custom regulatory domain will be trusted completely and as such previous - * default channel settings will be disregarded. If no rule is found for a - * channel on the regulatory domain the channel will be disabled. - */ -extern void wiphy_apply_custom_regulatory( - struct wiphy *wiphy, - const struct ieee80211_regdomain *regd); - -/** - * freq_reg_info - get regulatory information for the given frequency - * @wiphy: the wiphy for which we want to process this rule for - * @center_freq: Frequency in KHz for which we want regulatory information for - * @desired_bw_khz: the desired max bandwidth you want to use per - * channel. Note that this is still 20 MHz if you want to use HT40 - * as HT40 makes use of two channels for its 40 MHz width bandwidth. - * If set to 0 we'll assume you want the standard 20 MHz. - * @reg_rule: the regulatory rule which we have for this frequency - * - * Use this function to get the regulatory rule for a specific frequency on - * a given wireless device. If the device has a specific regulatory domain - * it wants to follow we respect that unless a country IE has been received - * and processed already. - * - * Returns 0 if it was able to find a valid regulatory rule which does - * apply to the given center_freq otherwise it returns non-zero. It will - * also return -ERANGE if we determine the given center_freq does not even have - * a regulatory rule for a frequency range in the center_freq's band. See - * freq_in_rule_band() for our current definition of a band -- this is purely - * subjective and right now its 802.11 specific. - */ -extern int freq_reg_info(struct wiphy *wiphy, - u32 center_freq, - u32 desired_bw_khz, - const struct ieee80211_reg_rule **reg_rule); - -/* - * callbacks for asynchronous cfg80211 methods, notification - * functions and BSS handling helpers - */ - -/** - * cfg80211_scan_done - notify that scan finished - * - * @request: the corresponding scan request - * @aborted: set to true if the scan was aborted for any reason, - * userspace will be notified of that - */ -void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted); - -/** - * cfg80211_sched_scan_results - notify that new scan results are available - * - * @wiphy: the wiphy which got scheduled scan results - */ -void cfg80211_sched_scan_results(struct wiphy *wiphy); - -/** - * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped - * - * @wiphy: the wiphy on which the scheduled scan stopped - * - * The driver can call this function to inform cfg80211 that the - * scheduled scan had to be stopped, for whatever reason. The driver - * is then called back via the sched_scan_stop operation when done. - */ -void cfg80211_sched_scan_stopped(struct wiphy *wiphy); - -/** - * cfg80211_inform_bss_frame - inform cfg80211 of a received BSS frame - * - * @wiphy: the wiphy reporting the BSS - * @channel: The channel the frame was received on - * @mgmt: the management frame (probe response or beacon) - * @len: length of the management frame - * @signal: the signal strength, type depends on the wiphy's signal_type - * @gfp: context flags - * - * This informs cfg80211 that BSS information was found and - * the BSS should be updated/added. - * - * NOTE: Returns a referenced struct, must be released with cfg80211_put_bss()! - */ -struct cfg80211_bss * __must_check -cfg80211_inform_bss_frame(struct wiphy *wiphy, - struct ieee80211_channel *channel, - struct ieee80211_mgmt *mgmt, size_t len, - s32 signal, gfp_t gfp); - -/** - * cfg80211_inform_bss - inform cfg80211 of a new BSS - * - * @wiphy: the wiphy reporting the BSS - * @channel: The channel the frame was received on - * @bssid: the BSSID of the BSS - * @timestamp: the TSF timestamp sent by the peer - * @capability: the capability field sent by the peer - * @beacon_interval: the beacon interval announced by the peer - * @ie: additional IEs sent by the peer - * @ielen: length of the additional IEs - * @signal: the signal strength, type depends on the wiphy's signal_type - * @gfp: context flags - * - * This informs cfg80211 that BSS information was found and - * the BSS should be updated/added. - * - * NOTE: Returns a referenced struct, must be released with cfg80211_put_bss()! - */ -struct cfg80211_bss * __must_check -cfg80211_inform_bss(struct wiphy *wiphy, - struct ieee80211_channel *channel, - const u8 *bssid, - u64 timestamp, u16 capability, u16 beacon_interval, - const u8 *ie, size_t ielen, - s32 signal, gfp_t gfp); - -struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, - struct ieee80211_channel *channel, - const u8 *bssid, - const u8 *ssid, size_t ssid_len, - u16 capa_mask, u16 capa_val); -static inline struct cfg80211_bss * -cfg80211_get_ibss(struct wiphy *wiphy, - struct ieee80211_channel *channel, - const u8 *ssid, size_t ssid_len) -{ - return cfg80211_get_bss(wiphy, channel, NULL, ssid, ssid_len, - WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS); -} - -struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy, - struct ieee80211_channel *channel, - const u8 *meshid, size_t meshidlen, - const u8 *meshcfg); -void cfg80211_put_bss(struct cfg80211_bss *bss); - -/** - * cfg80211_unlink_bss - unlink BSS from internal data structures - * @wiphy: the wiphy - * @bss: the bss to remove - * - * This function removes the given BSS from the internal data structures - * thereby making it no longer show up in scan results etc. Use this - * function when you detect a BSS is gone. Normally BSSes will also time - * out, so it is not necessary to use this function at all. - */ -void cfg80211_unlink_bss(struct wiphy *wiphy, struct cfg80211_bss *bss); - -void cfg80211_unlink_allbss(struct wiphy *wiphy); - - -/** - * cfg80211_send_rx_auth - notification of processed authentication - * @dev: network device - * @buf: authentication frame (header + body) - * @len: length of the frame data - * - * This function is called whenever an authentication has been processed in - * station mode. The driver is required to call either this function or - * cfg80211_send_auth_timeout() to indicate the result of cfg80211_ops::auth() - * call. This function may sleep. - */ -void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len); - -/** - * cfg80211_send_auth_timeout - notification of timed out authentication - * @dev: network device - * @addr: The MAC address of the device with which the authentication timed out - * - * This function may sleep. - */ -void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr); - -/** - * __cfg80211_auth_canceled - notify cfg80211 that authentication was canceled - * @dev: network device - * @addr: The MAC address of the device with which the authentication timed out - * - * When a pending authentication had no action yet, the driver may decide - * to not send a deauth frame, but in that case must calls this function - * to tell cfg80211 about this decision. It is only valid to call this - * function within the deauth() callback. - */ -void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr); - -/** - * cfg80211_send_rx_assoc - notification of processed association - * @dev: network device - * @buf: (re)association response frame (header + body) - * @len: length of the frame data - * - * This function is called whenever a (re)association response has been - * processed in station mode. The driver is required to call either this - * function or cfg80211_send_assoc_timeout() to indicate the result of - * cfg80211_ops::assoc() call. This function may sleep. - */ -void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len); - -/** - * cfg80211_send_assoc_timeout - notification of timed out association - * @dev: network device - * @addr: The MAC address of the device with which the association timed out - * - * This function may sleep. - */ -void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr); - -/** - * cfg80211_send_deauth - notification of processed deauthentication - * @dev: network device - * @buf: deauthentication frame (header + body) - * @len: length of the frame data - * - * This function is called whenever deauthentication has been processed in - * station mode. This includes both received deauthentication frames and - * locally generated ones. This function may sleep. - */ -void cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len); - -/** - * __cfg80211_send_deauth - notification of processed deauthentication - * @dev: network device - * @buf: deauthentication frame (header + body) - * @len: length of the frame data - * - * Like cfg80211_send_deauth(), but doesn't take the wdev lock. - */ -void __cfg80211_send_deauth(struct net_device *dev, const u8 *buf, size_t len); - -/** - * cfg80211_send_disassoc - notification of processed disassociation - * @dev: network device - * @buf: disassociation response frame (header + body) - * @len: length of the frame data - * - * This function is called whenever disassociation has been processed in - * station mode. This includes both received disassociation frames and locally - * generated ones. This function may sleep. - */ -void cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, size_t len); - -/** - * __cfg80211_send_disassoc - notification of processed disassociation - * @dev: network device - * @buf: disassociation response frame (header + body) - * @len: length of the frame data - * - * Like cfg80211_send_disassoc(), but doesn't take the wdev lock. - */ -void __cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, - size_t len); - -/** - * cfg80211_send_unprot_deauth - notification of unprotected deauthentication - * @dev: network device - * @buf: deauthentication frame (header + body) - * @len: length of the frame data - * - * This function is called whenever a received Deauthentication frame has been - * dropped in station mode because of MFP being used but the Deauthentication - * frame was not protected. This function may sleep. - */ -void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf, - size_t len); - -/** - * cfg80211_send_unprot_disassoc - notification of unprotected disassociation - * @dev: network device - * @buf: disassociation frame (header + body) - * @len: length of the frame data - * - * This function is called whenever a received Disassociation frame has been - * dropped in station mode because of MFP being used but the Disassociation - * frame was not protected. This function may sleep. - */ -void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, - size_t len); - -/** - * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP) - * @dev: network device - * @addr: The source MAC address of the frame - * @key_type: The key type that the received frame used - * @key_id: Key identifier (0..3). Can be -1 if missing. - * @tsc: The TSC value of the frame that generated the MIC failure (6 octets) - * @gfp: allocation flags - * - * This function is called whenever the local MAC detects a MIC failure in a - * received frame. This matches with MLME-MICHAELMICFAILURE.indication() - * primitive. - */ -void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr, - enum nl80211_key_type key_type, int key_id, - const u8 *tsc, gfp_t gfp); - -/** - * cfg80211_ibss_joined - notify cfg80211 that device joined an IBSS - * - * @dev: network device - * @bssid: the BSSID of the IBSS joined - * @gfp: allocation flags - * - * This function notifies cfg80211 that the device joined an IBSS or - * switched to a different BSSID. Before this function can be called, - * either a beacon has to have been received from the IBSS, or one of - * the cfg80211_inform_bss{,_frame} functions must have been called - * with the locally generated beacon -- this guarantees that there is - * always a scan result for this IBSS. cfg80211 will handle the rest. - */ -void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp); - -/** - * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate - * - * @dev: network device - * @macaddr: the MAC address of the new candidate - * @ie: information elements advertised by the peer candidate - * @ie_len: lenght of the information elements buffer - * @gfp: allocation flags - * - * This function notifies cfg80211 that the mesh peer candidate has been - * detected, most likely via a beacon or, less likely, via a probe response. - * cfg80211 then sends a notification to userspace. - */ -void cfg80211_notify_new_peer_candidate(struct net_device *dev, - const u8 *macaddr, const u8 *ie, u8 ie_len, gfp_t gfp); - -/** - * DOC: RFkill integration - * - * RFkill integration in cfg80211 is almost invisible to drivers, - * as cfg80211 automatically registers an rfkill instance for each - * wireless device it knows about. Soft kill is also translated - * into disconnecting and turning all interfaces off, drivers are - * expected to turn off the device when all interfaces are down. - * - * However, devices may have a hard RFkill line, in which case they - * also need to interact with the rfkill subsystem, via cfg80211. - * They can do this with a few helper functions documented here. - */ - -/** - * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state - * @wiphy: the wiphy - * @blocked: block status - */ -void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked); - -/** - * wiphy_rfkill_start_polling - start polling rfkill - * @wiphy: the wiphy - */ -void wiphy_rfkill_start_polling(struct wiphy *wiphy); - -/** - * wiphy_rfkill_stop_polling - stop polling rfkill - * @wiphy: the wiphy - */ -void wiphy_rfkill_stop_polling(struct wiphy *wiphy); - -#ifdef CONFIG_NL80211_TESTMODE -/** - * DOC: Test mode - * - * Test mode is a set of utility functions to allow drivers to - * interact with driver-specific tools to aid, for instance, - * factory programming. - * - * This chapter describes how drivers interact with it, for more - * information see the nl80211 book's chapter on it. - */ - -/** - * cfg80211_testmode_alloc_reply_skb - allocate testmode reply - * @wiphy: the wiphy - * @approxlen: an upper bound of the length of the data that will - * be put into the skb - * - * This function allocates and pre-fills an skb for a reply to - * the testmode command. Since it is intended for a reply, calling - * it outside of the @testmode_cmd operation is invalid. - * - * The returned skb (or %NULL if any errors happen) is pre-filled - * with the wiphy index and set up in a way that any data that is - * put into the skb (with skb_put(), nla_put() or similar) will end - * up being within the %NL80211_ATTR_TESTDATA attribute, so all that - * needs to be done with the skb is adding data for the corresponding - * userspace tool which can then read that data out of the testdata - * attribute. You must not modify the skb in any other way. - * - * When done, call cfg80211_testmode_reply() with the skb and return - * its error code as the result of the @testmode_cmd operation. - */ -struct sk_buff *cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy, - int approxlen); - -/** - * cfg80211_testmode_reply - send the reply skb - * @skb: The skb, must have been allocated with - * cfg80211_testmode_alloc_reply_skb() - * - * Returns an error code or 0 on success, since calling this - * function will usually be the last thing before returning - * from the @testmode_cmd you should return the error code. - * Note that this function consumes the skb regardless of the - * return value. - */ -int cfg80211_testmode_reply(struct sk_buff *skb); - -/** - * cfg80211_testmode_alloc_event_skb - allocate testmode event - * @wiphy: the wiphy - * @approxlen: an upper bound of the length of the data that will - * be put into the skb - * @gfp: allocation flags - * - * This function allocates and pre-fills an skb for an event on the - * testmode multicast group. - * - * The returned skb (or %NULL if any errors happen) is set up in the - * same way as with cfg80211_testmode_alloc_reply_skb() but prepared - * for an event. As there, you should simply add data to it that will - * then end up in the %NL80211_ATTR_TESTDATA attribute. Again, you must - * not modify the skb in any other way. - * - * When done filling the skb, call cfg80211_testmode_event() with the - * skb to send the event. - */ -struct sk_buff *cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, - int approxlen, gfp_t gfp); - -/** - * cfg80211_testmode_event - send the event - * @skb: The skb, must have been allocated with - * cfg80211_testmode_alloc_event_skb() - * @gfp: allocation flags - * - * This function sends the given @skb, which must have been allocated - * by cfg80211_testmode_alloc_event_skb(), as an event. It always - * consumes it. - */ -void cfg80211_testmode_event(struct sk_buff *skb, gfp_t gfp); - -#define CFG80211_TESTMODE_CMD(cmd) .testmode_cmd = (cmd), -#define CFG80211_TESTMODE_DUMP(cmd) .testmode_dump = (cmd), -#else -#define CFG80211_TESTMODE_CMD(cmd) -#define CFG80211_TESTMODE_DUMP(cmd) -#endif - -/** - * cfg80211_connect_result - notify cfg80211 of connection result - * - * @dev: network device - * @bssid: the BSSID of the AP - * @req_ie: association request IEs (maybe be %NULL) - * @req_ie_len: association request IEs length - * @resp_ie: association response IEs (may be %NULL) - * @resp_ie_len: assoc response IEs length - * @status: status code, 0 for successful connection, use - * %WLAN_STATUS_UNSPECIFIED_FAILURE if your device cannot give you - * the real status code for failures. - * @gfp: allocation flags - * - * It should be called by the underlying driver whenever connect() has - * succeeded. - */ -void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, - const u8 *req_ie, size_t req_ie_len, - const u8 *resp_ie, size_t resp_ie_len, - u16 status, gfp_t gfp); - -/** - * cfg80211_roamed - notify cfg80211 of roaming - * - * @dev: network device - * @channel: the channel of the new AP - * @bssid: the BSSID of the new AP - * @req_ie: association request IEs (maybe be %NULL) - * @req_ie_len: association request IEs length - * @resp_ie: association response IEs (may be %NULL) - * @resp_ie_len: assoc response IEs length - * @gfp: allocation flags - * - * It should be called by the underlying driver whenever it roamed - * from one AP to another while connected. - */ -void cfg80211_roamed(struct net_device *dev, - struct ieee80211_channel *channel, - const u8 *bssid, - const u8 *req_ie, size_t req_ie_len, - const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp); - -/** - * cfg80211_roamed_bss - notify cfg80211 of roaming - * - * @dev: network device - * @bss: entry of bss to which STA got roamed - * @req_ie: association request IEs (maybe be %NULL) - * @req_ie_len: association request IEs length - * @resp_ie: association response IEs (may be %NULL) - * @resp_ie_len: assoc response IEs length - * @gfp: allocation flags - * - * This is just a wrapper to notify cfg80211 of roaming event with driver - * passing bss to avoid a race in timeout of the bss entry. It should be - * called by the underlying driver whenever it roamed from one AP to another - * while connected. Drivers which have roaming implemented in firmware - * may use this function to avoid a race in bss entry timeout where the bss - * entry of the new AP is seen in the driver, but gets timed out by the time - * it is accessed in __cfg80211_roamed() due to delay in scheduling - * rdev->event_work. In case of any failures, the reference is released - * either in cfg80211_roamed_bss() or in __cfg80211_romed(), Otherwise, - * it will be released while diconneting from the current bss. - */ -void cfg80211_roamed_bss(struct net_device *dev, struct cfg80211_bss *bss, - const u8 *req_ie, size_t req_ie_len, - const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp); - -/** - * cfg80211_disconnected - notify cfg80211 that connection was dropped - * - * @dev: network device - * @ie: information elements of the deauth/disassoc frame (may be %NULL) - * @ie_len: length of IEs - * @reason: reason code for the disconnection, set it to 0 if unknown - * @gfp: allocation flags - * - * After it calls this function, the driver should enter an idle state - * and not try to connect to any AP any more. - */ -void cfg80211_disconnected(struct net_device *dev, u16 reason, - u8 *ie, size_t ie_len, gfp_t gfp); - -/** - * cfg80211_ready_on_channel - notification of remain_on_channel start - * @dev: network device - * @cookie: the request cookie - * @chan: The current channel (from remain_on_channel request) - * @channel_type: Channel type - * @duration: Duration in milliseconds that the driver intents to remain on the - * channel - * @gfp: allocation flags - */ -void cfg80211_ready_on_channel(struct net_device *dev, u64 cookie, - struct ieee80211_channel *chan, - enum nl80211_channel_type channel_type, - unsigned int duration, gfp_t gfp); - -/** - * cfg80211_remain_on_channel_expired - remain_on_channel duration expired - * @dev: network device - * @cookie: the request cookie - * @chan: The current channel (from remain_on_channel request) - * @channel_type: Channel type - * @gfp: allocation flags - */ -void cfg80211_remain_on_channel_expired(struct net_device *dev, - u64 cookie, - struct ieee80211_channel *chan, - enum nl80211_channel_type channel_type, - gfp_t gfp); - - -/** - * cfg80211_new_sta - notify userspace about station - * - * @dev: the netdev - * @mac_addr: the station's address - * @sinfo: the station information - * @gfp: allocation flags - */ -void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, - struct station_info *sinfo, gfp_t gfp); - -/** - * cfg80211_del_sta - notify userspace about deletion of a station - * - * @dev: the netdev - * @mac_addr: the station's address - * @gfp: allocation flags - */ -void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp); - -/** - * cfg80211_rx_mgmt - notification of received, unprocessed management frame - * @dev: network device - * @freq: Frequency on which the frame was received in MHz - * @buf: Management frame (header + body) - * @len: length of the frame data - * @gfp: context flags - * - * Returns %true if a user space application has registered for this frame. - * For action frames, that makes it responsible for rejecting unrecognized - * action frames; %false otherwise, in which case for action frames the - * driver is responsible for rejecting the frame. - * - * This function is called whenever an Action frame is received for a station - * mode interface, but is not processed in kernel. - */ -bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, - size_t len, gfp_t gfp); - -/** - * cfg80211_mgmt_tx_status - notification of TX status for management frame - * @dev: network device - * @cookie: Cookie returned by cfg80211_ops::mgmt_tx() - * @buf: Management frame (header + body) - * @len: length of the frame data - * @ack: Whether frame was acknowledged - * @gfp: context flags - * - * This function is called whenever a management frame was requested to be - * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the - * transmission attempt. - */ -void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie, - const u8 *buf, size_t len, bool ack, gfp_t gfp); - - -/** - * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event - * @dev: network device - * @rssi_event: the triggered RSSI event - * @gfp: context flags - * - * This function is called when a configured connection quality monitoring - * rssi threshold reached event occurs. - */ -void cfg80211_cqm_rssi_notify(struct net_device *dev, - enum nl80211_cqm_rssi_threshold_event rssi_event, - gfp_t gfp); - -/** - * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer - * @dev: network device - * @peer: peer's MAC address - * @num_packets: how many packets were lost -- should be a fixed threshold - * but probably no less than maybe 50, or maybe a throughput dependent - * threshold (to account for temporary interference) - * @gfp: context flags - */ -void cfg80211_cqm_pktloss_notify(struct net_device *dev, - const u8 *peer, u32 num_packets, gfp_t gfp); - -/** - * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying - * @dev: network device - * @bssid: BSSID of AP (to avoid races) - * @replay_ctr: new replay counter - * @gfp: allocation flags - */ -void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, - const u8 *replay_ctr, gfp_t gfp); - -/** - * cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate - * @dev: network device - * @index: candidate index (the smaller the index, the higher the priority) - * @bssid: BSSID of AP - * @preauth: Whether AP advertises support for RSN pre-authentication - * @gfp: allocation flags - */ -void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, - const u8 *bssid, bool preauth, gfp_t gfp); - -/** - * cfg80211_rx_spurious_frame - inform userspace about a spurious frame - * @dev: The device the frame matched to - * @addr: the transmitter address - * @gfp: context flags - * - * This function is used in AP mode (only!) to inform userspace that - * a spurious class 3 frame was received, to be able to deauth the - * sender. - * Returns %true if the frame was passed to userspace (or this failed - * for a reason other than not having a subscription.) - */ -bool cfg80211_rx_spurious_frame(struct net_device *dev, - const u8 *addr, gfp_t gfp); - -/** - * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame - * @dev: The device the frame matched to - * @addr: the transmitter address - * @gfp: context flags - * - * This function is used in AP mode (only!) to inform userspace that - * an associated station sent a 4addr frame but that wasn't expected. - * It is allowed and desirable to send this event only once for each - * station to avoid event flooding. - * Returns %true if the frame was passed to userspace (or this failed - * for a reason other than not having a subscription.) - */ -bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, - const u8 *addr, gfp_t gfp); - -/** - * cfg80211_probe_status - notify userspace about probe status - * @dev: the device the probe was sent on - * @addr: the address of the peer - * @cookie: the cookie filled in @probe_client previously - * @acked: indicates whether probe was acked or not - * @gfp: allocation flags - */ -void cfg80211_probe_status(struct net_device *dev, const u8 *addr, - u64 cookie, bool acked, gfp_t gfp); - -/** - * cfg80211_report_obss_beacon - report beacon from other APs - * @wiphy: The wiphy that received the beacon - * @frame: the frame - * @len: length of the frame - * @freq: frequency the frame was received on - * @gfp: allocation flags - * - * Use this function to report to userspace when a beacon was - * received. It is not useful to call this when there is no - * netdev that is in AP/GO mode. - */ -void cfg80211_report_obss_beacon(struct wiphy *wiphy, - const u8 *frame, size_t len, - int freq, gfp_t gfp); - -/** - * cfg80211_priv_event - notify userspace about priv event - * @dev: the device the priv event was sent on - * @priv_event: event string - * @gfp: allocation flags - */ -void cfg80211_priv_event(struct net_device *dev, const char *priv_event, - gfp_t gfp); - - -/* Logging, debugging and troubleshooting/diagnostic helpers. */ - -/* wiphy_printk helpers, similar to dev_printk */ - -#define wiphy_printk(level, wiphy, format, args...) \ - dev_printk(level, &(wiphy)->dev, format, ##args) -#define wiphy_emerg(wiphy, format, args...) \ - dev_emerg(&(wiphy)->dev, format, ##args) -#define wiphy_alert(wiphy, format, args...) \ - dev_alert(&(wiphy)->dev, format, ##args) -#define wiphy_crit(wiphy, format, args...) \ - dev_crit(&(wiphy)->dev, format, ##args) -#define wiphy_err(wiphy, format, args...) \ - dev_err(&(wiphy)->dev, format, ##args) -#define wiphy_warn(wiphy, format, args...) \ - dev_warn(&(wiphy)->dev, format, ##args) -#define wiphy_notice(wiphy, format, args...) \ - dev_notice(&(wiphy)->dev, format, ##args) -#define wiphy_info(wiphy, format, args...) \ - dev_info(&(wiphy)->dev, format, ##args) - -#define wiphy_debug(wiphy, format, args...) \ - wiphy_printk(KERN_DEBUG, wiphy, format, ##args) - -#define wiphy_dbg(wiphy, format, args...) \ - dev_dbg(&(wiphy)->dev, format, ##args) - -#if defined(VERBOSE_DEBUG) -#define wiphy_vdbg wiphy_dbg -#else -#define wiphy_vdbg(wiphy, format, args...) \ -({ \ - if (0) \ - wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \ - 0; \ -}) -#endif - -/* - * wiphy_WARN() acts like wiphy_printk(), but with the key difference - * of using a WARN/WARN_ON to get the message out, including the - * file/line information and a backtrace. - */ -#define wiphy_WARN(wiphy, format, args...) \ - WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args); - -#endif /* __NET_CFG80211_H */ diff --git a/include/compat/net/ieee80211_radiotap.h b/include/compat/net/ieee80211_radiotap.h deleted file mode 100755 index 7139254..0000000 --- a/include/compat/net/ieee80211_radiotap.h +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (c) 2003, 2004 David Young. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of David Young may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID - * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - */ - -/* - * Modifications to fit into the linux IEEE 802.11 stack, - * Mike Kershaw (dragorn@kismetwireless.net) - */ - -#ifndef IEEE80211RADIOTAP_H -#define IEEE80211RADIOTAP_H - -#include <linux/if_ether.h> -#include <linux/kernel.h> -#include <asm/unaligned.h> - -/* Base version of the radiotap packet header data */ -#define PKTHDR_RADIOTAP_VERSION 0 - -/* A generic radio capture format is desirable. There is one for - * Linux, but it is neither rigidly defined (there were not even - * units given for some fields) nor easily extensible. - * - * I suggest the following extensible radio capture format. It is - * based on a bitmap indicating which fields are present. - * - * I am trying to describe precisely what the application programmer - * should expect in the following, and for that reason I tell the - * units and origin of each measurement (where it applies), or else I - * use sufficiently weaselly language ("is a monotonically nondecreasing - * function of...") that I cannot set false expectations for lawyerly - * readers. - */ - -/* - * The radio capture header precedes the 802.11 header. - * All data in the header is little endian on all platforms. - */ -struct ieee80211_radiotap_header { - u8 it_version; /* Version 0. Only increases - * for drastic changes, - * introduction of compatible - * new fields does not count. - */ - u8 it_pad; - __le16 it_len; /* length of the whole - * header in bytes, including - * it_version, it_pad, - * it_len, and data fields. - */ - __le32 it_present; /* A bitmap telling which - * fields are present. Set bit 31 - * (0x80000000) to extend the - * bitmap by another 32 bits. - * Additional extensions are made - * by setting bit 31. - */ -} __packed; - -/* Name Data type Units - * ---- --------- ----- - * - * IEEE80211_RADIOTAP_TSFT __le64 microseconds - * - * Value in microseconds of the MAC's 64-bit 802.11 Time - * Synchronization Function timer when the first bit of the - * MPDU arrived at the MAC. For received frames, only. - * - * IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap - * - * Tx/Rx frequency in MHz, followed by flags (see below). - * - * IEEE80211_RADIOTAP_FHSS __le16 see below - * - * For frequency-hopping radios, the hop set (first byte) - * and pattern (second byte). - * - * IEEE80211_RADIOTAP_RATE u8 500kb/s - * - * Tx/Rx data rate - * - * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from - * one milliwatt (dBm) - * - * RF signal power at the antenna, decibel difference from - * one milliwatt. - * - * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from - * one milliwatt (dBm) - * - * RF noise power at the antenna, decibel difference from one - * milliwatt. - * - * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB) - * - * RF signal power at the antenna, decibel difference from an - * arbitrary, fixed reference. - * - * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB) - * - * RF noise power at the antenna, decibel difference from an - * arbitrary, fixed reference point. - * - * IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless - * - * Quality of Barker code lock. Unitless. Monotonically - * nondecreasing with "better" lock strength. Called "Signal - * Quality" in datasheets. (Is there a standard way to measure - * this?) - * - * IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless - * - * Transmit power expressed as unitless distance from max - * power set at factory calibration. 0 is max power. - * Monotonically nondecreasing with lower power levels. - * - * IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB) - * - * Transmit power expressed as decibel distance from max power - * set at factory calibration. 0 is max power. Monotonically - * nondecreasing with lower power levels. - * - * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from - * one milliwatt (dBm) - * - * Transmit power expressed as dBm (decibels from a 1 milliwatt - * reference). This is the absolute power level measured at - * the antenna port. - * - * IEEE80211_RADIOTAP_FLAGS u8 bitmap - * - * Properties of transmitted and received frames. See flags - * defined below. - * - * IEEE80211_RADIOTAP_ANTENNA u8 antenna index - * - * Unitless indication of the Rx/Tx antenna for this packet. - * The first antenna is antenna 0. - * - * IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap - * - * Properties of received frames. See flags defined below. - * - * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap - * - * Properties of transmitted frames. See flags defined below. - * - * IEEE80211_RADIOTAP_RTS_RETRIES u8 data - * - * Number of rts retries a transmitted frame used. - * - * IEEE80211_RADIOTAP_DATA_RETRIES u8 data - * - * Number of unicast retries a transmitted frame used. - * - * IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless - * - * Contains a bitmap of known fields/flags, the flags, and - * the MCS index. - * - */ -enum ieee80211_radiotap_type { - IEEE80211_RADIOTAP_TSFT = 0, - IEEE80211_RADIOTAP_FLAGS = 1, - IEEE80211_RADIOTAP_RATE = 2, - IEEE80211_RADIOTAP_CHANNEL = 3, - IEEE80211_RADIOTAP_FHSS = 4, - IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, - IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, - IEEE80211_RADIOTAP_LOCK_QUALITY = 7, - IEEE80211_RADIOTAP_TX_ATTENUATION = 8, - IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, - IEEE80211_RADIOTAP_DBM_TX_POWER = 10, - IEEE80211_RADIOTAP_ANTENNA = 11, - IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, - IEEE80211_RADIOTAP_DB_ANTNOISE = 13, - IEEE80211_RADIOTAP_RX_FLAGS = 14, - IEEE80211_RADIOTAP_TX_FLAGS = 15, - IEEE80211_RADIOTAP_RTS_RETRIES = 16, - IEEE80211_RADIOTAP_DATA_RETRIES = 17, - - IEEE80211_RADIOTAP_MCS = 19, - - /* valid in every it_present bitmap, even vendor namespaces */ - IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, - IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, - IEEE80211_RADIOTAP_EXT = 31 -}; - -/* Channel flags. */ -#define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ -#define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ -#define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ -#define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ -#define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ -#define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ -#define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ -#define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ - -/* For IEEE80211_RADIOTAP_FLAGS */ -#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received - * during CFP - */ -#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received - * with short - * preamble - */ -#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received - * with WEP encryption - */ -#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received - * with fragmentation - */ -#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ -#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between - * 802.11 header and payload - * (to 32-bit boundary) - */ -#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* bad FCS */ - -/* For IEEE80211_RADIOTAP_RX_FLAGS */ -#define IEEE80211_RADIOTAP_F_RX_BADPLCP 0x0002 /* frame has bad PLCP */ - -/* For IEEE80211_RADIOTAP_TX_FLAGS */ -#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive - * retries */ -#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ -#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ -#define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* don't expect an ack */ - - -/* For IEEE80211_RADIOTAP_MCS */ -#define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01 -#define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02 -#define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04 -#define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08 -#define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10 - -#define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03 -#define IEEE80211_RADIOTAP_MCS_BW_20 0 -#define IEEE80211_RADIOTAP_MCS_BW_40 1 -#define IEEE80211_RADIOTAP_MCS_BW_20L 2 -#define IEEE80211_RADIOTAP_MCS_BW_20U 3 -#define IEEE80211_RADIOTAP_MCS_SGI 0x04 -#define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 -#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 - - -/* helpers */ -static inline int ieee80211_get_radiotap_len(unsigned char *data) -{ - struct ieee80211_radiotap_header *hdr = - (struct ieee80211_radiotap_header *)data; - - return get_unaligned_le16(&hdr->it_len); -} - -#endif /* IEEE80211_RADIOTAP_H */ diff --git a/include/compat/net/lib80211.h b/include/compat/net/lib80211.h deleted file mode 100755 index d178c26..0000000 --- a/include/compat/net/lib80211.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * lib80211.h -- common bits for IEEE802.11 wireless drivers - * - * Copyright (c) 2008, John W. Linville <linville@tuxdriver.com> - * - * Some bits copied from old ieee80211 component, w/ original copyright - * notices below: - * - * Original code based on Host AP (software wireless LAN access point) driver - * for Intersil Prism2/2.5/3. - * - * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen - * <j@w1.fi> - * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi> - * - * Adaption to a generic IEEE 802.11 stack by James Ketrenos - * <jketreno@linux.intel.com> - * - * Copyright (c) 2004, Intel Corporation - * - */ - -#ifndef LIB80211_H -#define LIB80211_H - -#include <linux/types.h> -#include <linux/list.h> -#include <linux/atomic.h> -#include <linux/if.h> -#include <linux/skbuff.h> -#include <linux/ieee80211.h> -#include <linux/timer.h> -/* print_ssid() is intended to be used in debug (and possibly error) - * messages. It should never be used for passing ssid to user space. */ -const char *print_ssid(char *buf, const char *ssid, u8 ssid_len); -#define DECLARE_SSID_BUF(var) char var[IEEE80211_MAX_SSID_LEN * 4 + 1] __maybe_unused - -#define NUM_WEP_KEYS 4 - -enum { - IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), -}; - -struct module; - -struct lib80211_crypto_ops { - const char *name; - struct list_head list; - - /* init new crypto context (e.g., allocate private data space, - * select IV, etc.); returns NULL on failure or pointer to allocated - * private data on success */ - void *(*init) (int keyidx); - - /* deinitialize crypto context and free allocated private data */ - void (*deinit) (void *priv); - - /* encrypt/decrypt return < 0 on error or >= 0 on success. The return - * value from decrypt_mpdu is passed as the keyidx value for - * decrypt_msdu. skb must have enough head and tail room for the - * encryption; if not, error will be returned; these functions are - * called for all MPDUs (i.e., fragments). - */ - int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); - int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); - - /* These functions are called for full MSDUs, i.e. full frames. - * These can be NULL if full MSDU operations are not needed. */ - int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv); - int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len, - void *priv); - - int (*set_key) (void *key, int len, u8 * seq, void *priv); - int (*get_key) (void *key, int len, u8 * seq, void *priv); - - /* procfs handler for printing out key information and possible - * statistics */ - char *(*print_stats) (char *p, void *priv); - - /* Crypto specific flag get/set for configuration settings */ - unsigned long (*get_flags) (void *priv); - unsigned long (*set_flags) (unsigned long flags, void *priv); - - /* maximum number of bytes added by encryption; encrypt buf is - * allocated with extra_prefix_len bytes, copy of in_buf, and - * extra_postfix_len; encrypt need not use all this space, but - * the result must start at the beginning of the buffer and correct - * length must be returned */ - int extra_mpdu_prefix_len, extra_mpdu_postfix_len; - int extra_msdu_prefix_len, extra_msdu_postfix_len; - - struct module *owner; -}; - -struct lib80211_crypt_data { - struct list_head list; /* delayed deletion list */ - struct lib80211_crypto_ops *ops; - void *priv; - atomic_t refcnt; -}; - -struct lib80211_crypt_info { - char *name; - /* Most clients will already have a lock, - so just point to that. */ - spinlock_t *lock; - - struct lib80211_crypt_data *crypt[NUM_WEP_KEYS]; - int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ - struct list_head crypt_deinit_list; - struct timer_list crypt_deinit_timer; - int crypt_quiesced; -}; - -int lib80211_crypt_info_init(struct lib80211_crypt_info *info, char *name, - spinlock_t *lock); -void lib80211_crypt_info_free(struct lib80211_crypt_info *info); -int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops); -int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops); -struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name); -void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info, - struct lib80211_crypt_data **crypt); - -#endif /* LIB80211_H */ diff --git a/include/compat/net/mac80211.h b/include/compat/net/mac80211.h deleted file mode 100755 index c26795fc..0000000 --- a/include/compat/net/mac80211.h +++ /dev/null @@ -1,3686 +0,0 @@ -/* - * mac80211 <-> driver interface - * - * Copyright 2002-2005, Devicescape Software, Inc. - * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> - * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef MAC80211_H -#define MAC80211_H - -#include <linux/kernel.h> -#include <linux/if_ether.h> -#include <linux/skbuff.h> -#include <linux/device.h> -#include <linux/ieee80211.h> -#include <net/cfg80211.h> -#include <asm/unaligned.h> - -/** - * DOC: Introduction - * - * mac80211 is the Linux stack for 802.11 hardware that implements - * only partial functionality in hard- or firmware. This document - * defines the interface between mac80211 and low-level hardware - * drivers. - */ - -/** - * DOC: Calling mac80211 from interrupts - * - * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be - * called in hardware interrupt context. The low-level driver must not call any - * other functions in hardware interrupt context. If there is a need for such - * call, the low-level driver should first ACK the interrupt and perform the - * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even - * tasklet function. - * - * NOTE: If the driver opts to use the _irqsafe() functions, it may not also - * use the non-IRQ-safe functions! - */ - -/** - * DOC: Warning - * - * If you're reading this document and not the header file itself, it will - * be incomplete because not all documentation has been converted yet. - */ - -/** - * DOC: Frame format - * - * As a general rule, when frames are passed between mac80211 and the driver, - * they start with the IEEE 802.11 header and include the same octets that are - * sent over the air except for the FCS which should be calculated by the - * hardware. - * - * There are, however, various exceptions to this rule for advanced features: - * - * The first exception is for hardware encryption and decryption offload - * where the IV/ICV may or may not be generated in hardware. - * - * Secondly, when the hardware handles fragmentation, the frame handed to - * the driver from mac80211 is the MSDU, not the MPDU. - * - * Finally, for received frames, the driver is able to indicate that it has - * filled a radiotap header and put that in front of the frame; if it does - * not do so then mac80211 may add this under certain circumstances. - */ - -/** - * DOC: mac80211 workqueue - * - * mac80211 provides its own workqueue for drivers and internal mac80211 use. - * The workqueue is a single threaded workqueue and can only be accessed by - * helpers for sanity checking. Drivers must ensure all work added onto the - * mac80211 workqueue should be cancelled on the driver stop() callback. - * - * mac80211 will flushed the workqueue upon interface removal and during - * suspend. - * - * All work performed on the mac80211 workqueue must not acquire the RTNL lock. - * - */ - -/** - * enum ieee80211_max_queues - maximum number of queues - * - * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues. - */ -enum ieee80211_max_queues { - IEEE80211_MAX_QUEUES = 4, -}; - -/** - * enum ieee80211_ac_numbers - AC numbers as used in mac80211 - * @IEEE80211_AC_VO: voice - * @IEEE80211_AC_VI: video - * @IEEE80211_AC_BE: best effort - * @IEEE80211_AC_BK: background - */ -enum ieee80211_ac_numbers { - IEEE80211_AC_VO = 0, - IEEE80211_AC_VI = 1, - IEEE80211_AC_BE = 2, - IEEE80211_AC_BK = 3, -}; -#define IEEE80211_NUM_ACS 4 - -/** - * struct ieee80211_tx_queue_params - transmit queue configuration - * - * The information provided in this structure is required for QoS - * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29. - * - * @aifs: arbitration interframe space [0..255] - * @cw_min: minimum contention window [a value of the form - * 2^n-1 in the range 1..32767] - * @cw_max: maximum contention window [like @cw_min] - * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled - * @uapsd: is U-APSD mode enabled for the queue - */ -struct ieee80211_tx_queue_params { - u16 txop; - u16 cw_min; - u16 cw_max; - u8 aifs; - bool uapsd; -}; - -struct ieee80211_low_level_stats { - unsigned int dot11ACKFailureCount; - unsigned int dot11RTSFailureCount; - unsigned int dot11FCSErrorCount; - unsigned int dot11RTSSuccessCount; -}; - -/** - * enum ieee80211_bss_change - BSS change notification flags - * - * These flags are used with the bss_info_changed() callback - * to indicate which BSS parameter changed. - * - * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated), - * also implies a change in the AID. - * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed - * @BSS_CHANGED_ERP_PREAMBLE: preamble changed - * @BSS_CHANGED_ERP_SLOT: slot timing changed - * @BSS_CHANGED_HT: 802.11n parameters changed - * @BSS_CHANGED_BASIC_RATES: Basic rateset changed - * @BSS_CHANGED_BEACON_INT: Beacon interval changed - * @BSS_CHANGED_BSSID: BSSID changed, for whatever - * reason (IBSS and managed mode) - * @BSS_CHANGED_BEACON: Beacon data changed, retrieve - * new beacon (beaconing modes) - * @BSS_CHANGED_BEACON_ENABLED: Beaconing should be - * enabled/disabled (beaconing modes) - * @BSS_CHANGED_CQM: Connection quality monitor config changed - * @BSS_CHANGED_IBSS: IBSS join status changed - * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed. - * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note - * that it is only ever disabled for station mode. - * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. - * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode) - * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode) - */ -enum ieee80211_bss_change { - BSS_CHANGED_ASSOC = 1<<0, - BSS_CHANGED_ERP_CTS_PROT = 1<<1, - BSS_CHANGED_ERP_PREAMBLE = 1<<2, - BSS_CHANGED_ERP_SLOT = 1<<3, - BSS_CHANGED_HT = 1<<4, - BSS_CHANGED_BASIC_RATES = 1<<5, - BSS_CHANGED_BEACON_INT = 1<<6, - BSS_CHANGED_BSSID = 1<<7, - BSS_CHANGED_BEACON = 1<<8, - BSS_CHANGED_BEACON_ENABLED = 1<<9, - BSS_CHANGED_CQM = 1<<10, - BSS_CHANGED_IBSS = 1<<11, - BSS_CHANGED_ARP_FILTER = 1<<12, - BSS_CHANGED_QOS = 1<<13, - BSS_CHANGED_IDLE = 1<<14, - BSS_CHANGED_SSID = 1<<15, - BSS_CHANGED_AP_PROBE_RESP = 1<<16, - - /* when adding here, make sure to change ieee80211_reconfig */ -}; - -/* - * The maximum number of IPv4 addresses listed for ARP filtering. If the number - * of addresses for an interface increase beyond this value, hardware ARP - * filtering will be disabled. - */ -#define IEEE80211_BSS_ARP_ADDR_LIST_LEN 4 - -/** - * enum ieee80211_rssi_event - RSSI threshold event - * An indicator for when RSSI goes below/above a certain threshold. - * @RSSI_EVENT_HIGH: AP's rssi crossed the high threshold set by the driver. - * @RSSI_EVENT_LOW: AP's rssi crossed the low threshold set by the driver. - */ -enum ieee80211_rssi_event { - RSSI_EVENT_HIGH, - RSSI_EVENT_LOW, -}; - -/** - * struct ieee80211_bss_conf - holds the BSS's changing parameters - * - * This structure keeps information about a BSS (and an association - * to that BSS) that can change during the lifetime of the BSS. - * - * @assoc: association status - * @ibss_joined: indicates whether this station is part of an IBSS - * or not - * @aid: association ID number, valid only when @assoc is true - * @use_cts_prot: use CTS protection - * @use_short_preamble: use 802.11b short preamble; - * if the hardware cannot handle this it must set the - * IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE hardware flag - * @use_short_slot: use short slot time (only relevant for ERP); - * if the hardware cannot handle this it must set the - * IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE hardware flag - * @dtim_period: num of beacons before the next DTIM, for beaconing, - * valid in station mode only while @assoc is true and if also - * requested by %IEEE80211_HW_NEED_DTIM_PERIOD (cf. also hw conf - * @ps_dtim_period) - * @timestamp: beacon timestamp - * @beacon_int: beacon interval - * @assoc_capability: capabilities taken from assoc resp - * @basic_rates: bitmap of basic rates, each bit stands for an - * index into the rate table configured by the driver in - * the current band. - * @mcast_rate: per-band multicast rate index + 1 (0: disabled) - * @bssid: The BSSID for this BSS - * @enable_beacon: whether beaconing should be enabled or not - * @channel_type: Channel type for this BSS -- the hardware might be - * configured for HT40+ while this BSS only uses no-HT, for - * example. - * @ht_operation_mode: HT operation mode (like in &struct ieee80211_ht_info). - * This field is only valid when the channel type is one of the HT types. - * @cqm_rssi_thold: Connection quality monitor RSSI threshold, a zero value - * implies disabled - * @cqm_rssi_hyst: Connection quality monitor RSSI hysteresis - * @arp_addr_list: List of IPv4 addresses for hardware ARP filtering. The - * may filter ARP queries targeted for other addresses than listed here. - * The driver must allow ARP queries targeted for all address listed here - * to pass through. An empty list implies no ARP queries need to pass. - * @arp_addr_cnt: Number of addresses currently on the list. - * @arp_filter_enabled: Enable ARP filtering - if enabled, the hardware may - * filter ARP queries based on the @arp_addr_list, if disabled, the - * hardware must not perform any ARP filtering. Note, that the filter will - * be enabled also in promiscuous mode. - * @qos: This is a QoS-enabled BSS. - * @idle: This interface is idle. There's also a global idle flag in the - * hardware config which may be more appropriate depending on what - * your driver/device needs to do. - * @ssid: The SSID of the current vif. Only valid in AP-mode. - * @ssid_len: Length of SSID given in @ssid. - * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode. - */ -struct ieee80211_bss_conf { - const u8 *bssid; - /* association related data */ - bool assoc, ibss_joined; - u16 aid; - /* erp related data */ - bool use_cts_prot; - bool use_short_preamble; - bool use_short_slot; - bool enable_beacon; - u8 dtim_period; - u16 beacon_int; - u16 assoc_capability; - u64 timestamp; - u32 basic_rates; - int mcast_rate[IEEE80211_NUM_BANDS]; - u16 ht_operation_mode; - s32 cqm_rssi_thold; - u32 cqm_rssi_hyst; - enum nl80211_channel_type channel_type; - __be32 arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN]; - u8 arp_addr_cnt; - bool arp_filter_enabled; - bool qos; - bool idle; - u8 ssid[IEEE80211_MAX_SSID_LEN]; - size_t ssid_len; - bool hidden_ssid; -}; - -/** - * enum mac80211_tx_control_flags - flags to describe transmission information/status - * - * These flags are used with the @flags member of &ieee80211_tx_info. - * - * @IEEE80211_TX_CTL_REQ_TX_STATUS: require TX status callback for this frame. - * @IEEE80211_TX_CTL_ASSIGN_SEQ: The driver has to assign a sequence - * number to this frame, taking care of not overwriting the fragment - * number and increasing the sequence number only when the - * IEEE80211_TX_CTL_FIRST_FRAGMENT flag is set. mac80211 will properly - * assign sequence numbers to QoS-data frames but cannot do so correctly - * for non-QoS-data and management frames because beacons need them from - * that counter as well and mac80211 cannot guarantee proper sequencing. - * If this flag is set, the driver should instruct the hardware to - * assign a sequence number to the frame or assign one itself. Cf. IEEE - * 802.11-2007 7.1.3.4.1 paragraph 3. This flag will always be set for - * beacons and always be clear for frames without a sequence number field. - * @IEEE80211_TX_CTL_NO_ACK: tell the low level not to wait for an ack - * @IEEE80211_TX_CTL_CLEAR_PS_FILT: clear powersave filter for destination - * station - * @IEEE80211_TX_CTL_FIRST_FRAGMENT: this is a first fragment of the frame - * @IEEE80211_TX_CTL_SEND_AFTER_DTIM: send this frame after DTIM beacon - * @IEEE80211_TX_CTL_AMPDU: this frame should be sent as part of an A-MPDU - * @IEEE80211_TX_CTL_INJECTED: Frame was injected, internal to mac80211. - * @IEEE80211_TX_STAT_TX_FILTERED: The frame was not transmitted - * because the destination STA was in powersave mode. Note that to - * avoid race conditions, the filter must be set by the hardware or - * firmware upon receiving a frame that indicates that the station - * went to sleep (must be done on device to filter frames already on - * the queue) and may only be unset after mac80211 gives the OK for - * that by setting the IEEE80211_TX_CTL_CLEAR_PS_FILT (see above), - * since only then is it guaranteed that no more frames are in the - * hardware queue. - * @IEEE80211_TX_STAT_ACK: Frame was acknowledged - * @IEEE80211_TX_STAT_AMPDU: The frame was aggregated, so status - * is for the whole aggregation. - * @IEEE80211_TX_STAT_AMPDU_NO_BACK: no block ack was returned, - * so consider using block ack request (BAR). - * @IEEE80211_TX_CTL_RATE_CTRL_PROBE: internal to mac80211, can be - * set by rate control algorithms to indicate probe rate, will - * be cleared for fragmented frames (except on the last fragment) - * @IEEE80211_TX_INTFL_NEED_TXPROCESSING: completely internal to mac80211, - * used to indicate that a pending frame requires TX processing before - * it can be sent out. - * @IEEE80211_TX_INTFL_RETRIED: completely internal to mac80211, - * used to indicate that a frame was already retried due to PS - * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211, - * used to indicate frame should not be encrypted - * @IEEE80211_TX_CTL_POLL_RESPONSE: This frame is a response to a poll - * frame (PS-Poll or uAPSD) and should be sent although the station - * is in powersave mode. - * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the - * transmit function after the current frame, this can be used - * by drivers to kick the DMA queue only if unset or when the - * queue gets full. - * @IEEE80211_TX_INTFL_RETRANSMISSION: This frame is being retransmitted - * after TX status because the destination was asleep, it must not - * be modified again (no seqno assignment, crypto, etc.) - * @IEEE80211_TX_INTFL_NL80211_FRAME_TX: Frame was requested through nl80211 - * MLME command (internal to mac80211 to figure out whether to send TX - * status to user space) - * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame - * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this - * frame and selects the maximum number of streams that it can use. - * @IEEE80211_TX_CTL_TX_OFFCHAN: Marks this packet to be transmitted on - * the off-channel channel when a remain-on-channel offload is done - * in hardware -- normal packets still flow and are expected to be - * handled properly by the device. - * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP - * testing. It will be sent out with incorrect Michael MIC key to allow - * TKIP countermeasures to be tested. - * @IEEE80211_TX_CTL_NO_CCK_RATE: This frame will be sent at non CCK rate. - * This flag is actually used for management frame especially for P2P - * frames not being sent at CCK rate in 2GHz band. - * @IEEE80211_TX_STATUS_EOSP: This packet marks the end of service period, - * when its status is reported the service period ends. For frames in - * an SP that mac80211 transmits, it is already set; for driver frames - * the driver may set this flag. It is also used to do the same for - * PS-Poll responses. - * @IEEE80211_TX_CTL_USE_MINRATE: This frame will be sent at lowest rate. - * This flag is used to send nullfunc frame at minimum rate when - * the nullfunc is used for connection monitoring purpose. - * @IEEE80211_TX_CTL_DONTFRAG: Don't fragment this packet even if it - * would be fragmented by size (this is optional, only used for - * monitor injection). - * - * Note: If you have to add new flags to the enumeration, then don't - * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary. - */ -enum mac80211_tx_control_flags { - IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0), - IEEE80211_TX_CTL_ASSIGN_SEQ = BIT(1), - IEEE80211_TX_CTL_NO_ACK = BIT(2), - IEEE80211_TX_CTL_CLEAR_PS_FILT = BIT(3), - IEEE80211_TX_CTL_FIRST_FRAGMENT = BIT(4), - IEEE80211_TX_CTL_SEND_AFTER_DTIM = BIT(5), - IEEE80211_TX_CTL_AMPDU = BIT(6), - IEEE80211_TX_CTL_INJECTED = BIT(7), - IEEE80211_TX_STAT_TX_FILTERED = BIT(8), - IEEE80211_TX_STAT_ACK = BIT(9), - IEEE80211_TX_STAT_AMPDU = BIT(10), - IEEE80211_TX_STAT_AMPDU_NO_BACK = BIT(11), - IEEE80211_TX_CTL_RATE_CTRL_PROBE = BIT(12), - IEEE80211_TX_INTFL_NEED_TXPROCESSING = BIT(14), - IEEE80211_TX_INTFL_RETRIED = BIT(15), - IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16), - IEEE80211_TX_CTL_POLL_RESPONSE = BIT(17), - IEEE80211_TX_CTL_MORE_FRAMES = BIT(18), - IEEE80211_TX_INTFL_RETRANSMISSION = BIT(19), - /* hole at 20, use later */ - IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21), - IEEE80211_TX_CTL_LDPC = BIT(22), - IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24), - IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25), - IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26), - IEEE80211_TX_CTL_NO_CCK_RATE = BIT(27), - IEEE80211_TX_STATUS_EOSP = BIT(28), - IEEE80211_TX_CTL_USE_MINRATE = BIT(29), - IEEE80211_TX_CTL_DONTFRAG = BIT(30), -}; - -#define IEEE80211_TX_CTL_STBC_SHIFT 23 - -/* - * This definition is used as a mask to clear all temporary flags, which are - * set by the tx handlers for each transmission attempt by the mac80211 stack. - */ -#define IEEE80211_TX_TEMPORARY_FLAGS (IEEE80211_TX_CTL_NO_ACK | \ - IEEE80211_TX_CTL_CLEAR_PS_FILT | IEEE80211_TX_CTL_FIRST_FRAGMENT | \ - IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \ - IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \ - IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \ - IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_POLL_RESPONSE | \ - IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \ - IEEE80211_TX_CTL_STBC | IEEE80211_TX_STATUS_EOSP) - -/** - * enum mac80211_rate_control_flags - per-rate flags set by the - * Rate Control algorithm. - * - * These flags are set by the Rate control algorithm for each rate during tx, - * in the @flags member of struct ieee80211_tx_rate. - * - * @IEEE80211_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate. - * @IEEE80211_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required. - * This is set if the current BSS requires ERP protection. - * @IEEE80211_TX_RC_USE_SHORT_PREAMBLE: Use short preamble. - * @IEEE80211_TX_RC_MCS: HT rate. - * @IEEE80211_TX_RC_GREEN_FIELD: Indicates whether this rate should be used in - * Greenfield mode. - * @IEEE80211_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be 40 MHz. - * @IEEE80211_TX_RC_DUP_DATA: The frame should be transmitted on both of the - * adjacent 20 MHz channels, if the current channel type is - * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS. - * @IEEE80211_TX_RC_SHORT_GI: Short Guard interval should be used for this rate. - */ -enum mac80211_rate_control_flags { - IEEE80211_TX_RC_USE_RTS_CTS = BIT(0), - IEEE80211_TX_RC_USE_CTS_PROTECT = BIT(1), - IEEE80211_TX_RC_USE_SHORT_PREAMBLE = BIT(2), - - /* rate index is an MCS rate number instead of an index */ - IEEE80211_TX_RC_MCS = BIT(3), - IEEE80211_TX_RC_GREEN_FIELD = BIT(4), - IEEE80211_TX_RC_40_MHZ_WIDTH = BIT(5), - IEEE80211_TX_RC_DUP_DATA = BIT(6), - IEEE80211_TX_RC_SHORT_GI = BIT(7), -}; - - -/* there are 40 bytes if you don't need the rateset to be kept */ -#define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40 - -/* if you do need the rateset, then you have less space */ -#define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24 - -/* maximum number of rate stages */ -#define IEEE80211_TX_MAX_RATES 5 - -/** - * struct ieee80211_tx_rate - rate selection/status - * - * @idx: rate index to attempt to send with - * @flags: rate control flags (&enum mac80211_rate_control_flags) - * @count: number of tries in this rate before going to the next rate - * - * A value of -1 for @idx indicates an invalid rate and, if used - * in an array of retry rates, that no more rates should be tried. - * - * When used for transmit status reporting, the driver should - * always report the rate along with the flags it used. - * - * &struct ieee80211_tx_info contains an array of these structs - * in the control information, and it will be filled by the rate - * control algorithm according to what should be sent. For example, - * if this array contains, in the format { <idx>, <count> } the - * information - * { 3, 2 }, { 2, 2 }, { 1, 4 }, { -1, 0 }, { -1, 0 } - * then this means that the frame should be transmitted - * up to twice at rate 3, up to twice at rate 2, and up to four - * times at rate 1 if it doesn't get acknowledged. Say it gets - * acknowledged by the peer after the fifth attempt, the status - * information should then contain - * { 3, 2 }, { 2, 2 }, { 1, 1 }, { -1, 0 } ... - * since it was transmitted twice at rate 3, twice at rate 2 - * and once at rate 1 after which we received an acknowledgement. - */ -struct ieee80211_tx_rate { - s8 idx; - u8 count; - u8 flags; -} __packed; - -/** - * struct ieee80211_tx_info - skb transmit information - * - * This structure is placed in skb->cb for three uses: - * (1) mac80211 TX control - mac80211 tells the driver what to do - * (2) driver internal use (if applicable) - * (3) TX status information - driver tells mac80211 what happened - * - * The TX control's sta pointer is only valid during the ->tx call, - * it may be NULL. - * - * @flags: transmit info flags, defined above - * @band: the band to transmit on (use for checking for races) - * @antenna_sel_tx: antenna to use, 0 for automatic diversity - * @ack_frame_id: internal frame ID for TX status, used internally - * @control: union for control data - * @status: union for status data - * @driver_data: array of driver_data pointers - * @ampdu_ack_len: number of acked aggregated frames. - * relevant only if IEEE80211_TX_STAT_AMPDU was set. - * @ampdu_len: number of aggregated frames. - * relevant only if IEEE80211_TX_STAT_AMPDU was set. - * @ack_signal: signal strength of the ACK frame - */ -struct ieee80211_tx_info { - /* common information */ - u32 flags; - u8 band; - - u8 antenna_sel_tx; - - u16 ack_frame_id; - - union { - struct { - union { - /* rate control */ - struct { - struct ieee80211_tx_rate rates[ - IEEE80211_TX_MAX_RATES]; - s8 rts_cts_rate_idx; - }; - /* only needed before rate control */ - unsigned long jiffies; - }; - /* NB: vif can be NULL for injected frames */ - struct ieee80211_vif *vif; - struct ieee80211_key_conf *hw_key; - struct ieee80211_sta *sta; - } control; - struct { - struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES]; - u8 ampdu_ack_len; - int ack_signal; - u8 ampdu_len; - /* 15 bytes free */ - } status; - struct { - struct ieee80211_tx_rate driver_rates[ - IEEE80211_TX_MAX_RATES]; - void *rate_driver_data[ - IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE / sizeof(void *)]; - }; - void *driver_data[ - IEEE80211_TX_INFO_DRIVER_DATA_SIZE / sizeof(void *)]; - }; -}; - -/** - * struct ieee80211_sched_scan_ies - scheduled scan IEs - * - * This structure is used to pass the appropriate IEs to be used in scheduled - * scans for all bands. It contains both the IEs passed from the userspace - * and the ones generated by mac80211. - * - * @ie: array with the IEs for each supported band - * @len: array with the total length of the IEs for each band - */ -struct ieee80211_sched_scan_ies { - u8 *ie[IEEE80211_NUM_BANDS]; - size_t len[IEEE80211_NUM_BANDS]; -}; - -static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb) -{ - return (struct ieee80211_tx_info *)skb->cb; -} - -static inline struct ieee80211_rx_status *IEEE80211_SKB_RXCB(struct sk_buff *skb) -{ - return (struct ieee80211_rx_status *)skb->cb; -} - -/** - * ieee80211_tx_info_clear_status - clear TX status - * - * @info: The &struct ieee80211_tx_info to be cleared. - * - * When the driver passes an skb back to mac80211, it must report - * a number of things in TX status. This function clears everything - * in the TX status but the rate control information (it does clear - * the count since you need to fill that in anyway). - * - * NOTE: You can only use this function if you do NOT use - * info->driver_data! Use info->rate_driver_data - * instead if you need only the less space that allows. - */ -static inline void -ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) -{ - int i; - - BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != - offsetof(struct ieee80211_tx_info, control.rates)); - BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != - offsetof(struct ieee80211_tx_info, driver_rates)); - BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, status.rates) != 8); - /* clear the rate counts */ - for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) - info->status.rates[i].count = 0; - - BUILD_BUG_ON( - offsetof(struct ieee80211_tx_info, status.ampdu_ack_len) != 23); - memset(&info->status.ampdu_ack_len, 0, - sizeof(struct ieee80211_tx_info) - - offsetof(struct ieee80211_tx_info, status.ampdu_ack_len)); -} - - -/** - * enum mac80211_rx_flags - receive flags - * - * These flags are used with the @flag member of &struct ieee80211_rx_status. - * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame. - * Use together with %RX_FLAG_MMIC_STRIPPED. - * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware. - * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame, - * verification has been done by the hardware. - * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame. - * If this flag is set, the stack cannot do any replay detection - * hence the driver or hardware will have to do that. - * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on - * the frame. - * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on - * the frame. - * @RX_FLAG_MACTIME_MPDU: The timestamp passed in the RX status (@mactime - * field) is valid and contains the time the first symbol of the MPDU - * was received. This is useful in monitor mode and for proper IBSS - * merging. - * @RX_FLAG_SHORTPRE: Short preamble was used for this frame - * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index - * @RX_FLAG_40MHZ: HT40 (40 MHz) was used - * @RX_FLAG_SHORT_GI: Short guard interval was used - */ -enum mac80211_rx_flags { - RX_FLAG_MMIC_ERROR = 1<<0, - RX_FLAG_DECRYPTED = 1<<1, - RX_FLAG_MMIC_STRIPPED = 1<<3, - RX_FLAG_IV_STRIPPED = 1<<4, - RX_FLAG_FAILED_FCS_CRC = 1<<5, - RX_FLAG_FAILED_PLCP_CRC = 1<<6, - RX_FLAG_MACTIME_MPDU = 1<<7, - RX_FLAG_SHORTPRE = 1<<8, - RX_FLAG_HT = 1<<9, - RX_FLAG_40MHZ = 1<<10, - RX_FLAG_SHORT_GI = 1<<11, -}; - -/** - * struct ieee80211_rx_status - receive status - * - * The low-level driver should provide this information (the subset - * supported by hardware) to the 802.11 code with each received - * frame, in the skb's control buffer (cb). - * - * @mactime: value in microseconds of the 64-bit Time Synchronization Function - * (TSF) timer when the first data symbol (MPDU) arrived at the hardware. - * @band: the active band when this frame was received - * @freq: frequency the radio was tuned to when receiving this frame, in MHz - * @signal: signal strength when receiving this frame, either in dBm, in dB or - * unspecified depending on the hardware capabilities flags - * @IEEE80211_HW_SIGNAL_* - * @antenna: antenna used - * @rate_idx: index of data rate into band's supported rates or MCS index if - * HT rates are use (RX_FLAG_HT) - * @flag: %RX_FLAG_* - * @rx_flags: internal RX flags for mac80211 - */ -struct ieee80211_rx_status { - u64 mactime; - enum ieee80211_band band; - int freq; - int signal; - int antenna; - int rate_idx; - int flag; - unsigned int rx_flags; -}; - -/** - * enum ieee80211_conf_flags - configuration flags - * - * Flags to define PHY configuration options - * - * @IEEE80211_CONF_MONITOR: there's a monitor interface present -- use this - * to determine for example whether to calculate timestamps for packets - * or not, do not use instead of filter flags! - * @IEEE80211_CONF_PS: Enable 802.11 power save mode (managed mode only). - * This is the power save mode defined by IEEE 802.11-2007 section 11.2, - * meaning that the hardware still wakes up for beacons, is able to - * transmit frames and receive the possible acknowledgment frames. - * Not to be confused with hardware specific wakeup/sleep states, - * driver is responsible for that. See the section "Powersave support" - * for more. - * @IEEE80211_CONF_IDLE: The device is running, but idle; if the flag is set - * the driver should be prepared to handle configuration requests but - * may turn the device off as much as possible. Typically, this flag will - * be set when an interface is set UP but not associated or scanning, but - * it can also be unset in that case when monitor interfaces are active. - * @IEEE80211_CONF_OFFCHANNEL: The device is currently not on its main - * operating channel. - */ -enum ieee80211_conf_flags { - IEEE80211_CONF_MONITOR = (1<<0), - IEEE80211_CONF_PS = (1<<1), - IEEE80211_CONF_IDLE = (1<<2), - IEEE80211_CONF_OFFCHANNEL = (1<<3), -}; - - -/** - * enum ieee80211_conf_changed - denotes which configuration changed - * - * @IEEE80211_CONF_CHANGE_LISTEN_INTERVAL: the listen interval changed - * @IEEE80211_CONF_CHANGE_MONITOR: the monitor flag changed - * @IEEE80211_CONF_CHANGE_PS: the PS flag or dynamic PS timeout changed - * @IEEE80211_CONF_CHANGE_POWER: the TX power changed - * @IEEE80211_CONF_CHANGE_CHANNEL: the channel/channel_type changed - * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed - * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed - * @IEEE80211_CONF_CHANGE_SMPS: Spatial multiplexing powersave mode changed - */ -enum ieee80211_conf_changed { - IEEE80211_CONF_CHANGE_SMPS = BIT(1), - IEEE80211_CONF_CHANGE_LISTEN_INTERVAL = BIT(2), - IEEE80211_CONF_CHANGE_MONITOR = BIT(3), - IEEE80211_CONF_CHANGE_PS = BIT(4), - IEEE80211_CONF_CHANGE_POWER = BIT(5), - IEEE80211_CONF_CHANGE_CHANNEL = BIT(6), - IEEE80211_CONF_CHANGE_RETRY_LIMITS = BIT(7), - IEEE80211_CONF_CHANGE_IDLE = BIT(8), -}; - -/** - * enum ieee80211_smps_mode - spatial multiplexing power save mode - * - * @IEEE80211_SMPS_AUTOMATIC: automatic - * @IEEE80211_SMPS_OFF: off - * @IEEE80211_SMPS_STATIC: static - * @IEEE80211_SMPS_DYNAMIC: dynamic - * @IEEE80211_SMPS_NUM_MODES: internal, don't use - */ -enum ieee80211_smps_mode { - IEEE80211_SMPS_AUTOMATIC, - IEEE80211_SMPS_OFF, - IEEE80211_SMPS_STATIC, - IEEE80211_SMPS_DYNAMIC, - - /* keep last */ - IEEE80211_SMPS_NUM_MODES, -}; - -/** - * struct ieee80211_conf - configuration of the device - * - * This struct indicates how the driver shall configure the hardware. - * - * @flags: configuration flags defined above - * - * @listen_interval: listen interval in units of beacon interval - * @max_sleep_period: the maximum number of beacon intervals to sleep for - * before checking the beacon for a TIM bit (managed mode only); this - * value will be only achievable between DTIM frames, the hardware - * needs to check for the multicast traffic bit in DTIM beacons. - * This variable is valid only when the CONF_PS flag is set. - * @ps_dtim_period: The DTIM period of the AP we're connected to, for use - * in power saving. Power saving will not be enabled until a beacon - * has been received and the DTIM period is known. - * @dynamic_ps_timeout: The dynamic powersave timeout (in ms), see the - * powersave documentation below. This variable is valid only when - * the CONF_PS flag is set. - * - * @power_level: requested transmit power (in dBm) - * - * @channel: the channel to tune to - * @channel_type: the channel (HT) type - * - * @long_frame_max_tx_count: Maximum number of transmissions for a "long" frame - * (a frame not RTS protected), called "dot11LongRetryLimit" in 802.11, - * but actually means the number of transmissions not the number of retries - * @short_frame_max_tx_count: Maximum number of transmissions for a "short" - * frame, called "dot11ShortRetryLimit" in 802.11, but actually means the - * number of transmissions not the number of retries - * - * @smps_mode: spatial multiplexing powersave mode; note that - * %IEEE80211_SMPS_STATIC is used when the device is not - * configured for an HT channel - */ -struct ieee80211_conf { - u32 flags; - int power_level, dynamic_ps_timeout; - int max_sleep_period; - - u16 listen_interval; - u8 ps_dtim_period; - - u8 long_frame_max_tx_count, short_frame_max_tx_count; - - struct ieee80211_channel *channel; - enum nl80211_channel_type channel_type; - enum ieee80211_smps_mode smps_mode; -}; - -/** - * struct ieee80211_channel_switch - holds the channel switch data - * - * The information provided in this structure is required for channel switch - * operation. - * - * @timestamp: value in microseconds of the 64-bit Time Synchronization - * Function (TSF) timer when the frame containing the channel switch - * announcement was received. This is simply the rx.mactime parameter - * the driver passed into mac80211. - * @block_tx: Indicates whether transmission must be blocked before the - * scheduled channel switch, as indicated by the AP. - * @channel: the new channel to switch to - * @count: the number of TBTT's until the channel switch event - */ -struct ieee80211_channel_switch { - u64 timestamp; - bool block_tx; - struct ieee80211_channel *channel; - u8 count; -}; - -/** - * struct ieee80211_vif - per-interface data - * - * Data in this structure is continually present for driver - * use during the life of a virtual interface. - * - * @type: type of this virtual interface - * @bss_conf: BSS configuration for this interface, either our own - * or the BSS we're associated to - * @addr: address of this interface - * @p2p: indicates whether this AP or STA interface is a p2p - * interface, i.e. a GO or p2p-sta respectively - * @drv_priv: data area for driver use, will always be aligned to - * sizeof(void *). - */ -struct ieee80211_vif { - enum nl80211_iftype type; - struct ieee80211_bss_conf bss_conf; - u8 addr[ETH_ALEN]; - bool p2p; - /* must be last */ - u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); -}; - -static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) -{ -#ifdef CONFIG_MAC80211_MESH - return vif->type == NL80211_IFTYPE_MESH_POINT; -#endif - return false; -} - -/** - * enum ieee80211_key_flags - key flags - * - * These flags are used for communication about keys between the driver - * and mac80211, with the @flags parameter of &struct ieee80211_key_conf. - * - * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates - * that the STA this key will be used with could be using QoS. - * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the - * driver to indicate that it requires IV generation for this - * particular key. - * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by - * the driver for a TKIP key if it requires Michael MIC - * generation in software. - * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates - * that the key is pairwise rather then a shared key. - * @IEEE80211_KEY_FLAG_SW_MGMT: This flag should be set by the driver for a - * CCMP key if it requires CCMP encryption of management frames (MFP) to - * be done in software. - * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver - * for a CCMP key if space should be prepared for the IV, but the IV - * itself should not be generated. Do not set together with - * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. - */ -enum ieee80211_key_flags { - IEEE80211_KEY_FLAG_WMM_STA = 1<<0, - IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1, - IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, - IEEE80211_KEY_FLAG_PAIRWISE = 1<<3, - IEEE80211_KEY_FLAG_SW_MGMT = 1<<4, - IEEE80211_KEY_FLAG_PUT_IV_SPACE = 1<<5, -}; - -/** - * struct ieee80211_key_conf - key information - * - * This key information is given by mac80211 to the driver by - * the set_key() callback in &struct ieee80211_ops. - * - * @hw_key_idx: To be set by the driver, this is the key index the driver - * wants to be given when a frame is transmitted and needs to be - * encrypted in hardware. - * @cipher: The key's cipher suite selector. - * @flags: key flags, see &enum ieee80211_key_flags. - * @keyidx: the key index (0-3) - * @keylen: key material length - * @key: key material. For ALG_TKIP the key is encoded as a 256-bit (32 byte) - * data block: - * - Temporal Encryption Key (128 bits) - * - Temporal Authenticator Tx MIC Key (64 bits) - * - Temporal Authenticator Rx MIC Key (64 bits) - * @icv_len: The ICV length for this key type - * @iv_len: The IV length for this key type - */ -struct ieee80211_key_conf { - u32 cipher; - u8 icv_len; - u8 iv_len; - u8 hw_key_idx; - u8 flags; - s8 keyidx; - u8 keylen; - u8 key[0]; -}; - -/** - * enum set_key_cmd - key command - * - * Used with the set_key() callback in &struct ieee80211_ops, this - * indicates whether a key is being removed or added. - * - * @SET_KEY: a key is set - * @DISABLE_KEY: a key must be disabled - */ -enum set_key_cmd { - SET_KEY, DISABLE_KEY, -}; - -/** - * struct ieee80211_sta - station table entry - * - * A station table entry represents a station we are possibly - * communicating with. Since stations are RCU-managed in - * mac80211, any ieee80211_sta pointer you get access to must - * either be protected by rcu_read_lock() explicitly or implicitly, - * or you must take good care to not use such a pointer after a - * call to your sta_remove callback that removed it. - * - * @addr: MAC address - * @aid: AID we assigned to the station if we're an AP - * @supp_rates: Bitmap of supported rates (per band) - * @ht_cap: HT capabilities of this STA; restricted to our own TX capabilities - * @wme: indicates whether the STA supports WME. Only valid during AP-mode. - * @drv_priv: data area for driver use, will always be aligned to - * sizeof(void *), size is determined in hw information. - * @uapsd_queues: bitmap of queues configured for uapsd. Only valid - * if wme is supported. - * @max_sp: max Service Period. Only valid if wme is supported. - */ -struct ieee80211_sta { - u32 supp_rates[IEEE80211_NUM_BANDS]; - u8 addr[ETH_ALEN]; - u16 aid; - struct ieee80211_sta_ht_cap ht_cap; - bool wme; - u8 uapsd_queues; - u8 max_sp; - - /* must be last */ - u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); -}; - -/** - * enum sta_notify_cmd - sta notify command - * - * Used with the sta_notify() callback in &struct ieee80211_ops, this - * indicates if an associated station made a power state transition. - * - * @STA_NOTIFY_SLEEP: a station is now sleeping - * @STA_NOTIFY_AWAKE: a sleeping station woke up - */ -enum sta_notify_cmd { - STA_NOTIFY_SLEEP, STA_NOTIFY_AWAKE, -}; - -/** - * enum ieee80211_hw_flags - hardware flags - * - * These flags are used to indicate hardware capabilities to - * the stack. Generally, flags here should have their meaning - * done in a way that the simplest hardware doesn't need setting - * any particular flags. There are some exceptions to this rule, - * however, so you are advised to review these flags carefully. - * - * @IEEE80211_HW_HAS_RATE_CONTROL: - * The hardware or firmware includes rate control, and cannot be - * controlled by the stack. As such, no rate control algorithm - * should be instantiated, and the TX rate reported to userspace - * will be taken from the TX status instead of the rate control - * algorithm. - * Note that this requires that the driver implement a number of - * callbacks so it has the correct information, it needs to have - * the @set_rts_threshold callback and must look at the BSS config - * @use_cts_prot for G/N protection, @use_short_slot for slot - * timing in 2.4 GHz and @use_short_preamble for preambles for - * CCK frames. - * - * @IEEE80211_HW_RX_INCLUDES_FCS: - * Indicates that received frames passed to the stack include - * the FCS at the end. - * - * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING: - * Some wireless LAN chipsets buffer broadcast/multicast frames - * for power saving stations in the hardware/firmware and others - * rely on the host system for such buffering. This option is used - * to configure the IEEE 802.11 upper layer to buffer broadcast and - * multicast frames when there are power saving stations so that - * the driver can fetch them with ieee80211_get_buffered_bc(). - * - * @IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE: - * Hardware is not capable of short slot operation on the 2.4 GHz band. - * - * @IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE: - * Hardware is not capable of receiving frames with short preamble on - * the 2.4 GHz band. - * - * @IEEE80211_HW_SIGNAL_UNSPEC: - * Hardware can provide signal values but we don't know its units. We - * expect values between 0 and @max_signal. - * If possible please provide dB or dBm instead. - * - * @IEEE80211_HW_SIGNAL_DBM: - * Hardware gives signal values in dBm, decibel difference from - * one milliwatt. This is the preferred method since it is standardized - * between different devices. @max_signal does not need to be set. - * - * @IEEE80211_HW_SPECTRUM_MGMT: - * Hardware supports spectrum management defined in 802.11h - * Measurement, Channel Switch, Quieting, TPC - * - * @IEEE80211_HW_AMPDU_AGGREGATION: - * Hardware supports 11n A-MPDU aggregation. - * - * @IEEE80211_HW_SUPPORTS_PS: - * Hardware has power save support (i.e. can go to sleep). - * - * @IEEE80211_HW_PS_NULLFUNC_STACK: - * Hardware requires nullfunc frame handling in stack, implies - * stack support for dynamic PS. - * - * @IEEE80211_HW_SUPPORTS_DYNAMIC_PS: - * Hardware has support for dynamic PS. - * - * @IEEE80211_HW_MFP_CAPABLE: - * Hardware supports management frame protection (MFP, IEEE 802.11w). - * - * @IEEE80211_HW_BEACON_FILTER: - * Hardware supports dropping of irrelevant beacon frames to - * avoid waking up cpu. - * - * @IEEE80211_HW_SUPPORTS_STATIC_SMPS: - * Hardware supports static spatial multiplexing powersave, - * ie. can turn off all but one chain even on HT connections - * that should be using more chains. - * - * @IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS: - * Hardware supports dynamic spatial multiplexing powersave, - * ie. can turn off all but one chain and then wake the rest - * up as required after, for example, rts/cts handshake. - * - * @IEEE80211_HW_SUPPORTS_UAPSD: - * Hardware supports Unscheduled Automatic Power Save Delivery - * (U-APSD) in managed mode. The mode is configured with - * conf_tx() operation. - * - * @IEEE80211_HW_REPORTS_TX_ACK_STATUS: - * Hardware can provide ack status reports of Tx frames to - * the stack. - * - * @IEEE80211_HW_CONNECTION_MONITOR: - * The hardware performs its own connection monitoring, including - * periodic keep-alives to the AP and probing the AP on beacon loss. - * When this flag is set, signaling beacon-loss will cause an immediate - * change to disassociated state. - * - * @IEEE80211_HW_SUPPORTS_CQM_RSSI: - * Hardware can do connection quality monitoring - i.e. it can monitor - * connection quality related parameters, such as the RSSI level and - * provide notifications if configured trigger levels are reached. - * - * @IEEE80211_HW_NEED_DTIM_PERIOD: - * This device needs to know the DTIM period for the BSS before - * associating. - * - * @IEEE80211_HW_SUPPORTS_PER_STA_GTK: The device's crypto engine supports - * per-station GTKs as used by IBSS RSN or during fast transition. If - * the device doesn't support per-station GTKs, but can be asked not - * to decrypt group addressed frames, then IBSS RSN support is still - * possible but software crypto will be used. Advertise the wiphy flag - * only in that case. - * - * @IEEE80211_HW_AP_LINK_PS: When operating in AP mode the device - * autonomously manages the PS status of connected stations. When - * this flag is set mac80211 will not trigger PS mode for connected - * stations based on the PM bit of incoming frames. - * Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure - * the PS mode of connected stations. - * - * @IEEE80211_HW_TX_AMPDU_SETUP_IN_HW: The device handles TX A-MPDU session - * setup strictly in HW. mac80211 should not attempt to do this in - * software. - */ -enum ieee80211_hw_flags { - IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, - IEEE80211_HW_RX_INCLUDES_FCS = 1<<1, - IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2, - IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE = 1<<3, - IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE = 1<<4, - IEEE80211_HW_SIGNAL_UNSPEC = 1<<5, - IEEE80211_HW_SIGNAL_DBM = 1<<6, - IEEE80211_HW_NEED_DTIM_PERIOD = 1<<7, - IEEE80211_HW_SPECTRUM_MGMT = 1<<8, - IEEE80211_HW_AMPDU_AGGREGATION = 1<<9, - IEEE80211_HW_SUPPORTS_PS = 1<<10, - IEEE80211_HW_PS_NULLFUNC_STACK = 1<<11, - IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 1<<12, - IEEE80211_HW_MFP_CAPABLE = 1<<13, - IEEE80211_HW_BEACON_FILTER = 1<<14, - IEEE80211_HW_SUPPORTS_STATIC_SMPS = 1<<15, - IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS = 1<<16, - IEEE80211_HW_SUPPORTS_UAPSD = 1<<17, - IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, - IEEE80211_HW_CONNECTION_MONITOR = 1<<19, - IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20, - IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, - IEEE80211_HW_AP_LINK_PS = 1<<22, - IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23, -}; - -/** - * struct ieee80211_hw - hardware information and state - * - * This structure contains the configuration and hardware - * information for an 802.11 PHY. - * - * @wiphy: This points to the &struct wiphy allocated for this - * 802.11 PHY. You must fill in the @perm_addr and @dev - * members of this structure using SET_IEEE80211_DEV() - * and SET_IEEE80211_PERM_ADDR(). Additionally, all supported - * bands (with channels, bitrates) are registered here. - * - * @conf: &struct ieee80211_conf, device configuration, don't use. - * - * @priv: pointer to private area that was allocated for driver use - * along with this structure. - * - * @flags: hardware flags, see &enum ieee80211_hw_flags. - * - * @extra_tx_headroom: headroom to reserve in each transmit skb - * for use by the driver (e.g. for transmit headers.) - * - * @channel_change_time: time (in microseconds) it takes to change channels. - * - * @max_signal: Maximum value for signal (rssi) in RX information, used - * only when @IEEE80211_HW_SIGNAL_UNSPEC or @IEEE80211_HW_SIGNAL_DB - * - * @max_listen_interval: max listen interval in units of beacon interval - * that HW supports - * - * @queues: number of available hardware transmit queues for - * data packets. WMM/QoS requires at least four, these - * queues need to have configurable access parameters. - * - * @rate_control_algorithm: rate control algorithm for this hardware. - * If unset (NULL), the default algorithm will be used. Must be - * set before calling ieee80211_register_hw(). - * - * @vif_data_size: size (in bytes) of the drv_priv data area - * within &struct ieee80211_vif. - * @sta_data_size: size (in bytes) of the drv_priv data area - * within &struct ieee80211_sta. - * - * @max_rates: maximum number of alternate rate retry stages the hw - * can handle. - * @max_report_rates: maximum number of alternate rate retry stages - * the hw can report back. - * @max_rate_tries: maximum number of tries for each stage - * - * @napi_weight: weight used for NAPI polling. You must specify an - * appropriate value here if a napi_poll operation is provided - * by your driver. - * - * @max_rx_aggregation_subframes: maximum buffer size (number of - * sub-frames) to be used for A-MPDU block ack receiver - * aggregation. - * This is only relevant if the device has restrictions on the - * number of subframes, if it relies on mac80211 to do reordering - * it shouldn't be set. - * - * @max_tx_aggregation_subframes: maximum number of subframes in an - * aggregate an HT driver will transmit, used by the peer as a - * hint to size its reorder buffer. - */ -struct ieee80211_hw { - struct ieee80211_conf conf; - struct wiphy *wiphy; - const char *rate_control_algorithm; - void *priv; - u32 flags; - unsigned int extra_tx_headroom; - int channel_change_time; - int vif_data_size; - int sta_data_size; - int napi_weight; - u16 queues; - u16 max_listen_interval; - s8 max_signal; - u8 max_rates; - u8 max_report_rates; - u8 max_rate_tries; - u8 max_rx_aggregation_subframes; - u8 max_tx_aggregation_subframes; -}; - -/** - * wiphy_to_ieee80211_hw - return a mac80211 driver hw struct from a wiphy - * - * @wiphy: the &struct wiphy which we want to query - * - * mac80211 drivers can use this to get to their respective - * &struct ieee80211_hw. Drivers wishing to get to their own private - * structure can then access it via hw->priv. Note that mac802111 drivers should - * not use wiphy_priv() to try to get their private driver structure as this - * is already used internally by mac80211. - */ -struct ieee80211_hw *wiphy_to_ieee80211_hw(struct wiphy *wiphy); - -/** - * SET_IEEE80211_DEV - set device for 802.11 hardware - * - * @hw: the &struct ieee80211_hw to set the device for - * @dev: the &struct device of this 802.11 device - */ -static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev) -{ - set_wiphy_dev(hw->wiphy, dev); -} - -/** - * SET_IEEE80211_PERM_ADDR - set the permanent MAC address for 802.11 hardware - * - * @hw: the &struct ieee80211_hw to set the MAC address for - * @addr: the address to set - */ -static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr) -{ - memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN); -} - -static inline struct ieee80211_rate * -ieee80211_get_tx_rate(const struct ieee80211_hw *hw, - const struct ieee80211_tx_info *c) -{ - if (WARN_ON(c->control.rates[0].idx < 0)) - return NULL; - return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx]; -} - -static inline struct ieee80211_rate * -ieee80211_get_rts_cts_rate(const struct ieee80211_hw *hw, - const struct ieee80211_tx_info *c) -{ - if (c->control.rts_cts_rate_idx < 0) - return NULL; - return &hw->wiphy->bands[c->band]->bitrates[c->control.rts_cts_rate_idx]; -} - -static inline struct ieee80211_rate * -ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, - const struct ieee80211_tx_info *c, int idx) -{ - if (c->control.rates[idx + 1].idx < 0) - return NULL; - return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[idx + 1].idx]; -} - -/** - * ieee80211_free_txskb - free TX skb - * @hw: the hardware - * @skb: the skb - * - * Free a transmit skb. Use this funtion when some failure - * to transmit happened and thus status cannot be reported. - */ -void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); - -/** - * DOC: Hardware crypto acceleration - * - * mac80211 is capable of taking advantage of many hardware - * acceleration designs for encryption and decryption operations. - * - * The set_key() callback in the &struct ieee80211_ops for a given - * device is called to enable hardware acceleration of encryption and - * decryption. The callback takes a @sta parameter that will be NULL - * for default keys or keys used for transmission only, or point to - * the station information for the peer for individual keys. - * Multiple transmission keys with the same key index may be used when - * VLANs are configured for an access point. - * - * When transmitting, the TX control data will use the @hw_key_idx - * selected by the driver by modifying the &struct ieee80211_key_conf - * pointed to by the @key parameter to the set_key() function. - * - * The set_key() call for the %SET_KEY command should return 0 if - * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be - * added; if you return 0 then hw_key_idx must be assigned to the - * hardware key index, you are free to use the full u8 range. - * - * When the cmd is %DISABLE_KEY then it must succeed. - * - * Note that it is permissible to not decrypt a frame even if a key - * for it has been uploaded to hardware, the stack will not make any - * decision based on whether a key has been uploaded or not but rather - * based on the receive flags. - * - * The &struct ieee80211_key_conf structure pointed to by the @key - * parameter is guaranteed to be valid until another call to set_key() - * removes it, but it can only be used as a cookie to differentiate - * keys. - * - * In TKIP some HW need to be provided a phase 1 key, for RX decryption - * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key - * handler. - * The update_tkip_key() call updates the driver with the new phase 1 key. - * This happens every time the iv16 wraps around (every 65536 packets). The - * set_key() call will happen only once for each key (unless the AP did - * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is - * provided by update_tkip_key only. The trigger that makes mac80211 call this - * handler is software decryption with wrap around of iv16. - */ - -/** - * DOC: Powersave support - * - * mac80211 has support for various powersave implementations. - * - * First, it can support hardware that handles all powersaving by itself, - * such hardware should simply set the %IEEE80211_HW_SUPPORTS_PS hardware - * flag. In that case, it will be told about the desired powersave mode - * with the %IEEE80211_CONF_PS flag depending on the association status. - * The hardware must take care of sending nullfunc frames when necessary, - * i.e. when entering and leaving powersave mode. The hardware is required - * to look at the AID in beacons and signal to the AP that it woke up when - * it finds traffic directed to it. - * - * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in - * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused - * with hardware wakeup and sleep states. Driver is responsible for waking - * up the hardware before issuing commands to the hardware and putting it - * back to sleep at appropriate times. - * - * When PS is enabled, hardware needs to wakeup for beacons and receive the - * buffered multicast/broadcast frames after the beacon. Also it must be - * possible to send frames and receive the acknowledment frame. - * - * Other hardware designs cannot send nullfunc frames by themselves and also - * need software support for parsing the TIM bitmap. This is also supported - * by mac80211 by combining the %IEEE80211_HW_SUPPORTS_PS and - * %IEEE80211_HW_PS_NULLFUNC_STACK flags. The hardware is of course still - * required to pass up beacons. The hardware is still required to handle - * waking up for multicast traffic; if it cannot the driver must handle that - * as best as it can, mac80211 is too slow to do that. - * - * Dynamic powersave is an extension to normal powersave in which the - * hardware stays awake for a user-specified period of time after sending a - * frame so that reply frames need not be buffered and therefore delayed to - * the next wakeup. It's compromise of getting good enough latency when - * there's data traffic and still saving significantly power in idle - * periods. - * - * Dynamic powersave is simply supported by mac80211 enabling and disabling - * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS - * flag and mac80211 will handle everything automatically. Additionally, - * hardware having support for the dynamic PS feature may set the - * %IEEE80211_HW_SUPPORTS_DYNAMIC_PS flag to indicate that it can support - * dynamic PS mode itself. The driver needs to look at the - * @dynamic_ps_timeout hardware configuration value and use it that value - * whenever %IEEE80211_CONF_PS is set. In this case mac80211 will disable - * dynamic PS feature in stack and will just keep %IEEE80211_CONF_PS - * enabled whenever user has enabled powersave. - * - * Some hardware need to toggle a single shared antenna between WLAN and - * Bluetooth to facilitate co-existence. These types of hardware set - * limitations on the use of host controlled dynamic powersave whenever there - * is simultaneous WLAN and Bluetooth traffic. For these types of hardware, the - * driver may request temporarily going into full power save, in order to - * enable toggling the antenna between BT and WLAN. If the driver requests - * disabling dynamic powersave, the @dynamic_ps_timeout value will be - * temporarily set to zero until the driver re-enables dynamic powersave. - * - * Driver informs U-APSD client support by enabling - * %IEEE80211_HW_SUPPORTS_UAPSD flag. The mode is configured through the - * uapsd paramater in conf_tx() operation. Hardware needs to send the QoS - * Nullfunc frames and stay awake until the service period has ended. To - * utilize U-APSD, dynamic powersave is disabled for voip AC and all frames - * from that AC are transmitted with powersave enabled. - * - * Note: U-APSD client mode is not yet supported with - * %IEEE80211_HW_PS_NULLFUNC_STACK. - */ - -/** - * DOC: Beacon filter support - * - * Some hardware have beacon filter support to reduce host cpu wakeups - * which will reduce system power consumption. It usuallly works so that - * the firmware creates a checksum of the beacon but omits all constantly - * changing elements (TSF, TIM etc). Whenever the checksum changes the - * beacon is forwarded to the host, otherwise it will be just dropped. That - * way the host will only receive beacons where some relevant information - * (for example ERP protection or WMM settings) have changed. - * - * Beacon filter support is advertised with the %IEEE80211_HW_BEACON_FILTER - * hardware capability. The driver needs to enable beacon filter support - * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When - * power save is enabled, the stack will not check for beacon loss and the - * driver needs to notify about loss of beacons with ieee80211_beacon_loss(). - * - * The time (or number of beacons missed) until the firmware notifies the - * driver of a beacon loss event (which in turn causes the driver to call - * ieee80211_beacon_loss()) should be configurable and will be controlled - * by mac80211 and the roaming algorithm in the future. - * - * Since there may be constantly changing information elements that nothing - * in the software stack cares about, we will, in the future, have mac80211 - * tell the driver which information elements are interesting in the sense - * that we want to see changes in them. This will include - * - a list of information element IDs - * - a list of OUIs for the vendor information element - * - * Ideally, the hardware would filter out any beacons without changes in the - * requested elements, but if it cannot support that it may, at the expense - * of some efficiency, filter out only a subset. For example, if the device - * doesn't support checking for OUIs it should pass up all changes in all - * vendor information elements. - * - * Note that change, for the sake of simplification, also includes information - * elements appearing or disappearing from the beacon. - * - * Some hardware supports an "ignore list" instead, just make sure nothing - * that was requested is on the ignore list, and include commonly changing - * information element IDs in the ignore list, for example 11 (BSS load) and - * the various vendor-assigned IEs with unknown contents (128, 129, 133-136, - * 149, 150, 155, 156, 173, 176, 178, 179, 219); for forward compatibility - * it could also include some currently unused IDs. - * - * - * In addition to these capabilities, hardware should support notifying the - * host of changes in the beacon RSSI. This is relevant to implement roaming - * when no traffic is flowing (when traffic is flowing we see the RSSI of - * the received data packets). This can consist in notifying the host when - * the RSSI changes significantly or when it drops below or rises above - * configurable thresholds. In the future these thresholds will also be - * configured by mac80211 (which gets them from userspace) to implement - * them as the roaming algorithm requires. - * - * If the hardware cannot implement this, the driver should ask it to - * periodically pass beacon frames to the host so that software can do the - * signal strength threshold checking. - */ - -/** - * DOC: Spatial multiplexing power save - * - * SMPS (Spatial multiplexing power save) is a mechanism to conserve - * power in an 802.11n implementation. For details on the mechanism - * and rationale, please refer to 802.11 (as amended by 802.11n-2009) - * "11.2.3 SM power save". - * - * The mac80211 implementation is capable of sending action frames - * to update the AP about the station's SMPS mode, and will instruct - * the driver to enter the specific mode. It will also announce the - * requested SMPS mode during the association handshake. Hardware - * support for this feature is required, and can be indicated by - * hardware flags. - * - * The default mode will be "automatic", which nl80211/cfg80211 - * defines to be dynamic SMPS in (regular) powersave, and SMPS - * turned off otherwise. - * - * To support this feature, the driver must set the appropriate - * hardware support flags, and handle the SMPS flag to the config() - * operation. It will then with this mechanism be instructed to - * enter the requested SMPS mode while associated to an HT AP. - */ - -/** - * DOC: Frame filtering - * - * mac80211 requires to see many management frames for proper - * operation, and users may want to see many more frames when - * in monitor mode. However, for best CPU usage and power consumption, - * having as few frames as possible percolate through the stack is - * desirable. Hence, the hardware should filter as much as possible. - * - * To achieve this, mac80211 uses filter flags (see below) to tell - * the driver's configure_filter() function which frames should be - * passed to mac80211 and which should be filtered out. - * - * Before configure_filter() is invoked, the prepare_multicast() - * callback is invoked with the parameters @mc_count and @mc_list - * for the combined multicast address list of all virtual interfaces. - * It's use is optional, and it returns a u64 that is passed to - * configure_filter(). Additionally, configure_filter() has the - * arguments @changed_flags telling which flags were changed and - * @total_flags with the new flag states. - * - * If your device has no multicast address filters your driver will - * need to check both the %FIF_ALLMULTI flag and the @mc_count - * parameter to see whether multicast frames should be accepted - * or dropped. - * - * All unsupported flags in @total_flags must be cleared. - * Hardware does not support a flag if it is incapable of _passing_ - * the frame to the stack. Otherwise the driver must ignore - * the flag, but not clear it. - * You must _only_ clear the flag (announce no support for the - * flag to mac80211) if you are not able to pass the packet type - * to the stack (so the hardware always filters it). - * So for example, you should clear @FIF_CONTROL, if your hardware - * always filters control frames. If your hardware always passes - * control frames to the kernel and is incapable of filtering them, - * you do _not_ clear the @FIF_CONTROL flag. - * This rule applies to all other FIF flags as well. - */ - -/** - * DOC: AP support for powersaving clients - * - * In order to implement AP and P2P GO modes, mac80211 has support for - * client powersaving, both "legacy" PS (PS-Poll/null data) and uAPSD. - * There currently is no support for sAPSD. - * - * There is one assumption that mac80211 makes, namely that a client - * will not poll with PS-Poll and trigger with uAPSD at the same time. - * Both are supported, and both can be used by the same client, but - * they can't be used concurrently by the same client. This simplifies - * the driver code. - * - * The first thing to keep in mind is that there is a flag for complete - * driver implementation: %IEEE80211_HW_AP_LINK_PS. If this flag is set, - * mac80211 expects the driver to handle most of the state machine for - * powersaving clients and will ignore the PM bit in incoming frames. - * Drivers then use ieee80211_sta_ps_transition() to inform mac80211 of - * stations' powersave transitions. In this mode, mac80211 also doesn't - * handle PS-Poll/uAPSD. - * - * In the mode without %IEEE80211_HW_AP_LINK_PS, mac80211 will check the - * PM bit in incoming frames for client powersave transitions. When a - * station goes to sleep, we will stop transmitting to it. There is, - * however, a race condition: a station might go to sleep while there is - * data buffered on hardware queues. If the device has support for this - * it will reject frames, and the driver should give the frames back to - * mac80211 with the %IEEE80211_TX_STAT_TX_FILTERED flag set which will - * cause mac80211 to retry the frame when the station wakes up. The - * driver is also notified of powersave transitions by calling its - * @sta_notify callback. - * - * When the station is asleep, it has three choices: it can wake up, - * it can PS-Poll, or it can possibly start a uAPSD service period. - * Waking up is implemented by simply transmitting all buffered (and - * filtered) frames to the station. This is the easiest case. When - * the station sends a PS-Poll or a uAPSD trigger frame, mac80211 - * will inform the driver of this with the @allow_buffered_frames - * callback; this callback is optional. mac80211 will then transmit - * the frames as usual and set the %IEEE80211_TX_CTL_POLL_RESPONSE - * on each frame. The last frame in the service period (or the only - * response to a PS-Poll) also has %IEEE80211_TX_STATUS_EOSP set to - * indicate that it ends the service period; as this frame must have - * TX status report it also sets %IEEE80211_TX_CTL_REQ_TX_STATUS. - * When TX status is reported for this frame, the service period is - * marked has having ended and a new one can be started by the peer. - * - * Another race condition can happen on some devices like iwlwifi - * when there are frames queued for the station and it wakes up - * or polls; the frames that are already queued could end up being - * transmitted first instead, causing reordering and/or wrong - * processing of the EOSP. The cause is that allowing frames to be - * transmitted to a certain station is out-of-band communication to - * the device. To allow this problem to be solved, the driver can - * call ieee80211_sta_block_awake() if frames are buffered when it - * is notified that the station went to sleep. When all these frames - * have been filtered (see above), it must call the function again - * to indicate that the station is no longer blocked. - * - * If the driver buffers frames in the driver for aggregation in any - * way, it must use the ieee80211_sta_set_buffered() call when it is - * notified of the station going to sleep to inform mac80211 of any - * TIDs that have frames buffered. Note that when a station wakes up - * this information is reset (hence the requirement to call it when - * informed of the station going to sleep). Then, when a service - * period starts for any reason, @release_buffered_frames is called - * with the number of frames to be released and which TIDs they are - * to come from. In this case, the driver is responsible for setting - * the EOSP (for uAPSD) and MORE_DATA bits in the released frames, - * to help the @more_data paramter is passed to tell the driver if - * there is more data on other TIDs -- the TIDs to release frames - * from are ignored since mac80211 doesn't know how many frames the - * buffers for those TIDs contain. - * - * If the driver also implement GO mode, where absence periods may - * shorten service periods (or abort PS-Poll responses), it must - * filter those response frames except in the case of frames that - * are buffered in the driver -- those must remain buffered to avoid - * reordering. Because it is possible that no frames are released - * in this case, the driver must call ieee80211_sta_eosp_irqsafe() - * to indicate to mac80211 that the service period ended anyway. - * - * Finally, if frames from multiple TIDs are released from mac80211 - * but the driver might reorder them, it must clear & set the flags - * appropriately (only the last frame may have %IEEE80211_TX_STATUS_EOSP) - * and also take care of the EOSP and MORE_DATA bits in the frame. - * The driver may also use ieee80211_sta_eosp_irqsafe() in this case. - */ - -/** - * enum ieee80211_filter_flags - hardware filter flags - * - * These flags determine what the filter in hardware should be - * programmed to let through and what should not be passed to the - * stack. It is always safe to pass more frames than requested, - * but this has negative impact on power consumption. - * - * @FIF_PROMISC_IN_BSS: promiscuous mode within your BSS, - * think of the BSS as your network segment and then this corresponds - * to the regular ethernet device promiscuous mode. - * - * @FIF_ALLMULTI: pass all multicast frames, this is used if requested - * by the user or if the hardware is not capable of filtering by - * multicast address. - * - * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the - * %RX_FLAG_FAILED_FCS_CRC for them) - * - * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set - * the %RX_FLAG_FAILED_PLCP_CRC for them - * - * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate - * to the hardware that it should not filter beacons or probe responses - * by BSSID. Filtering them can greatly reduce the amount of processing - * mac80211 needs to do and the amount of CPU wakeups, so you should - * honour this flag if possible. - * - * @FIF_CONTROL: pass control frames (except for PS Poll), if PROMISC_IN_BSS - * is not set then only those addressed to this station. - * - * @FIF_OTHER_BSS: pass frames destined to other BSSes - * - * @FIF_PSPOLL: pass PS Poll frames, if PROMISC_IN_BSS is not set then only - * those addressed to this station. - * - * @FIF_PROBE_REQ: pass probe request frames - */ -enum ieee80211_filter_flags { - FIF_PROMISC_IN_BSS = 1<<0, - FIF_ALLMULTI = 1<<1, - FIF_FCSFAIL = 1<<2, - FIF_PLCPFAIL = 1<<3, - FIF_BCN_PRBRESP_PROMISC = 1<<4, - FIF_CONTROL = 1<<5, - FIF_OTHER_BSS = 1<<6, - FIF_PSPOLL = 1<<7, - FIF_PROBE_REQ = 1<<8, -}; - -/** - * enum ieee80211_ampdu_mlme_action - A-MPDU actions - * - * These flags are used with the ampdu_action() callback in - * &struct ieee80211_ops to indicate which action is needed. - * - * Note that drivers MUST be able to deal with a TX aggregation - * session being stopped even before they OK'ed starting it by - * calling ieee80211_start_tx_ba_cb_irqsafe, because the peer - * might receive the addBA frame and send a delBA right away! - * - * @IEEE80211_AMPDU_RX_START: start Rx aggregation - * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation - * @IEEE80211_AMPDU_TX_START: start Tx aggregation - * @IEEE80211_AMPDU_TX_STOP: stop Tx aggregation - * @IEEE80211_AMPDU_TX_OPERATIONAL: TX aggregation has become operational - */ -enum ieee80211_ampdu_mlme_action { - IEEE80211_AMPDU_RX_START, - IEEE80211_AMPDU_RX_STOP, - IEEE80211_AMPDU_TX_START, - IEEE80211_AMPDU_TX_STOP, - IEEE80211_AMPDU_TX_OPERATIONAL, -}; - -/** - * enum ieee80211_tx_sync_type - TX sync type - * @IEEE80211_TX_SYNC_AUTH: sync TX for authentication - * (and possibly also before direct probe) - * @IEEE80211_TX_SYNC_ASSOC: sync TX for association - * @IEEE80211_TX_SYNC_ACTION: sync TX for action frame - * (not implemented yet) - */ -enum ieee80211_tx_sync_type { - IEEE80211_TX_SYNC_AUTH, - IEEE80211_TX_SYNC_ASSOC, - IEEE80211_TX_SYNC_ACTION, -}; - -/** - * enum ieee80211_frame_release_type - frame release reason - * @IEEE80211_FRAME_RELEASE_PSPOLL: frame released for PS-Poll - * @IEEE80211_FRAME_RELEASE_UAPSD: frame(s) released due to - * frame received on trigger-enabled AC - */ -enum ieee80211_frame_release_type { - IEEE80211_FRAME_RELEASE_PSPOLL, - IEEE80211_FRAME_RELEASE_UAPSD, -}; - -/** - * struct ieee80211_ops - callbacks from mac80211 to the driver - * - * This structure contains various callbacks that the driver may - * handle or, in some cases, must handle, for example to configure - * the hardware to a new channel or to transmit a frame. - * - * @tx: Handler that 802.11 module calls for each transmitted frame. - * skb contains the buffer starting from the IEEE 802.11 header. - * The low-level driver should send the frame out based on - * configuration in the TX control data. This handler should, - * preferably, never fail and stop queues appropriately, more - * importantly, however, it must never fail for A-MPDU-queues. - * This function should return NETDEV_TX_OK except in very - * limited cases. - * Must be implemented and atomic. - * - * @start: Called before the first netdevice attached to the hardware - * is enabled. This should turn on the hardware and must turn on - * frame reception (for possibly enabled monitor interfaces.) - * Returns negative error codes, these may be seen in userspace, - * or zero. - * When the device is started it should not have a MAC address - * to avoid acknowledging frames before a non-monitor device - * is added. - * Must be implemented and can sleep. - * - * @stop: Called after last netdevice attached to the hardware - * is disabled. This should turn off the hardware (at least - * it must turn off frame reception.) - * May be called right after add_interface if that rejects - * an interface. If you added any work onto the mac80211 workqueue - * you should ensure to cancel it on this callback. - * Must be implemented and can sleep. - * - * @suspend: Suspend the device; mac80211 itself will quiesce before and - * stop transmitting and doing any other configuration, and then - * ask the device to suspend. This is only invoked when WoWLAN is - * configured, otherwise the device is deconfigured completely and - * reconfigured at resume time. - * The driver may also impose special conditions under which it - * wants to use the "normal" suspend (deconfigure), say if it only - * supports WoWLAN when the device is associated. In this case, it - * must return 1 from this function. - * - * @resume: If WoWLAN was configured, this indicates that mac80211 is - * now resuming its operation, after this the device must be fully - * functional again. If this returns an error, the only way out is - * to also unregister the device. If it returns 1, then mac80211 - * will also go through the regular complete restart on resume. - * - * @add_interface: Called when a netdevice attached to the hardware is - * enabled. Because it is not called for monitor mode devices, @start - * and @stop must be implemented. - * The driver should perform any initialization it needs before - * the device can be enabled. The initial configuration for the - * interface is given in the conf parameter. - * The callback may refuse to add an interface by returning a - * negative error code (which will be seen in userspace.) - * Must be implemented and can sleep. - * - * @change_interface: Called when a netdevice changes type. This callback - * is optional, but only if it is supported can interface types be - * switched while the interface is UP. The callback may sleep. - * Note that while an interface is being switched, it will not be - * found by the interface iteration callbacks. - * - * @remove_interface: Notifies a driver that an interface is going down. - * The @stop callback is called after this if it is the last interface - * and no monitor interfaces are present. - * When all interfaces are removed, the MAC address in the hardware - * must be cleared so the device no longer acknowledges packets, - * the mac_addr member of the conf structure is, however, set to the - * MAC address of the device going away. - * Hence, this callback must be implemented. It can sleep. - * - * @config: Handler for configuration requests. IEEE 802.11 code calls this - * function to change hardware configuration, e.g., channel. - * This function should never fail but returns a negative error code - * if it does. The callback can sleep. - * - * @bss_info_changed: Handler for configuration requests related to BSS - * parameters that may vary during BSS's lifespan, and may affect low - * level driver (e.g. assoc/disassoc status, erp parameters). - * This function should not be used if no BSS has been set, unless - * for association indication. The @changed parameter indicates which - * of the bss parameters has changed when a call is made. The callback - * can sleep. - * - * @tx_sync: Called before a frame is sent to an AP/GO. In the GO case, the - * driver should sync with the GO's powersaving so the device doesn't - * transmit the frame while the GO is asleep. In the regular AP case - * it may be used by drivers for devices implementing other restrictions - * on talking to APs, e.g. due to regulatory enforcement or just HW - * restrictions. - * This function is called for every authentication, association and - * action frame separately since applications might attempt to auth - * with multiple APs before chosing one to associate to. If it returns - * an error, the corresponding authentication, association or frame - * transmission is aborted and reported as having failed. It is always - * called after tuning to the correct channel. - * The callback might be called multiple times before @finish_tx_sync - * (but @finish_tx_sync will be called once for each) but in practice - * this is unlikely to happen. It can also refuse in that case if the - * driver cannot handle that situation. - * This callback can sleep. - * @finish_tx_sync: Called as a counterpart to @tx_sync, unless that returned - * an error. This callback can sleep. - * - * @prepare_multicast: Prepare for multicast filter configuration. - * This callback is optional, and its return value is passed - * to configure_filter(). This callback must be atomic. - * - * @configure_filter: Configure the device's RX filter. - * See the section "Frame filtering" for more information. - * This callback must be implemented and can sleep. - * - * @set_tim: Set TIM bit. mac80211 calls this function when a TIM bit - * must be set or cleared for a given STA. Must be atomic. - * - * @set_key: See the section "Hardware crypto acceleration" - * This callback is only called between add_interface and - * remove_interface calls, i.e. while the given virtual interface - * is enabled. - * Returns a negative error code if the key can't be added. - * The callback can sleep. - * - * @update_tkip_key: See the section "Hardware crypto acceleration" - * This callback will be called in the context of Rx. Called for drivers - * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY. - * The callback must be atomic. - * - * @set_rekey_data: If the device supports GTK rekeying, for example while the - * host is suspended, it can assign this callback to retrieve the data - * necessary to do GTK rekeying, this is the KEK, KCK and replay counter. - * After rekeying was done it should (for example during resume) notify - * userspace of the new replay counter using ieee80211_gtk_rekey_notify(). - * - * @hw_scan: Ask the hardware to service the scan request, no need to start - * the scan state machine in stack. The scan must honour the channel - * configuration done by the regulatory agent in the wiphy's - * registered bands. The hardware (or the driver) needs to make sure - * that power save is disabled. - * The @req ie/ie_len members are rewritten by mac80211 to contain the - * entire IEs after the SSID, so that drivers need not look at these - * at all but just send them after the SSID -- mac80211 includes the - * (extended) supported rates and HT information (where applicable). - * When the scan finishes, ieee80211_scan_completed() must be called; - * note that it also must be called when the scan cannot finish due to - * any error unless this callback returned a negative error code. - * The callback can sleep. - * - * @cancel_hw_scan: Ask the low-level tp cancel the active hw scan. - * The driver should ask the hardware to cancel the scan (if possible), - * but the scan will be completed only after the driver will call - * ieee80211_scan_completed(). - * This callback is needed for wowlan, to prevent enqueueing a new - * scan_work after the low-level driver was already suspended. - * The callback can sleep. - * - * @sched_scan_start: Ask the hardware to start scanning repeatedly at - * specific intervals. The driver must call the - * ieee80211_sched_scan_results() function whenever it finds results. - * This process will continue until sched_scan_stop is called. - * - * @sched_scan_stop: Tell the hardware to stop an ongoing scheduled scan. - * - * @sw_scan_start: Notifier function that is called just before a software scan - * is started. Can be NULL, if the driver doesn't need this notification. - * The callback can sleep. - * - * @sw_scan_complete: Notifier function that is called just after a - * software scan finished. Can be NULL, if the driver doesn't need - * this notification. - * The callback can sleep. - * - * @get_stats: Return low-level statistics. - * Returns zero if statistics are available. - * The callback can sleep. - * - * @get_tkip_seq: If your device implements TKIP encryption in hardware this - * callback should be provided to read the TKIP transmit IVs (both IV32 - * and IV16) for the given key from hardware. - * The callback must be atomic. - * - * @set_frag_threshold: Configuration of fragmentation threshold. Assign this - * if the device does fragmentation by itself; if this callback is - * implemented then the stack will not do fragmentation. - * The callback can sleep. - * - * @set_rts_threshold: Configuration of RTS threshold (if device needs it) - * The callback can sleep. - * - * @sta_add: Notifies low level driver about addition of an associated station, - * AP, IBSS/WDS/mesh peer etc. This callback can sleep. - * - * @sta_remove: Notifies low level driver about removal of an associated - * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep. - * - * @sta_notify: Notifies low level driver about power state transition of an - * associated station, AP, IBSS/WDS/mesh peer etc. For a VIF operating - * in AP mode, this callback will not be called when the flag - * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic. - * - * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), - * bursting) for a hardware TX queue. - * Returns a negative error code on failure. - * The callback can sleep. - * - * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently, - * this is only used for IBSS mode BSSID merging and debugging. Is not a - * required function. - * The callback can sleep. - * - * @set_tsf: Set the TSF timer to the specified value in the firmware/hardware. - * Currently, this is only used for IBSS mode debugging. Is not a - * required function. - * The callback can sleep. - * - * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize - * with other STAs in the IBSS. This is only used in IBSS mode. This - * function is optional if the firmware/hardware takes full care of - * TSF synchronization. - * The callback can sleep. - * - * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us. - * This is needed only for IBSS mode and the result of this function is - * used to determine whether to reply to Probe Requests. - * Returns non-zero if this device sent the last beacon. - * The callback can sleep. - * - * @ampdu_action: Perform a certain A-MPDU action - * The RA/TID combination determines the destination and TID we want - * the ampdu action to be performed for. The action is defined through - * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn) - * is the first frame we expect to perform the action on. Notice - * that TX/RX_STOP can pass NULL for this parameter. - * The @buf_size parameter is only valid when the action is set to - * %IEEE80211_AMPDU_TX_OPERATIONAL and indicates the peer's reorder - * buffer size (number of subframes) for this session -- the driver - * may neither send aggregates containing more subframes than this - * nor send aggregates in a way that lost frames would exceed the - * buffer size. If just limiting the aggregate size, this would be - * possible with a buf_size of 8: - * - TX: 1.....7 - * - RX: 2....7 (lost frame #1) - * - TX: 8..1... - * which is invalid since #1 was now re-transmitted well past the - * buffer size of 8. Correct ways to retransmit #1 would be: - * - TX: 1 or 18 or 81 - * Even "189" would be wrong since 1 could be lost again. - * - * Returns a negative error code on failure. - * The callback can sleep. - * - * @get_survey: Return per-channel survey information - * - * @rfkill_poll: Poll rfkill hardware state. If you need this, you also - * need to set wiphy->rfkill_poll to %true before registration, - * and need to call wiphy_rfkill_set_hw_state() in the callback. - * The callback can sleep. - * - * @set_coverage_class: Set slot time for given coverage class as specified - * in IEEE 802.11-2007 section 17.3.8.6 and modify ACK timeout - * accordingly. This callback is not required and may sleep. - * - * @testmode_cmd: Implement a cfg80211 test mode command. - * The callback can sleep. - * @testmode_dump: Implement a cfg80211 test mode dump. The callback can sleep. - * - * @flush: Flush all pending frames from the hardware queue, making sure - * that the hardware queues are empty. If the parameter @drop is set - * to %true, pending frames may be dropped. The callback can sleep. - * - * @channel_switch: Drivers that need (or want) to offload the channel - * switch operation for CSAs received from the AP may implement this - * callback. They must then call ieee80211_chswitch_done() to indicate - * completion of the channel switch. - * - * @napi_poll: Poll Rx queue for incoming data frames. - * - * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device. - * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may - * reject TX/RX mask combinations they cannot support by returning -EINVAL - * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX). - * - * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant). - * - * @remain_on_channel: Starts an off-channel period on the given channel, must - * call back to ieee80211_ready_on_channel() when on that channel. Note - * that normal channel traffic is not stopped as this is intended for hw - * offload. Frames to transmit on the off-channel channel are transmitted - * normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the - * duration (which will always be non-zero) expires, the driver must call - * ieee80211_remain_on_channel_expired(). This callback may sleep. - * @cancel_remain_on_channel: Requests that an ongoing off-channel period is - * aborted before it expires. This callback may sleep. - * - * @set_ringparam: Set tx and rx ring sizes. - * - * @get_ringparam: Get tx and rx ring current and maximum sizes. - * - * @tx_frames_pending: Check if there is any pending frame in the hardware - * queues before entering power save. - * - * @set_bitrate_mask: Set a mask of rates to be used for rate control selection - * when transmitting a frame. Currently only legacy rates are handled. - * The callback can sleep. - * @rssi_callback: Notify driver when the average RSSI goes above/below - * thresholds that were registered previously. The callback can sleep. - * - * @release_buffered_frames: Release buffered frames according to the given - * parameters. In the case where the driver buffers some frames for - * sleeping stations mac80211 will use this callback to tell the driver - * to release some frames, either for PS-poll or uAPSD. - * Note that if the @more_data paramter is %false the driver must check - * if there are more frames on the given TIDs, and if there are more than - * the frames being released then it must still set the more-data bit in - * the frame. If the @more_data parameter is %true, then of course the - * more-data bit must always be set. - * The @tids parameter tells the driver which TIDs to release frames - * from, for PS-poll it will always have only a single bit set. - * In the case this is used for a PS-poll initiated release, the - * @num_frames parameter will always be 1 so code can be shared. In - * this case the driver must also set %IEEE80211_TX_STATUS_EOSP flag - * on the TX status (and must report TX status) so that the PS-poll - * period is properly ended. This is used to avoid sending multiple - * responses for a retried PS-poll frame. - * In the case this is used for uAPSD, the @num_frames parameter may be - * bigger than one, but the driver may send fewer frames (it must send - * at least one, however). In this case it is also responsible for - * setting the EOSP flag in the QoS header of the frames. Also, when the - * service period ends, the driver must set %IEEE80211_TX_STATUS_EOSP - * on the last frame in the SP. Alternatively, it may call the function - * ieee80211_sta_eosp_irqsafe() to inform mac80211 of the end of the SP. - * This callback must be atomic. - * @allow_buffered_frames: Prepare device to allow the given number of frames - * to go out to the given station. The frames will be sent by mac80211 - * via the usual TX path after this call. The TX information for frames - * released will also have the %IEEE80211_TX_CTL_POLL_RESPONSE flag set - * and the last one will also have %IEEE80211_TX_STATUS_EOSP set. In case - * frames from multiple TIDs are released and the driver might reorder - * them between the TIDs, it must set the %IEEE80211_TX_STATUS_EOSP flag - * on the last frame and clear it on all others and also handle the EOSP - * bit in the QoS header correctly. Alternatively, it can also call the - * ieee80211_sta_eosp_irqsafe() function. - * The @tids parameter is a bitmap and tells the driver which TIDs the - * frames will be on; it will at most have two bits set. - * This callback must be atomic. - */ -struct ieee80211_ops { - void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); - int (*start)(struct ieee80211_hw *hw); - void (*stop)(struct ieee80211_hw *hw); -#ifdef CONFIG_PM - int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); - int (*resume)(struct ieee80211_hw *hw); -#endif - int (*add_interface)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); - int (*change_interface)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype new_type, bool p2p); - void (*remove_interface)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); - int (*config)(struct ieee80211_hw *hw, u32 changed); - void (*bss_info_changed)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *info, - u32 changed); - - int (*tx_sync)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - const u8 *bssid, enum ieee80211_tx_sync_type type); - void (*finish_tx_sync)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - const u8 *bssid, - enum ieee80211_tx_sync_type type); - - u64 (*prepare_multicast)(struct ieee80211_hw *hw, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) - struct netdev_hw_addr_list *mc_list); -#else - int mc_count, struct dev_addr_list *mc_list); -#endif - void (*configure_filter)(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast); - int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta, - bool set); - int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, struct ieee80211_sta *sta, - struct ieee80211_key_conf *key); - void (*update_tkip_key)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_key_conf *conf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key); - void (*set_rekey_data)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_gtk_rekey_data *data); - int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct cfg80211_scan_request *req); - void (*cancel_hw_scan)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); - int (*sched_scan_start)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_sched_scan_request *req, - struct ieee80211_sched_scan_ies *ies); - void (*sched_scan_stop)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); - void (*sw_scan_start)(struct ieee80211_hw *hw); - void (*sw_scan_complete)(struct ieee80211_hw *hw); - int (*get_stats)(struct ieee80211_hw *hw, - struct ieee80211_low_level_stats *stats); - void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx, - u32 *iv32, u16 *iv16); - int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); - int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); - int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta); - int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - struct ieee80211_sta *sta); - void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - enum sta_notify_cmd, struct ieee80211_sta *sta); - int (*conf_tx)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params); - u64 (*get_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); - void (*set_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - u64 tsf); - void (*reset_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); - int (*tx_last_beacon)(struct ieee80211_hw *hw); - int (*ampdu_action)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size); - int (*get_survey)(struct ieee80211_hw *hw, int idx, - struct survey_info *survey); - void (*rfkill_poll)(struct ieee80211_hw *hw); - void (*set_coverage_class)(struct ieee80211_hw *hw, u8 coverage_class); -#ifdef CONFIG_NL80211_TESTMODE - int (*testmode_cmd)(struct ieee80211_hw *hw, void *data, int len); - int (*testmode_dump)(struct ieee80211_hw *hw, struct sk_buff *skb, - struct netlink_callback *cb, - void *data, int len); -#endif - void (*flush)(struct ieee80211_hw *hw, bool drop); - void (*channel_switch)(struct ieee80211_hw *hw, - struct ieee80211_channel_switch *ch_switch); - int (*napi_poll)(struct ieee80211_hw *hw, int budget); - int (*set_antenna)(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant); - int (*get_antenna)(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant); - - int (*remain_on_channel)(struct ieee80211_hw *hw, - struct ieee80211_channel *chan, - enum nl80211_channel_type channel_type, - int duration); - int (*cancel_remain_on_channel)(struct ieee80211_hw *hw); - int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx); - void (*get_ringparam)(struct ieee80211_hw *hw, - u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max); - bool (*tx_frames_pending)(struct ieee80211_hw *hw); - int (*set_bitrate_mask)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - const struct cfg80211_bitrate_mask *mask); - void (*rssi_callback)(struct ieee80211_hw *hw, - enum ieee80211_rssi_event rssi_event); - - void (*allow_buffered_frames)(struct ieee80211_hw *hw, - struct ieee80211_sta *sta, - u16 tids, int num_frames, - enum ieee80211_frame_release_type reason, - bool more_data); - void (*release_buffered_frames)(struct ieee80211_hw *hw, - struct ieee80211_sta *sta, - u16 tids, int num_frames, - enum ieee80211_frame_release_type reason, - bool more_data); -}; - -/** - * ieee80211_alloc_hw - Allocate a new hardware device - * - * This must be called once for each hardware device. The returned pointer - * must be used to refer to this device when calling other functions. - * mac80211 allocates a private data area for the driver pointed to by - * @priv in &struct ieee80211_hw, the size of this area is given as - * @priv_data_len. - * - * @priv_data_len: length of private data - * @ops: callbacks for this device - */ -struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, - const struct ieee80211_ops *ops); - -/** - * ieee80211_register_hw - Register hardware device - * - * You must call this function before any other functions in - * mac80211. Note that before a hardware can be registered, you - * need to fill the contained wiphy's information. - * - * @hw: the device to register as returned by ieee80211_alloc_hw() - */ -int ieee80211_register_hw(struct ieee80211_hw *hw); - -/** - * struct ieee80211_tpt_blink - throughput blink description - * @throughput: throughput in Kbit/sec - * @blink_time: blink time in milliseconds - * (full cycle, ie. one off + one on period) - */ -struct ieee80211_tpt_blink { - int throughput; - int blink_time; -}; - -/** - * enum ieee80211_tpt_led_trigger_flags - throughput trigger flags - * @IEEE80211_TPT_LEDTRIG_FL_RADIO: enable blinking with radio - * @IEEE80211_TPT_LEDTRIG_FL_WORK: enable blinking when working - * @IEEE80211_TPT_LEDTRIG_FL_CONNECTED: enable blinking when at least one - * interface is connected in some way, including being an AP - */ -enum ieee80211_tpt_led_trigger_flags { - IEEE80211_TPT_LEDTRIG_FL_RADIO = BIT(0), - IEEE80211_TPT_LEDTRIG_FL_WORK = BIT(1), - IEEE80211_TPT_LEDTRIG_FL_CONNECTED = BIT(2), -}; - -#ifdef CONFIG_MAC80211_LEDS -extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); -extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); -extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw); -extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw); -extern char *__ieee80211_create_tpt_led_trigger( - struct ieee80211_hw *hw, unsigned int flags, - const struct ieee80211_tpt_blink *blink_table, - unsigned int blink_table_len); -#endif -/** - * ieee80211_get_tx_led_name - get name of TX LED - * - * mac80211 creates a transmit LED trigger for each wireless hardware - * that can be used to drive LEDs if your driver registers a LED device. - * This function returns the name (or %NULL if not configured for LEDs) - * of the trigger so you can automatically link the LED device. - * - * @hw: the hardware to get the LED trigger name for - */ -static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw) -{ -#ifdef CONFIG_MAC80211_LEDS - return __ieee80211_get_tx_led_name(hw); -#else - return NULL; -#endif -} - -/** - * ieee80211_get_rx_led_name - get name of RX LED - * - * mac80211 creates a receive LED trigger for each wireless hardware - * that can be used to drive LEDs if your driver registers a LED device. - * This function returns the name (or %NULL if not configured for LEDs) - * of the trigger so you can automatically link the LED device. - * - * @hw: the hardware to get the LED trigger name for - */ -static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw) -{ -#ifdef CONFIG_MAC80211_LEDS - return __ieee80211_get_rx_led_name(hw); -#else - return NULL; -#endif -} - -/** - * ieee80211_get_assoc_led_name - get name of association LED - * - * mac80211 creates a association LED trigger for each wireless hardware - * that can be used to drive LEDs if your driver registers a LED device. - * This function returns the name (or %NULL if not configured for LEDs) - * of the trigger so you can automatically link the LED device. - * - * @hw: the hardware to get the LED trigger name for - */ -static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) -{ -#ifdef CONFIG_MAC80211_LEDS - return __ieee80211_get_assoc_led_name(hw); -#else - return NULL; -#endif -} - -/** - * ieee80211_get_radio_led_name - get name of radio LED - * - * mac80211 creates a radio change LED trigger for each wireless hardware - * that can be used to drive LEDs if your driver registers a LED device. - * This function returns the name (or %NULL if not configured for LEDs) - * of the trigger so you can automatically link the LED device. - * - * @hw: the hardware to get the LED trigger name for - */ -static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw) -{ -#ifdef CONFIG_MAC80211_LEDS - return __ieee80211_get_radio_led_name(hw); -#else - return NULL; -#endif -} - -/** - * ieee80211_create_tpt_led_trigger - create throughput LED trigger - * @hw: the hardware to create the trigger for - * @flags: trigger flags, see &enum ieee80211_tpt_led_trigger_flags - * @blink_table: the blink table -- needs to be ordered by throughput - * @blink_table_len: size of the blink table - * - * This function returns %NULL (in case of error, or if no LED - * triggers are configured) or the name of the new trigger. - * This function must be called before ieee80211_register_hw(). - */ -static inline char * -ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags, - const struct ieee80211_tpt_blink *blink_table, - unsigned int blink_table_len) -{ -#ifdef CONFIG_MAC80211_LEDS - return __ieee80211_create_tpt_led_trigger(hw, flags, blink_table, - blink_table_len); -#else - return NULL; -#endif -} - -/** - * ieee80211_unregister_hw - Unregister a hardware device - * - * This function instructs mac80211 to free allocated resources - * and unregister netdevices from the networking subsystem. - * - * @hw: the hardware to unregister - */ -void ieee80211_unregister_hw(struct ieee80211_hw *hw); - -/** - * ieee80211_free_hw - free hardware descriptor - * - * This function frees everything that was allocated, including the - * private data for the driver. You must call ieee80211_unregister_hw() - * before calling this function. - * - * @hw: the hardware to free - */ -void ieee80211_free_hw(struct ieee80211_hw *hw); - -/** - * ieee80211_restart_hw - restart hardware completely - * - * Call this function when the hardware was restarted for some reason - * (hardware error, ...) and the driver is unable to restore its state - * by itself. mac80211 assumes that at this point the driver/hardware - * is completely uninitialised and stopped, it starts the process by - * calling the ->start() operation. The driver will need to reset all - * internal state that it has prior to calling this function. - * - * @hw: the hardware to restart - */ -void ieee80211_restart_hw(struct ieee80211_hw *hw); - -/** ieee80211_napi_schedule - schedule NAPI poll - * - * Use this function to schedule NAPI polling on a device. - * - * @hw: the hardware to start polling - */ -void ieee80211_napi_schedule(struct ieee80211_hw *hw); - -/** ieee80211_napi_complete - complete NAPI polling - * - * Use this function to finish NAPI polling on a device. - * - * @hw: the hardware to stop polling - */ -void ieee80211_napi_complete(struct ieee80211_hw *hw); - -/** - * ieee80211_rx - receive frame - * - * Use this function to hand received frames to mac80211. The receive - * buffer in @skb must start with an IEEE 802.11 header. In case of a - * paged @skb is used, the driver is recommended to put the ieee80211 - * header of the frame on the linear part of the @skb to avoid memory - * allocation and/or memcpy by the stack. - * - * This function may not be called in IRQ context. Calls to this function - * for a single hardware must be synchronized against each other. Calls to - * this function, ieee80211_rx_ni() and ieee80211_rx_irqsafe() may not be - * mixed for a single hardware. - * - * In process context use instead ieee80211_rx_ni(). - * - * @hw: the hardware this frame came in on - * @skb: the buffer to receive, owned by mac80211 after this call - */ -void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb); - -/** - * ieee80211_rx_irqsafe - receive frame - * - * Like ieee80211_rx() but can be called in IRQ context - * (internally defers to a tasklet.) - * - * Calls to this function, ieee80211_rx() or ieee80211_rx_ni() may not - * be mixed for a single hardware. - * - * @hw: the hardware this frame came in on - * @skb: the buffer to receive, owned by mac80211 after this call - */ -void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb); - -/** - * ieee80211_rx_ni - receive frame (in process context) - * - * Like ieee80211_rx() but can be called in process context - * (internally disables bottom halves). - * - * Calls to this function, ieee80211_rx() and ieee80211_rx_irqsafe() may - * not be mixed for a single hardware. - * - * @hw: the hardware this frame came in on - * @skb: the buffer to receive, owned by mac80211 after this call - */ -static inline void ieee80211_rx_ni(struct ieee80211_hw *hw, - struct sk_buff *skb) -{ - local_bh_disable(); - ieee80211_rx(hw, skb); - local_bh_enable(); -} - -/** - * ieee80211_sta_ps_transition - PS transition for connected sta - * - * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS - * flag set, use this function to inform mac80211 about a connected station - * entering/leaving PS mode. - * - * This function may not be called in IRQ context or with softirqs enabled. - * - * Calls to this function for a single hardware must be synchronized against - * each other. - * - * The function returns -EINVAL when the requested PS mode is already set. - * - * @sta: currently connected sta - * @start: start or stop PS - */ -int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start); - -/** - * ieee80211_sta_ps_transition_ni - PS transition for connected sta - * (in process context) - * - * Like ieee80211_sta_ps_transition() but can be called in process context - * (internally disables bottom halves). Concurrent call restriction still - * applies. - * - * @sta: currently connected sta - * @start: start or stop PS - */ -static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta, - bool start) -{ - int ret; - - local_bh_disable(); - ret = ieee80211_sta_ps_transition(sta, start); - local_bh_enable(); - - return ret; -} - -/* - * The TX headroom reserved by mac80211 for its own tx_status functions. - * This is enough for the radiotap header. - */ -#define IEEE80211_TX_STATUS_HEADROOM 14 - -/** - * ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames - * @sta: &struct ieee80211_sta pointer for the sleeping station - * @tid: the TID that has buffered frames - * @buffered: indicates whether or not frames are buffered for this TID - * - * If a driver buffers frames for a powersave station instead of passing - * them back to mac80211 for retransmission, the station may still need - * to be told that there are buffered frames via the TIM bit. - * - * This function informs mac80211 whether or not there are frames that are - * buffered in the driver for a given TID; mac80211 can then use this data - * to set the TIM bit (NOTE: This may call back into the driver's set_tim - * call! Beware of the locking!) - * - * If all frames are released to the station (due to PS-poll or uAPSD) - * then the driver needs to inform mac80211 that there no longer are - * frames buffered. However, when the station wakes up mac80211 assumes - * that all buffered frames will be transmitted and clears this data, - * drivers need to make sure they inform mac80211 about all buffered - * frames on the sleep transition (sta_notify() with %STA_NOTIFY_SLEEP). - * - * Note that technically mac80211 only needs to know this per AC, not per - * TID, but since driver buffering will inevitably happen per TID (since - * it is related to aggregation) it is easier to make mac80211 map the - * TID to the AC as required instead of keeping track in all drivers that - * use this API. - */ -void ieee80211_sta_set_buffered(struct ieee80211_sta *sta, - u8 tid, bool buffered); - -/** - * ieee80211_tx_status - transmit status callback - * - * Call this function for all transmitted frames after they have been - * transmitted. It is permissible to not call this function for - * multicast frames but this can affect statistics. - * - * This function may not be called in IRQ context. Calls to this function - * for a single hardware must be synchronized against each other. Calls - * to this function, ieee80211_tx_status_ni() and ieee80211_tx_status_irqsafe() - * may not be mixed for a single hardware. - * - * @hw: the hardware the frame was transmitted by - * @skb: the frame that was transmitted, owned by mac80211 after this call - */ -void ieee80211_tx_status(struct ieee80211_hw *hw, - struct sk_buff *skb); - -/** - * ieee80211_tx_status_ni - transmit status callback (in process context) - * - * Like ieee80211_tx_status() but can be called in process context. - * - * Calls to this function, ieee80211_tx_status() and - * ieee80211_tx_status_irqsafe() may not be mixed - * for a single hardware. - * - * @hw: the hardware the frame was transmitted by - * @skb: the frame that was transmitted, owned by mac80211 after this call - */ -static inline void ieee80211_tx_status_ni(struct ieee80211_hw *hw, - struct sk_buff *skb) -{ - local_bh_disable(); - ieee80211_tx_status(hw, skb); - local_bh_enable(); -} - -/** - * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback - * - * Like ieee80211_tx_status() but can be called in IRQ context - * (internally defers to a tasklet.) - * - * Calls to this function, ieee80211_tx_status() and - * ieee80211_tx_status_ni() may not be mixed for a single hardware. - * - * @hw: the hardware the frame was transmitted by - * @skb: the frame that was transmitted, owned by mac80211 after this call - */ -void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, - struct sk_buff *skb); - -/** - * ieee80211_report_low_ack - report non-responding station - * - * When operating in AP-mode, call this function to report a non-responding - * connected STA. - * - * @sta: the non-responding connected sta - * @num_packets: number of packets sent to @sta without a response - */ -void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets); - -/** - * ieee80211_beacon_get_tim - beacon generation function - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @tim_offset: pointer to variable that will receive the TIM IE offset. - * Set to 0 if invalid (in non-AP modes). - * @tim_length: pointer to variable that will receive the TIM IE length, - * (including the ID and length bytes!). - * Set to 0 if invalid (in non-AP modes). - * - * If the driver implements beaconing modes, it must use this function to - * obtain the beacon frame/template. - * - * If the beacon frames are generated by the host system (i.e., not in - * hardware/firmware), the driver uses this function to get each beacon - * frame from mac80211 -- it is responsible for calling this function - * before the beacon is needed (e.g. based on hardware interrupt). - * - * If the beacon frames are generated by the device, then the driver - * must use the returned beacon as the template and change the TIM IE - * according to the current DTIM parameters/TIM bitmap. - * - * The driver is responsible for freeing the returned skb. - */ -struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - u16 *tim_offset, u16 *tim_length); - -/** - * ieee80211_beacon_get - beacon generation function - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * See ieee80211_beacon_get_tim(). - */ -static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - return ieee80211_beacon_get_tim(hw, vif, NULL, NULL); -} - -/** - * ieee80211_proberesp_get - retrieve a Probe Response template - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * Creates a Probe Response template which can, for example, be uploaded to - * hardware. The destination address should be set by the caller. - * - * Can only be called in AP mode. - */ -struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); - -/** - * ieee80211_pspoll_get - retrieve a PS Poll template - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * Creates a PS Poll a template which can, for example, uploaded to - * hardware. The template must be updated after association so that correct - * AID, BSSID and MAC address is used. - * - * Note: Caller (or hardware) is responsible for setting the - * &IEEE80211_FCTL_PM bit. - */ -struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); - -/** - * ieee80211_nullfunc_get - retrieve a nullfunc template - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * Creates a Nullfunc template which can, for example, uploaded to - * hardware. The template must be updated after association so that correct - * BSSID and address is used. - * - * Note: Caller (or hardware) is responsible for setting the - * &IEEE80211_FCTL_PM bit as well as Duration and Sequence Control fields. - */ -struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); - -/** - * ieee80211_probereq_get - retrieve a Probe Request template - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @ssid: SSID buffer - * @ssid_len: length of SSID - * @ie: buffer containing all IEs except SSID for the template - * @ie_len: length of the IE buffer - * - * Creates a Probe Request template which can, for example, be uploaded to - * hardware. - */ -struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - const u8 *ssid, size_t ssid_len, - const u8 *ie, size_t ie_len); - -/** - * ieee80211_rts_get - RTS frame generation function - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @frame: pointer to the frame that is going to be protected by the RTS. - * @frame_len: the frame length (in octets). - * @frame_txctl: &struct ieee80211_tx_info of the frame. - * @rts: The buffer where to store the RTS frame. - * - * If the RTS frames are generated by the host system (i.e., not in - * hardware/firmware), the low-level driver uses this function to receive - * the next RTS frame from the 802.11 code. The low-level is responsible - * for calling this function before and RTS frame is needed. - */ -void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - const void *frame, size_t frame_len, - const struct ieee80211_tx_info *frame_txctl, - struct ieee80211_rts *rts); - -/** - * ieee80211_rts_duration - Get the duration field for an RTS frame - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @frame_len: the length of the frame that is going to be protected by the RTS. - * @frame_txctl: &struct ieee80211_tx_info of the frame. - * - * If the RTS is generated in firmware, but the host system must provide - * the duration field, the low-level driver uses this function to receive - * the duration field value in little-endian byteorder. - */ -__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, size_t frame_len, - const struct ieee80211_tx_info *frame_txctl); - -/** - * ieee80211_ctstoself_get - CTS-to-self frame generation function - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @frame: pointer to the frame that is going to be protected by the CTS-to-self. - * @frame_len: the frame length (in octets). - * @frame_txctl: &struct ieee80211_tx_info of the frame. - * @cts: The buffer where to store the CTS-to-self frame. - * - * If the CTS-to-self frames are generated by the host system (i.e., not in - * hardware/firmware), the low-level driver uses this function to receive - * the next CTS-to-self frame from the 802.11 code. The low-level is responsible - * for calling this function before and CTS-to-self frame is needed. - */ -void ieee80211_ctstoself_get(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - const void *frame, size_t frame_len, - const struct ieee80211_tx_info *frame_txctl, - struct ieee80211_cts *cts); - -/** - * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. - * @frame_txctl: &struct ieee80211_tx_info of the frame. - * - * If the CTS-to-self is generated in firmware, but the host system must provide - * the duration field, the low-level driver uses this function to receive - * the duration field value in little-endian byteorder. - */ -__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - size_t frame_len, - const struct ieee80211_tx_info *frame_txctl); - -/** - * ieee80211_generic_frame_duration - Calculate the duration field for a frame - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @frame_len: the length of the frame. - * @rate: the rate at which the frame is going to be transmitted. - * - * Calculate the duration field of some generic frame, given its - * length and transmission rate (in 100kbps). - */ -__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - size_t frame_len, - struct ieee80211_rate *rate); - -/** - * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames - * @hw: pointer as obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * Function for accessing buffered broadcast and multicast frames. If - * hardware/firmware does not implement buffering of broadcast/multicast - * frames when power saving is used, 802.11 code buffers them in the host - * memory. The low-level driver uses this function to fetch next buffered - * frame. In most cases, this is used when generating beacon frame. This - * function returns a pointer to the next buffered skb or NULL if no more - * buffered frames are available. - * - * Note: buffered frames are returned only after DTIM beacon frame was - * generated with ieee80211_beacon_get() and the low-level driver must thus - * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns - * NULL if the previous generated beacon was not DTIM, so the low-level driver - * does not need to check for DTIM beacons separately and should be able to - * use common code for all beacons. - */ -struct sk_buff * -ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif); - -/** - * ieee80211_get_tkip_p1k_iv - get a TKIP phase 1 key for IV32 - * - * This function returns the TKIP phase 1 key for the given IV32. - * - * @keyconf: the parameter passed with the set key - * @iv32: IV32 to get the P1K for - * @p1k: a buffer to which the key will be written, as 5 u16 values - */ -void ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *keyconf, - u32 iv32, u16 *p1k); - -/** - * ieee80211_get_tkip_p1k - get a TKIP phase 1 key - * - * This function returns the TKIP phase 1 key for the IV32 taken - * from the given packet. - * - * @keyconf: the parameter passed with the set key - * @skb: the packet to take the IV32 value from that will be encrypted - * with this P1K - * @p1k: a buffer to which the key will be written, as 5 u16 values - */ -static inline void ieee80211_get_tkip_p1k(struct ieee80211_key_conf *keyconf, - struct sk_buff *skb, u16 *p1k) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - const u8 *data = (u8 *)hdr + ieee80211_hdrlen(hdr->frame_control); - u32 iv32 = get_unaligned_le32(&data[4]); - - ieee80211_get_tkip_p1k_iv(keyconf, iv32, p1k); -} - -/** - * ieee80211_get_tkip_rx_p1k - get a TKIP phase 1 key for RX - * - * This function returns the TKIP phase 1 key for the given IV32 - * and transmitter address. - * - * @keyconf: the parameter passed with the set key - * @ta: TA that will be used with the key - * @iv32: IV32 to get the P1K for - * @p1k: a buffer to which the key will be written, as 5 u16 values - */ -void ieee80211_get_tkip_rx_p1k(struct ieee80211_key_conf *keyconf, - const u8 *ta, u32 iv32, u16 *p1k); - -/** - * ieee80211_get_tkip_p2k - get a TKIP phase 2 key - * - * This function computes the TKIP RC4 key for the IV values - * in the packet. - * - * @keyconf: the parameter passed with the set key - * @skb: the packet to take the IV32/IV16 values from that will be - * encrypted with this key - * @p2k: a buffer to which the key will be written, 16 bytes - */ -void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf, - struct sk_buff *skb, u8 *p2k); - -/** - * struct ieee80211_key_seq - key sequence counter - * - * @tkip: TKIP data, containing IV32 and IV16 in host byte order - * @ccmp: PN data, most significant byte first (big endian, - * reverse order than in packet) - * @aes_cmac: PN data, most significant byte first (big endian, - * reverse order than in packet) - */ -struct ieee80211_key_seq { - union { - struct { - u32 iv32; - u16 iv16; - } tkip; - struct { - u8 pn[6]; - } ccmp; - struct { - u8 pn[6]; - } aes_cmac; - }; -}; - -/** - * ieee80211_get_key_tx_seq - get key TX sequence counter - * - * @keyconf: the parameter passed with the set key - * @seq: buffer to receive the sequence data - * - * This function allows a driver to retrieve the current TX IV/PN - * for the given key. It must not be called if IV generation is - * offloaded to the device. - * - * Note that this function may only be called when no TX processing - * can be done concurrently, for example when queues are stopped - * and the stop has been synchronized. - */ -void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf, - struct ieee80211_key_seq *seq); - -/** - * ieee80211_get_key_rx_seq - get key RX sequence counter - * - * @keyconf: the parameter passed with the set key - * @tid: The TID, or -1 for the management frame value (CCMP only); - * the value on TID 0 is also used for non-QoS frames. For - * CMAC, only TID 0 is valid. - * @seq: buffer to receive the sequence data - * - * This function allows a driver to retrieve the current RX IV/PNs - * for the given key. It must not be called if IV checking is done - * by the device and not by mac80211. - * - * Note that this function may only be called when no RX processing - * can be done concurrently. - */ -void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf, - int tid, struct ieee80211_key_seq *seq); - -/** - * ieee80211_gtk_rekey_notify - notify userspace supplicant of rekeying - * @vif: virtual interface the rekeying was done on - * @bssid: The BSSID of the AP, for checking association - * @replay_ctr: the new replay counter after GTK rekeying - * @gfp: allocation flags - */ -void ieee80211_gtk_rekey_notify(struct ieee80211_vif *vif, const u8 *bssid, - const u8 *replay_ctr, gfp_t gfp); - -/** - * ieee80211_wake_queue - wake specific queue - * @hw: pointer as obtained from ieee80211_alloc_hw(). - * @queue: queue number (counted from zero). - * - * Drivers should use this function instead of netif_wake_queue. - */ -void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue); - -/** - * ieee80211_stop_queue - stop specific queue - * @hw: pointer as obtained from ieee80211_alloc_hw(). - * @queue: queue number (counted from zero). - * - * Drivers should use this function instead of netif_stop_queue. - */ -void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue); - -/** - * ieee80211_queue_stopped - test status of the queue - * @hw: pointer as obtained from ieee80211_alloc_hw(). - * @queue: queue number (counted from zero). - * - * Drivers should use this function instead of netif_stop_queue. - */ - -int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue); - -/** - * ieee80211_stop_queues - stop all queues - * @hw: pointer as obtained from ieee80211_alloc_hw(). - * - * Drivers should use this function instead of netif_stop_queue. - */ -void ieee80211_stop_queues(struct ieee80211_hw *hw); - -/** - * ieee80211_wake_queues - wake all queues - * @hw: pointer as obtained from ieee80211_alloc_hw(). - * - * Drivers should use this function instead of netif_wake_queue. - */ -void ieee80211_wake_queues(struct ieee80211_hw *hw); - -/** - * ieee80211_scan_completed - completed hardware scan - * - * When hardware scan offload is used (i.e. the hw_scan() callback is - * assigned) this function needs to be called by the driver to notify - * mac80211 that the scan finished. This function can be called from - * any context, including hardirq context. - * - * @hw: the hardware that finished the scan - * @aborted: set to true if scan was aborted - */ -void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted); - -/** - * ieee80211_sched_scan_results - got results from scheduled scan - * - * When a scheduled scan is running, this function needs to be called by the - * driver whenever there are new scan results available. - * - * @hw: the hardware that is performing scheduled scans - */ -void ieee80211_sched_scan_results(struct ieee80211_hw *hw); - -/** - * ieee80211_sched_scan_stopped - inform that the scheduled scan has stopped - * - * When a scheduled scan is running, this function can be called by - * the driver if it needs to stop the scan to perform another task. - * Usual scenarios are drivers that cannot continue the scheduled scan - * while associating, for instance. - * - * @hw: the hardware that is performing scheduled scans - */ -void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw); - -/** - * ieee80211_iterate_active_interfaces - iterate active interfaces - * - * This function iterates over the interfaces associated with a given - * hardware that are currently active and calls the callback for them. - * This function allows the iterator function to sleep, when the iterator - * function is atomic @ieee80211_iterate_active_interfaces_atomic can - * be used. - * Does not iterate over a new interface during add_interface() - * - * @hw: the hardware struct of which the interfaces should be iterated over - * @iterator: the iterator function to call - * @data: first argument of the iterator function - */ -void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, - void (*iterator)(void *data, u8 *mac, - struct ieee80211_vif *vif), - void *data); - -/** - * ieee80211_iterate_active_interfaces_atomic - iterate active interfaces - * - * This function iterates over the interfaces associated with a given - * hardware that are currently active and calls the callback for them. - * This function requires the iterator callback function to be atomic, - * if that is not desired, use @ieee80211_iterate_active_interfaces instead. - * Does not iterate over a new interface during add_interface() - * - * @hw: the hardware struct of which the interfaces should be iterated over - * @iterator: the iterator function to call, cannot sleep - * @data: first argument of the iterator function - */ -void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw, - void (*iterator)(void *data, - u8 *mac, - struct ieee80211_vif *vif), - void *data); - -/** - * ieee80211_queue_work - add work onto the mac80211 workqueue - * - * Drivers and mac80211 use this to add work onto the mac80211 workqueue. - * This helper ensures drivers are not queueing work when they should not be. - * - * @hw: the hardware struct for the interface we are adding work for - * @work: the work we want to add onto the mac80211 workqueue - */ -void ieee80211_queue_work(struct ieee80211_hw *hw, struct work_struct *work); - -/** - * ieee80211_queue_delayed_work - add work onto the mac80211 workqueue - * - * Drivers and mac80211 use this to queue delayed work onto the mac80211 - * workqueue. - * - * @hw: the hardware struct for the interface we are adding work for - * @dwork: delayable work to queue onto the mac80211 workqueue - * @delay: number of jiffies to wait before queueing - */ -void ieee80211_queue_delayed_work(struct ieee80211_hw *hw, - struct delayed_work *dwork, - unsigned long delay); - -/** - * ieee80211_start_tx_ba_session - Start a tx Block Ack session. - * @sta: the station for which to start a BA session - * @tid: the TID to BA on. - * @timeout: session timeout value (in TUs) - * - * Return: success if addBA request was sent, failure otherwise - * - * Although mac80211/low level driver/user space application can estimate - * the need to start aggregation on a certain RA/TID, the session level - * will be managed by the mac80211. - */ -int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid, - u16 timeout); - -/** - * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate. - * @vif: &struct ieee80211_vif pointer from the add_interface callback - * @ra: receiver address of the BA session recipient. - * @tid: the TID to BA on. - * - * This function must be called by low level driver once it has - * finished with preparations for the BA session. It can be called - * from any context. - */ -void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra, - u16 tid); - -/** - * ieee80211_stop_tx_ba_session - Stop a Block Ack session. - * @sta: the station whose BA session to stop - * @tid: the TID to stop BA. - * - * Return: negative error if the TID is invalid, or no aggregation active - * - * Although mac80211/low level driver/user space application can estimate - * the need to stop aggregation on a certain RA/TID, the session level - * will be managed by the mac80211. - */ -int ieee80211_stop_tx_ba_session(struct ieee80211_sta *sta, u16 tid); - -/** - * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate. - * @vif: &struct ieee80211_vif pointer from the add_interface callback - * @ra: receiver address of the BA session recipient. - * @tid: the desired TID to BA on. - * - * This function must be called by low level driver once it has - * finished with preparations for the BA session tear down. It - * can be called from any context. - */ -void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_vif *vif, const u8 *ra, - u16 tid); - -/** - * ieee80211_find_sta - find a station - * - * @vif: virtual interface to look for station on - * @addr: station's address - * - * This function must be called under RCU lock and the - * resulting pointer is only valid under RCU lock as well. - */ -struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif, - const u8 *addr); - -/** - * ieee80211_find_sta_by_ifaddr - find a station on hardware - * - * @hw: pointer as obtained from ieee80211_alloc_hw() - * @addr: remote station's address - * @localaddr: local address (vif->sdata->vif.addr). Use NULL for 'any'. - * - * This function must be called under RCU lock and the - * resulting pointer is only valid under RCU lock as well. - * - * NOTE: You may pass NULL for localaddr, but then you will just get - * the first STA that matches the remote address 'addr'. - * We can have multiple STA associated with multiple - * logical stations (e.g. consider a station connecting to another - * BSSID on the same AP hardware without disconnecting first). - * In this case, the result of this method with localaddr NULL - * is not reliable. - * - * DO NOT USE THIS FUNCTION with localaddr NULL if at all possible. - */ -struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, - const u8 *addr, - const u8 *localaddr); - -/** - * ieee80211_sta_block_awake - block station from waking up - * @hw: the hardware - * @pubsta: the station - * @block: whether to block or unblock - * - * Some devices require that all frames that are on the queues - * for a specific station that went to sleep are flushed before - * a poll response or frames after the station woke up can be - * delivered to that it. Note that such frames must be rejected - * by the driver as filtered, with the appropriate status flag. - * - * This function allows implementing this mode in a race-free - * manner. - * - * To do this, a driver must keep track of the number of frames - * still enqueued for a specific station. If this number is not - * zero when the station goes to sleep, the driver must call - * this function to force mac80211 to consider the station to - * be asleep regardless of the station's actual state. Once the - * number of outstanding frames reaches zero, the driver must - * call this function again to unblock the station. That will - * cause mac80211 to be able to send ps-poll responses, and if - * the station queried in the meantime then frames will also - * be sent out as a result of this. Additionally, the driver - * will be notified that the station woke up some time after - * it is unblocked, regardless of whether the station actually - * woke up while blocked or not. - */ -void ieee80211_sta_block_awake(struct ieee80211_hw *hw, - struct ieee80211_sta *pubsta, bool block); - -/** - * ieee80211_sta_eosp - notify mac80211 about end of SP - * @pubsta: the station - * - * When a device transmits frames in a way that it can't tell - * mac80211 in the TX status about the EOSP, it must clear the - * %IEEE80211_TX_STATUS_EOSP bit and call this function instead. - * This applies for PS-Poll as well as uAPSD. - * - * Note that there is no non-_irqsafe version right now as - * it wasn't needed, but just like _tx_status() and _rx() - * must not be mixed in irqsafe/non-irqsafe versions, this - * function must not be mixed with those either. Use the - * all irqsafe, or all non-irqsafe, don't mix! If you need - * the non-irqsafe version of this, you need to add it. - */ -void ieee80211_sta_eosp_irqsafe(struct ieee80211_sta *pubsta); - -/** - * ieee80211_iter_keys - iterate keys programmed into the device - * @hw: pointer obtained from ieee80211_alloc_hw() - * @vif: virtual interface to iterate, may be %NULL for all - * @iter: iterator function that will be called for each key - * @iter_data: custom data to pass to the iterator function - * - * This function can be used to iterate all the keys known to - * mac80211, even those that weren't previously programmed into - * the device. This is intended for use in WoWLAN if the device - * needs reprogramming of the keys during suspend. Note that due - * to locking reasons, it is also only safe to call this at few - * spots since it must hold the RTNL and be able to sleep. - * - * The order in which the keys are iterated matches the order - * in which they were originally installed and handed to the - * set_key callback. - */ -void ieee80211_iter_keys(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - void (*iter)(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key, - void *data), - void *iter_data); - -/** - * ieee80211_ap_probereq_get - retrieve a Probe Request template - * @hw: pointer obtained from ieee80211_alloc_hw(). - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * Creates a Probe Request template which can, for example, be uploaded to - * hardware. The template is filled with bssid, ssid and supported rate - * information. This function must only be called from within the - * .bss_info_changed callback function and only in managed mode. The function - * is only useful when the interface is associated, otherwise it will return - * NULL. - */ -struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); - -/** - * ieee80211_beacon_loss - inform hardware does not receive beacons - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER and - * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the - * hardware is not receiving beacons with this function. - */ -void ieee80211_beacon_loss(struct ieee80211_vif *vif); - -/** - * ieee80211_connection_loss - inform hardware has lost connection to the AP - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER, and - * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver - * needs to inform if the connection to the AP has been lost. - * - * This function will cause immediate change to disassociated state, - * without connection recovery attempts. - */ -void ieee80211_connection_loss(struct ieee80211_vif *vif); - -/** - * ieee80211_resume_disconnect - disconnect from AP after resume - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * Instructs mac80211 to disconnect from the AP after resume. - * Drivers can use this after WoWLAN if they know that the - * connection cannot be kept up, for example because keys were - * used while the device was asleep but the replay counters or - * similar cannot be retrieved from the device during resume. - * - * Note that due to implementation issues, if the driver uses - * the reconfiguration functionality during resume the interface - * will still be added as associated first during resume and then - * disconnect normally later. - * - * This function can only be called from the resume callback and - * the driver must not be holding any of its own locks while it - * calls this function, or at least not any locks it needs in the - * key configuration paths (if it supports HW crypto). - */ -void ieee80211_resume_disconnect(struct ieee80211_vif *vif); - -/** - * ieee80211_disable_dyn_ps - force mac80211 to temporarily disable dynamic psm - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * Some hardware require full power save to manage simultaneous BT traffic - * on the WLAN frequency. Full PSM is required periodically, whenever there are - * burst of BT traffic. The hardware gets information of BT traffic via - * hardware co-existence lines, and consequentially requests mac80211 to - * (temporarily) enter full psm. - * This function will only temporarily disable dynamic PS, not enable PSM if - * it was not already enabled. - * The driver must make sure to re-enable dynamic PS using - * ieee80211_enable_dyn_ps() if the driver has disabled it. - * - */ -void ieee80211_disable_dyn_ps(struct ieee80211_vif *vif); - -/** - * ieee80211_enable_dyn_ps - restore dynamic psm after being disabled - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * This function restores dynamic PS after being temporarily disabled via - * ieee80211_disable_dyn_ps(). Each ieee80211_disable_dyn_ps() call must - * be coupled with an eventual call to this function. - * - */ -void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif); - -/** - * ieee80211_cqm_rssi_notify - inform a configured connection quality monitoring - * rssi threshold triggered - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @rssi_event: the RSSI trigger event type - * @gfp: context flags - * - * When the %IEEE80211_HW_SUPPORTS_CQM_RSSI is set, and a connection quality - * monitoring is configured with an rssi threshold, the driver will inform - * whenever the rssi level reaches the threshold. - */ -void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, - enum nl80211_cqm_rssi_threshold_event rssi_event, - gfp_t gfp); - -/** - * ieee80211_get_operstate - get the operstate of the vif - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * - * The driver might need to know the operstate of the net_device - * (specifically, whether the link is IF_OPER_UP after resume) - */ -unsigned char ieee80211_get_operstate(struct ieee80211_vif *vif); - -/** - * ieee80211_chswitch_done - Complete channel switch process - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @success: make the channel switch successful or not - * - * Complete the channel switch post-process: set the new operational channel - * and wake up the suspended queues. - */ -void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success); - -/** - * ieee80211_request_smps - request SM PS transition - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @smps_mode: new SM PS mode - * - * This allows the driver to request an SM PS transition in managed - * mode. This is useful when the driver has more information than - * the stack about possible interference, for example by bluetooth. - */ -void ieee80211_request_smps(struct ieee80211_vif *vif, - enum ieee80211_smps_mode smps_mode); - -/** - * ieee80211_key_removed - disable hw acceleration for key - * @key_conf: The key hw acceleration should be disabled for - * - * This allows drivers to indicate that the given key has been - * removed from hardware acceleration, due to a new key that - * was added. Don't use this if the key can continue to be used - * for TX, if the key restriction is on RX only it is permitted - * to keep the key for TX only and not call this function. - * - * Due to locking constraints, it may only be called during - * @set_key. This function must be allowed to sleep, and the - * key it tries to disable may still be used until it returns. - */ -void ieee80211_key_removed(struct ieee80211_key_conf *key_conf); - -/** - * ieee80211_ready_on_channel - notification of remain-on-channel start - * @hw: pointer as obtained from ieee80211_alloc_hw() - */ -void ieee80211_ready_on_channel(struct ieee80211_hw *hw); - -/** - * ieee80211_remain_on_channel_expired - remain_on_channel duration expired - * @hw: pointer as obtained from ieee80211_alloc_hw() - */ -void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw); - -/** - * ieee80211_stop_rx_ba_session - callback to stop existing BA sessions - * - * in order not to harm the system performance and user experience, the device - * may request not to allow any rx ba session and tear down existing rx ba - * sessions based on system constraints such as periodic BT activity that needs - * to limit wlan activity (eg.sco or a2dp)." - * in such cases, the intention is to limit the duration of the rx ppdu and - * therefore prevent the peer device to use a-mpdu aggregation. - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @ba_rx_bitmap: Bit map of open rx ba per tid - * @addr: & to bssid mac address - */ -void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap, - const u8 *addr); - -/** - * ieee80211_send_bar - send a BlockAckReq frame - * - * can be used to flush pending frames from the peer's aggregation reorder - * buffer. - * - * @vif: &struct ieee80211_vif pointer from the add_interface callback. - * @ra: the peer's destination address - * @tid: the TID of the aggregation session - * @ssn: the new starting sequence number for the receiver - */ -void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn); - -/* Rate control API */ - -/** - * enum rate_control_changed - flags to indicate which parameter changed - * - * @IEEE80211_RC_HT_CHANGED: The HT parameters of the operating channel have - * changed, rate control algorithm can update its internal state if needed. - */ -enum rate_control_changed { - IEEE80211_RC_HT_CHANGED = BIT(0) -}; - -/** - * struct ieee80211_tx_rate_control - rate control information for/from RC algo - * - * @hw: The hardware the algorithm is invoked for. - * @sband: The band this frame is being transmitted on. - * @bss_conf: the current BSS configuration - * @reported_rate: The rate control algorithm can fill this in to indicate - * which rate should be reported to userspace as the current rate and - * used for rate calculations in the mesh network. - * @rts: whether RTS will be used for this frame because it is longer than the - * RTS threshold - * @short_preamble: whether mac80211 will request short-preamble transmission - * if the selected rate supports it - * @max_rate_idx: user-requested maximum rate (not MCS for now) - * (deprecated; this will be removed once drivers get updated to use - * rate_idx_mask) - * @rate_idx_mask: user-requested rate mask (not MCS for now) - * @skb: the skb that will be transmitted, the control information in it needs - * to be filled in - * @bss: whether this frame is sent out in AP or IBSS mode - */ -struct ieee80211_tx_rate_control { - struct ieee80211_hw *hw; - struct ieee80211_supported_band *sband; - struct ieee80211_bss_conf *bss_conf; - struct sk_buff *skb; - struct ieee80211_tx_rate reported_rate; - bool rts, short_preamble; - u8 max_rate_idx; - u32 rate_idx_mask; - bool bss; -}; - -struct rate_control_ops { - struct module *module; - const char *name; - void *(*alloc)(struct ieee80211_hw *hw, struct dentry *debugfsdir); - void (*free)(void *priv); - - void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp); - void (*rate_init)(void *priv, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta); - void (*rate_update)(void *priv, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, - void *priv_sta, u32 changed, - enum nl80211_channel_type oper_chan_type); - void (*free_sta)(void *priv, struct ieee80211_sta *sta, - void *priv_sta); - - void (*tx_status)(void *priv, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta, - struct sk_buff *skb); - void (*get_rate)(void *priv, struct ieee80211_sta *sta, void *priv_sta, - struct ieee80211_tx_rate_control *txrc); - - void (*add_sta_debugfs)(void *priv, void *priv_sta, - struct dentry *dir); - void (*remove_sta_debugfs)(void *priv, void *priv_sta); -}; - -static inline int rate_supported(struct ieee80211_sta *sta, - enum ieee80211_band band, - int index) -{ - return (sta == NULL || sta->supp_rates[band] & BIT(index)); -} - -/** - * rate_control_send_low - helper for drivers for management/no-ack frames - * - * Rate control algorithms that agree to use the lowest rate to - * send management frames and NO_ACK data with the respective hw - * retries should use this in the beginning of their mac80211 get_rate - * callback. If true is returned the rate control can simply return. - * If false is returned we guarantee that sta and sta and priv_sta is - * not null. - * - * Rate control algorithms wishing to do more intelligent selection of - * rate for multicast/broadcast frames may choose to not use this. - * - * @sta: &struct ieee80211_sta pointer to the target destination. Note - * that this may be null. - * @priv_sta: private rate control structure. This may be null. - * @txrc: rate control information we sholud populate for mac80211. - */ -bool rate_control_send_low(struct ieee80211_sta *sta, - void *priv_sta, - struct ieee80211_tx_rate_control *txrc); - - -static inline s8 -rate_lowest_index(struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta) -{ - int i; - - for (i = 0; i < sband->n_bitrates; i++) - if (rate_supported(sta, sband->band, i)) - return i; - - /* warn when we cannot find a rate. */ - WARN_ON_ONCE(1); - - /* and return 0 (the lowest index) */ - return 0; -} - -static inline -bool rate_usable_index_exists(struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta) -{ - unsigned int i; - - for (i = 0; i < sband->n_bitrates; i++) - if (rate_supported(sta, sband->band, i)) - return true; - return false; -} - -int ieee80211_rate_control_register(struct rate_control_ops *ops); -void ieee80211_rate_control_unregister(struct rate_control_ops *ops); - -static inline bool -conf_is_ht20(struct ieee80211_conf *conf) -{ - return conf->channel_type == NL80211_CHAN_HT20; -} - -static inline bool -conf_is_ht40_minus(struct ieee80211_conf *conf) -{ - return conf->channel_type == NL80211_CHAN_HT40MINUS; -} - -static inline bool -conf_is_ht40_plus(struct ieee80211_conf *conf) -{ - return conf->channel_type == NL80211_CHAN_HT40PLUS; -} - -static inline bool -conf_is_ht40(struct ieee80211_conf *conf) -{ - return conf_is_ht40_minus(conf) || conf_is_ht40_plus(conf); -} - -static inline bool -conf_is_ht(struct ieee80211_conf *conf) -{ - return conf->channel_type != NL80211_CHAN_NO_HT; -} - -static inline enum nl80211_iftype -ieee80211_iftype_p2p(enum nl80211_iftype type, bool p2p) -{ - if (p2p) { - switch (type) { - case NL80211_IFTYPE_STATION: - return NL80211_IFTYPE_P2P_CLIENT; - case NL80211_IFTYPE_AP: - return NL80211_IFTYPE_P2P_GO; - default: - break; - } - } - return type; -} - -static inline enum nl80211_iftype -ieee80211_vif_type_p2p(struct ieee80211_vif *vif) -{ - return ieee80211_iftype_p2p(vif->type, vif->p2p); -} - -void ieee80211_enable_rssi_reports(struct ieee80211_vif *vif, - int rssi_min_thold, - int rssi_max_thold); - -void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif); - -int ieee80211_add_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb); - -int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif, - struct sk_buff *skb); -#endif /* MAC80211_H */ diff --git a/include/compat/net/net_namespace.h b/include/compat/net/net_namespace.h deleted file mode 100755 index 0f74944..0000000 --- a/include/compat/net/net_namespace.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _COMPAT_NET_NET_NAMESPACE_H -#define _COMPAT_NET_NET_NAMESPACE_H 1 - -#include <linux/version.h> - -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) -#include_next <net/net_namespace.h> -#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) */ - -#endif /* _COMPAT_NET_NET_NAMESPACE_H */ diff --git a/include/compat/net/regulatory.h b/include/compat/net/regulatory.h deleted file mode 100755 index ebe5fe7..0000000 --- a/include/compat/net/regulatory.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef __NET_REGULATORY_H -#define __NET_REGULATORY_H -/* - * regulatory support structures - * - * Copyright 2008-2009 Luis R. Rodriguez <mcgrof@qca.qualcomm.com> - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -/** - * enum environment_cap - Environment parsed from country IE - * @ENVIRON_ANY: indicates country IE applies to both indoor and - * outdoor operation. - * @ENVIRON_INDOOR: indicates country IE applies only to indoor operation - * @ENVIRON_OUTDOOR: indicates country IE applies only to outdoor operation - */ -enum environment_cap { - ENVIRON_ANY, - ENVIRON_INDOOR, - ENVIRON_OUTDOOR, -}; - -/** - * struct regulatory_request - used to keep track of regulatory requests - * - * @wiphy_idx: this is set if this request's initiator is - * %REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This - * can be used by the wireless core to deal with conflicts - * and potentially inform users of which devices specifically - * cased the conflicts. - * @initiator: indicates who sent this request, could be any of - * of those set in nl80211_reg_initiator (%NL80211_REGDOM_SET_BY_*) - * @alpha2: the ISO / IEC 3166 alpha2 country code of the requested - * regulatory domain. We have a few special codes: - * 00 - World regulatory domain - * 99 - built by driver but a specific alpha2 cannot be determined - * 98 - result of an intersection between two regulatory domains - * 97 - regulatory domain has not yet been configured - * @intersect: indicates whether the wireless core should intersect - * the requested regulatory domain with the presently set regulatory - * domain. - * @processed: indicates whether or not this requests has already been - * processed. When the last request is processed it means that the - * currently regulatory domain set on cfg80211 is updated from - * CRDA and can be used by other regulatory requests. When a - * the last request is not yet processed we must yield until it - * is processed before processing any new requests. - * @country_ie_checksum: checksum of the last processed and accepted - * country IE - * @country_ie_env: lets us know if the AP is telling us we are outdoor, - * indoor, or if it doesn't matter - * @list: used to insert into the reg_requests_list linked list - */ -struct regulatory_request { - int wiphy_idx; - enum nl80211_reg_initiator initiator; - char alpha2[2]; - bool intersect; - bool processed; - enum environment_cap country_ie_env; - struct list_head list; -}; - -struct ieee80211_freq_range { - u32 start_freq_khz; - u32 end_freq_khz; - u32 max_bandwidth_khz; -}; - -struct ieee80211_power_rule { - u32 max_antenna_gain; - u32 max_eirp; -}; - -struct ieee80211_reg_rule { - struct ieee80211_freq_range freq_range; - struct ieee80211_power_rule power_rule; - u32 flags; -}; - -struct ieee80211_regdomain { - u32 n_reg_rules; - char alpha2[2]; - struct ieee80211_reg_rule reg_rules[]; -}; - -#define MHZ_TO_KHZ(freq) ((freq) * 1000) -#define KHZ_TO_MHZ(freq) ((freq) / 1000) -#define DBI_TO_MBI(gain) ((gain) * 100) -#define MBI_TO_DBI(gain) ((gain) / 100) -#define DBM_TO_MBM(gain) ((gain) * 100) -#define MBM_TO_DBM(gain) ((gain) / 100) - -#define REG_RULE(start, end, bw, gain, eirp, reg_flags) \ -{ \ - .freq_range.start_freq_khz = MHZ_TO_KHZ(start), \ - .freq_range.end_freq_khz = MHZ_TO_KHZ(end), \ - .freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw), \ - .power_rule.max_antenna_gain = DBI_TO_MBI(gain),\ - .power_rule.max_eirp = DBM_TO_MBM(eirp), \ - .flags = reg_flags, \ -} - -#endif |