Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
7168-snmp-Types-and-specs-for-snmp_community_mi...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 7168-snmp-Types-and-specs-for-snmp_community_mib-add_comm.patch of Package erlang
From cdd215ee0acd01b1eb084a20744ce8bb40689722 Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Thu, 11 Jan 2024 14:14:29 +0100 Subject: [PATCH 28/67] [snmp] Types and specs for snmp_community_mib:add_community/5,6 Also "required" adding a bunch of types in other mib modules. Also "fixed" type mib_name. --- lib/snmp/doc/src/Makefile | 9 ++- lib/snmp/doc/src/snmp.xml | 34 +++++------- lib/snmp/doc/src/snmp_community_mib.xml | 67 ++++++++++++++++++----- lib/snmp/doc/src/snmp_framework_mib.xml | 26 ++++++++- lib/snmp/doc/src/snmp_target_mib.xml | 13 +++++ lib/snmp/doc/src/specs.xml | 3 + lib/snmp/src/agent/snmp_community_mib.erl | 39 ++++++++++++- lib/snmp/src/agent/snmp_framework_mib.erl | 11 +++- lib/snmp/src/agent/snmp_target_mib.erl | 8 ++- lib/snmp/src/app/snmp.erl | 6 +- 10 files changed, 175 insertions(+), 41 deletions(-) diff --git a/lib/snmp/doc/src/Makefile b/lib/snmp/doc/src/Makefile index 6d7be422e7..b8bf3f4500 100644 --- a/lib/snmp/doc/src/Makefile +++ b/lib/snmp/doc/src/Makefile @@ -57,7 +57,11 @@ XML_OUTPUT = \ # SPECS_FILES = $(XML_REF3_FILES:%.xml=$(SPECDIR)/specs_%.xml) SPECS_FILES = \ - $(SPECDIR)/specs_snmp.xml + $(SPECDIR)/specs_snmp.xml \ + $(SPECDIR)/specs_snmp_community_mib.xml \ + $(SPECDIR)/specs_snmp_framework_mib.xml \ + $(SPECDIR)/specs_snmp_target_mib.xml + TOP_SPECS_FILE = specs.xml NO_CHUNKS = diff --git a/lib/snmp/doc/src/snmp.xml b/lib/snmp/doc/src/snmp.xml index 9d153601c2..c1e40cce7d 100644 --- a/lib/snmp/doc/src/snmp.xml +++ b/lib/snmp/doc/src/snmp.xml @@ -133,16 +133,18 @@ </datatype> <datatype> - <name name="void"/> + <name name="algorithm"/> + <!-- <desc> <p> - The type is used when a functions return is to be ignored. + TBD </p> </desc> + --> </datatype> <datatype> - <name name="algorithm"/> + <name name="mib"/> <!-- <desc> <p> @@ -153,7 +155,7 @@ </datatype> <datatype> - <name name="mib"/> + <name name="mib_name"/> <!-- <desc> <p> @@ -163,22 +165,16 @@ --> </datatype> - </datatypes> + <datatype> + <name name="void"/> + <desc> + <p> + The type is used when a functions return is to be ignored. + </p> + </desc> + </datatype> - <section> - <title>Common Data Types</title> - <p>The following data-types are used in the functions below: </p> - <list type="bulleted"> - <item> - <p><c>datetime() = {date(), time()}</c></p> - <p>See <seeerl marker="stdlib:calendar">calendar</seeerl> - for more info.</p> - </item> - - </list> - - <marker id="config"></marker> - </section> + </datatypes> <funcs> <func> diff --git a/lib/snmp/doc/src/snmp_community_mib.xml b/lib/snmp/doc/src/snmp_community_mib.xml index 1885917724..a08a7c0f7a 100644 --- a/lib/snmp/doc/src/snmp_community_mib.xml +++ b/lib/snmp/doc/src/snmp_community_mib.xml @@ -43,6 +43,58 @@ <marker id="configure"></marker> </description> + <datatypes> + <datatype> + <name name="index"/> + <desc> + <p> + <c><![CDATA[SnmpAdminString (SIZE(1..32))]]></c> + </p> + </desc> + </datatype> + + <datatype> + <name name="name"/> + <desc> + <p> + <c><![CDATA[OCTET STRING (SIZE(1..64))]]></c> + </p> + </desc> + </datatype> + + <datatype> + <name name="security_name"/> + <desc> + <p> + <c><![CDATA[SnmpAdminString]]></c> + </p> + </desc> + </datatype> + + <datatype> + <name name="context_name"/> + <desc> + <p> + A human readable string. + </p> + <p> + <c><![CDATA[SnmpAdminString]]></c> + </p> + </desc> + </datatype> + + <datatype> + <name name="transport_tag"/> + <desc> + <p> + <c><![CDATA[SnmpTagValue]]></c> + </p> + </desc> + </datatype> + + </datatypes> + + <funcs> <func> <name since="">configure(ConfDir) -> void()</name> @@ -108,20 +160,9 @@ </func> <func> - <name since="">add_community(Idx, CommName, SecName, CtxName, TransportTag) -> Ret</name> - <name since="OTP R14B03">add_community(Idx, CommName, SecName, EngineId, CtxName, TransportTag) -> Ret</name> + <name name="add_community" arity="5" clause_i="1" since=""/> + <name name="add_community" arity="6" clause_i="1" since="OTP R14B03"/> <fsummary>Added one community</fsummary> - <type> - <v>Idx = string()</v> - <v>CommName = string()</v> - <v>SecName = string()</v> - <v>EngineId = string()</v> - <v>CtxName = string()</v> - <v>TransportTag = string()</v> - <v>Ret = {ok, Key} | {error, Reason}</v> - <v>Key = term()</v> - <v>Reason = term()</v> - </type> <desc> <p>Adds a community to the agent config. Equivalent to one line in the <c>community.conf</c> file.</p> diff --git a/lib/snmp/doc/src/snmp_framework_mib.xml b/lib/snmp/doc/src/snmp_framework_mib.xml index 305e202430..9e7792443d 100644 --- a/lib/snmp/doc/src/snmp_framework_mib.xml +++ b/lib/snmp/doc/src/snmp_framework_mib.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1999</year><year>2020</year> + <year>1999</year><year>2024</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -42,6 +42,30 @@ </p> <p>The configuration files are described in the SNMP User's Manual.</p> </description> + + + <datatypes> + <datatype> + <name name="admin_string"/> + <desc> + <p> + <c><![CDATA[OCTET STRING (SIZE(0..255))]]></c> + </p> + </desc> + </datatype> + + <datatype> + <name name="engine_id"/> + <desc> + <p> + <c><![CDATA[OCTET STRING (SIZE(5..32))]]></c> + </p> + </desc> + </datatype> + + </datatypes> + + <funcs> <func> <name since="">configure(ConfDir) -> void()</name> diff --git a/lib/snmp/doc/src/snmp_target_mib.xml b/lib/snmp/doc/src/snmp_target_mib.xml index 18382628a7..cc5ce0f3e7 100644 --- a/lib/snmp/doc/src/snmp_target_mib.xml +++ b/lib/snmp/doc/src/snmp_target_mib.xml @@ -47,6 +47,19 @@ <marker id="types"></marker> </description> + <datatypes> + <datatype> + <name name="tag_value"/> + <desc> + <p> + <c><![CDATA[OCTET STRING (SIZE (0..255))]]></c> + </p> + </desc> + </datatype> + + </datatypes> + + <section> <title>DATA TYPES</title> <p>See the <seeerl marker="snmpa_conf#types"> diff --git a/lib/snmp/doc/src/specs.xml b/lib/snmp/doc/src/specs.xml index bc617cea24..37006d7fed 100644 --- a/lib/snmp/doc/src/specs.xml +++ b/lib/snmp/doc/src/specs.xml @@ -1,4 +1,7 @@ <?xml version="1.0" encoding="utf-8" ?> <specs xmlns:xi="http://www.w3.org/2001/XInclude"> <xi:include href="../specs/specs_snmp.xml"/> + <xi:include href="../specs/specs_snmp_community_mib.xml"/> + <xi:include href="../specs/specs_snmp_framework_mib.xml"/> + <xi:include href="../specs/specs_snmp_target_mib.xml"/> </specs> diff --git a/lib/snmp/src/agent/snmp_community_mib.erl b/lib/snmp/src/agent/snmp_community_mib.erl index 4bd30632f5..b335928f96 100644 --- a/lib/snmp/src/agent/snmp_community_mib.erl +++ b/lib/snmp/src/agent/snmp_community_mib.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2019. All Rights Reserved. +%% Copyright Ericsson AB 1999-2024. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -29,6 +29,15 @@ -export([add_community/5, add_community/6, delete_community/1]). -export([check_community/1]). +-export_type([ + index/0, + name/0, + security_name/0, + context_name/0, + transport_tag/0 + ]). + + -include("snmpa_internal.hrl"). -include("SNMP-COMMUNITY-MIB.hrl"). -include("SNMP-TARGET-MIB.hrl"). @@ -44,6 +53,13 @@ -endif. +-type index() :: snmp_framework_mib:admin_string(). +-type name() :: string(). +-type security_name() :: snmp_framework_mib:admin_string(). +-type context_name() :: snmp_framework_mib:admin_string(). +-type transport_tag() :: snmp_target_mib:tag_value(). + + %%%----------------------------------------------------------------- %%% Implements the instrumentation functions and additional %%% functions for the SNMP-COMMUNITY-MIB. @@ -185,11 +201,32 @@ table_del_row(Tab, Key) -> snmpa_mib_lib:table_del_row(db(Tab), Key). +-spec add_community(Idx, CommName, SecName, CtxName, TransportTag) -> + {ok, Key} | {error, Reason} when + Idx :: index(), + CommName :: name(), + SecName :: security_name(), + CtxName :: context_name(), + TransportTag :: transport_tag(), + Key :: term(), + Reason :: term(). + %% FIXME: does not work with mnesia add_community(Idx, CommName, SecName, CtxName, TransportTag) -> Community = {Idx, CommName, SecName, CtxName, TransportTag}, do_add_community(Community). +-spec add_community(Idx, CommName, SecName, EngineId, CtxName, TransportTag) -> + {ok, Key} | {error, Reason} when + Idx :: index(), + CommName :: name(), + SecName :: security_name(), + EngineId :: snmp_framework_mib:engine_id(), + CtxName :: context_name(), + TransportTag :: transport_tag(), + Key :: term(), + Reason :: term(). + add_community(Idx, CommName, SecName, EngineId, CtxName, TransportTag) -> Community = {Idx, CommName, SecName, EngineId, CtxName, TransportTag}, do_add_community(Community). diff --git a/lib/snmp/src/agent/snmp_framework_mib.erl b/lib/snmp/src/agent/snmp_framework_mib.erl index 8d6e655a9d..9fc4bd8a7f 100644 --- a/lib/snmp/src/agent/snmp_framework_mib.erl +++ b/lib/snmp/src/agent/snmp_framework_mib.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2020. All Rights Reserved. +%% Copyright Ericsson AB 1999-2024. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -67,6 +67,15 @@ -export([add_context/1, delete_context/1]). -export([check_agent/2, check_context/1, order_agent/2]). +-export_type([ + admin_string/0, + engine_id/0 + ]). + + +-type admin_string() :: string(). +-type engine_id() :: string(). + %%----------------------------------------------------------------- %% Func: init/0 diff --git a/lib/snmp/src/agent/snmp_target_mib.erl b/lib/snmp/src/agent/snmp_target_mib.erl index 30a3f08749..08f43df3a2 100644 --- a/lib/snmp/src/agent/snmp_target_mib.erl +++ b/lib/snmp/src/agent/snmp_target_mib.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2019. All Rights Reserved. +%% Copyright Ericsson AB 1998-2024. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -32,6 +32,10 @@ -export([check_target_addr/1, check_target_params/1]). -export([default_domain/0]). +-export_type([ + tag_value/0 + ]). + -include_lib("snmp/include/snmp_types.hrl"). -include_lib("snmp/include/snmp_tables.hrl"). -include_lib("snmp/include/SNMP-TARGET-MIB.hrl"). @@ -44,6 +48,8 @@ -include("snmp_verbosity.hrl"). -include("snmpa_internal.hrl"). +-type tag_value() :: string(). + %% Column not accessible via SNMP - needed when the agent sends informs -define(snmpTargetAddrEngineId, 10). diff --git a/lib/snmp/src/app/snmp.erl b/lib/snmp/src/app/snmp.erl index 374f1cc029..5d8757863b 100644 --- a/lib/snmp/src/app/snmp.erl +++ b/lib/snmp/src/app/snmp.erl @@ -154,13 +154,13 @@ -type atl_type() :: read | write | read_write. -type verbosity() :: silence | info | log | debug | trace. --type engine_id() :: string(). +-type engine_id() :: snmp_framework_mib:engine_id(). -type tdomain() :: transportDomainUdpIpv4 | transportDomainUdpIpv6. --type community() :: string(). +-type community() :: snmp_community_mib:name(). -type mms() :: non_neg_integer(). -type version() :: v1 | v2 | v3. -type sec_model() :: any | v1 | v2c | usm. --type sec_name() :: string(). +-type sec_name() :: snmp_community_mib:security_name(). -type sec_level() :: noAuthNoPriv | authNoPriv | authPriv. -type oid() :: [non_neg_integer()]. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor