summaryrefslogtreecommitdiff
path: root/src/rfid.c
blob: c2a86c5647bd9c76e0554e07827b854aa912af8f (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* librfid core 
 *  (C) 2005-2006 by Harald Welte <laforge@gnumonks.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 
 *  as published by the Free Software Foundation
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
#include <stdio.h>
#include <string.h>

#include <librfid/rfid.h>
#include <librfid/rfid_reader.h>
#include <librfid/rfid_protocol.h>
#include <librfid/rfid_protocol_tcl.h>
#include <librfid/rfid_protocol_mifare_ul.h>
#include <librfid/rfid_protocol_mifare_classic.h>

#ifdef LIBRFID_STATIC
struct rfid_asic_handle rfid_ah;
struct rfid_layer2_handle rfid_l2h;
struct rfid_protocol_handle rfid_ph;
struct rfid_asic_transport_handle rfid_ath;
struct rfid_reader_handle rfid_rh;
#endif

#ifndef LIBRFID_FIRMWARE
#ifdef  DEBUG_LIBRFID
const char *
rfid_hexdump(const void *data, unsigned int len)
{
	static char string[1024];
	unsigned char *d = (unsigned char *) data;
	unsigned int i, left;

	string[0] = '\0';
	left = sizeof(string);
	for (i = 0; len--; i += 3) {
		if (i >= sizeof(string) -4)
			break;
		snprintf(string+i, 4, " %02x", *d++);
	}
	return string;
}
#endif/*DEBUG_LIBRFID*/
#else
#define rfid_hexdump(x, y) hexdump(x, y)
#endif

#if 0
int rfid_setopt(struct rfid_handle *rh, unsigned int level,
		unsigned int optname,
		const void *opt, unsigned int *optlen)
{
	switch (level) {
	case RFID_LEVEL_ASIC:
	case RFID_LEVEL_READER:
		return -EINVAL;
		break;
	case RFID_LEVEL_LAYER2:
		return rfid_layer2_setopt(optname, opt, optlen);
		break;
	case RFID_LEVEL_LAYER3:
		return rfid_layer3_setopt(optname, opt, optlen);
		break;
	default:
		return -EINVAL;
		break;
	}

	return 0;
}

int rfid_getopt(struct rfid_handle *rh, unsigned int level,
		unsigned int optname,
		void *opt, unsigned int *optlen)
{
	switch (level) {
	case RFID_LEVEL_ASIC:
	case RFID_LEVEL_READER:
		return -EINVAL;
		break;
	case RFID_LEVEL_LAYER2:
		return rfid_layer2_getopt(optname, opt, optlen);
		break;
	case RFID_LEVEL_LAYER3:
		return rfid_layer3_getopt(optname, opt, optlen);
		break;
	default:
		return -EINVAL;
		break;
	}

	return 0;
}
#endif

int rfid_init()
{
	return 0;
}

void rfid_fini()
{
	/* FIXME: implementation */
}
personal git repositories of Harald Welte. Your mileage may vary