pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/41461?usp=email )

Change subject: config: Set pfcp_net_inst_* fields as strings
......................................................................

config: Set pfcp_net_inst_* fields as strings

The encoded format is not user friendly at all, since length of each DNS
label (subdomain) needs to be encoded in the bytestring.

Related: SYS#7734
Change-Id: I7c2da02945829066d317100556e09e55483bd7e7
---
M config/sys.config
M src/erab_fsm.erl
2 files changed, 21 insertions(+), 3 deletions(-)

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




diff --git a/config/sys.config b/config/sys.config
index 920a30e..9ad1ca2 100644
--- a/config/sys.config
+++ b/config/sys.config
@@ -17,8 +17,8 @@
    {pfcp_loc_addr, "127.0.1.1"}, %% local address for incoming PFCP PDUs from 
the UPF
    {pfcp_rem_addr, "127.0.1.2"} %% remote address for outgoing PFCP PDUs to 
the UPF
 %% Optional PFCP Network Instance IEs (omitted if not configured)
-%% {pfcp_net_inst_core, << 16#09, "core-side" >>}, %% PFCP Network Instance IE 
value (to core)
-%% {pfcp_net_inst_access, << 16#0a, "radio-side" >>} %% PFCP Network Instance 
IE value (to access)
+%% {pfcp_net_inst_core, "core-side"}, %% PFCP Network Instance IE value (to 
core)
+%% {pfcp_net_inst_access, "radio-side"} %% PFCP Network Instance IE value (to 
access)
 %%
 %% Optional GTP-U KPI configuration
 %% {gtpu_kpi_enable, true}, %% whether to enable the GTP-U KPI module 
(default: false)
diff --git a/src/erab_fsm.erl b/src/erab_fsm.erl
index f5d8efe..49a26ca 100644
--- a/src/erab_fsm.erl
+++ b/src/erab_fsm.erl
@@ -695,12 +695,30 @@
 net_inst_param('Access') -> pfcp_net_inst_access.


+%% Encode one DNS label from string format into DNS Name Notation
+-spec enc_net_inst_label(string()) -> binary().
+enc_net_inst_label(LabelStr) ->
+    LabelLen = string:length(LabelStr),
+    LabelBin = list_to_binary(LabelStr),
+    << LabelLen:8, LabelBin/binary >>.
+
+
+%% Encode Network Instance IE (3GPP TS 29.244 8.2.4) from string format into 
DNS Name Notation
+%% Example: enc_net_inst("www.foobar.com") -> << 3, 'w', 'w', 'w', 6, 'f', 
'o', 'o', 'b', 'a', 'r', 3, 'c', 'o', 'm' >>.
+-spec enc_net_inst(string()) -> binary().
+enc_net_inst(FQDN) ->
+    Labels = string:split(FQDN, ".", all),
+    LabelsEnc = lists:map(fun enc_net_inst_label/1, Labels),
+    list_to_binary(LabelsEnc).
+
+
 %% if configured, add Network Instance IE (optional)
 -spec add_net_inst(pfcp_ie(), iface()) -> pfcp_ie().
 add_net_inst(IE, Iface) ->
     Param = net_inst_param(Iface),
     case application:get_env(osmo_s1gw, Param) of
-        {ok, NI} ->
+        {ok, NIStr} ->
+            NI = enc_net_inst(NIStr),
             IE#{network_instance => NI};
         undefined ->
             IE

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

Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I7c2da02945829066d317100556e09e55483bd7e7
Gerrit-Change-Number: 41461
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: lynxis lazus <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to