public CharacterSet(string name, Mib mibEnum, string[] aliases, string preferredMimeName, Encoding e) { this.name = name; this.mibEnum = mibEnum; this.aliases = aliases; this.e = e; if (preferredMimeName != null) { bool preferredMimeNameFound = preferredMimeName.Equals(name, StringComparison.InvariantCultureIgnoreCase); if (!preferredMimeNameFound && aliases != null) { foreach (string alias in aliases) { if (preferredMimeName.Equals(alias, StringComparison.InvariantCultureIgnoreCase)) { preferredMimeNameFound = true; break; } } } if (preferredMimeNameFound) { this.preferredMimeName = preferredMimeName; } else { throw new System.Exception(); } } }
public void Prepare() { /** Variables de control */ Mib.Add(new SnmpStringObject(QueryOid, "preguntar-equipo")); Mib.Add(new SnmpStringObject(AnswerOid, "oid-equipo")); /** Variables de la tabla */ foreach (var item in equipments.MibObjects) { Mib.Add(item); } Mib.Sort(); /** Agregarlos al almacen del agente */ foreach (MibObject obj in Mib) { SnmpAgent.Store.Add(obj); } equipments.GlobalStatusLoad(); SnmpAgent.PduSetReceived += PduSetReceived_handler; NotifyReady?.Invoke(); }
public static string GetValue(Mib mib) { switch (mib) { case Mib.ClientApMacAddress: return("1.3.6.1.4.1.14179.2.1.4.1.4"); case Mib.ClientIpAddress: return("1.3.6.1.4.1.14179.2.1.4.1.2"); case Mib.ClientSsid: return("1.3.6.1.4.1.14179.2.1.4.1.7"); case Mib.ClientUsername: return("1.3.6.1.4.1.14179.2.1.4.1.3"); case Mib.ClientVlan: return("1.3.6.1.4.1.14179.2.1.4.1.29"); case Mib.ClientWlanInterface: return("1.3.6.1.4.1.14179.2.1.4.1.27"); case Mib.ClientMacAddress: default: return("1.3.6.1.4.1.14179.2.1.4.1.1"); } }
/// <summary> /// Initializes a new instance of the <see cref="MibSymbol"/> class /// with the specified name. The symbol will also be added to the MIB file. /// </summary> /// <param name="location">The MIB file location</param> /// <param name="mib">The mib name</param> /// <param name="name">The symbol name</param> public MibSymbol(FileLocation location, Mib mib, string name) { this.location = location; this.mib = mib; this.name = name; if (mib != null) { mib.AddSymbol(this); } }
public static string GetValue(Mib mib) { switch (mib) { case Mib.ClientApMacAddress: return("1.3.6.1.4.1.14179.2.1.4.1.4"); case Mib.ClientIpAddress: return("1.3.6.1.4.1.14179.2.1.4.1.2"); case Mib.ClientSsid: return("1.3.6.1.4.1.14179.2.1.4.1.7"); case Mib.ClientUsername: return("1.3.6.1.4.1.14179.2.1.4.1.3"); case Mib.ClientVlan: return("1.3.6.1.4.1.14179.2.1.4.1.29"); case Mib.ClientWlanInterface: return("1.3.6.1.4.1.14179.2.1.4.1.27"); case Mib.ApBaseRadioMacAddress: return("1.3.6.1.4.1.14179.2.2.1.1.1"); case Mib.ApName: return("1.3.6.1.4.1.14179.2.2.1.1.3"); case Mib.ApLocation: return("1.3.6.1.4.1.14179.2.2.1.1.4"); case Mib.ApModel: return("1.3.6.1.4.1.14179.2.2.1.1.16"); case Mib.ApSerialNumber: return("1.3.6.1.4.1.14179.2.2.1.1.17"); case Mib.ApIpAddress: return("1.3.6.1.4.1.14179.2.2.1.1.19"); case Mib.ApEthernetMacAddress: return("1.3.6.1.4.1.14179.2.2.1.1.33"); case Mib.ClientMacAddress: default: return("1.3.6.1.4.1.14179.2.1.4.1.1"); } }
public void Dispose() { //lock (locker) { /** Cerrar el Agente SNMP*/ SnmpAgent.Close(); Mib.Dispose(); /** OJO!!! Cerrar el Agente SIP */ //if (LocalAudioPlayer != -1) //{ // SipAgent.DestroyWavPlayer(LocalAudioPlayer); //} SipAgent.End(); LocalAudioPlayer = -1; /** Descargar Datos */ Unload(); } }
/// <summary> /// Validates an element type. This will check that the element /// is present in the MIB file. If it is not, a new symbol will be /// added to the MIB. /// </summary> /// <param name="symbol">The MIB symbol containing this type</param> /// <param name="log">The MIB Loader log</param> /// <param name="element">The MIB element type to check</param> /// <param name="pos">The MIB element position</param> /// <exception cref="MibException"> /// If an error was encountered during the validation /// </exception> private static void CheckElement( MibValueSymbol symbol, MibLoaderLog log, ElementType element, int pos) { Mib mib = symbol.Mib; MibSymbol elementSymbol; string name; MibType type; ObjectIdentifierValue value; elementSymbol = mib.GetSymbol(element.Name); if (elementSymbol == null) { if (element.Name != null) { name = pos + " '" + element.Name + "'"; } else { name = pos.ToString(); } string msg = "sequence element " + name + " is undefined " + "in MIB, a default symbol will be created"; log.AddWarning(symbol.Location, msg); name = element.Name; if (name == null) { name = symbol.Name + "." + pos; } type = new SnmpObjectType( element.Type, null, SnmpAccess.ReadOnly, SnmpStatus.CURRENT, "AUTOMATICALLY CREATED SYMBOL", null, new List <SnmpIndex>(), null); value = (ObjectIdentifierValue)symbol.Value; value = new ObjectIdentifierValue( symbol.Location, value, element.Name, pos); elementSymbol = new MibValueSymbol( symbol.Location, mib, name, type, value); elementSymbol.Initialize(log); } else if (elementSymbol is MibTypeSymbol) { if (element.Name != null) { name = pos + " '" + element.Name + "'"; } else { name = pos.ToString(); } throw new MibException( symbol.Location, "sequence element " + name + " does not refer to a value, but to a type"); } }
/// <summary> /// The main program function /// </summary> /// <param name="args">The array of program arguments</param> public static void Main(string[] args) { MibLoader loader = new MibLoader(); Mib mib = null; System.Collections.ArrayList queue = new System.Collections.ArrayList(); string file; int warnings = 0; int errors = 0; // Check command-line arguments if (args.Length < 1) { PrintHelp("No file(s) specified"); return; } foreach (string arg in args) { try { if (arg.Contains(":")) { queue.Add(new Uri(arg)); } else { if (Directory.Exists(arg)) { AddMibs(arg, queue); continue; } if (!File.Exists(arg)) { Console.Out.WriteLine("Warning: Skipping " + arg + ": file not found"); continue; } queue.Add(arg); } } catch (UriFormatException e) { System.Console.Out.WriteLine( "Warning: Skipping " + arg + ": " + e.Message); } } // Parse MIB files int i = 0; foreach (var src in queue) { Console.Out.Write(i); Console.Out.Write("/"); Console.Out.Write(queue.Count); Console.Out.Write(": Reading " + src + "... "); Console.Out.Flush(); try { loader.UnloadAll(); if (src is Uri uri) { loader.RemoveAllDirs(); mib = loader.Load(uri); } else { file = (string)src; if (!loader.HasDir(Directory.GetParent(file).FullName)) { loader.RemoveAllDirs(); loader.AddDir(Directory.GetParent(file).FullName); } using StreamReader sr = new StreamReader(file); mib = loader.Load(sr); } Console.Out.WriteLine("[OK]"); if (mib.Log.WarningCount > 0) { mib.Log.PrintTo(Console.Out); warnings++; } } catch (FileNotFoundException e) { Console.Out.WriteLine("[FAILED]"); PrintError(src.ToString(), e); errors++; } catch (IOException e) { Console.Out.WriteLine("[FAILED]"); PrintError(src.ToString(), e); errors++; } catch (MibLoaderException e) { Console.Out.WriteLine("[FAILED]"); e.Log.PrintTo(Console.Out); errors++; } i++; } // Print error count System.Console.Out.WriteLine(); Console.Out.WriteLine("Files processed: " + queue.Count); Console.Out.WriteLine(" with errors: " + errors); Console.Out.WriteLine(" with warnings: " + warnings); if (errors > 0) { Console.Error.WriteLine("Error: validation errors were encountered"); } Console.ReadLine(); // Return error count return; }
public CharacterSet(string name, Mib mibEnum) : this(name, mibEnum, null, null, null) { }
public CharacterSet(string name, Mib mibEnum, Encoding e) : this(name, mibEnum, null, null, e) { }
public CharacterSet(string name, Mib mibEnum, string[] aliases) : this(name, mibEnum, aliases, null, null) { }
public CharacterSet(string name, Mib mibEnum, string[] aliases, Encoding e) : this(name, mibEnum, aliases, null, e) { }
public CharacterSet(string name, Mib mibEnum, string[] aliases, string preferredMimeName) : this(name, mibEnum, aliases, preferredMimeName, null) { }