textual
[RRG-proxmark3.git] / client / src / wiegand_formats.h
blob313681bab000a16a48c06f75f21891c048348f3c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2018 grauerfuchs
3 //
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
6 // the license.
7 //-----------------------------------------------------------------------------
8 // Wiegand format packing/unpacking routines
9 //-----------------------------------------------------------------------------
11 #ifndef WIEGAND_FORMATS_H__
12 #define WIEGAND_FORMATS_H__
14 #include <string.h> // memset
15 #include <stdbool.h>
16 #include <stdint.h>
17 #include <inttypes.h>
18 #include <math.h>
19 #include <stdio.h>
20 #include "cmddata.h"
21 #include "wiegand_formatutils.h"
22 #include "parity.h" // for parity
23 #include "ui.h"
25 typedef struct {
26 bool hasCardNumber;
27 bool hasFacilityCode;
28 bool hasIssueLevel;
29 bool hasOEMCode;
30 bool hasParity;
31 } cardformatdescriptor_t;
33 // Structure for defined Wiegand card formats available for packing/unpacking
34 typedef struct {
35 const char *Name;
36 bool (*Pack)(wiegand_card_t *card, wiegand_message_t *packed, bool preamble);
37 bool (*Unpack)(wiegand_message_t *packed, wiegand_card_t *card);
38 const char *Descrp;
39 cardformatdescriptor_t Fields;
40 } cardformat_t;
42 void HIDListFormats(void);
43 int HIDFindCardFormat(const char *format);
44 cardformat_t HIDGetCardFormat(int idx);
45 bool HIDPack(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble);
46 bool HIDTryUnpack(wiegand_message_t *packed);
47 void HIDPackTryAll(wiegand_card_t *card, bool preamble);
48 void HIDUnpack(int idx, wiegand_message_t *packed);
49 void print_wiegand_code(wiegand_message_t *packed);
50 void print_desc_wiegand(cardformat_t *fmt, wiegand_message_t *packed);
51 #endif