2019-09-19 01:20:07 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
2022-01-07 08:58:03 +08:00
|
|
|
// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
|
2019-09-19 01:20:07 +08:00
|
|
|
//
|
2022-01-07 08:58:03 +08:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// See LICENSE.txt for the text of the license.
|
2019-09-19 01:20:07 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Wiegand format packing/unpacking routines
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef WIEGAND_FORMATS_H__
|
|
|
|
#define WIEGAND_FORMATS_H__
|
|
|
|
|
2019-09-19 02:15:29 +08:00
|
|
|
#include <string.h> // memset
|
2019-09-19 01:20:07 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "cmddata.h"
|
|
|
|
#include "wiegand_formatutils.h"
|
|
|
|
#include "parity.h" // for parity
|
|
|
|
#include "ui.h"
|
|
|
|
|
|
|
|
typedef struct {
|
2019-09-19 16:47:12 +08:00
|
|
|
bool hasCardNumber;
|
|
|
|
bool hasFacilityCode;
|
|
|
|
bool hasIssueLevel;
|
|
|
|
bool hasOEMCode;
|
|
|
|
bool hasParity;
|
2019-09-19 01:20:07 +08:00
|
|
|
} cardformatdescriptor_t;
|
|
|
|
|
|
|
|
// Structure for defined Wiegand card formats available for packing/unpacking
|
|
|
|
typedef struct {
|
2019-09-19 16:47:12 +08:00
|
|
|
const char *Name;
|
2021-02-03 07:14:40 +08:00
|
|
|
bool (*Pack)(wiegand_card_t *card, wiegand_message_t *packed, bool preamble);
|
2019-09-19 16:47:12 +08:00
|
|
|
bool (*Unpack)(wiegand_message_t *packed, wiegand_card_t *card);
|
|
|
|
const char *Descrp;
|
|
|
|
cardformatdescriptor_t Fields;
|
2019-09-19 01:20:07 +08:00
|
|
|
} cardformat_t;
|
|
|
|
|
2020-05-03 07:13:28 +08:00
|
|
|
void HIDListFormats(void);
|
2019-09-19 01:20:07 +08:00
|
|
|
int HIDFindCardFormat(const char *format);
|
|
|
|
cardformat_t HIDGetCardFormat(int idx);
|
2021-02-03 07:14:40 +08:00
|
|
|
bool HIDPack(int format_idx, wiegand_card_t *card, wiegand_message_t *packed, bool preamble);
|
2021-04-27 21:19:34 +08:00
|
|
|
bool HIDTryUnpack(wiegand_message_t *packed);
|
2021-02-03 07:14:40 +08:00
|
|
|
void HIDPackTryAll(wiegand_card_t *card, bool preamble);
|
2021-04-28 01:16:06 +08:00
|
|
|
void HIDUnpack(int idx, wiegand_message_t *packed);
|
2021-01-29 18:56:31 +08:00
|
|
|
void print_wiegand_code(wiegand_message_t *packed);
|
|
|
|
void print_desc_wiegand(cardformat_t *fmt, wiegand_message_t *packed);
|
2019-09-19 01:20:07 +08:00
|
|
|
#endif
|