FreeCalypso > hg > fc-sim-sniff
annotate sw/sniff-dec/hl_decode.c @ 56:966a54303d68
simsniff-dec: factor out high-level decoding
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 04 Oct 2023 01:18:50 +0000 |
parents | |
children | eb4274e7f4da |
rev | line source |
---|---|
56
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Here we implement higher-level decoding of INS codes and SELECT file IDs. |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 static struct ins_code_tab { |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 u_char ins_code; |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 char *cmdname; |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 } ins_code_table[] = { |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 {0xA4, "SELECT"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 {0xF2, "STATUS"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 {0xB0, "READ BINARY"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 {0xD6, "UPDATE BINARY"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 {0xB2, "READ RECORD"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 {0xDC, "UPDATE RECORD"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 {0xA2, "SEEK"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 {0x32, "INCREASE"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 {0x20, "VERIFY PIN"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 {0x24, "CHANGE PIN"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 {0x26, "DISABLE PIN"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 {0x28, "ENABLE PIN"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 {0x2C, "UNBLOCK PIN"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 {0x04, "INVALIDATE"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 {0x44, "REHABILITATE"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 {0x88, "RUN GSM ALGO"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 {0xFA, "SLEEP"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 {0xC0, "GET RESPONSE"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 {0x10, "TERMINAL PROFILE"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 {0xC2, "ENVELOPE"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 {0x12, "FETCH"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 {0x14, "TERMINAL RESPONSE"}, |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 /* table search terminator */ |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 {0, 0} |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 }; |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 void |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 decode_cmd_opcode(ins) |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 u_char ins; |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 { |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 struct ins_code_tab *tp; |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 for (tp = ins_code_table; tp->cmdname; tp++) |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (tp->ins_code == ins) |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 break; |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 if (tp->cmdname) |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 printf(" Command: %s\n", tp->cmdname); |
966a54303d68
simsniff-dec: factor out high-level decoding
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |