diff --git a/rebar.lock b/rebar.lock index cc705c2a..f93359d7 100644 --- a/rebar.lock +++ b/rebar.lock @@ -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", diff --git a/src/ergw_gsn_lib.erl b/src/ergw_gsn_lib.erl index e0523a44..40df107e 100644 --- a/src/ergw_gsn_lib.erl +++ b/src/ergw_gsn_lib.erl @@ -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. diff --git a/test/ergw_test_sx_up.erl b/test/ergw_test_sx_up.erl index 893cb483..48be20c7 100644 --- a/test/ergw_test_sx_up.erl +++ b/test/ergw_test_sx_up.erl @@ -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{} ->