Skip to content

Commit 9cf1576

Browse files
committed
Improve output format for hf felica scsvcode
1 parent 9b59204 commit 9cf1576

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

client/src/cmdhffelica.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,8 +1948,7 @@ static int CmdHFFelicaDumpServiceArea(const char *Cmd) {
19481948
if (!check_last_idm(data, datalen))
19491949
return PM3_EINVARG;
19501950

1951-
PrintAndLogEx(HINT, "Area and service code are printed in big endian.");
1952-
PrintAndLogEx(HINT, "Don't forget to convert to little endian when using hf felica rdbl.");
1951+
PrintAndLogEx(HINT, "Area and service codes are printed in network order.");
19531952
PrintAndLogEx(INFO, "┌───────────────────────────────────────────────");
19541953

19551954
uint8_t flags = FELICA_APPEND_CRC | FELICA_RAW;
@@ -1981,7 +1980,9 @@ static int CmdHFFelicaDumpServiceArea(const char *Cmd) {
19811980
}
19821981

19831982
uint8_t len = resp.frame_response.length[0];
1984-
uint16_t node_code = resp.payload[0] | (resp.payload[1] << 8);
1983+
uint16_t node_code = resp.payload[0] | (resp.payload[1] << 8); /* LE for traversal */
1984+
uint16_t node_code_net = (resp.payload[0] << 8) | resp.payload[1]; /* BE for display */
1985+
uint16_t node_number = node_code >> 6; /* upper 10 bits in host order */
19851986

19861987
if (node_code == 0xFFFF) break; /* end-marker */
19871988

@@ -2002,13 +2003,16 @@ static int CmdHFFelicaDumpServiceArea(const char *Cmd) {
20022003
/* ----- print --------------------------------------------------- */
20032004
if (len == 0x0E) { /* AREA node */
20042005
uint16_t end_code = resp.payload[2] | (resp.payload[3] << 8);
2005-
PrintAndLogEx(INFO, "%sAREA_%04X", prefix, node_code >> 6);
2006+
uint16_t end_number = end_code >> 6;
2007+
PrintAndLogEx(INFO, "%sAREA_%02X%02X%02X%02X (%u-%u)", prefix,
2008+
resp.payload[0], resp.payload[1], resp.payload[2], resp.payload[3],
2009+
node_number, end_number);
20062010

20072011
if (depth < 7) {
20082012
area_end_stack[++depth] = end_code;
20092013
}
20102014
} else if (len == 0x0C) { /* SERVICE */
2011-
PrintAndLogEx(INFO, "%ssvc_%04X", prefix, node_code);
2015+
PrintAndLogEx(INFO, "%sSVC_%04X (%u)", prefix, node_code_net, node_number);
20122016
} else {
20132017
PrintAndLogEx(FAILED, "Unexpected length 0x%02X @ 0x%04X",
20142018
len, cursor);

0 commit comments

Comments
 (0)