fix one too small
[RRG-proxmark3.git] / client / src / wiegand_formats.h
blob671795c9a7dc5aeef071125ec49da4b58a760fc0
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // Wiegand format packing/unpacking routines
17 //-----------------------------------------------------------------------------
19 #ifndef WIEGAND_FORMATS_H__
20 #define WIEGAND_FORMATS_H__
22 #include <string.h> // memset
23 #include <stdbool.h>
24 #include <stdint.h>
25 #include <inttypes.h>
26 #include <math.h>
27 #include <stdio.h>
28 #include "cmddata.h"
29 #include "wiegand_formatutils.h"
30 #include "parity.h" // for parity
31 #include "ui.h"
33 typedef struct {
34 bool hasCardNumber;
35 bool hasFacilityCode;
36 bool hasIssueLevel;
37 bool hasOEMCode;
38 bool hasParity;
39 } cardformatdescriptor_t;
41 // Structure for defined Wiegand card formats available for packing/unpacking
42 typedef struct {
43 const char *Name;
44 bool (*Pack)(wiegand_card_t *card, wiegand_message_t *packed, bool preamble);
45 bool (*Unpack)(wiegand_message_t *packed, wiegand_card_t *card);
46 const char *Descrp;
47 cardformatdescriptor_t Fields;
48 } cardformat_t;
50 void HIDListFormats(void);
51 int HIDFindCardFormat(const char *format);
52 cardformat_t HIDGetCardFormat(int idx);
53 bool HIDPack(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble);
54 bool HIDTryUnpack(wiegand_message_t *packed);
55 void HIDPackTryAll(wiegand_card_t *card, bool preamble);
56 void HIDUnpack(int idx, wiegand_message_t *packed);
57 void print_wiegand_code(wiegand_message_t *packed);
58 void print_desc_wiegand(cardformat_t *fmt, wiegand_message_t *packed);
59 #endif