summaryrefslogtreecommitdiff
path: root/include/rfid/rfid_protocol.h
blob: f9db31801c90614cf887bd37698749e032a9e8a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _RFID_PROTOCOL_H
#define _RFID_PROTOCOL_H

#include <rfid/rfid_layer2.h>

#include <rfid/rfid_protocol_tcl.h>

struct rfid_protocol_handle;

struct rfid_protocol {
	struct rfid_protocol *next;
	unsigned int id;
	char *name;
	struct {
		struct rfid_protocol_handle *(*init)(struct rfid_layer2_handle *l2h);
		int (*open)(struct rfid_protocol_handle *ph);
		int (*close)(struct rfid_protocol_handle *ph);
		int (*fini)(struct rfid_protocol_handle *ph);
		int (*transcieve)(struct rfid_protocol_handle *ph,
				  const unsigned char *tx_buf,
				  unsigned int tx_len,
				  unsigned char *rx_buf,
				  unsigned int *rx_len,
				  unsigned int timeout,
				  unsigned int flags);
	} fn;
};

struct rfid_protocol_handle {
	struct rfid_layer2_handle *l2h;
	struct rfid_protocol *proto;
	union {
		struct tcl_handle tcl;
	} priv;				/* priv has to be last, since
					 * it could contain additional
					 * private data over the end of
					 * sizeof(priv). */
};

struct rfid_protocol_handle *
rfid_protocol_init(struct rfid_layer2_handle *l2h, unsigned int id);
int rfid_protocol_open(struct rfid_protocol_handle *ph);
int rfid_protocol_transcieve(struct rfid_protocol_handle *ph,
			     const unsigned char *tx_buf, unsigned int tx_len,
			     unsigned char *rx_buf, unsigned int *rx_len,
			     unsigned int timeout, unsigned int flags);
int rfid_protocol_fini(struct rfid_protocol_handle *ph);
int rfid_protocol_close(struct rfid_protocol_handle *ph);

int rfid_protocol_register(struct rfid_protocol *p);

enum rfid_protocol_id {
	RFID_PROTOCOL_UNKNOWN,
	RFID_PROTOCOL_TCL,
};
#endif
personal git repositories of Harald Welte. Your mileage may vary