pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43893?usp=email )


Change subject: HTTP2_Adapter: Add func helper f_http2_adapter_next_stream_id()
......................................................................

HTTP2_Adapter: Add func helper f_http2_adapter_next_stream_id()

Change-Id: I6a881a1d5bbce832cb8da5a6371fb1e46b920b56
---
M library/HTTP2_Adapter.ttcn
M smf/SMF_Session_CT_5G.ttcn
2 files changed, 25 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/93/43893/1

diff --git a/library/HTTP2_Adapter.ttcn b/library/HTTP2_Adapter.ttcn
index 7ce7eef..b35b4f4 100644
--- a/library/HTTP2_Adapter.ttcn
+++ b/library/HTTP2_Adapter.ttcn
@@ -1,6 +1,6 @@
 module HTTP2_Adapter {

-/* HTTP2 Adapter component
+/* HTTP2 Adapter component (RFC9113)
  * (C) 2019 by Harald Welte <[email protected]>
  * (C) 2026 by sysmocom s.f.m.c. GmbH <[email protected]>
  * All rights reserved.
@@ -28,6 +28,7 @@
 import from Misc_Helpers all;

 const integer HTTP2_MAX_NUM_CLIENTS := 4;
+const integer HTTP2_ADATER_INITIAL_STREAM_ID := 1;

 type component HTTP2_CT {
        port HTTP2_CODEC_PT HTTP2[HTTP2_MAX_NUM_CLIENTS];
@@ -37,6 +38,9 @@
        /* Connection identifier of the client / server itself */
        var IPL4asp_Types.ConnectionId g_self_conn_id[HTTP2_MAX_NUM_CLIENTS];

+       /* stream_id to use for next stream opened. */
+       var IPL4asp_Types.ConnectionId 
g_http2_next_stream_id[HTTP2_MAX_NUM_CLIENTS];
+
        /* Header block compress enc/dec: */
        var HTTP2_comp_context g_http2_ctx_dec[HTTP2_MAX_NUM_CLIENTS];
        var HTTP2_comp_context g_http2_ctx_enc[HTTP2_MAX_NUM_CLIENTS];
@@ -69,6 +73,7 @@
 function f_http2_adapter_init() runs on HTTP2_CT {
        for(var integer i := 0; i < HTTP2_MAX_NUM_CLIENTS; i := i + 1) {
                map(self:HTTP2[i], system:HTTP2_CODEC_PT);
+               g_http2_next_stream_id[i] := HTTP2_ADATER_INITIAL_STREAM_ID;
                g_self_conn_id[i] := -1;
        }
 }
@@ -99,6 +104,18 @@
        return -1;
 }

+/* RFC 9913 5.1.1. Stream Identifiers:
+ * "Streams initiated by a client MUST use odd-numbered stream identifiers".
+ * "The identifier of a newly established stream MUST be numerically greater
+ * than all streams that the initiating endpoint has opened or reserved."
+ */
+function f_http2_adapter_next_stream_id(integer idx := 0)
+runs on HTTP2_CT return integer {
+       var integer stream_id := g_http2_next_stream_id[idx];
+       g_http2_next_stream_id[idx] := g_http2_next_stream_id[idx] + 2;
+       return stream_id;
+}
+
 private function f_http2_adapter_header_block_encode(HTTP2_header_block hb,
                                                     integer idx := 0)
 runs on HTTP2_CT return octetstring {
@@ -169,6 +186,7 @@
        var IPL4asp_Types.Result res;
        res := HTTP2_CodecPort_CtrlFunct.f_IPL4_close(HTTP2[idx], 
g_self_conn_id[idx], {tcp := {}});
        g_self_conn_id[idx] := -1;
+       g_http2_next_stream_id[idx] := HTTP2_ADATER_INITIAL_STREAM_ID;
        HTTP2_comp_context_free(g_http2_ctx_dec[idx]);
        HTTP2_comp_context_free(g_http2_ctx_enc[idx]);
 }
diff --git a/smf/SMF_Session_CT_5G.ttcn b/smf/SMF_Session_CT_5G.ttcn
index 493b031..ab35f03 100644
--- a/smf/SMF_Session_CT_5G.ttcn
+++ b/smf/SMF_Session_CT_5G.ttcn
@@ -135,7 +135,7 @@
        var template (value) octetstring body_enc;
        var charstring http2_boundary := "=-0EVVjxcWWFYNd1JXh1OQEg=="
        var integer http2_idx;
-       var integer http2_stream_id := 3;
+       var integer http2_stream_id;
        var HTTP2_multipart_part_list parts;
        var template (value) HTTP2_Msg http2_tx;
        var HTTP2_Msg http2_rx;
@@ -156,6 +156,7 @@

        body_enc := f_HTTP2_multipart_msg_encode(parts, http2_boundary);
        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 := {
@@ -282,7 +283,7 @@
        var template (value) octetstring body_enc;
        var charstring http2_boundary := "=-0EVVjxcWWFYNd1JXh1OQEg=="
        var integer http2_idx;
-       var integer http2_stream_id := 3;
+       var integer http2_stream_id;
        var HTTP2_multipart_part_list parts;
        var template (value) HTTP2_Msg http2_tx;
        var HTTP2_Msg http2_rx;
@@ -303,6 +304,7 @@

        body_enc := f_HTTP2_multipart_msg_encode(parts, http2_boundary);
        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 := {
@@ -360,7 +362,7 @@
        var template (value) octetstring body_enc;
        var charstring http2_boundary := "=-0EVVjxcWWFYNd1JXh1OQEg=="
        var integer http2_idx;
-       var integer http2_stream_id := 3;
+       var integer http2_stream_id;
        var HTTP2_multipart_part_list parts;
        var template (value) HTTP2_Msg http2_tx;
        var HTTP2_Msg http2_rx;
@@ -376,6 +378,7 @@

        body_enc := f_HTTP2_multipart_msg_encode(parts, http2_boundary);
        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 := {

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

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I6a881a1d5bbce832cb8da5a6371fb1e46b920b56
Gerrit-Change-Number: 43893
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to