diff options
author | Micael Karlberg <[email protected]> | 2011-03-03 14:27:32 +0100 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2011-03-03 14:27:32 +0100 |
commit | 4526ec71fc913993ec6c5f0a9c0e11192240a60a (patch) | |
tree | a77f5209a2fc5459805836121d76cd883915aa09 /lib | |
parent | d711ad48d29ea87398880e2655db72455334bf07 (diff) | |
download | otp-4526ec71fc913993ec6c5f0a9c0e11192240a60a.tar.gz otp-4526ec71fc913993ec6c5f0a9c0e11192240a60a.tar.bz2 otp-4526ec71fc913993ec6c5f0a9c0e11192240a60a.zip |
Handling target address configuration files (with new Domain).
Also added some proper documentation.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/snmp/doc/src/notes.xml | 4 | ||||
-rw-r--r-- | lib/snmp/doc/src/snmp_agent_config_files.xml | 60 | ||||
-rw-r--r-- | lib/snmp/doc/src/snmp_target_mib.xml | 24 | ||||
-rw-r--r-- | lib/snmp/doc/src/snmpa_conf.xml | 25 | ||||
-rw-r--r-- | lib/snmp/src/agent/snmp_target_mib.erl | 21 | ||||
-rw-r--r-- | lib/snmp/src/agent/snmpa_conf.erl | 47 |
6 files changed, 115 insertions, 66 deletions
diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml index 8677d5ab61..8dd5bcb2c0 100644 --- a/lib/snmp/doc/src/notes.xml +++ b/lib/snmp/doc/src/notes.xml @@ -45,6 +45,10 @@ <list type="bulleted"> <item> <p>[agent] Added support for sending traps to IPv6 targets. </p> + <p>See the + <seealso marker="snmp_agent_config_files#target_addr">target address config file</seealso>, + the <seealso marker="snmpa_conf#target_addr_entry">target_addr_entry/11</seealso> function or + <seealso marker="snmp_target_mib#add_addr">add_addr/11</seealso> for more info. </p> <p>Own Id: OTP-9088</p> <p>Aux Id: Seq 11790</p> </item> diff --git a/lib/snmp/doc/src/snmp_agent_config_files.xml b/lib/snmp/doc/src/snmp_agent_config_files.xml index b62269d506..bd5c537522 100644 --- a/lib/snmp/doc/src/snmp_agent_config_files.xml +++ b/lib/snmp/doc/src/snmp_agent_config_files.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="latin1" ?> +<?xml version="1.0" encoding="iso-8859-1" ?> <!DOCTYPE chapter SYSTEM "chapter.dtd"> <chapter> @@ -367,56 +367,50 @@ <marker id="target_addr"></marker> <title>Target Address Definitions</title> <p>The information about Target Address Definitions should be - stored in a file called - <c>target_addr.conf</c>. - </p> + stored in a file called <c>target_addr.conf</c>. </p> <p>The corresponding tables are <c>snmpTargetAddrTable</c> in the - SNMP-TARGET-MIB and <c>snmpTargetAddrExtTable</c> in the SNMP-COMMUNITY-MIB. - </p> - <p>Each entry is a term: - </p> - <p><c>{TargetName, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId}.</c> or <br></br> -<c>{TargetName, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize}.</c></p> + SNMP-TARGET-MIB and <c>snmpTargetAddrExtTable</c> in the + SNMP-COMMUNITY-MIB. </p> + <p>Each entry is a term: </p> + <p><c>{TargetName, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId}.</c> <br></br> or <br></br> +<c>{TargetName, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize}.</c> <br></br> or <br></br> +<c>{TargetName, Domain, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize}.</c></p> <list type="bulleted"> <item> <p><c>TargetName</c> is a unique non-empty string. </p> </item> <item> - <p><c>Ip</c> is a list of four integers. - </p> + <p><c>Domain</c> is one of the atoms: + <c>transportDomainUdpIpv4</c> | <c>transportDomainUdpIpv6</c>. </p> </item> <item> - <p><c>Udp</c> is an integer. - </p> + <p><c>Ip</c> is a list of four or eight integers. </p> </item> <item> - <p><c>Timeout</c> is an integer. - </p> + <p><c>Udp</c> is an integer. </p> </item> <item> - <p><c>RetryCount</c> is an integer. - </p> + <p><c>Timeout</c> is an integer. </p> </item> <item> - <p><c>TagList</c> is a string. - </p> + <p><c>RetryCount</c> is an integer. </p> </item> <item> - <p><c>ParamsName</c> is a string. - </p> + <p><c>TagList</c> is a string. </p> </item> <item> - <p><c>EngineId</c> is a string or the atom <c>discovery</c>. - </p> + <p><c>ParamsName</c> is a string. </p> </item> <item> - <p><c>TMask</c> is a string of size 0, or size 6 (default: []). - </p> + <p><c>EngineId</c> is a string or the atom <c>discovery</c>. </p> </item> <item> - <p><c>MaxMessageSize</c> is an integer (default: 2048). - </p> + <p><c>TMask</c> is a list of integer() of size 0, + size 6 or size 10 (default: []). </p> + </item> + <item> + <p><c>MaxMessageSize</c> is an integer (default: 2048). </p> </item> </list> <p>Note that if <c>EngineId</c> has the value <c>discovery</c>, @@ -429,14 +423,10 @@ <marker id="target_params"></marker> <title>Target Parameters Definitions</title> <p>The information about Target Parameters Definitions should be - stored in a file called - <c>target_params.conf</c>. - </p> + stored in a file called <c>target_params.conf</c>. </p> <p>The corresponding table is <c>snmpTargetParamsTable</c> in the - SNMP-TARGET-MIB. - </p> - <p>Each entry is a term: - </p> + SNMP-TARGET-MIB. </p> + <p>Each entry is a term: </p> <p><c>{ParamsName, MPModel, SecurityModel, SecurityName, SecurityLevel}.</c></p> <list type="bulleted"> <item> diff --git a/lib/snmp/doc/src/snmp_target_mib.xml b/lib/snmp/doc/src/snmp_target_mib.xml index 4a36be19a3..d5151d41de 100644 --- a/lib/snmp/doc/src/snmp_target_mib.xml +++ b/lib/snmp/doc/src/snmp_target_mib.xml @@ -1,10 +1,10 @@ -<?xml version="1.0" encoding="latin1" ?> +<?xml version="1.0" encoding="iso-8859-1" ?> <!DOCTYPE erlref SYSTEM "erlref.dtd"> <erlref> <header> <copyright> - <year>1998</year><year>2009</year> + <year>1998</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -39,9 +39,21 @@ and functions for configuring the database. </p> <p>The configuration files are described in the SNMP User's Manual.</p> - <marker id="configure"></marker> + <marker id="types"></marker> </description> + <section> + <title>DATA TYPES</title> + <code type="none"><![CDATA[ +transportDomain() = transportDomainUdpIpv4 | transportDomainUdpIpv6 +transportAddressIPv4() = [integer()], length 4 +transportAddressIPv6() = [integer()], length 8 +transportAddressMask() = [integer()], length 0 (default), 6 (IPv4) or 10 (IPv6) + ]]></code> + + <marker id="configure"></marker> + </section> + <funcs> <func> <name>configure(ConfDir) -> void()</name> @@ -118,17 +130,19 @@ <func> <name>add_addr(Name, Ip, Port, Timeout, Retry, TagList, Params, EngineId, TMask, MMS) -> Ret</name> + <name>add_addr(Name, Domain, Ip, Port, Timeout, Retry, TagList, Params, EngineId, TMask, MMS) -> Ret</name> <fsummary>Add one target address definition</fsummary> <type> <v>Name = string()</v> - <v>Ip = [integer()], length 4</v> + <v>Domain = transportDomain()</v> + <v>Ip = transportAddressIPv4() | transportAddressIPv6() (depends on the value of Domain)</v> <v>Port = integer()</v> <v>Timeout = integer()</v> <v>Retry = integer()</v> <v>TagList = string()</v> <v>ParamsName = string()</v> <v>EngineId = string()</v> - <v>TMask = string(), length 0 or 6</v> + <v>TMask = transportAddressMask() (depends on Domain)</v> <v>MMS = integer()</v> <v>Ret = {ok, Key} | {error, Reason}</v> <v>Key = term()</v> diff --git a/lib/snmp/doc/src/snmpa_conf.xml b/lib/snmp/doc/src/snmpa_conf.xml index d873574c6e..a533c179ee 100644 --- a/lib/snmp/doc/src/snmpa_conf.xml +++ b/lib/snmp/doc/src/snmpa_conf.xml @@ -1,10 +1,10 @@ -<?xml version="1.0" encoding="latin1" ?> +<?xml version="1.0" encoding="iso-8859-1" ?> <!DOCTYPE erlref SYSTEM "erlref.dtd"> <erlref> <header> <copyright> - <year>2006</year><year>2010</year> + <year>2006</year><year>2011</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -38,8 +38,21 @@ used for manipulating (write/append/read) the config files of the SNMP agent. </p> - <marker id="agent_entry"></marker> + <marker id="types"></marker> </description> + + <section> + <title>DATA TYPES</title> + <code type="none"><![CDATA[ +transportDomain() = transportDomainUdpIpv4 | transportDomainUdpIpv6 +transportAddressIPv4() = [integer()], length 4 +transportAddressIPv6() = [integer()], length 8 +transportAddressMask() = [integer()], length 0 (default), 6 (IPv4) or 10 (IPv6) + ]]></code> + + <marker id="agent_entry"></marker> + </section> + <funcs> <func> <name>agent_entry(Tag, Val) -> agent_entry()</name> @@ -381,17 +394,19 @@ <name>target_addr_entry(Name, Ip, TagList, ParamsName, EngineId, TMask) -> target_addr_entry()</name> <name>target_addr_entry(Name, Ip, Udp, TagList, ParamsName, EngineId, TMask, MaxMessageSize) -> target_addr_entry()</name> <name>target_addr_entry(Name, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize) -> target_addr_entry()</name> + <name>target_addr_entry(Name, Domain, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize) -> target_addr_entry()</name> <fsummary>Create an target_addr entry</fsummary> <type> <v>Name = string()</v> - <v>Ip = string()</v> + <v>Domain = transportDomain()</v> + <v>Ip = transportAddressIPv4() | transportAddressIPv6() (depends on Domain)</v> <v>Udp = integer()</v> <v>Timeout = integer()</v> <v>RetryCount = integer()</v> <v>TagList = string()</v> <v>ParamsName = string()</v> <v>EngineId = string()</v> - <v>TMask = string()</v> + <v>TMask = transportAddressMask() (depends on Domain)</v> <v>MaxMessageSize = integer()</v> <v>target_addr_entry() = term()</v> </type> diff --git a/lib/snmp/src/agent/snmp_target_mib.erl b/lib/snmp/src/agent/snmp_target_mib.erl index c76e4bb173..c7fc449bd2 100644 --- a/lib/snmp/src/agent/snmp_target_mib.erl +++ b/lib/snmp/src/agent/snmp_target_mib.erl @@ -29,6 +29,7 @@ -export([add_addr/10, delete_addr/1, add_params/5, delete_params/1]). -export([check_target_addr/1, check_target_params/1]). +-export([default_domain/0]). -include_lib("snmp/include/snmp_types.hrl"). -include_lib("snmp/include/snmp_tables.hrl"). @@ -50,6 +51,12 @@ %%----------------------------------------------------------------- + +default_domain() -> + snmpUDPDomain. + + +%%----------------------------------------------------------------- %% Func: configure/1 %% Args: Dir is the directory where the configuration files are found. %% Purpose: If the tables doesn't exist, this function reads @@ -140,8 +147,6 @@ read_target_config_files(Dir) -> %% {Name, Ip, Udp, Timeout, RetryCount, TagList, Params, EngineId, %% TMask, MMS} %%----------------------------------------------------------------- -default_domain() -> - snmpUDPDomain. check_target_addr({Name, Domain, Ip, Udp, Timeout, RetryCount, TagList, Params, EngineId, TMask, MMS}) -> @@ -172,7 +177,7 @@ check_target_addr({Name, Domain, Ip, Udp, Timeout, RetryCount, TagList, check_engine_id(EngineId), TAddress = snmp_conf:mk_taddress(Domain, Ip, Udp), TDomain = snmp_conf:mk_tdomain(Domain), - check_mask(TDomain, TMask, TAddress), + check_tmask(TDomain, TMask, TAddress), snmp_conf:check_packet_size(MMS), ?vtrace("check target address done",[]), Addr = {Name, TDomain, TAddress, Timeout, @@ -210,12 +215,12 @@ check_engine_id(EngineId) -> snmp_conf:check_string(EngineId). -check_mask(_TDomain, [], _TAddress) -> +check_tmask(_TDomain, [], _TAddress) -> ok; -check_mask(TDomain, TMask, TAddress) when length(TMask) =:= length(TAddress) -> +check_tmask(TDomain, TMask, TAddress) when length(TMask) =:= length(TAddress) -> snmp_conf:check_taddress(TDomain, TMask); -check_mask(_TDomain, TMask, _TAddr) -> - throw({error, {invalid_mask, TMask}}). +check_tmask(_TDomain, TMask, _TAddr) -> + throw({error, {invalid_tmask, TMask}}). %%----------------------------------------------------------------- @@ -637,7 +642,7 @@ snmpTargetAddrTable(get, RowIndex, Cols) -> snmpTargetAddrTable(get_next, RowIndex, Cols) -> next(snmpTargetAddrTable, RowIndex, Cols); snmpTargetAddrTable(set, RowIndex, Cols0) -> - %% BMK BMK BMK + %% BMK BMK case (catch verify_targetAddrTable_cols(Cols0)) of {ok, Cols} -> snmp_notification_mib:invalidate_cache(), diff --git a/lib/snmp/src/agent/snmpa_conf.erl b/lib/snmp/src/agent/snmpa_conf.erl index b4fc716b3e..c17256b258 100644 --- a/lib/snmp/src/agent/snmpa_conf.erl +++ b/lib/snmp/src/agent/snmpa_conf.erl @@ -48,7 +48,7 @@ %% target_addr.conf target_addr_entry/5, target_addr_entry/6, - target_addr_entry/8, target_addr_entry/10, + target_addr_entry/8, target_addr_entry/10, target_addr_entry/11, write_target_addr_config/2, write_target_addr_config/3, append_target_addr_config/2, read_target_addr_config/1, @@ -447,7 +447,23 @@ target_addr_entry(Name, EngineId, TMask, MaxMessageSize) -> + target_addr_entry(Name, snmp_target_mib:default_domain(), Ip, Udp, + Timeout, RetryCount, TagList, ParamsName, + TMask, MaxMessageSize). + +target_addr_entry(Name, + Domain, + Ip, + Udp, + Timeout, + RetryCount, + TagList, + ParamsName, + EngineId, + TMask, + MaxMessageSize) -> {Name, + Domain, Ip, Udp, Timeout, @@ -465,9 +481,13 @@ write_target_addr_config(Dir, Conf) -> "%% The data is inserted into the snmpTargetAddrTable defined\n" "%% in SNMP-TARGET-MIB, and in the snmpTargetAddrExtTable defined\n" "%% in SNMP-COMMUNITY-MIB.\n" -"%% Each row is a 10-tuple:\n" -"%% {Name, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId,\n" -"%% TMask, MaxMessageSize}.\n" +"%% Each row is a 10 or 11-tuple (Domain is optional):\n" +"%% {Name, \n" +"%% Domain, Ip, Udp, \n" +"%% Timeout, RetryCount, TagList, ParamsName, EngineId,\n" +"%% TMask, MaxMessageSize}.\n" +"%% The value of Domain deside the format of the Ip and TMask values. \n" +"%% If not present, classic Ipv4 is assumed. \n" "%% The EngineId value is only used if Inform-Requests are sent to this\n" "%% target. If Informs are not sent, this value is ignored, and can be\n" "%% e.g. an empty string. However, if Informs are sent, it is essential\n" @@ -524,13 +544,14 @@ write_target_addr_conf(Fd, Conf) -> lists:foreach(Fun, Conf). do_write_target_addr_conf(Fd, - {Name, Ip, Udp, + {Name, + Domain, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize}) -> io:format(Fd, - "{\"~s\", ~w, ~w, ~w, ~w, \"~s\", \"~s\", \"~s\", ~w, ~w}.~n", - [Name, Ip, Udp, Timeout, RetryCount, TagList, + "{\"~s\", ~w, ~w, ~w, ~w, ~w, \"~s\", \"~s\", \"~s\", ~w, ~w}.~n", + [Name, Domain, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId, TMask, MaxMessageSize]); do_write_target_addr_conf(_Fd, Crap) -> error({bad_target_addr_config, Crap}). @@ -546,13 +567,13 @@ target_params_entry(Name, Vsn) -> target_params_entry(Name, Vsn, SecName, SecLevel). target_params_entry(Name, Vsn, SecName, SecLevel) -> - MPModel = if Vsn == v1 -> v1; - Vsn == v2 -> v2c; - Vsn == v3 -> v3 + MPModel = if Vsn =:= v1 -> v1; + Vsn =:= v2 -> v2c; + Vsn =:= v3 -> v3 end, - SecModel = if Vsn == v1 -> v1; - Vsn == v2 -> v2c; - Vsn == v3 -> usm + SecModel = if Vsn =:= v1 -> v1; + Vsn =:= v2 -> v2c; + Vsn =:= v3 -> usm end, target_params_entry(Name, MPModel, SecModel, SecName, SecLevel). |