private void AddToOidList() { ListOidEnt notFound = new ListOidEnt(); foreach (OidInfo oInfo in _listOidInfo) { bool bFound = false; foreach (OidEnt oid in _listOids) { if (oid.OidIndex.Contains(oInfo.OIDValue)) { bFound = true; // OID was not in MIB but provided from the HP Device if (oid.OidName.Equals(string.Empty)) { oid.OidName = oInfo.NameOid; oid.OidString = oInfo.OIDValue; oid.Usage = USAGES.eMcHpDevice; } else { switch (oid.Usage) { case USAGES.eMib: oid.Usage = USAGES.eMcMib; break; case USAGES.eHpDeviceMib: oid.Usage = USAGES.eAll; break; } } } } if (!bFound) { OidEnt temp = new OidEnt(); temp.OidName = oInfo.NameOid; temp.OidString = oInfo.OIDValue; temp.OidIndex = oInfo.SupportedIdxStr(); temp.OidIndexValue = oInfo.ExpectedValue; temp.Access = oInfo.Access(); temp.Syntax.Add(Enum <SNMP_DATATYPES> .Value(oInfo.DataType)); temp.Status = oInfo.Implementation; temp.Usage = USAGES.eMc; notFound.Add(temp); } } if (notFound.Count > 0) { foreach (OidEnt oid in notFound) { _listOids.Add(oid); } } }
private void AddNewOids(ListOidEnt listOidEnt) { int cnt = 0; foreach (OidEnt oid in listOidEnt) { if (!OidEntFound(oid)) { _listOids.Add(oid); cnt++; } } MessageBox.Show("New Additions: " + cnt.ToString()); }
private void BuildOidListing(string filePath) { TranslateOidInfo toi = new TranslateOidInfo(filePath, _listMibs); toi.CreateOidListing(); if (_listOids.Count == 0) { _listOids = toi.OidsListing; } else { AddNewOids(toi.OidsListing); } }
private void GetDeviceOidListing() { DeviceOids device = new DeviceOids(_password, txtIpAddr.Text, txtOidValue.Text); if (device.ValidateEngine()) { ListOidEnt tmpOidList = new ListOidEnt(); lblReleaseName.Text = device.ReleaseName; lblReleaseName.Refresh(); device.GetDeviceOidListings(); foreach (DeviceOidEnt dOid in device.ListDeviceOids) { bool bFound = false; foreach (OidEnt oidInfo in _listOids) { string temp = oidInfo.OidString + "."; if (dOid.OidString.Contains(temp)) { bFound = true; AddOidData(oidInfo, dOid, tmpOidList); } } if (!bFound) { OidEnt oid = new OidEnt(); oid.OidIndex = dOid.OidString; oid.OidIndexValue = dOid.OidValue; oid.Usage = USAGES.eHPDevice; tmpOidList.Add(oid); } } foreach (OidEnt oid in tmpOidList) { _listOids.Add(oid); } } else { MessageBox.Show(device.GetLastError); } }
private void AddOidData(OidEnt oidInfo, DeviceOidEnt dOid, ListOidEnt tmpOidList) { if (string.IsNullOrEmpty(oidInfo.OidIndex)) { oidInfo.OidIndex = dOid.OidString; oidInfo.OidIndexValue = dOid.OidValue; oidInfo.Usage = USAGES.eHpDeviceMib; } else { // same family but a different index, so making a copy and setting same OID with different index OidEnt oid = new OidEnt(oidInfo); oid.OidIndex = dOid.OidString; oid.OidIndexValue = dOid.OidValue; oidInfo.Usage = USAGES.eHpDeviceMib; oid.Usage = USAGES.eHpDeviceMib; tmpOidList.Add(oid); } }
private void CheckIfOidsBuiltCorrectly() { ListOidEnt listNotFound = new ListOidEnt(); foreach (OidEnt oidInfo in _listOids) { string oidValue = GetOidValue(oidInfo.Parent); if (oidValue.Contains(HP_OID)) { if (oidValue[0].Equals('.')) { oidValue = oidValue.Substring(1); } } else { oidValue = HP_OID + oidValue; } oidValue += "." + oidInfo.Value; // The parent values aren't building correctly if (!oidValue.Equals(oidInfo.OidString)) { OidEnt temp = new OidEnt(oidInfo); temp.OidIndex = oidValue; temp.OidIndexValue = string.Empty; temp.Usage = USAGES.eUnknown; listNotFound.Add(temp); } } if (listNotFound.Count > 0) { WriteFile wf = new WriteFile(listNotFound); wf.WritePartOInfoFile(); MessageBox.Show(listNotFound.Count.ToString() + " building of parent values not matching stated MIB OID."); } }
public void CreateOidListing() { OidsListing = new ListOidEnt(); FileStream fs = null; try { fs = new FileStream(MibFile, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); MovePointerToStart(sr); while (sr.Peek() != -1) { if (!string.IsNullOrEmpty(CurrentLine) && !CurrentLine.Contains("-- XREF:")) { SetOidType(CurrentLine); BuildOidObject(sr, CurrentLine); } else { CurrentLine = sr.ReadLine().Trim(); } } } catch (FileNotFoundException fe) { GetLastError = fe.JoinAllErrorMessages(); } catch (DirectoryNotFoundException fe) { GetLastError = fe.JoinAllErrorMessages(); } catch (IOException e) { GetLastError = e.JoinAllErrorMessages(); } finally { if (fs != null) { fs.Close(); } } }
public WriteFile(ListOidEnt listOids, string startDir = "") { ListOids = listOids; SaveDirectory = startDir; }