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 -----
  • 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

March 2025

  • 1 participants
  • 1378 discussions
[XS] Change in libosmo-abis[master]: trau_frame cosmetic: fix doxygen comments
by falconia 04 Mar '25

04 Mar '25
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39667?usp=email ) Change subject: trau_frame cosmetic: fix doxygen comments ...................................................................... trau_frame cosmetic: fix doxygen comments Change-Id: I5a69c25c4abeef0b62d92bedc2c56a2d533390c5 --- M src/trau/trau_frame.c 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/67/39667/1 diff --git a/src/trau/trau_frame.c b/src/trau/trau_frame.c index 74f4526..b8085c2 100644 --- a/src/trau/trau_frame.c +++ b/src/trau/trau_frame.c @@ -1231,10 +1231,10 @@ /*! Encode a TRAU frame from its decoded representation to a sequence of unpacked bits. - * \param[out] bits caller-allocated buffer for unpacked outpud bits + * \param[out] bits caller-allocated buffer for unpacked output bits * \param[in] n_bits size of 'bits' output buffer in number of unpacked bits * \param[in] fr decoded representation of TRAU frame to be encoded - * \return 0 number of unpacked output bits generated; negative in case of error + * \returns number of unpacked output bits generated; negative in case of error * * This function exhibits a behavioral quirk which users need to be aware of: * for many frame types, the first 5 bits out of user-provided fr->c_bits[] @@ -1326,10 +1326,10 @@ } /*! Encode a TFO frame from its decoded representation to a sequence of unpacked bits. - * \param[out] bits caller-allocated buffer for unpacked outpud bits + * \param[out] bits caller-allocated buffer for unpacked output bits * \param[in] n_bits size of 'bits' output buffer in number of unpacked bits * \param[in] fr decoded representation of TRAU frame to be encoded - * \return 0 number of unpacked output bits generated; negative in case of error + * \returns number of unpacked output bits generated; negative in case of error * * Compared to regular osmo_trau_frame_encode(), this TFO-specific TRAU frame * encoding function restricts the set of possible frame types to those that -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39667?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: I5a69c25c4abeef0b62d92bedc2c56a2d533390c5 Gerrit-Change-Number: 39667 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <falcon(a)freecalypso.org>
1 0
0 0
[S] Change in libosmo-abis[master]: trau_frame encode8_hr: simplify setting of C5 for odd parity
by falconia 04 Mar '25

04 Mar '25
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39669?usp=email ) Change subject: trau_frame encode8_hr: simplify setting of C5 for odd parity ...................................................................... trau_frame encode8_hr: simplify setting of C5 for odd parity As detailed in the previous commit, the API "contract" of osmo_trau_frame_encode() for OSMO_TRAU8_SPEECH in DL direction immortalizes a strange choice where C4 is controlled by the user while C1..C3 and C5 are overridden by the function. C5 is the odd parity bit; because C1..C3 are fixed and only C4 comes from the user, the correct odd parity bit C5 can be set more efficiently by simply inverting C4, skipping full computation of OP. Change-Id: I30c7dfdaaadd0fd4cb084cf02c66c0f19a40ae42 --- M src/trau/trau_frame.c 1 file changed, 6 insertions(+), 18 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/69/39669/1 diff --git a/src/trau/trau_frame.c b/src/trau/trau_frame.c index 652c703..3e8364a 100644 --- a/src/trau/trau_frame.c +++ b/src/trau/trau_frame.c @@ -812,23 +812,6 @@ return 0; } -/* compute the odd parity bit of the given input bit sequence */ -static ubit_t compute_odd_parity(const ubit_t *in, unsigned int num_bits) -{ - int i; - unsigned int sum = 0; - - for (i = 0; i < num_bits; i++) { - if (in[i]) - sum++; - } - - if (sum & 1) - return 0; - else - return 1; -} - /* TS 08.61 Section 5.2.1.1 */ static int encode8_hr(ubit_t *trau_bits, const struct osmo_trau_frame *fr, bool is_tfo) { @@ -855,11 +838,16 @@ cbits_out[4] = 0; } } else { + /* Per backward-compatible API "contract", we consider only + * fr->c_bits[3] set by the user, and override the other 4 + * bits. C1..C3 are constant frame type code; C5 is odd + * parity, which in this case is always the inverse of C4. + */ cbits_out[0] = 0; cbits_out[1] = 0; cbits_out[2] = 0; cbits_out[3] = fr->c_bits[3]; - cbits_out[4] = compute_odd_parity(cbits_out, 4); + cbits_out[4] = !fr->c_bits[3]; } /* XC1 .. XC2 */ -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39669?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: I30c7dfdaaadd0fd4cb084cf02c66c0f19a40ae42 Gerrit-Change-Number: 39669 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <falcon(a)freecalypso.org>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: stp: STP_Tests.ttcn: Use M3UA PC and RCTX from config
by laforge 03 Mar '25

