lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35218?usp=email )
Change subject: epdg_gtpc_s2b: add TLV Serving Network ......................................................................
epdg_gtpc_s2b: add TLV Serving Network
The open5gs requires Serving Network TLV.
Change-Id: I2a9459859fc660e6433cd8178ab9d1f92ae74fc0 --- M src/epdg_gtpc_s2b.erl A src/gtp_utils.erl 2 files changed, 63 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-epdg refs/changes/18/35218/1
diff --git a/src/epdg_gtpc_s2b.erl b/src/epdg_gtpc_s2b.erl index a5658f1..a71e71d 100644 --- a/src/epdg_gtpc_s2b.erl +++ b/src/epdg_gtpc_s2b.erl @@ -59,6 +59,9 @@
%% TODO: make APN configurable? get it from HSS? -define(APN, <<"internet">>). +-define(MCC, 901). +-define(MNC, 42). +-define(MNC_SIZE, 42).
-record(gtp_state, { socket, @@ -330,7 +333,10 @@ #v2_access_point_name{instance = 0, apn = [Apn]}, #v2_selection_mode{mode = 0}, #v2_pdn_address_allocation{type = ipv4, address = <<0,0,0,0>>}, - #v2_bearer_context{group = BearersIE} + #v2_bearer_context{group = BearersIE}, + #v2_serving_network{ + plmn_id = gtp_utils:plmn_to_bin(?MCC, ?MNC, ?MNC_SIZE) + } ], #gtp{version = v2, type = create_session_request, tei = 0, seq_no = SeqNo, ie = IEs}.
@@ -346,5 +352,3 @@ tei = RemoteCtlTEI, seq_no = Req#gtp.seq_no, ie = IEs}. - - diff --git a/src/gtp_utils.erl b/src/gtp_utils.erl new file mode 100644 index 0000000..b899530 --- /dev/null +++ b/src/gtp_utils.erl @@ -0,0 +1,45 @@ +% GTP utilities +% +% (C) 2023 by sysmocom - s.f.m.c. GmbH info@sysmocom.de +% Author: Alexander Couzens lynxis@fe80.eu +% +% All Rights Reserved +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU Affero General Public License as +% published by the Free Software Foundation; either version 3 of the +% License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU Affero General Public License +% along with this program. If not, see http://www.gnu.org/licenses/. +% +% Additional Permission under GNU AGPL version 3 section 7: +% +% If you modify this Program, or any covered work, by linking or +% combining it with runtime libraries of Erlang/OTP as released by +% Ericsson on http://www.erlang.org (or a modified version of these +% libraries), containing parts covered by the terms of the Erlang Public +% License (http://www.erlang.org/EPLICENSE), the licensors of this +% Program grant you additional permission to convey the resulting work +% without the need to license the runtime libraries of Erlang/OTP under +% the GNU Affero General Public License. Corresponding Source for a +% non-source form of such a combination shall include the source code +% for the parts of the runtime libraries of Erlang/OTP used as well as +% that of the covered work. + +-module(gtp_utils). +-author('Alexander Couzens lynxis@fe80.eu'). + +-export([plmn_to_bin/3]). + +% ergw/apps/ergw/test/*.erl +% under GPLv2+ +plmn_to_bin(CC, NC, NCSize) -> + MCC = iolist_to_binary(io_lib:format("~3..0b", [CC])), + MNC = iolist_to_binary(io_lib:format("~*..0b", [NCSize, NC])), + {MCC, MNC}.