move librfid to new location in repository
[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         union {
32                 struct tcl_handle tcl;
33         } priv;
34         struct rfid_protocol *proto;
35 };
36
37 struct rfid_protocol_handle *
38 rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id);
39 int rfid_protocol_open(struct rfid_protocol_handle *ph);
40 int rfid_protocol_transcieve(struct rfid_protocol_handle *ph,
41                              const unsigned char *tx_buf, unsigned int tx_len,
42                              unsigned char *rx_buf, unsigned int *rx_len,
43                              unsigned int timeout, unsigned int flags);
44 int rfid_protocol_fini(struct rfid_protocol_handle *ph);
45 int rfid_protocol_close(struct rfid_protocol_handle *ph);
46
47 int rfid_protocol_register(struct rfid_protocol *p);
48
49 enum rfid_protocol_id {
50         RFID_PROTOCOL_UNKNOWN,
51         RFID_PROTOCOL_TCL,
52 };
53 #endif