pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/34728?usp=email )
Change subject: Initial GSUP Auth handler support ......................................................................
Initial GSUP Auth handler support
Change-Id: Iad42c74f1c6f35791d3e33c1082e804eb67e861c --- A src/auth_handler.erl M src/gsup_server.erl M src/osmo_epdg_sup.erl 3 files changed, 74 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-epdg refs/changes/28/34728/1
diff --git a/src/auth_handler.erl b/src/auth_handler.erl new file mode 100644 index 0000000..83e8aaf --- /dev/null +++ b/src/auth_handler.erl @@ -0,0 +1,58 @@ +-module(auth_handler). +-behaviour(gen_server). + +-include_lib("osmo_gsup/include/gsup_protocol.hrl"). +-include_lib("diameter_3gpp_ts29_273_swx.hrl"). + +-record(auth_state, { + table_id % ets table id +}). + +-export([start_link/0]). +-export([init/1, handle_call/3, handle_cast/2, handle_info/2]). +-export([code_change/3, terminate/2]). + +-export[(auth_request/1)]. + +-define(SERVER, ?MODULE). + +% The ets table contains only IMSIs + +start_link() -> + gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). + +init([]) -> + TableId = ets:new(auth_req, [bag, named_table]), + {ok, #auth_state{table_id = TableId}}. + + +auth_request(Imsi) -> + gen_server:call(?SERVER, {epdg_auth_req, Imsi}). + +handle_call({epdg_auth_req, Imsi}, From, State) -> + % request the diameter code for a tuple + CKey = [], + IntegrityKey = [], + Result = epdg_diameter_swx:multimedia_auth_request(Imsi, 1, "EAP-AKA", 1, CKey, IntegrityKey), + case Result of + {ok, Mar} -> {reply, {ok, Mar}, State}; + {error, Err} -> {reply, {error, Err}, State}; + {_, _} -> {reply, {error, unknown}, State} + end. + +handle_cast(Info, S) -> + error_logger:error_report(["unknown handle_cast", {module, ?MODULE}, {info, Info}, {state, S}]), + {noreply, S}. +handle_info(Info, S) -> + error_logger:error_report(["unknown handle_info", {module, ?MODULE}, {info, Info}, {state, S}]), + {noreply, S}. + + +stop() -> + gen_server:call(?MODULE, stop). + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +terminate(Reason, _S) -> + lager:info("terminating ~p with reason ~p~n", [?MODULE, Reason]). diff --git a/src/gsup_server.erl b/src/gsup_server.erl index e25e681..26af3b4 100644 --- a/src/gsup_server.erl +++ b/src/gsup_server.erl @@ -140,8 +140,7 @@
% send auth info / requesting authentication tuples handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, GsupMsgRx = #{message_type := send_auth_info_req, imsi := Imsi}}, S) -> - Auth = {error, 'not_implemented_yet!'}, - %Auth = auth_handler:auth_request(Imsi), + Auth = auth_handler:auth_request(Imsi), case Auth of {ok, Mar} -> SipAuthTuples = Mar#'MAA'.'SIP-Auth-Data-Item', % AuthTuples = dia_sip2gsup(SipAuthTuples), diff --git a/src/osmo_epdg_sup.erl b/src/osmo_epdg_sup.erl index d5b0e6e..a523a7f 100644 --- a/src/osmo_epdg_sup.erl +++ b/src/osmo_epdg_sup.erl @@ -19,4 +19,9 @@ 5000, worker, [gsup_server]}, - {ok, { {one_for_all, 5, 10}, [DiaServer, GsupServer]} }. + AuthHandler = {auth_handler, {auth_handler, start_link, []}, + permanent, + 5000, + worker, + [auth_handler]}, + {ok, { {one_for_all, 5, 10}, [DiaServer, GsupServer, AuthHandler]} }.