remove autogenerated file
[librfid] / src / rfid_proto_icode.c
1
2 /* Philips/NXP I*Code implementation, PCD side.
3  *
4  * (C) 2005-2008 by Harald Welte <laforge@gnumonks.org>
5  *
6  */
7
8 /*
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License version 2
11  *  as published by the Free Software Foundation
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <string.h>
26 #include <errno.h>
27
28 #include <librfid/rfid.h>
29 #include <librfid/rfid_protocol.h>
30 #include <librfid/rfid_layer2.h>
31 #include <librfid/rfid_layer2_icode1.h>
32 #include <librfid/rfid_protocol_icode.h>
33
34 static int
35 icode_read(struct rfid_protocol_handle *ph, unsigned int page,
36            unsigned char *rx_data, unsigned int *rx_len)
37 {
38         unsigned char rx_buf[16];
39         unsigned int real_rx_len = sizeof(rx_buf);
40         unsigned char tx[2];
41         int ret;
42
43         /* FIXME */
44         return -EINVAL;
45 }
46
47 static int
48 icode_write(struct rfid_protocol_handle *ph, unsigned int page,
49             unsigned char *tx_data, unsigned int tx_len)
50 {
51         unsigned int i;
52         unsigned char tx[6];
53         unsigned char rx[10];
54         unsigned int rx_len = sizeof(rx);
55         int ret;
56
57         return -EINVAL;
58 }
59
60 static int
61 icode_getopt(struct rfid_protocol_handle *ph, int optname, void *optval,
62             unsigned int *optlen)
63 {
64         int ret = -EINVAL;
65         unsigned int *size = optval;
66
67         switch (optname) {
68         case RFID_OPT_PROTO_SIZE:
69                 ret = 0;
70                 /* we have to return the size in bytes, not bits */
71                 /* FIXME: implement this */
72                 *size = 12345;
73                 break;
74         }
75
76         return ret;
77 }
78
79
80 static struct rfid_protocol_handle *
81 icode_init(struct rfid_layer2_handle *l2h)
82 {
83         struct rfid_protocol_handle *ph;
84         u_int8_t uid[6];
85         int uid_len = sizeof(uid);
86
87         if (l2h->l2->id != RFID_LAYER2_ICODE1)
88                 return NULL;
89
90         /* According to "SCBU002 - November 2005 */
91         rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID,
92                            uid, &uid_len);
93         if (uid[5] != 0xe0 || uid[4] != 0x07)
94                 return NULL;
95         if (l2h->uid_len != 6)
96                 return NULL;
97
98         ph = malloc_protocol_handle(sizeof(struct rfid_protocol_handle));
99         return ph;
100 }
101
102 static int icode_fini(struct rfid_protocol_handle *ph)
103 {
104         free_protocol_handle(ph);
105         return 0;
106 }
107
108 const struct rfid_protocol rfid_protocol_icode = {
109         .id     = RFID_PROTOCOL_ICODE_SLI,
110         .name   = "I*Code SLI",
111         .fn     = {
112                 .init           = &icode_init,
113                 .read           = &icode_read,
114                 .write          = &icode_write,
115                 .fini           = &icode_fini,
116                 .getopt         = &icode_getopt,
117         },
118 };
119
120 /* Functions below are not (yet? covered in the generic librfid api */