summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Cuissard <cuissard@marvell.com>2014-08-18 18:50:23 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2014-08-18 18:53:17 +0200
commita7982fc453197cc03b3cd8e5a1efae038c56a416 (patch)
tree9ec5bc3f287d8ea8e4c9876265e584bc1170b36e
parent9915fb13c32cef95e84112fea0d8120739bfe846 (diff)
downloadneard-a7982fc453197cc03b3cd8e5a1efae038c56a416.tar.gz
neard-a7982fc453197cc03b3cd8e5a1efae038c56a416.tar.bz2
neard-a7982fc453197cc03b3cd8e5a1efae038c56a416.zip
nfctype5: Support 16 bits block numbers encoding
In ISO15693, it is possible for tags that have huge memory to encode the number of blocks on 16bits instead of 8bits. This has to be taken into account when GET_SYSTEM_INFO is received.
-rw-r--r--plugins/nfctype5.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/nfctype5.c b/plugins/nfctype5.c
index de566e2..6b50585 100644
--- a/plugins/nfctype5.c
+++ b/plugins/nfctype5.c
@@ -113,6 +113,7 @@
#define GET_SYS_INFO_FLAG_AFI 0x02
#define GET_SYS_INFO_FLAG_MEM_SIZE 0x04
#define GET_SYS_INFO_FLAG_IC_REF 0x08
+#define GET_SYS_INFO_FLAG_16B_NB_BLOCK 0x10
struct type5_cmd_hdr {
uint8_t flags;
@@ -749,7 +750,12 @@ static int t5_get_sys_info_resp(uint8_t *resp, int length, void *data)
offset++;
if (t5_resp->info_flags & GET_SYS_INFO_FLAG_MEM_SIZE) {
- near_tag_set_num_blks(tag, t5_resp->data[offset++] + 1);
+ if (t5_resp->info_flags & GET_SYS_INFO_FLAG_16B_NB_BLOCK) {
+ near_tag_set_num_blks(tag, (t5_resp->data[offset] |
+ (t5_resp->data[offset + 1] << 8)) + 1);
+ offset += 2;
+ } else
+ near_tag_set_num_blks(tag, t5_resp->data[offset++] + 1);
near_tag_set_blk_size(tag,
(t5_resp->data[offset++] & 0x1f) + 1);
} else { /* Tag must provide memory size info */