Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/linux
File: rfkill.h
/*
[0] Fix | Delete
* Copyright (C) 2006 - 2007 Ivo van Doorn
[1] Fix | Delete
* Copyright (C) 2007 Dmitry Torokhov
[2] Fix | Delete
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
[3] Fix | Delete
*
[4] Fix | Delete
* Permission to use, copy, modify, and/or distribute this software for any
[5] Fix | Delete
* purpose with or without fee is hereby granted, provided that the above
[6] Fix | Delete
* copyright notice and this permission notice appear in all copies.
[7] Fix | Delete
*
[8] Fix | Delete
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
[9] Fix | Delete
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
[10] Fix | Delete
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
[11] Fix | Delete
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
[12] Fix | Delete
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
[13] Fix | Delete
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
[14] Fix | Delete
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
[15] Fix | Delete
*/
[16] Fix | Delete
#ifndef __RFKILL_H
[17] Fix | Delete
#define __RFKILL_H
[18] Fix | Delete
[19] Fix | Delete
[20] Fix | Delete
#include <linux/types.h>
[21] Fix | Delete
[22] Fix | Delete
/* define userspace visible states */
[23] Fix | Delete
#define RFKILL_STATE_SOFT_BLOCKED 0
[24] Fix | Delete
#define RFKILL_STATE_UNBLOCKED 1
[25] Fix | Delete
#define RFKILL_STATE_HARD_BLOCKED 2
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* enum rfkill_type - type of rfkill switch.
[29] Fix | Delete
*
[30] Fix | Delete
* @RFKILL_TYPE_ALL: toggles all switches (requests only - not a switch type)
[31] Fix | Delete
* @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device.
[32] Fix | Delete
* @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device.
[33] Fix | Delete
* @RFKILL_TYPE_UWB: switch is on a ultra wideband device.
[34] Fix | Delete
* @RFKILL_TYPE_WIMAX: switch is on a WiMAX device.
[35] Fix | Delete
* @RFKILL_TYPE_WWAN: switch is on a wireless WAN device.
[36] Fix | Delete
* @RFKILL_TYPE_GPS: switch is on a GPS device.
[37] Fix | Delete
* @RFKILL_TYPE_FM: switch is on a FM radio device.
[38] Fix | Delete
* @RFKILL_TYPE_NFC: switch is on an NFC device.
[39] Fix | Delete
* @NUM_RFKILL_TYPES: number of defined rfkill types
[40] Fix | Delete
*/
[41] Fix | Delete
enum rfkill_type {
[42] Fix | Delete
RFKILL_TYPE_ALL = 0,
[43] Fix | Delete
RFKILL_TYPE_WLAN,
[44] Fix | Delete
RFKILL_TYPE_BLUETOOTH,
[45] Fix | Delete
RFKILL_TYPE_UWB,
[46] Fix | Delete
RFKILL_TYPE_WIMAX,
[47] Fix | Delete
RFKILL_TYPE_WWAN,
[48] Fix | Delete
RFKILL_TYPE_GPS,
[49] Fix | Delete
RFKILL_TYPE_FM,
[50] Fix | Delete
RFKILL_TYPE_NFC,
[51] Fix | Delete
NUM_RFKILL_TYPES,
[52] Fix | Delete
};
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* enum rfkill_operation - operation types
[56] Fix | Delete
* @RFKILL_OP_ADD: a device was added
[57] Fix | Delete
* @RFKILL_OP_DEL: a device was removed
[58] Fix | Delete
* @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device
[59] Fix | Delete
* @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all)
[60] Fix | Delete
* into a state, also updating the default state used for devices that
[61] Fix | Delete
* are hot-plugged later.
[62] Fix | Delete
*/
[63] Fix | Delete
enum rfkill_operation {
[64] Fix | Delete
RFKILL_OP_ADD = 0,
[65] Fix | Delete
RFKILL_OP_DEL,
[66] Fix | Delete
RFKILL_OP_CHANGE,
[67] Fix | Delete
RFKILL_OP_CHANGE_ALL,
[68] Fix | Delete
};
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* enum rfkill_hard_block_reasons - hard block reasons
[72] Fix | Delete
* @RFKILL_HARD_BLOCK_SIGNAL: the hardware rfkill signal is active
[73] Fix | Delete
* @RFKILL_HARD_BLOCK_NOT_OWNER: the NIC is not owned by the host
[74] Fix | Delete
*/
[75] Fix | Delete
enum rfkill_hard_block_reasons {
[76] Fix | Delete
RFKILL_HARD_BLOCK_SIGNAL = 1 << 0,
[77] Fix | Delete
RFKILL_HARD_BLOCK_NOT_OWNER = 1 << 1,
[78] Fix | Delete
};
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* struct rfkill_event - events for userspace on /dev/rfkill
[82] Fix | Delete
* @idx: index of dev rfkill
[83] Fix | Delete
* @type: type of the rfkill struct
[84] Fix | Delete
* @op: operation code
[85] Fix | Delete
* @hard: hard state (0/1)
[86] Fix | Delete
* @soft: soft state (0/1)
[87] Fix | Delete
*
[88] Fix | Delete
* Structure used for userspace communication on /dev/rfkill,
[89] Fix | Delete
* used for events from the kernel and control to the kernel.
[90] Fix | Delete
*/
[91] Fix | Delete
struct rfkill_event {
[92] Fix | Delete
__u32 idx;
[93] Fix | Delete
__u8 type;
[94] Fix | Delete
__u8 op;
[95] Fix | Delete
__u8 soft;
[96] Fix | Delete
__u8 hard;
[97] Fix | Delete
} __attribute__((packed));
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* struct rfkill_event_ext - events for userspace on /dev/rfkill
[101] Fix | Delete
* @idx: index of dev rfkill
[102] Fix | Delete
* @type: type of the rfkill struct
[103] Fix | Delete
* @op: operation code
[104] Fix | Delete
* @hard: hard state (0/1)
[105] Fix | Delete
* @soft: soft state (0/1)
[106] Fix | Delete
* @hard_block_reasons: valid if hard is set. One or several reasons from
[107] Fix | Delete
* &enum rfkill_hard_block_reasons.
[108] Fix | Delete
*
[109] Fix | Delete
* Structure used for userspace communication on /dev/rfkill,
[110] Fix | Delete
* used for events from the kernel and control to the kernel.
[111] Fix | Delete
*
[112] Fix | Delete
* See the extensibility docs below.
[113] Fix | Delete
*/
[114] Fix | Delete
struct rfkill_event_ext {
[115] Fix | Delete
__u32 idx;
[116] Fix | Delete
__u8 type;
[117] Fix | Delete
__u8 op;
[118] Fix | Delete
__u8 soft;
[119] Fix | Delete
__u8 hard;
[120] Fix | Delete
[121] Fix | Delete
/*
[122] Fix | Delete
* older kernels will accept/send only up to this point,
[123] Fix | Delete
* and if extended further up to any chunk marked below
[124] Fix | Delete
*/
[125] Fix | Delete
[126] Fix | Delete
__u8 hard_block_reasons;
[127] Fix | Delete
} __attribute__((packed));
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* DOC: Extensibility
[131] Fix | Delete
*
[132] Fix | Delete
* Originally, we had planned to allow backward and forward compatible
[133] Fix | Delete
* changes by just adding fields at the end of the structure that are
[134] Fix | Delete
* then not reported on older kernels on read(), and not written to by
[135] Fix | Delete
* older kernels on write(), with the kernel reporting the size it did
[136] Fix | Delete
* accept as the result.
[137] Fix | Delete
*
[138] Fix | Delete
* This would have allowed userspace to detect on read() and write()
[139] Fix | Delete
* which kernel structure version it was dealing with, and if was just
[140] Fix | Delete
* recompiled it would have gotten the new fields, but obviously not
[141] Fix | Delete
* accessed them, but things should've continued to work.
[142] Fix | Delete
*
[143] Fix | Delete
* Unfortunately, while actually exercising this mechanism to add the
[144] Fix | Delete
* hard block reasons field, we found that userspace (notably systemd)
[145] Fix | Delete
* did all kinds of fun things not in line with this scheme:
[146] Fix | Delete
*
[147] Fix | Delete
* 1. treat the (expected) short writes as an error;
[148] Fix | Delete
* 2. ask to read sizeof(struct rfkill_event) but then compare the
[149] Fix | Delete
* actual return value to RFKILL_EVENT_SIZE_V1 and treat any
[150] Fix | Delete
* mismatch as an error.
[151] Fix | Delete
*
[152] Fix | Delete
* As a consequence, just recompiling with a new struct version caused
[153] Fix | Delete
* things to no longer work correctly on old and new kernels.
[154] Fix | Delete
*
[155] Fix | Delete
* Hence, we've rolled back &struct rfkill_event to the original version
[156] Fix | Delete
* and added &struct rfkill_event_ext. This effectively reverts to the
[157] Fix | Delete
* old behaviour for all userspace, unless it explicitly opts in to the
[158] Fix | Delete
* rules outlined here by using the new &struct rfkill_event_ext.
[159] Fix | Delete
*
[160] Fix | Delete
* Additionally, some other userspace (bluez, g-s-d) was reading with a
[161] Fix | Delete
* large size but as streaming reads rather than message-based, or with
[162] Fix | Delete
* too strict checks for the returned size. So eventually, we completely
[163] Fix | Delete
* reverted this, and extended messages need to be opted in to by using
[164] Fix | Delete
* an ioctl:
[165] Fix | Delete
*
[166] Fix | Delete
* ioctl(fd, RFKILL_IOCTL_MAX_SIZE, sizeof(struct rfkill_event_ext));
[167] Fix | Delete
*
[168] Fix | Delete
* Userspace using &struct rfkill_event_ext and the ioctl must adhere to
[169] Fix | Delete
* the following rules:
[170] Fix | Delete
*
[171] Fix | Delete
* 1. accept short writes, optionally using them to detect that it's
[172] Fix | Delete
* running on an older kernel;
[173] Fix | Delete
* 2. accept short reads, knowing that this means it's running on an
[174] Fix | Delete
* older kernel;
[175] Fix | Delete
* 3. treat reads that are as long as requested as acceptable, not
[176] Fix | Delete
* checking against RFKILL_EVENT_SIZE_V1 or such.
[177] Fix | Delete
*/
[178] Fix | Delete
#define RFKILL_EVENT_SIZE_V1 sizeof(struct rfkill_event)
[179] Fix | Delete
[180] Fix | Delete
/* ioctl for turning off rfkill-input (if present) */
[181] Fix | Delete
#define RFKILL_IOC_MAGIC 'R'
[182] Fix | Delete
#define RFKILL_IOC_NOINPUT 1
[183] Fix | Delete
#define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT)
[184] Fix | Delete
#define RFKILL_IOC_MAX_SIZE 2
[185] Fix | Delete
#define RFKILL_IOCTL_MAX_SIZE _IOW(RFKILL_IOC_MAGIC, RFKILL_IOC_EXT_SIZE, __u32)
[186] Fix | Delete
[187] Fix | Delete
/* and that's all userspace gets */
[188] Fix | Delete
[189] Fix | Delete
#endif /* __RFKILL_H */
[190] Fix | Delete
[191] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function