aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_codec.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-07-06 11:02:31 +0200
committerAnders Svensson <[email protected]>2017-08-03 17:14:27 +0200
commit1b3b64af3d9a5441b6da37cf4e97b59cb043f33b (patch)
tree495cd9292b841814f4e509b78d68fe807ca6cd6f /lib/diameter/src/base/diameter_codec.erl
parent722fa41564381dff0b7aa2b465193db30bb2f02f (diff)
downloadotp-1b3b64af3d9a5441b6da37cf4e97b59cb043f33b.tar.gz
otp-1b3b64af3d9a5441b6da37cf4e97b59cb043f33b.tar.bz2
otp-1b3b64af3d9a5441b6da37cf4e97b59cb043f33b.zip
Let messages and grouped AVPs be encoded/decoded from/to maps
With {record_decode, map}. The option name is arguably a bit misleading now, but not too objectionable given that the encode/decode in question has historically only been of records. One advantage of the map decode is that the map only contains values for those AVPs existing in the message or grouped AVP in question. The name of the message or grouped AVP is stored in with key ':name', the leading colon ensuring that the key isn't a diameter-name. Decoding to maps makes the hrl files generated from dictionary files largely irrelevant. There are value defines generated into these, but they're typically so long as to be unusable.
Diffstat (limited to 'lib/diameter/src/base/diameter_codec.erl')
-rw-r--r--lib/diameter/src/base/diameter_codec.erl3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/diameter/src/base/diameter_codec.erl b/lib/diameter/src/base/diameter_codec.erl
index 5e4c6e6d8f..0c43d52093 100644
--- a/lib/diameter/src/base/diameter_codec.erl
+++ b/lib/diameter/src/base/diameter_codec.erl
@@ -275,6 +275,9 @@ rec2msg(_, [Name|_])
when is_atom(Name) ->
Name;
+rec2msg(_, #{':name' := Name}) ->
+ Name;
+
rec2msg(Mod, Rec) ->
Mod:rec2msg(element(1, Rec)).