X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=src%2Frfid_proto_mifare_ul.c;h=d90ac63a84f466bf6e7f91eea44694261f2f8a04;hb=e3131addee5e4374cffddf7fa01bc02b5d39524c;hp=8981b5e7792f0e7dc42fd9b9aaa61bc228288cfe;hpb=3703fbd7ddc9068bddc59dc9096affda5ecb170d;p=librfid diff --git a/src/rfid_proto_mifare_ul.c b/src/rfid_proto_mifare_ul.c index 8981b5e..d90ac63 100644 --- a/src/rfid_proto_mifare_ul.c +++ b/src/rfid_proto_mifare_ul.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include @@ -99,23 +99,41 @@ mful_write(struct rfid_protocol_handle *ph, unsigned int page, return ret; } -static int -mful_transceive(struct rfid_protocol_handle *ph, - const unsigned char *tx_data, unsigned int tx_len, - unsigned char *rx_data, unsigned int *rx_len, - unsigned int timeout, unsigned int flags) +static int +mful_getopt(struct rfid_protocol_handle *ph, int optname, void *optval, + unsigned int *optlen) { - return -EINVAL; + int ret = -EINVAL; + unsigned int *size = optval; + + switch (optname) { + case RFID_OPT_PROTO_SIZE: + ret = 0; + /* we have to return the size in bytes, not bits */ + *size = 512/8; + break; + } + + return ret; } + static struct rfid_protocol_handle * mful_init(struct rfid_layer2_handle *l2h) { struct rfid_protocol_handle *ph; + u_int8_t atqa[2]; + 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[0] != 0x44 || atqa[1] != 0x00) + return NULL; + /* according to "Functional Specification Rev. 3.0 */ if (l2h->uid_len != 7) return NULL; @@ -138,6 +156,7 @@ const struct rfid_protocol rfid_protocol_mful = { .read = &mful_read, .write = &mful_write, .fini = &mful_fini, + .getopt = &mful_getopt, }, };