pespin has uploaded this change for review. ( 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, 24 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/61/41461/1
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..4a2be6a 100644 --- a/src/erab_fsm.erl +++ b/src/erab_fsm.erl @@ -84,6 +84,9 @@ modify_cnf_nack. -type rel_kind() :: cmd | ind.
+-type bin_fqdn_label() :: << _:8, _:_*8 >>. +-type bin_fqdn() :: [bin_fqdn_label()]. + -record(erab_state, {uid :: term(), %% unique E-RAB identifier from :: undefined | gen_statem:from(), %% destination to use when replying u2c :: undefined | teid_addr(), %% GTP-U params for UPF -> Core @@ -695,12 +698,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()) -> bin_fqdn_label(). +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()) -> bin_fqdn(). +enc_net_inst(FQDN) -> + Labels = string:split(FQDN, ".", all), + LabelsEnc = lists:map(fun(X)->enc_net_inst_label(X) end, 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