aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2013-04-08 12:51:11 +0200
committerAnders Svensson <[email protected]>2013-04-08 12:51:11 +0200
commit4fb256d26b9213911d0f93db00ba89aecf595178 (patch)
tree11a6aa182ea9dbf0b4342bd42e8650eb005ecca6 /lib
parent0804e1eefdab7113b4168c370ecad934f42d3587 (diff)
parent157886e6b69e9c7cf1e0e6f8ea932a82b810ea12 (diff)
downloadotp-4fb256d26b9213911d0f93db00ba89aecf595178.tar.gz
otp-4fb256d26b9213911d0f93db00ba89aecf595178.tar.bz2
otp-4fb256d26b9213911d0f93db00ba89aecf595178.zip
Merge branch 'maint'
Diffstat (limited to 'lib')
-rw-r--r--lib/diameter/doc/src/notes.xml18
-rw-r--r--lib/diameter/src/base/diameter_config.erl40
-rw-r--r--lib/diameter/test/diameter_config_SUITE.erl15
3 files changed, 45 insertions, 28 deletions
diff --git a/lib/diameter/doc/src/notes.xml b/lib/diameter/doc/src/notes.xml
index 2daf84b0d4..ad61f12b5b 100644
--- a/lib/diameter/doc/src/notes.xml
+++ b/lib/diameter/doc/src/notes.xml
@@ -42,7 +42,7 @@ first.</p>
<!-- ===================================================================== -->
-<section><title>Diameter 1.4.1.1</title>
+<section><title>diameter 1.4.1.1</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
@@ -79,7 +79,7 @@ first.</p>
</section>
-<section><title>Diameter 1.4.1</title>
+<section><title>diameter 1.4.1</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
@@ -166,7 +166,7 @@ first.</p>
</section>
-<section><title>Diameter 1.4</title>
+<section><title>diameter 1.4</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
@@ -245,7 +245,7 @@ first.</p>
</section>
-<section><title>Diameter 1.3.1</title>
+<section><title>diameter 1.3.1</title>
<section><title>Known Bugs and Problems</title>
<list>
@@ -261,7 +261,7 @@ first.</p>
</section>
-<section><title>Diameter 1.3</title>
+<section><title>diameter 1.3</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
@@ -418,7 +418,7 @@ first.</p>
</section>
-<section><title>Diameter 1.2</title>
+<section><title>diameter 1.2</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
@@ -518,7 +518,7 @@ first.</p>
</section>
-<section><title>Diameter 1.1</title>
+<section><title>diameter 1.1</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
@@ -545,7 +545,7 @@ first.</p>
</section>
-<section><title>Diameter 1.0</title>
+<section><title>diameter 1.0</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
@@ -659,7 +659,7 @@ first.</p>
</section>
-<section><title>Diameter 0.10</title>
+<section><title>diameter 0.10</title>
<section><title>Fixed Bugs and Malfunctions</title>
<list>
diff --git a/lib/diameter/src/base/diameter_config.erl b/lib/diameter/src/base/diameter_config.erl
index 1282930145..2a145c874b 100644
--- a/lib/diameter/src/base/diameter_config.erl
+++ b/lib/diameter/src/base/diameter_config.erl
@@ -614,30 +614,38 @@ stop_transport(SvcName, Refs) ->
%% make_config/2
make_config(SvcName, Opts) ->
- Apps = init_apps(Opts),
+ AppOpts = [T || {application, _} = T <- Opts],
+ Apps = init_apps(AppOpts),
+
[] == Apps andalso ?THROW(no_apps),
%% Use the fact that diameter_caps has the same field names as CER.
Fields = ?BASE:'#info-'(diameter_base_CER) -- ['AVP'],
- COpts = [T || {K,_} = T <- Opts, lists:member(K, Fields)],
- Caps = make_caps(#diameter_caps{}, COpts),
+ CapOpts = [T || {K,_} = T <- Opts, lists:member(K, Fields)],
+ Caps = make_caps(#diameter_caps{}, CapOpts),
- ok = encode_CER(COpts),
+ ok = encode_CER(CapOpts),
- Os = split(Opts, fun opt/2, [{false, share_peers},
- {false, use_shared_peers},
- {false, monitor},
- {?NOMASK, sequence},
- {nodes, restrict_connections}]),
+ SvcOpts = make_opts((Opts -- AppOpts) -- CapOpts,
+ [{false, share_peers},
+ {false, use_shared_peers},
+ {false, monitor},
+ {?NOMASK, sequence},
+ {nodes, restrict_connections}]),
#service{name = SvcName,
rec = #diameter_service{applications = Apps,
capabilities = Caps},
- options = Os}.
+ options = SvcOpts}.
+
+make_opts(Opts, Defs) ->
+ Known = [{K, get_opt(K, Opts, D)} || {D,K} <- Defs],
+ Unknown = Opts -- Known,
+
+ [] == Unknown orelse ?THROW({invalid, hd(Unknown)}),
-split(Opts, F, Defs) ->
- [{K, F(K, get_opt(K, Opts, D))} || {D,K} <- Defs].
+ [{K, opt(K,V)} || {K,V} <- Known].
opt(K, false = B)
when K /= sequence ->
@@ -728,8 +736,8 @@ encode_CER(Opts) ->
init_apps(Opts) ->
lists:foldl(fun app_acc/2, [], lists:reverse(Opts)).
-app_acc({application, Opts}, Acc) ->
- is_list(Opts) orelse ?THROW({application, Opts}),
+app_acc({application, Opts} = T, Acc) ->
+ is_list(Opts) orelse ?THROW(T),
[Dict, Mod] = get_opt([dictionary, module], Opts),
Alias = get_opt(alias, Opts, Dict),
@@ -745,9 +753,7 @@ app_acc({application, Opts}, Acc) ->
mutable = M,
options = [{answer_errors, A},
{request_errors, P}]}
- | Acc];
-app_acc(_, Acc) ->
- Acc.
+ | Acc].
init_mod(#diameter_callback{} = R) ->
init_mod([diameter_callback, R]);
diff --git a/lib/diameter/test/diameter_config_SUITE.erl b/lib/diameter/test/diameter_config_SUITE.erl
index 47def9c8c9..46ff63756d 100644
--- a/lib/diameter/test/diameter_config_SUITE.erl
+++ b/lib/diameter/test/diameter_config_SUITE.erl
@@ -82,7 +82,11 @@
[[true],
[false],
[[node(), node()]]],
- [[x]]}]).
+ [[x]]},
+ {invalid_option, %% invalid service options are rejected
+ [],
+ [[x],
+ [x,x]]}]).
-define(TRANSPORT_CONFIG,
[{transport_module,
@@ -167,7 +171,14 @@
[[{okay, 1}]],
[[{suspect, 2}]]],
[[x],
- [[{open, 0}]]]}]).
+ [[{open, 0}]]]},
+ {private,
+ [[x]],
+ []},
+ {invalid_option, %% invalid transport options are silently ignored
+ [[x],
+ [x,x]],
+ []}]).
%% ===========================================================================