fixed ISO 14443A anticollision
[librfid] / src / rfid.c
1 /* librfid core 
2  *  (C) 2005-2006 by Harald Welte <laforge@gnumonks.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License version 2 
6  *  as published by the Free Software Foundation
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17 #include <stdio.h>
18 #include <string.h>
19
20 #include <librfid/rfid_reader.h>
21 #include <librfid/rfid_protocol.h>
22 #include <librfid/rfid_protocol_tcl.h>
23 #include <librfid/rfid_protocol_mifare_ul.h>
24 #include <librfid/rfid_protocol_mifare_classic.h>
25
26 #ifdef LIBRFID_STATIC
27 struct rfid_asic_handle rfid_ah;
28 struct rfid_layer2_handle rfid_l2h;
29 struct rfid_protocol_handle rfid_ph;
30 struct rfid_asic_transport_handle rfid_ath;
31 struct rfid_reader_handle rfid_rh;
32 #endif
33
34 #ifndef LIBRFID_FIRMWARE
35 const char *
36 rfid_hexdump(const void *data, unsigned int len)
37 {
38         static char string[1024];
39         unsigned char *d = (unsigned char *) data;
40         unsigned int i, left;
41
42         string[0] = '\0';
43         left = sizeof(string);
44         for (i = 0; len--; i += 3) {
45                 if (i >= sizeof(string) -4)
46                         break;
47                 snprintf(string+i, 4, " %02x", *d++);
48         }
49         return string;
50 }
51 #else
52 #define rfid_hexdump(x, y) hexdump(x, y)
53 #endif
54
55 #if 0
56 int rfid_setopt(struct rfid_handle *rh, unsigned int level,
57                 unsigned int optname,
58                 const void *opt, unsigned int *optlen)
59 {
60         switch (level) {
61         case RFID_LEVEL_ASIC:
62         case RFID_LEVEL_READER:
63                 return -EINVAL;
64                 break;
65         case RFID_LEVEL_LAYER2:
66                 return rfid_layer2_setopt(optname, opt, optlen);
67                 break;
68         case RFID_LEVEL_LAYER3:
69                 return rfid_layer3_setopt(optname, opt, optlen);
70                 break;
71         default:
72                 return -EINVAL;
73                 break;
74         }
75
76         return 0;
77 }
78
79 int rfid_getopt(struct rfid_handle *rh, unsigned int level,
80                 unsigned int optname,
81                 void *opt, unsigned int *optlen)
82 {
83         switch (level) {
84         case RFID_LEVEL_ASIC:
85         case RFID_LEVEL_READER:
86                 return -EINVAL;
87                 break;
88         case RFID_LEVEL_LAYER2:
89                 return rfid_layer2_getopt(optname, opt, optlen);
90                 break;
91         case RFID_LEVEL_LAYER3:
92                 return rfid_layer3_getopt(optname, opt, optlen);
93                 break;
94         default:
95                 return -EINVAL;
96                 break;
97         }
98
99         return 0;
100 }
101 #endif
102
103 int rfid_init()
104 {
105         return 0;
106 }
107
108 void rfid_fini()
109 {
110         /* FIXME: implementation */
111 }