diff options
author | Raimo Niskanen <[email protected]> | 2014-08-22 12:09:03 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2014-08-22 12:09:03 +0200 |
commit | bdbd6849aa811faf20d5ce7d577a49612266209a (patch) | |
tree | dad16dd76eebe0b8a0d2fe5fbff0f9040ffd7db0 /lib/snmp/src/misc | |
parent | 037590364fe8b5a657563cd7d28a20d84ee8d99f (diff) | |
download | otp-bdbd6849aa811faf20d5ce7d577a49612266209a.tar.gz otp-bdbd6849aa811faf20d5ce7d577a49612266209a.tar.bz2 otp-bdbd6849aa811faf20d5ce7d577a49612266209a.zip |
Clean up config error handling and negative results
Diffstat (limited to 'lib/snmp/src/misc')
-rw-r--r-- | lib/snmp/src/misc/snmp_conf.erl | 8 | ||||
-rw-r--r-- | lib/snmp/src/misc/snmp_config.erl | 8 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/snmp/src/misc/snmp_conf.erl b/lib/snmp/src/misc/snmp_conf.erl index f4483995cb..153c8070c2 100644 --- a/lib/snmp/src/misc/snmp_conf.erl +++ b/lib/snmp/src/misc/snmp_conf.erl @@ -749,8 +749,6 @@ which_domain({A0, A1, A2, A3, A4, A5, A6, A7}) %% --------- -mk_addr_string({_IP, Port} = Addr) when is_integer(Port) -> - mk_addr_string({snmpUDPDomain, Addr}); mk_addr_string({Domain, Addr}) when is_atom(Domain) -> %% XXX There is only code for IP domains here case check_address_ip(Domain, Addr) of @@ -768,7 +766,11 @@ mk_addr_string({Domain, Addr}) when is_atom(Domain) -> mk_addr_string_ntoa(Domain, Addr); IP -> mk_addr_string_ntoa(Domain, IP) - end. + end; +mk_addr_string({_IP, Port} = Addr) when is_integer(Port) -> + mk_addr_string({snmpUDPDomain, Addr}); +mk_addr_string(Strange) -> + lists:flatten(io_lib:format("~w", [Strange])). mk_addr_string_ntoa({_, _, _, _} = IP) -> diff --git a/lib/snmp/src/misc/snmp_config.erl b/lib/snmp/src/misc/snmp_config.erl index 0a50174adc..17dfcd70b4 100644 --- a/lib/snmp/src/misc/snmp_config.erl +++ b/lib/snmp/src/misc/snmp_config.erl @@ -1676,7 +1676,9 @@ write_agent_snmp_conf(Dir, AgentIP, AgentUDP, EngineID, MMS) {intAgentIpAddress, AgentIP}, {snmpEngineID, EngineID}, {snmpEngineMaxMessageSize, MMS}], - do_write_agent_snmp_conf(Dir, Conf). + do_write_agent_snmp_conf(Dir, Conf); +write_agent_snmp_conf(_Dir, Domain, AgentAddr, _EngineID, _MMS) -> + error({bad_address, {Domain, AgentAddr}}). do_write_agent_snmp_conf(Dir, Conf) -> Comment = @@ -2153,7 +2155,9 @@ write_manager_snmp_conf(Dir, Domain_or_IP, Addr_or_Port, MMS, EngineID) -> {address, IP}]; _ when is_integer(Addr_or_Port) -> [{port, Addr_or_Port}, - {address, Domain_or_IP}] + {address, Domain_or_IP}]; + _ -> + error({bad_address, {Domain_or_IP, Addr_or_Port}}) end ++ [{engine_id, EngineID}, {max_message_size, MMS}], |