summaryrefslogtreecommitdiff
path: root/src/rfid_proto_mifare_ul.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_ul.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_ul.c')
-rw-r--r--src/rfid_proto_mifare_ul.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/rfid_proto_mifare_ul.c b/src/rfid_proto_mifare_ul.c
index 8981b5e..65347b1 100644
--- a/src/rfid_proto_mifare_ul.c
+++ b/src/rfid_proto_mifare_ul.c
@@ -108,14 +108,41 @@ mful_transceive(struct rfid_protocol_handle *ph,
return -EINVAL;
}
+static int
+mful_getopt(struct rfid_protocol_handle *ph, int optname, void *optval,
+ unsigned int optlen)
+{
+ int ret = -EINVAL;
+ u_int16_t atqa;
+ unsigned int *size = optval;
+
+ switch (optname) {
+ case RFID_OPT_PROTO_SIZE:
+ ret = 0;
+ *size = 512;
+ break;
+ }
+
+ return ret;
+}
+
+
static struct rfid_protocol_handle *
mful_init(struct rfid_layer2_handle *l2h)
{
struct rfid_protocol_handle *ph;
+ u_int16_t atqa;
+ unsigned int atqa_len = sizeof(atqa);
if (l2h->l2->id != RFID_LAYER2_ISO14443A)
return NULL;
+ /* According to "Type Identification Procedure Rev. 1.3" */
+ rfid_layer2_getopt(l2h, RFID_OPT_14443A_ATQA,
+ &atqa, atqa_len);
+ if (atqa != 0x0044)
+ return NULL;
+
/* according to "Functional Specification Rev. 3.0 */
if (l2h->uid_len != 7)
return NULL;
@@ -138,6 +165,7 @@ const struct rfid_protocol rfid_protocol_mful = {
.read = &mful_read,
.write = &mful_write,
.fini = &mful_fini,
+ .getopt = &mful_getopt,
},
};
personal git repositories of Harald Welte. Your mileage may vary