osmo-ttcn3-hacks/library/VPCD_Types.ttcn

76 lines
1.9 KiB
Plaintext

module VPCD_Types {
/* VPCD/VPICC Types, implementing the protocol used by vpcd/vpicc of
* vsmartcard.git by Frank Morgner.
*/
import from General_Types all;
import from Osmocom_Types all;
type enumerated VPCD_CtrlCmd {
VPCD_CTRL_OFF (0),
VPCD_CTRL_ON (1),
VPCD_CTRL_RESET (2),
VPCD_CTRL_ATR (4)
} with { variant "FIELDLENGTH(8)" };
type union VPCD_MsgUnion {
VPCD_CtrlCmd ctrl,
octetstring data
};
type record VPCD_PDU {
uint16_t len,
VPCD_MsgUnion u
} with {
variant (len) "LENGTHTO(u)"
variant (u) "CROSSTAG(
ctrl, len = 1;
data, OTHERWISE)"
};
template (value) VPCD_PDU ts_VPCD_CTRL(template (value) VPCD_CtrlCmd cmd) := {
len := 0, // overwritten
u := {
ctrl := cmd
}
}
template (value) VPCD_PDU ts_VPCD_CTRL_OFF := ts_VPCD_CTRL(VPCD_CTRL_OFF);
template (value) VPCD_PDU ts_VPCD_CTRL_ON := ts_VPCD_CTRL(VPCD_CTRL_ON);
template (value) VPCD_PDU ts_VPCD_CTRL_RESET := ts_VPCD_CTRL(VPCD_CTRL_RESET);
template (value) VPCD_PDU ts_VPCD_CTRL_ATR := ts_VPCD_CTRL(VPCD_CTRL_ATR);
template (value) VPCD_PDU ts_VPCD_DATA(template (value) octetstring data) := {
len := 0, //overwritten
u := {
data := data
}
}
template (present) VPCD_PDU tr_VPCD_CTRL(template (present) VPCD_CtrlCmd cmd) := {
len := ?,
u := {
ctrl := cmd
}
}
template (present) VPCD_PDU tr_VPCD_CTRL_OFF := tr_VPCD_CTRL(VPCD_CTRL_OFF);
template (present) VPCD_PDU tr_VPCD_CTRL_ON := tr_VPCD_CTRL(VPCD_CTRL_ON);
template (present) VPCD_PDU tr_VPCD_CTRL_RESET := tr_VPCD_CTRL(VPCD_CTRL_RESET);
template (present) VPCD_PDU tr_VPCD_CTRL_ATR := tr_VPCD_CTRL(VPCD_CTRL_ATR);
template (present) VPCD_PDU tr_VPCD_DATA(template (present) octetstring data) := {
len := ?,
u := {
data := data
}
}
external function enc_VPCD_PDU(in VPCD_PDU msg) return octetstring
with { extension "prototype(convert) encode(RAW)" };
external function dec_VPCD_PDU(in octetstring msg) return VPCD_PDU
with { extension "prototype(convert) decode(RAW)" };
} with { encode "RAW" };