summaryrefslogtreecommitdiff
path: root/src/rfid_proto_mifare_classic.c
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-12-01 13:29:00 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-12-01 13:29:00 +0000
commitf0a3a3f8c4f39dfacf2d370bd23b27cd5b3358bf (patch)
tree9980bd638b3df4f71088adc3f191dd4cbc392de5 /src/rfid_proto_mifare_classic.c
parent8b39e78b9d52a6c87ef0a4ab8402d7188f94e788 (diff)
- add size detection for mifare classic / ultralight
- add possibility to obtain ATQA via getopt - fix default -EINVAL return of tcl getopt git-svn-id: https://svn.gnumonks.org/trunk/librfid@1930 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'src/rfid_proto_mifare_classic.c')
-rw-r--r--src/rfid_proto_mifare_classic.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/rfid_proto_mifare_classic.c b/src/rfid_proto_mifare_classic.c
index 4032b80..c2020b0 100644
--- a/src/rfid_proto_mifare_classic.c
+++ b/src/rfid_proto_mifare_classic.c
@@ -140,6 +140,35 @@ mfcl_write(struct rfid_protocol_handle *ph, unsigned int page,
return ret;
}
+static int
+mfcl_getopt(struct rfid_protocol_handle *ph, int optname, void *optval,
+ unsigned int *optlen)
+{
+ int ret = -EINVAL;
+ u_int16_t atqa;
+ unsigned int atqa_size = sizeof(atqa);
+ unsigned int *size = optval;
+
+ switch (optname) {
+ case RFID_OPT_PROTO_SIZE:
+ if (*optlen < sizeof(*size))
+ return -EINVAL;
+ *optlen = sizeof(*size);
+ ret = 0;
+ rfid_layer2_getopt(ph->l2h, RFID_OPT_14443A_ATQA,
+ (void *) &atqa, &atqa_size);
+ if (atqa == 0x0004)
+ *size = 1024;
+ else if (atqa == 0x0002)
+ *size = 4096;
+ else
+ ret = -EIO;
+ break;
+ }
+
+ return ret;
+}
+
static struct rfid_protocol_handle *
mfcl_init(struct rfid_layer2_handle *l2h)
{
@@ -169,6 +198,7 @@ const struct rfid_protocol rfid_protocol_mfcl = {
.read = &mfcl_read,
.write = &mfcl_write,
.fini = &mfcl_fini,
+ .getopt = &mfcl_getopt,
},
};
personal git repositories of Harald Welte. Your mileage may vary