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

Change subject: Introduce bsf testsuite
......................................................................

Introduce bsf testsuite

Introduce a new "bsf" testsuite which runs against open5gs-bsfd.
Start with a couple tests which already contain most of the
infrastructure needed and makes it easy to extend later on.

Related: SYS#7073
Change-Id: I4d8aabfbc3bdbc6fe966ca946a7263d345eef739
---
M Makefile
A bsf/BSF_Tests.cfg
A bsf/BSF_Tests.default
A bsf/BSF_Tests.ttcn
A bsf/ConnHdlr.ttcn
A bsf/README.md
A bsf/expected-results.xml
A bsf/gen_links.sh
A bsf/open5gs-bsf.yaml
A bsf/regen_makefile.sh
A bsf/testenv.cfg
A bsf/testsrcdir.cfg
M library/TS29521_Nbsf_Management_Templates.ttcn
M pcf/ConnHdlr.ttcn
14 files changed, 798 insertions(+), 1 deletion(-)

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




diff --git a/Makefile b/Makefile
index d583aad..565fb33 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,7 @@
        ausf \
        bsc \
        bsc-nat \
+       bsf \
        bts \
        cbc \
        ccid \
diff --git a/bsf/BSF_Tests.cfg b/bsf/BSF_Tests.cfg
new file mode 100644
index 0000000..8e3b7b8
--- /dev/null
+++ b/bsf/BSF_Tests.cfg
@@ -0,0 +1,23 @@
+[ORDERED_INCLUDE]
+# Common configuration, shared between test suites
+"../Common.cfg"
+# testsuite specific configuration, not expected to change
+"./BSF_Tests.default"
+
+# Local configuration below
+
+[LOGGING]
+
+[TESTPORT_PARAMETERS]
+
+[MODULE_PARAMETERS]
+BSF_Tests.mp_bsf_hostname := "127.0.0.15";
+BSF_Tests.mp_bsf_sbi_port := 7777;
+BSF_Tests.mp_scp_local_ip := "127.0.0.200";
+BSF_Tests.mp_scp_local_port := 7777;
+BSF_Tests.mp_pcf_local_ip := "127.0.0.6";
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+BSF_Tests.control
diff --git a/bsf/BSF_Tests.default b/bsf/BSF_Tests.default
new file mode 100644
index 0000000..b03f59e
--- /dev/null
+++ b/bsf/BSF_Tests.default
@@ -0,0 +1,12 @@
+[LOGGING]
+FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC;
+
+[TESTPORT_PARAMETERS]
+*.TCP.noDelay := "yes" // turn off nagle
+*.HTTP.use_notification_ASPs := "yes"
+
+[MODULE_PARAMETERS]
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
diff --git a/bsf/BSF_Tests.ttcn b/bsf/BSF_Tests.ttcn
new file mode 100644
index 0000000..ea4227c
--- /dev/null
+++ b/bsf/BSF_Tests.ttcn
@@ -0,0 +1,154 @@
+/* BSF test suite in TTCN-3 (3GPP TS 29.521)
+ * (C) 2026 by sysmocom - s.f.m.c. GmbH <[email protected]>
+ * All rights reserved.
+ * Author: Pau Espin Pedrol <[email protected]>
+ *
+ * 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
+ */
+
+module BSF_Tests {
+
+import from General_Types all;
+import from Native_Functions all;
+import from IPL4asp_Types all;
+import from Misc_Helpers all;
+
+import from Osmocom_Types all;
+import from GSM_Types all;
+
+import from TCCEncoding_Functions all;
+
+import from HTTP2_Adapter all;
+import from HTTP2_Server_Emulation all;
+
+import from ConnHdlr all;
+
+modulepar {
+       charstring mp_bsf_hostname := "127.0.0.15";
+       integer mp_bsf_sbi_port := 7777;
+
+       charstring mp_scp_local_ip := "127.0.0.200";
+       integer mp_scp_local_port := 7777;
+
+       /* IP address at which we listen for HTTP2/SBI to emulate a AUSF in 
ttcn3 */
+       charstring mp_pcf_local_ip := "127.0.0.6";
+
+       GsmMcc mp_mcc := '999'H;
+       GsmMnc mp_mnc := '70'H;
+       HEX15n mp_imsi := '999700000000000'H;
+}
+
+type component MTC_CT extends HTTP2_CT, HTTP2_ConnHdlr {
+       /* emulated SCP */
+       var HTTP2_Server_Emulation_CT vc_HTTP2_SRV_SCP;
+
+       timer g_Tguard := 30.0;
+}
+
+private function f_init_http2_srv(charstring id) runs on MTC_CT {
+       id := id & "-HTTP2SRV";
+
+       var Http2ServerEmulationCfg http2_srv_cfg := {
+               http2_bind_ip := mp_scp_local_ip,
+               http2_bind_port := mp_scp_local_port,
+               one_req_per_conn := false
+       };
+
+       vc_HTTP2_SRV_SCP := HTTP2_Server_Emulation_CT.create(id) alive;
+       vc_HTTP2_SRV_SCP.start(HTTP2_Server_Emulation.main(http2_srv_cfg));
+
+       connect(self:HTTP2_CONN_PROC[HTTP2_CONN_SCP], 
vc_HTTP2_SRV_SCP:CONN_PROC);
+}
+
+
+private function f_init(integer imsi_suffix := 0, float t_guard := 30.0) runs 
on MTC_CT {
+       var charstring id := testcasename();
+
+       g_Tguard.start(t_guard);
+       activate(as_Tguard());
+
+       f_init_http2_srv(id);
+}
+
+private function f_shutdown() runs on MTC_CT {
+       f_http2_server_close_conn_all();
+       setverdict(pass);
+}
+
+private function f_start_handler_create()
+runs on MTC_CT return ConnHdlr
+{
+       var ConnHdlr vc_conn;
+       var charstring id := testcasename();
+
+       vc_conn := ConnHdlr.create(id);
+
+       if (isbound(vc_HTTP2_SRV_SCP)) {
+               connect(vc_conn:HTTP2_CONN[HTTP2_CONN_SCP], 
vc_HTTP2_SRV_SCP:CONN);
+               connect(vc_conn:HTTP2_CONN_PROC[HTTP2_CONN_SCP], 
vc_HTTP2_SRV_SCP:CONN_PROC);
+       }
+
+       return vc_conn;
+}
+
+private function f_start_handler_run(ConnHdlr vc_conn, void_fn fn, 
ConnHdlrPars pars) runs on MTC_CT
+{
+       vc_conn.start(f_ConnHdlr_init(fn, pars));
+}
+
+/* start a connection handler with given parameters */
+private function f_start_handler(void_fn fn, ConnHdlrPars pars)
+runs on MTC_CT return ConnHdlr {
+       var ConnHdlr vc_conn;
+       vc_conn := f_start_handler_create();
+       f_start_handler_run(vc_conn, fn, pars);
+       return vc_conn;
+}
+
+private altstep as_Tguard() runs on MTC_CT {
+       [] g_Tguard.timeout {
+               Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard 
timeout");
+       }
+}
+
+/* 3GPP TS 29.521 4.2.2.2 Register a new PCF for a PDU Session binding 
information +
+ * 3GPP TS 29.521 4.2.3.2 Deregister an individual PCF for a PDU Session 
binding information */
+private function f_TC_pcfBindings() runs on ConnHdlr {
+       f_nbsf_mgmt_post_pcfbindings();
+       f_nbsf_mgmt_delete_individual_pcfbinding();
+       setverdict(pass);
+}
+testcase TC_pcfBindings() runs on MTC_CT {
+       var ConnHdlr vc_conn;
+       var ConnHdlrPars pars := f_ConnHdlrPars(0);
+       f_init();
+       vc_conn := f_start_handler(refers(f_TC_pcfBindings), pars);
+       vc_conn.done;
+       f_shutdown();
+}
+
+/* 3GPP TS 29.521 4.2.2.3 Register a new PCF for a UE binding information +
+ * 3GPP TS 29.521 4.2.3.3 Deregister an individual PCF for a UE binding 
information */
+private function f_TC_pcf_ue_bindings() runs on ConnHdlr {
+       f_nbsf_mgmt_post_pcf_ue_bindings();
+       f_nbsf_mgmt_delete_individual_pcf_ue_binding();
+       setverdict(pass);
+}
+testcase TC_pcf_ue_bindings() runs on MTC_CT {
+       var ConnHdlr vc_conn;
+       var ConnHdlrPars pars := f_ConnHdlrPars(0);
+       f_init();
+       vc_conn := f_start_handler(refers(f_TC_pcf_ue_bindings), pars);
+       vc_conn.done;
+       f_shutdown();
+}
+
+control {
+       execute( TC_pcfBindings() );
+       execute( TC_pcf_ue_bindings() );
+}
+
+}
diff --git a/bsf/ConnHdlr.ttcn b/bsf/ConnHdlr.ttcn
new file mode 100644
index 0000000..74594d7
--- /dev/null
+++ b/bsf/ConnHdlr.ttcn
@@ -0,0 +1,355 @@
+/* BSF test suite in TTCN-3 (3GPP TS 29.521), ConnHdlr
+ * (C) 2026 by sysmocom - s.f.m.c. GmbH <[email protected]>
+ * All rights reserved.
+ * Author: Pau Espin Pedrol <[email protected]>
+ *
+ * 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
+ */
+
+module ConnHdlr {
+
+import from TCCEncoding_Functions all;
+
+import from General_Types all;
+import from Native_Functions all;
+import from IPL4asp_Types all;
+import from Misc_Helpers all;
+
+import from Osmocom_Types all;
+import from GSM_Types all;
+
+import from HTTP2_Types all;
+import from HTTP2_Templates all;
+import from HTTP2_Functions all;
+import from HTTP2_Msg all;
+import from HTTP2_Adapter all;
+import from HTTP2_Server_Emulation all;
+
+import from Prometheus_Checker all;
+
+import from TS29571_CommonData_Templates all;
+import from TS29521_Nbsf_Management all;
+import from TS29521_Nbsf_Management_Templates all;
+
+import from BSF_Tests all;
+
+const integer HTTP2_CONN_SCP := 0;
+
+/* These are a preset of path matches which can be applied through the entire 
lifecycle of the session: */
+function f_http2_server_path_match()
+runs on ConnHdlr return charstring {
+       var charstring imsi_match := "*imsi-" & g_pars.imsi_str & "*";
+       return imsi_match;
+}
+
+type record ConnHdlrPars {
+       integer idx,
+       integer pdu_sess_id,
+       hexstring imsi,
+       charstring imsi_str,
+       charstring serving_network,
+       NfInstanceId pcf_instance_id,
+       charstring binding_id optional
+}
+
+type component ConnHdlr extends HTTP2_CT, HTTP2_ConnHdlr, 
Prometheus_Checker_CT {
+       var ConnHdlrPars g_pars;
+}
+
+type function void_fn() runs on ConnHdlr;
+
+function f_ConnHdlrPars(integer idx := 0) return ConnHdlrPars
+{
+       var hexstring imsi := f_concat_pad(lengthof(mp_imsi), substr(mp_imsi, 
0, lengthof(mp_imsi) - 6), idx);
+       var charstring imsi_str := f_dec_TBCD(imsi_hex2oct(imsi));
+       var template (value) ConnHdlrPars pars := {
+               idx := idx,
+               pdu_sess_id := idx + 1,
+               imsi := imsi,
+               imsi_str := imsi_str,
+               serving_network := "5G:mnc070.mcc999.3gppnetwork.org", /* TODO: 
set based on mp_mcc and mp_mnc */
+               pcf_instance_id := "pcf-instance-id-" & int2str(idx),
+               binding_id := omit
+       };
+       return valueof(pars);
+}
+
+function f_ConnHdlr_init(void_fn fn, ConnHdlrPars pars) runs on ConnHdlr {
+       /* make parameters available via component variable */
+       g_pars := pars;
+
+       /* Setup */
+       /* Register SCP HTTP2 sever, where IUT will send all SBI requests: */
+       f_http2_server_emu_register(f_http2_server_path_match(), idx := 
HTTP2_CONN_SCP);
+       f_http2_adapter_init();
+
+       fn.apply();
+
+       /* Cleanup */
+       f_http2_server_emu_unregister(f_http2_server_path_match(), idx := 
HTTP2_CONN_SCP);
+}
+
+function f_http2_adapter_connect_pcf(integer idx := 0)
+runs on ConnHdlr {
+       f_http2_adapter_connect(mp_bsf_hostname, mp_bsf_sbi_port, 
mp_pcf_local_ip, idx := idx);
+}
+
+function f_http2_adapter_connect_send_bsf(template (value) HTTP2_Msg 
http2_msg, integer idx := 0)
+runs on ConnHdlr {
+       f_http2_adapter_connect_pcf(idx := idx);
+       f_http2_adapter_send(http2_msg);
+}
+
+/********************************************
+ * SCP
+/*******************************************/
+const charstring SCP_uri_hostport := mp_scp_local_ip & ":" & 
int2str(mp_scp_local_port);
+const charstring SCP_uri_prefix := "http://"; & SCP_uri_hostport;
+
+/****************************************************
+ * Nbsf_Management (SBI) Emulated PCF, 3GPP TS 29.521
+ ****************************************************/
+const charstring c_Nbsf_uri_hostport := mp_bsf_hostname & ":" & 
int2str(mp_bsf_sbi_port);
+const charstring c_Nbsf_uri_prefix := "http://"; & c_Nbsf_uri_hostport;
+
+/* 5.3.2.3.1 Resource: BSF for a PDU Session Bindings (POST) */
+private function f_nbsf_mgmt_prepare_post_pcfbindings(PcfBinding pcf_binding)
+runs on ConnHdlr return HTTP2_Msg {
+       var octetstring pcf_binding_enc;
+       var integer http2_idx;
+       var integer http2_stream_id;
+       var template (value) HTTP2_Msg http2_tx;
+
+       pcf_binding_enc := f_enc_PcfBinding(pcf_binding);
+
+       http2_idx := f_http2_adapter_find_free_idx();
+       http2_stream_id := f_http2_adapter_next_stream_id(http2_idx);
+       http2_tx := ts_HTTP2_Msg(http2_idx,
+                                http2_stream_id,
+                                hb := {
+                                       pseudo_headers := 
ts_HTTP2_pseudo_headers_Req(method := "POST",
+                                                                               
      scheme := "http",
+                                                                               
      authority := c_Nbsf_uri_hostport,
+                                                                               
      path := c_Nbsf_Management_path_pcfBindings),
+                                       headers := {
+                                               
ts_HTTP2_Hdr_content_type("application/json"),
+                                               
ts_HTTP2_Hdr_accept("application/json"),
+                                               
ts_HTTP2_Hdr_user_agent("ttcn3-pcf"),
+                                               
ts_HTTP2_Hdr_accept_encoding("gzip")
+                                       }
+                                },
+                                body := ts_HTTP2_Data_frame(http2_stream_id,
+                                                            end_stream_flag := 
true,
+                                                            data := 
pcf_binding_enc));
+       return valueof(http2_tx);
+}
+
+/* 4.2.2.2 Register a new PCF for a PDU Session binding information */
+function f_nbsf_mgmt_post_pcfbindings()
+runs on ConnHdlr {
+       var HTTP2_Msg http2_tx;
+       var HTTP2_Msg http2_rx;
+       var template (present) HTTP2_Msg http2_exp_rx;
+       var template (value) PcfBinding pcf_binding;
+
+       pcf_binding := ts_PcfBinding(supi := ts_sbi_Supi(g_pars.imsi_str),
+                                    ipv4Addr := mp_pcf_local_ip,
+                                    dnn := "internet",
+                                    pcfIpEndPoints := { 
ts_IpEndPoint(ipv4Address := mp_pcf_local_ip,
+                                                                      port_ := 
mp_scp_local_port) },
+                                    snssai := 
TS29521_Nbsf_Management_Templates.ts_Snssai(1),
+                                    pcfId := g_pars.pcf_instance_id);
+
+       http2_tx := f_nbsf_mgmt_prepare_post_pcfbindings(valueof(pcf_binding));
+       f_http2_adapter_connect_send_bsf(http2_tx, idx := http2_tx.conn_id);
+
+       /* 3GPP TS 29.521 Table 5.3.2.3.1-3 */
+       http2_exp_rx :=
+               tr_HTTP2_Msg(http2_tx.conn_id,
+                            http2_tx.stream_id,
+                            tr_HTTP2_header_block(pseudo_headers := 
tr_HTTP2_pseudo_headers_Resp(201)),
+                            tr_HTTP2_Data_frame(stream_id := 
http2_tx.stream_id,
+                                                end_stream_flag := true,
+                                                data := decmatch 
tr_PcfBinding));
+       as_http2_adapter_receive(http2_rx, http2_exp_rx, idx := 
http2_tx.conn_id);
+
+       /* Store obtained bindingId: */
+       var charstring created_location := 
valueof(f_HTTP2_header_list_find_header(http2_rx.hb.headers, 
c_HTTP2_HDR_location));
+       g_pars.binding_id := regexp(created_location, c_Nbsf_uri_prefix & 
c_Nbsf_Management_path_pcfBindings & "/(?+)", 0);
+
+       f_http2_adapter_close(idx := http2_tx.conn_id);
+       setverdict(pass);
+}
+
+/* 5.3.3.3.1 Resource: Individual PCF for a PDU Session Binding (DELETE) */
+private function f_nbsf_mgmt_prepare_delete_individual_pcfbinding()
+runs on ConnHdlr return HTTP2_Msg {
+       var integer http2_idx;
+       var integer http2_stream_id;
+       var template (value) HTTP2_Msg http2_tx;
+
+       http2_idx := f_http2_adapter_find_free_idx();
+       http2_stream_id := f_http2_adapter_next_stream_id(http2_idx);
+       http2_tx := ts_HTTP2_Msg(http2_idx,
+                                http2_stream_id,
+                                hb := {
+                                       pseudo_headers := 
ts_HTTP2_pseudo_headers_Req(method := "DELETE",
+                                                                               
      scheme := "http",
+                                                                               
      authority := c_Nbsf_uri_hostport,
+                                                                               
      path := 
ts_Nbsf_Management_path_individual_pcf_pdu_sess_binding(g_pars.binding_id)),
+                                       headers := {
+                                               
ts_HTTP2_Hdr_content_type("application/json"),
+                                               
ts_HTTP2_Hdr_accept("application/json"),
+                                               
ts_HTTP2_Hdr_user_agent("ttcn3-pcf"),
+                                               
ts_HTTP2_Hdr_accept_encoding("gzip")
+                                       }
+                                },
+                                body := omit);
+       return valueof(http2_tx);
+}
+
+/* 4.2.3.2 Deregister an individual PCF for a PDU Session binding information 
*/
+function f_nbsf_mgmt_delete_individual_pcfbinding()
+runs on ConnHdlr {
+       var HTTP2_Msg http2_tx;
+       var HTTP2_Msg http2_rx;
+       var template (present) HTTP2_Msg http2_exp_rx;
+
+       http2_tx := f_nbsf_mgmt_prepare_delete_individual_pcfbinding();
+       f_http2_adapter_connect_send_bsf(http2_tx, idx := http2_tx.conn_id);
+
+       /* 3GPP TS 29.521 Table 5.3.2.3.1-3 */
+       http2_exp_rx :=
+               tr_HTTP2_Msg(http2_tx.conn_id,
+                            http2_tx.stream_id,
+                            tr_HTTP2_header_block(pseudo_headers := 
tr_HTTP2_pseudo_headers_Resp(204)),
+                            omit);
+       as_http2_adapter_receive(http2_rx, http2_exp_rx, idx := 
http2_tx.conn_id);
+
+       g_pars.binding_id := omit;
+
+       f_http2_adapter_close(idx := http2_tx.conn_id);
+       setverdict(pass);
+}
+
+/* 5.3.7.3.1 Resource: PCF for a UE Bindings (POST) */
+private function f_nbsf_mgmt_prepare_post_pcf_ue_bindings(PcfForUeBinding 
pcf_ue_binding)
+runs on ConnHdlr return HTTP2_Msg {
+       var octetstring pcf_ue_binding_enc;
+       var integer http2_idx;
+       var integer http2_stream_id;
+       var template (value) HTTP2_Msg http2_tx;
+
+       pcf_ue_binding_enc := f_enc_PcfForUeBinding(pcf_ue_binding);
+
+       http2_idx := f_http2_adapter_find_free_idx();
+       http2_stream_id := f_http2_adapter_next_stream_id(http2_idx);
+       http2_tx := ts_HTTP2_Msg(http2_idx,
+                                http2_stream_id,
+                                hb := {
+                                       pseudo_headers := 
ts_HTTP2_pseudo_headers_Req(method := "POST",
+                                                                               
      scheme := "http",
+                                                                               
      authority := c_Nbsf_uri_hostport,
+                                                                               
      path := c_Nbsf_Management_path_pcf_ue_bindings),
+                                       headers := {
+                                               
ts_HTTP2_Hdr_content_type("application/json"),
+                                               
ts_HTTP2_Hdr_accept("application/json"),
+                                               
ts_HTTP2_Hdr_user_agent("ttcn3-pcf"),
+                                               
ts_HTTP2_Hdr_accept_encoding("gzip")
+                                       }
+                                },
+                                body := ts_HTTP2_Data_frame(http2_stream_id,
+                                                            end_stream_flag := 
true,
+                                                            data := 
pcf_ue_binding_enc));
+       return valueof(http2_tx);
+}
+
+/* 4.2.2.3 Register a new PCF for a UE binding information */
+function f_nbsf_mgmt_post_pcf_ue_bindings()
+runs on ConnHdlr {
+       var HTTP2_Msg http2_tx;
+       var HTTP2_Msg http2_rx;
+       var template (present) HTTP2_Msg http2_exp_rx;
+       var template (value) PcfForUeBinding pcf_ue_binding;
+
+       pcf_ue_binding := ts_PcfForUeBinding(supi := 
ts_sbi_Supi(g_pars.imsi_str),
+                                            pcfForUeIpEndPoints := { 
ts_IpEndPoint(ipv4Address := mp_pcf_local_ip,
+                                                                               
     port_ := mp_scp_local_port) },
+                                            pcfId := g_pars.pcf_instance_id);
+
+       http2_tx := 
f_nbsf_mgmt_prepare_post_pcf_ue_bindings(valueof(pcf_ue_binding));
+       f_http2_adapter_connect_send_bsf(http2_tx, idx := http2_tx.conn_id);
+
+       /* 3GPP TS 29.521 Table 5.3.2.3.1-3 */
+       http2_exp_rx :=
+               tr_HTTP2_Msg(http2_tx.conn_id,
+                            http2_tx.stream_id,
+                            tr_HTTP2_header_block(pseudo_headers := 
tr_HTTP2_pseudo_headers_Resp(201)),
+                            tr_HTTP2_Data_frame(stream_id := 
http2_tx.stream_id,
+                                                end_stream_flag := true,
+                                                data := decmatch 
tr_PcfForUeBinding));
+       as_http2_adapter_receive(http2_rx, http2_exp_rx, idx := 
http2_tx.conn_id);
+
+       /* Store obtained bindingId: */
+       var charstring created_location := 
valueof(f_HTTP2_header_list_find_header(http2_rx.hb.headers, 
c_HTTP2_HDR_location));
+       g_pars.binding_id := regexp(created_location, c_Nbsf_uri_prefix & 
c_Nbsf_Management_path_pcf_ue_bindings & "/(?+)", 0);
+
+       f_http2_adapter_close(idx := http2_tx.conn_id);
+       setverdict(pass);
+}
+
+/* 5.3.3.3.1 Resource: Individual PCF for a PDU Session Binding (DELETE) */
+private function f_nbsf_mgmt_prepare_delete_individual_pcf_ue_binding()
+runs on ConnHdlr return HTTP2_Msg {
+       var integer http2_idx;
+       var integer http2_stream_id;
+       var template (value) HTTP2_Msg http2_tx;
+
+       http2_idx := f_http2_adapter_find_free_idx();
+       http2_stream_id := f_http2_adapter_next_stream_id(http2_idx);
+       http2_tx := ts_HTTP2_Msg(http2_idx,
+                                http2_stream_id,
+                                hb := {
+                                       pseudo_headers := 
ts_HTTP2_pseudo_headers_Req(method := "DELETE",
+                                                                               
      scheme := "http",
+                                                                               
      authority := c_Nbsf_uri_hostport,
+                                                                               
      path := 
ts_Nbsf_Management_path_individual_pcf_ue_binding(g_pars.binding_id)),
+                                       headers := {
+                                               
ts_HTTP2_Hdr_content_type("application/json"),
+                                               
ts_HTTP2_Hdr_accept("application/json"),
+                                               
ts_HTTP2_Hdr_user_agent("ttcn3-pcf"),
+                                               
ts_HTTP2_Hdr_accept_encoding("gzip")
+                                       }
+                                },
+                                body := omit);
+       return valueof(http2_tx);
+}
+
+/* 4.2.3.3 Deregister an individual PCF for a UE binding information */
+function f_nbsf_mgmt_delete_individual_pcf_ue_binding()
+runs on ConnHdlr {
+       var HTTP2_Msg http2_tx;
+       var HTTP2_Msg http2_rx;
+       var template (present) HTTP2_Msg http2_exp_rx;
+
+       http2_tx := f_nbsf_mgmt_prepare_delete_individual_pcf_ue_binding();
+       f_http2_adapter_connect_send_bsf(http2_tx, idx := http2_tx.conn_id);
+
+       /* 3GPP TS 29.521 Table 5.3.2.3.1-3 */
+       http2_exp_rx :=
+               tr_HTTP2_Msg(http2_tx.conn_id,
+                            http2_tx.stream_id,
+                            tr_HTTP2_header_block(pseudo_headers := 
tr_HTTP2_pseudo_headers_Resp(204)),
+                            omit);
+       as_http2_adapter_receive(http2_rx, http2_exp_rx, idx := 
http2_tx.conn_id);
+
+       g_pars.binding_id := omit;
+
+       f_http2_adapter_close(idx := http2_tx.conn_id);
+       setverdict(pass);
+}
+
+}
diff --git a/bsf/README.md b/bsf/README.md
new file mode 100644
index 0000000..5f9a700
--- /dev/null
+++ b/bsf/README.md
@@ -0,0 +1,18 @@
+# BSF_Tests.ttcn
+
+* external interfaces
+    * N7: SBI (emulates SMF)
+    * N15: SBI (emulates AMF)
+    * N36: SBI (emulates UDR)
+
+{% dot pcf_tests.svg
+digraph G {
+  rankdir=LR;
+  ATS [label="ATS\nBSF_Tests.ttcn"];
+  UDM [label="AMF\open5gs-pcfd",shape="box"];
+
+  ATS -> UDM [label="N7"];
+  ATS -> UDM [label="N15"];
+  ATS -> UDM [label="N36"];
+}
+%}
diff --git a/bsf/expected-results.xml b/bsf/expected-results.xml
new file mode 100644
index 0000000..552ba05
--- /dev/null
+++ b/bsf/expected-results.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<testsuite name='Titan' tests='1' failures='0' errors='0' skipped='0' 
inconc='0' time='MASKED'>
+  <testcase classname='BSF_Tests' name='TC_pcfBindings' time='MASKED'/>
+  <testcase classname='BSF_Tests' name='TC_pcf_ue_bindings' time='MASKED'/>
+</testsuite>
diff --git a/bsf/gen_links.sh b/bsf/gen_links.sh
new file mode 100755
index 0000000..de245fb
--- /dev/null
+++ b/bsf/gen_links.sh
@@ -0,0 +1,52 @@
+#!/bin/bash -e
+
+BASEDIR=../deps
+
+. ../_buildsystem/gen_links.inc.sh
+
+DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"
+FILES+=" TCCEncoding_Functions.ttcn TCCEncoding.cc " # GSM 7-bit coding
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
+FILES="Socket_API_Definitions.ttcn"
+gen_links $DIR $FILES
+
+# Required by MGCP and IPA
+DIR=$BASEDIR/titan.TestPorts.IPL4asp/src
+FILES="IPL4asp_Functions.ttcn  IPL4asp_PT.cc  IPL4asp_PT.hh 
IPL4asp_PortType.ttcn  IPL4asp_Types.ttcn  IPL4asp_discovery.cc 
IPL4asp_protocol_L234.hh"
+gen_links $DIR $FILES
+
+# Needed by HTTP_Adapter (Prometheus_Checker.ttcn metrics):
+DIR=$BASEDIR/titan.TestPorts.Common_Components.Abstract_Socket/src
+FILES="Abstract_Socket.cc Abstract_Socket.hh "
+gen_links $DIR $FILES
+
+# Needed by HTTP_Adapter (Prometheus_Checker.ttcn metrics):
+DIR=$BASEDIR/titan.TestPorts.HTTPmsg/src
+FILES="HTTPmsg_MessageLen.ttcn HTTPmsg_MessageLen_Function.cc HTTPmsg_PT.cc 
HTTPmsg_PT.hh HTTPmsg_PortType.ttcn HTTPmsg_Types.ttcn "
+gen_links $DIR $FILES
+
+# Needed by HTTP2_Adapter:
+DIR=$BASEDIR/titan.ProtocolModules.HTTP2/src
+FILES="HTTP2_EncDec.cc HTTP2_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolModules.JSON_v07_2006/src
+FILES="JSON_Generic_Null_Def.asn JSON_Generic.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/osmo-ttcn3-openapi-generator/openapi-specs/3GPP_5GC_Rel19/ttcn3
+FILES="TS29571_CommonData.ttcn TS29521_Nbsf_Management.ttcn "
+gen_links $DIR $FILES
+
+DIR=../library
+FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn 
Native_Functions.ttcn Native_FunctionDefs.cc IPCP_Types.ttcn 
IPCP_Templates.ttcn "
+FILES+="SCTP_Templates.ttcn "
+FILES+="HTTP2_CodecPort.ttcn HTTP2_CodecPort_CtrlFunct.ttcn 
HTTP2_CodecPort_CtrlFunctDef.cc HTTP2_Templates.ttcn HTTP2_Functions.ttcn 
HTTP2_Msg.ttcn HTTP2_Adapter.ttcn HTTP2_Server_Emulation.ttcn "
+FILES+="HTTP_Adapter.ttcn Prometheus_Checker.ttcn "
+FILES+="TS29571_CommonData_Templates.ttcn 
TS29521_Nbsf_Management_Templates.ttcn "
+gen_links $DIR $FILES
+
+gen_links_finish
diff --git a/bsf/open5gs-bsf.yaml b/bsf/open5gs-bsf.yaml
new file mode 100644
index 0000000..3dd2191
--- /dev/null
+++ b/bsf/open5gs-bsf.yaml
@@ -0,0 +1,19 @@
+# See https://github.com/open5gs/open5gs/blob/main/configs/open5gs/bsf.yaml.in
+
+logger:
+  level: debug
+
+global:
+  max:
+    ue: 1024
+
+bsf:
+  sbi:
+    server:
+      - address: 127.0.0.15
+        port: 7777
+    client:
+#      nrf:
+#        - uri: http://127.0.0.10:7777
+      scp:
+        - uri: http://127.0.0.200:7777
diff --git a/bsf/regen_makefile.sh b/bsf/regen_makefile.sh
new file mode 100755
index 0000000..5596140
--- /dev/null
+++ b/bsf/regen_makefile.sh
@@ -0,0 +1,23 @@
+#!/bin/sh -e
+
+NAME=BSF_Tests
+
+FILES="
+       *.asn
+       *.ttcn
+       Abstract_Socket.cc
+       HTTPmsg_MessageLen_Function.cc
+       HTTPmsg_PT.cc
+       HTTP2_EncDec.cc
+       HTTP2_CodecPort_CtrlFunctDef.cc
+       IPL4asp_PT.cc
+       IPL4asp_discovery.cc
+       Native_FunctionDefs.cc
+       TCCConversion.cc
+       TCCEncoding.cc
+       TCCInterface.cc
+"
+
+. ../_buildsystem/regen_makefile.inc.sh
+
+sed -i -e 's/^LINUX_LIBS = -lxml2 -lsctp/LINUX_LIBS = -lxml2 -lsctp -lgnutls/' 
Makefile
diff --git a/bsf/testenv.cfg b/bsf/testenv.cfg
new file mode 100644
index 0000000..38ecb56
--- /dev/null
+++ b/bsf/testenv.cfg
@@ -0,0 +1,10 @@
+[testsuite]
+program=BSF_Tests
+config=BSF_Tests.cfg
+
+[bsf]
+program=open5gs-bsfd -c open5gs-bsf.yaml
+make=open5gs
+package=open5gs-bsf
+copy=open5gs-bsf.yaml
+
diff --git a/bsf/testsrcdir.cfg b/bsf/testsrcdir.cfg
new file mode 100644
index 0000000..7f19289
--- /dev/null
+++ b/bsf/testsrcdir.cfg
@@ -0,0 +1,2 @@
+[testsrcdir]
+max_jobs_per_gb_ram=0.3
diff --git a/library/TS29521_Nbsf_Management_Templates.ttcn 
b/library/TS29521_Nbsf_Management_Templates.ttcn
index 4e14679..7eaa96f 100644
--- a/library/TS29521_Nbsf_Management_Templates.ttcn
+++ b/library/TS29521_Nbsf_Management_Templates.ttcn
@@ -6,17 +6,44 @@
 const charstring c_Nbsf_Management_path_pcfBindings
 := c_Nbsf_Management_path_api_prefix & "/pcfBindings";

