public ISNMPRawEntryDTO BuildSNMPRawEntry(string OID, string RawValue, EnumSNMPOIDType DataType) { //Lazy initialization if (SNMPRawDataEntries == null) { SNMPRawDataEntries = new Dictionary <string, ISNMPRawEntryDTO>(); } ISNMPRawEntryDTO RawEntry = new SNMPRawEntryDTO(this, OID, RawValue, DataType); //In case of existing previous vale, override if (SNMPRawDataEntries.ContainsKey(OID)) { SNMPRawDataEntries[OID] = RawEntry; } else { SNMPRawDataEntries.Add(OID, RawEntry); } //We know data is fully ready OnChange?.Invoke(RawEntry, typeof(ISNMPRawEntryDTO)); return(RawEntry); }
public SNMPRawEntryDTO(ISNMPDeviceDataDTO regardingobj, string oid, string data, EnumSNMPOIDType datatype) { RegardingObject = regardingobj; OID = oid; ValueData = data; DataType = datatype; }
private bool SNMPDecodeData(SnmpV2Packet Result, Oid indexOid, Oid finalOid, bool InclusiveInterval, ISNMPDeviceDataDTO SNMPDeviceData) { bool nextEntry = true; if (Result != null && Result.Pdu.ErrorStatus == 0) { // Walk through returned variable bindings foreach (Vb ResBinding in Result.Pdu.VbList) { // Check that retrieved Oid is higher than the limit or is the last block of leafs if (ResBinding.Oid < finalOid || finalOid.IsRootOf(ResBinding.Oid) && InclusiveInterval) { //Check OID Value Type. If unknown we break loop and storage EnumSNMPOIDType OIDType = (EnumSNMPOIDType)Enum.Parse(typeof(EnumSNMPOIDType), SnmpConstants.GetTypeName(ResBinding.Value.Type)); if (OIDType != EnumSNMPOIDType.Unknown) { ISNMPRawEntryDTO SNMPRawData = SNMPDeviceData.BuildSNMPRawEntry(ResBinding.Oid.ToString(), ResBinding.Value.ToString(), OIDType); } else { nextEntry = false; break; } //Check if we have already drilled down all contents if (ResBinding.Value.Type != SnmpConstants.SMI_ENDOFMIBVIEW) { indexOid.Set(ResBinding.Oid); //If we use = operator, we are changing references! In that case, ref keyword is mandatory nextEntry = true; } } else { nextEntry = false; break; } } } else { //Console.WriteLine("Error in SNMP reply. Error {0} index {1}", Result.Pdu.ErrorStatus, Result.Pdu.ErrorIndex); } return(nextEntry); }