aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/manager/snmpm_config.erl
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2014-08-29 11:19:52 +0200
committerRaimo Niskanen <[email protected]>2014-09-03 16:03:19 +0200
commit5bd1edc7b53dbcea6f63e0a7fb57925935e6b293 (patch)
tree34c29df796dea4ee090e8c787010eca5a3c05649 /lib/snmp/src/manager/snmpm_config.erl
parent46f752b15205977cb1191c1693e942a499d351f9 (diff)
downloadotp-5bd1edc7b53dbcea6f63e0a7fb57925935e6b293.tar.gz
otp-5bd1edc7b53dbcea6f63e0a7fb57925935e6b293.tar.bz2
otp-5bd1edc7b53dbcea6f63e0a7fb57925935e6b293.zip
Clean up some config warts
Diffstat (limited to 'lib/snmp/src/manager/snmpm_config.erl')
-rw-r--r--lib/snmp/src/manager/snmpm_config.erl42
1 files changed, 34 insertions, 8 deletions
diff --git a/lib/snmp/src/manager/snmpm_config.erl b/lib/snmp/src/manager/snmpm_config.erl
index 05d5ce72b1..940800fed4 100644
--- a/lib/snmp/src/manager/snmpm_config.erl
+++ b/lib/snmp/src/manager/snmpm_config.erl
@@ -1816,7 +1816,11 @@ verify_agent_config(
{TD, VerifiedConf};
_ ->
%% Insert tdomain since it is missing
- TD = default_transport_domain(),
+ %% Note: not default_transport_domain() since
+ %% taddress is the new format hence the application
+ %% should be tdomain aware and therefore addresses
+ %% on the Domain, Addr format should be used and understood.
+ TD = transportDomainUdpIpv4,
{TD, [{tdomain, TD}|VerifiedConf]}
end,
case snmp_conf:check_address(TDomain, Address, 0) of
@@ -2269,15 +2273,37 @@ check_manager_config({address = Tag, Ip} = Entry, {Domain, Port} = State) ->
[{Tag, FixedIp},
{transports, [{Domain, {FixedIp, Port}}]}]
end, State};
-check_manager_config({transports = Tag, Transports}, State) ->
+check_manager_config({transports = Tag, Transports}, {_, Port} = State)
+ when is_list(Transports) ->
CheckedTransports =
- [case snmp_conf:check_address(Domain, Address) of
- ok ->
- Transport;
- {ok, FixedAddress} ->
- {Domain, FixedAddress}
+ [case Transport of
+ {Domain, Address} ->
+ case
+ case Port of
+ undefined ->
+ snmp_conf:check_address(Domain, Address);
+ _ ->
+ snmp_conf:check_address(Domain, Address, Port)
+ end
+ of
+ ok ->
+ Transport;
+ {ok, FixedAddress} ->
+ {Domain, FixedAddress}
+ end;
+ _Domain when Port =:= undefined->
+ error({missing_mandatory, port});
+ Domain ->
+ Family = snmp_conf:tdomain_to_family(Domain),
+ {ok, Hostname} = inet:gethostname(),
+ case inet:getaddr(Hostname, Family) of
+ {ok, IpAddr} ->
+ {Domain, {IpAddr, Port}};
+ {error, _} ->
+ error({bad_address, {Domain, Hostname}})
+ end
end
- || {Domain, Address} = Transport <- Transports],
+ || Transport <- Transports],
{{ok, {Tag, CheckedTransports}}, State};
check_manager_config(Entry, State) ->
{check_manager_config(Entry), State}.