pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36049?usp=email )

Change subject: gsup: Add PCO IE
......................................................................

gsup: Add PCO IE

This commit adds a new file PCO_Types.ttcn which allows generically
encoding decoding PCOs.

Change-Id: I9a1ae74712d6e8e0cd524ccd7fc2529b1a15dd97
---
M dia2gsup/gen_links.sh
M epdg/EPDG_Tests.ttcn
M epdg/gen_links.sh
M hlr/gen_links.sh
M library/GSUP_Templates.ttcn
M library/GSUP_Types.ttcn
A library/PCO_Types.ttcn
M msc/gen_links.sh
M selftest/gen_links.sh
M sgsn/gen_links.sh
10 files changed, 181 insertions(+), 8 deletions(-)

Approvals:
  pespin: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve




diff --git a/dia2gsup/gen_links.sh b/dia2gsup/gen_links.sh
index e343bd2..d653781 100755
--- a/dia2gsup/gen_links.sh
+++ b/dia2gsup/gen_links.sh
@@ -40,7 +40,7 @@
 FILES+="DIAMETER_Templates.ttcn DIAMETER_ts29_272_Templates.ttcn "
 FILES+="IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc
 IPA_Emulation.ttcnpp "
-FILES+="GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn "
+FILES+="PCO_Types.ttcn GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn 
"
 gen_links $DIR $FILES

 ignore_pp_results
diff --git a/epdg/EPDG_Tests.ttcn b/epdg/EPDG_Tests.ttcn
index 2ad1b32..ff026cf 100644
--- a/epdg/EPDG_Tests.ttcn
+++ b/epdg/EPDG_Tests.ttcn
@@ -8,6 +8,7 @@
 import from DNS_Helpers all;

 import from IPA_Emulation all;
+import from PCO_Types all;
 import from GSUP_Types all;
 import from GSUP_Templates all;
 import from GSUP_Emulation all;
