Pau Espin Pedrol | ce1d3cb | 2024-02-21 17:40:59 +0100 | [diff] [blame^] | 1 | module PCO_Types { |
| 2 | |
| 3 | /* PCO_Types, defining abstract TTCN-3 data types for the Protocol Configuration Options (PCO). |
| 4 | * |
| 5 | * (C) 2024 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | */ |
| 13 | |
| 14 | /* 3GPP TS 24.008 10.5.6.3, 3GPP TS 29.060 7.7.31 */ |
| 15 | |
| 16 | import from General_Types all; |
| 17 | import from Osmocom_Types all; |
| 18 | |
| 19 | type enumerated PCO_P { |
| 20 | PCO_P_LCP ('C021'O), |
| 21 | PCO_P_PAP ('C023'O), |
| 22 | PCO_P_CHAP ('C223'O), |
| 23 | PCO_P_IPCP ('8021'O), |
| 24 | PCO_P_PCSCF_ADDR ('0001'O), |
| 25 | PCO_P_IM_CN_SS_F ('0002'O), |
| 26 | PCO_P_DNS_IPv6_ADDR ('0003'O), |
| 27 | PCO_P_POLICY_CTRL_REJ ('0004'O), /* only in Network->MS */ |
| 28 | PCO_P_MS_SUP_NETREQ_BCI ('0005'O), |
| 29 | /* reserved */ |
| 30 | PCO_P_DSMIPv6_HA_ADDR ('0007'O), |
| 31 | PCO_P_DSMIPv6_HN_PREF ('0008'O), |
| 32 | PCO_P_DSMIPv6_v4_HA_ADDR ('0009'O), |
| 33 | PCO_P_IP_ADDR_VIA_NAS ('000a'O), /* only MS->Network */ |
| 34 | PCO_P_IPv4_ADDR_VIA_DHCP ('000b'O), /* only MS->Netowrk */ |
| 35 | PCO_P_PCSCF_IPv4_ADDR ('000c'O), |
| 36 | PCO_P_DNS_IPv4_ADDR ('000d'O), |
| 37 | PCO_P_MSISDN ('000e'O), |
| 38 | PCO_P_IFOM_SUPPORT ('000f'O), |
| 39 | PCO_P_IPv4_LINK_MTU ('0010'O), |
| 40 | PCO_P_MS_SUPP_LOC_A_TFT ('0011'O), |
| 41 | PCO_P_PCSCF_RESEL_SUP ('0012'O), /* only MS->Network */ |
| 42 | PCO_P_NBIFOM_REQ ('0013'O), |
| 43 | PCO_P_NBIFOM_MODE ('0014'O), |
| 44 | PCO_P_NONIP_LINK_MTU ('0015'O), |
| 45 | PCO_P_APN_RATE_CTRL_SUP ('0016'O), |
| 46 | PCO_P_PS_DATA_OFF_UE ('0017'O), |
| 47 | PCO_P_REL_DATA_SVC ('0018'O) |
| 48 | } with { variant "FIELDLENGTH(16)"; |
| 49 | variant "BYTEORDER(last)" }; |
| 50 | |
| 51 | /* RFC 1332 IP Control Protocol options, extensions in RFC 1877 */ |
| 52 | type enumerated IPCP_OPT { |
| 53 | IPCP_OPT_IPADDR (3), /* RFC 1332 3.3 */ |
| 54 | IPCP_OPT_PRIMARY_DNS (129), /* RFC 1877 1.1 */ |
| 55 | IPCP_OPT_SECONDARY_DNS (131) /* RFC 1877 1.2 */ |
| 56 | } with { variant "FIELDLENGTH(8)" }; |
| 57 | |
| 58 | /* RFC 1334, section 3.2. Packet Format */ |
| 59 | type enumerated PAP_CODE_ { |
| 60 | PAP_CODE__IPADDR (1), |
| 61 | PAP_CODE__PRIMARY_DNS (2), |
| 62 | PAP_CODE__SECONDARY_DNS (3) |
| 63 | } with { variant "FIELDLENGTH(8)" }; |
| 64 | |
| 65 | type set of ProtocolElement ProtocolIDList; |
| 66 | |
| 67 | type record ProtocolElement { |
| 68 | PCO_P protocolID, |
| 69 | uint8_t lengthProtoID, |
| 70 | octetstring protoIDContents |
| 71 | } with { variant (lengthProtoID) "LENGTHTO(protoIDContents)" }; |
| 72 | |
| 73 | type record PCO_DATA { |
| 74 | BIT1 extension0, |
| 75 | BIT4 spare, |
| 76 | BIT3 configProtocol, |
| 77 | ProtocolIDList protocols |
| 78 | }; |
| 79 | |
| 80 | external function enc_PCO_DATA(in PCO_DATA pco_data) return octetstring |
| 81 | with { extension "prototype(convert)" extension "encode(RAW)" } |
| 82 | |
| 83 | external function dec_PCO_DATA(in octetstring pco_payload) return PCO_DATA |
| 84 | with { extension "prototype(convert) decode(RAW)" }; |
| 85 | |
| 86 | /********************** |
| 87 | * PCO_Templates: |
| 88 | **********************/ |
| 89 | |
| 90 | template (value) ProtocolElement ts_PCO_P_OCTSTR(template (value) PCO_P protocolID, |
| 91 | template (value) uint8_t lengthProtoID := 0, |
| 92 | template (value) octetstring protoIDContents := ''O) |
| 93 | := { |
| 94 | protocolID := protocolID, |
| 95 | lengthProtoID := lengthProtoID, |
| 96 | protoIDContents := protoIDContents |
| 97 | } |
| 98 | |
| 99 | template (present) ProtocolElement tr_PCO_P_OCTSTR(template (present) PCO_P protocolID := ?, |
| 100 | template (present) uint8_t lengthProtoID := ?, |
| 101 | template (present) octetstring protoIDContents := ?) |
| 102 | := { |
| 103 | protocolID := protocolID, |
| 104 | lengthProtoID := lengthProtoID, |
| 105 | protoIDContents := protoIDContents |
| 106 | } |
| 107 | |
| 108 | |
| 109 | template (value) ProtocolElement ts_PCO_P_DNS_IPv4(template (value) octetstring dns4 := ''O) := |
| 110 | ts_PCO_P_OCTSTR(PCO_P_DNS_IPv4_ADDR, protoIDContents := dns4); |
| 111 | |
| 112 | template (value) ProtocolElement ts_PCO_P_DNS_IPv6(template (value) octetstring dns6 := ''O) := |
| 113 | ts_PCO_P_OCTSTR(PCO_P_DNS_IPv6_ADDR, protoIDContents := dns6); |
| 114 | |
| 115 | template (value) ProtocolElement ts_PCO_P_PCSCF_IPv4(template (value) octetstring pcscf4 := ''O) := |
| 116 | ts_PCO_P_OCTSTR(PCO_P_PCSCF_IPv4_ADDR, protoIDContents := pcscf4); |
| 117 | |
| 118 | template (value) ProtocolElement ts_PCO_P_PCSCF_IPv6(template (value) octetstring pcscf6 := ''O) := |
| 119 | ts_PCO_P_OCTSTR(PCO_P_PCSCF_ADDR, protoIDContents := pcscf6); |
| 120 | |
| 121 | /* PCO send base template */ |
| 122 | template (value) PCO_DATA ts_PCO(template (value) ProtocolIDList protocols := {}) := { |
| 123 | extension0 := '1'B, |
| 124 | spare := '0000'B, |
| 125 | configProtocol := '000'B, |
| 126 | protocols := protocols |
| 127 | } |
| 128 | /* PCO receive base template */ |
| 129 | template (present) PCO_DATA tr_PCO(template (present) ProtocolIDList protocols := ?) := { |
| 130 | extension0 := '1'B, |
| 131 | spare := ?, |
| 132 | configProtocol := '000'B, |
| 133 | protocols := protocols |
| 134 | } |
| 135 | |
| 136 | template (value) PCO_DATA ts_PCO_IPv4_DNS(template (value) octetstring dns4 := ''O) := |
| 137 | ts_PCO({ ts_PCO_P_DNS_IPv4(dns4) }); |
| 138 | |
| 139 | } with { encode "RAW"; variant "FIELDORDER(msb)" } |