+const charstring c_Nbsf_Management_path_pcf_ue_bindings
+:= c_Nbsf_Management_path_api_prefix & "/pcf-ue-bindings";
+
 /* 5.3.3 Resource: Individual PCF for a PDU Session Binding */
 template (value) charstring
 ts_Nbsf_Management_path_individual_pcf_pdu_sess_binding(template (value) 
charstring binding_id)
 := c_Nbsf_Management_path_pcfBindings & "/" & valueof(binding_id);

+/* 5.3.8 Resource: Individual PCF for a UE Binding */
+template (value) charstring
+ts_Nbsf_Management_path_individual_pcf_ue_binding(template (value) charstring 
binding_id)
+:= c_Nbsf_Management_path_pcf_ue_bindings & "/" & valueof(binding_id);
+
+template (value) Snssai
+ts_Snssai(template (value) integer sst,
+         template (omit) charstring sd := omit) := {
+       sst := sst,
+       sd := sd
+}
+
+template (value) IpEndPoint
+ts_IpEndPoint(template (omit) Ipv4Addr ipv4Address := omit,
+             template (omit) Ipv6Addr ipv6Address := omit,
+             template (omit) TransportProtocol transport := omit,
+             template (omit) integer port_ := omit) := {
+       ipv4Address := ipv4Address,
+       ipv6Address := ipv6Address,
+       transport := transport,
+       port_ :=  port_
+}
+
 type TS29521_Nbsf_Management.PcfBinding.addIpv6Prefixes Ipv6PrefixList;
 type TS29521_Nbsf_Management.PcfBinding.addMacAddrs MacAddr48List;
 type TS29521_Nbsf_Management.PcfBinding.pcfIpEndPoints PcfIpEndPointList;
 type TS29521_Nbsf_Management.PcfBinding.pcfSmIpEndPoints PcfSmIpEndPointList;
 type TS29521_Nbsf_Management.PcfBinding.ipv4FrameRouteList Ipv4FrameRouteList;
 type TS29521_Nbsf_Management.PcfBinding.ipv6FrameRouteList Ipv6FrameRouteList;
