From 2bca644911ba844ff2185c61ec1bab0ba2a20044 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 9 Sep 2020 14:36:36 +0200 Subject: [PATCH] Add Q931_Types + Q933_Tyeps with definitions from ITU-T Q.931 + Q.933 Change-Id: I722be710badeb92400f552929fd5769b858722af --- src/Q931_Types.ttcn | 37 +++++++ src/Q933_Types.ttcn | 243 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 src/Q931_Types.ttcn create mode 100644 src/Q933_Types.ttcn diff --git a/src/Q931_Types.ttcn b/src/Q931_Types.ttcn new file mode 100644 index 0000000..ad00faf --- /dev/null +++ b/src/Q931_Types.ttcn @@ -0,0 +1,37 @@ +module Q931_Types { + +/* Definitions from ITU T-REC Q.931 */ + + +type enumerated Q931_MessageType { + Q931_MSGT_ALERTING ('00000001'B), + Q931_MSGT_CALL_PROCEEDING ('00000010'B), + Q931_MSGT_CONNECT ('00000111'B), + Q931_MSGT_CONNECT_ACK ('00001111'B), + Q931_MSGT_PROGRESS ('00000011'B), + Q931_MSGT_SETUP ('00000101'B), + Q931_MSGT_SETUP_ACK ('00001101'B), + + Q931_MSGT_RESUME ('00100110'B), + Q931_MSGT_RESUME_ACK ('00101110'B), + Q931_MSGT_RESUME_REJ ('00100010'B), + Q931_MSGT_SUSPEND ('00100101'B), + Q931_MSGT_SUSPEND_ACK ('00101101'B), + Q931_MSGT_SUSPEND_REJ ('00100001'B), + Q931_MSGT_USER_INFO ('00100000'B), + + Q931_MSGT_DISCONNECT ('01000101'B), + Q931_MSGT_RELEASE ('01001101'B), + Q931_MSGT_RELEASE_COMPL ('01011010'B), + Q931_MSGT_RESTART ('01000110'B), + Q931_MSGT_RESTART_ACK ('01001110'B), + + Q931_MSGT_SEGMENT ('01100000'B), + Q931_MSGT_CONGESTION_CTRL ('01111001'B), + Q931_MSGT_INFORMATION ('01111011'B), + Q931_MSGT_NOTIFY ('01101110'B), + Q931_MSGT_STATUS ('01111101'B), + Q931_MSGT_STATUS_ENQ ('01110101'B) +} with { variant "FIELDLENGTH(8)" }; + +} with { encode "RAW" }; diff --git a/src/Q933_Types.ttcn b/src/Q933_Types.ttcn new file mode 100644 index 0000000..525e824 --- /dev/null +++ b/src/Q933_Types.ttcn @@ -0,0 +1,243 @@ +module Q933_Types { + +import from General_Types all; +import from Osmocom_Types all; +import from Q931_Types all; + +type enumerated Q933_IEI { + Q933_IEI_REPORT_TYPE ('01010001'B), + Q933_IEI_LINK_INTEGRITY ('01010011'B), + Q933_IEI_PVC_STATUS ('01010111'B) +} with { variant "FIELDLENGTH(8)" }; + + + +/* ITU-T Rec. Q.933 Table A.1 */ +type record Q933_STATUS_Msg { + Q933_ReportTypeIE rep_type, + Q933_LinkIntegrityIE link_int optional, + Q933_PvcStatusIE pvc_status optional +}; + +/* ITU-T Rec. Q.933 Table A.2 */ +type record Q933_STATEUS_ENQ_Msg { + Q933_ReportTypeIE rep_type, + Q933_LinkIntegrityIE link_int +}; + + +/* ITU-T Rec. Q.933 Figure A.1 */ +type record Q933_ReportTypeIE { + Q933_IEI iei, + uint8_t len, + Q933_TypeOfReport type_of_rep +} with { + variant "PRESENCE(iei = Q933_IEI_REPORT_TYPE)" + variant (len) "LENGTHTO(type_of_rep)" +}; +type enumerated Q933_TypeOfReport { + Q993_REP_T_FULL_STATUS ('00'O), + Q933_REP_T_LINK_INTEG_VF_ONLY ('01'O), + Q933_REP_T_SINGLE_PVC_ASYNC_STS ('02'O) +} with { variant "FIELDLENGTH(8)" }; + + +/* ITU-T Rec. Q.933 Figure A.2 */ +type record Q933_LinkIntegrityIE { + Q933_IEI iei, + uint8_t len, + uint8_t send_seq_nr, + uint8_t recv_seq_nr +} with { + variant "PRESENCE(iei = Q933_IEI_LINK_INTEGRITY)" + variant (len) "LENGTHTO(send_seq_nr,recv_seq_nr)" +}; + +/* ITU-T Rec. Q.933 Figure A.3 */ +type record Q933_PvcStatusIE { + Q933_IEI iei, + uint8_t len, + Q933_PvcStatusRec pvc_status +} with { + variant "PRESENCE(iei = Q933_IEI_PVC_STATUS)" + variant (len) "LENGTHTO(pvc_status)" +}; +type record Q933_PvcStatus { + BIT2 spare, + BIT6 dlci_high, + BIT1 ext1, + BIT4 dlci_low, + BIT3 spare0, + BIT1 ext1_, + BIT3 spare0_, + boolean new, + boolean delete, + boolean active, + BIT1 reserved0 +}; +type set of Q933_PvcStatus Q933_PvcStatusRec; + +type union Q933_Payload { + Q933_STATUS_Msg status, + Q933_STATEUS_ENQ_Msg status_enq, + octetstring other +}; + +type record Q933_PDU { + OCT1 prot_disc, + OCT1 call_ref, + Q931_MessageType msg_type, + Q933_Payload body +} with { variant (body) "CROSSTAG( + status, msg_type = Q931_MSGT_STATUS; + status_enq, msg_type = Q931_MSGT_STATUS_ENQ; + other, OTHERWISE; + )" +}; + + +external function enc_Q933_PDU(in Q933_PDU si) return octetstring + with { extension "prototype(convert) encode(RAW)" }; + +external function dec_Q933_PDU(in octetstring stream) return Q933_PDU + with { extension "prototype(convert) decode(RAW)" }; + + +template (present) Q933_PDU tr_Q933_LMI_PDU := { + prot_disc := '08'O, + call_ref := '00'O, + msg_type := (Q931_MSGT_STATUS, Q931_MSGT_STATUS_ENQ), + body := ? +} + +template (value) Q933_PDU ts_Q933_LMI_PDU := { + prot_disc := '08'O, + call_ref := '00'O, + msg_type := -, + body := - +} + +template (present) Q933_PDU tr_Q933_STATUS_ENQ(template (present) Q933_TypeOfReport rep_type := ?) +modifies tr_Q933_LMI_PDU := { + msg_type := Q931_MSGT_STATUS_ENQ, + body := { + status_enq := { + rep_type := tr_Q933_RepTypeIE(rep_type), + link_int := ? + } + } +} + +template (value) Q933_PDU ts_Q933_STATUS_ENQ(template (value) Q933_TypeOfReport rep_type, + template (value) Q933_LinkIntegrityIE link_int) +modifies ts_Q933_LMI_PDU := { + msg_type := Q931_MSGT_STATUS_ENQ, + body := { + status_enq := { + rep_type := ts_Q933_RepTypeIE(rep_type), + link_int := link_int + } + } +} + +template (present) Q933_PDU tr_Q933_STATUS(template (present) Q933_TypeOfReport rep_type := ?, + template Q933_LinkIntegrityIE link_int := *, + template Q933_PvcStatusIE pvc_sts := *) +modifies tr_Q933_LMI_PDU := { + msg_type := Q931_MSGT_STATUS, + body := { + status := { + rep_type := tr_Q933_RepTypeIE(rep_type), + link_int := link_int, + pvc_status := pvc_sts + } + } +} + +template (value) Q933_PDU ts_Q933_STATUS(template (value) Q933_TypeOfReport rep_type, + template (omit) Q933_LinkIntegrityIE link_int, + template (omit) Q933_PvcStatusIE pvc_sts := omit) +modifies ts_Q933_LMI_PDU := { + msg_type := Q931_MSGT_STATUS, + body := { + status := { + rep_type := ts_Q933_RepTypeIE(rep_type), + link_int := link_int, + pvc_status := pvc_sts + } + } +} + + +template (present) Q933_LinkIntegrityIE +tr_Q933_LinkIntIE(template (present) uint8_t send_seq_nr, template (present) uint8_t recv_seq_nr) := { + iei := Q933_IEI_LINK_INTEGRITY, + len := 2, + send_seq_nr := send_seq_nr, + recv_seq_nr := recv_seq_nr +} +template (value) Q933_LinkIntegrityIE +ts_Q933_LinkIntIE(template (value) uint8_t send_seq_nr, template (value) uint8_t recv_seq_nr) := { + iei := Q933_IEI_LINK_INTEGRITY, + len := 2, + send_seq_nr := send_seq_nr, + recv_seq_nr := recv_seq_nr +} + +template (present) Q933_PvcStatus +tr_Q933_PvcStatus(integer dlci, template (present) boolean new, + template (present) boolean delete, template (present) boolean active) := { + spare := '00'B, + dlci_high := substr(int2bit(dlci, 10), 0, 6), + ext1 := '1'B, + dlci_low := substr(int2bit(dlci, 10), 6, 4), + spare0 := '000'B, + ext1_ := '1'B, + spare0_ := '000'B, + new := new, + delete := delete, + active := active, + reserved0 := '0'B +} + +template (value) Q933_PvcStatus ts_Q933_PvcStatus(integer dlci, boolean new, boolean delete, boolean active) := { + spare := '00'B, + dlci_high := substr(int2bit(dlci, 10), 0, 6), + ext1 := '1'B, + dlci_low := substr(int2bit(dlci, 10), 6, 4), + spare0 := '000'B, + ext1_ := '1'B, + spare0_ := '000'B, + new := new, + delete := delete, + active := active, + reserved0 := '0'B +} + +template (present) Q933_PvcStatusIE tr_Q933_PvcStatusIE(template (present) Q933_PvcStatusRec srec) := { + iei := Q933_IEI_PVC_STATUS, + len := ?, + pvc_status := srec +} + +template (value) Q933_PvcStatusIE ts_Q933_PvcStatusIE(template (value) Q933_PvcStatusRec srec) := { + iei := Q933_IEI_PVC_STATUS, + len := 0, // overwritten + pvc_status := srec +} + +template (present) Q933_ReportTypeIE tr_Q933_RepTypeIE(template (present) Q933_TypeOfReport rept := ?) := { + iei := Q933_IEI_REPORT_TYPE, + len := ?, + type_of_rep := rept +} + +template (value) Q933_ReportTypeIE ts_Q933_RepTypeIE(template (value) Q933_TypeOfReport rept) := { + iei := Q933_IEI_REPORT_TYPE, + len := 0, // overwritten + type_of_rep := rept +} + + + +} with { encode "RAW" variant "FIELDORDER(msb)" };