mirror of
https://github.com/Proxmark/proxmark3.git
synced 2024-09-21 07:16:24 +08:00
Provide msclock() as Milliseconds timer for performance measures (#231)
- don't use clock(). It has different functionalities in Windows and Linux - move sleep functions to util.h
This commit is contained in:
parent
0ca9bc0e99
commit
acf0582d53
|
@ -54,7 +54,6 @@ endif
|
|||
|
||||
CORESRCS = uart.c \
|
||||
util.c \
|
||||
sleep.c
|
||||
|
||||
|
||||
CMDSRCS = crapto1/crapto1.c\
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
// CRC Calculations from the software reveng commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN32
|
||||
# include <io.h>
|
||||
# include <fcntl.h>
|
||||
|
@ -19,8 +18,8 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "cmdmain.h"
|
||||
#include "cmdcrc.h"
|
||||
#include "reveng/reveng.h"
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
// High frequency commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "proxmark3.h"
|
||||
#include "util.h"
|
||||
#include "data.h"
|
||||
#include "ui.h"
|
||||
#include "iso14443crc.h"
|
||||
#include "cmdmain.h"
|
||||
|
|
|
@ -431,7 +431,7 @@ int CmdHF14ACUIDs(const char *Cmd)
|
|||
n = n > 0 ? n : 1;
|
||||
|
||||
PrintAndLog("Collecting %d UIDs", n);
|
||||
PrintAndLog("Start: %u", time(NULL));
|
||||
PrintAndLog("Start: %" PRIu64, msclock()/1000);
|
||||
// repeat n times
|
||||
for (int i = 0; i < n; i++) {
|
||||
// execute anticollision procedure
|
||||
|
@ -454,7 +454,7 @@ int CmdHF14ACUIDs(const char *Cmd)
|
|||
PrintAndLog("%s", uid_string);
|
||||
}
|
||||
}
|
||||
PrintAndLog("End: %u", time(NULL));
|
||||
PrintAndLog("End: %" PRIu64, msclock()/1000);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -12,13 +12,14 @@
|
|||
#ifndef CMDHF14A_H__
|
||||
#define CMDHF14A_H__
|
||||
|
||||
int CmdHF14A(const char *Cmd);
|
||||
#include <stdint.h>
|
||||
|
||||
int CmdHF14A(const char *Cmd);
|
||||
int CmdHF14AList(const char *Cmd);
|
||||
int CmdHF14AMifare(const char *Cmd);
|
||||
int CmdHF14AReader(const char *Cmd);
|
||||
int CmdHF14ASim(const char *Cmd);
|
||||
int CmdHF14ASnoop(const char *Cmd);
|
||||
|
||||
char* getTagInfo(uint8_t uid);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,15 +8,19 @@
|
|||
// Commands related to the German electronic Identification Card
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "util.h"
|
||||
#include "cmdhfepa.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include "util.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "common.h"
|
||||
#include "cmdmain.h"
|
||||
#include "sleep.h"
|
||||
#include "cmdhfepa.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
@ -37,7 +41,7 @@ int CmdHFEPACollectPACENonces(const char *Cmd)
|
|||
n = n > 0 ? n : 1;
|
||||
|
||||
PrintAndLog("Collecting %u %u-byte nonces", n, m);
|
||||
PrintAndLog("Start: %u", time(NULL));
|
||||
PrintAndLog("Start: %" PRIu64 , msclock()/1000);
|
||||
// repeat n times
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
// execute PACE
|
||||
|
@ -64,7 +68,7 @@ int CmdHFEPACollectPACENonces(const char *Cmd)
|
|||
sleep(d);
|
||||
}
|
||||
}
|
||||
PrintAndLog("End: %u", time(NULL));
|
||||
PrintAndLog("End: %" PRIu64, msclock()/1000);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "proxmark3.h"
|
||||
#include "cmdmain.h"
|
||||
#include "util.h"
|
||||
|
@ -688,8 +690,8 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
}
|
||||
}
|
||||
else { // ------------------------------------ multiple sectors working
|
||||
clock_t time1;
|
||||
time1 = clock();
|
||||
uint64_t msclock1;
|
||||
msclock1 = msclock();
|
||||
|
||||
e_sector = calloc(SectorsCnt, sizeof(sector_t));
|
||||
if (e_sector == NULL) return 1;
|
||||
|
@ -759,7 +761,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
}
|
||||
}
|
||||
|
||||
printf("Time in nested: %1.3f (%1.3f sec per key)\n\n", ((float)clock() - time1)/CLOCKS_PER_SEC, ((float)clock() - time1)/iterations/CLOCKS_PER_SEC);
|
||||
printf("Time in nested: %1.3f (%1.3f sec per key)\n\n", ((float)(msclock() - msclock1))/1000.0, ((float)(msclock() - msclock1))/iterations/1000.0);
|
||||
|
||||
PrintAndLog("-----------------------------------------------\nIterations count: %d\n\n", iterations);
|
||||
//print them
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
// High frequency MIFARE ULTRALIGHT (C) commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "cmdhfmfu.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "proxmark3.h"
|
||||
#include "usb_cmd.h"
|
||||
#include "cmdmain.h"
|
||||
#include "ui.h"
|
||||
#include "loclass/des.h"
|
||||
#include "cmdhfmfu.h"
|
||||
#include "cmdhfmf.h"
|
||||
#include "cmdhf14a.h"
|
||||
#include "mifare.h"
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
// Low frequency AWID26 commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h> // sscanf
|
||||
#include "proxmark3.h" // Definitions, USB controls, etc
|
||||
#include "ui.h" // PrintAndLog
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
#include "data.h"
|
||||
#include "graph.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmddata.h"
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "util.h"
|
||||
#include "hitag2.h"
|
||||
#include "hitagS.h"
|
||||
#include "sleep.h"
|
||||
#include "cmdmain.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include "cmdlfpresco.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include "cmdlfpyramid.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h"
|
||||
#include "graph.h"
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "sleep.h"
|
||||
#include "cmdparser.h"
|
||||
#include "proxmark3.h"
|
||||
#include "data.h"
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include "proxmark3.h"
|
||||
#include "sleep.h"
|
||||
#include "util.h"
|
||||
#include "flash.h"
|
||||
#include "elf.h"
|
||||
#include "proxendian.h"
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "sleep.h"
|
||||
#include "proxmark3.h"
|
||||
#include "util.h"
|
||||
#include "flash.h"
|
||||
#include "uart.h"
|
||||
#include "usb_cmd.h"
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "sleep.h"
|
||||
#include "proxusb.h"
|
||||
#include "flash.h"
|
||||
#include "elf.h"
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "sleep.h"
|
||||
#include "proxusb.h"
|
||||
#include "flash.h"
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <strings.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "sleep.h"
|
||||
#include "proxusb.h"
|
||||
#include "proxmark3.h"
|
||||
#include "usb_cmd.h"
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "util.h"
|
||||
#include "cipherutils.h"
|
||||
#include "cipher.h"
|
||||
#include "ikeys.h"
|
||||
|
@ -512,7 +512,7 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[])
|
|||
uint8_t i;
|
||||
int errors = 0;
|
||||
size_t itemsize = sizeof(dumpdata);
|
||||
clock_t t1 = clock();
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
dumpdata* attack = (dumpdata* ) malloc(itemsize);
|
||||
|
||||
|
@ -522,9 +522,9 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[])
|
|||
errors += bruteforceItem(*attack, keytable);
|
||||
}
|
||||
free(attack);
|
||||
t1 = clock() - t1;
|
||||
float diff = ((float)t1 / CLOCKS_PER_SEC );
|
||||
prnlog("\nPerformed full crack in %f seconds",diff);
|
||||
t1 = msclock() - t1;
|
||||
float diff = (float)t1 / 1000.0;
|
||||
prnlog("\nPerformed full crack in %f seconds", diff);
|
||||
|
||||
// Pick out the first 16 bytes of the keytable.
|
||||
// The keytable is now in 16-bit ints, where the upper 8 bits
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
// MIFARE Darkside hack
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "nonce2key.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "mifarehost.h"
|
||||
#include "ui.h"
|
||||
#include "util.h"
|
||||
|
@ -160,7 +159,7 @@ bool mfkey32(nonces_t data, uint64_t *outputkey) {
|
|||
uint32_t ar0_enc = data.ar; // first encrypted reader response
|
||||
uint32_t nr1_enc = data.nr2; // second encrypted reader challenge
|
||||
uint32_t ar1_enc = data.ar2; // second encrypted reader response
|
||||
clock_t t1 = clock();
|
||||
uint64_t t1 = msclock();
|
||||
bool isSuccess = false;
|
||||
uint8_t counter=0;
|
||||
|
||||
|
@ -181,8 +180,8 @@ bool mfkey32(nonces_t data, uint64_t *outputkey) {
|
|||
}
|
||||
}
|
||||
isSuccess = (counter == 1);
|
||||
t1 = clock() - t1;
|
||||
//if ( t1 > 0 ) PrintAndLog("Time in mfkey32: %.0f ticks \nFound %d possible keys", (float)t1, counter);
|
||||
t1 = msclock() - t1;
|
||||
//if ( t1 > 0 ) PrintAndLog("Time in mfkey32: %.1f seconds \nFound %d possible keys", (float)t1/1000.0, counter);
|
||||
*outputkey = ( isSuccess ) ? outkey : 0;
|
||||
crypto1_destroy(s);
|
||||
/* //un-comment to save all keys to a stats.txt file
|
||||
|
@ -212,7 +211,7 @@ bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey) {
|
|||
int counter = 0;
|
||||
|
||||
//PrintAndLog("Enter mfkey32_moebius");
|
||||
clock_t t1 = clock();
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
s = lfsr_recovery32(ar0_enc ^ prng_successor(nt0, 64), 0);
|
||||
|
||||
|
@ -233,8 +232,8 @@ bool tryMfk32_moebius(nonces_t data, uint64_t *outputkey) {
|
|||
}
|
||||
}
|
||||
isSuccess = (counter == 1);
|
||||
t1 = clock() - t1;
|
||||
//if ( t1 > 0 ) PrintAndLog("Time in mfkey32_moebius: %.0f ticks \nFound %d possible keys", (float)t1,counter);
|
||||
t1 = msclock() - t1;
|
||||
//if ( t1 > 0 ) PrintAndLog("Time in mfkey32_moebius: %.1f seconds \nFound %d possible keys", (float)t1/1000.0, counter);
|
||||
*outputkey = ( isSuccess ) ? outkey : 0;
|
||||
crypto1_destroy(s);
|
||||
/* // un-comment to output all keys to stats.txt
|
||||
|
@ -265,7 +264,7 @@ int tryMfk64(uint32_t uid, uint32_t nt, uint32_t nr_enc, uint32_t ar_enc, uint32
|
|||
struct Crypto1State *revstate;
|
||||
|
||||
PrintAndLog("Enter mfkey64");
|
||||
clock_t t1 = clock();
|
||||
uint64_t t1 = msclock();
|
||||
|
||||
// Extract the keystream from the messages
|
||||
ks2 = ar_enc ^ prng_successor(nt, 64);
|
||||
|
@ -280,8 +279,8 @@ int tryMfk64(uint32_t uid, uint32_t nt, uint32_t nr_enc, uint32_t ar_enc, uint32
|
|||
crypto1_destroy(revstate);
|
||||
*outputkey = key;
|
||||
|
||||
t1 = clock() - t1;
|
||||
if ( t1 > 0 ) PrintAndLog("Time in mfkey64: %.0f ticks \n", (float)t1);
|
||||
t1 = msclock() - t1;
|
||||
if ( t1 > 0 ) PrintAndLog("Time in mfkey64: %.1f seconds \n", (float)t1/1000.0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "cmdmain.h"
|
||||
#include "uart.h"
|
||||
#include "ui.h"
|
||||
#include "sleep.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdhw.h"
|
||||
#include "whereami.h"
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// platform-independant sleep macros
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#define _POSIX_C_SOURCE 199309L
|
||||
#include "sleep.h"
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
||||
void nsleep(uint64_t n) {
|
||||
struct timespec timeout;
|
||||
timeout.tv_sec = n/1000000000;
|
||||
timeout.tv_nsec = n%1000000000;
|
||||
while (nanosleep(&timeout, &timeout) && errno == EINTR);
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
// the license.
|
||||
//-----------------------------------------------------------------------------
|
||||
// platform-independant sleep macros
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef SLEEP_H__
|
||||
#define SLEEP_H__
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# define sleep(n) Sleep(1000 * n)
|
||||
# define msleep(n) Sleep(n)
|
||||
#else
|
||||
# include <inttypes.h>
|
||||
# include <unistd.h>
|
||||
void nsleep(uint64_t n);
|
||||
# define msleep(n) nsleep(1000000 * n)
|
||||
# define usleep(n) nsleep(1000 * n)
|
||||
#endif // _WIN32
|
||||
|
||||
#endif // SLEEP_H__
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
// Snooper binary
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "sleep.h"
|
||||
#include "ui.h"
|
||||
#include "proxusb.h"
|
||||
#include "cmdmain.h"
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <readline/readline.h>
|
||||
#include <pthread.h>
|
||||
|
||||
|
@ -34,7 +33,7 @@ void PrintAndLog(char *fmt, ...)
|
|||
static FILE *logfile = NULL;
|
||||
static int logging=1;
|
||||
|
||||
// lock this section to avoid interlacing prints from different threats
|
||||
// lock this section to avoid interlacing prints from different threads
|
||||
pthread_mutex_lock(&print_lock);
|
||||
|
||||
if (logging && !logfile) {
|
||||
|
|
|
@ -8,15 +8,26 @@
|
|||
// utilities
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ctype.h>
|
||||
#if !defined(_WIN32)
|
||||
#define _POSIX_C_SOURCE 199309L // need nanosleep()
|
||||
#endif
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "data.h"
|
||||
|
||||
#define MAX_BIN_BREAK_LENGTH (3072+384+1)
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
|
||||
int ukbhit(void)
|
||||
{
|
||||
int cnt = 0;
|
||||
|
@ -42,6 +53,7 @@ int ukbhit(void)
|
|||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <conio.h>
|
||||
int ukbhit(void) {
|
||||
return kbhit();
|
||||
|
@ -591,3 +603,38 @@ void clean_ascii(unsigned char *buf, size_t len) {
|
|||
buf[i] = '.';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Timer functions
|
||||
#if !defined (_WIN32)
|
||||
#include <errno.h>
|
||||
|
||||
static void nsleep(uint64_t n) {
|
||||
struct timespec timeout;
|
||||
timeout.tv_sec = n/1000000000;
|
||||
timeout.tv_nsec = n%1000000000;
|
||||
while (nanosleep(&timeout, &timeout) && errno == EINTR);
|
||||
}
|
||||
|
||||
void msleep(uint32_t n) {
|
||||
nsleep(1000000 * n);
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
// a milliseconds timer for performance measurement
|
||||
uint64_t msclock() {
|
||||
#if defined(_WIN32)
|
||||
#include <sys/types.h>
|
||||
struct _timeb t;
|
||||
if (_ftime_s(&t)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1000 * t.time + t.millitm;
|
||||
}
|
||||
#else
|
||||
struct timespec t;
|
||||
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
return (t.tv_sec * 1000 + t.tv_nsec / 1000000);
|
||||
#endif
|
||||
}
|
||||
|
|
108
client/util.h
108
client/util.h
|
@ -8,13 +8,11 @@
|
|||
// utilities
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h> //included in data.h
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h> //time, gmtime
|
||||
#include "data.h" //for FILE_PATH_SIZE
|
||||
#ifndef UTIL_H__
|
||||
#define UTIL_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef ROTR
|
||||
# define ROTR(x,n) (((uintmax_t)(x) >> (n)) | ((uintmax_t)(x) << ((sizeof(x) * 8) - (n))))
|
||||
|
@ -25,54 +23,68 @@
|
|||
#ifndef MAX
|
||||
# define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define EVEN 0
|
||||
#define ODD 1
|
||||
|
||||
int ukbhit(void);
|
||||
extern int ukbhit(void);
|
||||
|
||||
void AddLogLine(char *fileName, char *extData, char *c);
|
||||
void AddLogHex(char *fileName, char *extData, const uint8_t * data, const size_t len);
|
||||
void AddLogUint64(char *fileName, char *extData, const uint64_t data);
|
||||
void AddLogCurrentDT(char *fileName);
|
||||
void FillFileNameByUID(char *fileName, uint8_t * uid, char *ext, int byteCount);
|
||||
extern void AddLogLine(char *fileName, char *extData, char *c);
|
||||
extern void AddLogHex(char *fileName, char *extData, const uint8_t * data, const size_t len);
|
||||
extern void AddLogUint64(char *fileName, char *extData, const uint64_t data);
|
||||
extern void AddLogCurrentDT(char *fileName);
|
||||
extern void FillFileNameByUID(char *fileName, uint8_t * uid, char *ext, int byteCount);
|
||||
|
||||
void print_hex(const uint8_t * data, const size_t len);
|
||||
char * sprint_hex(const uint8_t * data, const size_t len);
|
||||
char * sprint_bin(const uint8_t * data, const size_t len);
|
||||
char * sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t breaks);
|
||||
char * sprint_hex_ascii(const uint8_t *data, const size_t len);
|
||||
char * sprint_ascii(const uint8_t *data, const size_t len);
|
||||
extern void print_hex(const uint8_t * data, const size_t len);
|
||||
extern char *sprint_hex(const uint8_t * data, const size_t len);
|
||||
extern char *sprint_bin(const uint8_t * data, const size_t len);
|
||||
extern char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t breaks);
|
||||
extern char *sprint_hex_ascii(const uint8_t *data, const size_t len);
|
||||
extern char *sprint_ascii(const uint8_t *data, const size_t len);
|
||||
|
||||
void num_to_bytes(uint64_t n, size_t len, uint8_t* dest);
|
||||
uint64_t bytes_to_num(uint8_t* src, size_t len);
|
||||
void num_to_bytebits(uint64_t n, size_t len, uint8_t *dest);
|
||||
void num_to_bytebitsLSBF(uint64_t n, size_t len, uint8_t *dest);
|
||||
char * printBits(size_t const size, void const * const ptr);
|
||||
uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize);
|
||||
void SwapEndian64ex(const uint8_t *src, const size_t len, const uint8_t blockSize, uint8_t *dest);
|
||||
extern void num_to_bytes(uint64_t n, size_t len, uint8_t* dest);
|
||||
extern uint64_t bytes_to_num(uint8_t* src, size_t len);
|
||||
extern void num_to_bytebits(uint64_t n, size_t len, uint8_t *dest);
|
||||
extern void num_to_bytebitsLSBF(uint64_t n, size_t len, uint8_t *dest);
|
||||
extern char *printBits(size_t const size, void const * const ptr);
|
||||
extern uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize);
|
||||
extern void SwapEndian64ex(const uint8_t *src, const size_t len, const uint8_t blockSize, uint8_t *dest);
|
||||
|
||||
char param_getchar(const char *line, int paramnum);
|
||||
int param_getptr(const char *line, int *bg, int *en, int paramnum);
|
||||
uint8_t param_get8(const char *line, int paramnum);
|
||||
uint8_t param_get8ex(const char *line, int paramnum, int deflt, int base);
|
||||
uint32_t param_get32ex(const char *line, int paramnum, int deflt, int base);
|
||||
uint64_t param_get64ex(const char *line, int paramnum, int deflt, int base);
|
||||
uint8_t param_getdec(const char *line, int paramnum, uint8_t *destination);
|
||||
uint8_t param_isdec(const char *line, int paramnum);
|
||||
int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt);
|
||||
int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt);
|
||||
int param_getstr(const char *line, int paramnum, char * str);
|
||||
extern char param_getchar(const char *line, int paramnum);
|
||||
extern int param_getptr(const char *line, int *bg, int *en, int paramnum);
|
||||
extern uint8_t param_get8(const char *line, int paramnum);
|
||||
extern uint8_t param_get8ex(const char *line, int paramnum, int deflt, int base);
|
||||
extern uint32_t param_get32ex(const char *line, int paramnum, int deflt, int base);
|
||||
extern uint64_t param_get64ex(const char *line, int paramnum, int deflt, int base);
|
||||
extern uint8_t param_getdec(const char *line, int paramnum, uint8_t *destination);
|
||||
extern uint8_t param_isdec(const char *line, int paramnum);
|
||||
extern int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt);
|
||||
extern int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt);
|
||||
extern int param_getstr(const char *line, int paramnum, char * str);
|
||||
|
||||
int hextobinarray( char *target, char *source);
|
||||
int hextobinstring( char *target, char *source);
|
||||
int binarraytohex( char *target, char *source, int length);
|
||||
void binarraytobinstring(char *target, char *source, int length);
|
||||
uint8_t GetParity( uint8_t *string, uint8_t type, int length);
|
||||
void wiegand_add_parity(uint8_t *target, uint8_t *source, uint8_t length);
|
||||
extern int hextobinarray( char *target, char *source);
|
||||
extern int hextobinstring( char *target, char *source);
|
||||
extern int binarraytohex( char *target, char *source, int length);
|
||||
extern void binarraytobinstring(char *target, char *source, int length);
|
||||
extern uint8_t GetParity( uint8_t *string, uint8_t type, int length);
|
||||
extern void wiegand_add_parity(uint8_t *target, uint8_t *source, uint8_t length);
|
||||
|
||||
void xor(unsigned char *dst, unsigned char *src, size_t len);
|
||||
int32_t le24toh(uint8_t data[3]);
|
||||
uint32_t le32toh (uint8_t *data);
|
||||
void rol(uint8_t *data, const size_t len);
|
||||
extern void xor(unsigned char *dst, unsigned char *src, size_t len);
|
||||
extern int32_t le24toh(uint8_t data[3]);
|
||||
extern uint32_t le32toh (uint8_t *data);
|
||||
extern void rol(uint8_t *data, const size_t len);
|
||||
|
||||
void clean_ascii(unsigned char *buf, size_t len);
|
||||
extern void clean_ascii(unsigned char *buf, size_t len);
|
||||
|
||||
// timer functions/macros
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# define sleep(n) Sleep(1000 *(n))
|
||||
# define msleep(n) Sleep((n))
|
||||
#else
|
||||
extern void msleep(uint32_t n); // sleep n milliseconds
|
||||
#endif // _WIN32
|
||||
|
||||
extern uint64_t msclock(); // a milliseconds clock
|
||||
|
||||
#endif // UTIL_H__
|
||||
|
|
Loading…
Reference in a new issue