Skip to content

Commit

Permalink
make the wildcard APN config work
Browse files Browse the repository at this point in the history
  • Loading branch information
RoadRunnr committed Mar 28, 2019
1 parent 1293a00 commit 273df25
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/ergw.erl
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ handler(Socket, Protocol) ->
{error, not_found}
end.

vrf_lookup(APN0) ->
APN = (catch gtp_c_lib:normalize_labels(APN0)),
vrf_lookup(APN) ->
case ets:lookup(?SERVER, APN) of
[#route{vrf = VRF, options = Options}] ->
{ok, {VRF, Options}};
Expand All @@ -152,7 +151,8 @@ expand_apn(_, APN) ->
end,
APN ++ [MNCpart, <<"mcc", MCC/binary>>, <<"gprs">>].

vrf(APN) ->
vrf(APN0) ->
APN = gtp_c_lib:normalize_labels(APN0),
case vrf_lookup(APN) of
{ok, _} = Result ->
Result;
Expand Down
21 changes: 20 additions & 1 deletion test/pgw_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
{apns,
[{?'APN-EXAMPLE', [{vrf, upstream}]},
{[<<"exa">>, <<"mple">>, <<"net">>], [{vrf, upstream}]},
{[<<"APN1">>], [{vrf, upstream}]}
{[<<"APN1">>], [{vrf, upstream}]},
{[<<"APN2">>, <<"mnc001">>, <<"mcc001">>, <<"gprs">>], [{vrf, upstream}]}
%% {'_', [{vrf, wildcard}]}
]},

{nodes,
Expand Down Expand Up @@ -262,6 +264,7 @@ end_per_group(Group, Config)
common() ->
[lager_format_ies,
invalid_gtp_pdu,
apn_lookup,
create_session_request_missing_ie,
create_session_request_aaa_reject,
create_session_request_gx_fail,
Expand Down Expand Up @@ -1720,6 +1723,22 @@ gy_validity_timer(Config) ->
ok = application:set_env(ergw_aaa, apps, Cfg0),
ok.

%%--------------------------------------------------------------------
apn_lookup() ->
[{doc, "Check that the APN and wildcard APN lookup works"}].
apn_lookup(Config) ->
ct:pal("VRF: ~p", [ergw:vrf(?'APN-EXAMPLE')]),
?match({ok, {<<8, "upstream">>, _}}, ergw:vrf(?'APN-EXAMPLE')),
?match({ok, {<<8, "upstream">>, _}}, ergw:vrf([<<"exa">>, <<"mple">>, <<"net">>])),
?match({ok, {<<8, "upstream">>, _}}, ergw:vrf([<<"APN1">>])),
?match({ok, {<<8, "upstream">>, _}}, ergw:vrf([<<"APN1">>, <<"mnc001">>, <<"mcc001">>, <<"gprs">>])),
?match({ok, {<<8, "upstream">>, _}}, ergw:vrf([<<"APN2">>])),
?match({ok, {<<8, "upstream">>, _}}, ergw:vrf([<<"APN2">>, <<"mnc001">>, <<"mcc001">>, <<"gprs">>])),
%% ?match({ok, {<<8, "wildcard">>, _}}, ergw:vrf([<<"APN3">>])),
%% ?match({ok, {<<8, "wildcard">>, _}}, ergw:vrf([<<"APN3">>, <<"mnc001">>, <<"mcc001">>, <<"gprs">>])),
%% ?match({ok, {<<8, "wildcard">>, _}}, ergw:vrf([<<"APN4">>, <<"mnc001">>, <<"mcc901">>, <<"gprs">>])),
ok.

%%%===================================================================
%%% Internal functions
%%%===================================================================

0 comments on commit 273df25

Please sign in to comment.