aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2013-04-08 12:50:37 +0200
committerAnders Svensson <[email protected]>2013-04-08 12:50:37 +0200
commit157886e6b69e9c7cf1e0e6f8ea932a82b810ea12 (patch)
treebf4890c069b3358fe3d1c62c8bdc1926297beede /lib/diameter/src
parent68380845615d54f23a08d6a5928ef28701de744b (diff)
parent38304d7b542e3c592d2234391062b4e74c42f4b5 (diff)
downloadotp-157886e6b69e9c7cf1e0e6f8ea932a82b810ea12.tar.gz
otp-157886e6b69e9c7cf1e0e6f8ea932a82b810ea12.tar.bz2
otp-157886e6b69e9c7cf1e0e6f8ea932a82b810ea12.zip
Merge branch 'anders/diameter/service_config/OTP-11017' into maint
* anders/diameter/service_config/OTP-11017: Fix handling of unknown options to diameter:start_service/2
Diffstat (limited to 'lib/diameter/src')
-rw-r--r--lib/diameter/src/base/diameter_config.erl40
1 files changed, 23 insertions, 17 deletions
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]);