Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
7197-snmp-Types-and-specs-for-snmp_pdus-dec_mes...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 7197-snmp-Types-and-specs-for-snmp_pdus-dec_message-1.patch of Package erlang
From 98ade9ce4a30ea688d08dbb2fd2af599f92844a1 Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Mon, 15 Jan 2024 19:43:54 +0100 Subject: [PATCH 57/67] [snmp] Types and specs for snmp_pdus:dec_message/1 --- lib/snmp/doc/src/Makefile | 1 + lib/snmp/doc/src/snmp_pdus.xml | 38 +++++++++++++++++++++++---------- lib/snmp/doc/src/specs.xml | 1 + lib/snmp/src/misc/snmp_pdus.erl | 15 ++++++++++++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/lib/snmp/doc/src/Makefile b/lib/snmp/doc/src/Makefile index b6652ae7b0..4bba34d84b 100644 --- a/lib/snmp/doc/src/Makefile +++ b/lib/snmp/doc/src/Makefile @@ -64,6 +64,7 @@ SPECS_FILES = \ $(SPECDIR)/specs_snmp_target_mib.xml \ $(SPECDIR)/specs_snmp_generic.xml \ $(SPECDIR)/specs_snmp_index.xml \ + $(SPECDIR)/specs_snmp_pdus.xml \ $(SPECDIR)/specs_snmpa.xml TOP_SPECS_FILE = specs.xml diff --git a/lib/snmp/doc/src/snmp_pdus.xml b/lib/snmp/doc/src/snmp_pdus.xml index 120f5192a1..7fd571a433 100644 --- a/lib/snmp/doc/src/snmp_pdus.xml +++ b/lib/snmp/doc/src/snmp_pdus.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> - <year>1996</year><year>2020</year> + <year>1996</year><year>2024</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -53,23 +53,39 @@ own Net if process. </p> </description> + + + <datatypes> + <datatype> + <name name="message"/> + <desc> + <p> + The message is version dependent. + 'vsn_hdr' is either a community string (v1 and v2) or a 'v3_hdr' + record (v3). + 'data' is either a PDU (v1 and v2c) or a (possibly encrypted) + 'scopedPdu'. + </p> + </desc> + </datatype> + + </datatypes> + <funcs> <func> - <name since="">dec_message([byte()]) -> Message</name> + <name name="dec_message" arity="1" clause_i="1" since=""/> <fsummary>Decode an SNMP Message</fsummary> - <type> - <v>Message = #message</v> - </type> <desc> <p>Decodes a list of bytes into an SNMP Message. Note, if there - is a v3 message, the <c>msgSecurityParameters</c> are not - decoded. They must be explicitly decoded by a call to a - security model specific decoding function, - e.g. <c>dec_usm_security_parameters/1</c>. Also note, if - the <c>scopedPDU</c> is encrypted, the OCTET STRING encoded - <c>encryptedPDU</c> will be present in the <c>data</c> field.</p> + is a v3 message, the <c>msgSecurityParameters</c> are not + decoded. They must be explicitly decoded by a call to a + security model specific decoding function, + e.g. <c>dec_usm_security_parameters/1</c>. Also note, if + the <c>scopedPDU</c> is encrypted, the OCTET STRING encoded + <c>encryptedPDU</c> will be present in the <c>data</c> field.</p> </desc> </func> + <func> <name since="">dec_message_only([byte()]) -> Message</name> <fsummary>Decode an SNMP Message, but not the data part</fsummary> diff --git a/lib/snmp/doc/src/specs.xml b/lib/snmp/doc/src/specs.xml index 45036db0e4..052d9cf672 100644 --- a/lib/snmp/doc/src/specs.xml +++ b/lib/snmp/doc/src/specs.xml @@ -7,5 +7,6 @@ <xi:include href="../specs/specs_snmp_target_mib.xml"/> <xi:include href="../specs/specs_snmp_generic.xml"/> <xi:include href="../specs/specs_snmp_index.xml"/> + <xi:include href="../specs/specs_snmp_pdus.xml"/> <xi:include href="../specs/specs_snmpa.xml"/> </specs> diff --git a/lib/snmp/src/misc/snmp_pdus.erl b/lib/snmp/src/misc/snmp_pdus.erl index 1967c7078d..d413617b73 100644 --- a/lib/snmp/src/misc/snmp_pdus.erl +++ b/lib/snmp/src/misc/snmp_pdus.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-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. @@ -42,12 +42,25 @@ get_encoded_length/1, enc_value/2, dec_value/1]). +-export_type([ + message/0 + ]). + + +-type message() :: #message{}. + + %% -compile(export_all). %% Returns the number of octets required to encode Length. get_encoded_length(Length) -> length(elength(Length)). + +-spec dec_message(Bytes) -> Message when + Bytes :: [byte()], + Message :: message(). + dec_message([48 | Bytes]) -> Bytes2 = get_data_bytes(Bytes), case dec_snmp_version(Bytes2) of -- 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