blob: 5caa0be6996418edfe93b178ebef079038aa82eb [file] [log] [blame]
Harald Welte619b2a62019-11-22 00:35:52 +01001module VPCD_Types {
2
3/* VPCD/VPICC Types, implementing the protocol used by vpcd/vpicc of
4 * vsmartcard.git by Frank Morgner.
5 */
6
7import from General_Types all;
8import from Osmocom_Types all;
9
10type enumerated VPCD_CtrlCmd {
11 VPCD_CTRL_OFF (0),
12 VPCD_CTRL_ON (1),
13 VPCD_CTRL_RESET (2),
14 VPCD_CTRL_ATR (4)
15} with { variant "FIELDLENGTH(8)" };
16
17type union VPCD_MsgUnion {
18 VPCD_CtrlCmd ctrl,
19 octetstring data
20};
21
22type record VPCD_PDU {
23 uint16_t len,
24 VPCD_MsgUnion u
25} with {
26 variant (len) "LENGTHTO(u)"
27 variant (u) "CROSSTAG(
28 ctrl, len = 1;
29 data, OTHERWISE)"
30};
31
32
33template (value) VPCD_PDU ts_VPCD_CTRL(template (value) VPCD_CtrlCmd cmd) := {
34 len := 0, // overwritten
35 u := {
36 ctrl := cmd
37 }
38}
39template (value) VPCD_PDU ts_VPCD_CTRL_OFF := ts_VPCD_CTRL(VPCD_CTRL_OFF);
40template (value) VPCD_PDU ts_VPCD_CTRL_ON := ts_VPCD_CTRL(VPCD_CTRL_ON);
41template (value) VPCD_PDU ts_VPCD_CTRL_RESET := ts_VPCD_CTRL(VPCD_CTRL_RESET);
42template (value) VPCD_PDU ts_VPCD_CTRL_ATR := ts_VPCD_CTRL(VPCD_CTRL_ATR);
43template (value) VPCD_PDU ts_VPCD_DATA(template (value) octetstring data) := {
44 len := 0, //overwritten
45 u := {
46 data := data
47 }
48}
49
50template (present) VPCD_PDU tr_VPCD_CTRL(template (present) VPCD_CtrlCmd cmd) := {
51 len := ?,
52 u := {
53 ctrl := cmd
54 }
55}
56template (present) VPCD_PDU tr_VPCD_CTRL_OFF := tr_VPCD_CTRL(VPCD_CTRL_OFF);
57template (present) VPCD_PDU tr_VPCD_CTRL_ON := tr_VPCD_CTRL(VPCD_CTRL_ON);
58template (present) VPCD_PDU tr_VPCD_CTRL_RESET := tr_VPCD_CTRL(VPCD_CTRL_RESET);
59template (present) VPCD_PDU tr_VPCD_CTRL_ATR := tr_VPCD_CTRL(VPCD_CTRL_ATR);
60template (present) VPCD_PDU tr_VPCD_DATA(template (present) octetstring data) := {
61 len := ?,
62 u := {
63 data := data
64 }
65}
66
67external function enc_VPCD_PDU(in VPCD_PDU msg) return octetstring
68 with { extension "prototype(convert) encode(RAW)" };
69
70external function dec_VPCD_PDU(in octetstring msg) return VPCD_PDU
71 with { extension "prototype(convert) decode(RAW)" };
72
73
74
75} with { encode "RAW" };