fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/41030?usp=email )
Change subject: s1ap_proxy: add fetch_enb_info/1
......................................................................
s1ap_proxy: add fetch_enb_info/1
This is useful for introspection and the upcoming REST interface.
Change-Id: I79fcb599274c78d8f58e6c774a4f8c64c2fb08b5
---
M src/s1ap_proxy.erl
1 file changed, 25 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/30/41030/1
diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl
index a08f61d..a55746f 100644
--- a/src/s1ap_proxy.erl
+++ b/src/s1ap_proxy.erl
@@ -44,6 +44,7 @@
process_pdu/2,
fetch_erab/2,
fetch_erab_list/1,
+ fetch_enb_info/1,
shutdown/1]).
-include_lib("kernel/include/logger.hrl").
@@ -87,7 +88,13 @@
-type proxy_state() :: #proxy_state{}.
-type proxy_action() :: forward | reply | drop.
--export_type([proxy_action/0]).
+-type enb_info() :: #{enb_id => non_neg_integer(),
+ plmn_id => plmn_id(),
+ genb_id_str => string()
+ }.
+
+-export_type([proxy_action/0,
+ enb_info/0]).
%% ------------------------------------------------------------------
@@ -119,6 +126,12 @@
gen_server:call(Pid, ?FUNCTION_NAME).
+%% Fetch information about the eNB
+-spec fetch_enb_info(pid()) -> enb_info().
+fetch_enb_info(Pid) ->
+ gen_server:call(Pid, ?FUNCTION_NAME).
+
+
-spec shutdown(pid()) -> ok.
shutdown(Pid) ->
gen_server:stop(Pid).
@@ -149,6 +162,17 @@
#proxy_state{erabs = ERABs} = S) ->
{reply, dict:to_list(ERABs), S};
+handle_call(fetch_enb_info, _From,
+ #proxy_state{enb_id = EnbId,
+ plmn_id = PLMNId,
+ genb_id_str = GlobalENBId} = S) ->
+ Info = #{enb_id => EnbId,
+ plmn_id => PLMNId,
+ genb_id_str => GlobalENBId},
+ %% omit fields with Value =:= undefined
+ Reply = maps:filter(fun(_K, V) -> V =/= undefined end, Info),
+ {reply, Reply, S};
+
handle_call(Info, From,
#proxy_state{} = S) ->
?LOG_ERROR("unknown ~p() from ~p: ~p", [?FUNCTION_NAME, From, Info]),
--
To view, visit
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/41030?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: I79fcb599274c78d8f58e6c774a4f8c64c2fb08b5
Gerrit-Change-Number: 41030
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>