J. Ritchie CarrollGSF.Net: Added SNMP library.c5ac7fa6 years agoHistory
132 lines · 4.5 KB · C#
RawDownload
// REPORT message type.// Copyright (C) 2008-2010 Malcolm Crowe, Lex Li, and other contributors.// // Permission is hereby granted, free of charge, to any person obtaining a copy of this// software and associated documentation files (the "Software"), to deal in the Software// without restriction, including without limitation the rights to use, copy, modify, merge,// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons// to whom the Software is furnished to do so, subject to the following conditions:// // The above copyright notice and this permission notice shall be included in all copies or// substantial portions of the Software.// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER// DEALINGS IN THE SOFTWARE. /* * Created by SharpDevelop. * User: lextm * Date: 2008/8/3 * Time: 15:36 *  * To change this template use Tools | Options | Coding | Edit Standard Headers. */using System;using System.Globalization;using GSF.Net.Snmp.Security; namespace GSF.Net.Snmp.Messaging{    /// <summary>    /// REPORT message.    /// </summary>    public sealed class ReportMessage : ISnmpMessage    {        private readonly byte[] _bytes;         /// <summary>        /// Initializes a new instance of the <see cref="ReportMessage"/> class.        /// </summary>        /// <param name="version">The version code.</param>        /// <param name="header">The header.</param>        /// <param name="parameters">The security parameters.</param>        /// <param name="scope">The scope.</param>        /// <param name="privacy">The privacy provider.</param>        /// <param name="length">The length bytes.</param>        public ReportMessage(VersionCode version, Header header, SecurityParameters parameters, Scope scope, IPrivacyProvider privacy, byte[] length)        {            if (scope == null)            {                throw new ArgumentNullException(nameof(scope));            }             if (parameters == null)            {                throw new ArgumentNullException(nameof(parameters));            }             if (header == null)            {                throw new ArgumentNullException(nameof(header));            }             if (privacy == null)            {                throw new ArgumentNullException(nameof(privacy));            }             if (version != VersionCode.V3)            {                throw new ArgumentException("Only v3 is supported.", nameof(version));            }             Version = version;            Header = header;            Parameters = parameters;            Scope = scope;            Privacy = privacy;            Privacy.ComputeHash(Version, Header, Parameters, Scope);            _bytes = this.PackMessage(length).ToBytes();        }         /// <summary>        /// Gets the header.        /// </summary>        public Header Header { get; private set; }         /// <summary>        /// Security parameters.        /// </summary>        public SecurityParameters Parameters { get; private set; }         /// <summary>        /// Gets the scope.        /// </summary>        /// <value>The scope.</value>        public Scope Scope { get; private set; }         /// <summary>        /// Gets the version.        /// </summary>        /// <value>The version.</value>        public VersionCode Version { get; private set; }         /// <summary>        /// Converts to byte format.        /// </summary>        /// <returns></returns>        public byte[] ToBytes()        {            return _bytes;        }         /// <summary>        /// Gets the privacy provider.        /// </summary>        /// <value>The privacy provider.</value>        public IPrivacyProvider Privacy { get; private set; }         /// <summary>        /// Returns a <see cref="string"/> that represents this <see cref="ReportMessage"/>.        /// </summary>        /// <returns></returns>        public override string ToString()        {            return string.Format(CultureInfo.InvariantCulture, "REPORT request message: version: {0}; {1}; {2}", Version, Parameters.UserName, Scope.Pdu);        }    }}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t