03 Mar '25
Attention is currently required from: pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39662?usp=email ) Change subject: stp: STP_Tests.ttcn: Use M3UA PC and RCTX from config ...................................................................... Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39662?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I81c8402d5ccd6e59f2a6869927c637fff30cb952 Gerrit-Change-Number: 39662 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Mon, 03 Mar 2025 22:39:41 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[M] Change in osmo-ttcn3-hacks[master]: stp: Fix brokeness in STP_Tests_M3UA.TC_tmt_loadshare
by laforge 03 Mar '25

03 Mar '25
Attention is currently required from: fixeria, osmith, pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39651?usp=email ) Change subject: stp: Fix brokeness in STP_Tests_M3UA.TC_tmt_loadshare ...................................................................... Patch Set 6: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/39651?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I16d81cb2f88bb2927f248182ad4f8f27c8c24859 Gerrit-Change-Number: 39651 Gerrit-PatchSet: 6 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 03 Mar 2025 22:38:27 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[S] Change in ...osmo-s1gw[master]: s1gw_metrics: use lists:filter/2 to create counters/gauges
by laforge 03 Mar '25

03 Mar '25
Attention is currently required from: fixeria. laforge has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39665?usp=email ) Change subject: s1gw_metrics: use lists:filter/2 to create counters/gauges ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39665?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I5aa1ab8c95820e4e5e3233c92a6c1b8b3190a30c Gerrit-Change-Number: 39665 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 03 Mar 2025 22:36:49 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[M] Change in ...osmo-s1gw[master]: sctp_common: new module with common SCTP/S1AP API
by laforge 03 Mar '25

03 Mar '25
Attention is currently required from: fixeria. laforge has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39664?usp=email ) Change subject: sctp_common: new module with common SCTP/S1AP API ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39664?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I49511b0860f45ff1410f1b6fe2f027606c7f0ae8 Gerrit-Change-Number: 39664 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 03 Mar 2025 22:36:23 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[S] Change in ...osmo-s1gw[master]: sctp_{server,proxy}: log SCTP TSN, SID, SSN, and data len
by laforge 03 Mar '25

03 Mar '25
Attention is currently required from: fixeria. laforge has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39663?usp=email ) Change subject: sctp_{server,proxy}: log SCTP TSN, SID, SSN, and data len ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39663?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I3692e3bfccdb2ab0a705b1f0903181197c0a2237 Gerrit-Change-Number: 39663 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 03 Mar 2025 22:35:55 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[S] Change in ...osmo-s1gw[master]: s1gw_metrics: use lists:filter/2 to create counters/gauges
by fixeria 03 Mar '25

