diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-08-12 20:41:40 +0800 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-08-12 20:41:40 +0800 |
commit | 590c3fb3328a3afdae28051e6662c4d242f85d0f (patch) | |
tree | d48ee75e88869e197272ef6899c1b1359c2874de /easytool/mifare_classic.c | |
parent | a1111c14e99e17688c237ce2041080fa765425e3 (diff) |
Separate the mifare classic related stuff out from the Easycard
Diffstat (limited to 'easytool/mifare_classic.c')
-rw-r--r-- | easytool/mifare_classic.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/easytool/mifare_classic.c b/easytool/mifare_classic.c new file mode 100644 index 0000000..e516631 --- /dev/null +++ b/easytool/mifare_classic.c @@ -0,0 +1,29 @@ +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include "mifare_classic.h" + +void mfcl_parse_acc_bits(struct acc_bits_parsed *abp, uint8_t *acc_bits) +{ + uint8_t c1, c2, c3; + uint8_t block; + + memset(abp, 0, sizeof(*abp)); + + c1 = acc_bits[1] >> 4; + c2 = acc_bits[2] & 0xf; + c3 = acc_bits[2] >> 4; + + printf("C1 = %x, C2 = %x, C3 = %x\n", c1, c2, c3); + + for (block = 0; block < 4; block++) { + uint8_t testbit = 1 << block; + if (c1 & testbit) + abp->block[block] |= ABP_C1; + if (c2 & testbit) + abp->block[block] |= ABP_C2; + if (c3 & testbit) + abp->block[block] |= ABP_C3; + } +} |