summaryrefslogtreecommitdiff
path: root/easytool/mifare_classic.h
blob: 05b3dc6293f460054f4f3206e5e8b64e49eb804c (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
#ifndef EASY_MFCL_H
#define EASY_MFCL_H

#include <stdint.h>

#define ABP_C1	0x04
#define ABP_C2	0x02
#define ABP_C3	0x01

struct acc_bits_parsed {
	uint8_t block[4];
};

void mfcl_parse_acc_bits(struct acc_bits_parsed *abp, uint8_t *acc_bits);

/* Mifare classic VALUE BLOCK */
struct mfcl_value_block {
	uint32_t value;		/* value in NTD */
	uint32_t value_inv;	/* bit-inverted copy of value in NTD */
	uint32_t value_backup;	/* backup copy of value in NTD */
	uint8_t addr[4];
} __attribute__ ((packed));

struct mfcl_addr {
	uint8_t sector;
	uint8_t block;
};

/* apply a delta (positive or negative) to a Mifare Classic VALUE block */
int mfcl_update_value_block(struct mfcl_value_block *mvb, int32_t delta);

#endif
personal git repositories of Harald Welte. Your mileage may vary