mfcl_write(struct rfid_protocol_handle *ph, unsigned int page,
unsigned char *tx_data, unsigned int tx_len)
{
- unsigned int i;
unsigned char tx[18];
unsigned char rx[1];
- unsigned int rx_len;
+ unsigned int rx_len = sizeof(rx);
int ret;
if (page > MIFARE_CL_PAGE_MAX)
return ret;
}
+static int
+mfcl_getopt(struct rfid_protocol_handle *ph, int optname, void *optval,
+ unsigned int *optlen)
+{
+ int ret = -EINVAL;
+ u_int8_t atqa[2];
+ 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,
+ atqa, &atqa_size);
+ if (atqa[0] == 0x04 && atqa[1] == 0x00)
+ *size = 1024;
+ else if (atqa[0] == 0x02 && atqa[1] == 0x00)
+ *size = 4096;
+ else
+ ret = -EIO;
+ break;
+ }
+
+ return ret;
+}
+
static struct rfid_protocol_handle *
mfcl_init(struct rfid_layer2_handle *l2h)
{
.read = &mfcl_read,
.write = &mfcl_write,
.fini = &mfcl_fini,
+ .getopt = &mfcl_getopt,
},
};