shuffle structure elements to cope with atr[0]
[librfid] / include / rfid / rfid_protocol.h
1 #ifndef _RFID_PROTOCOL_H
2 #define _RFID_PROTOCOL_H
3
4 #include <rfid/rfid_layer2.h>
5
6 #include <rfid/rfid_protocol_tcl.h>
7
8 struct rfid_protocol_handle;
9
10 struct rfid_protocol {
11         struct rfid_protocol *next;
12         unsigned int id;
13         char *name;
14         struct {
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                 int (*transcieve)(struct rfid_protocol_handle *ph,
20                                   const unsigned char *tx_buf,
21                                   unsigned int tx_len,
22                                   unsigned char *rx_buf,
23                                   unsigned int *rx_len,
24                                   unsigned int timeout,
25                                   unsigned int flags);
26         } fn;
27 };
28
29 struct rfid_protocol_handle {
30         struct rfid_layer2_handle *l2h;
31         struct rfid_protocol *proto;
32         union {
33                 struct tcl_handle tcl;
34         } priv;                         /* priv has to be last, since
35                                          * it could contain additional
36                                          * private data over the end of
37                                          * sizeof(priv). */
38 };
39
40 struct rfid_protocol_handle *
41 rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id);
42 int rfid_protocol_open(struct rfid_protocol_handle *ph);
43 int rfid_protocol_transcieve(struct rfid_protocol_handle *ph,
44                              const unsigned char *tx_buf, unsigned int tx_len,
45                              unsigned char *rx_buf, unsigned int *rx_len,
46                              unsigned int timeout, unsigned int flags);
47 int rfid_protocol_fini(struct rfid_protocol_handle *ph);
48 int rfid_protocol_close(struct rfid_protocol_handle *ph);
49
50 int rfid_protocol_register(struct rfid_protocol *p);
51
52 enum rfid_protocol_id {
53         RFID_PROTOCOL_UNKNOWN,
54         RFID_PROTOCOL_TCL,
55 };
56 #endif