Skip to content

Commit

Permalink
fix URR update generation
Browse files Browse the repository at this point in the history
URRs updates can not be generate as diff. The new value might
be identical to old one. We therefor generate all rules and then
apply only the URRs that where included in the update request.
  • Loading branch information
RoadRunnr committed Mar 28, 2019
1 parent 273df25 commit 5d427c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},1},
{<<"pfcplib">>,
{git,"https://github.com/travelping/pfcplib.git",
{ref,"d875280de4cefadc330b9ec6286caef3026d973c"}},
{ref,"0da3d89742a6d60b712d5e4103556ec5b166fe65"}},
0},
{<<"pmod_transform">>,
{git,"git://github.com/erlang/pmod_transform.git",
Expand Down
17 changes: 8 additions & 9 deletions src/ergw_gsn_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -644,19 +644,18 @@ update_sx_usage_rules(Update, Ctx, PCtx0)
PCtx = #pfcp_ctx{sx_rules = Rules} =
ergw_pfcp:apply_timers(PCtx0, PCtx1),

lager:info("Sx Modify: ~p, (~p)", [maps:values(Rules), Errors]),
Add = [{urr, {online, RatingGroup}} ||
#{'Result-Code' := [Code], 'Rating-Group' := [RatingGroup]} <- Update, Code == 2001],
UpdateURRs = [#update_urr{group = V} || V <- maps:values(maps:with(Add, Rules))],

case maps:values(Rules) of
[] ->
ok;
RulesList when is_list(RulesList) ->
URRs = [#update_urr{group = V} || V <- RulesList],
lager:info("Sx Modify: ~p", [URRs]),
if length(UpdateURRs) /= 0 ->
lager:info("Sx Modify: ~p", [UpdateURRs]),

IEs = [#update_urr{group = V} || V <- maps:values(Rules)],
Req = #pfcp{version = v1, type = session_modification_request, ie = IEs},
Req = #pfcp{version = v1, type = session_modification_request, ie = UpdateURRs},
R = ergw_sx_node:call(PCtx, Req, Ctx),
lager:warning("R: ~p", [R]),
ok;
true ->
ok
end,
PCtx.
Expand Down
1 change: 1 addition & 0 deletions test/ergw_test_sx_up.erl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ handle_info({udp, SxSocket, IP, InPortNo, Packet},
#state{sx = SxSocket, history = Hist} = State0) ->
try
Msg = pfcp_packet:decode(Packet),
?match(ok, (catch pfcp_packet:validate('Sxb', Msg))),
{Reply, State} = handle_message(Msg, State0#state{history = [Msg|Hist]}),
case Reply of
#pfcp{} ->
Expand Down

0 comments on commit 5d427c5

Please sign in to comment.