X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=include%2Flibrfid%2Frfid_reader.h;h=27bcef3ba27a8699db6d39b95dbd052e3aa3315f;hb=967687ffce29d0034a16be9a0babdc91bf3187cd;hp=b41672ffce2b9f1a627f85b6416bed13ad55461e;hpb=467fb40ebe9da53e0963544e0152cca12c8bb4d2;p=librfid diff --git a/include/librfid/rfid_reader.h b/include/librfid/rfid_reader.h index b41672f..27bcef3 100644 --- a/include/librfid/rfid_reader.h +++ b/include/librfid/rfid_reader.h @@ -3,25 +3,50 @@ #include #include +#include struct rfid_reader_handle; +/* 0...0xffff = global options, 0x10000...0x1ffff = private options */ +#define RFID_OPT_RDR_PRIV 0x00010000 +enum rfid_reader_opt { + RFID_OPT_RDR_FW_VERSION = 0x0001, + RFID_OPT_RDR_RF_KILL = 0x0002, +}; + + struct rfid_reader { char *name; unsigned int id; unsigned int l2_supported; unsigned int proto_supported; + int (*reset)(struct rfid_reader_handle *h); + + /* open the reader */ + struct rfid_reader_handle * (*open)(void *data); + + /* Initialize the reader for a given layer 2 */ + int (*init)(struct rfid_reader_handle *h, enum rfid_layer2_id); + + /* completely close the reader */ + void (*close)(struct rfid_reader_handle *h); + + + int (*getopt)(struct rfid_reader_handle *rh, int optname, + void *optval, unsigned int *optlen); + + int (*setopt)(struct rfid_reader_handle *rh, int optname, + const void *optval, unsigned int optlen); + + /* transceive one frame */ int (*transceive)(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 (*transceive_sf)(struct rfid_reader_handle *h, unsigned char cmd, struct iso14443a_atqa *atqa); @@ -34,14 +59,18 @@ struct rfid_reader { 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); + int (*transceive_ac)(struct rfid_reader_handle *h, + const struct iso15693_anticol_cmd *acf, + unsigned int acf_len, + struct iso15693_anticol_resp *resp, + unsigned int *rx_len, char *bit_of_col); } iso15693; struct rfid_mifare_classic_reader { int (*setkey)(struct rfid_reader_handle *h, const unsigned char *key); + int (*setkey_ee)(struct rfid_reader_handle *h, const unsigned int addr); int (*auth)(struct rfid_reader_handle *h, u_int8_t cmd, u_int32_t serno, u_int8_t block); } mifare_classic; @@ -51,6 +80,7 @@ enum rfid_reader_id { RFID_READER_CM5121, RFID_READER_PEGODA, RFID_READER_OPENPCD, + RFID_READER_SPIDEV, }; struct rfid_reader_handle { @@ -59,11 +89,17 @@ struct rfid_reader_handle { union { } priv; - struct rfid_reader *reader; + const 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); + +extern int rfid_reader_getopt(struct rfid_reader_handle *rh, int optname, + void *optval, unsigned int *optlen); +extern int rfid_reader_setopt(struct rfid_reader_handle *rh, int optname, + const void *optval, unsigned int optlen); + #endif