+
 template (present) PcfBinding
 tr_PcfBinding(template Supi supi := *,
              template Gpsi gpsi := *,
@@ -68,4 +95,100 @@
        ipv6FrameRouteList := ipv6FrameRouteList
 }

+template (value) PcfBinding
+ts_PcfBinding(
+             template (omit) Supi supi := omit,
+             template (omit) Gpsi gpsi := omit,
+             template (omit) Ipv4Addr ipv4Addr := omit,
+             template (omit) Ipv6Prefix ipv6Prefix := omit,
+             template (omit) Ipv6PrefixList addIpv6Prefixes := omit,
+             template (omit) charstring ipDomain := omit,
+             template (omit) MacAddr48 macAddr48 := omit,
+             template (omit) MacAddr48List addMacAddrs := omit,
+             template (value) Dnn dnn,
+             template (omit) Fqdn pcfFqdn := omit,
+             template (omit) PcfIpEndPointList pcfIpEndPoints := omit,
+             template (omit) DiameterIdentity pcfDiamHost := omit,
+             template (omit) DiameterIdentity pcfDiamRealm := omit,
+             template (omit) Fqdn pcfSmFqdn := omit,
+             template (omit) PcfSmIpEndPointList pcfSmIpEndPoints := omit,
+             template (value) Snssai snssai,
+             template (omit) SupportedFeatures suppFeat := omit,
+             template (omit) NfInstanceId pcfId := omit,
+             template (omit) NfSetId pcfSetId := omit,
+             template (omit) DateTime recoveryTime := omit,
+             template (omit) ParameterCombination paraCom := omit,
+             template (omit) BindingLevel bindLevel := omit,
+             template (omit) Ipv4FrameRouteList ipv4FrameRouteList := omit,
+             template (omit) Ipv6FrameRouteList ipv6FrameRouteList := omit) := 
{
+       supi := supi,
+       gpsi := gpsi,
+       ipv4Addr := ipv4Addr,
+       ipv6Prefix := ipv6Prefix,
+       addIpv6Prefixes := addIpv6Prefixes,
+       ipDomain := ipDomain,
+       macAddr48 := macAddr48,
+       addMacAddrs := addMacAddrs,
+       dnn := dnn,
+       pcfFqdn := pcfFqdn,
+       pcfIpEndPoints := pcfIpEndPoints,
+       pcfDiamHost := pcfDiamHost,
+       pcfDiamRealm := pcfDiamRealm,
+       pcfSmFqdn := pcfSmFqdn,
+       pcfSmIpEndPoints := pcfSmIpEndPoints,
+       snssai := snssai,
+       suppFeat := suppFeat,
+       pcfId := pcfId,
+       pcfSetId := pcfSetId,
+       recoveryTime := recoveryTime,
+       paraCom := paraCom,
+       bindLevel := bindLevel,
+       ipv4FrameRouteList := ipv4FrameRouteList,
+       ipv6FrameRouteList := ipv6FrameRouteList
+}
+
+type TS29521_Nbsf_Management.PcfForUeBinding.pcfForUeIpEndPoints 
PcfForUeIpEndPointList;
+
+template (present) PcfForUeBinding
+tr_PcfForUeBinding(template (present) Supi supi := ?,
+                  template Gpsi gpsi := *,
+                  template Fqdn pcfForUeFqdn := *,
+                  template PcfForUeIpEndPointList pcfForUeIpEndPoints := *,
+                  template NfInstanceId pcfId := *,
+                  template DateTime recoveryTime := *,
+                  template NfSetId pcfSetId := *,
+                  template BindingLevel bindLevel := *,
+                  template SupportedFeatures suppFeat := *) := {
+       supi := supi,
+       gpsi := gpsi,
+       pcfForUeFqdn := pcfForUeFqdn,
+       pcfForUeIpEndPoints := pcfForUeIpEndPoints,
+       pcfId := pcfId,
+       recoveryTime := recoveryTime,
+       pcfSetId := pcfSetId,
+       bindLevel := bindLevel,
+       suppFeat := suppFeat
+}
+
+template (value) PcfForUeBinding
+ts_PcfForUeBinding(template (value) Supi supi,
+                  template (omit) Gpsi gpsi := omit,
+                  template (omit) Fqdn pcfForUeFqdn := omit,
+                  template (omit) PcfForUeIpEndPointList pcfForUeIpEndPoints 
:= omit,
+                  template (omit) NfInstanceId pcfId := omit,
+                  template (omit) DateTime recoveryTime := omit,
+                  template (omit) NfSetId pcfSetId := omit,
+                  template (omit) BindingLevel bindLevel := omit,
+                  template (omit) SupportedFeatures suppFeat := omit) := {
+       supi := supi,
+       gpsi := gpsi,
+       pcfForUeFqdn := pcfForUeFqdn,
+       pcfForUeIpEndPoints := pcfForUeIpEndPoints,
+       pcfId := pcfId,
+       recoveryTime := recoveryTime,
+       pcfSetId := pcfSetId,
+       bindLevel := bindLevel,
+       suppFeat := suppFeat
+}
+
 }
diff --git a/pcf/ConnHdlr.ttcn b/pcf/ConnHdlr.ttcn
index 4894e0f..c296cc4 100644
--- a/pcf/ConnHdlr.ttcn
+++ b/pcf/ConnHdlr.ttcn
@@ -230,7 +230,7 @@
                var template (value) HTTP2_Msg http2_tx;

                sm_policy_data := ts_SmPolicyData(smPolicySnssaiData := {
-                                                       {"", 
ts_SmPolicySnssaiData(snssai := ts_Snssai(1),
+                                                       {"", 
ts_SmPolicySnssaiData(snssai := TS29519_Policy_Data_Templates.ts_Snssai(1),
                                                                                
   smPolicyDnnData := {{"internet",
                                                                                
                        ts_SmPolicyDnnData(dnn := "internet")}})}
                                                  });

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

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I4d8aabfbc3bdbc6fe966ca946a7263d345eef739
Gerrit-Change-Number: 44013
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to