public TranslateOidInfo(string fileName, ListMibEnt mibList) { MibFile = fileName; _listMibParents = mibList; GetLastError = string.Empty; CurrentLine = string.Empty; }
private void GetObjIdentHeader(ListMibEnt mibListing, string[] data) { MibEnt mib = new MibEnt(); int last = data.Length - 2; mib.Title = data[0].Trim(); mib.Value = GetMibValue(data); mib.Parent = GetMibStringValue(data[last]); mibListing.Add(mib); }
public bool FoundMibEnt(ListMibEnt mibList, MibEnt mib) { bool bFound = false; foreach (MibEnt ent in mibList) { if (ent.Equals(mib)) { bFound = true; break; } } return(bFound); }
private void GenerateBase(ListMibEnt mibList) { for (int idx = 0; idx < _titles.Count(); idx++) { MibEnt ent = new MibEnt(); ent.Title = _titles[idx]; ent.Value = _titleValues[idx]; if (idx > 0) { ent.Parent = _titles[idx - 1]; } mibList.Add(ent); } }
public void CreateMibListing(ListMibEnt mibList) { FileStream fs = null; try { fs = new FileStream(MibFile, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); GenerateBase(mibList); while (sr.Peek() != -1) { string line = sr.ReadLine(); if (line.ToLower().Contains("object identifier") && line.Contains("::=")) { if (IsGenericMib(line)) { MibEnt mib = new MibEnt(); mib = ParseMibIdentifier(line); if (!FoundMibEnt(mibList, mib)) { mibList.Add(mib); } } else { ParseObjectIdent(mibList, line); } } } } catch (FileNotFoundException fe) { GetLastError = fe.JoinAllErrorMessages(); } catch (DirectoryNotFoundException fe) { GetLastError = fe.JoinAllErrorMessages(); } catch (IOException e) { GetLastError = e.JoinAllErrorMessages(); } finally { if (fs != null) { fs.Close(); } } }
private void ParseObjectIdent(ListMibEnt mibListing, string line) { string[] separators = { " ", "\t", "{", "}" }; string[] data = line.Split(separators, StringSplitOptions.RemoveEmptyEntries); string parent = GetStartingParent(data); int start = FindStartOfObjIdent(data); GetObjIdentHeader(mibListing, data); for (int idx = start; idx < data.Length - 1; idx++) { MibEnt mib = new MibEnt(); mib.Title = GetMibStringValue(data[idx]); mib.Value = GetMibValue(data[idx]); mib.Parent = parent; parent = mib.Title; mibListing.Add(mib); } }
public BuildOIDString(ListMibEnt listMibEnt) { _ParentMIB_Values = listMibEnt; }