aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/diameter/doc/src/diameter.xml48
-rw-r--r--lib/diameter/doc/src/diameter_codec.xml2
-rw-r--r--lib/diameter/src/base/diameter.erl6
-rw-r--r--lib/diameter/src/base/diameter_codec.erl2
-rw-r--r--lib/diameter/src/base/diameter_config.erl10
-rw-r--r--lib/diameter/src/base/diameter_gen.erl4
-rw-r--r--lib/diameter/src/base/diameter_peer_fsm.erl6
-rw-r--r--lib/diameter/src/base/diameter_service.erl2
-rw-r--r--lib/diameter/src/base/diameter_traffic.erl6
-rw-r--r--lib/diameter/src/base/diameter_watchdog.erl6
-rw-r--r--lib/diameter/test/diameter_codec_SUITE.erl2
-rw-r--r--lib/diameter/test/diameter_codec_SUITE_data/diameter_test_unknown.erl2
-rw-r--r--lib/diameter/test/diameter_codec_test.erl2
-rw-r--r--lib/diameter/test/diameter_traffic_SUITE.erl14
14 files changed, 57 insertions, 55 deletions
diff --git a/lib/diameter/doc/src/diameter.xml b/lib/diameter/doc/src/diameter.xml
index e525ab3345..a7f001e096 100644
--- a/lib/diameter/doc/src/diameter.xml
+++ b/lib/diameter/doc/src/diameter.xml
@@ -798,6 +798,29 @@ be matched by corresponding &capability; configuration, of
</item>
<tag>
+<marker id="decode_format"/>
+<c>{decode_format, record | list | map | false}</c></tag>
+<item>
+<p>
+The type of decoded messages and grouped AVPs in the <c>msg</c> field
+of diameter_packet records and <c>value</c> field of diameter_avp
+records respectively.
+If <c>false</c> then the fields are set this value.
+See also &codec_message;.</p>
+
+<p>
+Defaults to <c>record</c>.</p>
+
+<note>
+<p>
+AVPs are decoded into a list of diameter_avp records in <c>avps</c>
+field of diameter_packet records independently of
+<c>decode_format</c>.</p>
+</note>
+
+</item>
+
+<tag>
<marker id="incoming_maxlen"/><c>{incoming_maxlen, 0..16777215}</c></tag>
<item>
<p>
@@ -970,31 +993,6 @@ occur in the message in question.</p>
</item>
<tag>
-<marker id="record_decode"/>
-<c>{record_decode, boolean() | list | map}</c></tag>
-<item>
-<p>
-Whether or not to decode message and grouped AVPs to records in the
-<c>msg</c> field of diameter_packet records and <c>value</c> field of
-diameter_avp records respectively, or to an alternate format.
-If false then the fields are set to the same value.
-See also &codec_message;.</p>
-
-<p>
-Defaults to <c>true</c>.</p>
-
-<note>
-<p>
-Disabling the record is useful for applications in which the records
-aren't used/needed.
-AVP values are available in the <c>avps</c> field of
-diameter_packet records regardless of whether or not there is a record
-decode.</p>
-</note>
-
-</item>
-
-<tag>
<marker id="string_decode"/><c>{string_decode, boolean()}</c></tag>
<item>
<p>
diff --git a/lib/diameter/doc/src/diameter_codec.xml b/lib/diameter/doc/src/diameter_codec.xml
index 6262dbf00d..4df8e788b7 100644
--- a/lib/diameter/doc/src/diameter_codec.xml
+++ b/lib/diameter/doc/src/diameter_codec.xml
@@ -244,7 +244,7 @@ file) and whose tail is a list of <c>{AvpName, AvpValues}</c> pairs,
or as a map with values keyed on AVP names and the message name in key
<c>:name</c>.
The format at decode is determined by &mod_service_opt;
-<c>record_decode</c>.
+<c>decode_format</c>.
Any of the formats is accepted at encode.</p>
<p>
diff --git a/lib/diameter/src/base/diameter.erl b/lib/diameter/src/base/diameter.erl
index b033632c47..75deaad511 100644
--- a/lib/diameter/src/base/diameter.erl
+++ b/lib/diameter/src/base/diameter.erl
@@ -47,6 +47,7 @@
stop/0]).
-export_type([evaluable/0,
+ decode_format/0,
restriction/0,
message_length/0,
remotes/0,
@@ -330,6 +331,9 @@ call(SvcName, App, Message) ->
-type message_length()
:: 0..16#FFFFFF.
+-type decode_format()
+ :: record | list | map | false.
+
%% Options passed to start_service/2
-type service_opt()
@@ -338,7 +342,7 @@ call(SvcName, App, Message) ->
| {restrict_connections, restriction()}
| {sequence, sequence() | evaluable()}
| {share_peers, remotes()}
- | {record_decode, boolean() | list | map}
+ | {decode_format, decode_format()}
| {string_decode, boolean()}
| {strict_mbit, boolean()}
| {incoming_maxlen, message_length()}
diff --git a/lib/diameter/src/base/diameter_codec.erl b/lib/diameter/src/base/diameter_codec.erl
index 9043af145e..275e80b9bb 100644
--- a/lib/diameter/src/base/diameter_codec.erl
+++ b/lib/diameter/src/base/diameter_codec.erl
@@ -290,7 +290,7 @@ rec2msg(Mod, Rec) ->
%% longer *the* decode.
decode(Mod, Pkt) ->
- Opts = #{record_decode => true,
+ Opts = #{decode_format => record,
string_decode => true,
strict_mbit => true,
rfc => 6733},
diff --git a/lib/diameter/src/base/diameter_config.erl b/lib/diameter/src/base/diameter_config.erl
index 8f958a67b4..09018308d5 100644
--- a/lib/diameter/src/base/diameter_config.erl
+++ b/lib/diameter/src/base/diameter_config.erl
@@ -713,7 +713,7 @@ make_config(SvcName, Opts) ->
{nodes, restrict_connections},
{16#FFFFFF, incoming_maxlen},
{true, strict_mbit},
- {true, record_decode},
+ {record, decode_format},
{true, string_decode},
{[], spawn_opt}]),
@@ -757,7 +757,7 @@ opt(K, false = B)
K == monitor;
K == restrict_connections;
K == strict_mbit;
- K == record_decode;
+ K == decode_format;
K == string_decode ->
B;
@@ -765,12 +765,12 @@ opt(K, true = B)
when K == share_peers;
K == use_shared_peers;
K == strict_mbit;
- K == record_decode;
K == string_decode ->
B;
-opt(record_decode, T)
- when T == list;
+opt(decode_format, T)
+ when T == record;
+ T == list;
T == map ->
T;
diff --git a/lib/diameter/src/base/diameter_gen.erl b/lib/diameter/src/base/diameter_gen.erl
index 2381b73d07..239d4a535f 100644
--- a/lib/diameter/src/base/diameter_gen.erl
+++ b/lib/diameter/src/base/diameter_gen.erl
@@ -178,7 +178,7 @@ enc_AVP(_Name, {_Dict, _AvpName, _Data} = T, Opts, _) ->
-> {parent_record(), [avp()], Failed}
when Failed :: [{5000..5999, #diameter_avp{}}].
-decode_avps(Name, Recs, #{module := Mod, record_decode := Fmt} = Opts) ->
+decode_avps(Name, Recs, #{module := Mod, decode_format := Fmt} = Opts) ->
{Avps, {Rec, AM, Failed}}
= mapfoldl(fun(T,A) -> decode(Name, Opts, Mod, T, A) end,
{newrec(Mod, Name, Fmt), #{}, []},
@@ -749,7 +749,7 @@ empty(Name, #{module := Mod} = Opts) ->
newrec(_, _, false = No) ->
No;
-newrec(Mod, Name, true) ->
+newrec(Mod, Name, record) ->
newrec(Mod, Name);
newrec(_, Name, _) ->
diff --git a/lib/diameter/src/base/diameter_peer_fsm.erl b/lib/diameter/src/base/diameter_peer_fsm.erl
index f2fbb70270..abf948593f 100644
--- a/lib/diameter/src/base/diameter_peer_fsm.erl
+++ b/lib/diameter/src/base/diameter_peer_fsm.erl
@@ -128,7 +128,7 @@
%% outgoing DPR; boolean says whether or not
%% the request was sent explicitly with
%% diameter:call/4.
- codec :: #{record_decode := true,
+ codec :: #{decode_format := record,
string_decode := boolean(),
strict_mbit := boolean(),
rfc := 3588 | 6733,
@@ -254,13 +254,13 @@ i({Ack, WPid, {M, Ref} = T, Opts, {SvcOpts, Nodes, Dict0, Svc}}) ->
length_errors = LengthErr,
strict = Strictness,
incoming_maxlen = Maxlen,
- codec = maps:with([record_decode,
+ codec = maps:with([decode_format,
string_decode,
strict_mbit,
rfc,
ordered_encode],
SvcOpts#{ordered_encode => false,
- record_decode => true})}.
+ decode_format => record})}.
%% The transport returns its local ip addresses so that different
%% transports on the same service can use different local addresses.
%% The local addresses are put into Host-IP-Address avps here when
diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl
index 7f7e3e3a3f..43be4d889a 100644
--- a/lib/diameter/src/base/diameter_service.erl
+++ b/lib/diameter/src/base/diameter_service.erl
@@ -113,7 +113,7 @@
restrict_connections := diameter:restriction(),
incoming_maxlen := diameter:message_length(),
strict_mbit := boolean(),
- record_decode := boolean() | map | list,
+ decode_format := diameter:decode_format(),
string_decode := boolean(),
spawn_opt := list() | {module(), atom(), list()}}}).
diff --git a/lib/diameter/src/base/diameter_traffic.erl b/lib/diameter/src/base/diameter_traffic.erl
index 6594994cfa..f684f60cb7 100644
--- a/lib/diameter/src/base/diameter_traffic.erl
+++ b/lib/diameter/src/base/diameter_traffic.erl
@@ -76,7 +76,7 @@
service_name :: diameter:service_name(),
apps :: [#diameter_app{}],
sequence :: diameter:sequence(),
- codec :: #{record_decode := boolean() | map | list,
+ codec :: #{decode_format := diameter:decode_format(),
string_decode := boolean(),
strict_mbit := boolean(),
incoming_maxlen := diameter:message_length()}}).
@@ -103,7 +103,7 @@ make_recvdata([SvcName, PeerT, Apps, SvcOpts | _]) ->
peerT = PeerT,
apps = Apps,
sequence = Mask,
- codec = maps:with([record_decode,
+ codec = maps:with([decode_format,
string_decode,
strict_mbit,
ordered_encode,
@@ -1976,7 +1976,7 @@ choose(false, _, X) -> X.
%% Decode options sufficient for AVP extraction.
decode_opts(Dict) ->
- #{record_decode => true,
+ #{decode_format => record,
string_decode => false,
strict_mbit => false,
failed_avp => false,
diff --git a/lib/diameter/src/base/diameter_watchdog.erl b/lib/diameter/src/base/diameter_watchdog.erl
index c3dc8c3bf0..60baf1e8a4 100644
--- a/lib/diameter/src/base/diameter_watchdog.erl
+++ b/lib/diameter/src/base/diameter_watchdog.erl
@@ -72,7 +72,7 @@
restrict := boolean(),
suspect := non_neg_integer(), %% OKAY -> SUSPECT
okay := non_neg_integer()}, %% REOPEN -> OKAY
- codec :: #{record_decode := false,
+ codec :: #{decode_format := false,
string_decode := false,
strict_mbit := boolean(),
failed_avp := false,
@@ -136,7 +136,7 @@ i({Ack, T, Pid, {Opts,
putr(restart, {T, Opts, Svc, SvcOpts}), %% save seeing it in trace
putr(dwr, dwr(Caps)), %%
Nodes = restrict_nodes(Restrict),
- CodecKeys = [record_decode,
+ CodecKeys = [decode_format,
string_decode,
strict_mbit,
incoming_maxlen,
@@ -157,7 +157,7 @@ i({Ack, T, Pid, {Opts,
suspect => 1,
okay => 3},
Opts)),
- codec = maps:with(CodecKeys, SvcOpts#{record_decode := false,
+ codec = maps:with(CodecKeys, SvcOpts#{decode_format := false,
string_decode := false,
ordered_encode => false})}.
diff --git a/lib/diameter/test/diameter_codec_SUITE.erl b/lib/diameter/test/diameter_codec_SUITE.erl
index 31332537e9..c79b642c09 100644
--- a/lib/diameter/test/diameter_codec_SUITE.erl
+++ b/lib/diameter/test/diameter_codec_SUITE.erl
@@ -292,7 +292,7 @@ recode(Msg, Dict) ->
opts(Mod) ->
#{dictionary => Mod,
- record_decode => true,
+ decode_format => record,
string_decode => false,
strict_mbit => true,
rfc => 6733,
diff --git a/lib/diameter/test/diameter_codec_SUITE_data/diameter_test_unknown.erl b/lib/diameter/test/diameter_codec_SUITE_data/diameter_test_unknown.erl
index fe602c9ee5..735339ebb9 100644
--- a/lib/diameter/test/diameter_codec_SUITE_data/diameter_test_unknown.erl
+++ b/lib/diameter/test/diameter_codec_SUITE_data/diameter_test_unknown.erl
@@ -78,7 +78,7 @@ dec('BR', #diameter_packet
opts(Mod) ->
#{dictionary => Mod,
- record_decode => true,
+ decode_format => record,
string_decode => true,
strict_mbit => true,
rfc => 6733,
diff --git a/lib/diameter/test/diameter_codec_test.erl b/lib/diameter/test/diameter_codec_test.erl
index 7595e7edfc..22fb0550ea 100644
--- a/lib/diameter/test/diameter_codec_test.erl
+++ b/lib/diameter/test/diameter_codec_test.erl
@@ -219,7 +219,7 @@ opts(Mod) ->
dictionary => Mod}.
opts() ->
- #{record_decode => true,
+ #{decode_format => record,
string_decode => true,
strict_mbit => true,
rfc => 6733,
diff --git a/lib/diameter/test/diameter_traffic_SUITE.erl b/lib/diameter/test/diameter_traffic_SUITE.erl
index adf8bf4d66..aa0098ccd6 100644
--- a/lib/diameter/test/diameter_traffic_SUITE.erl
+++ b/lib/diameter/test/diameter_traffic_SUITE.erl
@@ -142,8 +142,8 @@
%% How to construct outgoing messages.
-define(ENCODINGS, [list, record, map]).
-%% How to set record_decode.
--define(DECODINGS, [true, false, map, list]).
+%% How to decode incoming messages.
+-define(DECODINGS, [record, false, map, list]).
%% How to send answers, in a diameter_packet or not.
-define(CONTAINERS, [pkt, msg]).
@@ -462,7 +462,7 @@ start_services(Config) ->
server_service = SN,
server_decoding = SD}
= group(Config),
- ok = diameter:start_service(SN, [{record_decode, SD}
+ ok = diameter:start_service(SN, [{decode_format, SD}
| ?SERVICE(SN, S)]),
ok = diameter:start_service(CN, [{sequence, ?CLIENT_MASK}
| ?SERVICE(CN, S)]).
@@ -1065,11 +1065,11 @@ origin(N) ->
%% Map atoms. The atoms are part of (constructed) group names, so it's
%% good that they're readable.
-decode(true) -> 0; %% record
+decode(record) -> 0;
decode(list) -> 1;
decode(map) -> 2;
decode(false) -> 3;
-decode(0) -> true;
+decode(0) -> record;
decode(1) -> list;
decode(2) -> map;
decode(3) -> false.
@@ -1113,14 +1113,14 @@ to_map(map, #diameter_packet{msg = Msg})
to_map(list, #diameter_packet{msg = [MsgName | Avps]}) ->
maps:put(':name', MsgName, maps:from_list(Avps));
-to_map(true, #diameter_packet{header = H, msg = Rec}) ->
+to_map(record, #diameter_packet{header = H, msg = Rec}) ->
rec_to_map(Rec, dict(H));
%% No record decode: do it ourselves.
to_map(false, #diameter_packet{header = H,
msg = false,
bin = Bin}) ->
- Opts = #{record_decode => map,
+ Opts = #{decode_format => map,
string_decode => false,
strict_mbit => true,
rfc => 6733},