aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/agent
diff options
context:
space:
mode:
Diffstat (limited to 'lib/snmp/src/agent')
-rw-r--r--lib/snmp/src/agent/snmp_target_mib.erl31
-rw-r--r--lib/snmp/src/agent/snmpa_net_if.erl34
2 files changed, 31 insertions, 34 deletions
diff --git a/lib/snmp/src/agent/snmp_target_mib.erl b/lib/snmp/src/agent/snmp_target_mib.erl
index 3bcfd469e6..932829e150 100644
--- a/lib/snmp/src/agent/snmp_target_mib.erl
+++ b/lib/snmp/src/agent/snmp_target_mib.erl
@@ -679,6 +679,20 @@ snmpTargetAddrTable(print) ->
FOI = foi(Table),
PrintRow =
fun(Prefix, Row) ->
+ TDomain = element(?snmpTargetAddrTDomain, Row),
+ Domain =
+ try snmp_conf:tdomain_to_domain(TDomain)
+ catch
+ {error, {bad_tdomain, _}} ->
+ undefined
+ end,
+ TAddress = element(?snmpTargetAddrTAddress, Row),
+ AddrString =
+ try snmp_conf:mk_addr_string({Domain, TAddress})
+ catch
+ {error, {bad_address, _}} ->
+ "-"
+ end,
lists:flatten(
io_lib:format("~sName: ~p"
"~n~sTDomain: ~p (~w)"
@@ -693,21 +707,8 @@ snmpTargetAddrTable(print) ->
"~n~s[Ext] TMask: ~p"
"~n~s[Ext] MMS: ~p",
[Prefix, element(?snmpTargetAddrName, Row),
- Prefix, element(?snmpTargetAddrTDomain, Row),
- case element(?snmpTargetAddrTDomain, Row) of
- ?snmpUDPDomain -> snmpUDPDomain;
- ?transportDomainUdpIpv4 -> transportDomainUdpIpv4;
- ?transportDomainUdpIpv6 -> transportDomainUdpIpv6;
- _ -> undefined
- end,
- Prefix, element(?snmpTargetAddrTAddress, Row),
- case element(?snmpTargetAddrTAddress, Row) of
- [A,B,C,D,U1,U2] ->
- lists:flatten(
- io_lib:format("~w.~w.~w.~w:~w",
- [A, B, C, D, U1 bsl 8 + U2]));
- _ -> "-"
- end,
+ Prefix, TDomain, Domain,
+ Prefix, TAddress, AddrString,
Prefix, element(?snmpTargetAddrTimeout, Row),
Prefix, element(?snmpTargetAddrRetryCount, Row),
Prefix, element(?snmpTargetAddrTagList, Row),
diff --git a/lib/snmp/src/agent/snmpa_net_if.erl b/lib/snmp/src/agent/snmpa_net_if.erl
index 2c800db8b6..71bb9cad2e 100644
--- a/lib/snmp/src/agent/snmpa_net_if.erl
+++ b/lib/snmp/src/agent/snmpa_net_if.erl
@@ -142,9 +142,16 @@ init(Prio, NoteStore, MasterAgent, Parent, Opts) ->
try loop(State)
catch C:E ->
S = erlang:get_stacktrace(),
- error_msg(
- "loop/1 EXCEPTION ~w:~w~n"
- " ~p", [C,E,S]),
+ Fmt =
+ "loop/1 EXCEPTION ~w:~w~n"
+ " ~p",
+ case C of
+ exit ->
+ %% Externally killed, root cause is elsewhere
+ info_msg(Fmt, [C, E, S]);
+ _ ->
+ error_msg(Fmt, [C, E, S])
+ end,
erlang:raise(C, E, S)
end;
{error, Reason} ->
@@ -287,20 +294,9 @@ log({Log, Types}, _, Packet, Address) ->
false ->
ok
end.
-%% log(_, _, _, _, _) ->
-%% ok.
-
-format_address({snmpUDPDomain, {_Ip, Port} = Addr}) when is_integer(Port) ->
- format_address(Addr);
-format_address({transportDomainUdpIpv4, {Ip, Port}}) ->
- format_address("udpIpv4/~s:~w", [inet:ntoa(Ip), Port]);
-format_address({transportDomainUdpIpv6, {Ip, Port}}) ->
- format_address("udpIpv6/[~s]:~w", [inet:ntoa(Ip), Port]);
-format_address({Ip, Port}) when is_integer(Port) ->
- format_address("~s:~w", [inet:ntoa(Ip), Port]).
-format_address(Format, Args) ->
- iolist_to_binary(io_lib:format(Format, Args)).
+format_address(Address) ->
+ iolist_to_binary(snmp_conf:mk_addr_string(Address)).
@@ -712,7 +708,6 @@ maybe_handle_reply_pdu(
Type, ACMData, To) ->
S1 = update_req_counter_outgoing(S, Rid),
- %% Addresses = [To],
Addresses = [fix_filter_address(Domain, To)],
case
try
@@ -962,7 +957,6 @@ handle_response(Vsn, Pdu, From, S) ->
maybe_udp_send(
#state{usock = Sock, filter = FilterMod, domain = Domain},
To, Packet) ->
- %% {To_1, To_2} = To,
{To_1, To_2} = fix_filter_address(Domain, To),
case
try FilterMod:accept_send(To_1, To_2)
@@ -997,7 +991,6 @@ maybe_udp_send(
filter = FilterMod,
domain = Domain},
To, Packet, Type, _LogData) ->
- %% {To_1, To_2} = To,
{To_1, To_2} = fix_filter_address(Domain, To),
case
try FilterMod:accept_send(To_1, To_2)
@@ -1358,6 +1351,9 @@ get_bind_to_ip_address(Opts) ->
error_msg(F,A) ->
?snmpa_error("NET-IF server: " ++ F, A).
+info_msg(F,A) ->
+ ?snmpa_info("NET-IF server: " ++ F, A).
+
%% ---
user_err(F, A) ->