aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/manager/snmpm_config.erl
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2014-05-28 16:26:34 +0200
committerRaimo Niskanen <[email protected]>2014-07-25 12:17:49 +0200
commit4dba07b435696393adbf582933f9b539be48b943 (patch)
tree1d20e6bc8a0e47635b9ff5f219dc31ce030a15e5 /lib/snmp/src/manager/snmpm_config.erl
parent20bb61e48a8370a4b5913d7d8e16a260bd3e31eb (diff)
downloadotp-4dba07b435696393adbf582933f9b539be48b943.tar.gz
otp-4dba07b435696393adbf582933f9b539be48b943.tar.bz2
otp-4dba07b435696393adbf582933f9b539be48b943.zip
Use IPv6 config in manager
Diffstat (limited to 'lib/snmp/src/manager/snmpm_config.erl')
-rw-r--r--lib/snmp/src/manager/snmpm_config.erl28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/snmp/src/manager/snmpm_config.erl b/lib/snmp/src/manager/snmpm_config.erl
index b3500d7293..5ebd3a0662 100644
--- a/lib/snmp/src/manager/snmpm_config.erl
+++ b/lib/snmp/src/manager/snmpm_config.erl
@@ -2297,9 +2297,33 @@ read_manager_config_file(Dir) ->
%% If the address is not possible to determine
%% that way, then we give up...
verify_mandatory(Conf, [port,engine_id,max_message_size]),
- ensure_config(default_manager_config(), Conf).
-
+ default_manager_config(Conf).
+default_manager_config(Conf) ->
+ %% Ensure address of right family
+ case lists:keyfind(address, 1, Conf) of
+ false ->
+ Domain =
+ case lists:keyfind(domain, 1, Conf) of
+ false ->
+ default_transport_domain();
+ {_, D} ->
+ D
+ end,
+ Family = snmp_conf:tdomain_to_family(Domain),
+ {ok, HostName} = inet:gethostname(),
+ case inet:getaddr(HostName, Family) of
+ {ok, Address} ->
+ [{address, Address} | Conf];
+ {error, _Reason} ->
+ ?d("default_manager_config -> "
+ "failed getting ~w address for ~s:~n"
+ " _Reason: ~p", [Family, HostName, _Reason]),
+ Conf
+ end;
+ _ ->
+ Conf
+ end.
default_manager_config() ->
{ok, HostName} = inet:gethostname(),