diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2015-02-01 22:54:20 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2015-03-26 12:28:15 +0100 |
commit | d30ea3524ddb5433e20b945dcfece10fcb7bb106 (patch) | |
tree | 20c6980df4f9a160f322387939867d682be73f73 | |
parent | fcb5119278bfda9a4139ccdf089f4c8e97fcdbdf (diff) | |
download | neard-d30ea3524ddb5433e20b945dcfece10fcb7bb106.tar.gz |
netlink: Add support for NFC_CMD_ACTIVATE_TARGET
When reading a tag, it might be useful to have the ability to
reactive it when it is in halt state.
This will be usefull for example with specific tag type2.
-rw-r--r-- | include/nfc_copy.h | 1 | ||||
-rw-r--r-- | include/tag.h | 2 | ||||
-rw-r--r-- | src/near.h | 2 | ||||
-rw-r--r-- | src/netlink.c | 35 | ||||
-rw-r--r-- | src/tag.c | 7 |
5 files changed, 47 insertions, 0 deletions
diff --git a/include/nfc_copy.h b/include/nfc_copy.h index 9789dc9..0b25f5c 100644 --- a/include/nfc_copy.h +++ b/include/nfc_copy.h @@ -116,6 +116,7 @@ enum nfc_commands { NFC_EVENT_SE_TRANSACTION, NFC_CMD_GET_SE, NFC_CMD_SE_IO, + NFC_CMD_ACTIVATE_TARGET, /* private: internal use only */ __NFC_CMD_AFTER_LAST }; diff --git a/include/tag.h b/include/tag.h index 5332027..013a4d1 100644 --- a/include/tag.h +++ b/include/tag.h @@ -80,6 +80,8 @@ struct near_tag_driver { struct near_tag; struct near_tag *near_tag_get_tag(uint32_t adapter_idx, uint32_t target_idx); +int near_tag_activate_target(uint32_t adapter_idx, uint32_t target_idx, + uint32_t protocol); void near_tag_set_ro(struct near_tag *tag, bool readonly); void near_tag_set_blank(struct near_tag *tag, bool blank); bool near_tag_get_blank(struct near_tag *tag); @@ -162,6 +162,8 @@ int __near_netlink_get_adapters(void); int __near_netlink_start_poll(int idx, uint32_t im_protocols, uint32_t tm_protocols); int __near_netlink_stop_poll(int idx); +int __near_netlink_activate_target(uint32_t idx, uint32_t target_idx, + uint32_t protocol); int __near_netlink_dep_link_up(uint32_t idx, uint32_t target_idx, uint8_t comm_mode, uint8_t rf_mode); int __near_netlink_dep_link_down(uint32_t idx); diff --git a/src/netlink.c b/src/netlink.c index 9155f62..d02d62f 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -294,6 +294,41 @@ nla_put_failure: return err; } +int __near_netlink_activate_target(uint32_t idx, uint32_t target_idx, + uint32_t protocol) +{ + struct nl_msg *msg; + void *hdr; + int err; + + DBG(""); + + msg = nlmsg_alloc(); + if (!msg) + return -ENOMEM; + + hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, nfc_state->nfc_id, 0, + NLM_F_REQUEST, NFC_CMD_ACTIVATE_TARGET, + NFC_GENL_VERSION); + if (!hdr) { + err = -EINVAL; + goto nla_put_failure; + } + + err = -EMSGSIZE; + + NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx); + NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target_idx); + NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, protocol); + + err = nl_send_msg(nfc_state->cmd_sock, msg, NULL, NULL); + +nla_put_failure: + nlmsg_free(msg); + + return err; +} + int __near_netlink_dep_link_up(uint32_t idx, uint32_t target_idx, uint8_t comm_mode, uint8_t rf_mode) { @@ -1187,6 +1187,13 @@ int __near_tag_check_presence(struct near_tag *tag, near_tag_io_cb cb) return -EOPNOTSUPP; } +int near_tag_activate_target(uint32_t adapter_idx, uint32_t target_idx, + uint32_t protocol) +{ + return __near_netlink_activate_target(adapter_idx, target_idx, + protocol); +} + static void free_tag(gpointer data) { struct near_tag *tag = data; |