summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-01-14 01:00:34 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2012-01-14 01:00:34 +0100
commit3a73d9043114f402c2d90eee059f0531f10875e4 (patch)
tree6e86052e28d43106f21104935f967d1368842d4c
parent2d818feedd22a7ef9d9d939976ae5237a8aef2ee (diff)
downloadneard-3a73d9043114f402c2d90eee059f0531f10875e4.tar.gz
neard-3a73d9043114f402c2d90eee059f0531f10875e4.tar.bz2
neard-3a73d9043114f402c2d90eee059f0531f10875e4.zip
target: Export NFCID to plugins
-rw-r--r--include/target.h2
-rw-r--r--src/target.c31
2 files changed, 33 insertions, 0 deletions
diff --git a/include/target.h b/include/target.h
index f15fba8..f42fe14 100644
--- a/include/target.h
+++ b/include/target.h
@@ -34,5 +34,7 @@ struct near_tag *near_target_add_tag(uint32_t adapter_idx, uint32_t target_idx,
size_t data_length);
enum near_target_sub_type near_target_get_subtype(uint32_t adapter_idx,
uint32_t target_idx);
+uint8_t *near_target_get_nfcid(uint32_t adapter_idx, uint32_t target_idx,
+ uint8_t *nfcid_len);
#endif
diff --git a/src/target.c b/src/target.c
index c5b84ee..23af6f5 100644
--- a/src/target.c
+++ b/src/target.c
@@ -446,6 +446,37 @@ enum near_target_sub_type near_target_get_subtype(uint32_t adapter_idx,
return target->sub_type;
}
+uint8_t *near_target_get_nfcid(uint32_t adapter_idx, uint32_t target_idx,
+ uint8_t *nfcid_len)
+{
+ struct near_target *target;
+ char *path;
+ uint8_t *nfcid;
+
+ path = g_strdup_printf("%s/nfc%d/target%d", NFC_PATH,
+ adapter_idx, target_idx);
+ if (path == NULL)
+ goto fail;
+
+ target = g_hash_table_lookup(target_hash, path);
+ g_free(path);
+ if (target == NULL)
+ goto fail;
+
+ nfcid = g_try_malloc0(target->nfcid_len);
+ if (nfcid == NULL)
+ goto fail;
+
+ memcpy(nfcid, target->nfcid, target->nfcid_len);
+ *nfcid_len = target->nfcid_len;
+
+ return nfcid;
+
+fail:
+ *nfcid_len = 0;
+ return NULL;
+}
+
struct near_tag *near_target_add_tag(uint32_t adapter_idx, uint32_t target_idx,
size_t data_length)
{