03 Mar '25
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39665?usp=email ) Change subject: s1gw_metrics: use lists:filter/2 to create counters/gauges ...................................................................... s1gw_metrics: use lists:filter/2 to create counters/gauges Change-Id: I5aa1ab8c95820e4e5e3233c92a6c1b8b3190a30c --- M src/s1gw_metrics.erl 1 file changed, 9 insertions(+), 23 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/65/39665/1 diff --git a/src/s1gw_metrics.erl b/src/s1gw_metrics.erl index 9f7b2e8..dceb477 100644 --- a/src/s1gw_metrics.erl +++ b/src/s1gw_metrics.erl @@ -98,29 +98,14 @@ -type counter() :: [ctr | _]. -type gauge() :: [gauge | _]. --spec new_ctr(counter()) -> ok. -new_ctr(Name) -> - %%?LOG_INFO("New counter ~p", [Name]), - ok = exometer:new(Name, counter). --spec new_ctrs(list(counter())) -> ok. -new_ctrs([]) -> - ok; -new_ctrs([Name | MoreNames]) -> - new_ctr(Name), - new_ctrs(MoreNames). +-spec register_all(Type, List) -> Result + when Type :: exometer:type(), + List :: list(exometer:name()), + Result :: list(exometer:name()). +register_all(Type, List) -> + lists:filter(fun(Name) -> exometer:new(Name, Type) =/= ok end, List). --spec new_gauge(gauge()) -> ok. -new_gauge(Name) -> - %%?LOG_INFO("New gauge ~p", [Name]), - ok = exometer:new(Name, gauge). - --spec new_gauges(list(gauge())) -> ok. -new_gauges([]) -> - ok; -new_gauges([Name | MoreNames]) -> - new_gauge(Name), - new_gauges(MoreNames). -spec get_current_value(counter() | gauge()) -> integer(). get_current_value(Name) -> @@ -128,14 +113,15 @@ {ok, [{value, PrevVal}]} = Result, PrevVal. + %% ------------------------------------------------------------------ %% public API %% ------------------------------------------------------------------ init() -> ?LOG_INFO("Initiating metrics"), - new_ctrs(?S1GW_COUNTERS), - new_gauges(?S1GW_GAUGES). + [] = register_all(counter, ?S1GW_COUNTERS), + [] = register_all(gauge, ?S1GW_GAUGES). %%%%%%%%%%%%% %% CTR APIs -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39665?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I5aa1ab8c95820e4e5e3233c92a6c1b8b3190a30c Gerrit-Change-Number: 39665 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[S] Change in ...osmo-s1gw[master]: s1gw_metrics: add histograms for gen_sctp:send delay
by fixeria 03 Mar '25

