public void Walkv1v2cAsync(SNMPVersion version, IPAddress ipAddress, string community, string oid, WalkMode walkMode, SNMPOptions options) { Task.Run(() => { try { IList <Variable> results = new List <Variable>(); Messenger.Walk(version == SNMPVersion.v1 ? VersionCode.V1 : VersionCode.V2, new IPEndPoint(ipAddress, options.Port), new OctetString(community), new ObjectIdentifier(oid), results, options.Timeout, walkMode); foreach (Variable result in results) { OnReceived(new SNMPReceivedArgs(result.Id, result.Data)); } OnComplete(); } catch (Lextm.SharpSnmpLib.Messaging.TimeoutException) { OnTimeout(); } catch (ErrorException) { OnError(); } }); }
public void WalkV1V2CAsync(SNMPVersion version, IPAddress ipAddress, SecureString community, string oid, WalkMode walkMode) { Task.Run(() => { try { IList <Variable> results = new List <Variable>(); Messenger.Walk(version == SNMPVersion.V1 ? VersionCode.V1 : VersionCode.V2, new IPEndPoint(ipAddress, Port), new OctetString(SecureStringHelper.ConvertToString(community)), new ObjectIdentifier(oid), results, Timeout, walkMode); foreach (var result in results) { OnReceived(new SNMPReceivedArgs(result.Id, result.Data)); } OnComplete(); } catch (Lextm.SharpSnmpLib.Messaging.TimeoutException) { OnTimeoutReached(); } catch (ErrorException) { OnError(); } }); }
public void GetV1V2CAsync(SNMPVersion version, IPAddress ipAddress, string community, string oid, SNMPOptions options) { Task.Run(() => { try { foreach (var result in Messenger.Get(version == SNMPVersion.V1 ? VersionCode.V1 : VersionCode.V2, new IPEndPoint(ipAddress, options.Port), new OctetString(community), new List <Variable> { new Variable(new ObjectIdentifier(oid)) }, options.Timeout)) { OnReceived(new SNMPReceivedArgs(result.Id, result.Data)); } OnComplete(); } catch (Lextm.SharpSnmpLib.Messaging.TimeoutException) { OnTimeout(); } catch (ErrorException) { OnError(); } }); }
/// <summary> /// Reads an object from serialization infomration. /// </summary> /// <param name="info"></param> /// <param name="ctxt"></param> public DeviceConfiguration(SerializationInfo info, StreamingContext ctxt) { this.Name = (string)info.GetValue("Name", typeof(string)); this.Address = (string)info.GetValue("Address", typeof(string)); this.Port = (int)info.GetValue("Port", typeof(int)); this.Version = (SNMPVersion)info.GetValue("Version", typeof(SNMPVersion)); this.CommunityRO = (string)info.GetValue("CommunityRO", typeof(string)); this.CommunityRW = (string)info.GetValue("CommunityRW", typeof(string)); this.Username = (string)info.GetValue("Username", typeof(string)); this.AuthType = (V3AuthTypes)info.GetValue("AuthType", typeof(V3AuthTypes)); this.AuthPass = (string)info.GetValue("AuthPass", typeof(string)); this.PrivType = (V3PrivTypes)info.GetValue("PrivType", typeof(V3PrivTypes)); this.PrivPass = (string)info.GetValue("PrivPass", typeof(string)); }
public void Setv1v2cAsync(SNMPVersion version, IPAddress ipAddress, string communtiy, string oid, string data, SNMPOptions options) { Task.Run(() => { try { Messenger.Set(version == SNMPVersion.v1 ? VersionCode.V1 : VersionCode.V2, new IPEndPoint(ipAddress, options.Port), new OctetString(communtiy), new List <Variable> { new Variable(new ObjectIdentifier(oid), new OctetString(data)) }, options.Timeout); OnComplete(); } catch (Lextm.SharpSnmpLib.Messaging.TimeoutException) { OnTimeout(); } catch (ErrorException) { OnError(); } }); }
public void SetV1V2CAsync(SNMPVersion version, IPAddress ipAddress, SecureString communtiy, string oid, string data) { Task.Run(() => { try { Messenger.Set(version == SNMPVersion.V1 ? VersionCode.V1 : VersionCode.V2, new IPEndPoint(ipAddress, Port), new OctetString(SecureStringHelper.ConvertToString(communtiy)), new List <Variable> { new Variable(new ObjectIdentifier(oid), new OctetString(data)) }, Timeout); OnComplete(); } catch (Lextm.SharpSnmpLib.Messaging.TimeoutException) { OnTimeoutReached(); } catch (ErrorException) { OnError(); } }); }
public SNMPClient(string _ipAddress, int _readTimeOut, int _retryNumber, double _pollingtime, SNMPVersion Version = SNMPVersion.V1) : base(_ipAddress, _readTimeOut, _retryNumber, _pollingtime) { }