general clean up to support SWx
This commit is contained in:
parent
12664a0b4e
commit
7d82f17fc9
|
@ -0,0 +1,47 @@
|
||||||
|
[%% ===========================================
|
||||||
|
%% Application config
|
||||||
|
%% ===========================================
|
||||||
|
{epdg_diameter_swx,
|
||||||
|
[% Connection parameters
|
||||||
|
{diameter_server_ip, "192.168.56.132"},
|
||||||
|
{diameter_port, 3868},
|
||||||
|
{diameter_proto, sctp},
|
||||||
|
% Server parameters
|
||||||
|
{vendor_id, 0},
|
||||||
|
{origin_host, "aaa.gprs.fe80.eu"},
|
||||||
|
{origin_realm, "gprs.fe80.eu"},
|
||||||
|
{context_id, "gprs@giameter.com"}]},
|
||||||
|
%% ===========================================
|
||||||
|
%% SASL config
|
||||||
|
%% ===========================================
|
||||||
|
{sasl, [{sasl_error_logger, false}]},
|
||||||
|
% {sasl, [
|
||||||
|
% {sasl_error_logger, {file, "log/sasl-error.log"}},
|
||||||
|
% {errlog_type, error},
|
||||||
|
% {error_logger_mf_dir, "log/sasl"}, % Log directory
|
||||||
|
% {error_logger_mf_maxbytes, 10485760}, % 10 MB max file size
|
||||||
|
% {error_logger_mf_maxfiles, 5} % 5 files max
|
||||||
|
% ]},
|
||||||
|
% %% ===========================================
|
||||||
|
%% Lager logging config
|
||||||
|
%% ===========================================
|
||||||
|
{lager,
|
||||||
|
[{log_root, "log"},
|
||||||
|
{colored, true},
|
||||||
|
{handlers,
|
||||||
|
[{lager_console_backend, [{level, info}]},
|
||||||
|
{lager_file_backend,
|
||||||
|
[{file, "console.log"}, {level, debug}, {size, 104857600}, {date, "$D0"}, {count, 10}]},
|
||||||
|
{lager_file_backend,
|
||||||
|
[{file, "error.log"}, {level, error}, {size, 104857600}, {date, "$D0"}, {count, 10}]}]},
|
||||||
|
{crash_log, "crash.log"},
|
||||||
|
{crash_log_msg_size, 65536},
|
||||||
|
{crash_log_size, 104857600},
|
||||||
|
{crash_log_date, "$D0"},
|
||||||
|
{crash_log_count, 10},
|
||||||
|
{error_logger_redirect, true}]},
|
||||||
|
{kernel,
|
||||||
|
[{logger,
|
||||||
|
[{handler, debug, logger_std_h, % {handler, HandlerId, Module,
|
||||||
|
#{config => #{file => "log/erlang.log"}}} % Config}
|
||||||
|
]}]}].
|
|
@ -0,0 +1,15 @@
|
||||||
|
## Name of the node
|
||||||
|
-sname osmo-epdg
|
||||||
|
|
||||||
|
## Cookie for distributed erlang
|
||||||
|
-setcookie osmo-epdg_cookie
|
||||||
|
|
||||||
|
## Enable kernel poll and a few async threads
|
||||||
|
+K true
|
||||||
|
+A30
|
||||||
|
|
||||||
|
## Increase number of concurrent ports/sockets
|
||||||
|
-env ERL_MAX_PORTS 4096
|
||||||
|
|
||||||
|
## Tweak GC to run more often
|
||||||
|
##-env ERL_FULLSWEEP_AFTER 10
|
|
@ -43,7 +43,6 @@
|
||||||
-include_lib("diameter_3gpp_ts29_273_swx.hrl").
|
-include_lib("diameter_3gpp_ts29_273_swx.hrl").
|
||||||
-include_lib("diameter/include/diameter_gen_base_rfc6733.hrl").
|
-include_lib("diameter/include/diameter_gen_base_rfc6733.hrl").
|
||||||
|
|
||||||
|
|
||||||
%% API Function Exports
|
%% API Function Exports
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
-export([start/0, stop/0, terminate/2]).
|
-export([start/0, stop/0, terminate/2]).
|
||||||
|
@ -57,7 +56,7 @@
|
||||||
-define(SERVER, ?MODULE).
|
-define(SERVER, ?MODULE).
|
||||||
-define(SVC_NAME, ?MODULE).
|
-define(SVC_NAME, ?MODULE).
|
||||||
-define(APP_ALIAS, ?MODULE).
|
-define(APP_ALIAS, ?MODULE).
|
||||||
-define(CALLBACK_MOD, swx_client_cb).
|
-define(CALLBACK_MOD, epdg_diameter_swx_cb).
|
||||||
-define(DIAMETER_DICT_SWX, diameter_3gpp_ts29_273_swx).
|
-define(DIAMETER_DICT_SWX, diameter_3gpp_ts29_273_swx).
|
||||||
|
|
||||||
-define(VENDOR_ID_3GPP, 10415).
|
-define(VENDOR_ID_3GPP, 10415).
|
||||||
|
@ -68,8 +67,8 @@
|
||||||
%% supporting multiple Diameter applications may or may not want to
|
%% supporting multiple Diameter applications may or may not want to
|
||||||
%% configure a common callback module on all applications.
|
%% configure a common callback module on all applications.
|
||||||
-define(SERVICE,
|
-define(SERVICE,
|
||||||
[{'Origin-Host', application:get_env(?SERVER, origin_host, "default.com")},
|
[{'Origin-Host', application:get_env(?SERVER, origin_host, "aaa.example.org")},
|
||||||
{'Origin-Realm', application:get_env(?SERVER, origin_realm, "realm.default.com")},
|
{'Origin-Realm', application:get_env(?SERVER, origin_realm, "realm.example.org")},
|
||||||
{'Vendor-Id', application:get_env(?SERVER, vendor_id, 0)},
|
{'Vendor-Id', application:get_env(?SERVER, vendor_id, 0)},
|
||||||
{'Vendor-Specific-Application-Id',
|
{'Vendor-Specific-Application-Id',
|
||||||
[#'diameter_base_Vendor-Specific-Application-Id'{
|
[#'diameter_base_Vendor-Specific-Application-Id'{
|
||||||
|
@ -108,43 +107,40 @@ init(State) ->
|
||||||
Proto = application:get_env(?SERVER, diameter_proto, sctp),
|
Proto = application:get_env(?SERVER, diameter_proto, sctp),
|
||||||
Ip = application:get_env(?SERVER, diameter_server_ip, "192.168.56.132"),
|
Ip = application:get_env(?SERVER, diameter_server_ip, "192.168.56.132"),
|
||||||
Port = application:get_env(?SERVER, diameter_port, 3868),
|
Port = application:get_env(?SERVER, diameter_port, 3868),
|
||||||
DiaServ = diameter:start_service(?MODULE, ?SERVICE),
|
ok = diameter:start_service(?MODULE, ?SERVICE),
|
||||||
lager:info("DiaServices is ~p~n", [DiaServ]),
|
% lager:info("DiaServices is ~p~n", [DiaServ]),
|
||||||
Transport = connect({address, Proto, Ip, Port}),
|
{ok, _} = connect({address, Proto, Ip, Port}),
|
||||||
lager:info("DiaTransport is ~p~n", [Transport]),
|
|
||||||
|
|
||||||
{ok, State}.
|
{ok, State}.
|
||||||
|
|
||||||
test() ->
|
test() ->
|
||||||
test("262421234567890").
|
test("262421234567890").
|
||||||
|
|
||||||
test(IMSI) ->
|
test(IMSI) ->
|
||||||
media_auth_request(IMSI, 3, "EAP-AKA", 1, [], []).
|
media_auth_request(IMSI, 3, "EAP-AKA", 1, [], []).
|
||||||
|
|
||||||
media_auth_request(IMSI, NumAuthItems, AuthScheme, RAT, CKey = [], IntegrityKey = []) ->
|
media_auth_request(IMSI, NumAuthItems, AuthScheme, RAT, CKey, IntegrityKey) ->
|
||||||
Res = gen_server:call(?SERVER,
|
gen_server:call(?SERVER,
|
||||||
{mar, {IMSI, NumAuthItems, AuthScheme, RAT, CKey, IntegrityKey}}),
|
{mar, {IMSI, NumAuthItems, AuthScheme, RAT, CKey, IntegrityKey}}).
|
||||||
lager:info("Response is ~p~n", [Res]),
|
|
||||||
Res.
|
|
||||||
|
|
||||||
% TODO Sync failure
|
% TODO Sync failure
|
||||||
handle_call({mar, {IMSI, NumAuthItems, AuthScheme, RAT, _CKey, _IntegrityKey}}, _From, State) ->
|
handle_call({mar, {IMSI, NumAuthItems, AuthScheme, RAT, CKey, IntegrityKey}}, _From, State) ->
|
||||||
SessionId = diameter:session_id(application:get_env(?SERVER, origin_host, "default.com")),
|
SessionId = diameter:session_id(application:get_env(?SERVER, origin_host, "aaa.example.org")),
|
||||||
MAR = #'MAR'{'Session-Id' = SessionId,
|
MAR = #'MAR'{'Vendor-Specific-Application-Id' = #'Vendor-Specific-Application-Id'{
|
||||||
'Auth-Session-State' = 1,
|
'Vendor-Id' = ?VENDOR_ID_3GPP,
|
||||||
|
'Auth-Application-Id' = [?DIAMETER_APP_ID_SWX]},
|
||||||
|
'Session-Id' = SessionId,
|
||||||
'User-Name' = IMSI,
|
'User-Name' = IMSI,
|
||||||
|
'Auth-Session-State' = 1,
|
||||||
'SIP-Auth-Data-Item' = #'SIP-Auth-Data-Item'{
|
'SIP-Auth-Data-Item' = #'SIP-Auth-Data-Item'{
|
||||||
'SIP-Authentication-Scheme' = [AuthScheme]},
|
'SIP-Authentication-Scheme' = [AuthScheme],
|
||||||
|
'Confidentiality-Key' = CKey,
|
||||||
|
'Integrity-Key' = IntegrityKey},
|
||||||
'SIP-Number-Auth-Items' = NumAuthItems,
|
'SIP-Number-Auth-Items' = NumAuthItems,
|
||||||
'RAT-Type' = RAT,
|
'RAT-Type' = RAT
|
||||||
'Vendor-Specific-Application-Id' = #'Vendor-Specific-Application-Id'{
|
|
||||||
'Vendor-Id' = ?VENDOR_ID_3GPP,
|
|
||||||
'Auth-Application-Id' = [?DIAMETER_APP_ID_SWX]}
|
|
||||||
},
|
},
|
||||||
Ret = diameter:call(?SVC_NAME, ?APP_ALIAS, MAR, []),
|
Ret = diameter:call(?SVC_NAME, ?APP_ALIAS, MAR, []),
|
||||||
case Ret of
|
case Ret of
|
||||||
{ok, MAA} ->
|
{ok, MAA} ->
|
||||||
lager:info("MAR Success"),
|
|
||||||
{reply, {ok, MAA}, State};
|
{reply, {ok, MAA}, State};
|
||||||
{error, Err} ->
|
{error, Err} ->
|
||||||
lager:error("Error: ~w~n", [Err]),
|
lager:error("Error: ~w~n", [Err]),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%%
|
%%
|
||||||
%% The diameter application callback module configured by client.erl.
|
%% The diameter application callback module configured by client.erl.
|
||||||
%%
|
%%
|
||||||
-module(swx_client_cb).
|
-module(epdg_diameter_swx_cb).
|
||||||
|
|
||||||
-include_lib("diameter/include/diameter.hrl").
|
-include_lib("diameter/include/diameter.hrl").
|
||||||
-include_lib("diameter_3gpp_ts29_273_swx.hrl").
|
-include_lib("diameter_3gpp_ts29_273_swx.hrl").
|
||||||
|
@ -13,7 +13,6 @@
|
||||||
%% peer_up/3
|
%% peer_up/3
|
||||||
peer_up(_SvcName, Peer, State) ->
|
peer_up(_SvcName, Peer, State) ->
|
||||||
lager:info("Peer up: ~p~n", [Peer]),
|
lager:info("Peer up: ~p~n", [Peer]),
|
||||||
epdg_diameter_swx:test(),
|
|
||||||
State.
|
State.
|
||||||
|
|
||||||
%% peer_down/3
|
%% peer_down/3
|
||||||
|
@ -30,7 +29,6 @@ pick_peer([Peer | _], _, _SvcName, _State) ->
|
||||||
prepare_request(#diameter_packet{msg = [ T | Avps ]}, _, {_, Caps})
|
prepare_request(#diameter_packet{msg = [ T | Avps ]}, _, {_, Caps})
|
||||||
when is_list(Avps) ->
|
when is_list(Avps) ->
|
||||||
#diameter_caps{origin_host = {OH, DH}, origin_realm = {OR, DR}} = Caps,
|
#diameter_caps{origin_host = {OH, DH}, origin_realm = {OR, DR}} = Caps,
|
||||||
lager:info("List Head ~n"),
|
|
||||||
{send,
|
{send,
|
||||||
[T,
|
[T,
|
||||||
{'Origin-Host', OH},
|
{'Origin-Host', OH},
|
||||||
|
@ -38,15 +36,13 @@ prepare_request(#diameter_packet{msg = [ T | Avps ]}, _, {_, Caps})
|
||||||
{'Destination-Host', [DH]},
|
{'Destination-Host', [DH]},
|
||||||
{'Destination-Realm', DR}
|
{'Destination-Realm', DR}
|
||||||
| Avps]};
|
| Avps]};
|
||||||
prepare_request(#diameter_packet{msg = Rec}, _, {_, Caps}) ->
|
prepare_request(#diameter_packet{msg = Req}, _, {_, Caps})
|
||||||
|
when is_record(Req, 'MAR') ->
|
||||||
#diameter_caps{origin_host = {OH, DH}, origin_realm = {OR, DR}} = Caps,
|
#diameter_caps{origin_host = {OH, DH}, origin_realm = {OR, DR}} = Caps,
|
||||||
Msg = Rec#'MAR'{'Origin-Host' = OH,
|
Msg = Req#'MAR'{'Origin-Host' = OH,
|
||||||
'Origin-Realm' = OR,
|
'Origin-Realm' = OR,
|
||||||
'Destination-Host' = [DH],
|
'Destination-Host' = [DH],
|
||||||
'Destination-Realm' = DR},
|
'Destination-Realm' = DR},
|
||||||
lager:info("Record Head ~p ~n", [Msg]),
|
|
||||||
% Encoded = diameter_codec:encode(diameter_3gpp_ts29_273_swx, Msg),
|
|
||||||
% lager:info("Enc Head ~p ~n", [Encoded]),
|
|
||||||
{send, Msg}.
|
{send, Msg}.
|
||||||
|
|
||||||
%% prepare_retransmit/3
|
%% prepare_retransmit/3
|
|
@ -9,20 +9,9 @@ start_link() ->
|
||||||
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
|
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
|
||||||
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
% GSUP side
|
|
||||||
%% HlrIp = application:get_env(osmo_dia2gsup, hlr_ip, "127.0.0.1"),
|
|
||||||
%% HlrPort = application:get_env(osmo_dia2gsup, hlr_port, 4222),
|
|
||||||
%% Args = [{local, gsup_client}, gsup_client, [HlrIp, HlrPort, []], [{debug, [trace]}]],
|
|
||||||
%% GsupChild = {gsup_client, {gen_server, start_link, Args}, permanent, 2000, worker, [gsup_client]},
|
|
||||||
% DIAMETER side
|
|
||||||
DiaServer = {epdg_diameter_swx, {epdg_diameter_swx,start_link,[]},
|
DiaServer = {epdg_diameter_swx, {epdg_diameter_swx,start_link,[]},
|
||||||
permanent,
|
permanent,
|
||||||
5000,
|
5000,
|
||||||
worker,
|
worker,
|
||||||
[swx_client_cb]},
|
[epdg_diameter_swx_cb]},
|
||||||
%% DiaSuper = {diameter, {diameter,start_link,[]},
|
|
||||||
%% permanent,
|
|
||||||
%% 5000,
|
|
||||||
%% worker,
|
|
||||||
%% []},
|
|
||||||
{ok, { {one_for_one, 5, 10}, [DiaServer]} }.
|
{ok, { {one_for_one, 5, 10}, [DiaServer]} }.
|
||||||
|
|
Loading…
Reference in New Issue