From 5fc01ff6f98d72219420bc29fb59d2d6eb93e887 Mon Sep 17 00:00:00 2001 From: laforge Date: Sat, 22 Oct 2005 20:20:21 +0000 Subject: - add mifare classic support - move uid/pupi from l2 private data into l2 global data - various cleanups git-svn-id: https://svn.gnumonks.org/trunk/librfid@1555 e0336214-984f-0b4b-a45f-81c69e1f0ede --- include/rfid/rfid_asic_rc632.h | 72 ++++++++++++++++------------- include/rfid/rfid_layer2.h | 2 + include/rfid/rfid_layer2_iso14443a.h | 2 - include/rfid/rfid_layer2_iso14443b.h | 1 - include/rfid/rfid_protocol.h | 1 + include/rfid/rfid_protocol_mifare_classic.h | 11 +++++ include/rfid/rfid_protocol_mifare_ul.h | 2 +- include/rfid/rfid_reader.h | 5 ++ 8 files changed, 60 insertions(+), 36 deletions(-) create mode 100644 include/rfid/rfid_protocol_mifare_classic.h (limited to 'include/rfid') diff --git a/include/rfid/rfid_asic_rc632.h b/include/rfid/rfid_asic_rc632.h index 13279a8..7a984ff 100644 --- a/include/rfid/rfid_asic_rc632.h +++ b/include/rfid/rfid_asic_rc632.h @@ -6,18 +6,18 @@ struct rfid_asic_transport_handle; struct rfid_asic_rc632_transport { struct { int (*reg_write)(struct rfid_asic_transport_handle *rath, - unsigned char reg, - unsigned char value); + u_int8_t reg, + u_int8_t value); int (*reg_read)(struct rfid_asic_transport_handle *rath, - unsigned char reg, - unsigned char *value); + u_int8_t reg, + u_int8_t *value); int (*fifo_write)(struct rfid_asic_transport_handle *rath, - unsigned char len, - const unsigned char *buf, - unsigned char flags); + u_int8_t len, + const u_int8_t *buf, + u_int8_t flags); int (*fifo_read)(struct rfid_asic_transport_handle *rath, - unsigned char len, - unsigned char *buf); + u_int8_t len, + u_int8_t *buf); } fn; }; @@ -33,16 +33,16 @@ struct rfid_asic_rc632 { int (*turn_on_rf)(struct rfid_asic_handle *h); int (*turn_off_rf)(struct rfid_asic_handle *h); int (*transcieve)(struct rfid_asic_handle *h, - const unsigned char *tx_buf, + const u_int32_t *tx_buf, unsigned int tx_len, - unsigned char *rx_buf, + u_int32_t *rx_buf, unsigned int *rx_len, u_int64_t timeout, unsigned int flags); struct { int (*init)(struct rfid_asic_handle *h); int (*transcieve_sf)(struct rfid_asic_handle *h, - unsigned char cmd, + u_int32_t cmd, struct iso14443a_atqa *atqa); int (*transcieve_acf)(struct rfid_asic_handle *h, struct iso14443a_anticol_cmd *cmd, @@ -54,6 +54,11 @@ struct rfid_asic_rc632 { struct { int (*init)(struct rfid_asic_handle *h); } iso15693; + struct { + int (*setkey)(struct rfid_asic_handle *h, unsigned char *key); + int (*auth)(struct rfid_asic_handle *h, u_int8_t cmd, + u_int32_t serno, u_int8_t block); + } mifare_classic; } fn; }; @@ -65,33 +70,34 @@ struct rfid_asic_rc632_handle { struct rc632_transport_handle th; }; +#if 0 int rc632_reg_write(struct rfid_asic_handle *handle, - unsigned char reg, - unsigned char val); + u_int8_t reg, + u_int8_t val); int rc632_reg_read(struct rfid_asic_handle *handle, - unsigned char reg, - unsigned char *val); + u_int8_t reg, + u_int8_t *val); int rc632_fifo_write(struct rfid_asic_handle *handle, - unsigned char len, - const unsigned char *buf, - unsigned char flags); + u_int8_t len, + const u_int32_t *buf, + u_int8_t flags); int rc632_fifo_read(struct rfid_asic_handle *handle, - unsigned char len, - unsigned char *buf); + u_int8_t len, + u_int8_t *buf); int -rc632_set_bits(struct rfid_asic_handle *handle, unsigned char reg, - unsigned char val); +rc632_set_bits(struct rfid_asic_handle *handle, u_int8_t reg, + u_int82_t val); int -rc632_clear_bits(struct rfid_asic_handle *handle, unsigned char reg, - unsigned char val); +rc632_clear_bits(struct rfid_asic_handle *handle, u_int32_t reg, + u_int32_t val); int @@ -113,16 +119,16 @@ rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time); int rc632_transmit(struct rfid_asic_handle *handle, - const unsigned char *buf, - unsigned char len, + const u_int32_t *buf, + u_int32_t len, u_int64_t timeout); int rc632_transcieve(struct rfid_asic_handle *handle, - const unsigned char *tx_buf, - unsigned char tx_len, - unsigned char *rx_buf, - unsigned char *rx_len, + const u_int32_t *tx_buf, + u_int32_t tx_len, + u_int32_t *rx_buf, + u_int32_t *rx_len, unsigned int timer, unsigned int toggle); @@ -134,7 +140,7 @@ int rc632_calc_crc16_from(struct rfid_asic_handle *handle); int -rc632_register_dump(struct rfid_asic_handle *handle, unsigned char *buf); +rc632_register_dump(struct rfid_asic_handle *handle, u_int32_t *buf); struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th); @@ -142,3 +148,5 @@ struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th); extern struct rfid_asic rc632; #endif + +#endif diff --git a/include/rfid/rfid_layer2.h b/include/rfid/rfid_layer2.h index fb296a2..c87578b 100644 --- a/include/rfid/rfid_layer2.h +++ b/include/rfid/rfid_layer2.h @@ -29,6 +29,8 @@ struct rfid_layer2 { struct rfid_layer2_handle { struct rfid_reader_handle *rh; + unsigned char uid[10]; /* triple size 14443a id is 10 bytes */ + unsigned int uid_len; union { struct iso14443a_handle iso14443a; struct iso14443b_handle iso14443b; diff --git a/include/rfid/rfid_layer2_iso14443a.h b/include/rfid/rfid_layer2_iso14443a.h index 9594abb..400f951 100644 --- a/include/rfid/rfid_layer2_iso14443a.h +++ b/include/rfid/rfid_layer2_iso14443a.h @@ -68,8 +68,6 @@ struct iso14443a_handle { unsigned int state; unsigned int level; unsigned int tcl_capable; - unsigned int uid_len; - unsigned char uid[10]; /* Triple size UID is 10 bytes */ }; enum iso14443a_level { diff --git a/include/rfid/rfid_layer2_iso14443b.h b/include/rfid/rfid_layer2_iso14443b.h index b35a118..6c84c26 100644 --- a/include/rfid/rfid_layer2_iso14443b.h +++ b/include/rfid/rfid_layer2_iso14443b.h @@ -43,7 +43,6 @@ struct iso14443b_attrib_hdr { struct iso14443b_handle { unsigned int tcl_capable; /* do we support T=CL */ - unsigned char pupi[4]; /* Pseudo-Unique PICC Identifier */ unsigned int cid; /* Card ID */ unsigned int fsc; /* max. frame size card */ diff --git a/include/rfid/rfid_protocol.h b/include/rfid/rfid_protocol.h index c232818..1403e83 100644 --- a/include/rfid/rfid_protocol.h +++ b/include/rfid/rfid_protocol.h @@ -76,5 +76,6 @@ enum rfid_protocol_id { RFID_PROTOCOL_UNKNOWN, RFID_PROTOCOL_TCL, RFID_PROTOCOL_MIFARE_UL, + RFID_PROTOCOL_MIFARE_CLASSIC, }; #endif diff --git a/include/rfid/rfid_protocol_mifare_classic.h b/include/rfid/rfid_protocol_mifare_classic.h new file mode 100644 index 0000000..01066f4 --- /dev/null +++ b/include/rfid/rfid_protocol_mifare_classic.h @@ -0,0 +1,11 @@ +#ifndef _MIFARE_CLASSIC_H + +extern struct rfid_protocol rfid_protocol_mfcl; + +#define RFID_CMD_MIFARE_AUTH1A 0x60 +#define RFID_CMD_MIFARE_AUTH1B 0x61 + +#define MIFARE_CLASSIC_KEY_DEFAULT "\xa0\xa1\xa2\xa3\xa4\xa5" + + +#endif diff --git a/include/rfid/rfid_protocol_mifare_ul.h b/include/rfid/rfid_protocol_mifare_ul.h index 729c481..06cf515 100644 --- a/include/rfid/rfid_protocol_mifare_ul.h +++ b/include/rfid/rfid_protocol_mifare_ul.h @@ -13,7 +13,7 @@ #define MIFARE_UL_PAGE_LOCK 2 #define MIFARE_UL_PAGE_OTP 3 -struct rfid_protocol rfid_protocol_mful; +extern struct rfid_protocol rfid_protocol_mful; int rfid_mful_lock_page(struct rfid_protocol_handle *ph, unsigned int page); diff --git a/include/rfid/rfid_reader.h b/include/rfid/rfid_reader.h index 98c03a1..0acd532 100644 --- a/include/rfid/rfid_reader.h +++ b/include/rfid/rfid_reader.h @@ -33,6 +33,11 @@ struct rfid_reader { struct rfid_15693_reader { int (*init)(struct rfid_reader_handle *rh); } iso15693; + struct rfid_mifare_classic_reader { + int (*setkey)(struct rfid_reader_handle *h, unsigned char *key); + int (*auth)(struct rfid_reader_handle *h, u_int8_t cmd, + u_int32_t serno, u_int8_t block); + } mifare_classic; struct rfid_reader *next; }; -- cgit v1.2.3