fixeria has submitted this change. (
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/38793?usp=email )
Change subject: sctp_proxy: add fetch_info/1 for state introspection
......................................................................
sctp_proxy: add fetch_info/1 for state introspection
This API will be used by the upcoming interactive VTY interface.
Change-Id: Ifd495c3b5e6f036fca1fbb2a06330f06ddfbbe61
---
M src/sctp_proxy.erl
1 file changed, 14 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl
index b23451f..755d2a3 100644
--- a/src/sctp_proxy.erl
+++ b/src/sctp_proxy.erl
@@ -45,6 +45,7 @@
-export([start_link/2,
start_link/3,
send_data/2,
+ fetch_info/1,
shutdown/1]).
-include_lib("kernel/include/logger.hrl").
@@ -79,6 +80,11 @@
gen_statem:cast(Pid, {send_data, Data}).
+-spec fetch_info(pid()) -> proplists:proplist().
+fetch_info(Pid) ->
+ gen_statem:call(Pid, ?FUNCTION_NAME).
+
+
-spec shutdown(pid()) -> ok.
shutdown(Pid) ->
gen_statem:stop(Pid).
@@ -202,6 +208,14 @@
%% Event handler for all states
+handle_event(State, {call, From}, fetch_info,
+ #{handler := Pid} = S0) ->
+ ERABs = s1ap_proxy:fetch_erab_list(Pid),
+ S1 = maps:with([enb_aid, mme_aid, mme_addr, mme_port], S0),
+ S2 = S1#{state => State, erab_list => ERABs},
+ Reply = proplists:from_map(S2),
+ {keep_state_and_data, {reply, From, Reply}};
+
handle_event(State, Event, EventData, _S) ->
?LOG_ERROR("Unexpected event ~p in state ~p: ~p", [Event, State,
EventData]),
{keep_state_and_data}.
--
To view, visit
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/38793?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: Ifd495c3b5e6f036fca1fbb2a06330f06ddfbbe61
Gerrit-Change-Number: 38793
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>