mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-19 19:38:52 +08:00
chg: return codes
This commit is contained in:
parent
d546f39534
commit
486211599d
3 changed files with 46 additions and 46 deletions
|
@ -46,7 +46,7 @@ static int usage_lf_fdx_clone(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf fdx clone 999 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_fdx_sim(void) {
|
||||
|
@ -61,7 +61,7 @@ static int usage_lf_fdx_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf fdx sim 999 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// clearing the topbit needed for the preambl detection.
|
||||
|
@ -105,23 +105,23 @@ static int CmdFDXBdemodBI(const char *Cmd) {
|
|||
errCnt = askdemod(bs, &size, &clk, &invert, maxErr, 0, 0);
|
||||
if (errCnt < 0 || errCnt > maxErr) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDXB no data or error found %d, clock: %d", errCnt, clk);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
errCnt = BiphaseRawDecode(bs, &size, &offset, 1);
|
||||
if (errCnt < 0 || errCnt > maxErr) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDXB BiphaseRawDecode: %d", errCnt);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
int preambleIndex = detectFDXB(bs, &size);
|
||||
if (preambleIndex < 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDXB preamble not found :: %d", preambleIndex);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
if (size != 128) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDXB incorrect data length found");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
setDemodBuff(bs, 128, preambleIndex);
|
||||
|
@ -130,7 +130,7 @@ static int CmdFDXBdemodBI(const char *Cmd) {
|
|||
size = removeParity(bs, preambleIndex + 11, 9, 2, 117);
|
||||
if (size != 104) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDXB error removeParity:: %d", size);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "\nFDX-B / ISO 11784/5 Animal Tag ID Found:");
|
||||
|
||||
|
@ -164,7 +164,7 @@ static int CmdFDXBdemodBI(const char *Cmd) {
|
|||
char *bin = sprint_bin_break(bs, size, 16);
|
||||
PrintAndLogEx(DEBUG, "DEBUG BinStream:\n%s", bin);
|
||||
}
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -175,9 +175,9 @@ static int CmdFdxDemod(const char *Cmd) {
|
|||
|
||||
//Differential Biphase / di-phase (inverted biphase)
|
||||
//get binary from ask wave
|
||||
if (!ASKbiphaseDemod("0 32 1 100", false)) {
|
||||
if (ASKbiphaseDemod("0 32 1 100", false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDX-B ASKbiphaseDemod failed");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int preambleIndex = detectFDXB(DemodBuffer, &size);
|
||||
|
@ -191,7 +191,7 @@ static int CmdFdxDemod(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDX-B Size not correct: %d", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDX-B ans: %d", preambleIndex);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// set and leave DemodBuffer intact
|
||||
|
@ -201,7 +201,7 @@ static int CmdFdxDemod(const char *Cmd) {
|
|||
size = removeParity(DemodBuffer, 11, 9, 2, 117);
|
||||
if (size != 104) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - FDX-B error removeParity: %d", size);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
//got a good demod
|
||||
|
@ -237,7 +237,7 @@ static int CmdFdxDemod(const char *Cmd) {
|
|||
// set block 0 for later
|
||||
//g_DemodConfig = T55x7_MODULATION_DIPHASE | T55x7_BITRATE_RF_32 | 4 << T55x7_MAXBLOCK_SHIFT;
|
||||
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdFdxRead(const char *Cmd) {
|
||||
|
@ -263,9 +263,9 @@ static int CmdFdxClone(const char *Cmd) {
|
|||
verify_values(countryid, animalid);
|
||||
|
||||
// getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits)
|
||||
if (!getFDXBits(animalid, countryid, 1, 0, 0, bs)) {
|
||||
if (getFDXBits(animalid, countryid, 1, 0, 0, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
//Q5
|
||||
|
@ -301,10 +301,10 @@ static int CmdFdxClone(const char *Cmd) {
|
|||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdFdxSim(const char *Cmd) {
|
||||
|
@ -348,7 +348,7 @@ static command_t CommandTable[] = {
|
|||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdLFFdx(const char *Cmd) {
|
||||
|
@ -421,6 +421,6 @@ int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t
|
|||
num_to_bytebitsLSBF(extended >> 0, 8, bits + 101);
|
||||
num_to_bytebitsLSBF(extended >> 8, 8, bits + 110);
|
||||
num_to_bytebitsLSBF(extended >> 16, 8, bits + 119);
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ static int usage_lf_guard_clone(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf gprox clone 26 123 11223");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_guard_sim(void) {
|
||||
|
@ -41,7 +41,7 @@ static int usage_lf_guard_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf gprox sim 26 123 11223");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
//by marshmellow
|
||||
|
@ -54,9 +54,9 @@ static int CmdGuardDemod(const char *Cmd) {
|
|||
|
||||
//Differential Biphase
|
||||
//get binary from ask wave
|
||||
if (!ASKbiphaseDemod("0 64 0 0", false)) {
|
||||
if (ASKbiphaseDemod("0 64 0 0", false) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - gProxII ASKbiphaseDemod failed");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
size_t size = DemodBufferLen;
|
||||
|
@ -74,7 +74,7 @@ static int CmdGuardDemod(const char *Cmd) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - gProxII wrong spacerbits");
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - gProxII ans: %d", preambleIndex);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
//got a good demod of 96 bits
|
||||
|
@ -89,7 +89,7 @@ static int CmdGuardDemod(const char *Cmd) {
|
|||
size_t len = removeParity(bits_no_spacer, 0, 5, 3, 90); //source, startloc, paritylen, ptype, length_to_run
|
||||
if (len != 72) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - gProxII spacer removal did not produce 72 bits: %u, start: %u", len, startIdx);
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
// get key and then get all 8 bytes of payload decoded
|
||||
xorKey = (uint8_t)bytebits_to_byteLSBF(bits_no_spacer, 8);
|
||||
|
@ -128,7 +128,7 @@ static int CmdGuardDemod(const char *Cmd) {
|
|||
else
|
||||
PrintAndLogEx(SUCCESS, "Unknown G-Prox-II Fmt Found: Format Len: %u, Raw: %08x%08x%08x", fmtLen, raw1, raw2, raw3);
|
||||
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdGuardRead(const char *Cmd) {
|
||||
|
@ -154,9 +154,9 @@ static int CmdGuardClone(const char *Cmd) {
|
|||
facilitycode = (fc & 0x000000FF);
|
||||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
if (!getGuardBits(fmtlen, facilitycode, cardnumber, bs)) {
|
||||
if (getGuardBits(fmtlen, facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
// Q5
|
||||
|
@ -190,10 +190,10 @@ static int CmdGuardClone(const char *Cmd) {
|
|||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdGuardSim(const char *Cmd) {
|
||||
|
@ -214,9 +214,9 @@ static int CmdGuardSim(const char *Cmd) {
|
|||
facilitycode = (fc & 0x000000FF);
|
||||
cardnumber = (cn & 0x0000FFFF);
|
||||
|
||||
if (!getGuardBits(fmtlen, facilitycode, cardnumber, bs)) {
|
||||
if (getGuardBits(fmtlen, facilitycode, cardnumber, bs) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Guardall - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber);
|
||||
|
@ -242,7 +242,7 @@ static command_t CommandTable[] = {
|
|||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdLFGuard(const char *Cmd) {
|
||||
|
@ -374,6 +374,6 @@ int getGuardBits(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint8_t *guardBits) {
|
|||
guardBits[5] = 0;
|
||||
|
||||
PrintAndLogEx(DEBUG, " FIN | %s\n", sprint_bin(guardBits, 96));
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ static int usage_lf_jablotron_clone(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf jablotron clone 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int usage_lf_jablotron_sim(void) {
|
||||
|
@ -36,7 +36,7 @@ static int usage_lf_jablotron_sim(void) {
|
|||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf jablotron sim 112233");
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t jablontron_chksum(uint8_t *bits) {
|
||||
|
@ -65,9 +65,9 @@ static int CmdJablotronDemod(const char *Cmd) {
|
|||
|
||||
//Differential Biphase / di-phase (inverted biphase)
|
||||
//get binary from ask wave
|
||||
if (!ASKbiphaseDemod("0 64 1 0", false)) {
|
||||
if (ASKbiphaseDemod("0 64 1 0", false) != PM3_SUCCESS) {
|
||||
if (g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: Error - Jablotron ASKbiphaseDemod failed");
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
size_t size = DemodBufferLen;
|
||||
int ans = detectJablotron(DemodBuffer, &size);
|
||||
|
@ -84,7 +84,7 @@ static int CmdJablotronDemod(const char *Cmd) {
|
|||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Jablotron ans: %d", ans);
|
||||
}
|
||||
return 0;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
setDemodBuff(DemodBuffer, 64, ans);
|
||||
|
@ -113,7 +113,7 @@ static int CmdJablotronDemod(const char *Cmd) {
|
|||
(uint16_t)(id >> 16) & 0xFFFF,
|
||||
(uint16_t)id & 0xFFFF
|
||||
);
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdJablotronRead(const char *Cmd) {
|
||||
|
@ -144,9 +144,9 @@ static int CmdJablotronClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Card Number Truncated to 39bits: %"PRIx64, fullcode);
|
||||
}
|
||||
|
||||
if (!getJablotronBits(fullcode, bits)) {
|
||||
if (getJablotronBits(fullcode, bits) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Error with tag bitstream generation.");
|
||||
return 1;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
blocks[1] = bytebits_to_byte(bits, 32);
|
||||
|
@ -175,10 +175,10 @@ static int CmdJablotronClone(const char *Cmd) {
|
|||
SendCommandNG(CMD_T55XX_WRITE_BLOCK, (uint8_t *)&ng, sizeof(ng));
|
||||
if (!WaitForResponseTimeout(CMD_T55XX_WRITE_BLOCK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
return PM3_ETIMEOUT;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdJablotronSim(const char *Cmd) {
|
||||
|
@ -221,7 +221,7 @@ static command_t CommandTable[] = {
|
|||
static int CmdHelp(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
CmdsHelp(CommandTable);
|
||||
return 0;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
int CmdLFJablotron(const char *Cmd) {
|
||||
|
@ -239,7 +239,7 @@ int getJablotronBits(uint64_t fullcode, uint8_t *bits) {
|
|||
//chksum byte
|
||||
uint8_t chksum = jablontron_chksum(bits);
|
||||
num_to_bytebits(chksum, 8, bits + 56);
|
||||
return 1;
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// ASK/Diphase fc/64 (inverted Biphase)
|
||||
|
|
Loading…
Add table
Reference in a new issue