03 Mar '25
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39666?usp=email ) Change subject: s1gw_metrics: add histograms for gen_sctp:send delay ...................................................................... s1gw_metrics: add histograms for gen_sctp:send delay Change-Id: I7633a6e6182bda3fca4e7562e2b780b2b9f9708f Related: SYS#7288 --- M include/s1gw_metrics.hrl M src/s1gw_metrics.erl M src/sctp_common.erl M src/sctp_proxy.erl M src/sctp_server.erl 5 files changed, 44 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/66/39666/1 diff --git a/include/s1gw_metrics.hrl b/include/s1gw_metrics.hrl index 940529b..e6a1316 100644 --- a/include/s1gw_metrics.hrl +++ b/include/s1gw_metrics.hrl @@ -40,6 +40,9 @@ -define(S1GW_GAUGE_S1AP_ENB_NUM_SCTP_CONNECTIONS, [gauge, s1ap, enb, num_sctp_connections]). -define(S1GW_GAUGE_S1AP_PROXY_UPLINK_PACKETS_QUEUED, [gauge, s1ap, proxy, uplink_packets_queued]). +-define(S1GW_HIST_SCTP_ENB_SEND_TIME, [hist, sctp, enb, send_time]). +-define(S1GW_HIST_SCTP_MME_SEND_TIME, [hist, sctp, mme, send_time]). + %% NOTE: Remember to add new entries to s1gw_metric:init()! %% vim:set ts=4 sw=4 et: diff --git a/src/s1gw_metrics.erl b/src/s1gw_metrics.erl index dceb477..8df8efc 100644 --- a/src/s1gw_metrics.erl +++ b/src/s1gw_metrics.erl @@ -42,7 +42,9 @@ gauge_set/2, gauge_inc/1, gauge_inc/2, - gauge_dec/1]). + gauge_dec/1, + hist_reset/1, + hist_add/2]). -include_lib("kernel/include/logger.hrl"). -include("s1gw_metrics.hrl"). @@ -95,8 +97,14 @@ ?S1GW_GAUGE_S1AP_PROXY_UPLINK_PACKETS_QUEUED ]). +-define(S1GW_HISTOGRAMS, [ + ?S1GW_HIST_SCTP_ENB_SEND_TIME, + ?S1GW_HIST_SCTP_MME_SEND_TIME +]). + -type counter() :: [ctr | _]. -type gauge() :: [gauge | _]. +-type hist() :: [hist | _]. -spec register_all(Type, List) -> Result @@ -121,7 +129,8 @@ init() -> ?LOG_INFO("Initiating metrics"), [] = register_all(counter, ?S1GW_COUNTERS), - [] = register_all(gauge, ?S1GW_GAUGES). + [] = register_all(gauge, ?S1GW_GAUGES), + [] = register_all(histogram, ?S1GW_HISTOGRAMS). %%%%%%%%%%%%% %% CTR APIs @@ -166,5 +175,18 @@ gauge_dec(Name) -> gauge_inc(Name, -1). +%%%%%%%%%%%% +%% HIST APIs +%%%%%%%%%%%% +-spec hist_reset(hist()) -> ok | {error, any()}. +hist_reset(Name) -> + ?LOG_DEBUG("~p(~p)", [?FUNCTION_NAME, Name]), + exometer:reset(Name). + +-spec hist_add(hist(), integer()) -> ok | {error, any()}. +hist_add(Name, Value) -> + ?LOG_DEBUG("~p(~p)", [?FUNCTION_NAME, Name]), + exometer:update(Name, Value). + %% vim:set ts=4 sw=4 et: diff --git a/src/sctp_common.erl b/src/sctp_common.erl index 0d28f81..428cf95 100644 --- a/src/sctp_common.erl +++ b/src/sctp_common.erl @@ -35,12 +35,14 @@ -module(sctp_common). -export([send_data/2, + send_data_to/3, shutdown/1]). -include_lib("kernel/include/logger.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). -include("s1ap.hrl"). +-include("s1gw_metrics.hrl"). -type sock_aid() :: {gen_sctp:sctp_socket(), @@ -58,6 +60,18 @@ assoc_id = Aid}, Data). +-spec send_data_to(enb | mme, sock_aid(), binary()) -> ok | {error, term()}. +send_data_to(Peer, {Sock, Aid}, Data) -> + {Time, Result} = timer:tc(fun() -> send_data({Sock, Aid}, Data) end), + case Peer of + enb -> + s1gw_metrics:hist_add(?S1GW_HIST_SCTP_ENB_SEND_TIME, Time); + mme -> + s1gw_metrics:hist_add(?S1GW_HIST_SCTP_MME_SEND_TIME, Time) + end, + Result. + + -spec shutdown(sock_aid()) -> ok | {error, term()}. shutdown({Sock, Aid}) -> gen_sctp:eof(Sock, #sctp_assoc_change{assoc_id = Aid}). diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index 94ff36a..a52424d 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -197,7 +197,7 @@ {forward, FwdData} -> sctp_server:send_data(EnbAid, FwdData); {reply, ReData} -> - ok = sctp_common:send_data({Sock, Aid}, ReData) + ok = sctp_common:send_data_to(mme, {Sock, Aid}, ReData) end, {keep_state, S}; @@ -260,7 +260,7 @@ handler := Pid}) -> case s1ap_proxy:process_pdu(Pid, Data) of {forward, FwdData} -> - ok = sctp_common:send_data({Sock, Aid}, FwdData); + ok = sctp_common:send_data_to(mme, {Sock, Aid}, FwdData); {reply, ReData} -> sctp_server:send_data(EnbAid, ReData) end. diff --git a/src/sctp_server.erl b/src/sctp_server.erl index 27752d8..77a0969 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -133,7 +133,7 @@ handle_cast({send_data, Aid, Data}, #server_state{sock = Sock} = S) -> - sctp_common:send_data({Sock, Aid}, Data), + sctp_common:send_data_to(enb, {Sock, Aid}, Data), {noreply, S}; handle_cast(Info, S) -> -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39666?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I7633a6e6182bda3fca4e7562e2b780b2b9f9708f Gerrit-Change-Number: 39666 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[M] Change in ...osmo-s1gw[master]: sctp_common: new module with common SCTP/S1AP API
by fixeria 03 Mar '25

