aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/app/diameter_codec.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2011-09-22 19:59:03 +0200
committerAnders Svensson <[email protected]>2011-09-26 20:12:33 +0200
commit4a64f3a7d64e3aae364508054c0c1a9273db2301 (patch)
tree2ca852fde37213393c2bde0a785d05e408202ba3 /lib/diameter/src/app/diameter_codec.erl
parent97f3a064f27843a9f825210c1c7a27075b7b3ad7 (diff)
downloadotp-4a64f3a7d64e3aae364508054c0c1a9273db2301.tar.gz
otp-4a64f3a7d64e3aae364508054c0c1a9273db2301.tar.bz2
otp-4a64f3a7d64e3aae364508054c0c1a9273db2301.zip
Fix bugs in sending of answer-message replies
3001 (DIAMETER_COMMAND_UNSUPPORTED) was not sent since the decode placed the AVP list in the errors field rather than the avps field of the diameter_packet, causing the subsequent encode to fail. Session-Id was also set improperly, causing encode to fail even in this case.
Diffstat (limited to 'lib/diameter/src/app/diameter_codec.erl')
-rw-r--r--lib/diameter/src/app/diameter_codec.erl22
1 files changed, 7 insertions, 15 deletions
diff --git a/lib/diameter/src/app/diameter_codec.erl b/lib/diameter/src/app/diameter_codec.erl
index f6cbde5446..d88f42fb7c 100644
--- a/lib/diameter/src/app/diameter_codec.erl
+++ b/lib/diameter/src/app/diameter_codec.erl
@@ -140,10 +140,10 @@ make_flags(Flags0, #diameter_header{is_request = R,
mf(undefined, F, _) ->
F;
mf(B, F, N) -> %% reset the affected bit
- (F bxor (F band (1 bsl N))) bor (bit(B) bsl N).
+ (F bxor (F band (1 bsl N))) bor bit(B, N).
-bit(true) -> 1;
-bit(false) -> 0.
+bit(true, N) -> 1 bsl N;
+bit(false, _) -> 0.
%% values/1
@@ -199,25 +199,16 @@ msg_header(Mod, MsgName, Header) ->
p(Flags, #diameter_header{is_request = true,
is_proxiable = P}) ->
- Flags bor choose(P, 2#01000000, 0);
+ Flags band (2#10110000 bor choose(P, 2#01000000, 0));
p(Flags, _) ->
Flags.
-%% The header below is that of the incoming request being answered,
-%% not of the answer (which hasn't been encoded yet).
-
h(Mod, 'answer-message' = MsgName, Header) ->
?BASE = Mod,
- #diameter_header{is_request = true,
- cmd_code = Code}
- = Header,
+ #diameter_header{cmd_code = Code} = Header,
{_, Flags, ApplId} = ?BASE:msg_header(MsgName),
{Code, Flags, ApplId};
-h(Mod, MsgName, #diameter_header{is_request = true,
- cmd_code = Code}) ->
- {Code, _, _} = Mod:msg_header(MsgName); %% ensure Code
-
h(Mod, MsgName, _) ->
Mod:msg_header(MsgName).
@@ -290,7 +281,8 @@ decode_avps(MsgName, Mod, Pkt, {Bs, Avps}) -> %% invalid avp bits ...
decode_avps('', Mod, Pkt, Avps) -> %% unknown message ...
?LOG(unknown, {Mod, Pkt#diameter_packet.header}),
- Pkt#diameter_packet{errors = lists:reverse(Avps)};
+ Pkt#diameter_packet{avps = lists:reverse(Avps),
+ errors = [3001]}; %% DIAMETER_COMMAND_UNSUPPORTED
%% msg = undefined identifies this case.
decode_avps(MsgName, Mod, Pkt, Avps) -> %% ... or not