summaryrefslogtreecommitdiff
path: root/include/librfid/rfid_access_mifare_classic.h
blob: 4c7fbdf0af22189b15ca02ff8d1ebf36b92086eb (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
#ifndef _RFID_MIFARE_ACCESS_H
#define _RFID_MIFARE_ACCESS_H

struct mfcl_access_sect {
	u_int8_t block[4];
};

int mfcl_compile_access(u_int8_t *encoded,
		        const struct mfcl_access_sect *ac);
int mfcl_parse_access(struct mfcl_access_sect *ac, u_int8_t *encoded);


enum mfcl_access_exp_data {
	MFCL_ACCESS_NEVER 	= 0,
	MFCL_ACCESS_KEY_A	= 1,
	MFCL_ACCESS_KEY_B	= 2,
};

struct mfcl_access_exp_block {
#ifndef RFID_BIG_ENDIAN_BITFIELD
	u_int8_t read:2,
		 write:2,
		 inc:2,
		 dec:2;
#else
	u_int8_t dec:2,
		 inc:2,
		 write:2,
		 read:2;
#endif
} __attribute__ ((packed));

struct mfcl_access_exp_acc {
#ifndef RFID_BIG_ENDIAN_BITFIELD
	u_int8_t key_a_rd:2,
		  key_a_wr:2,
		  acc_rd:2,
		  acc_wr:2;
	u_int8_t key_b_rd:2,
		  key_b_wr:2,
		  reserved:4;
#else
	u_int8_t acc_wr:2,
		  acc_rd:2,
		  key_a_wr:2,
		  key_a_rd:2;
	u_int8_t reserved:4,
		  key_b_wr:2,
		  key_b_rd:2;
#endif
} __attribute__ ((packed));


struct mfcl_access_exp_sect {
	struct mfcl_access_exp_block block[3];
	struct mfcl_access_exp_acc acc;
};

void mfcl_access_to_exp(struct mfcl_access_exp_sect *exp,
			const struct mfcl_access_sect *sect);

char *mfcl_access_exp_stringify(const struct mfcl_access_exp_block *exp);
char *mfcl_access_exp_acc_stringify(const struct mfcl_access_exp_acc *acc);
#endif
personal git repositories of Harald Welte. Your mileage may vary