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

July 2024

  • 1 participants
  • 1379 discussions
[S] Change in osmo-ttcn3-hacks[master]: asterisk: Increase timeout waiting for AMI event FullyBooted
by pespin 11 Jul '24

11 Jul '24
Attention is currently required from: fixeria, jolly, laforge. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37455?usp=email ) Change subject: asterisk: Increase timeout waiting for AMI event FullyBooted ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37455?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ibd2bbdc4b916b5baca01407bac3cc5e9a99500e3 Gerrit-Change-Number: 37455 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Thu, 11 Jul 2024 08:18:44 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: asterisk: Increase timeout waiting for AMI event FullyBooted
by pespin 10 Jul '24

10 Jul '24
Attention is currently required from: fixeria, jolly, laforge, pespin. Hello Jenkins Builder, fixeria, jolly, laforge, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37455?usp=email to look at the new patch set (#3). The following approvals got outdated and were removed: Code-Review+1 by fixeria, Code-Review+1 by laforge Change subject: asterisk: Increase timeout waiting for AMI event FullyBooted ...................................................................... asterisk: Increase timeout waiting for AMI event FullyBooted Change-Id: Ibd2bbdc4b916b5baca01407bac3cc5e9a99500e3 --- M asterisk/Asterisk_Tests.ttcn 1 file changed, 12 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/55/37455/3 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37455?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ibd2bbdc4b916b5baca01407bac3cc5e9a99500e3 Gerrit-Change-Number: 37455 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: jolly <andreas(a)eversberg.eu> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[M] Change in ...osmo-s1gw[master]: {sctp,s1ap}_proxy: employ E-RAB FSMs
by fixeria 10 Jul '24

10 Jul '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37463?usp=email ) Change subject: {sctp,s1ap}_proxy: employ E-RAB FSMs ...................................................................... {sctp,s1ap}_proxy: employ E-RAB FSMs Change-Id: Ibb7e25ab3adbadd7fd85e9cb22e0136c6ca133cf --- M src/s1ap_proxy.erl M src/sctp_proxy.erl 2 files changed, 71 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/63/37463/1 diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl index eaa7dfd..f1a2726 100644 --- a/src/s1ap_proxy.erl +++ b/src/s1ap_proxy.erl @@ -37,6 +37,7 @@ -export([init/0, deinit/1, handle_pdu/2, + handle_exit/2, encode_pdu/1, decode_pdu/1]). @@ -48,7 +49,7 @@ -include("S1AP-Constants.hrl"). --record(proxy_state, { }). +-record(proxy_state, {erabs :: dict:dict()}). -type proxy_state() :: #proxy_state{}. @@ -59,7 +60,7 @@ %% Initialize per-connection data -spec init() -> proxy_state(). init() -> - #proxy_state{}. + #proxy_state{erabs = dict:new()}. %% De-initialize per-connection data @@ -81,6 +82,13 @@ end. +%% Handle an exit event +-spec handle_exit(pid(), proxy_state()) -> proxy_state(). +handle_exit(Pid, #proxy_state{erabs = ERABs} = S) -> + Fun = fun(_Key, Val) -> Val =/= Pid end, + S#proxy_state{erabs = dict:filter(Fun, ERABs)}. + + %% ------------------------------------------------------------------ %% private API %% ------------------------------------------------------------------ @@ -99,6 +107,18 @@ 'S1AP-PDU-Descriptions':decode('S1AP-PDU', Data). +%% Decode TEID from binary to integer +-spec decode_teid(binary()) -> non_neg_integer(). +decode_teid(<< TEID:32/big >>) -> + TEID. + + +%% Encode TEID from integer to binary +-spec encode_teid(non_neg_integer()) -> binary(). +encode_teid(TEID) when is_integer(TEID) -> + << TEID:32/big >>. + + %% Helper function for handle_pdu/3. %% Attempt to encode a new (modified) S1AP PDU, %% return a new binary() on success or Data on error. @@ -189,10 +209,16 @@ handle_ies(Content, ?'id-E-RABToBeSetupItemBearerSUReq', S); handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeSetupItemBearerSUReq', - value = Content}, S) -> + value = Content}, S0) -> %% eNB -> MME direction: we pass our MME facing local address TLA = transp_layer_addr(mme_loc_addr), - {Content#'E-RABToBeSetupItemBearerSUReq'{transportLayerAddress = TLA}, S}; + %% start and register an E-RAB FSM + #'E-RABToBeSetupItemBearerSUReq'{'e-RAB-ID' = ERABId, + 'gTP-TEID' = TEID_FromAcc} = Content, + {Pid, S1} = erab_fsm_start_reg(ERABId, S0), + {ok, TEID_ToCore} = erab_fsm:erab_setup_req(Pid, decode_teid(TEID_FromAcc)), + {Content#'E-RABToBeSetupItemBearerSUReq'{transportLayerAddress = TLA, + 'gTP-TEID' = encode_teid(TEID_ToCore)}, S1}; %% E-RAB SETUP RESPONSE related IEs handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABSetupListBearerSURes', @@ -201,10 +227,22 @@ handle_ies(Content, ?'id-E-RABSetupItemBearerSURes', S); handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABSetupItemBearerSURes', - value = Content}, S) -> + value = C0}, S) -> %% MME -> eNB direction: we pass our eNB facing local address TLA = transp_layer_addr(s1gw_bind_addr), - {Content#'E-RABSetupItemBearerSURes'{transportLayerAddress = TLA}, S}; + %% poke E-RAB FSM + #'E-RABSetupItemBearerSURes'{'e-RAB-ID' = ERABId, + 'gTP-TEID' = TEID_FromCore} = C0, + C1 = case dict:find(ERABId, S#proxy_state.erabs) of + {ok, Pid} -> + {ok, TEID_ToAcc} = erab_fsm:erab_setup_rsp(Pid, decode_teid(TEID_FromCore)), + C0#'E-RABSetupItemBearerSURes'{transportLayerAddress = TLA, + 'gTP-TEID' = encode_teid(TEID_ToAcc)}; + error -> + ?LOG_ERROR("E-RAB-ID ~p is not registered", [ERABId]), + C0#'E-RABSetupItemBearerSURes'{transportLayerAddress = TLA} + end, + {C1, S}; %% E-RAB MODIFICATION INDICATION related IEs handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeModifiedListBearerModInd', @@ -287,4 +325,15 @@ %% sadly, there exists inet:ntoa/1, but not inet:aton/1 list_to_binary(tuple_to_list(Addr)). + +-spec erab_fsm_start_reg(non_neg_integer(), proxy_state()) -> {pid(), proxy_state()}. +erab_fsm_start_reg(RABId, S) -> + {ok, Pid} = erab_fsm:start_link(RABId), %% TODO: add {eNB,MME}-UE-ID + {Pid, erab_fsm_reg(RABId, Pid, S)}. + + +-spec erab_fsm_reg(non_neg_integer(), pid(), proxy_state()) -> proxy_state(). +erab_fsm_reg(RABId, Pid, #proxy_state{erabs = ERABs} = S) -> + S#proxy_state{erabs = dict:store(RABId, Pid, ERABs)}. + %% vim:set ts=4 sw=4 et: diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index 148e00a..1d8d305 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -167,6 +167,13 @@ sctp_server:send_data(EnbAid, NewData), {keep_state, S#{priv := NewPriv}}; +%% Handle termination events of the child processes +connected(info, {'EXIT', Pid, Reason}, + #{priv := Priv} = S) -> + ?LOG_DEBUG("Child process ~p terminated with reason ~p", [Pid, Reason]), + NewPriv = s1ap_proxy:handle_exit(Pid, Priv), + {keep_state, S#{priv := NewPriv}}; + %% Catch-all for other kinds of SCTP events connected(info, {sctp, _Socket, MmeAddr, MmePort, {AncData, Data}}, S) -> -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37463?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: Ibb7e25ab3adbadd7fd85e9cb22e0136c6ca133cf Gerrit-Change-Number: 37463 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in ...osmo-s1gw[master]: sctp_proxy: fix typo in field name: s/mmr_port/mme_port/g
by fixeria 10 Jul '24

10 Jul '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37459?usp=email ) Change subject: sctp_proxy: fix typo in field name: s/mmr_port/mme_port/g ...................................................................... sctp_proxy: fix typo in field name: s/mmr_port/mme_port/g Change-Id: I0c3d5a979aaa494cb0b2bd3da9118d9fedf7027f --- M src/sctp_proxy.erl 1 file changed, 11 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/59/37459/1 diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index d325622..85b5c3d 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -78,7 +78,7 @@ {ok, connecting, #{enb_aid => Aid, mme_addr => MmeAddr, - mmr_port => MmePort, + mme_port => MmePort, tx_queue => []}}. @@ -88,7 +88,7 @@ %% CONNECTING state connecting(enter, OldState, - #{mme_addr := MmeAddr, mmr_port := MmePort} = S) -> + #{mme_addr := MmeAddr, mme_port := MmePort} = S) -> ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), %% Initiate connection establishment with the MME {ok, Sock} = sctp_client:connect(MmeAddr, MmePort), -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37459?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I0c3d5a979aaa494cb0b2bd3da9118d9fedf7027f Gerrit-Change-Number: 37459 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in ...osmo-s1gw[master]: sctp_client: add type hints
by fixeria 10 Jul '24

10 Jul '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37457?usp=email ) Change subject: sctp_client: add type hints ...................................................................... sctp_client: add type hints Change-Id: I89f237706dfbd6004e7644b3b68446fab7f31c7c --- M src/sctp_client.erl 1 file changed, 28 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/57/37457/1 diff --git a/src/sctp_client.erl b/src/sctp_client.erl index 24ec75d..ab02791 100644 --- a/src/sctp_client.erl +++ b/src/sctp_client.erl @@ -46,16 +46,33 @@ -include("s1ap.hrl"). + +-type loc_addr() :: any | list() | inet:ip_address(). +-type rem_addr() :: localhost | list() | inet:ip_address(). +-type loc_rem_addr() :: {loc_addr(), rem_addr()}. +-type connect_result() :: {ok, gen_sctp:sctp_socket()}. +-type sock_aid() :: {gen_sctp:sctp_socket(), + gen_sctp:assoc_id()}. + +-export_type([loc_addr/0, + rem_addr/0, + loc_rem_addr/0, + connect_result/0, + sock_aid/0]). + %% ------------------------------------------------------------------ %% public API %% ------------------------------------------------------------------ +-spec connect() -> connect_result(). connect() -> connect({any, localhost}). +-spec connect(loc_rem_addr()) -> connect_result(). connect(LocRemAddr) -> connect(LocRemAddr, ?S1AP_PORT). +-spec connect(loc_rem_addr(), inet:port_number()) -> connect_result(). connect({LocAddrStr, RemAddr}, Port) when is_list(LocAddrStr) -> {ok, LocAddr} = inet:parse_address(LocAddrStr), connect({LocAddr, RemAddr}, Port); @@ -72,12 +89,14 @@ {ok, Sock}. +-spec send_data(sock_aid(), binary()) -> ok | {error, term()}. send_data({Sock, Aid}, Data) -> gen_sctp:send(Sock, #sctp_sndrcvinfo{stream = ?S1AP_SCTP_STREAM, ppid = ?S1AP_SCTP_PPID, assoc_id = Aid}, Data). +-spec disconnect(sock_aid()) -> ok | {error, term()}. disconnect({Sock, Aid}) -> gen_sctp:eof(Sock, #sctp_assoc_change{assoc_id = Aid}). -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37457?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I89f237706dfbd6004e7644b3b68446fab7f31c7c Gerrit-Change-Number: 37457 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in ...osmo-s1gw[master]: sctp_proxy: add type hints for public API
by fixeria 10 Jul '24

10 Jul '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37458?usp=email ) Change subject: sctp_proxy: add type hints for public API ...................................................................... sctp_proxy: add type hints for public API Change-Id: I307e51f1130f08c219c6817629b856764ef7df59 --- M src/sctp_proxy.erl 1 file changed, 14 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/58/37458/1 diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index 350f655..d325622 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -53,14 +53,19 @@ %% public API %% ------------------------------------------------------------------ +-spec start_link(gen_sctp:assoc_id(), + sctp_client:loc_rem_addr(), + inet:port_number()) -> gen_statem:start_ret(). start_link(Aid, MmeAddr, MmePort) -> gen_statem:start_link(?MODULE, [Aid, MmeAddr, MmePort], []). +-spec send_data(pid(), binary()) -> ok. send_data(Pid, Data) -> gen_statem:cast(Pid, {send_data, Data}). +-spec shutdown(pid()) -> ok. shutdown(Pid) -> gen_statem:stop(Pid). -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37458?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I307e51f1130f08c219c6817629b856764ef7df59 Gerrit-Change-Number: 37458 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in ...osmo-s1gw[master]: sctp_proxy: handle_pdu/2: print stacktrace on exception
by fixeria 10 Jul '24

10 Jul '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37460?usp=email ) Change subject: sctp_proxy: handle_pdu/2: print stacktrace on exception ...................................................................... sctp_proxy: handle_pdu/2: print stacktrace on exception Change-Id: I7fef18d4462af4b629318922e59cb5aa161fed93 --- M src/sctp_proxy.erl 1 file changed, 11 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/60/37460/1 diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index 85b5c3d..ab147e6 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -204,8 +204,8 @@ try s1ap_proxy:handle_pdu(Data) of NewData -> NewData catch - Exception:Reason -> - ?LOG_ERROR("An exception occurred: ~p, ~p", [Exception, Reason]), + Exception:Reason:StackTrace -> + ?LOG_ERROR("An exception occurred: ~p, ~p, ~p", [Exception, Reason, StackTrace]), Data %% proxy as-is end. -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37460?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I7fef18d4462af4b629318922e59cb5aa161fed93 Gerrit-Change-Number: 37460 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in ...osmo-s1gw[master]: sctp_server: do not let sctp_proxy:shutdown() crash the server
by fixeria 10 Jul '24

10 Jul '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37461?usp=email ) Change subject: sctp_server: do not let sctp_proxy:shutdown() crash the server ...................................................................... sctp_server: do not let sctp_proxy:shutdown() crash the server Change-Id: Iaeedbc66cab21ec7274f864c8daf86c87f21e633 --- M src/sctp_server.erl 1 file changed, 15 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/61/37461/1 diff --git a/src/sctp_server.erl b/src/sctp_server.erl index d0484e6..8ea311f 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -197,7 +197,9 @@ client_del(Clients, Aid) -> case dict:find(Aid, Clients) of {ok, Client} -> - sctp_proxy:shutdown(Client#client_state.pid), + %% the proxy process might be already dead, so we guard + %% against exceptions like noproc or {nodedown,Node}. + catch sctp_proxy:shutdown(Client#client_state.pid), dict:erase(Aid, Clients); error -> Clients @@ -228,7 +230,9 @@ {FromAddr, FromPort} = Client#client_state.addr_port, ?LOG_NOTICE("Terminating eNB connection (id=~p, ~p:~p)", [Aid, FromAddr, FromPort]), %% request to terminate an MME connection - sctp_proxy:shutdown(Client#client_state.pid), + %% the proxy process might be already dead, so we guard + %% against exceptions like noproc or {nodedown,Node}. + catch sctp_proxy:shutdown(Client#client_state.pid), %% gracefully close an eNB connection gen_sctp:eof(Sock, #sctp_assoc_change{assoc_id = Aid}), %% ... and so for the remaining clients -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37461?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: Iaeedbc66cab21ec7274f864c8daf86c87f21e633 Gerrit-Change-Number: 37461 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[M] Change in ...osmo-s1gw[master]: sctp_proxy: maintain opaque state for s1ap_proxy
by fixeria 10 Jul '24

10 Jul '24
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37462?usp=email ) Change subject: sctp_proxy: maintain opaque state for s1ap_proxy ...................................................................... sctp_proxy: maintain opaque state for s1ap_proxy Change-Id: I6ea8479c1a66bca330a7d4030cc7cdf55a76b12c --- M src/s1ap_proxy.erl M src/sctp_proxy.erl 2 files changed, 131 insertions(+), 91 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/62/37462/1 diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl index 579df40..eaa7dfd 100644 --- a/src/s1ap_proxy.erl +++ b/src/s1ap_proxy.erl @@ -34,7 +34,9 @@ -module(s1ap_proxy). --export([handle_pdu/1, +-export([init/0, + deinit/1, + handle_pdu/2, encode_pdu/1, decode_pdu/1]). @@ -45,20 +47,37 @@ -include("S1AP-Containers.hrl"). -include("S1AP-Constants.hrl"). + +-record(proxy_state, { }). + +-type proxy_state() :: #proxy_state{}. + %% ------------------------------------------------------------------ %% public API %% ------------------------------------------------------------------ +%% Initialize per-connection data +-spec init() -> proxy_state(). +init() -> + #proxy_state{}. + + +%% De-initialize per-connection data +-spec deinit(proxy_state()) -> ok. +deinit(_S) -> + ok. + + %% Process an S1AP PDU --spec handle_pdu(binary()) -> binary(). -handle_pdu(Data) when is_binary(Data) -> +-spec handle_pdu(binary(), proxy_state()) -> {binary(), proxy_state()}. +handle_pdu(Data, S) when is_binary(Data) -> case decode_pdu(Data) of {ok, Pdu} -> ?LOG_INFO("S1AP PDU: ~p", [Pdu]), - handle_pdu(Data, Pdu); + handle_pdu(Data, Pdu, S); {error, {asn1, Error}} -> ?LOG_ERROR("S1AP PDU decoding failed: ~p", [Error]), - Data + {Data, S} end. @@ -80,73 +99,73 @@ 'S1AP-PDU-Descriptions':decode('S1AP-PDU', Data). -%% Helper function for handle_pdu/2. +%% Helper function for handle_pdu/3. %% Attempt to encode a new (modified) S1AP PDU, %% return a new binary() on success or Data on error. -handle_pdu_new(Data, NewPdu) -> +handle_pdu_new(Data, NewPdu, S) -> case encode_pdu(NewPdu) of {ok, NewData} -> - NewData; + {NewData, S}; {error, {asn1, Error}} -> ?LOG_ERROR("S1AP PDU encoding failed: ~p", [Error]), - Data + {Data, S} end. %% 9.1.3.1 E-RAB SETUP REQUEST handle_pdu(Data, {Outcome = initiatingMessage, #'InitiatingMessage'{procedureCode = ?'id-E-RABSetup', - value = Content} = Pdu}) -> + value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching E-RAB SETUP REQUEST"), - IEs = handle_ies(Content#'E-RABSetupRequest'.protocolIEs, - ?'id-E-RABToBeSetupListBearerSUReq'), + {IEs, S1} = handle_ies(Content#'E-RABSetupRequest'.protocolIEs, + ?'id-E-RABToBeSetupListBearerSUReq', S0), NewContent = Content#'E-RABSetupRequest'{protocolIEs = IEs}, - handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}); + handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}, S1); %% 9.1.3.2 E-RAB SETUP RESPONSE handle_pdu(Data, {Outcome = successfulOutcome, #'SuccessfulOutcome'{procedureCode = ?'id-E-RABSetup', - value = Content} = Pdu}) -> + value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching E-RAB SETUP RESPONSE"), - IEs = handle_ies(Content#'E-RABSetupResponse'.protocolIEs, - ?'id-E-RABSetupListBearerSURes'), + {IEs, S1} = handle_ies(Content#'E-RABSetupResponse'.protocolIEs, + ?'id-E-RABSetupListBearerSURes', S0), NewContent = Content#'E-RABSetupResponse'{protocolIEs = IEs}, - handle_pdu_new(Data, {Outcome, Pdu#'SuccessfulOutcome'{value = NewContent}}); + handle_pdu_new(Data, {Outcome, Pdu#'SuccessfulOutcome'{value = NewContent}}, S1); %% TODO: 9.1.3.3 E-RAB MODIFY REQUEST / (Optional) Transport Information %% 9.1.3.8 E-RAB MODIFICATION INDICATION handle_pdu(Data, {Outcome = initiatingMessage, #'InitiatingMessage'{procedureCode = ?'id-E-RABModificationIndication', - value = Content} = Pdu}) -> + value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching E-RAB MODIFICATION INDICATION"), IEs = Content#'E-RABModificationIndication'.protocolIEs, %% E-RAB to be Modified List - IEs1 = handle_ies(IEs, ?'id-E-RABToBeModifiedListBearerModInd'), + {IEs1, S1} = handle_ies(IEs, ?'id-E-RABToBeModifiedListBearerModInd', S0), %% E-RAB not to be Modified List - IEs2 = handle_ies(IEs1, ?'id-E-RABNotToBeModifiedListBearerModInd'), + {IEs2, S2} = handle_ies(IEs1, ?'id-E-RABNotToBeModifiedListBearerModInd', S1), NewContent = Content#'E-RABModificationIndication'{protocolIEs = IEs2}, - handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}); + handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}, S2); %% 9.1.4.1 INITIAL CONTEXT SETUP REQUEST handle_pdu(Data, {Outcome = initiatingMessage, #'InitiatingMessage'{procedureCode = ?'id-InitialContextSetup', - value = Content} = Pdu}) -> + value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching INITIAL CONTEXT SETUP REQUEST"), - IEs = handle_ies(Content#'InitialContextSetupRequest'.protocolIEs, - ?'id-E-RABToBeSetupListCtxtSUReq'), + {IEs, S1} = handle_ies(Content#'InitialContextSetupRequest'.protocolIEs, + ?'id-E-RABToBeSetupListCtxtSUReq', S0), NewContent = Content#'InitialContextSetupRequest'{protocolIEs = IEs}, - handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}); + handle_pdu_new(Data, {Outcome, Pdu#'InitiatingMessage'{value = NewContent}}, S1); %% 9.1.4.3 INITIAL CONTEXT SETUP RESPONSE handle_pdu(Data, {Outcome = successfulOutcome, #'SuccessfulOutcome'{procedureCode = ?'id-InitialContextSetup', - value = Content} = Pdu}) -> + value = Content} = Pdu}, S0) -> ?LOG_DEBUG("Patching INITIAL CONTEXT SETUP RESPONSE"), - IEs = handle_ies(Content#'InitialContextSetupResponse'.protocolIEs, - ?'id-E-RABSetupListCtxtSURes'), + {IEs, S1} = handle_ies(Content#'InitialContextSetupResponse'.protocolIEs, + ?'id-E-RABSetupListCtxtSURes', S0), NewContent = Content#'InitialContextSetupResponse'{protocolIEs = IEs}, - handle_pdu_new(Data, {Outcome, Pdu#'SuccessfulOutcome'{value = NewContent}}); + handle_pdu_new(Data, {Outcome, Pdu#'SuccessfulOutcome'{value = NewContent}}, S1); %% TODO: 9.1.5.2 HANDOVER COMMAND :: (O) UL/DL Transport Layer Address %% TODO: 9.1.5.4 HANDOVER REQUEST :: (M) Transport Layer Address @@ -156,107 +175,108 @@ %% TODO: 9.1.5.9 PATH SWITCH REQUEST ACKNOWLEDGE :: (M) Transport Layer Address %% Proxy all other messages unmodified -handle_pdu(Data, _Pdu) -> - Data. +handle_pdu(Data, _Pdu, S) -> + {Data, S}. %% Handle a single IE (Information Element) --spec handle_ie(tuple()) -> tuple(). +-spec handle_ie(tuple(), proxy_state()) -> {tuple(), proxy_state()}. %% E-RAB SETUP REQUEST related IEs handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeSetupListBearerSUReq', - value = Content}) -> + value = Content}, S) -> %% This IE contains a list of BearerSUReq, so patch inner IEs - handle_ies(Content, ?'id-E-RABToBeSetupItemBearerSUReq'); + handle_ies(Content, ?'id-E-RABToBeSetupItemBearerSUReq', S); handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeSetupItemBearerSUReq', - value = Content}) -> + value = Content}, S) -> %% eNB -> MME direction: we pass our MME facing local address TLA = transp_layer_addr(mme_loc_addr), - Content#'E-RABToBeSetupItemBearerSUReq'{transportLayerAddress = TLA}; + {Content#'E-RABToBeSetupItemBearerSUReq'{transportLayerAddress = TLA}, S}; %% E-RAB SETUP RESPONSE related IEs handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABSetupListBearerSURes', - value = Content}) -> + value = Content}, S) -> %% This IE contains a list of BearerSURes, so patch inner IEs - handle_ies(Content, ?'id-E-RABSetupItemBearerSURes'); + handle_ies(Content, ?'id-E-RABSetupItemBearerSURes', S); handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABSetupItemBearerSURes', - value = Content}) -> + value = Content}, S) -> %% MME -> eNB direction: we pass our eNB facing local address TLA = transp_layer_addr(s1gw_bind_addr), - Content#'E-RABSetupItemBearerSURes'{transportLayerAddress = TLA}; + {Content#'E-RABSetupItemBearerSURes'{transportLayerAddress = TLA}, S}; %% E-RAB MODIFICATION INDICATION related IEs handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeModifiedListBearerModInd', - value = Content}) -> + value = Content}, S) -> %% This IE contains a list of BearerModInd, so patch inner IEs - handle_ies(Content, ?'id-E-RABToBeModifiedItemBearerModInd'); + handle_ies(Content, ?'id-E-RABToBeModifiedItemBearerModInd', S); handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeModifiedItemBearerModInd', - value = Content}) -> + value = Content}, S) -> %% eNB -> MME direction: we pass our MME facing local address TLA = transp_layer_addr(mme_loc_addr), - Content#'E-RABToBeModifiedItemBearerModInd'{transportLayerAddress = TLA}; + {Content#'E-RABToBeModifiedItemBearerModInd'{transportLayerAddress = TLA}, S}; handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABNotToBeModifiedListBearerModInd', - value = Content}) -> + value = Content}, S) -> %% This IE contains a list of BearerModInd, so patch inner IEs - handle_ies(Content, ?'id-E-RABNotToBeModifiedItemBearerModInd'); + handle_ies(Content, ?'id-E-RABNotToBeModifiedItemBearerModInd', S); handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABNotToBeModifiedItemBearerModInd', - value = Content}) -> + value = Content}, S) -> %% eNB -> MME direction: we pass our MME facing local address TLA = transp_layer_addr(mme_loc_addr), - Content#'E-RABNotToBeModifiedItemBearerModInd'{transportLayerAddress = TLA}; + {Content#'E-RABNotToBeModifiedItemBearerModInd'{transportLayerAddress = TLA}, S}; %% INITIAL CONTEXT SETUP REQUEST related IEs handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeSetupListCtxtSUReq', - value = Content}) -> + value = Content}, S) -> %% This IE contains a list of CtxtSUReq, so patch inner IEs - handle_ies(Content, ?'id-E-RABToBeSetupItemCtxtSUReq'); + handle_ies(Content, ?'id-E-RABToBeSetupItemCtxtSUReq', S); handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABToBeSetupItemCtxtSUReq', - value = Content}) -> + value = Content}, S) -> %% eNB -> MME direction: we pass our MME facing local address TLA = transp_layer_addr(mme_loc_addr), - Content#'E-RABToBeSetupItemCtxtSUReq'{transportLayerAddress = TLA}; + {Content#'E-RABToBeSetupItemCtxtSUReq'{transportLayerAddress = TLA}, S}; %% INITIAL CONTEXT SETUP RESPONSE related IEs handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABSetupListCtxtSURes', - value = Content}) -> + value = Content}, S) -> %% This IE contains a list of CtxtSURes, so patch inner IEs - handle_ies(Content, ?'id-E-RABSetupItemCtxtSURes'); + handle_ies(Content, ?'id-E-RABSetupItemCtxtSURes', S); handle_ie(#'ProtocolIE-Field'{id = ?'id-E-RABSetupItemCtxtSURes', - value = Content}) -> + value = Content}, S) -> %% MME -> eNB direction: we pass our eNB facing local address TLA = transp_layer_addr(s1gw_bind_addr), - Content#'E-RABSetupItemCtxtSURes'{transportLayerAddress = TLA}; + {Content#'E-RABSetupItemCtxtSURes'{transportLayerAddress = TLA}, S}; %% Catch-all variant, which should not be called normally -handle_ie(#'ProtocolIE-Field'{value = Content} = IE) -> +handle_ie(#'ProtocolIE-Field'{value = Content} = IE, S) -> ?LOG_ERROR("[BUG] Unhandled S1AP IE: ~p", [IE]), - Content. + {Content, S}. %% 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). +-spec handle_ies(list(), integer(), proxy_state()) -> {list(), proxy_state()}. +handle_ies(IEs, IEI, S) -> + handle_ies([], IEs, IEI, S). -handle_ies(Acc, [IE | IEs], IEI) -> +handle_ies(Acc, [IE | IEs], IEI, S0) -> case IE of #'ProtocolIE-Field'{id = IEI} -> - NewIE = IE#'ProtocolIE-Field'{value = handle_ie(IE)}, - handle_ies([NewIE | Acc], IEs, IEI); + {Content, S1} = handle_ie(IE, S0), + NewIE = IE#'ProtocolIE-Field'{value = Content}, + handle_ies([NewIE | Acc], IEs, IEI, S1); _ -> - handle_ies([IE | Acc], IEs, IEI) + handle_ies([IE | Acc], IEs, IEI, S0) end; -handle_ies(Acc, [], _) -> - lists:reverse(Acc). +handle_ies(Acc, [], _IEI, S) -> + {lists:reverse(Acc), S}. %% GTP-U IP address (TransportLayerAddress) to be used while patching diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index ab147e6..148e00a 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -79,7 +79,8 @@ #{enb_aid => Aid, mme_addr => MmeAddr, mme_port => MmePort, - tx_queue => []}}. + tx_queue => [], + priv => s1ap_proxy:init()}}. callback_mode() -> @@ -131,16 +132,16 @@ %% CONNECTED state -connected(enter, OldState, S) -> +connected(enter, OldState, S0) -> ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), %% Send pending eNB -> MME messages (if any) - ok = sctp_send_pending(S), - {keep_state, maps:remove(tx_queue, S)}; + S1 = sctp_send_pending(S0), + {keep_state, S1}; %% Handle an eNB -> MME data forwarding request (forward) -connected(cast, {send_data, Data}, S) -> - ok = sctp_send(S, Data), - {keep_state, S}; +connected(cast, {send_data, Data}, S0) -> + S1 = sctp_send(Data, S0), + {keep_state, S1}; %% Handle an #sctp_assoc_change event (MME connection state) connected(info, {sctp, _Socket, MmeAddr, MmePort, @@ -158,11 +159,13 @@ %% Handle an #sctp_sndrcvinfo event (MME -> eNB data) connected(info, {sctp, _Socket, MmeAddr, MmePort, - {[#sctp_sndrcvinfo{assoc_id = Aid}], Data}}, S) -> + {[#sctp_sndrcvinfo{assoc_id = Aid}], Data}}, + #{enb_aid := EnbAid, priv := Priv} = S) -> ?LOG_DEBUG("MME connection (id=~p, ~p:~p) -> eNB: ~p", [Aid, MmeAddr, MmePort, Data]), - sctp_server:send_data(maps:get(enb_aid, S), handle_pdu(Data)), - {keep_state, S}; + {NewData, NewPriv} = handle_pdu(Data, Priv), + sctp_server:send_data(EnbAid, NewData), + {keep_state, S#{priv := NewPriv}}; %% Catch-all for other kinds of SCTP events connected(info, {sctp, _Socket, MmeAddr, MmePort, @@ -185,7 +188,10 @@ terminate(Reason, State, S) -> ?LOG_NOTICE("Terminating in state ~p, reason ~p", [State, Reason]), case S of - #{sock := Sock, mme_aid := Aid} -> + #{sock := Sock, + mme_aid := Aid, + priv := Priv} -> + s1ap_proxy:deinit(Priv), sctp_client:disconnect({Sock, Aid}), gen_sctp:close(Sock); #{sock := Sock} -> @@ -199,31 +205,36 @@ %% ------------------------------------------------------------------ %% A safe wrapper for s1ap_proxy:handle_pdu/1 --spec handle_pdu(binary()) -> binary(). -handle_pdu(Data) when is_binary(Data) -> - try s1ap_proxy:handle_pdu(Data) of - NewData -> NewData +-spec handle_pdu(binary(), term()) -> {binary(), term()}. +handle_pdu(Data, Priv) when is_binary(Data) -> + try s1ap_proxy:handle_pdu(Data, Priv) of + Result -> Result %% {NewData, NewPriv} catch Exception:Reason:StackTrace -> ?LOG_ERROR("An exception occurred: ~p, ~p, ~p", [Exception, Reason, StackTrace]), - Data %% proxy as-is + {Data, Priv} %% proxy as-is end. %% Send a single message to the MME -sctp_send(#{sock := Sock, mme_aid := Aid}, Data) -> - sctp_client:send_data({Sock, Aid}, handle_pdu(Data)). +sctp_send(Data, + #{sock := Sock, + mme_aid := Aid, + priv := Priv} = S) -> + {NewData, NewPriv} = handle_pdu(Data, Priv), + ok = sctp_client:send_data({Sock, Aid}, NewData), + S#{priv := NewPriv}. %% Send pending messages to the MME sctp_send_pending(#{tx_queue := Pending} = S) -> - sctp_send_pending(S, lists:reverse(Pending)). + sctp_send_pending(lists:reverse(Pending), S). -sctp_send_pending(S, [Data | Pending]) -> - sctp_send(S, Data), - sctp_send_pending(S, Pending); +sctp_send_pending([Data | Pending], S0) -> + S1 = sctp_send(Data, S0), + sctp_send_pending(Pending, S1); -sctp_send_pending(_S, []) -> - ok. +sctp_send_pending([], S) -> + S#{tx_queue := []}. %% vim:set ts=4 sw=4 et: -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37462?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I6ea8479c1a66bca330a7d4030cc7cdf55a76b12c Gerrit-Change-Number: 37462 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[L] Change in pysim[master]: pySim-smpp2sim.py: Simulate SMSC+CN+RAN+UE for OTA testing
by fixeria 10 Jul '24

10 Jul '24
Attention is currently required from: dexter. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/37456?usp=email ) Change subject: pySim-smpp2sim.py: Simulate SMSC+CN+RAN+UE for OTA testing ...................................................................... Patch Set 3: (5 comments) File pySim-smpp2sim.py: https://gerrit.osmocom.org/c/pysim/+/37456/comment/501d4171_5a319bc1 PS3, Line 34: from pprint no longer used? https://gerrit.osmocom.org/c/pysim/+/37456/comment/b0223980_2b60ec94 PS3, Line 41: from zope.interface import implementer curious: what package this belongs to? https://gerrit.osmocom.org/c/pysim/+/37456/comment/5b06594f_beadc2da PS3, Line 59: logger = logging.getLogger(__name__) so you have a module local logger module (which is good), but still mostly using the root logger (`logging.foo()` instead of `logger.foo()`) down below? https://gerrit.osmocom.org/c/pysim/+/37456/comment/36e53396_371fc409 PS3, Line 95: submit unused? https://gerrit.osmocom.org/c/pysim/+/37456/comment/f8ed11e9_6b1dd4e5 PS3, Line 101: data FYI: you can use `pformat()` from `pprint` as follows: ``` logging.info(pformat(data)) ``` in case you still want to achieve pretty printing like in previous patchset revision. -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37456?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ie5bae9d823bca6f6c658bd455303f63bace2258c Gerrit-Change-Number: 37456 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Wed, 10 Jul 2024 18:32:29 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • ...
  • 138
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.