lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

June 2024

  • 1 participants
  • 1566 discussions
[S] Change in osmo-s1gw[master]: rebar.config: cosmetic: reformat, add vim modeline
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37051?usp=email ) Change subject: rebar.config: cosmetic: reformat, add vim modeline ...................................................................... rebar.config: cosmetic: reformat, add vim modeline Change-Id: If93630d6e0a89512beeb27723bf7a56deb49e9c5 --- M rebar.config 1 file changed, 21 insertions(+), 11 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/51/37051/1 diff --git a/rebar.config b/rebar.config index 57da0ba..d6c6b0a 100644 --- a/rebar.config +++ b/rebar.config @@ -4,20 +4,21 @@ {minimum_otp_vsn, "25.2.3"}. -{deps, [ - {logger_color_formatter, {git, "https://github.com/rlipscombe/logger_color_formatter.git", {tag, "0.5.0"}}} -]}. +{deps, [{logger_color_formatter, + {git, "https://github.com/rlipscombe/logger_color_formatter.git", {tag, "0.5.0"}}} + ]}. -{plugins, [ - {provider_asn1, ".*", {git, "https://github.com/knusbaum/provider_asn1.git", {tag, "0.4.0"}}} -]}. +{plugins, [{provider_asn1, ".*", + {git, "https://github.com/knusbaum/provider_asn1.git", {tag, "0.4.0"}}} + ]}. {asn1_args, [{verbose, false}, {encoding, per}]}. {xref_checks, [undefined_function_calls, undefined_functions, - deprecated_function_calls, deprecated_functions]}. + deprecated_function_calls, deprecated_functions]}. -{dialyzer, [ - {plt_extra_apps, [kernel, stdlib, erts, tools, inets, compiler]}, - {warnings, [no_improper_lists]} -]}. +{dialyzer, [{plt_extra_apps, [kernel, stdlib, erts, tools, inets, compiler]}, + {warnings, [no_improper_lists]} + ]}. + +%% vim:set ts=4 sw=4 et: -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37051?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: If93630d6e0a89512beeb27723bf7a56deb49e9c5 Gerrit-Change-Number: 37051 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-s1gw[master]: rebar.config: add escript and relx parameters
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37052?usp=email ) Change subject: rebar.config: add escript and relx parameters ...................................................................... rebar.config: add escript and relx parameters Change-Id: I204aba4a0fdd678d2e6f5ab588c8c42ef3e44678 --- M rebar.config 1 file changed, 19 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/52/37052/1 diff --git a/rebar.config b/rebar.config index d6c6b0a..db88c7e 100644 --- a/rebar.config +++ b/rebar.config @@ -21,4 +21,14 @@ {warnings, [no_improper_lists]} ]}. +{escript_incl_apps, [osmo_s1gw]}. +{escript_main_app, osmo_s1gw}. +{escript_name, "osmo-s1gw"}. + +{relx, [{release, {"osmo-s1gw", "0.1.0"}, [osmo_s1gw]}, + {sys_config, "./config/sys.config"}, + {dev_mode, true}, + {include_erts, false}, + {extended_start_script, true}]}. + %% vim:set ts=4 sw=4 et: -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37052?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I204aba4a0fdd678d2e6f5ab588c8c42ef3e44678 Gerrit-Change-Number: 37052 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in osmo-s1gw[master]: README.md: initial version
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37053?usp=email ) Change subject: README.md: initial version ...................................................................... README.md: initial version Change-Id: Ifed0146b1bf609756e967e7c6b9ed159d29dfbf0 --- A README.md 1 file changed, 144 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/53/37053/1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..c5d30b2 --- /dev/null +++ b/README.md @@ -0,0 +1,135 @@ +osmo-s1gw +========= + +This is an S1AP (S1 Application Protocol) Gateway implementation in Erlang for +the 3GPP EPC (Evolved Packet Core) based (4G/LTE) networks. It is part of the +[Osmocom](https://osmocom.org/) Open Source Mobile Communications project. + +S1AP is a protocol "spoken" between the eNB and the MME. The S1GW is useful in +scenarios when eNB(s) and the MME co-exist in separate networks and thus unable +to access each other directly. This is basically a proxy, accepting incoming +connections from eNB(s), establishing the associated outgoing connections +to the MME, and forwarding S1AP PDUs back and forth. + +``` + (network A) | + | + +-------------+ +-------------+ + | osmo-s1gw | | MME | ++--------+ +-------------+ +-------------+ +| eNB(1) | --> | | --> | | ++--------+ | | | | + | | | | ++--------+ | | | | +| eNB(2) | --> | | --> | | ++--------+ | | | | + | | | | ++--------+ | | | | +| eNB(N) | --> | | --> | | ++--------+ +-------------+ +-------------+ + | + | (network B) +``` + + +Homepage +-------- + +This project does not have its own homepage yet, unlike many other +[Osmocom projects](https://osmocom.org/projects/). + + +GIT Repository +-------------- + +You can clone from the official osmo-s1gw.git repository using + +``` +$ git clone https://gitea.osmocom.org/erlang/osmo-s1gw +``` + +There is a web interface at <https://gitea.osmocom.org/erlang/osmo-s1gw> + + +Documentation +------------- + +Once the project reaches a usable milestone, we will be working on a +user manual. Stay tuned. + + +Contributing +------------ + +Our coding standards are described at +<https://osmocom.org/projects/cellular-infrastructure/wiki/Coding_standards>. + +We use a Gerrit based patch submission/review process for managing +contributions. Please see +<https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit> for +more details. + +The current patch queue for osmo-s1gw can be seen at +<https://gerrit.osmocom.org/#/q/project:erlang/osmo-s1gw+status:open>. + + +Building +-------- + +Install erlang and rebar3 packages (not "rebar", that's version 2! You may need +to compile it from source in some distros). + +``` +$ rebar3 asn compile +$ rebar3 compile +$ rebar3 escriptize +``` + + +Testing +------- + +Unit tests can be run this way: + +``` +$ rebar3 eunit +``` + + +Running +------- + +Once `osmo_s1gw` is built, you can start it this way: + +``` +$ rebar3 shell --config config/sys.config +``` + + +Configuration +------------- + +The default configuration can be found in +[config/sys.config](config/sys.config). + +The existing parameters can be represented as follows: + +``` + eNB S1GW ++-----+ +----------------+ +| ... | --> | s1gw_bind_addr | MME ++-----+ +----------------+ +-----------------+ + | mme_loc_addr | --> | mme_rem_addr | + +----------------+ +-----------------+ +``` + +* `s1gw_bind_addr` - S1GW bind address for incoming eNB connections +* `mme_loc_addr` - local address for outgoing connections to the MME +* `mme_rem_addr` - remote address for outgoing connections to the MME + +Logging can be configured in the `kernel` section: + +* `{logger_level, info}` - logging level (one of `emergency | alert | + critical | error | warning | notice | + info | debug`) +* `#{formatter => { ... }` - logging formatting configuration -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37053?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: Ifed0146b1bf609756e967e7c6b9ed159d29dfbf0 Gerrit-Change-Number: 37053 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in osmo-s1gw[master]: Add a global supervisor and env parameters
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37042?usp=email ) Change subject: Add a global supervisor and env parameters ...................................................................... Add a global supervisor and env parameters Change-Id: I2da6bccf728bdbe615aaf853b33077ceb4481176 --- M src/osmo_s1gw_app.erl A src/osmo_s1gw_sup.erl M src/sctp_proxy.erl M src/sctp_server.erl 4 files changed, 78 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/42/37042/1 diff --git a/src/osmo_s1gw_app.erl b/src/osmo_s1gw_app.erl index 596b3e8..7e1bc56 100644 --- a/src/osmo_s1gw_app.erl +++ b/src/osmo_s1gw_app.erl @@ -4,8 +4,9 @@ -export([start/2, stop/1]). start(_StartType, _StartArgs) -> - sctp_server:start_link(). - %% TODO: osmo_s1gw_sup:start_link(). + osmo_s1gw_sup:start_link(). stop(_State) -> - ok. + ok. + +%% vim:set ts=4 sw=4 et: diff --git a/src/osmo_s1gw_sup.erl b/src/osmo_s1gw_sup.erl new file mode 100644 index 0000000..a62f266 --- /dev/null +++ b/src/osmo_s1gw_sup.erl @@ -0,0 +1,46 @@ +-module(osmo_s1gw_sup). +-behaviour(supervisor). + +-export([init/1, + start_link/0]). + +-include("s1ap.hrl"). + +-define(SERVER, ?MODULE). +-define(ENV_APP_NAME, osmo_s1gw). +-define(ENV_DEFAULT_S1GW_BIND_ADDR, "0.0.0.0"). +-define(ENV_DEFAULT_S1GW_BIND_PORT, ?S1AP_PORT). +-define(ENV_DEFAULT_MME_ADDR, "127.0.0.1"). +-define(ENV_DEFAULT_MME_PORT, ?S1AP_PORT). + +%% ------------------------------------------------------------------ +%% supervisor API +%% ------------------------------------------------------------------ + +start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + + +init([]) -> + S1GWBindAddr = get_env(s1gw_bind_addr, ?ENV_DEFAULT_S1GW_BIND_ADDR), + S1GWBindPort = get_env(s1gw_bind_port, ?ENV_DEFAULT_S1GW_BIND_PORT), + MmeAddr = get_env(mme_addr, ?ENV_DEFAULT_MME_ADDR), + MmePort = get_env(mme_port, ?ENV_DEFAULT_MME_PORT), + SctpServer = {sctp_server, {sctp_server, start_link, + [S1GWBindAddr, S1GWBindPort, + {MmeAddr, MmePort}]}, + permanent, + 5000, + worker, + [sctp_server]}, + {ok, {{one_for_all, 5, 10}, [SctpServer]}}. + + +%% ------------------------------------------------------------------ +%% private API +%% ------------------------------------------------------------------ + +get_env(Param, Default) -> + application:get_env(?ENV_APP_NAME, Param, Default). + +%% vim:set ts=4 sw=4 et: diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index 2cc6165..43cb081 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -34,6 +34,10 @@ %% gen_statem API %% ------------------------------------------------------------------ +init([Aid, MmeAddrStr, MmePort]) when is_list(MmeAddrStr) -> + {ok, MmeAddr} = inet:parse_address(MmeAddrStr), + init([Aid, MmeAddr, MmePort]); + init([Aid, MmeAddr, MmePort]) -> {ok, connecting, #{enb_aid => Aid, diff --git a/src/sctp_server.erl b/src/sctp_server.erl index 48583c5..249cd8f 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -6,28 +6,25 @@ handle_call/3, handle_cast/2, terminate/2]). --export([start_link/0, - start_link/2]). --export([send_data/2]). +-export([start_link/3, + send_data/2]). -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). -include("s1ap.hrl"). --record(server_state, {sock, clients}). +-record(server_state, {sock, clients, mme_addr_port}). -record(client_state, {addr_port, pid}). %% ------------------------------------------------------------------ %% public API %% ------------------------------------------------------------------ -start_link() -> - start_link("127.0.0.1", ?S1AP_PORT). - -start_link(BindAddr, BindPort) -> +start_link(BindAddr, BindPort, MmeAddrPort) -> gen_server:start_link({local, ?MODULE}, ?MODULE, - [BindAddr, BindPort], []). + [BindAddr, BindPort, MmeAddrPort], + []). send_data(Aid, Data) -> @@ -38,11 +35,11 @@ %% gen_server API %% ------------------------------------------------------------------ -init([BindAddrStr, BindPort]) when is_list(BindAddrStr) -> +init([BindAddrStr, BindPort, MmeAddrPort]) when is_list(BindAddrStr) -> {ok, BindAddr} = inet:parse_address(BindAddrStr), - init([BindAddr, BindPort]); + init([BindAddr, BindPort, MmeAddrPort]); -init([BindAddr, BindPort]) -> +init([BindAddr, BindPort, MmeAddrPort]) -> process_flag(trap_exit, true), {ok, Sock} = gen_sctp:open([{ip, BindAddr}, {port, BindPort}, @@ -52,7 +49,8 @@ logger:info("SCTP server listening on ~w:~w", [BindAddr, BindPort]), ok = gen_sctp:listen(Sock, true), {ok, #server_state{sock = Sock, - clients = dict:new()}}. + clients = dict:new(), + mme_addr_port = MmeAddrPort}}. handle_call(Info, _From, State) -> @@ -116,7 +114,8 @@ case ConnState of comm_up -> logger:notice("Connection (id=~p, ~p:~p) established", [Aid, FromAddr, FromPort]), - Clients = client_add(State#server_state.clients, Aid, FromAddr, FromPort); + Clients = client_add(State#server_state.clients, Aid, FromAddr, FromPort, + State#server_state.mme_addr_port); shutdown_comp -> logger:notice("Connection (id=~p, ~p:~p) closed", [Aid, FromAddr, FromPort]), Clients = client_del(State#server_state.clients, Aid); @@ -151,8 +150,8 @@ %% Add a new client to the list, spawning a proxy process -client_add(Clients, Aid, FromAddr, FromPort) -> - {ok, Pid} = sctp_proxy:start_link(Aid, {127,0,1,1}, ?S1AP_PORT), %% XXX! +client_add(Clients, Aid, FromAddr, FromPort, {MmeAddr, MmePort}) -> + {ok, Pid} = sctp_proxy:start_link(Aid, MmeAddr, MmePort), NewClient = #client_state{addr_port = {FromAddr, FromPort}, pid = Pid}, dict:store(Aid, NewClient, Clients). -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37042?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I2da6bccf728bdbe615aaf853b33077ceb4481176 Gerrit-Change-Number: 37042 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-s1gw[master]: sctp_server: add public API to shutdown the server
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37044?usp=email ) Change subject: sctp_server: add public API to shutdown the server ...................................................................... sctp_server: add public API to shutdown the server Change-Id: I706dc7d79feb9d3c6d527fc767e5c5574004a95b --- M src/sctp_server.erl 1 file changed, 15 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/44/37044/1 diff --git a/src/sctp_server.erl b/src/sctp_server.erl index 249cd8f..4ba49eb 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -7,7 +7,8 @@ handle_cast/2, terminate/2]). -export([start_link/3, - send_data/2]). + send_data/2, + shutdown/0]). -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). @@ -31,6 +32,10 @@ gen_server:cast(?MODULE, {send_data, Aid, Data}). +shutdown() -> + gen_server:stop(?MODULE). + + %% ------------------------------------------------------------------ %% gen_server API %% ------------------------------------------------------------------ -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37044?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I706dc7d79feb9d3c6d527fc767e5c5574004a95b Gerrit-Change-Number: 37044 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-s1gw[master]: Rework logging config, colorize output
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37043?usp=email ) Change subject: Rework logging config, colorize output ...................................................................... Rework logging config, colorize output Change-Id: Icb24c9ab0f7f236424c08f6461d058d9a6e8a40b --- M config/sys.config M rebar.config M rebar.lock 3 files changed, 25 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/43/37043/1 diff --git a/config/sys.config b/config/sys.config index 072f183..dcace60 100644 --- a/config/sys.config +++ b/config/sys.config @@ -4,5 +4,12 @@ [{logger_level, info}, {logger, [{handler, default, logger_std_h, - #{ level => debug, formatter => {logger_formatter, - #{ template => ["[", level, "] ", pid, " ", file, ":", line, " ", msg, "\n"] }}}}]}]}]. + #{formatter => + {logger_color_formatter, #{legacy_header => false, + single_line => false, + template => [time, " ", color, "[", level, "]", + {pid, [" ", pid, ""], ""}, + {mfa, [" ", mfa, ":", line], ""}, + ": ", msg, reset, "\n"]}}}}]}]}]. + +%% vim:set ts=2 sw=2 et: diff --git a/rebar.config b/rebar.config index e4da64f..57da0ba 100644 --- a/rebar.config +++ b/rebar.config @@ -4,7 +4,9 @@ {minimum_otp_vsn, "25.2.3"}. -{deps, []}. +{deps, [ + {logger_color_formatter, {git, "https://github.com/rlipscombe/logger_color_formatter.git", {tag, "0.5.0"}}} +]}. {plugins, [ {provider_asn1, ".*", {git, "https://github.com/knusbaum/provider_asn1.git", {tag, "0.4.0"}}} diff --git a/rebar.lock b/rebar.lock index 57afcca..0d93593 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1 +1,4 @@ -[]. +[{<<"logger_color_formatter">>, + {git,"https://github.com/rlipscombe/logger_color_formatter.git", + {ref,"f1c96f979e6350f8cd787d27fe9ff003cbf3416b"}}, + 0}]. -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37043?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: Icb24c9ab0f7f236424c08f6461d058d9a6e8a40b Gerrit-Change-Number: 37043 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-s1gw[master]: sctp_server: fix terminate/2: match any Reason
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37045?usp=email ) Change subject: sctp_server: fix terminate/2: match any Reason ...................................................................... sctp_server: fix terminate/2: match any Reason Change-Id: I57f1604ef3febee6c330521a044271988110cf2a --- M src/sctp_server.erl 1 file changed, 11 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/45/37045/1 diff --git a/src/sctp_server.erl b/src/sctp_server.erl index 4ba49eb..a2b722a 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -102,8 +102,8 @@ {noreply, State}. -terminate(shutdown, State) -> - logger:notice("Terminating ~p", [?MODULE]), +terminate(Reason, State) -> + logger:notice("Terminating, reason ~p", [Reason]), close_conns(State), gen_sctp:close(State#server_state.sock), ok. -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37045?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I57f1604ef3febee6c330521a044271988110cf2a Gerrit-Change-Number: 37045 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-s1gw[master]: config/sys.config: add default environment params
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37047?usp=email ) Change subject: config/sys.config: add default environment params ...................................................................... config/sys.config: add default environment params Change-Id: Ie5ec9f62d77407152e18ea3c20cf401151fa6aea --- M config/sys.config M src/osmo_s1gw_sup.erl 2 files changed, 22 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/47/37047/1 diff --git a/config/sys.config b/config/sys.config index dcace60..8055631 100644 --- a/config/sys.config +++ b/config/sys.config @@ -1,6 +1,16 @@ %% -*- erlang -*- -[{kernel, +[%% =========================================== + %% application config + %% =========================================== + {osmo_s1gw, + [{s1gw_bind_addr, "127.0.1.1"}, %% S1GW bind address for incoming eNB connections + {mme_addr, "127.0.2.1"} %% MME address for outgoing connections + ]}, + %% =========================================== + %% kernel config + %% =========================================== + {kernel, [{logger_level, info}, {logger, [{handler, default, logger_std_h, diff --git a/src/osmo_s1gw_sup.erl b/src/osmo_s1gw_sup.erl index a62f266..4c93756 100644 --- a/src/osmo_s1gw_sup.erl +++ b/src/osmo_s1gw_sup.erl @@ -8,9 +8,9 @@ -define(SERVER, ?MODULE). -define(ENV_APP_NAME, osmo_s1gw). --define(ENV_DEFAULT_S1GW_BIND_ADDR, "0.0.0.0"). +-define(ENV_DEFAULT_S1GW_BIND_ADDR, "127.0.1.1"). -define(ENV_DEFAULT_S1GW_BIND_PORT, ?S1AP_PORT). --define(ENV_DEFAULT_MME_ADDR, "127.0.0.1"). +-define(ENV_DEFAULT_MME_ADDR, "127.0.2.1"). -define(ENV_DEFAULT_MME_PORT, ?S1AP_PORT). %% ------------------------------------------------------------------ -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37047?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: Ie5ec9f62d77407152e18ea3c20cf401151fa6aea Gerrit-Change-Number: 37047 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in osmo-s1gw[master]: s1ap_proxy: implement patching of E-RAB SETUP REQ/RSP
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37046?usp=email ) Change subject: s1ap_proxy: implement patching of E-RAB SETUP REQ/RSP ...................................................................... s1ap_proxy: implement patching of E-RAB SETUP REQ/RSP Change-Id: I88cb261d93b56a4e0ca06ad1d676d1ac16d115bb --- M src/s1ap_proxy.erl A test/s1ap_proxy_test.erl 2 files changed, 209 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/46/37046/1 diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl index 62701ef..a78f084 100644 --- a/src/s1ap_proxy.erl +++ b/src/s1ap_proxy.erl @@ -1,17 +1,25 @@ -module(s1ap_proxy). --export([handle_pdu/1]). +-export([handle_pdu/1, + encode_pdu/1, + decode_pdu/1]). + +-include("S1AP-PDU-Descriptions.hrl"). +-include("S1AP-PDU-Contents.hrl"). +-include("S1AP-Containers.hrl"). +-include("S1AP-Constants.hrl"). %% ------------------------------------------------------------------ %% public API %% ------------------------------------------------------------------ %% Process an S1AP PDU -handle_pdu(Data) -> +-spec handle_pdu(binary()) -> binary(). +handle_pdu(Data) when is_binary(Data) -> case decode_pdu(Data) of {ok, Pdu} -> logger:info("S1AP PDU: ~p", [Pdu]), - Data; + handle_pdu(Data, Pdu); {error, {asn1, Error}} -> logger:error("S1AP PDU decoding failed: ~p", [Error]), Data @@ -22,10 +30,111 @@ %% private API %% ------------------------------------------------------------------ +%% Encode an S1AP PDU +-spec encode_pdu(tuple()) -> {ok, binary()} | + {error, {asn1, tuple()}}. +encode_pdu(Pdu) -> + 'S1AP-PDU-Descriptions':encode('S1AP-PDU', Pdu). + + %% Decode an S1AP PDU -spec decode_pdu(binary()) -> {ok, tuple()} | {error, {asn1, tuple()}}. decode_pdu(Data) -> 'S1AP-PDU-Descriptions':decode('S1AP-PDU', Data). + +%% Helper function for handle_pdu/2. +%% Attempt to encode a new (modified) S1AP PDU, +%% return a new binary() on success or Data on error. +handle_pdu_new(Data, NewPdu) -> + case encode_pdu(NewPdu) of + {ok, NewData} -> + NewData; + {error, {asn1, Error}} -> + logger:error("S1AP PDU encoding failed: ~p", [Error]), + Data + end. + + +%% E-RAB SETUP REQUEST +handle_pdu(Data, {Outcome = initiatingMessage, + #'InitiatingMessage'{procedureCode = ?'id-E-RABSetup', + value = Content} = Pdu}) -> + logger:debug("Patching E-RAB SETUP REQUEST"), + IEs = handle_ies(Content#'E-RABSetupRequest'.protocolIEs, + ?'id-E-RABToBeSetupListBearerSUReq'), + NewContent = Content#'E-RABSetupRequest'{protocolIEs = IEs}, + handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}); + +%% E-RAB SETUP RESPONSE +handle_pdu(Data, {Outcome = successfulOutcome, + #'SuccessfulOutcome'{procedureCode = ?'id-E-RABSetup', + value = Content} = Pdu}) -> + logger:debug("Patching E-RAB SETUP RESPONSE"), + IEs = handle_ies(Content#'E-RABSetupResponse'.protocolIEs, + ?'id-E-RABSetupListBearerSURes'), + NewContent = Content#'E-RABSetupResponse'{protocolIEs = IEs}, + handle_pdu_new(Data, {Outcome, Pdu#'SuccessfulOutcome'{value = NewContent}}); + +%% Proxy all other messages unmodified +handle_pdu(Data, _Pdu) -> + Data. + + +%% Handle a single IE (Information Element) +-spec handle_ie(tuple()) -> tuple(). + +%% E-RAB SETUP REQUEST related IEs +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeSetupListBearerSUReq', + value = Content}) -> + %% This IE contains a list of BearerSUReq, so patch inner IEs + handle_ies(Content, ?'id-E-RABToBeSetupItemBearerSUReq'); + +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeSetupItemBearerSUReq', + value = Content}) -> + Content#'E-RABToBeSetupItemBearerSUReq'{transportLayerAddress = transp_layer_addr()}; + +%% E-RAB SETUP RESPONSE related IEs +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABSetupListBearerSURes', + value = Content}) -> + %% This IE contains a list of BearerSURes, so patch inner IEs + handle_ies(Content, ?'id-E-RABSetupItemBearerSURes'); + +handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABSetupItemBearerSURes', + value = Content}) -> + Content#'E-RABSetupItemBearerSURes'{transportLayerAddress = transp_layer_addr()}; + +%% Catch-all variant, which should not be called normally +handle_ie(#'ProtocolIE-Field'{value = Content} = IE) -> + logger:error("[BUG] Unhandled S1AP IE: ~p", [IE]), + Content. + + +%% Iterate over the given list of 'ProtocolIE-Field' IEs, +%% calling function handle_ie/1 for IEs matching the given IEI. +-spec handle_ies(list(), integer()) -> list(). +handle_ies(IEs, IEI) -> + handle_ies([], IEs, IEI). + +handle_ies(Acc, [IE | IEs], IEI) -> + case IE of + #'ProtocolIE-Field'{id = IEI} -> + NewIE = IE#'ProtocolIE-Field'{value = handle_ie(IE)}, + handle_ies([NewIE | Acc], IEs, IEI); + _ -> + handle_ies([IE | Acc], IEs, IEI) + end; + +handle_ies(Acc, [], _) -> + lists:reverse(Acc). + + +%% GTP-U IP address (TransportLayerAddress) to be used while patching +transp_layer_addr() -> + AddrStr = application:get_env(osmo_s1gw, transp_layer_addr, "255.255.255.255"), + {ok, Addr} = inet:parse_address(AddrStr), + %% sadly, there exists inet:ntoa/1, but not inet:aton/1 + list_to_binary(tuple_to_list(Addr)). + %% vim:set ts=4 sw=4 et: diff --git a/test/s1ap_proxy_test.erl b/test/s1ap_proxy_test.erl new file mode 100644 index 0000000..408f468 --- /dev/null +++ b/test/s1ap_proxy_test.erl @@ -0,0 +1,88 @@ +-module(s1ap_proxy_test). + +-include_lib("eunit/include/eunit.hrl"). + +%% ------------------------------------------------------------------ +%% testcases +%% ------------------------------------------------------------------ + +%% S1 SETUP REQUEST +s1_setup_req_pdu() -> + << 16#00, 16#11, 16#00, 16#1a, 16#00, 16#00, 16#02, 16#00, + 16#3b, 16#40, 16#08, 16#00, 16#00, 16#f1, 16#10, 16#00, + 16#00, 16#00, 16#00, 16#00, 16#40, 16#00, 16#07, 16#00, + 16#0c, 16#0e, 16#40, 16#00, 16#f1, 16#10 + >>. + +s1_setup_req_test() -> + OrigData = s1_setup_req_pdu(), + %% Expect the PDU to be proxied unmodified + ?assertEqual(OrigData, s1ap_proxy:handle_pdu(OrigData)). + + +%% E-RAB SETUP REQUEST +e_rab_setup_req_pdu(TLA, TEID) when is_binary(TLA), + is_binary(TEID) -> + << 16#00, 16#05, 16#00, 16#80, 16#9b, 16#00, 16#00, 16#03, + 16#00, 16#00, 16#00, 16#02, 16#00, 16#07, 16#00, 16#08, + 16#00, 16#02, 16#00, 16#09, 16#00, 16#10, 16#00, 16#80, + 16#87, 16#00, 16#00, 16#11, 16#00, 16#80, 16#81, 16#0c, + 16#00, 16#05, 16#04, 16#0f, 16#80, + TLA/bytes, %% transportLayerAddress (IPv4) + TEID/bytes, %% GTP-TEID + 16#72, 16#27, 16#c8, + 16#1a, 16#bc, 16#ec, 16#11, 16#62, 16#54, 16#c1, 16#01, + 16#05, 16#04, 16#03, 16#69, 16#6d, 16#73, 16#05, 16#01, + 16#c0, 16#a8, 16#65, 16#02, 16#5e, 16#02, 16#b3, 16#8c, + 16#58, 16#32, 16#27, 16#54, 16#80, 16#80, 16#21, 16#10, + 16#02, 16#00, 16#00, 16#10, 16#81, 16#06, 16#08, 16#08, + 16#08, 16#08, 16#83, 16#06, 16#08, 16#08, 16#04, 16#04, + 16#00, 16#0d, 16#04, 16#08, 16#08, 16#08, 16#08, 16#00, + 16#0d, 16#04, 16#08, 16#08, 16#04, 16#04, 16#00, 16#03, + 16#10, 16#20, 16#01, 16#48, 16#60, 16#48, 16#60, 16#00, + 16#00, 16#00, 16#00, 16#00, 16#00, 16#00, 16#00, 16#88, + 16#88, 16#00, 16#03, 16#10, 16#20, 16#01, 16#48, 16#60, + 16#48, 16#60, 16#00, 16#00, 16#00, 16#00, 16#00, 16#00, + 16#00, 16#00, 16#88, 16#44, 16#00, 16#0c, 16#04, 16#ac, + 16#16, 16#00, 16#15, 16#00, 16#10, 16#02, 16#05, 16#78 + >>. + +e_rab_setup_req_test() -> + %% Original input data + TEID = << 16#00, 16#00, 16#00, 16#18 >>, + OrigTLA = << 16#ac, 16#16, 16#00, 16#06 >>, + OrigData = e_rab_setup_req_pdu(OrigTLA, TEID), + + %% Expected output data + ExpTLA = << 16#7f, 16#00, 16#00, 16#01 >>, + ExpData = e_rab_setup_req_pdu(ExpTLA, TEID), + + application:set_env(osmo_s1gw, transp_layer_addr, "127.0.0.1"), + ?assertEqual(ExpData, s1ap_proxy:handle_pdu(OrigData)). + + +%% E-RAB SETUP RESPONSE +e_rab_setup_rsp_pdu(TLA, TEID) when is_binary(TLA), + is_binary(TEID) -> + << 16#20, 16#05, 16#00, 16#22, 16#00, 16#00, 16#03, 16#00, + 16#00, 16#40, 16#02, 16#00, 16#07, 16#00, 16#08, 16#40, + 16#02, 16#00, 16#09, 16#00, 16#1c, 16#40, 16#0f, 16#00, + 16#00, 16#27, 16#40, 16#0a, 16#0c, 16#1f, + TLA/bytes, %% transportLayerAddress (IPv4) + TEID/bytes %% GTP-TEID + >>. + +e_rab_setup_rsp_test() -> + %% Original input data + TEID = << 16#6c, 16#05, 16#bf, 16#56 >>, + OrigTLA = << 16#c0, 16#a8, 16#68, 16#a7 >>, + OrigData = e_rab_setup_rsp_pdu(OrigTLA, TEID), + + %% Expected output data + ExpTLA = << 16#7f, 16#00, 16#00, 16#01 >>, + ExpData = e_rab_setup_rsp_pdu(ExpTLA, TEID), + + application:set_env(osmo_s1gw, transp_layer_addr, "127.0.0.1"), + ?assertEqual(ExpData, s1ap_proxy:handle_pdu(OrigData)). + +%% vim:set ts=4 sw=4 et: -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37046?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I88cb261d93b56a4e0ca06ad1d676d1ac16d115bb Gerrit-Change-Number: 37046 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in osmo-s1gw[master]: .gitignore: ignore generated S1AP code
by osmith 05 Jun '24

05 Jun '24
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-s1gw/+/37038?usp=email ) Change subject: .gitignore: ignore generated S1AP code ...................................................................... .gitignore: ignore generated S1AP code Change-Id: I89df49e1290f32d2fabbc4ffd9a5767bf0fdac00 --- M .gitignore 1 file changed, 13 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-s1gw refs/changes/38/37038/1 diff --git a/.gitignore b/.gitignore index 83aa88b..483ba30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ _build *.beam + +# generated S1AP code +/include/S1AP-*.hrl +/src/S1AP-*.erl -- To view, visit https://gerrit.osmocom.org/c/osmo-s1gw/+/37038?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I89df49e1290f32d2fabbc4ffd9a5767bf0fdac00 Gerrit-Change-Number: 37038 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • ...
  • 157
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.