]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/hidcardformatutils.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2018 grauerfuchs
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
7 //-----------------------------------------------------------------------------
8 // HID card format packing/unpacking support functions
9 //-----------------------------------------------------------------------------
11 #ifndef HIDCARDFORMATUTILS_H__
12 #define HIDCARDFORMATUTILS_H__
18 // Structure for packed HID messages
19 // Always align lowest value (last transmitted) bit to ordinal position 0 (lowest valued bit bottom)
20 typedef struct hidproxmessage_s
{
21 uint8_t Length
; // Number of encoded bits in prox message (excluding headers and preamble)
22 uint32_t top
; // Bits in x<<64 positions
23 uint32_t mid
; // Bits in x<<32 positions
24 uint32_t bot
; // Lowest ordinal positions
27 // Structure for unpacked HID prox cards
28 typedef struct hidproxcard_s
{
29 uint32_t FacilityCode
;
33 bool ParityValid
; // Only valid for responses
36 bool get_bit_by_position(/* in */hidproxmessage_t
* data
, /* in */uint8_t pos
);
37 bool set_bit_by_position(/* inout */hidproxmessage_t
* data
, /* in */bool value
, /* in */uint8_t pos
);
39 uint64_t get_linear_field(/* in */hidproxmessage_t
* data
, /* in */uint8_t firstBit
, /* in */uint8_t length
);
40 bool set_linear_field(/* inout */hidproxmessage_t
* data
, /* in */uint64_t value
, /* in */uint8_t firstBit
, /* in */uint8_t length
);
42 uint64_t get_nonlinear_field(/* in */hidproxmessage_t
* data
, /* in */uint8_t numBits
, /* in */uint8_t* bits
);
43 bool set_nonlinear_field(/* inout */hidproxmessage_t
* data
, /* in */uint64_t value
, /* in */uint8_t numBits
, /* in */uint8_t* bits
);
45 hidproxmessage_t
initialize_proxmessage_object(/* in */uint32_t top
, /* in */uint32_t mid
, /* in */uint32_t bot
);
46 bool add_HID_header(/* inout */hidproxmessage_t
* data
);