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 char *rfid_protocol_name(struct rfid_protocol_handle *ph);
32 enum rfid_protocol_id {
33 RFID_PROTOCOL_UNKNOWN,
35 RFID_PROTOCOL_MIFARE_UL,
36 RFID_PROTOCOL_MIFARE_CLASSIC,
42 struct rfid_protocol {
43 struct rfid_protocol *next;
47 struct rfid_protocol_handle *(*init)(struct rfid_layer2_handle *l2h);
48 int (*open)(struct rfid_protocol_handle *ph);
49 int (*close)(struct rfid_protocol_handle *ph);
50 int (*fini)(struct rfid_protocol_handle *ph);
51 /* transceive for session based transport protocols */
52 int (*transceive)(struct rfid_protocol_handle *ph,
53 const unsigned char *tx_buf,
55 unsigned char *rx_buf,
59 /* read/write for synchronous memory cards */
60 int (*read)(struct rfid_protocol_handle *ph,
62 unsigned char *rx_data,
63 unsigned int *rx_len);
64 int (*write)(struct rfid_protocol_handle *ph,
66 unsigned char *tx_data,
71 #include <librfid/rfid_protocol_tcl.h>
72 #include <librfid/rfid_protocol_mifare_ul.h>
73 #include <librfid/rfid_protocol_mifare_classic.h>
75 struct rfid_protocol_handle {
76 struct rfid_layer2_handle *l2h;
77 struct rfid_protocol *proto;
79 struct tcl_handle tcl;
80 } priv; /* priv has to be last, since
81 * it could contain additional
82 * private data over the end of
86 #endif /* __LIBRFID__ */
88 #endif /* _RFID_PROTOCOL_H */