From d222d836a7a97c7164e0f96920b148d532fa574a Mon Sep 17 00:00:00 2001 From: laforge Date: Thu, 20 Oct 2005 20:15:49 +0000 Subject: add mifare ultralight support (incomplete) git-svn-id: https://svn.gnumonks.org/trunk/librfid@1543 e0336214-984f-0b4b-a45f-81c69e1f0ede --- rfid_protocol.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'rfid_protocol.c') diff --git a/rfid_protocol.c b/rfid_protocol.c index 3340b25..28da029 100644 --- a/rfid_protocol.c +++ b/rfid_protocol.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -40,7 +41,9 @@ rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id) int rfid_protocol_open(struct rfid_protocol_handle *ph) { - return ph->proto->fn.open(ph); + if (ph->proto->fn.open) + return ph->proto->fn.open(ph); + return 0; } int @@ -53,6 +56,30 @@ rfid_protocol_transcieve(struct rfid_protocol_handle *ph, timeout, flags); } +int +rfid_protocol_read(struct rfid_protocol_handle *ph, + unsigned int page, + unsigned char *rx_data, + unsigned int rx_len) +{ + if (ph->proto->fn.read) + return ph->proto->fn.read(ph, page, rx_data, rx_len); + else + return -EINVAL; +} + +int +rfid_protocol_write(struct rfid_protocol_handle *ph, + unsigned int page, + unsigned char *tx_data, + unsigned int tx_len) +{ + if (ph->proto->fn.write) + return ph->proto->fn.write(ph, page, tx_data, tx_len); + else + return -EINVAL; +} + int rfid_protocol_fini(struct rfid_protocol_handle *ph) { return ph->proto->fn.fini(ph); @@ -61,7 +88,9 @@ int rfid_protocol_fini(struct rfid_protocol_handle *ph) int rfid_protocol_close(struct rfid_protocol_handle *ph) { - return ph->proto->fn.close(ph); + if (ph->proto->fn.close) + return ph->proto->fn.close(ph); + return 0; } int -- cgit v1.2.3