aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_gen.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-07-13 01:28:06 +0200
committerAnders Svensson <[email protected]>2017-08-03 17:14:28 +0200
commite0603ba18a67c1ef33f60122fe6f00393c0c0203 (patch)
tree3ee53cc9989492b83de76014bbe15f14aa867af5 /lib/diameter/src/base/diameter_gen.erl
parent58f9d631df0c256f7bc4ff3de2670b3b04e265f7 (diff)
downloadotp-e0603ba18a67c1ef33f60122fe6f00393c0c0203.tar.gz
otp-e0603ba18a67c1ef33f60122fe6f00393c0c0203.tar.bz2
otp-e0603ba18a67c1ef33f60122fe6f00393c0c0203.zip
Tweak map-valued decode
Use the same [MsgName | Avps] representation as for the list decode, but with Avps a map instead of a AVP name/values list. As a result, don't set the message/AVP name on an additional key in the map, which felt a bit odd. Messages are [MsgName :: atom() | map()], Grouped AVPs are just map(). Fix at least one problem in the traffic suite along the way: with decode_format false, the own decode in to_map/2 didn't know whether or not to decode strings, resulting on some failures.
Diffstat (limited to 'lib/diameter/src/base/diameter_gen.erl')
-rw-r--r--lib/diameter/src/base/diameter_gen.erl13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/diameter/src/base/diameter_gen.erl b/lib/diameter/src/base/diameter_gen.erl
index 78d8bd2fa3..597ec143a8 100644
--- a/lib/diameter/src/base/diameter_gen.erl
+++ b/lib/diameter/src/base/diameter_gen.erl
@@ -186,7 +186,7 @@ decode_avps(Name, Recs, #{module := Mod, decode_format := Fmt} = Opts) ->
%% AM counts the number of top-level AVPs, which missing/4 then
%% uses when adding 5005 errors.
Arities = Mod:avp_arity(Name),
- {reformat(Rec, Arities, Mod, Fmt),
+ {reformat(Name, Rec, Arities, Mod, Fmt),
Avps,
Failed ++ missing(Arities, Opts, Mod, AM)}.
@@ -752,8 +752,8 @@ newrec(_, _, false = No) ->
newrec(Mod, Name, record) ->
newrec(Mod, Name);
-newrec(_, Name, _) ->
- #{':name' => Name}.
+newrec(_, _, _) ->
+ #{}.
%% newrec/2
@@ -762,15 +762,14 @@ newrec(Mod, Name) ->
%% reformat/4
-reformat(Map, Arities, _Mod, list) ->
+reformat(_, Map, Arities, _Mod, list) ->
[{F,V} || {F,_} <- Arities, #{F := V} <- [Map]];
-reformat(Map, Arities, Mod, record_from_map) ->
- #{':name' := Name} = Map,
+reformat(Name, Map, Arities, Mod, record_from_map) ->
RecName = Mod:name2rec(Name),
list_to_tuple([RecName | [maps:get(F, Map, def(A)) || {F,A} <- Arities]]);
-reformat(Rec, _, _, _) ->
+reformat(_, Rec, _, _, _) ->
Rec.
%% def/1