1 #ifndef _RFID_PROTOCOL_H
2 #define _RFID_PROTOCOL_H
4 #include <rfid/rfid_layer2.h>
6 #include <rfid/rfid_protocol_tcl.h>
8 struct rfid_protocol_handle;
10 struct rfid_protocol {
11 struct rfid_protocol *next;
15 struct rfid_protocol_handle *(*init)(struct rfid_layer2_handle *l2h);
16 int (*open)(struct rfid_protocol_handle *ph);
17 int (*close)(struct rfid_protocol_handle *ph);
18 int (*fini)(struct rfid_protocol_handle *ph);
19 /* transcieve for session based transport protocols */
20 int (*transcieve)(struct rfid_protocol_handle *ph,
21 const unsigned char *tx_buf,
23 unsigned char *rx_buf,
27 /* read/write for synchronous memory cards */
28 int (*read)(struct rfid_protocol_handle *ph,
30 unsigned char *rx_data,
31 unsigned int *rx_len);
32 int (*write)(struct rfid_protocol_handle *ph,
34 unsigned char *tx_data,
39 struct rfid_protocol_handle {
40 struct rfid_layer2_handle *l2h;
41 struct rfid_protocol *proto;
43 struct tcl_handle tcl;
44 } priv; /* priv has to be last, since
45 * it could contain additional
46 * private data over the end of
50 struct rfid_protocol_handle *
51 rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id);
52 int rfid_protocol_open(struct rfid_protocol_handle *ph);
53 int rfid_protocol_transcieve(struct rfid_protocol_handle *ph,
54 const unsigned char *tx_buf, unsigned int tx_len,
55 unsigned char *rx_buf, unsigned int *rx_len,
56 unsigned int timeout, unsigned int flags);
58 rfid_protocol_read(struct rfid_protocol_handle *ph,
60 unsigned char *rx_data,
64 rfid_protocol_write(struct rfid_protocol_handle *ph,
66 unsigned char *tx_data,
69 int rfid_protocol_fini(struct rfid_protocol_handle *ph);
70 int rfid_protocol_close(struct rfid_protocol_handle *ph);
72 int rfid_protocol_register(struct rfid_protocol *p);
74 enum rfid_protocol_id {
75 RFID_PROTOCOL_UNKNOWN,
77 RFID_PROTOCOL_MIFARE_UL,