diff options
author | Anders Svensson <[email protected]> | 2012-08-23 01:00:54 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2012-08-23 18:59:28 +0200 |
commit | 60fb617d030a24afb86fe9779479509f11179578 (patch) | |
tree | 9d12f43c77780e85073ac3520908638713297956 /lib/diameter/src/base/diameter_service.erl | |
parent | a9ec9ebbbcbed454c9bee618ffca81534322213b (diff) | |
download | otp-60fb617d030a24afb86fe9779479509f11179578.tar.gz otp-60fb617d030a24afb86fe9779479509f11179578.tar.bz2 otp-60fb617d030a24afb86fe9779479509f11179578.zip |
Set Result-Code as an optional AVP in reply to request containing errors
Previously assumed it had arity 1, which is not necessarily
the case. Whether or not we should do this is probably debatable.
There should at least be a way for the user to roll their own.
Diffstat (limited to 'lib/diameter/src/base/diameter_service.erl')
-rw-r--r-- | lib/diameter/src/base/diameter_service.erl | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl index a4160fddbd..167b2c1f79 100644 --- a/lib/diameter/src/base/diameter_service.erl +++ b/lib/diameter/src/base/diameter_service.erl @@ -1985,7 +1985,10 @@ rc(RC) -> rc(Rec, RC, Failed, Dict) when is_integer(RC) -> - set(Rec, [{'Result-Code', RC} | failed_avp(Rec, Failed, Dict)], Dict). + set(Rec, + lists:append([rc(Rec, {'Result-Code', RC}, Dict), + failed_avp(Rec, Failed, Dict)]), + Dict). %% Reply as name and tuple list ... set([_|_] = Ans, Avps, _) -> @@ -1995,6 +1998,22 @@ set([_|_] = Ans, Avps, _) -> set(Rec, Avps, Dict) -> Dict:'#set-'(Avps, Rec). +%% rc/3 +%% +%% Turn the result code into a list if its optional and only set it if +%% the arity is 1 or {0,1}. In other cases (which probably shouldn't +%% exist in practise) we can't know what's appropriate. + +rc([MsgName | _], {'Result-Code' = K, RC} = T, Dict) -> + case Dict:avp_arity(MsgName, 'Result-Code') of + 1 -> [T]; + {0,1} -> [{K, [RC]}]; + _ -> [] + end; + +rc(Rec, T, Dict) -> + rc([Dict:rec2msg(element(1, Rec))], T, Dict). + %% failed_avp/3 failed_avp(_, [] = No, _) -> |