2010-02-21 08:47:22 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// 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.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Main command parser entry point
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
2010-02-20 08:36:48 +08:00
|
|
|
#include "sleep.h"
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
#include "cmdparser.h"
|
2012-12-05 07:39:18 +08:00
|
|
|
#include "proxmark3.h"
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
#include "data.h"
|
|
|
|
#include "usb_cmd.h"
|
|
|
|
#include "ui.h"
|
|
|
|
#include "cmdhf.h"
|
|
|
|
#include "cmddata.h"
|
|
|
|
#include "cmdhw.h"
|
|
|
|
#include "cmdlf.h"
|
|
|
|
#include "cmdmain.h"
|
2012-12-09 21:00:19 +08:00
|
|
|
#include "util.h"
|
2013-07-10 13:10:58 +08:00
|
|
|
#include "cmdscript.h"
|
2015-05-16 21:36:40 +08:00
|
|
|
#include "cmdcrc.h"
|
2016-05-10 21:30:46 +08:00
|
|
|
#include "cmdanalyse.h"
|
2013-06-27 05:13:02 +08:00
|
|
|
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
unsigned int current_command = CMD_UNKNOWN;
|
|
|
|
|
|
|
|
static int CmdHelp(const char *Cmd);
|
|
|
|
static int CmdQuit(const char *Cmd);
|
2015-06-07 17:35:49 +08:00
|
|
|
static int CmdRev(const char *Cmd);
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
|
2013-06-07 17:30:32 +08:00
|
|
|
//For storing command that are received from the device
|
2015-10-05 00:01:33 +08:00
|
|
|
#define CMD_BUFFER_SIZE 50
|
2013-06-07 17:30:32 +08:00
|
|
|
static UsbCommand cmdBuffer[CMD_BUFFER_SIZE];
|
|
|
|
//Points to the next empty position to write to
|
|
|
|
static int cmd_head;//Starts as 0
|
|
|
|
//Points to the position of the last unread command
|
|
|
|
static int cmd_tail;//Starts as 0
|
|
|
|
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
static command_t CommandTable[] =
|
|
|
|
{
|
2015-05-16 21:36:40 +08:00
|
|
|
{"help", CmdHelp, 1, "This help. Use '<command> help' for details of a particular command."},
|
2016-05-10 21:30:46 +08:00
|
|
|
{"analyse", CmdAnalyse, 1, "{ Analyse bytes... }"},
|
2015-05-16 21:36:40 +08:00
|
|
|
{"data", CmdData, 1, "{ Plot window / data buffer manipulation... }"},
|
|
|
|
{"hf", CmdHF, 1, "{ High Frequency commands... }"},
|
|
|
|
{"hw", CmdHW, 1, "{ Hardware commands... }"},
|
|
|
|
{"lf", CmdLF, 1, "{ Low Frequency commands... }"},
|
2016-05-10 21:30:46 +08:00
|
|
|
{"reveng", CmdRev, 1, "Crc calculations from the software reveng 1.40"},
|
|
|
|
{"script", CmdScript, 1, "{ Scripting commands }"},
|
2015-05-16 21:36:40 +08:00
|
|
|
{"quit", CmdQuit, 1, "Exit program"},
|
|
|
|
{"exit", CmdQuit, 1, "Exit program"},
|
|
|
|
{NULL, NULL, 0, NULL}
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
};
|
|
|
|
|
2014-03-27 05:35:25 +08:00
|
|
|
command_t* getTopLevelCommandTable()
|
|
|
|
{
|
|
|
|
return CommandTable;
|
|
|
|
}
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
int CmdHelp(const char *Cmd)
|
|
|
|
{
|
|
|
|
CmdsHelp(CommandTable);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CmdQuit(const char *Cmd)
|
|
|
|
{
|
2015-11-10 04:46:57 +08:00
|
|
|
return 99;
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
}
|
2015-06-07 17:35:49 +08:00
|
|
|
|
|
|
|
int CmdRev(const char *Cmd)
|
|
|
|
{
|
|
|
|
CmdCrc(Cmd);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-09-20 03:53:09 +08:00
|
|
|
/**
|
|
|
|
* @brief This method should be called when sending a new command to the pm3. In case any old
|
|
|
|
* responses from previous commands are stored in the buffer, a call to this method should clear them.
|
|
|
|
* A better method could have been to have explicit command-ACKS, so we can know which ACK goes to which
|
|
|
|
* operation. Right now we'll just have to live with this.
|
|
|
|
*/
|
|
|
|
void clearCommandBuffer()
|
|
|
|
{
|
|
|
|
//This is a very simple operation
|
|
|
|
cmd_tail = cmd_head;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief storeCommand stores a USB command in a circular buffer
|
|
|
|
* @param UC
|
|
|
|
*/
|
|
|
|
void storeCommand(UsbCommand *command)
|
|
|
|
{
|
|
|
|
if( ( cmd_head+1) % CMD_BUFFER_SIZE == cmd_tail)
|
|
|
|
{
|
|
|
|
//If these two are equal, we're about to overwrite in the
|
|
|
|
// circular buffer.
|
|
|
|
PrintAndLog("WARNING: Command buffer about to overwrite command! This needs to be fixed!");
|
|
|
|
}
|
|
|
|
//Store the command at the 'head' location
|
|
|
|
UsbCommand* destination = &cmdBuffer[cmd_head];
|
|
|
|
memcpy(destination, command, sizeof(UsbCommand));
|
|
|
|
|
|
|
|
cmd_head = (cmd_head +1) % CMD_BUFFER_SIZE; //increment head and wrap
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @brief getCommand gets a command from an internal circular buffer.
|
|
|
|
* @param response location to write command
|
|
|
|
* @return 1 if response was returned, 0 if nothing has been received
|
|
|
|
*/
|
|
|
|
int getCommand(UsbCommand* response)
|
|
|
|
{
|
|
|
|
//If head == tail, there's nothing to read, or if we just got initialized
|
2015-08-01 00:48:58 +08:00
|
|
|
if(cmd_head == cmd_tail) return 0;
|
|
|
|
|
2013-09-20 03:53:09 +08:00
|
|
|
//Pick out the next unread command
|
|
|
|
UsbCommand* last_unread = &cmdBuffer[cmd_tail];
|
|
|
|
memcpy(response, last_unread, sizeof(UsbCommand));
|
2016-02-10 20:22:48 +08:00
|
|
|
|
2013-09-20 03:53:09 +08:00
|
|
|
//Increment tail - this is a circular buffer, so modulo buffer size
|
|
|
|
cmd_tail = (cmd_tail +1 ) % CMD_BUFFER_SIZE;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-06-07 17:30:32 +08:00
|
|
|
/**
|
|
|
|
* Waits for a certain response type. This method waits for a maximum of
|
|
|
|
* ms_timeout milliseconds for a specified response command.
|
|
|
|
*@brief WaitForResponseTimeout
|
|
|
|
* @param cmd command to wait for
|
|
|
|
* @param response struct to copy received command into.
|
|
|
|
* @param ms_timeout
|
|
|
|
* @return true if command was returned, otherwise false
|
|
|
|
*/
|
2012-12-05 07:39:18 +08:00
|
|
|
bool WaitForResponseTimeout(uint32_t cmd, UsbCommand* response, size_t ms_timeout) {
|
2013-06-07 17:30:32 +08:00
|
|
|
|
2015-07-31 16:37:24 +08:00
|
|
|
UsbCommand resp;
|
|
|
|
|
2015-01-07 04:20:41 +08:00
|
|
|
if (response == NULL)
|
2015-07-31 16:37:24 +08:00
|
|
|
response = &resp;
|
2015-01-07 04:20:41 +08:00
|
|
|
|
2015-07-31 16:37:24 +08:00
|
|
|
// Wait until the command is received
|
2015-10-05 00:01:33 +08:00
|
|
|
for ( size_t dm_seconds = 0; dm_seconds < ms_timeout/10; dm_seconds++ ) {
|
2013-06-07 17:30:32 +08:00
|
|
|
|
2015-10-05 00:01:33 +08:00
|
|
|
while( getCommand(response) ) {
|
2016-02-10 20:22:48 +08:00
|
|
|
if(response->cmd == cmd)
|
|
|
|
return true;
|
2015-07-31 16:37:24 +08:00
|
|
|
}
|
2016-02-10 20:22:48 +08:00
|
|
|
|
2015-07-31 16:37:24 +08:00
|
|
|
msleep(10); // XXX ugh
|
2016-02-20 05:30:19 +08:00
|
|
|
if (dm_seconds == 250) { // 2.5 seconds elapsed
|
2015-07-31 16:37:24 +08:00
|
|
|
PrintAndLog("Waiting for a response from the proxmark...");
|
|
|
|
PrintAndLog("Don't forget to cancel its operation first by pressing on the button");
|
|
|
|
}
|
2013-06-07 17:30:32 +08:00
|
|
|
}
|
2015-07-31 16:37:24 +08:00
|
|
|
return false;
|
2010-07-13 21:39:30 +08:00
|
|
|
}
|
|
|
|
|
2012-12-05 07:39:18 +08:00
|
|
|
bool WaitForResponse(uint32_t cmd, UsbCommand* response) {
|
2015-10-05 00:01:33 +08:00
|
|
|
return WaitForResponseTimeout(cmd, response, -1);
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Entry point into our code: called whenever the user types a command and
|
|
|
|
// then presses Enter, which the full command line that they typed.
|
|
|
|
//-----------------------------------------------------------------------------
|
2015-11-10 04:46:57 +08:00
|
|
|
int CommandReceived(char *Cmd) {
|
|
|
|
return CmdsParse(CommandTable, Cmd);
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Entry point into our code: called whenever we received a packet over USB
|
|
|
|
// that we weren't necessarily expecting, for example a debug print.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void UsbCommandReceived(UsbCommand *UC)
|
|
|
|
{
|
2015-01-07 04:20:41 +08:00
|
|
|
switch(UC->cmd) {
|
|
|
|
// First check if we are handling a debug message
|
|
|
|
case CMD_DEBUG_PRINT_STRING: {
|
2016-02-10 20:22:48 +08:00
|
|
|
char s[USB_CMD_DATA_SIZE+1];
|
2016-02-10 20:07:44 +08:00
|
|
|
memset(s, 0x00, sizeof(s));
|
2015-01-07 04:20:41 +08:00
|
|
|
size_t len = MIN(UC->arg[0],USB_CMD_DATA_SIZE);
|
2016-02-10 20:22:48 +08:00
|
|
|
memcpy(s, UC->d.asBytes, len);
|
2016-03-06 17:35:25 +08:00
|
|
|
|
|
|
|
// test
|
|
|
|
if ( UC->arg[1] == CMD_MEASURE_ANTENNA_TUNING_HF) {
|
|
|
|
printf("\r#db# %s", s);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2017-01-17 04:06:51 +08:00
|
|
|
else {
|
2016-03-06 17:35:25 +08:00
|
|
|
PrintAndLog("#db# %s", s);
|
2017-01-17 04:06:51 +08:00
|
|
|
}
|
2015-01-07 04:20:41 +08:00
|
|
|
return;
|
|
|
|
} break;
|
|
|
|
|
2016-03-12 16:03:28 +08:00
|
|
|
case CMD_DEBUG_PRINT_INTEGERS: {
|
2016-02-10 20:22:48 +08:00
|
|
|
PrintAndLog("#db# %08x, %08x, %08x", UC->arg[0], UC->arg[1], UC->arg[2]);
|
|
|
|
break;
|
2016-03-12 16:03:28 +08:00
|
|
|
}
|
2016-02-10 20:22:48 +08:00
|
|
|
case CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K:
|
2016-03-12 16:03:28 +08:00
|
|
|
case CMD_DOWNLOADED_EML_BIGBUF: {
|
2017-01-17 04:06:51 +08:00
|
|
|
// sample_buf is a array pointer, located in data.c
|
|
|
|
// arg0 = offset in transfer. Startindex of this chunk
|
|
|
|
// arg1 = length bytes to transfer
|
|
|
|
// arg2 = bigbuff tracelength (?)
|
2016-02-10 20:22:48 +08:00
|
|
|
memcpy( sample_buf + (UC->arg[0]), UC->d.asBytes, UC->arg[1]);
|
2017-01-17 04:06:51 +08:00
|
|
|
//printf("DBG:: Download from device. chunk %llu | size %llu | tracelen:%llu \n", UC->arg[0], UC->arg[1], UC->arg[2]);
|
2016-02-10 20:22:48 +08:00
|
|
|
break;
|
2016-03-12 16:03:28 +08:00
|
|
|
}
|
2015-10-12 01:14:17 +08:00
|
|
|
default: {
|
|
|
|
storeCommand(UC);
|
2015-10-05 00:01:33 +08:00
|
|
|
break;
|
2015-10-12 01:14:17 +08:00
|
|
|
}
|
2015-10-05 00:01:33 +08:00
|
|
|
}
|
2016-02-10 20:29:23 +08:00
|
|
|
|
2013-06-07 17:30:32 +08:00
|
|
|
}
|
|
|
|
|