NFC: Export new attributes sensb_res and sensf_res
Subsystems (2)
PATCH 1/1 NFC: Export new attributes sensb_res and sensf_res
From: Ilan Elias <[email protected]>
Export new attributes sensb_res for tech B and sensf_res for tech F in the target info (returned as a response to NFC_CMD_GET_TARGET).
--- include/linux/nfc.h | 4 ++ include/net/nfc/nci.h | 19 ++++++++ include/net/nfc/nfc.h | 6 +++ net/nfc/nci/ntf.c | 111 +++++++++++++++++++++++++++++++++++++++++++------ net/nfc/netlink.c | 6 +++ 5 files changed, 133 insertions(+), 13 deletions(-)
include/linux/nfc.h +4 -0
@@ -89,6 +89,8 @@ enum nfc_commands {* @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the * target is not NFC-Forum compliant) * @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes +* @NFC_ATTR_TARGET_SENSB_RES: NFC-B targets extra information, max 12 bytes +* @NFC_ATTR_TARGET_SENSF_RES: NFC-F targets extra information, max 18 bytes * @NFC_ATTR_COMM_MODE: Passive or active mode * @NFC_ATTR_RF_MODE: Initiator or target */
@@ -101,6 +103,8 @@ enum nfc_attrs {NFC_ATTR_TARGET_SENS_RES ,NFC_ATTR_TARGET_SEL_RES ,NFC_ATTR_TARGET_NFCID1 , +NFC_ATTR_TARGET_SENSB_RES , +NFC_ATTR_TARGET_SENSF_RES ,NFC_ATTR_COMM_MODE , NFC_ATTR_RF_MODE,/* private: internal use only */
include/net/nfc/nci.h +19 -0
@@ -275,11 +275,27 @@ struct rf_tech_specific_params_nfca_poll {__u8 sel_res; } __packed; +struct rf_tech_specific_params_nfcb_poll { +__u8 sensb_res_len; +__u8 sensb_res[12 ];/* 11 or 12 Bytes */ +} __packed; + +struct rf_tech_specific_params_nfcf_poll { +__u8 bit_rate; +__u8 sensf_res_len; +__u8 sensf_res[18 ];/* 16 or 18 Bytes */ +} __packed; +struct activation_params_nfca_poll_iso_dep {__u8 rats_res_len;__u8 rats_res[20 ]; }; +struct activation_params_nfcb_poll_iso_dep { +__u8 attrib_res_len; +__u8 attrib_res[50 ]; +}; +struct nci_rf_intf_activated_ntf {__u8 rf_discovery_id;__u8 rf_interface;
@@ -291,6 +307,8 @@ struct nci_rf_intf_activated_ntf {union {struct rf_tech_specific_params_nfca_poll nfca_poll; +struct rf_tech_specific_params_nfcb_poll nfcb_poll; +struct rf_tech_specific_params_nfcf_poll nfcf_poll; } rf_tech_specific_params;__u8 data_exch_rf_tech_and_mode;
@@ -300,6 +318,7 @@ struct nci_rf_intf_activated_ntf {union {struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep; +struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep; } activation_params; } __packed;
include/net/nfc/nfc.h +6 -0
@@ -66,6 +66,8 @@ struct nfc_ops {#define NFC_TARGET_IDX_ANY -1#define NFC_MAX_GT_LEN 48#define NFC_MAX_NFCID1_LEN 10 +#define NFC_MAX_SENSB_RES_LEN 12 +#define NFC_MAX_SENSF_RES_LEN 18struct nfc_target {u32 idx;
@@ -74,6 +76,10 @@ struct nfc_target {u8 sel_res;u8 nfcid1_len;u8 nfcid1[NFC_MAX_NFCID1_LEN ]; +u8 sensb_res_len; +u8 sensb_res[NFC_MAX_SENSB_RES_LEN ]; +u8 sensf_res_len; +u8 sensf_res[NFC_MAX_SENSF_RES_LEN ]; };struct nfc_genl_data {
net/nfc/nci/ntf.c +98 -13
152 lines not on this page · raw message
net/nfc/netlink.c +6 -0
@@ -70,6 +70,12 @@ static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,if (target->nfcid1_len >0 )NLA_PUT (msg,NFC_ATTR_TARGET_NFCID1 , target->nfcid1_len, target->nfcid1); +if (target->sensb_res_len >0 ) +NLA_PUT (msg,NFC_ATTR_TARGET_SENSB_RES , target->sensb_res_len, + target->sensb_res); +if (target->sensf_res_len >0 ) +NLA_PUT (msg,NFC_ATTR_TARGET_SENSF_RES , target->sensf_res_len, + target->sensf_res);return genlmsg_end (msg, hdr);
Signature · 1 line
1.7.0.4
Hi Ilan,
include/net/nfc/nfc.h struct nfc_ops { · line 70
Quoted 10 lines · On Sun, 2012-01-08 at 10:56 +0200, [email protected] wrote:
include/net/nfc/nfc.h +2
-0@@ -66,6 +66,8 @@ struct nfc_ops {#define NFC_TARGET_IDX_ANY -1#define NFC_MAX_GT_LEN 48#define NFC_MAX_NFCID1_LEN 10 +#define NFC_MAX_SENSB_RES_LEN 12 +#define NFC_MAX_SENSF_RES_LEN 18
I think those values should be exported to user space though include/linux/nfc.h.
When fetching the byte stream from the netlink socket, you usually want to check if it has a valid length in order to memcpy it to a static array embedded with your target structure.
Same applies to NFC_MAX_NFCID1_LEN.
The rest of the code looks fine to me.
Cheers,
Samuel.
Hi Samuel,
Quoted 9 lines
Quoted 9 lines
include/net/nfc/nfc.h +1
-0@@ -66,6 +66,8 @@ struct nfc_ops {#define NFC_TARGET_IDX_ANY -1#define NFC_MAX_GT_LEN 48#define NFC_MAX_NFCID1_LEN 10 +#define NFC_MAX_SENSB_RES_LEN 12
Quoted 8 lines
include/net/nfc/nfc.h struct nfc_ops { · line 70
Quoted 1 line
include/net/nfc/nfc.h +1
-0+#define NFC_MAX_SENSF_RES_LEN 18I think those values should be exported to user space though
include/linux/nfc.h.
When fetching the byte stream from the netlink socket, you usually want
to check if it has a valid length in order to memcpy it to a static array embedded with your target structure.
Same applies toNFC_MAX_NFCID1_LEN.
Sure, I will move the definitions to include/linux/nfc.h.
Quoted 4 lines
The rest of the code looks fine to me.
Cheers,
Samuel.
Thanks & BR,
Ilan