hf 14a list helptext handling by CmdTraceListAlias, to be generalized if ok

This commit is contained in:
Philippe Teuwen 2021-04-19 14:35:09 +02:00
commit 4dea429157
3 changed files with 38 additions and 5 deletions

View file

@ -171,12 +171,13 @@ static uint16_t frameLength = 0;
uint16_t atsFSC[] = {16, 24, 32, 40, 48, 64, 96, 128, 256};
static int CmdHF14AList(const char *Cmd) {
char args[128] = {0};
if (strlen(Cmd) == 0) {
snprintf(args, sizeof(args), "-t 14a");
} else {
strncpy(args, Cmd, sizeof(args) - 1);
int ret = CmdTraceListAlias(Cmd, "hf 14a list");
if (ret != PM3_SUCCESS) {
return ret;
}
char args[128] = {0};
snprintf(args, sizeof(args), "-t 14a ");
strncat(args, Cmd, sizeof(args) - strlen(args));
return CmdTraceList(args);
}

View file

@ -591,6 +591,37 @@ static int CmdTraceSave(const char *Cmd) {
return PM3_SUCCESS;
}
int CmdTraceListAlias(const char *Cmd, const char *alias) {
CLIParserContext *ctx;
char example[200] = {0};
sprintf(example,
"%s -f -> show frame delay times\n"
"%s -1 -> use trace buffer ",
alias, alias);
CLIParserInit(&ctx, alias,
"Alias of `trace list -t` with selected protocol data to annotate trace buffer\n"
"You can load a trace from file (see `trace load -h`) or it be downloaded from device by default\n"
"It accepts all other arguments of `trace list`. Note that some might not be relevant for this specific protocol",
example
);
void *argtable[] = {
arg_param_begin,
arg_lit0("1", "buffer", "use data from trace buffer"),
arg_lit0("f", NULL, "show frame delay times"),
arg_lit0("c", NULL, "mark CRC bytes"),
arg_lit0("r", NULL, "show relative times (gap and duration)"),
arg_lit0("u", NULL, "display times in microseconds instead of clock cycles"),
arg_lit0("x", NULL, "show hexdump to convert to pcap(ng)\n"
" or to import into Wireshark using encapsulation type \"ISO 14443\""),
arg_strx0(NULL, "dict", "<file>", "use dictionary keys file"),
arg_param_end
};
CLIExecWithReturn(ctx, Cmd, argtable, true);
CLIParserFree(ctx);
return PM3_SUCCESS;
}
int CmdTraceList(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "trace list",

View file

@ -15,5 +15,6 @@
int CmdTrace(const char *Cmd);
int CmdTraceList(const char *Cmd);
int CmdTraceListAlias(const char *Cmd, const char *alias);
#endif