History

net: nfc: Propagate ISO14443 type A target ATS to userspace via netlink

Add a 20-byte field ats to struct nfc_target and expose it as NFC_ATTR_TARGET_ATS via the netlink interface. The payload contains 'historical bytes' that help to distinguish cards from one another. The information is commonly used to assemble an emulated ATR similar to that reported by smart cards with contacts. Add a 20-byte field target_ats to struct nci_dev to hold the payload obtained in nci_rf_intf_activated_ntf_packet() and copy it to over to nfc_target.ats in nci_activate_target(). The approach is similar to the handling of 'general bytes' within ATR_RES. Replace the hard-coded size of rats_res within struct activation_params_nfca_poll_iso_dep by the equal constant NFC_ATS_MAXSIZE now defined in nfc.h Within NCI, the information corresponds to the 'RATS Response' activation parameter that omits the initial length byte TL. This loses no information and is consistent with our handling of SENSB_RES that also drops the first (constant) byte. Tested with nxp_nci_i2c on a few type A targets including an ICAO 9303 compliant passport. I refrain from the corresponding change to digital_in_recv_ats() to have the few drivers based on digital.h fill nfc_target.ats, as I have no way to test it. That class of drivers appear not to set NFC_ATTR_TARGET_SENSB_RES either. Consider a separate patch to propagate (all) the parameters.

Juraj Šarinay committed 2 years ago

Commit 9907cda1 parent dc7c3817 files · +60 −3Browse files

Showing the changes to include/uapi (1 of 7 files). Show all

Unified · Split

include/uapi/linux/nfc.h+3−0
@@ -164,6 +164,7 @@ enum nfc_commands { · 163 unmodified lines
164 * @NFC_ATTR_VENDOR_SUBCMD: Vendor specific sub command164 * @NFC_ATTR_VENDOR_SUBCMD: Vendor specific sub command
165 * @NFC_ATTR_VENDOR_DATA: Vendor specific data, to be optionally passed165 * @NFC_ATTR_VENDOR_DATA: Vendor specific data, to be optionally passed
166 * to a vendor specific command implementation166 * to a vendor specific command implementation
167 * @NFC_ATTR_TARGET_ATS: ISO 14443 type A target Answer To Select
167 */168 */
168enum nfc_attrs {169enum nfc_attrs {
169 NFC_ATTR_UNSPEC,170 NFC_ATTR_UNSPEC,
@@ -198,6 +199,7 @@ enum nfc_attrs { · 28 unmodified lines
198 NFC_ATTR_VENDOR_ID,199 NFC_ATTR_VENDOR_ID,
199 NFC_ATTR_VENDOR_SUBCMD,200 NFC_ATTR_VENDOR_SUBCMD,
200 NFC_ATTR_VENDOR_DATA,201 NFC_ATTR_VENDOR_DATA,
202 NFC_ATTR_TARGET_ATS,
201/* private: internal use only */203/* private: internal use only */
202 __NFC_ATTR_AFTER_LAST204 __NFC_ATTR_AFTER_LAST
203};205};
@@ -225,6 +227,7 @@ enum nfc_sdp_attr { · 21 unmodified lines
225#define NFC_GB_MAXSIZE 48227#define NFC_GB_MAXSIZE 48
226#define NFC_FIRMWARE_NAME_MAXSIZE 32228#define NFC_FIRMWARE_NAME_MAXSIZE 32
227#define NFC_ISO15693_UID_MAXSIZE 8229#define NFC_ISO15693_UID_MAXSIZE 8
230#define NFC_ATS_MAXSIZE 20
228 231
229/* NFC protocols */232/* NFC protocols */
230#define NFC_PROTO_JEWEL 1233#define NFC_PROTO_JEWEL 1

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t