1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
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.
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 // Weigand card format packing/unpacking support functions
17 //-----------------------------------------------------------------------------
19 #ifndef WIEGAND_FORMATUTILS_H__
20 #define WIEGAND_FORMATUTILS_H__
26 // Structure for packed wiegand messages
27 // Always align lowest value (last transmitted) bit to ordinal position 0 (lowest valued bit bottom)
29 uint8_t Length
; // Number of encoded bits in wiegand message (excluding headers and preamble)
30 uint32_t Top
; // Bits in x<<64 positions
31 uint32_t Mid
; // Bits in x<<32 positions
32 uint32_t Bot
; // Lowest ordinal positions
35 // Structure for unpacked wiegand card, like HID prox
37 uint32_t FacilityCode
;
41 bool ParityValid
; // Only valid for responses
44 uint8_t get_bit_by_position(wiegand_message_t
*data
, uint8_t pos
);
45 bool set_bit_by_position(wiegand_message_t
*data
, bool value
, uint8_t pos
);
47 uint64_t get_linear_field(wiegand_message_t
*data
, uint8_t firstBit
, uint8_t length
);
48 bool set_linear_field(wiegand_message_t
*data
, uint64_t value
, uint8_t firstBit
, uint8_t length
);
50 uint64_t get_nonlinear_field(wiegand_message_t
*data
, uint8_t numBits
, uint8_t *bits
);
51 bool set_nonlinear_field(wiegand_message_t
*data
, uint64_t value
, uint8_t numBits
, uint8_t *bits
);
53 wiegand_message_t
initialize_message_object(uint32_t top
, uint32_t mid
, uint32_t bot
, int n
);
55 bool add_HID_header(wiegand_message_t
*data
);