aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/misc/snmp_conf.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2011-03-07 19:22:30 +0100
committerMicael Karlberg <[email protected]>2011-03-07 19:22:30 +0100
commit0c14ab3979bb1eba4b4398c92d176e56eba8286b (patch)
treec21e60501bb4fc6446d9ba2b1091886c623b0120 /lib/snmp/src/misc/snmp_conf.erl
parente91ecef78904be02bb785fdff0dcaf6d38176ba7 (diff)
downloadotp-0c14ab3979bb1eba4b4398c92d176e56eba8286b.tar.gz
otp-0c14ab3979bb1eba4b4398c92d176e56eba8286b.tar.bz2
otp-0c14ab3979bb1eba4b4398c92d176e56eba8286b.zip
Basically backup commit (time to go home).
Implemented handling of domains in the mpd module. Still some errors left though (3 test cases fail).
Diffstat (limited to 'lib/snmp/src/misc/snmp_conf.erl')
-rw-r--r--lib/snmp/src/misc/snmp_conf.erl31
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/snmp/src/misc/snmp_conf.erl b/lib/snmp/src/misc/snmp_conf.erl
index 6fc261b07e..cda86d3f6f 100644
--- a/lib/snmp/src/misc/snmp_conf.erl
+++ b/lib/snmp/src/misc/snmp_conf.erl
@@ -40,6 +40,7 @@
check_domain/1,
check_tdomain/1,
mk_tdomain/1,
+ which_domain/1,
check_ip/1,
check_taddress/1, check_taddress/2,
mk_taddress/3,
@@ -516,16 +517,42 @@ check_domain(Domain) ->
%% point, so we dont need to do that again.
mk_taddress(snmpUDPDomain, Ip, Port) ->
mk_taddress(transportDomainUdpIpv4, Ip, Port);
-mk_taddress(transportDomainUdpIpv4, Ip, Port) ->
+mk_taddress(transportDomainUdpIpv4, Ip, Port) when is_list(Ip) ->
Ip ++ [Port div 256, Port rem 256];
-mk_taddress(transportDomainUdpIpv6, Ip, Port) ->
+mk_taddress(transportDomainUdpIpv4 = Domain, Ip, Port) when is_tuple(Ip) ->
+ mk_taddress(Domain, tuple_to_list(Ip), Port);
+mk_taddress(transportDomainUdpIpv6, Ip, Port) when is_list(Ip) ->
Ip ++ [Port div 256, Port rem 256];
+mk_taddress(transportDomainUdpIpv6 = Domain, Ip, Port) when is_tuple(Ip) ->
+ mk_taddress(Domain, tuple_to_list(Ip), Port);
+
+%% These are just for convenience
+mk_taddress(?snmpUDPDomain, Ip, Port) ->
+ mk_taddress(snmpUDPDomain, Ip, Port);
+mk_taddress(?transportDomainUdpIpv4, Ip, Port) ->
+ mk_taddress(transportDomainUdpIpv4, Ip, Port);
+mk_taddress(?transportDomainUdpIpv6, Ip, Port) ->
+ mk_taddress(transportDomainUdpIpv6, Ip, Port);
+
+%% Bad domain
mk_taddress(BadDomain, _Ip, _Port) ->
error({bad_domain, BadDomain}).
%% ---------
+which_domain(Ip) when is_list(Ip) andalso (length(Ip) =:= 4) ->
+ transportDomainUdpIpv4;
+which_domain(Ip) when is_tuple(Ip) andalso (size(Ip) =:= 4) ->
+ transportDomainUdpIpv4;
+which_domain(Ip) when is_list(Ip) andalso (length(Ip) =:= 8) ->
+ transportDomainUdpIpv6;
+which_domain(Ip) when is_tuple(Ip) andalso (size(Ip) =:= 8) ->
+ transportDomainUdpIpv6.
+
+
+%% ---------
+
check_ip(X) ->
check_ip(snmpUDPDomain, X).