03 Mar '25
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39664?usp=email ) Change subject: sctp_common: new module with common SCTP/S1AP API ...................................................................... sctp_common: new module with common SCTP/S1AP API Move send_data/2 and shutdown/1 from sctp_client into their own module. Make use of this API from sctp_server to avoid code duplication. Change-Id: I49511b0860f45ff1410f1b6fe2f027606c7f0ae8 --- M src/sctp_client.erl A src/sctp_common.erl M src/sctp_proxy.erl M src/sctp_server.erl 4 files changed, 78 insertions(+), 30 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/64/39664/1 diff --git a/src/sctp_client.erl b/src/sctp_client.erl index 72d5bd1..5875f61 100644 --- a/src/sctp_client.erl +++ b/src/sctp_client.erl @@ -36,9 +36,7 @@ -export([connect/0, connect/1, - connect/2, - send_data/2, - disconnect/1]). + connect/2]). -include_lib("kernel/include/logger.hrl"). -include_lib("kernel/include/inet.hrl"). @@ -51,14 +49,11 @@ -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]). + connect_result/0]). %% ------------------------------------------------------------------ @@ -111,15 +106,4 @@ {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}). - %% vim:set ts=4 sw=4 et: diff --git a/src/sctp_common.erl b/src/sctp_common.erl new file mode 100644 index 0000000..0d28f81 --- /dev/null +++ b/src/sctp_common.erl @@ -0,0 +1,66 @@ +%% Copyright (C) 2025 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> +%% Author: Vadim Yanitskiy <vyanitskiy(a)sysmocom.de> +%% +%% All Rights Reserved +%% +%% SPDX-License-Identifier: AGPL-3.0-or-later +%% +%% 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 <https://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 https://www.erlang.org (or a modified version of these +%% libraries), containing parts covered by the terms of the Erlang Public +%% License (https://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(sctp_common). + +-export([send_data/2, + shutdown/1]). + +-include_lib("kernel/include/logger.hrl"). +-include_lib("kernel/include/inet_sctp.hrl"). + +-include("s1ap.hrl"). + + +-type sock_aid() :: {gen_sctp:sctp_socket(), + gen_sctp:assoc_id()}. + + +%% ------------------------------------------------------------------ +%% public API +%% ------------------------------------------------------------------ + +-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 shutdown(sock_aid()) -> ok | {error, term()}. +shutdown({Sock, Aid}) -> + gen_sctp:eof(Sock, #sctp_assoc_change{assoc_id = Aid}). + + +%% vim:set ts=4 sw=4 et: diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index 4ea5e19..94ff36a 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -197,7 +197,7 @@ {forward, FwdData} -> sctp_server:send_data(EnbAid, FwdData); {reply, ReData} -> - ok = sctp_client:send_data({Sock, Aid}, ReData) + ok = sctp_common:send_data({Sock, Aid}, ReData) end, {keep_state, S}; @@ -240,7 +240,7 @@ case S of #{sock := Sock, mme_aid := Aid} -> - sctp_client:disconnect({Sock, Aid}), + sctp_common:shutdown({Sock, Aid}), gen_sctp:close(Sock); #{sock := Sock} -> gen_sctp:close(Sock); @@ -260,7 +260,7 @@ handler := Pid}) -> case s1ap_proxy:process_pdu(Pid, Data) of {forward, FwdData} -> - ok = sctp_client:send_data({Sock, Aid}, FwdData); + ok = sctp_common:send_data({Sock, Aid}, FwdData); {reply, ReData} -> sctp_server:send_data(EnbAid, ReData) end. diff --git a/src/sctp_server.erl b/src/sctp_server.erl index f269afe..27752d8 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -131,11 +131,9 @@ {reply, {error, not_implemented}, S}. -handle_cast({send_data, Aid, Data}, S) -> - gen_sctp:send(S#server_state.sock, - #sctp_sndrcvinfo{stream = ?S1AP_SCTP_STREAM, - ppid = ?S1AP_SCTP_PPID, - assoc_id = Aid}, Data), +handle_cast({send_data, Aid, Data}, + #server_state{sock = Sock} = S) -> + sctp_common:send_data({Sock, Aid}, Data), {noreply, S}; handle_cast(Info, S) -> @@ -154,8 +152,8 @@ ?LOG_DEBUG("Child process ~p terminated with reason ~p", [Pid, Reason]), case client_find(Pid, S0) of {ok, {Aid, C0}} -> - %% gracefully close the eNB connection - gen_sctp:eof(Sock, #sctp_assoc_change{assoc_id = Aid}), + %% shutdown the eNB connection gracefully + sctp_common:shutdown({Sock, Aid}), %% invalidate pid in the client's state C1 = C0#client_state{pid = undefined}, S1 = S0#server_state{clients = dict:store(Aid, C1, Clients)}, @@ -291,8 +289,8 @@ %% the handler process might be already dead, so we guard %% against exceptions like noproc or {nodedown,Node}. catch Handler:shutdown(Client#client_state.pid), - %% gracefully close an eNB connection - gen_sctp:eof(Sock, #sctp_assoc_change{assoc_id = Aid}), + %% shutdown an eNB connection gracefully + sctp_common:shutdown({Sock, Aid}), %% ... and so for the remaining clients close_conns(Sock, Handler, Clients); -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39664?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I49511b0860f45ff1410f1b6fe2f027606c7f0ae8 Gerrit-Change-Number: 39664 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • ...
  • 138
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.