@@ -600,7 +601,8 @@
 /* GSUP TunnelEPDG Tunnel Req + Resp, triggers S2b CreateSession Req + 
Response. */
 private function f_GSUP_EPDGTunnel_success() runs on EPDG_ConnHdlr {
        var GSUP_PDU rx_gsup;
-       GSUP.send(ts_GSUP_EPDGTunnel_REQ(g_pars.imsi));
+       var template (value) PCO_DATA pco := ts_PCO({ ts_PCO_P_DNS_IPv4, 
ts_PCO_P_PCSCF_IPv4 });
+       GSUP.send(ts_GSUP_EPDGTunnel_REQ(g_pars.imsi, pco));
        as_GTP2C_CreateSession_success();
        /* Expect a positive response back to the translator; */
        var template (present) GSUP_IEs pdp_info := {
diff --git a/epdg/gen_links.sh b/epdg/gen_links.sh
index c8eadc8..f981586 100755
--- a/epdg/gen_links.sh
+++ b/epdg/gen_links.sh
@@ -46,7 +46,7 @@
 FILES+="DIAMETER_Templates.ttcn DIAMETER_rfc5447_Templates.ttcn 
DIAMETER_ts29_273_Templates.ttcn "
 FILES+="IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc
 IPA_Emulation.ttcnpp "
-FILES+="GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn "
+FILES+="PCO_Types.ttcn GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn 
"
 FILES+="GTPv2_PrivateExtensions.ttcn GTPv2_Templates.ttcn "
 FILES+="GTPv2_CodecPort.ttcn GTPv2_CodecPort_CtrlFunctDef.cc 
GTPv2_CodecPort_CtrlFunct.ttcn GTPv2_Emulation.ttcn "
 gen_links $DIR $FILES
diff --git a/hlr/gen_links.sh b/hlr/gen_links.sh
index 52e01ba..e3a64d9 100755
--- a/hlr/gen_links.sh
+++ b/hlr/gen_links.sh
@@ -45,7 +45,7 @@

 DIR=../library
 FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn 
IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp "
-FILES+="GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn "
+FILES+="PCO_Types.ttcn GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn 
"
 FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn 
Osmocom_CTRL_Adapter.ttcn "
 FILES+="Osmocom_VTY_Functions.ttcn "
 FILES+="SS_Templates.ttcn USSD_Helpers.ttcn "
diff --git a/library/GSUP_Templates.ttcn b/library/GSUP_Templates.ttcn
index 10c682c..d886088 100644
--- a/library/GSUP_Templates.ttcn
+++ b/library/GSUP_Templates.ttcn
@@ -17,6 +17,7 @@

 import from General_Types all;
 import from Osmocom_Types all;
+import from PCO_Types all;
 import from GSUP_Types all;

 function f_gsup_postprocess_decoded(inout GSUP_PDU gsup) {
@@ -292,6 +293,14 @@
        }
 }

+template (value) GSUP_IE ts_GSUP_IE_PCO(template (value) PCO_DATA pco) := {
+       tag := OSMO_GSUP_PCO_IE,
+       len := 0,
+       val := {
+               pco := pco
+       }
+}
+
 template GSUP_PDU tr_GSUP(template GSUP_MessageType msgt := ?, template 
GSUP_IEs ies := *) := {
        msg_type := msgt,
        ies := ies
@@ -496,11 +505,13 @@

 /* EPDG Tunnel */
 template (value) GSUP_PDU ts_GSUP_EPDGTunnel_REQ(hexstring imsi,
+                                                template (value) PCO_DATA pco,
                                                 GSUP_Message_Class 
message_class := OSMO_GSUP_MESSAGE_CLASS_IPSEC_EPDG,
                                                 GSUP_CnDomain dom := 
OSMO_GSUP_CN_DOMAIN_PS,
                                                 template (omit) octetstring 
source_name := omit) :=
        ts_GSUP(OSMO_GSUP_MSGT_EPDG_TUNNEL_REQUEST, f_gen_ts_ies(imsi,
                                                                 message_class 
:= message_class,
+                                                                pco := pco,
                                                                 dom := dom,
                                                                 source_name := 
source_name));

@@ -1170,6 +1181,7 @@
                           template (omit) boolean pdp_info_compl := omit,
                           template (omit) GSUP_Message_Class message_class := 
omit,
                           template (omit) hexstring imei := omit,
+                          template (omit) PCO_DATA pco := omit,
                           template (omit) GSUP_CnDomain dom := omit,
                           template (omit) octetstring source_name := omit,
                           template (omit) octetstring destination_name := omit
@@ -1190,6 +1202,10 @@
                ies := ies & { valueof(ts_GSUP_IE_IMEI(valueof(imei))) };
        }

+       if (isvalue(pco)) {
+               ies := ies & { valueof(ts_GSUP_IE_PCO(valueof(pco))) };
+       }
+
        if (isvalue(message_class)) {
                ies := ies & { 
valueof(ts_GSUP_IE_Message_Class(valueof(message_class))) };
        }
diff --git a/library/GSUP_Types.ttcn b/library/GSUP_Types.ttcn
index 0bab1d6..078347e 100644
--- a/library/GSUP_Types.ttcn
+++ b/library/GSUP_Types.ttcn
@@ -17,6 +17,7 @@

 import from General_Types all;
 import from Osmocom_Types all;
+import from PCO_Types all;

 type enumerated GSUP_IEI {
        OSMO_GSUP_IMSI_IE               ('01'O),
@@ -33,6 +34,7 @@
        OSMO_GSUP_ACCESS_POINT_NAME_IE  ('12'O),
        OSMO_GSUP_PDP_QOS_IE            ('13'O),
        OSMO_GSUP_CHARG_CHAR_IE         ('14'O),
+       OSMO_GSUP_PCO_IE                ('15'O),

        OSMO_GSUP_RAND_IE               ('20'O),
        OSMO_GSUP_SRES_IE               ('21'O),
@@ -257,10 +259,11 @@
                                 hlr_number, tag = OSMO_GSUP_HLR_NUMBER_IE;
                                 cn_domain, tag = OSMO_GSUP_CN_DOMAIN_IE;
                                 pdp_info, tag = OSMO_GSUP_PDP_INFO_IE;
+                                pdp_address, tag = OSMO_GSUP_PDP_ADDRESS_IE;
                                 apn, tag = OSMO_GSUP_ACCESS_POINT_NAME_IE;
                                 pdp_qos, tag = OSMO_GSUP_PDP_QOS_IE;
-                                pdp_address, tag = OSMO_GSUP_PDP_ADDRESS_IE;
                                 charg_char, tag = OSMO_GSUP_CHARG_CHAR_IE;
+                                pco, tag = OSMO_GSUP_PCO_IE;
                                 pdp_ctx_id, tag = OSMO_GSUP_PDP_CONTEXT_ID_IE;
                                 session_state, tag = 
OSMO_GSUP_SESSION_STATE_IE;
                                 session_id, tag = OSMO_GSUP_SESSION_ID_IE;
@@ -323,6 +326,7 @@
        octetstring     pdp_qos,
        GSUP_PDP_Address        pdp_address,
        octetstring     charg_char,
+       PCO_DATA        pco,
        /* Session information */
        GSUP_SessionState       session_state,
        OCT4                    session_id,
diff --git a/library/PCO_Types.ttcn b/library/PCO_Types.ttcn
new file mode 100644
index 0000000..22b475a
--- /dev/null
+++ b/library/PCO_Types.ttcn
@@ -0,0 +1,139 @@
+module PCO_Types {
+
+/* PCO_Types, defining abstract TTCN-3 data types for the Protocol 
Configuration Options (PCO).
+ *
+ * (C) 2024 by sysmocom - s.f.m.c. GmbH <i...@sysmocom.de>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+/* 3GPP TS 24.008 10.5.6.3, 3GPP TS 29.060 7.7.31 */
+
+import from General_Types all;
+import from Osmocom_Types all;
+
+type enumerated PCO_P {
+       PCO_P_LCP                       ('C021'O),
+       PCO_P_PAP                       ('C023'O),
+       PCO_P_CHAP                      ('C223'O),
+       PCO_P_IPCP                      ('8021'O),
+       PCO_P_PCSCF_ADDR                ('0001'O),
+       PCO_P_IM_CN_SS_F                ('0002'O),
+       PCO_P_DNS_IPv6_ADDR             ('0003'O),
+       PCO_P_POLICY_CTRL_REJ           ('0004'O),      /* only in Network->MS 
*/
+       PCO_P_MS_SUP_NETREQ_BCI         ('0005'O),
+       /* reserved */
+       PCO_P_DSMIPv6_HA_ADDR           ('0007'O),
+       PCO_P_DSMIPv6_HN_PREF           ('0008'O),
+       PCO_P_DSMIPv6_v4_HA_ADDR        ('0009'O),
+       PCO_P_IP_ADDR_VIA_NAS           ('000a'O),      /* only MS->Network */
+       PCO_P_IPv4_ADDR_VIA_DHCP        ('000b'O),      /* only MS->Netowrk */
+       PCO_P_PCSCF_IPv4_ADDR           ('000c'O),
+       PCO_P_DNS_IPv4_ADDR             ('000d'O),
+       PCO_P_MSISDN                    ('000e'O),
+       PCO_P_IFOM_SUPPORT              ('000f'O),
+       PCO_P_IPv4_LINK_MTU             ('0010'O),
+       PCO_P_MS_SUPP_LOC_A_TFT         ('0011'O),
+       PCO_P_PCSCF_RESEL_SUP           ('0012'O),      /* only MS->Network */
+       PCO_P_NBIFOM_REQ                ('0013'O),
+       PCO_P_NBIFOM_MODE               ('0014'O),
+       PCO_P_NONIP_LINK_MTU            ('0015'O),
+       PCO_P_APN_RATE_CTRL_SUP         ('0016'O),
+       PCO_P_PS_DATA_OFF_UE            ('0017'O),
+       PCO_P_REL_DATA_SVC              ('0018'O)
+} with { variant "FIELDLENGTH(16)";
+        variant "BYTEORDER(last)" };
+
+/* RFC 1332 IP Control Protocol options, extensions in RFC 1877 */
+type enumerated IPCP_OPT {
+       IPCP_OPT_IPADDR         (3), /* RFC 1332 3.3 */
+       IPCP_OPT_PRIMARY_DNS    (129), /* RFC 1877 1.1 */
+       IPCP_OPT_SECONDARY_DNS  (131) /* RFC 1877 1.2 */
+} with { variant "FIELDLENGTH(8)" };
+
+/* RFC 1334, section 3.2. Packet Format */
+type enumerated PAP_CODE_ {
+       PAP_CODE__IPADDR        (1),
+       PAP_CODE__PRIMARY_DNS   (2),
+       PAP_CODE__SECONDARY_DNS (3)
+} with { variant "FIELDLENGTH(8)" };
+
+type set of ProtocolElement ProtocolIDList;
+
+type record ProtocolElement {
+       PCO_P           protocolID,
+       uint8_t         lengthProtoID,
+       octetstring     protoIDContents
+} with { variant (lengthProtoID) "LENGTHTO(protoIDContents)" };
+
+type record PCO_DATA {
+       BIT1            extension0,
+       BIT4            spare,
+       BIT3            configProtocol,
+       ProtocolIDList  protocols
+};
+
+external function enc_PCO_DATA(in PCO_DATA pco_data) return octetstring
+with { extension "prototype(convert)" extension "encode(RAW)" }
+
+external function dec_PCO_DATA(in octetstring pco_payload) return PCO_DATA
+with { extension "prototype(convert) decode(RAW)" };
+
+/**********************
+ * PCO_Templates:
+ **********************/
+
+template (value) ProtocolElement ts_PCO_P_OCTSTR(template (value) PCO_P 
protocolID,
+                                         template (value) uint8_t 
lengthProtoID := 0,
+                                         template (value) octetstring 
protoIDContents := ''O)
+:= {
+       protocolID := protocolID,
+       lengthProtoID := lengthProtoID,
+       protoIDContents := protoIDContents
+}
+
+template (present) ProtocolElement tr_PCO_P_OCTSTR(template (present) PCO_P 
protocolID := ?,
+                                           template (present) uint8_t 
lengthProtoID := ?,
+                                           template (present) octetstring 
protoIDContents := ?)
+:= {
+       protocolID := protocolID,
+       lengthProtoID := lengthProtoID,
+       protoIDContents := protoIDContents
+}
+
+
+template (value) ProtocolElement ts_PCO_P_DNS_IPv4(template (value) 
octetstring dns4 := ''O) :=
+       ts_PCO_P_OCTSTR(PCO_P_DNS_IPv4_ADDR, protoIDContents := dns4);
+
+template (value) ProtocolElement ts_PCO_P_DNS_IPv6(template (value) 
octetstring dns6 := ''O) :=
+       ts_PCO_P_OCTSTR(PCO_P_DNS_IPv6_ADDR, protoIDContents := dns6);
+
+template (value) ProtocolElement ts_PCO_P_PCSCF_IPv4(template (value) 
octetstring pcscf4 := ''O) :=
+       ts_PCO_P_OCTSTR(PCO_P_PCSCF_IPv4_ADDR, protoIDContents := pcscf4);
+
+template (value) ProtocolElement ts_PCO_P_PCSCF_IPv6(template (value) 
octetstring pcscf6 := ''O) :=
+       ts_PCO_P_OCTSTR(PCO_P_PCSCF_ADDR, protoIDContents := pcscf6);
+
+/* PCO send base template */
+template (value) PCO_DATA ts_PCO(template (value) ProtocolIDList protocols := 
{}) := {
+       extension0 := '1'B,
+       spare := '0000'B,
+       configProtocol := '000'B,
+       protocols := protocols
+}
+/* PCO receive base template */
+template (present) PCO_DATA tr_PCO(template (present) ProtocolIDList protocols 
:= ?) := {
+       extension0 := '1'B,
+       spare := ?,
+       configProtocol := '000'B,
+       protocols := protocols
+}
+
+template (value) PCO_DATA ts_PCO_IPv4_DNS(template (value) octetstring dns4 := 
''O) :=
+       ts_PCO({ ts_PCO_P_DNS_IPv4(dns4) });
+
+} with { encode "RAW"; variant "FIELDORDER(msb)" }
diff --git a/msc/gen_links.sh b/msc/gen_links.sh
index 8577208..8463976 100755
--- a/msc/gen_links.sh
+++ b/msc/gen_links.sh
@@ -94,7 +94,7 @@
 DIR=../library
 FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn 
MNCC_Types.ttcn MNCC_EncDec.cc MNCC_CodecPort.ttcn mncc.h MNCC_Emulation.ttcn 
Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc "
 FILES+="IPA_Types.ttcn IPA_Emulation.ttcnpp IPA_CodecPort.ttcn 
IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc "
-FILES+="GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn "
+FILES+="PCO_Types.ttcn GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn 
"
 FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn 
Osmocom_CTRL_Adapter.ttcn L3_Templates.ttcn RLCMAC_CSN1_Templates.ttcn 
RLCMAC_CSN1_Types.ttcn L3_Common.ttcn "
 FILES+="RAN_Emulation.ttcnpp BSSAP_CodecPort.ttcn BSSMAP_Templates.ttcn 
RAN_Adapter.ttcnpp MGCP_Types.ttcn MGCP_Templates.ttcn 
MGCP_CodecPort_CtrlFunct.ttcn MGCP_Emulation.ttcn "
 FILES+="RTP_CodecPort.ttcn RTP_CodecPort_CtrlFunctDef.cc "
diff --git a/selftest/gen_links.sh b/selftest/gen_links.sh
index 23201a8..1a3bbe1 100755
--- a/selftest/gen_links.sh
+++ b/selftest/gen_links.sh
@@ -39,7 +39,7 @@
 gen_links $DIR $FILES

 DIR=../library
-FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn 
IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn 
BSSMAP_Templates.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn 
GSM_RR_Types.ttcn GSM_RestOctets.ttcn RSL_Types.ttcn BSSAP_CodecPort.ttcn 
Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn GSUP_Types.ttcn 
Native_Functions.ttcn Native_FunctionDefs.cc"
+FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn 
IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn 
IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp L3_Templates.ttcn 
BSSMAP_Templates.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn 
GSM_RR_Types.ttcn GSM_RestOctets.ttcn RSL_Types.ttcn BSSAP_CodecPort.ttcn 
Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn PCO_Types.ttcn 
GSUP_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc"
 gen_links $DIR $FILES

 ignore_pp_results
diff --git a/sgsn/gen_links.sh b/sgsn/gen_links.sh
index afe6b02..3aa2d38 100755
--- a/sgsn/gen_links.sh
+++ b/sgsn/gen_links.sh
@@ -92,7 +92,7 @@
 FILES+="RAN_Emulation.ttcnpp RAN_Adapter.ttcnpp SCCP_Templates.ttcn "
 # IPA_Emulation + dependencies
 FILES+="IPA_Types.ttcn IPA_Emulation.ttcnpp IPA_CodecPort.ttcn 
IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc 
Native_Functions.ttcn Native_FunctionDefs.cc "
-FILES+="GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn "
+FILES+="PCO_Types.ttcn GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn 
"
 FILES+="GTP_CodecPort.ttcn GTP_CodecPort_CtrlFunct.ttcn 
GTP_CodecPort_CtrlFunctDef.cc GTP_Emulation.ttcn GTP_Templates.ttcn 
IPCP_Types.ttcn RAW_NS.ttcnpp "
 gen_links $DIR $FILES


--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36049?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I9a1ae74712d6e8e0cd524ccd7fc2529b1a15dd97
Gerrit-Change-Number: 36049
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: lynxis lazus <lyn...@fe80.eu>
Gerrit-Reviewer: osmith <osm...@sysmocom.de>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to