aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2013-02-16 22:38:03 +0100
committerAnders Svensson <[email protected]>2013-02-16 22:50:20 +0100
commit4d8afe10687f11e9e9796ba787a49c85f76082e9 (patch)
tree09a84c28c19620919cdc01064e1c184988a180c5 /lib/diameter
parent5ef85e261da9d3dbf9975b5e71b1d70b9064a479 (diff)
downloadotp-4d8afe10687f11e9e9796ba787a49c85f76082e9.tar.gz
otp-4d8afe10687f11e9e9796ba787a49c85f76082e9.tar.bz2
otp-4d8afe10687f11e9e9796ba787a49c85f76082e9.zip
Comments and minor Result-Code fix
In particular, don't put an error tuple in the errors field of a #diameter_packet{} when Result-Code and the E-bit are in conflict, put {integer(), #diameter_avp{}}.
Diffstat (limited to 'lib/diameter')
-rw-r--r--lib/diameter/src/base/diameter_traffic.erl23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/diameter/src/base/diameter_traffic.erl b/lib/diameter/src/base/diameter_traffic.erl
index d6cb5ff0fa..c70fad8f83 100644
--- a/lib/diameter/src/base/diameter_traffic.erl
+++ b/lib/diameter/src/base/diameter_traffic.erl
@@ -910,16 +910,20 @@ find(Pred, [H|T]) ->
%% incr/4
%%
-%% Increment a stats counter for an incoming or outgoing message.
+%% Increment a stats counter for result codes in incoming and outgoing
+%% answers.
%% Outgoing message as binary: don't count. (Sending binaries is only
%% partially supported.)
incr(_, #diameter_packet{msg = undefined}, _, _) ->
ok;
+%% Incoming with decode errors.
incr(recv = D, #diameter_packet{header = H, errors = [_|_]}, _, TPid) ->
incr(TPid, {diameter_codec:msg_id(H), D, error});
+%% Incoming without errors or outgoing. Outgoing with encode errors
+%% never gets here since encode fails.
incr(Dir, Pkt, Dict, TPid) ->
#diameter_packet{header = #diameter_header{is_error = E}
= Hdr,
@@ -929,9 +933,9 @@ incr(Dir, Pkt, Dict, TPid) ->
RC = int(get_avp_value(Dict, 'Result-Code', Rec)),
PE = is_protocol_error(RC),
- %% Check that the E bit is set only for 3xxx result codes.
- (not (E orelse PE))
- orelse (E andalso PE)
+ %% Check that Result-Code matches E-bit.
+ (not (E orelse PE)) %% non-3xxx answer without E-bit
+ orelse (E andalso PE) %% 3xxx answer with E-bit
orelse x({invalid_error_bit, RC}, answer, [Dir, Pkt]),
irc(TPid, Hdr, Dir, rc_counter(Dict, Rec, RC)).
@@ -947,7 +951,7 @@ irc(TPid, Hdr, Dir, Ctr) ->
incr(TPid, Counter) ->
diameter_stats:incr(Counter, TPid, 1).
-%% error_counter/2
+%% rc_counter/2
%% RFC 3588, 7.6:
%%
@@ -1303,12 +1307,15 @@ handle_answer(SvcName,
answer(Pkt, SvcName, Dict, App, #request{transport = TPid} = Req) ->
try
- incr(recv, Pkt, Dict, TPid)
+ incr(recv, Pkt, Dict, TPid) %% count result codes in received answers
of
_ -> answer(Pkt, SvcName, App, Req)
catch
- exit: {invalid_error_bit, _} = E ->
- answer(Pkt#diameter_packet{errors = [E]}, SvcName, App, Req)
+ exit: {invalid_error_bit, RC} ->
+ #diameter_packet{errors = Es}
+ = Pkt,
+ E = {5004, #diameter_avp{name = 'Result-Code', value = RC}},
+ answer(Pkt#diameter_packet{errors = [E|Es]}, SvcName, App, Req)
end.
answer(Pkt,