From 1fcc35aad699f3d40ca786b99c7255cf8aa55892 Mon Sep 17 00:00:00 2001 From: laforge Date: Tue, 8 Nov 2005 13:04:32 +0000 Subject: move include directory for pkginclude compliance git-svn-id: https://svn.gnumonks.org/trunk/librfid@1664 e0336214-984f-0b4b-a45f-81c69e1f0ede --- include/Makefile.am | 2 +- include/librfid/Makefile.am | 10 ++ include/librfid/rfid.h | 26 ++++ include/librfid/rfid_asic.h | 45 +++++++ include/librfid/rfid_asic_rc632.h | 160 +++++++++++++++++++++++++ include/librfid/rfid_layer2.h | 76 ++++++++++++ include/librfid/rfid_layer2_iso14443a.h | 84 +++++++++++++ include/librfid/rfid_layer2_iso14443b.h | 85 +++++++++++++ include/librfid/rfid_layer2_iso15693.h | 55 +++++++++ include/librfid/rfid_protocol.h | 88 ++++++++++++++ include/librfid/rfid_protocol_mifare_classic.h | 28 +++++ include/librfid/rfid_protocol_mifare_ul.h | 24 ++++ include/librfid/rfid_protocol_tcl.h | 70 +++++++++++ include/librfid/rfid_reader.h | 67 +++++++++++ include/librfid/rfid_reader_cm5121.h | 21 ++++ include/rfid/Makefile.am | 10 -- include/rfid/rfid.h | 26 ---- include/rfid/rfid_asic.h | 45 ------- include/rfid/rfid_asic_rc632.h | 160 ------------------------- include/rfid/rfid_layer2.h | 76 ------------ include/rfid/rfid_layer2_iso14443a.h | 84 ------------- include/rfid/rfid_layer2_iso14443b.h | 85 ------------- include/rfid/rfid_layer2_iso15693.h | 55 --------- include/rfid/rfid_protocol.h | 88 -------------- include/rfid/rfid_protocol_mifare_classic.h | 28 ----- include/rfid/rfid_protocol_mifare_ul.h | 24 ---- include/rfid/rfid_protocol_tcl.h | 70 ----------- include/rfid/rfid_reader.h | 67 ----------- include/rfid/rfid_reader_cm5121.h | 21 ---- 29 files changed, 840 insertions(+), 840 deletions(-) create mode 100644 include/librfid/Makefile.am create mode 100644 include/librfid/rfid.h create mode 100644 include/librfid/rfid_asic.h create mode 100644 include/librfid/rfid_asic_rc632.h create mode 100644 include/librfid/rfid_layer2.h create mode 100644 include/librfid/rfid_layer2_iso14443a.h create mode 100644 include/librfid/rfid_layer2_iso14443b.h create mode 100644 include/librfid/rfid_layer2_iso15693.h create mode 100644 include/librfid/rfid_protocol.h create mode 100644 include/librfid/rfid_protocol_mifare_classic.h create mode 100644 include/librfid/rfid_protocol_mifare_ul.h create mode 100644 include/librfid/rfid_protocol_tcl.h create mode 100644 include/librfid/rfid_reader.h create mode 100644 include/librfid/rfid_reader_cm5121.h delete mode 100644 include/rfid/Makefile.am delete mode 100644 include/rfid/rfid.h delete mode 100644 include/rfid/rfid_asic.h delete mode 100644 include/rfid/rfid_asic_rc632.h delete mode 100644 include/rfid/rfid_layer2.h delete mode 100644 include/rfid/rfid_layer2_iso14443a.h delete mode 100644 include/rfid/rfid_layer2_iso14443b.h delete mode 100644 include/rfid/rfid_layer2_iso15693.h delete mode 100644 include/rfid/rfid_protocol.h delete mode 100644 include/rfid/rfid_protocol_mifare_classic.h delete mode 100644 include/rfid/rfid_protocol_mifare_ul.h delete mode 100644 include/rfid/rfid_protocol_tcl.h delete mode 100644 include/rfid/rfid_reader.h delete mode 100644 include/rfid/rfid_reader_cm5121.h (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am index df5706a..dfaa277 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = rfid +SUBDIRS = librfid diff --git a/include/librfid/Makefile.am b/include/librfid/Makefile.am new file mode 100644 index 0000000..59ce8cb --- /dev/null +++ b/include/librfid/Makefile.am @@ -0,0 +1,10 @@ + +pkginclude_HEADERS = rfid.h rfid_asic.h rfid_asic_rc632.h \ + rfid_layer2.h rfid_layer2_iso14443a.h \ + rfid_layer2_iso14443b.h rfid_layer2_iso15693.h \ + rfid_protocol.h rfid_protocol_tcl.h \ + rfid_protocol_mifare_ul.h \ + rfid_protocol_mifare_classic.h \ + rfid_reader.h \ + rfid_reader_cm5121.h + diff --git a/include/librfid/rfid.h b/include/librfid/rfid.h new file mode 100644 index 0000000..6717ef8 --- /dev/null +++ b/include/librfid/rfid.h @@ -0,0 +1,26 @@ +#ifndef _RFID_H +#define _RFID_H + +#include + +#ifdef __LIBRFID__ + +enum rfid_frametype { + RFID_14443A_FRAME_REGULAR, + RFID_14443B_FRAME_REGULAR, + RFID_MIFARE_FRAME, +}; + +#define DEBUGP(x, args ...) fprintf(stderr, "%s(%d):%s: " x, __FILE__, __LINE__, __FUNCTION__, ## args) +#define DEBUGPC(x, args ...) fprintf(stderr, x, ## args) +extern const char *rfid_hexdump(const void *data, unsigned int len); + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + +#endif /* __LIBRFID__ */ + +int rfid_init(); + +#endif /* _RFID_H */ diff --git a/include/librfid/rfid_asic.h b/include/librfid/rfid_asic.h new file mode 100644 index 0000000..3686a7c --- /dev/null +++ b/include/librfid/rfid_asic.h @@ -0,0 +1,45 @@ +#ifndef _RFID_ASIC_H +#define _RFID_ASIC_H + +enum rfid_frametype; + +#include + +struct rfid_asic_transport { + char *name; + union { + struct rfid_asic_rc632_transport rc632; + } priv; +}; + +struct rfid_asic_transport_handle { + void *data; /* handle to stuff like even lower layers */ + + struct rfid_asic_transport *rat; +}; + + +struct rfid_asic_handle { + struct rfid_asic_transport_handle *rath; + unsigned int fc; + unsigned int mtu; + unsigned int mru; + + union { + struct rfid_asic_rc632_handle rc632; + //struct rfid_asic_rc531_handle rc531; + } priv; + struct rfid_asic *asic; +}; + + +struct rfid_asic { + char *name; + unsigned int fc; /* carrier frequency */ + union { + struct rfid_asic_rc632 rc632; + //struct rfid_asic_rc531 rc531; + } priv; +}; + +#endif /* _RFID_ASIC_H */ diff --git a/include/librfid/rfid_asic_rc632.h b/include/librfid/rfid_asic_rc632.h new file mode 100644 index 0000000..893e73b --- /dev/null +++ b/include/librfid/rfid_asic_rc632.h @@ -0,0 +1,160 @@ +#ifndef _RFID_ASIC_RC632_H +#define _RFID_ASIC_RC632_H + +struct rfid_asic_transport_handle; + +#include +#include + +struct rfid_asic_rc632_transport { + struct { + int (*reg_write)(struct rfid_asic_transport_handle *rath, + u_int8_t reg, + u_int8_t value); + int (*reg_read)(struct rfid_asic_transport_handle *rath, + u_int8_t reg, + u_int8_t *value); + int (*fifo_write)(struct rfid_asic_transport_handle *rath, + u_int8_t len, + const u_int8_t *buf, + u_int8_t flags); + int (*fifo_read)(struct rfid_asic_transport_handle *rath, + u_int8_t len, + u_int8_t *buf); + } fn; +}; + +struct rfid_asic_handle; + +struct iso14443a_atqa; +struct iso14443a_anticol_cmd; + +struct rfid_asic_rc632 { + struct { + int (*power_up)(struct rfid_asic_handle *h); + int (*power_down)(struct rfid_asic_handle *h); + 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, + enum rfid_frametype, + const u_int32_t *tx_buf, + unsigned int tx_len, + 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, + u_int32_t cmd, + struct iso14443a_atqa *atqa); + int (*transcieve_acf)(struct rfid_asic_handle *h, + struct iso14443a_anticol_cmd *cmd, + unsigned int *bit_of_col); + int (*set_speed)(struct rfid_asic_handle *h, + unsigned int tx, + unsigned int speed); + } iso14443a; + struct { + int (*init)(struct rfid_asic_handle *h); + } iso14443b; + struct { + int (*init)(struct rfid_asic_handle *h); + } iso15693; + struct { + int (*setkey)(struct rfid_asic_handle *h, + const 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; +}; + +struct rc632_transport_handle { +}; + +/* A handle to a specific RC632 chip */ +struct rfid_asic_rc632_handle { + struct rc632_transport_handle th; +}; + +#if 0 +int +rc632_reg_write(struct rfid_asic_handle *handle, + u_int8_t reg, + u_int8_t val); + +int +rc632_reg_read(struct rfid_asic_handle *handle, + u_int8_t reg, + u_int8_t *val); +int +rc632_fifo_write(struct rfid_asic_handle *handle, + u_int8_t len, + const u_int32_t *buf, + u_int8_t flags); + +int +rc632_fifo_read(struct rfid_asic_handle *handle, + u_int8_t len, + u_int8_t *buf); + +int +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, u_int32_t reg, + u_int32_t val); + + +int +rc632_turn_on_rf(struct rfid_asic_handle *handle); + + +int +rc632_turn_off_rf(struct rfid_asic_handle *handle); + +int +rc632_power_up(struct rfid_asic_handle *handle); + +int +rc632_power_down(struct rfid_asic_handle *handle); + + +int +rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time); + +int +rc632_transmit(struct rfid_asic_handle *handle, + const u_int32_t *buf, + u_int32_t len, + u_int64_t timeout); + +int +rc632_transcieve(struct rfid_asic_handle *handle, + 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); + +int +rc632_read_eeprom(struct rfid_asic_handle *handle); + + +int +rc632_calc_crc16_from(struct rfid_asic_handle *handle); + +int +rc632_register_dump(struct rfid_asic_handle *handle, u_int32_t *buf); + + +struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th); + + +extern struct rfid_asic rc632; +#endif + +#endif diff --git a/include/librfid/rfid_layer2.h b/include/librfid/rfid_layer2.h new file mode 100644 index 0000000..4622a02 --- /dev/null +++ b/include/librfid/rfid_layer2.h @@ -0,0 +1,76 @@ +#ifndef _RFID_LAYER2_H +#define _RFID_LAYER2_H + +#include +#include + +struct rfid_layer2_handle; +struct rfid_reader_handle; + +enum rfid_layer2_id { + RFID_LAYER2_NONE, + RFID_LAYER2_ISO14443A, + RFID_LAYER2_ISO14443B, + RFID_LAYER2_ISO15693, +}; + +struct rfid_layer2_handle *rfid_layer2_init(struct rfid_reader_handle *rh, + unsigned int id); +int rfid_layer2_open(struct rfid_layer2_handle *l2h); +int rfid_layer2_transcieve(struct rfid_layer2_handle *l2h, + enum rfid_frametype frametype, + const unsigned char *tx_buf, unsigned int tx_len, + unsigned char *rx_buf, unsigned int *rx_len, + u_int64_t timeout, unsigned int flags); +int rfid_layer2_close(struct rfid_layer2_handle *l2h); +int rfid_layer2_fini(struct rfid_layer2_handle *l2h); +int rfid_layer2_getopt(struct rfid_layer2_handle *ph, int optname, + void *optval, unsigned int *optlen); +int rfid_layer2_setopt(struct rfid_layer2_handle *ph, int optname, + const void *optval, unsigned int optlen); + +#ifdef __LIBRFID__ + +#include +#include +#include + +struct rfid_layer2 { + unsigned int id; + char *name; + + struct { + struct rfid_layer2_handle *(*init)(struct rfid_reader_handle *h); + int (*open)(struct rfid_layer2_handle *h); + int (*transcieve)(struct rfid_layer2_handle *h, + enum rfid_frametype frametype, + const unsigned char *tx_buf, + unsigned int tx_len, unsigned char *rx_buf, + unsigned int *rx_len, u_int64_t timeout, + unsigned int flags); + int (*close)(struct rfid_layer2_handle *h); + int (*fini)(struct rfid_layer2_handle *h); + int (*getopt)(struct rfid_layer2_handle *h, + int optname, void *optval, unsigned int *optlen); + int (*setopt)(struct rfid_layer2_handle *h, + int optname, const void *optval, + unsigned int optlen); + } fn; + struct rfid_layer2 *next; +}; + +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; + struct iso15693_handle iso15693; + } priv; + struct rfid_layer2 *l2; +}; + +#endif /* __LIBRFID__ */ + +#endif diff --git a/include/librfid/rfid_layer2_iso14443a.h b/include/librfid/rfid_layer2_iso14443a.h new file mode 100644 index 0000000..50a6f43 --- /dev/null +++ b/include/librfid/rfid_layer2_iso14443a.h @@ -0,0 +1,84 @@ +#ifndef _RFID_ISO14443A_H +#define _RFID_ISO14443A_H + +enum rfid_14443a_opt { + RFID_OPT_14443A_SPEED_RX = 0x00000001, + RFID_OPT_14443A_SPEED_TX = 0x00000002, +}; + +enum rfid_14443_opt_speed { + RFID_14443A_SPEED_106K = 0x01, + RFID_14443A_SPEED_212K = 0x02, + RFID_14443A_SPEED_424K = 0x04, + RFID_14443A_SPEED_848K = 0x08, +}; + +#ifdef __LIBRFID__ + +#include + +/* protocol definitions */ + +/* ISO 14443-3, Chapter 6.3.1 */ +enum iso14443a_sf_cmd { + ISO14443A_SF_CMD_REQA = 0x26, + ISO14443A_SF_CMD_WUPA = 0x52, + ISO14443A_SF_CMD_OPT_TIMESLOT = 0x35, /* Annex C */ + /* 40 to 4f and 78 to 7f: proprietary */ +}; + +struct iso14443a_atqa { + u_int8_t bf_anticol:5, + rfu1:1, + uid_size:2; + u_int8_t proprietary:4, + rfu2:4; +}; + +#define ISO14443A_HLTA 0x5000 + +/* ISO 14443-3, Chapter 6.3.2 */ +struct iso14443a_anticol_cmd { + unsigned char sel_code; + unsigned char nvb; + unsigned char uid_bits[5]; +}; + +enum iso14443a_anticol_sel_code { + ISO14443A_AC_SEL_CODE_CL1 = 0x93, + ISO14443A_AC_SEL_CODE_CL2 = 0x95, + ISO14443A_AC_SEL_CODE_CL3 = 0x97, +}; + +#define ISO14443A_BITOFCOL_NONE 0xffffffff + +struct iso14443a_handle { + unsigned int state; + unsigned int level; + unsigned int tcl_capable; +}; + +enum iso14443a_level { + ISO14443A_LEVEL_NONE, + ISO14443A_LEVEL_CL1, + ISO14443A_LEVEL_CL2, + ISO14443A_LEVEL_CL3, +}; + +enum iso14443a_state { + ISO14443A_STATE_ERROR, + ISO14443A_STATE_NONE, + ISO14443A_STATE_REQA_SENT, + ISO14443A_STATE_ATQA_RCVD, + ISO14443A_STATE_NO_BITFRAME_ANTICOL, + ISO14443A_STATE_ANTICOL_RUNNING, + ISO14443A_STATE_SELECTED, +}; + +#include +struct rfid_layer2 rfid_layer2_iso14443a; + +#endif /* __LIBRFID__ */ + + +#endif /* _ISO14443A_H */ diff --git a/include/librfid/rfid_layer2_iso14443b.h b/include/librfid/rfid_layer2_iso14443b.h new file mode 100644 index 0000000..5d6d979 --- /dev/null +++ b/include/librfid/rfid_layer2_iso14443b.h @@ -0,0 +1,85 @@ +#ifndef _RFID_LAYER2_ISO14443B_H +#define _RFID_LAYER2_ISO14443B_H + +#ifdef __LIBRFID__ + +struct iso14443b_atqb { + unsigned char fifty; + unsigned char pupi[4]; + unsigned char app_data[4]; + struct { + unsigned char bit_rate_capability; + unsigned char protocol_type:4, + max_frame_size:4; + unsigned char fo:2, + adc:2, + fwi:4; + } protocol_info; +}; + +struct iso14443b_attrib_hdr { + unsigned char one_d; + unsigned char identifier[4]; + struct { + unsigned char rfu:2, + sof:1, + eof:1, + min_tr1:2, + min_tr0:2; + } param1; + struct { + unsigned char fsdi:4, + spd_out:2, + spd_in:2; + } param2; + struct { + unsigned char protocol_type:4, + rfu:4; + } param3; + struct { + unsigned char cid:4, + rfu:4; + } param4; +}; + +struct iso14443b_handle { + unsigned int tcl_capable; /* do we support T=CL */ + + unsigned int cid; /* Card ID */ + + unsigned int fsc; /* max. frame size card */ + unsigned int fsd; /* max. frame size reader */ + + unsigned int fwt; /* frame waiting time (in usec) */ + + unsigned int mbl; /* maximum buffer length */ + + unsigned int tr0; /* pcd-eof to picc-subcarrier-on */ + unsigned int tr1; /* picc-subcarrier-on to picc-sof */ + + unsigned int flags; + unsigned int state; +}; + +enum { + ISO14443B_CID_SUPPORTED = 0x01, + ISO14443B_NAD_SUPPORTED = 0x02, +}; + +enum { + ISO14443B_STATE_ERROR, + ISO14443B_STATE_NONE, + ISO14443B_STATE_REQB_SENT, + ISO14443B_STATE_ATQB_RCVD, + ISO14443B_STATE_ATTRIB_SENT, + ISO14443B_STATE_SELECTED, + ISO14443B_STATE_HLTB_SENT, + ISO14443B_STATE_HALTED, +}; + +#include +struct rfid_layer2 rfid_layer2_iso14443b; + +#endif /* __LIBRFID__ */ + +#endif diff --git a/include/librfid/rfid_layer2_iso15693.h b/include/librfid/rfid_layer2_iso15693.h new file mode 100644 index 0000000..ea7f87a --- /dev/null +++ b/include/librfid/rfid_layer2_iso15693.h @@ -0,0 +1,55 @@ +#ifndef _RFID_ISO15693_H +#define _RFID_ISO15693_H + +#include + +/* +07h = TagIt +04h = I.CODE +05h = Infineon +02h = ST +*/ + +/* protocol definitions */ + +struct iso15693_handle; + +struct iso15693_transport { + unsigned char *name; + + struct { + int (*init)(struct iso15693_handle *handle); + int (*fini)(struct iso15693_handle *handle); + +#if 0 + int (*transcieve_sf)(struct iso14443a_handle *handle, + unsigned char cmd, + struct iso14443a_atqa *atqa); + int (*transcieve_acf)(struct iso14443a_handle *handle, + struct iso14443a_anticol_cmd *acf, + unsigned int *bit_of_col); +#endif + int (*transcieve)(struct iso15693_handle *handle, + const unsigned char *tx_buf, + unsigned int tx_len, + unsigned char *rx_buf, + unsigned int *rx_len); + } fn; + + union { + } priv; +}; + +struct iso15693_handle { + unsigned int state; +}; + +enum iso15693_state { + ISO15693_STATE_ERROR, + ISO15693_STATE_NONE, +}; + +#include +extern struct rfid_layer2 rfid_layer2_iso15693; + +#endif /* _ISO15693_H */ diff --git a/include/librfid/rfid_protocol.h b/include/librfid/rfid_protocol.h new file mode 100644 index 0000000..65bda4c --- /dev/null +++ b/include/librfid/rfid_protocol.h @@ -0,0 +1,88 @@ +#ifndef _RFID_PROTOCOL_H +#define _RFID_PROTOCOL_H + +#include + +struct rfid_protocol_handle; + +struct rfid_protocol_handle * +rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id); +int rfid_protocol_open(struct rfid_protocol_handle *ph); +int rfid_protocol_transcieve(struct rfid_protocol_handle *ph, + const unsigned char *tx_buf, unsigned int tx_len, + unsigned char *rx_buf, unsigned int *rx_len, + unsigned int timeout, unsigned int flags); +int +rfid_protocol_read(struct rfid_protocol_handle *ph, + unsigned int page, + unsigned char *rx_data, + unsigned int *rx_len); + +int +rfid_protocol_write(struct rfid_protocol_handle *ph, + unsigned int page, + unsigned char *tx_data, + unsigned int tx_len); + +int rfid_protocol_fini(struct rfid_protocol_handle *ph); +int rfid_protocol_close(struct rfid_protocol_handle *ph); + +enum rfid_protocol_id { + RFID_PROTOCOL_UNKNOWN, + RFID_PROTOCOL_TCL, + RFID_PROTOCOL_MIFARE_UL, + RFID_PROTOCOL_MIFARE_CLASSIC, +}; + + +#ifdef __LIBRFID__ + +struct rfid_protocol { + struct rfid_protocol *next; + unsigned int id; + char *name; + struct { + struct rfid_protocol_handle *(*init)(struct rfid_layer2_handle *l2h); + int (*open)(struct rfid_protocol_handle *ph); + int (*close)(struct rfid_protocol_handle *ph); + int (*fini)(struct rfid_protocol_handle *ph); + /* transcieve for session based transport protocols */ + int (*transcieve)(struct rfid_protocol_handle *ph, + const unsigned char *tx_buf, + unsigned int tx_len, + unsigned char *rx_buf, + unsigned int *rx_len, + unsigned int timeout, + unsigned int flags); + /* read/write for synchronous memory cards */ + int (*read)(struct rfid_protocol_handle *ph, + unsigned int page, + unsigned char *rx_data, + unsigned int *rx_len); + int (*write)(struct rfid_protocol_handle *ph, + unsigned int page, + unsigned char *tx_data, + unsigned int tx_len); + } fn; +}; + +int rfid_protocol_register(struct rfid_protocol *p); + +#include +#include +#include + +struct rfid_protocol_handle { + struct rfid_layer2_handle *l2h; + struct rfid_protocol *proto; + union { + struct tcl_handle tcl; + } priv; /* priv has to be last, since + * it could contain additional + * private data over the end of + * sizeof(priv). */ +}; + +#endif /* __LIBRFID__ */ + +#endif /* _RFID_PROTOCOL_H */ diff --git a/include/librfid/rfid_protocol_mifare_classic.h b/include/librfid/rfid_protocol_mifare_classic.h new file mode 100644 index 0000000..e6b2400 --- /dev/null +++ b/include/librfid/rfid_protocol_mifare_classic.h @@ -0,0 +1,28 @@ +#ifndef _MIFARE_CLASSIC_H + +#define MIFARE_CL_KEYA_DEFAULT "\xa0\xa1\xa2\xa3\xa4\xa5" +#define MIFARE_CL_KEYB_DEFAULT "\xb0\xb1\xb2\xb3\xb4\xb5" + +#define MIFARE_CL_KEYA_DEFAULT_INFINEON "\xff\xff\xff\xff\xff\xff" +#define MIFARE_CL_KEYB_DEFAULT_INFINEON MIFARE_CL_KEYA_DEFAULT_INFINEON + +#define MIFARE_CL_PAGE_MAX 0xff + +#define RFID_CMD_MIFARE_AUTH1A 0x60 +#define RFID_CMD_MIFARE_AUTH1B 0x61 + +#ifdef __LIBRFID__ + +extern struct rfid_protocol rfid_protocol_mfcl; + + +#define MIFARE_CL_CMD_WRITE16 0xA0 +#define MIFARE_CL_CMD_READ 0x30 + +#define MIFARE_CL_RESP_ACK 0x0a +#define MIFARE_CL_RESP_NAK 0x00 + + +#endif /* __LIBRFID__ */ + +#endif /* _MIFARE_CLASSIC_H */ diff --git a/include/librfid/rfid_protocol_mifare_ul.h b/include/librfid/rfid_protocol_mifare_ul.h new file mode 100644 index 0000000..cc93b6b --- /dev/null +++ b/include/librfid/rfid_protocol_mifare_ul.h @@ -0,0 +1,24 @@ +#ifndef _RFID_PROTOCOL_MFUL_H +#define _RFID_PROTOCOL_MFUL_H + +int rfid_mful_lock_page(struct rfid_protocol_handle *ph, unsigned int page); +int rfid_mful_lock_otp(struct rfid_protocol_handle *ph); + +#define MIFARE_UL_PAGE_MAX 15 + +#ifdef __LIBRFID__ + +#define MIFARE_UL_CMD_WRITE 0xA2 +#define MIFARE_UL_CMD_READ 0x30 + +#define MIFARE_UL_RESP_ACK 0x0a +#define MIFARE_UL_RESP_NAK 0x00 + +#define MIFARE_UL_PAGE_LOCK 2 +#define MIFARE_UL_PAGE_OTP 3 + +extern struct rfid_protocol rfid_protocol_mful; + +#endif /* __LIBRFID__ */ + +#endif diff --git a/include/librfid/rfid_protocol_tcl.h b/include/librfid/rfid_protocol_tcl.h new file mode 100644 index 0000000..f754ad9 --- /dev/null +++ b/include/librfid/rfid_protocol_tcl.h @@ -0,0 +1,70 @@ +#ifndef _RFID_PROTOCOL_TCL_H +#define _RFID_PROTOCOL_TCL_H + +#ifdef __LIBRFID__ + +enum tcl_transport_rate { + TCL_RATE_106 = 0x01, + TCL_RATE_212 = 0x02, + TCL_RATE_424 = 0x04, + TCL_RATE_848 = 0x08, +}; + +enum tcl_transport_transcieve_flags { + TCL_TRANSP_F_TX_CRC = 0x01, /* transport adds TX CRC */ + TCL_TRANSP_F_RX_CRC = 0x02, +}; + +struct tcl_handle { + /* derived from ats */ + unsigned char *historical_bytes; /* points into ats */ + unsigned int historical_len; + + unsigned int fsc; /* max frame size accepted by card */ + unsigned int fsd; /* max frame size accepted by reader */ + unsigned int fwt; /* frame waiting time (in usec)*/ + unsigned char ta; /* divisor information */ + unsigned char sfgt; /* start-up frame guard time (in usec) */ + + /* otherwise determined */ + unsigned int cid; /* Card ID */ + unsigned int nad; /* Node Address */ + + unsigned int flags; + unsigned int state; /* protocol state */ + + unsigned int toggle; /* send toggle with next frame */ + + unsigned int ats_len; + unsigned char ats[0]; +}; + +enum tcl_handle_flags { + TCL_HANDLE_F_NAD_SUPPORTED = 0x0001, + TCL_HANDLE_F_CID_SUPPORTED = 0x0002, + TCL_HANDLE_F_NAD_USED = 0x0010, + TCL_HANDLE_F_CID_USED = 0x0020, +}; + + +enum tcl_pcb_bits { + TCL_PCB_CID_FOLLOWING = 0x08, + TCL_PCB_NAD_FOLLOWING = 0x04, +}; + +enum tcl_pcd_state { + TCL_STATE_NONE = 0x00, + TCL_STATE_INITIAL, + TCL_STATE_RATS_SENT, /* waiting for ATS */ + TCL_STATE_ATS_RCVD, /* ATS received */ + TCL_STATE_PPS_SENT, /* waiting for PPS response */ + TCL_STATE_ESTABLISHED, /* xchg transparent data */ + TCL_STATE_DESELECT_SENT, /* waiting for DESELECT response */ + TCL_STATE_DESELECTED, /* card deselected or HLTA'd */ +}; + +struct rfid_protocol rfid_protocol_tcl; + +#endif /* __LIBRFID__ */ + +#endif diff --git a/include/librfid/rfid_reader.h b/include/librfid/rfid_reader.h new file mode 100644 index 0000000..3581cc1 --- /dev/null +++ b/include/librfid/rfid_reader.h @@ -0,0 +1,67 @@ +#ifndef _RFID_READER_H +#define _RFID_READER_H + +#include +#include + +struct rfid_reader_handle; + +struct rfid_reader { + char *name; + unsigned int id; + int (*transcieve)(struct rfid_reader_handle *h, + enum rfid_frametype frametype, + const unsigned char *tx_buf, unsigned int tx_len, + unsigned char *rx_buf, unsigned int *rx_len, + u_int64_t timeout, unsigned int flags); + struct rfid_reader_handle * (*open)(void *data); + void (*close)(struct rfid_reader_handle *h); + + struct rfid_14443a_reader { + int (*init)(struct rfid_reader_handle *h); + int (*transcieve_sf)(struct rfid_reader_handle *h, + unsigned char cmd, + struct iso14443a_atqa *atqa); + int (*transcieve_acf)(struct rfid_reader_handle *h, + struct iso14443a_anticol_cmd *cmd, + unsigned int *bit_of_col); + int (*set_speed)(struct rfid_reader_handle *h, + unsigned int tx, + unsigned int speed); + unsigned int speed; + } iso14443a; + struct rfid_14443b_reader { + int (*init)(struct rfid_reader_handle *rh); + unsigned int speed; + } iso14443b; + 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; +}; + +enum rfid_reader_id { + RFID_READER_CM5121, + RFID_READER_PEGODA, +}; + +struct rfid_reader_handle { + struct rfid_asic_handle *ah; + + union { + + } priv; + struct rfid_reader *reader; +}; + + +extern struct rfid_reader_handle * +rfid_reader_open(void *data, unsigned int id); + +extern void rfid_reader_close(struct rfid_reader_handle *rh); +#endif diff --git a/include/librfid/rfid_reader_cm5121.h b/include/librfid/rfid_reader_cm5121.h new file mode 100644 index 0000000..8d9a312 --- /dev/null +++ b/include/librfid/rfid_reader_cm5121.h @@ -0,0 +1,21 @@ +#ifndef _RFID_READER_CM5121_H +#define _RFID_READER_CM5121_H + +#define CM5121_CW_CONDUCTANCE 0x3f +#define CM5121_MOD_CONDUCTANCE 0x3f +#define CM5121_14443A_BITPHASE 0xa9 +#define CM5121_14443A_THRESHOLD 0xff + +#define CM5121_14443B_BITPHASE 0xad +#define CM5121_14443B_THRESHOLD 0xff + + +extern int +PC_to_RDR_Escape(void *handle, + const unsigned char *tx_buf, unsigned int tx_len, + unsigned char *rx_buf, unsigned int *rx_len); + +extern struct rfid_reader rfid_reader_cm5121; +// extern struct rfid_asic_transport cm5121_ccid; + +#endif diff --git a/include/rfid/Makefile.am b/include/rfid/Makefile.am deleted file mode 100644 index 59ce8cb..0000000 --- a/include/rfid/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ - -pkginclude_HEADERS = rfid.h rfid_asic.h rfid_asic_rc632.h \ - rfid_layer2.h rfid_layer2_iso14443a.h \ - rfid_layer2_iso14443b.h rfid_layer2_iso15693.h \ - rfid_protocol.h rfid_protocol_tcl.h \ - rfid_protocol_mifare_ul.h \ - rfid_protocol_mifare_classic.h \ - rfid_reader.h \ - rfid_reader_cm5121.h - diff --git a/include/rfid/rfid.h b/include/rfid/rfid.h deleted file mode 100644 index 6717ef8..0000000 --- a/include/rfid/rfid.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _RFID_H -#define _RFID_H - -#include - -#ifdef __LIBRFID__ - -enum rfid_frametype { - RFID_14443A_FRAME_REGULAR, - RFID_14443B_FRAME_REGULAR, - RFID_MIFARE_FRAME, -}; - -#define DEBUGP(x, args ...) fprintf(stderr, "%s(%d):%s: " x, __FILE__, __LINE__, __FUNCTION__, ## args) -#define DEBUGPC(x, args ...) fprintf(stderr, x, ## args) -extern const char *rfid_hexdump(const void *data, unsigned int len); - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -#endif /* __LIBRFID__ */ - -int rfid_init(); - -#endif /* _RFID_H */ diff --git a/include/rfid/rfid_asic.h b/include/rfid/rfid_asic.h deleted file mode 100644 index 6511615..0000000 --- a/include/rfid/rfid_asic.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _RFID_ASIC_H -#define _RFID_ASIC_H - -enum rfid_frametype; - -#include - -struct rfid_asic_transport { - char *name; - union { - struct rfid_asic_rc632_transport rc632; - } priv; -}; - -struct rfid_asic_transport_handle { - void *data; /* handle to stuff like even lower layers */ - - struct rfid_asic_transport *rat; -}; - - -struct rfid_asic_handle { - struct rfid_asic_transport_handle *rath; - unsigned int fc; - unsigned int mtu; - unsigned int mru; - - union { - struct rfid_asic_rc632_handle rc632; - //struct rfid_asic_rc531_handle rc531; - } priv; - struct rfid_asic *asic; -}; - - -struct rfid_asic { - char *name; - unsigned int fc; /* carrier frequency */ - union { - struct rfid_asic_rc632 rc632; - //struct rfid_asic_rc531 rc531; - } priv; -}; - -#endif /* _RFID_ASIC_H */ diff --git a/include/rfid/rfid_asic_rc632.h b/include/rfid/rfid_asic_rc632.h deleted file mode 100644 index e156814..0000000 --- a/include/rfid/rfid_asic_rc632.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef _RFID_ASIC_RC632_H -#define _RFID_ASIC_RC632_H - -struct rfid_asic_transport_handle; - -#include -#include - -struct rfid_asic_rc632_transport { - struct { - int (*reg_write)(struct rfid_asic_transport_handle *rath, - u_int8_t reg, - u_int8_t value); - int (*reg_read)(struct rfid_asic_transport_handle *rath, - u_int8_t reg, - u_int8_t *value); - int (*fifo_write)(struct rfid_asic_transport_handle *rath, - u_int8_t len, - const u_int8_t *buf, - u_int8_t flags); - int (*fifo_read)(struct rfid_asic_transport_handle *rath, - u_int8_t len, - u_int8_t *buf); - } fn; -}; - -struct rfid_asic_handle; - -struct iso14443a_atqa; -struct iso14443a_anticol_cmd; - -struct rfid_asic_rc632 { - struct { - int (*power_up)(struct rfid_asic_handle *h); - int (*power_down)(struct rfid_asic_handle *h); - 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, - enum rfid_frametype, - const u_int32_t *tx_buf, - unsigned int tx_len, - 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, - u_int32_t cmd, - struct iso14443a_atqa *atqa); - int (*transcieve_acf)(struct rfid_asic_handle *h, - struct iso14443a_anticol_cmd *cmd, - unsigned int *bit_of_col); - int (*set_speed)(struct rfid_asic_handle *h, - unsigned int tx, - unsigned int speed); - } iso14443a; - struct { - int (*init)(struct rfid_asic_handle *h); - } iso14443b; - struct { - int (*init)(struct rfid_asic_handle *h); - } iso15693; - struct { - int (*setkey)(struct rfid_asic_handle *h, - const 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; -}; - -struct rc632_transport_handle { -}; - -/* A handle to a specific RC632 chip */ -struct rfid_asic_rc632_handle { - struct rc632_transport_handle th; -}; - -#if 0 -int -rc632_reg_write(struct rfid_asic_handle *handle, - u_int8_t reg, - u_int8_t val); - -int -rc632_reg_read(struct rfid_asic_handle *handle, - u_int8_t reg, - u_int8_t *val); -int -rc632_fifo_write(struct rfid_asic_handle *handle, - u_int8_t len, - const u_int32_t *buf, - u_int8_t flags); - -int -rc632_fifo_read(struct rfid_asic_handle *handle, - u_int8_t len, - u_int8_t *buf); - -int -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, u_int32_t reg, - u_int32_t val); - - -int -rc632_turn_on_rf(struct rfid_asic_handle *handle); - - -int -rc632_turn_off_rf(struct rfid_asic_handle *handle); - -int -rc632_power_up(struct rfid_asic_handle *handle); - -int -rc632_power_down(struct rfid_asic_handle *handle); - - -int -rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time); - -int -rc632_transmit(struct rfid_asic_handle *handle, - const u_int32_t *buf, - u_int32_t len, - u_int64_t timeout); - -int -rc632_transcieve(struct rfid_asic_handle *handle, - 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); - -int -rc632_read_eeprom(struct rfid_asic_handle *handle); - - -int -rc632_calc_crc16_from(struct rfid_asic_handle *handle); - -int -rc632_register_dump(struct rfid_asic_handle *handle, u_int32_t *buf); - - -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 deleted file mode 100644 index 54c3c46..0000000 --- a/include/rfid/rfid_layer2.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef _RFID_LAYER2_H -#define _RFID_LAYER2_H - -#include -#include - -struct rfid_layer2_handle; -struct rfid_reader_handle; - -enum rfid_layer2_id { - RFID_LAYER2_NONE, - RFID_LAYER2_ISO14443A, - RFID_LAYER2_ISO14443B, - RFID_LAYER2_ISO15693, -}; - -struct rfid_layer2_handle *rfid_layer2_init(struct rfid_reader_handle *rh, - unsigned int id); -int rfid_layer2_open(struct rfid_layer2_handle *l2h); -int rfid_layer2_transcieve(struct rfid_layer2_handle *l2h, - enum rfid_frametype frametype, - const unsigned char *tx_buf, unsigned int tx_len, - unsigned char *rx_buf, unsigned int *rx_len, - u_int64_t timeout, unsigned int flags); -int rfid_layer2_close(struct rfid_layer2_handle *l2h); -int rfid_layer2_fini(struct rfid_layer2_handle *l2h); -int rfid_layer2_getopt(struct rfid_layer2_handle *ph, int optname, - void *optval, unsigned int *optlen); -int rfid_layer2_setopt(struct rfid_layer2_handle *ph, int optname, - const void *optval, unsigned int optlen); - -#ifdef __LIBRFID__ - -#include -#include -#include - -struct rfid_layer2 { - unsigned int id; - char *name; - - struct { - struct rfid_layer2_handle *(*init)(struct rfid_reader_handle *h); - int (*open)(struct rfid_layer2_handle *h); - int (*transcieve)(struct rfid_layer2_handle *h, - enum rfid_frametype frametype, - const unsigned char *tx_buf, - unsigned int tx_len, unsigned char *rx_buf, - unsigned int *rx_len, u_int64_t timeout, - unsigned int flags); - int (*close)(struct rfid_layer2_handle *h); - int (*fini)(struct rfid_layer2_handle *h); - int (*getopt)(struct rfid_layer2_handle *h, - int optname, void *optval, unsigned int *optlen); - int (*setopt)(struct rfid_layer2_handle *h, - int optname, const void *optval, - unsigned int optlen); - } fn; - struct rfid_layer2 *next; -}; - -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; - struct iso15693_handle iso15693; - } priv; - struct rfid_layer2 *l2; -}; - -#endif /* __LIBRFID__ */ - -#endif diff --git a/include/rfid/rfid_layer2_iso14443a.h b/include/rfid/rfid_layer2_iso14443a.h deleted file mode 100644 index fc79bca..0000000 --- a/include/rfid/rfid_layer2_iso14443a.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _RFID_ISO14443A_H -#define _RFID_ISO14443A_H - -enum rfid_14443a_opt { - RFID_OPT_14443A_SPEED_RX = 0x00000001, - RFID_OPT_14443A_SPEED_TX = 0x00000002, -}; - -enum rfid_14443_opt_speed { - RFID_14443A_SPEED_106K = 0x01, - RFID_14443A_SPEED_212K = 0x02, - RFID_14443A_SPEED_424K = 0x04, - RFID_14443A_SPEED_848K = 0x08, -}; - -#ifdef __LIBRFID__ - -#include - -/* protocol definitions */ - -/* ISO 14443-3, Chapter 6.3.1 */ -enum iso14443a_sf_cmd { - ISO14443A_SF_CMD_REQA = 0x26, - ISO14443A_SF_CMD_WUPA = 0x52, - ISO14443A_SF_CMD_OPT_TIMESLOT = 0x35, /* Annex C */ - /* 40 to 4f and 78 to 7f: proprietary */ -}; - -struct iso14443a_atqa { - u_int8_t bf_anticol:5, - rfu1:1, - uid_size:2; - u_int8_t proprietary:4, - rfu2:4; -}; - -#define ISO14443A_HLTA 0x5000 - -/* ISO 14443-3, Chapter 6.3.2 */ -struct iso14443a_anticol_cmd { - unsigned char sel_code; - unsigned char nvb; - unsigned char uid_bits[5]; -}; - -enum iso14443a_anticol_sel_code { - ISO14443A_AC_SEL_CODE_CL1 = 0x93, - ISO14443A_AC_SEL_CODE_CL2 = 0x95, - ISO14443A_AC_SEL_CODE_CL3 = 0x97, -}; - -#define ISO14443A_BITOFCOL_NONE 0xffffffff - -struct iso14443a_handle { - unsigned int state; - unsigned int level; - unsigned int tcl_capable; -}; - -enum iso14443a_level { - ISO14443A_LEVEL_NONE, - ISO14443A_LEVEL_CL1, - ISO14443A_LEVEL_CL2, - ISO14443A_LEVEL_CL3, -}; - -enum iso14443a_state { - ISO14443A_STATE_ERROR, - ISO14443A_STATE_NONE, - ISO14443A_STATE_REQA_SENT, - ISO14443A_STATE_ATQA_RCVD, - ISO14443A_STATE_NO_BITFRAME_ANTICOL, - ISO14443A_STATE_ANTICOL_RUNNING, - ISO14443A_STATE_SELECTED, -}; - -#include -struct rfid_layer2 rfid_layer2_iso14443a; - -#endif /* __LIBRFID__ */ - - -#endif /* _ISO14443A_H */ diff --git a/include/rfid/rfid_layer2_iso14443b.h b/include/rfid/rfid_layer2_iso14443b.h deleted file mode 100644 index 2bf8255..0000000 --- a/include/rfid/rfid_layer2_iso14443b.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef _RFID_LAYER2_ISO14443B_H -#define _RFID_LAYER2_ISO14443B_H - -#ifdef __LIBRFID__ - -struct iso14443b_atqb { - unsigned char fifty; - unsigned char pupi[4]; - unsigned char app_data[4]; - struct { - unsigned char bit_rate_capability; - unsigned char protocol_type:4, - max_frame_size:4; - unsigned char fo:2, - adc:2, - fwi:4; - } protocol_info; -}; - -struct iso14443b_attrib_hdr { - unsigned char one_d; - unsigned char identifier[4]; - struct { - unsigned char rfu:2, - sof:1, - eof:1, - min_tr1:2, - min_tr0:2; - } param1; - struct { - unsigned char fsdi:4, - spd_out:2, - spd_in:2; - } param2; - struct { - unsigned char protocol_type:4, - rfu:4; - } param3; - struct { - unsigned char cid:4, - rfu:4; - } param4; -}; - -struct iso14443b_handle { - unsigned int tcl_capable; /* do we support T=CL */ - - unsigned int cid; /* Card ID */ - - unsigned int fsc; /* max. frame size card */ - unsigned int fsd; /* max. frame size reader */ - - unsigned int fwt; /* frame waiting time (in usec) */ - - unsigned int mbl; /* maximum buffer length */ - - unsigned int tr0; /* pcd-eof to picc-subcarrier-on */ - unsigned int tr1; /* picc-subcarrier-on to picc-sof */ - - unsigned int flags; - unsigned int state; -}; - -enum { - ISO14443B_CID_SUPPORTED = 0x01, - ISO14443B_NAD_SUPPORTED = 0x02, -}; - -enum { - ISO14443B_STATE_ERROR, - ISO14443B_STATE_NONE, - ISO14443B_STATE_REQB_SENT, - ISO14443B_STATE_ATQB_RCVD, - ISO14443B_STATE_ATTRIB_SENT, - ISO14443B_STATE_SELECTED, - ISO14443B_STATE_HLTB_SENT, - ISO14443B_STATE_HALTED, -}; - -#include -struct rfid_layer2 rfid_layer2_iso14443b; - -#endif /* __LIBRFID__ */ - -#endif diff --git a/include/rfid/rfid_layer2_iso15693.h b/include/rfid/rfid_layer2_iso15693.h deleted file mode 100644 index 6ca1a7b..0000000 --- a/include/rfid/rfid_layer2_iso15693.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _RFID_ISO15693_H -#define _RFID_ISO15693_H - -#include - -/* -07h = TagIt -04h = I.CODE -05h = Infineon -02h = ST -*/ - -/* protocol definitions */ - -struct iso15693_handle; - -struct iso15693_transport { - unsigned char *name; - - struct { - int (*init)(struct iso15693_handle *handle); - int (*fini)(struct iso15693_handle *handle); - -#if 0 - int (*transcieve_sf)(struct iso14443a_handle *handle, - unsigned char cmd, - struct iso14443a_atqa *atqa); - int (*transcieve_acf)(struct iso14443a_handle *handle, - struct iso14443a_anticol_cmd *acf, - unsigned int *bit_of_col); -#endif - int (*transcieve)(struct iso15693_handle *handle, - const unsigned char *tx_buf, - unsigned int tx_len, - unsigned char *rx_buf, - unsigned int *rx_len); - } fn; - - union { - } priv; -}; - -struct iso15693_handle { - unsigned int state; -}; - -enum iso15693_state { - ISO15693_STATE_ERROR, - ISO15693_STATE_NONE, -}; - -#include -extern struct rfid_layer2 rfid_layer2_iso15693; - -#endif /* _ISO15693_H */ diff --git a/include/rfid/rfid_protocol.h b/include/rfid/rfid_protocol.h deleted file mode 100644 index bd9570f..0000000 --- a/include/rfid/rfid_protocol.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef _RFID_PROTOCOL_H -#define _RFID_PROTOCOL_H - -#include - -struct rfid_protocol_handle; - -struct rfid_protocol_handle * -rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id); -int rfid_protocol_open(struct rfid_protocol_handle *ph); -int rfid_protocol_transcieve(struct rfid_protocol_handle *ph, - const unsigned char *tx_buf, unsigned int tx_len, - unsigned char *rx_buf, unsigned int *rx_len, - unsigned int timeout, unsigned int flags); -int -rfid_protocol_read(struct rfid_protocol_handle *ph, - unsigned int page, - unsigned char *rx_data, - unsigned int *rx_len); - -int -rfid_protocol_write(struct rfid_protocol_handle *ph, - unsigned int page, - unsigned char *tx_data, - unsigned int tx_len); - -int rfid_protocol_fini(struct rfid_protocol_handle *ph); -int rfid_protocol_close(struct rfid_protocol_handle *ph); - -enum rfid_protocol_id { - RFID_PROTOCOL_UNKNOWN, - RFID_PROTOCOL_TCL, - RFID_PROTOCOL_MIFARE_UL, - RFID_PROTOCOL_MIFARE_CLASSIC, -}; - - -#ifdef __LIBRFID__ - -struct rfid_protocol { - struct rfid_protocol *next; - unsigned int id; - char *name; - struct { - struct rfid_protocol_handle *(*init)(struct rfid_layer2_handle *l2h); - int (*open)(struct rfid_protocol_handle *ph); - int (*close)(struct rfid_protocol_handle *ph); - int (*fini)(struct rfid_protocol_handle *ph); - /* transcieve for session based transport protocols */ - int (*transcieve)(struct rfid_protocol_handle *ph, - const unsigned char *tx_buf, - unsigned int tx_len, - unsigned char *rx_buf, - unsigned int *rx_len, - unsigned int timeout, - unsigned int flags); - /* read/write for synchronous memory cards */ - int (*read)(struct rfid_protocol_handle *ph, - unsigned int page, - unsigned char *rx_data, - unsigned int *rx_len); - int (*write)(struct rfid_protocol_handle *ph, - unsigned int page, - unsigned char *tx_data, - unsigned int tx_len); - } fn; -}; - -int rfid_protocol_register(struct rfid_protocol *p); - -#include -#include -#include - -struct rfid_protocol_handle { - struct rfid_layer2_handle *l2h; - struct rfid_protocol *proto; - union { - struct tcl_handle tcl; - } priv; /* priv has to be last, since - * it could contain additional - * private data over the end of - * sizeof(priv). */ -}; - -#endif /* __LIBRFID__ */ - -#endif /* _RFID_PROTOCOL_H */ diff --git a/include/rfid/rfid_protocol_mifare_classic.h b/include/rfid/rfid_protocol_mifare_classic.h deleted file mode 100644 index e6b2400..0000000 --- a/include/rfid/rfid_protocol_mifare_classic.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _MIFARE_CLASSIC_H - -#define MIFARE_CL_KEYA_DEFAULT "\xa0\xa1\xa2\xa3\xa4\xa5" -#define MIFARE_CL_KEYB_DEFAULT "\xb0\xb1\xb2\xb3\xb4\xb5" - -#define MIFARE_CL_KEYA_DEFAULT_INFINEON "\xff\xff\xff\xff\xff\xff" -#define MIFARE_CL_KEYB_DEFAULT_INFINEON MIFARE_CL_KEYA_DEFAULT_INFINEON - -#define MIFARE_CL_PAGE_MAX 0xff - -#define RFID_CMD_MIFARE_AUTH1A 0x60 -#define RFID_CMD_MIFARE_AUTH1B 0x61 - -#ifdef __LIBRFID__ - -extern struct rfid_protocol rfid_protocol_mfcl; - - -#define MIFARE_CL_CMD_WRITE16 0xA0 -#define MIFARE_CL_CMD_READ 0x30 - -#define MIFARE_CL_RESP_ACK 0x0a -#define MIFARE_CL_RESP_NAK 0x00 - - -#endif /* __LIBRFID__ */ - -#endif /* _MIFARE_CLASSIC_H */ diff --git a/include/rfid/rfid_protocol_mifare_ul.h b/include/rfid/rfid_protocol_mifare_ul.h deleted file mode 100644 index cc93b6b..0000000 --- a/include/rfid/rfid_protocol_mifare_ul.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _RFID_PROTOCOL_MFUL_H -#define _RFID_PROTOCOL_MFUL_H - -int rfid_mful_lock_page(struct rfid_protocol_handle *ph, unsigned int page); -int rfid_mful_lock_otp(struct rfid_protocol_handle *ph); - -#define MIFARE_UL_PAGE_MAX 15 - -#ifdef __LIBRFID__ - -#define MIFARE_UL_CMD_WRITE 0xA2 -#define MIFARE_UL_CMD_READ 0x30 - -#define MIFARE_UL_RESP_ACK 0x0a -#define MIFARE_UL_RESP_NAK 0x00 - -#define MIFARE_UL_PAGE_LOCK 2 -#define MIFARE_UL_PAGE_OTP 3 - -extern struct rfid_protocol rfid_protocol_mful; - -#endif /* __LIBRFID__ */ - -#endif diff --git a/include/rfid/rfid_protocol_tcl.h b/include/rfid/rfid_protocol_tcl.h deleted file mode 100644 index f754ad9..0000000 --- a/include/rfid/rfid_protocol_tcl.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _RFID_PROTOCOL_TCL_H -#define _RFID_PROTOCOL_TCL_H - -#ifdef __LIBRFID__ - -enum tcl_transport_rate { - TCL_RATE_106 = 0x01, - TCL_RATE_212 = 0x02, - TCL_RATE_424 = 0x04, - TCL_RATE_848 = 0x08, -}; - -enum tcl_transport_transcieve_flags { - TCL_TRANSP_F_TX_CRC = 0x01, /* transport adds TX CRC */ - TCL_TRANSP_F_RX_CRC = 0x02, -}; - -struct tcl_handle { - /* derived from ats */ - unsigned char *historical_bytes; /* points into ats */ - unsigned int historical_len; - - unsigned int fsc; /* max frame size accepted by card */ - unsigned int fsd; /* max frame size accepted by reader */ - unsigned int fwt; /* frame waiting time (in usec)*/ - unsigned char ta; /* divisor information */ - unsigned char sfgt; /* start-up frame guard time (in usec) */ - - /* otherwise determined */ - unsigned int cid; /* Card ID */ - unsigned int nad; /* Node Address */ - - unsigned int flags; - unsigned int state; /* protocol state */ - - unsigned int toggle; /* send toggle with next frame */ - - unsigned int ats_len; - unsigned char ats[0]; -}; - -enum tcl_handle_flags { - TCL_HANDLE_F_NAD_SUPPORTED = 0x0001, - TCL_HANDLE_F_CID_SUPPORTED = 0x0002, - TCL_HANDLE_F_NAD_USED = 0x0010, - TCL_HANDLE_F_CID_USED = 0x0020, -}; - - -enum tcl_pcb_bits { - TCL_PCB_CID_FOLLOWING = 0x08, - TCL_PCB_NAD_FOLLOWING = 0x04, -}; - -enum tcl_pcd_state { - TCL_STATE_NONE = 0x00, - TCL_STATE_INITIAL, - TCL_STATE_RATS_SENT, /* waiting for ATS */ - TCL_STATE_ATS_RCVD, /* ATS received */ - TCL_STATE_PPS_SENT, /* waiting for PPS response */ - TCL_STATE_ESTABLISHED, /* xchg transparent data */ - TCL_STATE_DESELECT_SENT, /* waiting for DESELECT response */ - TCL_STATE_DESELECTED, /* card deselected or HLTA'd */ -}; - -struct rfid_protocol rfid_protocol_tcl; - -#endif /* __LIBRFID__ */ - -#endif diff --git a/include/rfid/rfid_reader.h b/include/rfid/rfid_reader.h deleted file mode 100644 index 78d07e4..0000000 --- a/include/rfid/rfid_reader.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _RFID_READER_H -#define _RFID_READER_H - -#include -#include - -struct rfid_reader_handle; - -struct rfid_reader { - char *name; - unsigned int id; - int (*transcieve)(struct rfid_reader_handle *h, - enum rfid_frametype frametype, - const unsigned char *tx_buf, unsigned int tx_len, - unsigned char *rx_buf, unsigned int *rx_len, - u_int64_t timeout, unsigned int flags); - struct rfid_reader_handle * (*open)(void *data); - void (*close)(struct rfid_reader_handle *h); - - struct rfid_14443a_reader { - int (*init)(struct rfid_reader_handle *h); - int (*transcieve_sf)(struct rfid_reader_handle *h, - unsigned char cmd, - struct iso14443a_atqa *atqa); - int (*transcieve_acf)(struct rfid_reader_handle *h, - struct iso14443a_anticol_cmd *cmd, - unsigned int *bit_of_col); - int (*set_speed)(struct rfid_reader_handle *h, - unsigned int tx, - unsigned int speed); - unsigned int speed; - } iso14443a; - struct rfid_14443b_reader { - int (*init)(struct rfid_reader_handle *rh); - unsigned int speed; - } iso14443b; - 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; -}; - -enum rfid_reader_id { - RFID_READER_CM5121, - RFID_READER_PEGODA, -}; - -struct rfid_reader_handle { - struct rfid_asic_handle *ah; - - union { - - } priv; - struct rfid_reader *reader; -}; - - -extern struct rfid_reader_handle * -rfid_reader_open(void *data, unsigned int id); - -extern void rfid_reader_close(struct rfid_reader_handle *rh); -#endif diff --git a/include/rfid/rfid_reader_cm5121.h b/include/rfid/rfid_reader_cm5121.h deleted file mode 100644 index 8d9a312..0000000 --- a/include/rfid/rfid_reader_cm5121.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _RFID_READER_CM5121_H -#define _RFID_READER_CM5121_H - -#define CM5121_CW_CONDUCTANCE 0x3f -#define CM5121_MOD_CONDUCTANCE 0x3f -#define CM5121_14443A_BITPHASE 0xa9 -#define CM5121_14443A_THRESHOLD 0xff - -#define CM5121_14443B_BITPHASE 0xad -#define CM5121_14443B_THRESHOLD 0xff - - -extern int -PC_to_RDR_Escape(void *handle, - const unsigned char *tx_buf, unsigned int tx_len, - unsigned char *rx_buf, unsigned int *rx_len); - -extern struct rfid_reader rfid_reader_cm5121; -// extern struct rfid_asic_transport cm5121_ccid; - -#endif -- cgit v1.2.3