1 #ifndef _RFID_PROTOCOL_H
2 #define _RFID_PROTOCOL_H
4 #include <librfid/rfid_layer2.h>
6 struct rfid_protocol_handle;
8 struct rfid_protocol_handle *
9 rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id);
10 int rfid_protocol_open(struct rfid_protocol_handle *ph);
11 int rfid_protocol_transceive(struct rfid_protocol_handle *ph,
12 const unsigned char *tx_buf, unsigned int tx_len,
13 unsigned char *rx_buf, unsigned int *rx_len,
14 unsigned int timeout, unsigned int flags);
16 rfid_protocol_read(struct rfid_protocol_handle *ph,
18 unsigned char *rx_data,
19 unsigned int *rx_len);
22 rfid_protocol_write(struct rfid_protocol_handle *ph,
24 unsigned char *tx_data,
27 int rfid_protocol_fini(struct rfid_protocol_handle *ph);
28 int rfid_protocol_close(struct rfid_protocol_handle *ph);
30 int rfid_protocol_getopt(struct rfid_protocol_handle *ph, int optname,
31 void *optval, unsigned int *optlen);
33 int rfid_protocol_setopt(struct rfid_protocol_handle *ph, int optname,
34 const void *optval, unsigned int optlen);
36 char *rfid_protocol_name(struct rfid_protocol_handle *ph);
38 enum rfid_protocol_id {
39 RFID_PROTOCOL_UNKNOWN,
41 RFID_PROTOCOL_MIFARE_UL,
42 RFID_PROTOCOL_MIFARE_CLASSIC,
46 enum rfid_protocol_opt {
48 RFID_OPT_PROTO_SIZE = 0x10000001,
53 struct rfid_protocol {
57 struct rfid_protocol_handle *(*init)(struct rfid_layer2_handle *l2h);
58 int (*open)(struct rfid_protocol_handle *ph);
59 int (*close)(struct rfid_protocol_handle *ph);
60 int (*fini)(struct rfid_protocol_handle *ph);
61 /* transceive for session based transport protocols */
62 int (*transceive)(struct rfid_protocol_handle *ph,
63 const unsigned char *tx_buf,
65 unsigned char *rx_buf,
69 /* read/write for synchronous memory cards */
70 int (*read)(struct rfid_protocol_handle *ph,
72 unsigned char *rx_data,
73 unsigned int *rx_len);
74 int (*write)(struct rfid_protocol_handle *ph,
76 unsigned char *tx_data,
78 int (*getopt)(struct rfid_protocol_handle *h,
79 int optname, void *optval, unsigned int *optlen);
80 int (*setopt)(struct rfid_protocol_handle *h,
81 int optname, const void *optval,
86 #include <librfid/rfid_protocol_tcl.h>
87 #include <librfid/rfid_protocol_mifare_ul.h>
88 #include <librfid/rfid_protocol_mifare_classic.h>
90 struct rfid_protocol_handle {
91 struct rfid_layer2_handle *l2h;
92 struct rfid_protocol *proto;
94 struct tcl_handle tcl;
95 } priv; /* priv has to be last, since
96 * it could contain additional
97 * private data over the end of
101 #endif /* __LIBRFID__ */
103 #endif /* _RFID_PROTOCOL_H */