make "frametype" a parameter of transcieve functions
[librfid] / include / rfid / rfid_layer2.h
1 #ifndef _RFID_LAYER2_H
2 #define _RFID_LAYER2_H
3
4 struct rfid_layer2_handle;
5 struct rfid_reader_handle;
6
7 #include <rfid/rfid.h>
8
9 #include <rfid/rfid_layer2_iso14443a.h>
10 #include <rfid/rfid_layer2_iso14443b.h>
11 #include <rfid/rfid_layer2_iso15693.h>
12
13
14 struct rfid_layer2 {
15         unsigned int id;
16         char *name;
17
18         struct {
19                 struct rfid_layer2_handle *(*init)(struct rfid_reader_handle *h);
20                 int (*open)(struct rfid_layer2_handle *h);
21                 int (*transcieve)(struct rfid_layer2_handle *h,
22                                   enum rfid_frametype frametype,
23                                   const unsigned char *tx_buf, 
24                                   unsigned int tx_len, unsigned char *rx_buf, 
25                                   unsigned int *rx_len, u_int64_t timeout,
26                                   unsigned int flags);
27                 int (*close)(struct rfid_layer2_handle *h);
28                 int (*fini)(struct rfid_layer2_handle *h);
29         } fn;
30         struct rfid_layer2 *next;
31 };
32
33 struct rfid_layer2_handle {
34         struct rfid_reader_handle *rh;
35         unsigned char uid[10];  /* triple size 14443a id is 10 bytes */
36         unsigned int uid_len;
37         union {
38                 struct iso14443a_handle iso14443a;
39                 struct iso14443b_handle iso14443b;
40                 struct iso15693_handle iso15693;
41         } priv;
42         struct rfid_layer2 *l2;
43 };
44
45 enum rfid_layer2_id {
46         RFID_LAYER2_NONE,
47         RFID_LAYER2_ISO14443A,
48         RFID_LAYER2_ISO14443B,
49         RFID_LAYER2_ISO15693,
50 };
51
52 struct rfid_layer2_handle *rfid_layer2_init(struct rfid_reader_handle *rh,
53                                             unsigned int id);
54 int rfid_layer2_open(struct rfid_layer2_handle *l2h);
55 int rfid_layer2_transcieve(struct rfid_layer2_handle *l2h,
56                            enum rfid_frametype frametype,
57                            const unsigned char *tx_buf, unsigned int tx_len,
58                            unsigned char *rx_buf, unsigned int *rx_len,
59                            u_int64_t timeout, unsigned int flags);
60 int rfid_layer2_close(struct rfid_layer2_handle *l2h);
61 int rfid_layer2_fini(struct rfid_layer2_handle *l2h);
62
63 #endif