summaryrefslogtreecommitdiff
path: root/contrib/apps/LwipMibCompiler/SharpSnmpLib
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2024-10-16 08:10:14 -0600
committerTom Rini <[email protected]>2024-10-16 08:10:14 -0600
commitf3f86fd1fe0fb288356bff78f8a6fa2edf89e3fc (patch)
treef0a99ea87d92f63895a6d053e3185838ebecf2d0 /contrib/apps/LwipMibCompiler/SharpSnmpLib
Squashed 'lib/lwip/lwip/' content from commit 0a0452b2c39b
git-subtree-dir: lib/lwip/lwip git-subtree-split: 0a0452b2c39bdd91e252aef045c115f88f6ca773
Diffstat (limited to 'contrib/apps/LwipMibCompiler/SharpSnmpLib')
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/DisplayHint.cs84
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/AgentCapabilities.cs29
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/EntityBase.cs46
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/IEntity.cs62
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ModuleCompliance.cs23
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ModuleIdentity.cs10
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/NotificationGroup.cs22
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/NotificationType.cs11
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectGroup.cs22
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectIdentity.cs21
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectType.cs336
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/OidValueAssignment.cs30
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Exports.cs56
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/IDeclaration.cs18
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/IElement.cs35
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/ITypeReferrer.cs10
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Imports.cs81
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/ImportsFrom.cs60
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/TrapType.cs48
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/BaseType.cs54
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/BitsType.cs26
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Choice.cs35
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/ITypeAssignment.cs6
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/IntegerType.cs117
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/IpAddressType.cs21
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Macro.cs34
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/ObjectIdentifierType.cs11
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/OctetStringType.cs31
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/OpaqueType.cs11
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Sequence.cs46
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/SequenceOf.cs23
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/TextualConvention.cs238
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/TypeAssignment.cs147
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/UnsignedType.cs103
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/IModule.cs81
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ISymbolEnumerator.cs9
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Lexer.cs581
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MaxAccess.cs17
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibDocument.cs57
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibException.cs113
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibModule.cs294
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibResolver.cs97
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTree.cs130
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTreeNode.cs112
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTypesResolver.cs216
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ObjectIdentifier.cs54
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Status.cs17
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Symbol.cs357
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/SymbolList.cs146
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueMap.cs103
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueRange.cs76
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/AssemblyInfo.cs61
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/Resources.Designer.cs63
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/Resources.resx120
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/SharpSnmpLib.Mib.csproj140
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/license.txt458
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/readme.txt1
-rw-r--r--contrib/apps/LwipMibCompiler/SharpSnmpLib/sharpsnmplib.snkbin0 -> 596 bytes
58 files changed, 5210 insertions, 0 deletions
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/DisplayHint.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/DisplayHint.cs
new file mode 100644
index 00000000000..831f1177a37
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/DisplayHint.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Collections;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public class DisplayHint
+ {
+ private enum NumType {
+ dec,
+ hex,
+ oct,
+ bin,
+ str
+ }
+
+ private string _str;
+ private NumType _type;
+ private int _decimalPoints = 0;
+
+ public DisplayHint(string str)
+ {
+ _str = str;
+ if (str.StartsWith("d"))
+ {
+ _type = NumType.dec;
+ if (str.StartsWith("d-"))
+ {
+ _decimalPoints = Convert.ToInt32(str.Substring(2));
+ }
+ }
+ else if (str.StartsWith("o"))
+ {
+ _type = NumType.oct;
+ }
+ else if (str.StartsWith("h"))
+ {
+ _type = NumType.hex;
+ }
+ else if (str.StartsWith("b"))
+ {
+ _type = NumType.bin;
+ }
+ else
+ {
+ _type = NumType.str;
+ foreach (char c in str)
+ {
+
+ }
+ }
+
+ }
+
+ public override string ToString()
+ {
+ return _str;
+ }
+
+ internal object Decode(int i)
+ {
+ switch (_type)
+ {
+ case NumType.dec:
+ if (_decimalPoints == 0)
+ {
+ return i;
+ }
+ else
+ {
+ return i / Math.Pow(10.0, _decimalPoints);
+ }
+ case NumType.hex:
+ return System.Convert.ToString(i, 16);
+ case NumType.oct:
+ return System.Convert.ToString(i, 8);
+ case NumType.bin:
+ return System.Convert.ToString(i, 2);
+ default:
+ return null;
+ }
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/AgentCapabilities.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/AgentCapabilities.cs
new file mode 100644
index 00000000000..2f79cce5980
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/AgentCapabilities.cs
@@ -0,0 +1,29 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/31
+ * Time: 13:18
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ /// <summary>
+ /// The AGENT-CAPABILITIES construct is used to specify implementation characteristics of an SNMP agent sub-system with respect to object types and events.
+ /// </summary>
+ public sealed class AgentCapabilities : EntityBase
+ {
+ /// <summary>
+ /// Creates an <see cref="AgentCapabilities"/> instance.
+ /// </summary>
+ /// <param name="module"></param>
+ /// <param name="header"></param>
+ /// <param name="lexer"></param>
+ public AgentCapabilities(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ }
+
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/EntityBase.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/EntityBase.cs
new file mode 100644
index 00000000000..6da9b18cc78
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/EntityBase.cs
@@ -0,0 +1,46 @@
+using System;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ public abstract class EntityBase: IEntity
+ {
+ private readonly IModule _module;
+ private string _parent;
+ private readonly uint _value;
+ private readonly string _name;
+
+ public EntityBase(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ {
+ _module = module;
+ _name = preAssignSymbols[0].ToString();
+
+ Lexer.ParseOidValue(symbols, out _parent, out _value);
+ }
+
+ public IModule Module
+ {
+ get { return _module; }
+ }
+
+ public string Parent
+ {
+ get { return _parent; }
+ set { _parent = value; }
+ }
+
+ public uint Value
+ {
+ get { return _value; }
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ public virtual string Description
+ {
+ get { return string.Empty; }
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/IEntity.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/IEntity.cs
new file mode 100644
index 00000000000..7360a4727ca
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/IEntity.cs
@@ -0,0 +1,62 @@
+// Entity interface.
+// Copyright (C) 2008-2010 Malcolm Crowe, Lex Li, and other contributors.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/19
+ * Time: 20:10
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ /// <summary>
+ /// Basic interface for all elements building up the MIB tree, thus having an OID as value.
+ /// </summary>
+ public interface IEntity : IDeclaration
+ {
+ /// <summary>
+ /// Parent name.
+ /// </summary>
+ string Parent
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Value.
+ /// </summary>
+ uint Value
+ {
+ get;
+ }
+
+ /// <summary>
+ /// Gets the description.
+ /// </summary>
+ /// <value>The description.</value>
+ string Description
+ {
+ get;
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ModuleCompliance.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ModuleCompliance.cs
new file mode 100644
index 00000000000..008c354584a
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ModuleCompliance.cs
@@ -0,0 +1,23 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/21
+ * Time: 19:35
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ /// <summary>
+ /// Description of ModuleComplianceNode.
+ /// </summary>
+ public sealed class ModuleCompliance : EntityBase
+ {
+ public ModuleCompliance(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ }
+
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ModuleIdentity.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ModuleIdentity.cs
new file mode 100644
index 00000000000..6de28ce6991
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ModuleIdentity.cs
@@ -0,0 +1,10 @@
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ public sealed class ModuleIdentity : EntityBase
+ {
+ public ModuleIdentity(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/NotificationGroup.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/NotificationGroup.cs
new file mode 100644
index 00000000000..27d3e4ce4fe
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/NotificationGroup.cs
@@ -0,0 +1,22 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/21
+ * Time: 19:34
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ /// <summary>
+ /// Description of NotificationGroupNode.
+ /// </summary>
+ public sealed class NotificationGroup : EntityBase
+ {
+ public NotificationGroup(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/NotificationType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/NotificationType.cs
new file mode 100644
index 00000000000..7386e21786e
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/NotificationType.cs
@@ -0,0 +1,11 @@
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ public sealed class NotificationType : EntityBase
+ {
+ public NotificationType(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectGroup.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectGroup.cs
new file mode 100644
index 00000000000..d846cdbb88c
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectGroup.cs
@@ -0,0 +1,22 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/21
+ * Time: 19:27
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ /// <summary>
+ /// Description of ObjectGroupNode.
+ /// </summary>
+ public sealed class ObjectGroup : EntityBase
+ {
+ public ObjectGroup(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectIdentity.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectIdentity.cs
new file mode 100644
index 00000000000..9c1e084807e
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectIdentity.cs
@@ -0,0 +1,21 @@
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ /// <summary>
+ /// Object identifier node.
+ /// </summary>
+ public sealed class ObjectIdentity : EntityBase
+ {
+
+ /// <summary>
+ /// Creates a <see cref="ObjectIdentity"/>.
+ /// </summary>
+ /// <param name="module">Module name</param>
+ /// <param name="header">Header</param>
+ /// <param name="lexer">Lexer</param>
+ public ObjectIdentity(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectType.cs
new file mode 100644
index 00000000000..3a8b567a4bb
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/ObjectType.cs
@@ -0,0 +1,336 @@
+using System;
+using System.Collections.Generic;
+using Lextm.SharpSnmpLib.Mib.Elements.Types;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ public sealed class ObjectType : EntityBase, ITypeReferrer
+ {
+ private ITypeAssignment _syntax;
+ private string _units;
+ private MaxAccess _access;
+ private Status _status;
+ private string _description;
+ private string _reference;
+ private IList<string> _indices;
+ private string _augments;
+ private string _defVal;
+
+ public ObjectType(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ ParseProperties(preAssignSymbols);
+ }
+
+ private void ParseProperties(SymbolList header)
+ {
+ ISymbolEnumerator headerSymbols = header.GetSymbolEnumerator();
+ Symbol temp = headerSymbols.NextNonEOLSymbol();
+
+ // Skip name
+ temp = headerSymbols.NextNonEOLSymbol();
+ temp.Expect(Symbol.ObjectType);
+
+ _syntax = ParseSyntax (Module, headerSymbols);
+ _units = ParseUnits (headerSymbols);
+ _access = ParseAccess (headerSymbols);
+ _status = ParseStatus (headerSymbols);
+ _description = ParseDescription (headerSymbols);
+ _reference = ParseReference (headerSymbols);
+ _indices = ParseIndices (headerSymbols);
+ _augments = ParseAugments (headerSymbols);
+ _defVal = ParseDefVal (headerSymbols);
+ }
+
+ private static string ParseAugments(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.Augments)
+ {
+ string augment = null;
+
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.OpenBracket);
+
+ current = symbols.NextNonEOLSymbol();
+ augment = current.ToString();
+
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.CloseBracket);
+
+ return augment;
+ }
+ else if (current != null)
+ {
+ symbols.PutBack(current);
+ }
+
+ return null;
+ }
+
+ private static string ParseDefVal(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.DefVal)
+ {
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.OpenBracket);
+
+ string defVal = null;
+ current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.OpenBracket)
+ {
+ int depth = 1;
+ // TODO: decode this.
+ while (depth > 0)
+ {
+ current = symbols.NextNonEOLSymbol();
+ if (current == Symbol.OpenBracket)
+ {
+ depth++;
+ }
+ else if (current == Symbol.CloseBracket)
+ {
+ depth--;
+ }
+ }
+ }
+ else
+ {
+ defVal = current.ToString();
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.CloseBracket);
+ }
+
+ return defVal;
+ }
+ else if (current != null)
+ {
+ symbols.PutBack(current);
+ }
+
+ return null;
+ }
+
+ private static IList<string> ParseIndices(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.Index)
+ {
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.OpenBracket);
+
+ List<string> indices = new List<string>();
+
+ while (current != Symbol.CloseBracket)
+ {
+ current = symbols.NextNonEOLSymbol();
+
+ bool lastIndex = false;
+ if (current == Symbol.Implied)
+ {
+ current = symbols.NextNonEOLSymbol();
+ lastIndex = true; // 'IMPLIED' may only be used for last index
+ }
+
+ current.Assert((current != Symbol.Comma) && (current != Symbol.CloseBracket), "Expected index name but found symbol!");
+ indices.Add(current.ToString());
+
+ current = symbols.NextNonEOLSymbol();
+ if (lastIndex)
+ {
+ current.Expect(Symbol.CloseBracket);
+ }
+ else
+ {
+ current.Expect(Symbol.Comma, Symbol.CloseBracket);
+ }
+ }
+
+ return indices;
+ }
+ else if (current != null)
+ {
+ symbols.PutBack(current);
+ }
+
+ return null;
+ }
+
+ private static string ParseReference(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.Reference)
+ {
+ return symbols.NextNonEOLSymbol().ToString();
+ }
+ else if (current != null)
+ {
+ symbols.PutBack(current);
+ }
+
+ return null;
+ }
+
+ private static string ParseDescription(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.Description)
+ {
+ return symbols.NextNonEOLSymbol().ToString().Trim(new char[] { '"' });
+ }
+ else if (current != null)
+ {
+ symbols.PutBack(current);
+ }
+
+ return null;
+ }
+
+ private static Status ParseStatus(ISymbolEnumerator symbols)
+ {
+ Status status = Status.obsolete;
+
+ Symbol current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.Status);
+
+ current = symbols.NextNonEOLSymbol();
+ try
+ {
+ status = (Status)Enum.Parse(typeof(Status), current.ToString());
+ }
+ catch (ArgumentException)
+ {
+ current.Assert(false, "Invalid/Unknown status");
+ }
+
+ return status;
+ }
+
+ private static MaxAccess ParseAccess(ISymbolEnumerator symbols)
+ {
+ MaxAccess access = MaxAccess.notAccessible;
+
+ Symbol current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.MaxAccess, Symbol.Access);
+
+ current = symbols.NextNonEOLSymbol();
+ switch (current.ToString())
+ {
+ case "not-accessible":
+ access = MaxAccess.notAccessible;
+ break;
+ case "accessible-for-notify":
+ access = MaxAccess.accessibleForNotify;
+ break;
+ case "read-only":
+ access = MaxAccess.readOnly;
+ break;
+ case "read-write":
+ access = MaxAccess.readWrite;
+ break;
+ case "read-create":
+ access = MaxAccess.readCreate;
+ break;
+ case "write-only":
+ access = MaxAccess.readWrite;
+ break;
+ default:
+ current.Assert(false, "Invalid/Unknown access");
+ break;
+ }
+
+ return access;
+ }
+
+ private static string ParseUnits(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.Units)
+ {
+ return symbols.NextNonEOLSymbol().ToString();
+ }
+ else if (current != null)
+ {
+ symbols.PutBack(current);
+ }
+
+ return null;
+ }
+
+ private static ITypeAssignment ParseSyntax(IModule module, ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.Syntax);
+
+ return Lexer.ParseBasicTypeDef(module, String.Empty, symbols, isMacroSyntax: true);
+ }
+
+ private static bool IsProperty(Symbol sym)
+ {
+ string s = sym.ToString();
+ return s == "SYNTAX" || s == "MAX-ACCESS" || s == "STATUS" || s == "DESCRIPTION";
+ }
+
+ public ITypeAssignment Syntax
+ {
+ get { return _syntax; }
+ internal set { _syntax = value; }
+ }
+
+ public override string Description
+ {
+ get { return _description; }
+ }
+
+ public MaxAccess Access
+ {
+ get { return _access; }
+ }
+
+ public IList<string> Indices
+ {
+ get { return _indices; }
+ }
+
+ public string Augments
+ {
+ get { return _augments; }
+ }
+
+ #region ITypeReferrer Member
+
+ public ITypeAssignment ReferredType
+ {
+ get { return _syntax; }
+ set { _syntax = value; }
+ }
+
+ public ITypeAssignment BaseType
+ {
+ get
+ {
+ ITypeReferrer tr = this;
+ ITypeAssignment result = null;
+
+ while ((tr != null) && (tr.ReferredType != null))
+ {
+ result = tr.ReferredType;
+ tr = tr.ReferredType as ITypeReferrer;
+ }
+
+ return result;
+ }
+ }
+
+ #endregion
+
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/OidValueAssignment.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/OidValueAssignment.cs
new file mode 100644
index 00000000000..3c659407b8c
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Entities/OidValueAssignment.cs
@@ -0,0 +1,30 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/17
+ * Time: 20:49
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Entities
+{
+ /// <summary>
+ /// Object identifier node.
+ /// </summary>
+ public sealed class OidValueAssignment : EntityBase
+ {
+ /// <summary>
+ /// Creates a <see cref="OidValueAssignment"/>.
+ /// </summary>
+ /// <param name="module">Module</param>
+ /// <param name="name">Name</param>
+ /// <param name="lexer">Lexer</param>
+ public OidValueAssignment(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ : base(module, preAssignSymbols, symbols)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Exports.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Exports.cs
new file mode 100644
index 00000000000..c1e66e322d1
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Exports.cs
@@ -0,0 +1,56 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/6/7
+ * Time: 17:34
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements
+{
+ /// <summary>
+ /// Description of Exports.
+ /// </summary>
+ public sealed class Exports: IElement
+ {
+ private IModule _module;
+ private readonly IList<string> _types = new List<string>();
+
+ public Exports(IModule module, ISymbolEnumerator s)
+ {
+ _module = module;
+
+ Symbol previous = null;
+ Symbol current;
+ do
+ {
+ current = s.NextSymbol();
+
+ if (current == Symbol.EOL)
+ {
+ continue;
+ }
+ else if (((current == Symbol.Comma) || (current == Symbol.Semicolon)) && (previous != null))
+ {
+ previous.AssertIsValidIdentifier();
+ _types.Add(previous.ToString());
+ }
+
+ previous = current;
+ }
+ while (current != Symbol.Semicolon);
+ }
+
+ #region IElement Member
+
+ public IModule Module
+ {
+ get { return _module; }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/IDeclaration.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/IDeclaration.cs
new file mode 100644
index 00000000000..0958ac6153b
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/IDeclaration.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements
+{
+ public interface IDeclaration: IElement
+ {
+ /// <summary>
+ /// Name.
+ /// </summary>
+ string Name
+ {
+ get;
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/IElement.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/IElement.cs
new file mode 100644
index 00000000000..e2db7fd3a51
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/IElement.cs
@@ -0,0 +1,35 @@
+// Construct interface.
+// Copyright (C) 2008-2010 Malcolm Crowe, Lex Li, and other contributors.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+namespace Lextm.SharpSnmpLib.Mib.Elements
+{
+ /// <summary>
+ /// Construct interface.
+ /// </summary>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+ public interface IElement
+ {
+ /// <summary>
+ /// Containing module.
+ /// </summary>
+ IModule Module
+ {
+ get;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/ITypeReferrer.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/ITypeReferrer.cs
new file mode 100644
index 00000000000..f0f57056d4c
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/ITypeReferrer.cs
@@ -0,0 +1,10 @@
+using Lextm.SharpSnmpLib.Mib.Elements.Types;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements
+{
+ public interface ITypeReferrer
+ {
+ ITypeAssignment ReferredType { get; set; }
+ ITypeAssignment BaseType { get; }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Imports.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Imports.cs
new file mode 100644
index 00000000000..3a4ec6ecb69
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Imports.cs
@@ -0,0 +1,81 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/31
+ * Time: 12:07
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements
+{
+ /// <summary>
+ /// The IMPORTS construct is used to specify items used in the current MIB module which are defined in another MIB module or ASN.1 module.
+ /// </summary>
+ public sealed class Imports : List<ImportsFrom>, IElement
+ {
+ private IModule _module;
+
+ /// <summary>
+ /// Creates an <see cref="Imports"/> instance.
+ /// </summary>
+ /// <param name="lexer"></param>
+ public Imports(IModule module, ISymbolEnumerator symbols)
+ {
+ _module = module;
+
+ Symbol current;
+ while ((current = symbols.NextSymbol()) != Symbol.Semicolon)
+ {
+ if (current == Symbol.EOL)
+ {
+ continue;
+ }
+
+ ImportsFrom imports = new ImportsFrom(current, symbols);
+
+ this.Add(imports);
+ }
+ }
+
+ public IList<string> Dependents
+ {
+ get
+ {
+ List<string> result = new List<string>();
+
+ foreach (ImportsFrom import in this)
+ {
+ result.Add(import.Module);
+ }
+
+ return result;
+ }
+ }
+
+ public ImportsFrom GetImportFromType(string type)
+ {
+ foreach (ImportsFrom import in this)
+ {
+ if (import.Types.Contains(type))
+ {
+ return import;
+ }
+ }
+
+ return null;
+ }
+
+ #region IElement Member
+
+ public IModule Module
+ {
+ get { return _module; }
+ }
+
+ #endregion
+
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/ImportsFrom.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/ImportsFrom.cs
new file mode 100644
index 00000000000..cd5154bd72c
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/ImportsFrom.cs
@@ -0,0 +1,60 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/31
+ * Time: 12:07
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements
+{
+ public sealed class ImportsFrom
+ {
+ private readonly string _module;
+ private readonly List<string> _types = new List<string>();
+
+ public ImportsFrom(Symbol last, ISymbolEnumerator symbols)
+ {
+ Symbol previous = last;
+ Symbol current;
+ while ((current = symbols.NextSymbol()) != Symbol.From)
+ {
+ if (current == Symbol.EOL)
+ {
+ continue;
+ }
+
+ if (current == Symbol.Comma)
+ {
+ previous.AssertIsValidIdentifier();
+ _types.Add(previous.ToString());
+ }
+
+ previous = current;
+ }
+
+ previous.AssertIsValidIdentifier();
+ _types.Add(previous.ToString());
+
+ _module = symbols.NextSymbol().ToString().ToUpperInvariant(); // module names are uppercase
+ }
+
+ public string Module
+ {
+ get { return _module; }
+ }
+
+ public IList<string> Types
+ {
+ get { return _types; }
+ }
+
+ public override string ToString()
+ {
+ return string.Join(", ", _types.ToArray()) + " FROM " + _module;
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/TrapType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/TrapType.cs
new file mode 100644
index 00000000000..9c5ca4578cd
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/TrapType.cs
@@ -0,0 +1,48 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/31
+ * Time: 12:20
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+namespace Lextm.SharpSnmpLib.Mib.Elements
+{
+ public sealed class TrapType : IDeclaration
+ {
+ private readonly IModule _module;
+ private readonly string _name;
+ private readonly int _value;
+
+ public TrapType(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ {
+ _module = module;
+ _name = preAssignSymbols[0].ToString();
+
+ Symbol valueSymbol = symbols.NextNonEOLSymbol();
+
+ bool succeeded = int.TryParse(valueSymbol.ToString(), out _value);
+ valueSymbol.Assert(succeeded, "not a decimal");
+ }
+
+ public int Value
+ {
+ get { return _value; }
+ }
+
+ #region IDeclaration Member
+
+ public IModule Module
+ {
+ get { return _module; }
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/BaseType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/BaseType.cs
new file mode 100644
index 00000000000..a4412812944
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/BaseType.cs
@@ -0,0 +1,54 @@
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public abstract class BaseType : ITypeAssignment
+ {
+ private IModule _module;
+ private string _name;
+
+ protected BaseType(IModule module, string name)
+ {
+ _module = module;
+ _name = name;
+ }
+
+ public virtual IModule Module
+ {
+ // differentiate between:
+ // FddiTimeNano ::= INTEGER (0..2147483647)
+ // which is an IntegerType which appears under Types in a MibModule and therefore has a name and module
+ // and
+ // SYNTAX INTEGER (0..2147483647)
+ // which is also an IntegerType but not defined as a separate type and therefore has NO name and NO module
+ get
+ {
+ if (!string.IsNullOrEmpty(_name))
+ {
+ return _module;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ protected set { _module = value; }
+ }
+
+ public virtual string Name
+ {
+ get
+ {
+ if (!string.IsNullOrEmpty(_name))
+ {
+ return _name;
+ }
+ else
+ {
+ return "{ Implicit Base Type }";
+ }
+ }
+ protected set { _name = value; }
+ }
+
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/BitsType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/BitsType.cs
new file mode 100644
index 00000000000..a64c8dbeb9b
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/BitsType.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public class BitsType : BaseType
+ {
+ private ValueMap _map;
+
+ public BitsType(IModule module, string name, ISymbolEnumerator symbols)
+ : base(module, name)
+ {
+ _map = Lexer.DecodeEnumerations(symbols);
+ }
+
+ public ValueMap Map
+ {
+ get { return _map; }
+ }
+
+ public string this[int value]
+ {
+ get { return _map[value]; }
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Choice.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Choice.cs
new file mode 100644
index 00000000000..c66d1f3f183
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Choice.cs
@@ -0,0 +1,35 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/31
+ * Time: 11:39
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ /// <summary>
+ /// The CHOICE type represents a list of alternatives..
+ /// </summary>
+ public sealed class Choice : BaseType
+ {
+ /// <summary>
+ /// Creates a <see cref="Choice"/> instance.
+ /// </summary>
+ /// <param name="module"></param>
+ /// <param name="name"></param>
+ /// <param name="lexer"></param>
+ public Choice(IModule module, string name, ISymbolEnumerator symbols)
+ : base(module, name)
+ {
+ while (symbols.NextNonEOLSymbol() != Symbol.OpenBracket)
+ {
+ }
+
+ while (symbols.NextNonEOLSymbol() != Symbol.CloseBracket)
+ {
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/ITypeAssignment.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/ITypeAssignment.cs
new file mode 100644
index 00000000000..e962f9df92f
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/ITypeAssignment.cs
@@ -0,0 +1,6 @@
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public interface ITypeAssignment : IDeclaration
+ {
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/IntegerType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/IntegerType.cs
new file mode 100644
index 00000000000..4841ad51d53
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/IntegerType.cs
@@ -0,0 +1,117 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/7/25
+ * Time: 20:41
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ /// <summary>
+ /// The INTEGER type represents a list of alternatives, or a range of numbers..
+ /// Includes Integer32 as it's indistinguishable from INTEGER.
+ /// </summary>
+ /**
+ * As this type is used for Integer32 as well as INTEGER it incorrectly
+ * allows enumeration sub-typing of Integer32. This is ok as currently we
+ * do not care about detecting incorrect MIBs and this doesn't block the
+ * decoding of correct MIBs.
+ */
+ public sealed class IntegerType : BaseType
+ {
+ public enum Types
+ {
+ Integer,
+ Integer32
+ }
+
+ private Types _type;
+ private bool _isEnumeration;
+ private ValueMap _map;
+ private ValueRanges _ranges;
+
+ /// <summary>
+ /// Creates an <see cref="IntegerType"/> instance.
+ /// </summary>
+ /// <param name="module"></param>
+ /// <param name="name"></param>
+ /// <param name="enumerator"></param>
+ public IntegerType(IModule module, string name, Symbol type, ISymbolEnumerator symbols)
+ : base (module, name)
+ {
+ Types? t = GetExactType(type);
+ type.Assert(t.HasValue, "Unknown symbol for unsigned type!");
+ _type = t.Value;
+
+ _isEnumeration = false;
+
+ Symbol current = symbols.NextNonEOLSymbol();
+ if (current == Symbol.OpenBracket)
+ {
+ _isEnumeration = true;
+ symbols.PutBack(current);
+ _map = Lexer.DecodeEnumerations(symbols);
+ }
+ else if (current == Symbol.OpenParentheses)
+ {
+ symbols.PutBack(current);
+ _ranges = Lexer.DecodeRanges(symbols);
+ current.Assert(!_ranges.IsSizeDeclaration, "SIZE keyword is not allowed for ranges of integer types!");
+ }
+ else
+ {
+ symbols.PutBack(current);
+ }
+ }
+
+ public Types Type
+ {
+ get { return _type; }
+ }
+
+ public ValueRanges Ranges
+ {
+ get { return _ranges; }
+ }
+
+ public bool IsEnumeration
+ {
+ get
+ {
+ return _isEnumeration;
+ }
+ }
+
+ public ValueMap Enumeration
+ {
+ get { return _isEnumeration ? _map : null; }
+ }
+
+ internal static Types? GetExactType(Symbol symbol)
+ {
+ if (symbol == Symbol.Integer)
+ {
+ // represents the ASN.1 builtin INTEGER type:
+ // may be represent any arbitrary (signed/unsigned) integer (in theory may have any size)
+ return Types.Integer;
+ }
+ else if (symbol == Symbol.Integer32)
+ {
+ // Integer32 ::= INTEGER (-2147483648..2147483647) // from SNMPv2-SMI
+ return Types.Integer32;
+ }
+
+ return null;
+ }
+
+ internal static bool IsIntegerType(Symbol symbol)
+ {
+ return GetExactType(symbol).HasValue;
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/IpAddressType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/IpAddressType.cs
new file mode 100644
index 00000000000..84d78d66869
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/IpAddressType.cs
@@ -0,0 +1,21 @@
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public class IpAddressType : OctetStringType
+ {
+ public IpAddressType(IModule module, string name, ISymbolEnumerator symbols)
+ : base(module, name, symbols)
+ {
+ if (this.Size.Count != 0)
+ {
+ throw new MibException("Size definition not allowed for IpAddress type!");
+ }
+
+ // IpAddress type is defined as:
+ // IpAddress ::=
+ // [APPLICATION 0]
+ // IMPLICIT OCTET STRING (SIZE (4))
+ this.Size.Add(new ValueRange(4, null));
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Macro.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Macro.cs
new file mode 100644
index 00000000000..9f911ac95c8
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Macro.cs
@@ -0,0 +1,34 @@
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public sealed class Macro : ITypeAssignment
+ {
+ private IModule _module;
+ private string _name;
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "temp")]
+ public Macro(IModule module, SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ {
+ _module = module;
+ _name = preAssignSymbols[0].ToString();
+
+ while (symbols.NextNonEOLSymbol() != Symbol.Begin)
+ {
+ }
+
+ while (symbols.NextNonEOLSymbol() != Symbol.End)
+ {
+ }
+ }
+
+ public IModule Module
+ {
+ get { return _module; }
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/ObjectIdentifierType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/ObjectIdentifierType.cs
new file mode 100644
index 00000000000..cacd415aa3d
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/ObjectIdentifierType.cs
@@ -0,0 +1,11 @@
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public class ObjectIdentifierType : BaseType
+ {
+ public ObjectIdentifierType(IModule module, string name, ISymbolEnumerator symbols)
+ : base(module, name)
+ {
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/OctetStringType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/OctetStringType.cs
new file mode 100644
index 00000000000..f6453ce853f
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/OctetStringType.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public class OctetStringType : BaseType
+ {
+ private ValueRanges _size;
+
+ public OctetStringType(IModule module, string name, ISymbolEnumerator symbols)
+ : base(module, name)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+ if (current == Symbol.OpenParentheses)
+ {
+ symbols.PutBack(current);
+ _size = Lexer.DecodeRanges(symbols);
+ current.Assert(_size.IsSizeDeclaration, "SIZE keyword is required for ranges of octet string!");
+ }
+ else
+ {
+ symbols.PutBack(current);
+ _size = new ValueRanges(isSizeDecl: true);
+ }
+ }
+
+ public ValueRanges Size
+ {
+ get { return _size; }
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/OpaqueType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/OpaqueType.cs
new file mode 100644
index 00000000000..5a7eda33204
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/OpaqueType.cs
@@ -0,0 +1,11 @@
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public class OpaqueType : OctetStringType
+ {
+ public OpaqueType(IModule module, string name, ISymbolEnumerator symbols)
+ : base(module, name, symbols)
+ {
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Sequence.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Sequence.cs
new file mode 100644
index 00000000000..62912a515a9
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/Sequence.cs
@@ -0,0 +1,46 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/21
+ * Time: 19:43
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ /// <summary>
+ /// The SEQUENCE type represents a set of specified types. This is roughly analogous to a <code>struct</code> in C.
+ /// </summary>
+ public sealed class Sequence : BaseType
+ {
+ /// <summary>
+ /// Creates a <see cref="Sequence" /> instance.
+ /// </summary>
+ /// <param name="module">The module.</param>
+ /// <param name="name">The name.</param>
+ /// <param name="symbols">The enumerator.</param>
+ public Sequence(IModule module, string name, ISymbolEnumerator symbols)
+ : base(module, name)
+ {
+ // parse between ( )
+ Symbol temp = symbols.NextNonEOLSymbol();
+ int bracketSection = 0;
+ temp.Expect(Symbol.OpenBracket);
+ bracketSection++;
+ while (bracketSection > 0)
+ {
+ temp = symbols.NextNonEOLSymbol();
+ if (temp == Symbol.OpenBracket)
+ {
+ bracketSection++;
+ }
+ else if (temp == Symbol.CloseBracket)
+ {
+ bracketSection--;
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/SequenceOf.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/SequenceOf.cs
new file mode 100644
index 00000000000..4160ca40e47
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/SequenceOf.cs
@@ -0,0 +1,23 @@
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ /// <summary>
+ /// The SEQUENCE OF type represents a list of data sets..
+ /// </summary>
+ public sealed class SequenceOf : BaseType
+ {
+ private string _type;
+
+ public SequenceOf(IModule module, string name, ISymbolEnumerator sym)
+ : base(module, name)
+ {
+ _type = sym.NextNonEOLSymbol().ToString();
+ }
+
+ public string Type
+ {
+ get { return _type; }
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/TextualConvention.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/TextualConvention.cs
new file mode 100644
index 00000000000..ab4773150eb
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/TextualConvention.cs
@@ -0,0 +1,238 @@
+using System;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ public sealed class TextualConvention : ITypeAssignment, ITypeReferrer
+ {
+ private IModule _module;
+ private string _name;
+ private DisplayHint _displayHint;
+ private Status _status;
+ private string _description;
+ private string _reference;
+ private ITypeAssignment _syntax;
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "module")]
+ public TextualConvention(IModule module, string name, ISymbolEnumerator symbols)
+ {
+ _module = module;
+ _name = name;
+
+ _displayHint = ParseDisplayHint(symbols);
+ _status = ParseStatus(symbols);
+ _description = ParseDescription(symbols);
+ _reference = ParseReference(symbols);
+ _syntax = ParseSyntax(module, symbols);
+ }
+
+ private static DisplayHint ParseDisplayHint(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.DisplayHint)
+ {
+ return new DisplayHint(symbols.NextNonEOLSymbol().ToString().Trim(new char[] { '"' }));
+ }
+
+ symbols.PutBack(current);
+ return null;
+ }
+
+ private static Status ParseStatus(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.Status);
+
+ try
+ {
+ return (Status)Enum.Parse(typeof(Status), symbols.NextNonEOLSymbol().ToString());
+ }
+ catch (ArgumentException)
+ {
+ current.Assert(false, "Invalid/Unknown status");
+ }
+
+ return Status.current;
+ }
+
+ private static string ParseDescription(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.Description);
+
+ return symbols.NextNonEOLSymbol().ToString().Trim(new char[] { '"' });
+ }
+
+ private static string ParseReference(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.Reference)
+ {
+ string reference = symbols.NextNonEOLSymbol().ToString();
+ if ((reference.Length >= 2) && reference.StartsWith("\"") && reference.EndsWith("\""))
+ {
+ return reference.Substring(1, reference.Length-2);
+ }
+
+ return reference;
+ }
+
+ symbols.PutBack(current);
+ return null;
+ }
+
+ private static ITypeAssignment ParseSyntax(IModule module, ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.Syntax);
+
+ /*
+ * RFC2579 definition:
+ * Syntax ::= -- Must be one of the following:
+ * -- a base type (or its refinement), or
+ * -- a BITS pseudo-type
+ * type
+ * | "BITS" "{" NamedBits "}"
+ *
+ * From section 3.5:
+ * The data structure must be one of the alternatives defined
+ * in the ObjectSyntax CHOICE or the BITS construct. Note
+ * that this means that the SYNTAX clause of a Textual
+ * Convention can not refer to a previously defined Textual
+ * Convention.
+ *
+ * The SYNTAX clause of a TEXTUAL CONVENTION macro may be
+ * sub-typed in the same way as the SYNTAX clause of an
+ * OBJECT-TYPE macro.
+ *
+ * Therefore the possible values are (grouped by underlying type):
+ * INTEGER, Integer32
+ * OCTET STRING, Opaque
+ * OBJECT IDENTIFIER
+ * IpAddress
+ * Counter64
+ * Unsigned32, Counter32, Gauge32, TimeTicks
+ * BITS
+ * With appropriate sub-typing.
+ */
+
+ return Lexer.ParseBasicTypeDef(module, String.Empty, symbols, isMacroSyntax: true);
+ }
+
+ public IModule Module
+ {
+ get { return _module; }
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ public string DisplayHint
+ {
+ get { return _displayHint == null ? null : _displayHint.ToString(); }
+ }
+
+ public Status Status
+ {
+ get { return _status; }
+ }
+
+ public string Description
+ {
+ get { return _description; }
+ }
+
+ public string Reference
+ {
+ get { return _reference; }
+ }
+
+ public ITypeAssignment Syntax
+ {
+ get { return _syntax; }
+ }
+
+ //internal object Decode(Variable v)
+ //{
+ // if (_syntax is IntegerType)
+ // {
+ // Integer32 i = v.Data as Integer32;
+ // if (i == null || (_syntax as IntegerType).IsEnumeration)
+ // {
+ // return null;
+ // }
+ // else if (_displayHint != null)
+ // {
+ // return _displayHint.Decode(i.ToInt32());
+ // }
+ // else
+ // {
+ // return i.ToInt32();
+ // }
+ // }
+ // else if (_syntax is UnsignedType)
+ // {
+ // Integer32 i = v.Data as Integer32;
+ // if (i == null)
+ // {
+ // return null;
+ // }
+ // else if (_displayHint != null)
+ // {
+ // return _displayHint.Decode(i.ToInt32());
+ // }
+ // else
+ // {
+ // return i.ToInt32();
+ // }
+ // }
+ // else if (_syntax is OctetStringType)
+ // {
+ // OctetString o = v.Data as OctetString;
+ // if (o == null)
+ // {
+ // return null;
+ // }
+ // else
+ // {
+ // // TODO: Follow the format specifier for octet strings.
+ // return null;
+ // }
+ // }
+ // else
+ // {
+ // return null;
+ // }
+ //}
+
+ #region ITypeReferrer Member
+
+ public ITypeAssignment ReferredType
+ {
+ get { return _syntax; }
+ set { _syntax = value; }
+ }
+
+ public ITypeAssignment BaseType
+ {
+ get
+ {
+ ITypeReferrer tr = this;
+ ITypeAssignment result = this;
+
+ while ((tr != null) && (tr.ReferredType != null))
+ {
+ result = tr.ReferredType;
+ tr = tr.ReferredType as ITypeReferrer;
+ }
+
+ return result;
+ }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/TypeAssignment.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/TypeAssignment.cs
new file mode 100644
index 00000000000..b074ef62a26
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/TypeAssignment.cs
@@ -0,0 +1,147 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/18
+ * Time: 13:24
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ /* Please be aware of the following possible constructs:
+ *
+ * isnsRegEntityIndex OBJECT-TYPE
+ * SYNTAX IsnsEntityIndexIdOrZero
+ * ( 1 .. 4294967295 )
+ * MAX-ACCESS not-accessible
+ *
+ *
+ */
+
+ /// <summary/>
+ /// </summary>
+ public sealed class TypeAssignment : ITypeAssignment
+ {
+ private IModule _module;
+ private string _name;
+ private string _type;
+ private ValueRanges _ranges;
+ private ValueMap _map;
+
+ /// <summary>
+ /// Creates an <see cref="TypeAssignment" />.
+ /// </summary>
+ /// <param name="module">The module.</param>
+ /// <param name="name">The name.</param>
+ /// <param name="type">The type.</param>
+ /// <param name="symbols">The symbols.</param>
+ /// <param name="isMacroSyntax">if set to <c>true</c> indicates that the syntax clause of a macro is parsed (e.g. OBJECT-TYPE, TEXTUAL-CONVENTION).</param>
+ public TypeAssignment(IModule module, string name, Symbol type, ISymbolEnumerator symbols, bool isMacroSyntax)
+ {
+ _module = module;
+ _name = name;
+
+ SymbolList typeSymbols = new SymbolList();
+ typeSymbols.Add(type);
+
+ Symbol current = symbols.NextSymbol();
+ while (current != Symbol.EOL)
+ {
+ if (current == Symbol.OpenParentheses)
+ {
+ // parse range of unknown type
+ symbols.PutBack(current);
+ _ranges = Lexer.DecodeRanges(symbols);
+ break;
+ }
+ else if (current == Symbol.OpenBracket)
+ {
+ symbols.PutBack(current);
+ _map = Lexer.DecodeEnumerations(symbols);
+ break;
+ }
+
+ typeSymbols.Add(current);
+ current = symbols.NextSymbol();
+ }
+
+ _type = typeSymbols.Join(" ");
+
+ if ((_ranges == null) && (_map == null))
+ {
+ current = symbols.NextNonEOLSymbol();
+ if (current == Symbol.OpenParentheses)
+ {
+ // parse range of unknown type
+ symbols.PutBack(current);
+ _ranges = Lexer.DecodeRanges(symbols);
+ }
+ else if (current == Symbol.OpenBracket)
+ {
+ symbols.PutBack(current);
+ _map = Lexer.DecodeEnumerations(symbols);
+ }
+ else if (current != null)
+ {
+ symbols.PutBack(current);
+ }
+ }
+
+ if (isMacroSyntax)
+ {
+ // inside a macro the syntax is limited to one line, except there are brackets used for ranges/enums
+ return;
+ }
+
+ // outside macro Syntax clause we wait for two consecutive linebreaks with a following valid identifier as end condition
+ Symbol previous = current;
+ Symbol veryPrevious = null;
+
+ while ((current = symbols.NextSymbol()) != null)
+ {
+ if ((veryPrevious == Symbol.EOL) && (previous == Symbol.EOL) && current.IsValidIdentifier())
+ {
+ symbols.PutBack(current);
+ return;
+ }
+
+ veryPrevious = previous;
+ previous = current;
+ }
+
+ previous.Assert(false, "end of file reached");
+ }
+
+ public string Type
+ {
+ get { return _type; }
+ }
+
+ public ValueRanges Ranges
+ {
+ get { return _ranges; }
+ }
+
+ public IDictionary<long, string> Map
+ {
+ get { return _map; }
+ }
+
+ #region ITypeAssignment Member
+
+ public IModule Module
+ {
+ get { return _module; }
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/UnsignedType.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/UnsignedType.cs
new file mode 100644
index 00000000000..4866fc90181
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Elements/Types/UnsignedType.cs
@@ -0,0 +1,103 @@
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib.Elements.Types
+{
+ /**
+ * As this type is used for Counter32 and TimeTicks as well as Unsigned32
+ * and Gauge32 it incorrectly allows range restrictions of Counter32 and
+ * TimeTicks. This is ok as currently we do not care about detecting
+ * incorrect MIBs and this doesn't block the decoding of correct MIBs.
+ */
+ public class UnsignedType : BaseType
+ {
+ public enum Types
+ {
+ Unsigned32,
+ Gauge32,
+ Counter32,
+ TimeTicks,
+ Counter64,
+ }
+
+ private Types _type;
+ private ValueRanges _ranges;
+
+ public UnsignedType(IModule module, string name, Symbol type, ISymbolEnumerator symbols)
+ : base(module, name)
+ {
+ Types? t = GetExactType(type);
+ type.Assert(t.HasValue, "Unknown symbol for unsigned type!");
+ _type = t.Value;
+
+ Symbol current = symbols.NextNonEOLSymbol();
+ if (current == Symbol.OpenParentheses)
+ {
+ current.Assert((_type != Types.Counter64), "Ranges are not supported for Counter64 type!"); // our internal struct can only hold int64 values
+
+ symbols.PutBack(current);
+ _ranges = Lexer.DecodeRanges(symbols);
+ current.Assert(!_ranges.IsSizeDeclaration, "SIZE keyword is not allowed for ranges of unsigned types!");
+ }
+ else
+ {
+ symbols.PutBack(current);
+ }
+ }
+
+ public Types Type
+ {
+ get { return _type; }
+ }
+
+ public ValueRanges Ranges
+ {
+ get { return _ranges; }
+ }
+
+ internal static Types? GetExactType(Symbol symbol)
+ {
+ if (symbol == Symbol.Unsigned32)
+ {
+ // [APPLICATION 2] IMPLICIT INTEGER (0..4294967295) // from SNMPv2-SMI
+ return Types.Unsigned32;
+ }
+ else if (symbol == Symbol.Gauge32)
+ {
+ // [APPLICATION 2] IMPLICIT INTEGER (0..4294967295) // from SNMPv2-SMI
+ return Types.Gauge32;
+ }
+ else if (symbol == Symbol.Counter32)
+ {
+ // [APPLICATION 1] IMPLICIT INTEGER (0..4294967295) // from SNMPv2-SMI
+ return Types.Counter32;
+ }
+ else if (symbol == Symbol.TimeTicks)
+ {
+ // [APPLICATION 3] IMPLICIT INTEGER (0..4294967295) // from SNMPv2-SMI + RFC1155-SMI
+ return Types.TimeTicks;
+ }
+ else if (symbol == Symbol.Gauge)
+ {
+ // [APPLICATION 2] IMPLICIT INTEGER (0..4294967295) // from RFC1155-SMI
+ return Types.Gauge32;
+ }
+ else if (symbol == Symbol.Counter)
+ {
+ // [APPLICATION 1] IMPLICIT INTEGER (0..4294967295) // from RFC1155-SMI
+ return Types.Counter32;
+ }
+ else if (symbol == Symbol.Counter64)
+ {
+ // [APPLICATION 6] IMPLICIT INTEGER (0..18446744073709551615) // from SNMPv2-SMI
+ return Types.Counter64;
+ }
+
+ return null;
+ }
+
+ internal static bool IsUnsignedType(Symbol symbol)
+ {
+ return GetExactType(symbol).HasValue;
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/IModule.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/IModule.cs
new file mode 100644
index 00000000000..d41ab12978a
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/IModule.cs
@@ -0,0 +1,81 @@
+// Module interface.
+// Copyright (C) 2008-2010 Malcolm Crowe, Lex Li, and other contributors.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 5/1/2009
+ * Time: 10:40 AM
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System.Collections.Generic;
+using Lextm.SharpSnmpLib.Mib.Elements.Entities;
+using Lextm.SharpSnmpLib.Mib.Elements.Types;
+using Lextm.SharpSnmpLib.Mib.Elements;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ /// <summary>
+ /// MIB Module interface.
+ /// </summary>
+ public interface IModule
+ {
+ /// <summary>
+ /// Module name.
+ /// </summary>
+ string Name
+ {
+ get;
+ }
+
+ Exports Exports
+ {
+ get;
+ }
+
+ Imports Imports
+ {
+ get;
+ }
+
+ /// <summary>
+ /// Entities + Types + all other elements implementing IDeclaration
+ /// </summary>
+ IList<IDeclaration> Declarations
+ {
+ get;
+ }
+
+ /// <summary>
+ /// Entities.
+ /// </summary>
+ IList<IEntity> Entities
+ {
+ get;
+ }
+
+ /// <summary>
+ /// Known types.
+ /// </summary>
+ IList<ITypeAssignment> Types
+ {
+ get;
+ }
+
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ISymbolEnumerator.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ISymbolEnumerator.cs
new file mode 100644
index 00000000000..e9dd5920d51
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ISymbolEnumerator.cs
@@ -0,0 +1,9 @@
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public interface ISymbolEnumerator: IEnumerator<Symbol>
+ {
+ bool PutBack(Symbol item);
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Lexer.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Lexer.cs
new file mode 100644
index 00000000000..5bf2844a3db
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Lexer.cs
@@ -0,0 +1,581 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/17
+ * Time: 16:50
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using Lextm.SharpSnmpLib.Mib.Elements.Types;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ /// <summary>
+ /// Lexer class that parses MIB files into symbol list.
+ /// </summary>
+ public sealed class Lexer
+ {
+ private readonly SymbolList _symbols = new SymbolList();
+
+ public Lexer(string file)
+ : this(file, new StreamReader(file))
+ {
+ }
+
+ public Lexer(string file, TextReader stream)
+ {
+ this.Parse(file, stream);
+ }
+
+
+ public ISymbolEnumerator GetEnumerator()
+ {
+ return _symbols.GetSymbolEnumerator();
+ }
+
+
+ #region Parsing of MIB File
+
+ private class ParseParams
+ {
+ public string File;
+ public StringBuilder Temp = new StringBuilder();
+ public bool StringSection = false;
+ public bool AssignSection = false;
+ public bool AssignAhead = false;
+ public bool DotSection = false;
+
+ }
+
+ /// <summary>
+ /// Parses MIB file to symbol list.
+ /// </summary>
+ /// <param name="file">File</param>
+ /// <param name="stream">File stream</param>
+ private void Parse(string file, TextReader stream)
+ {
+ if (stream == null)
+ {
+ throw new ArgumentNullException("stream");
+ }
+
+ ParseParams pp = new ParseParams();
+ pp.File = file;
+
+ string line;
+ int row = 0;
+ while ((line = stream.ReadLine()) != null)
+ {
+ if (!pp.StringSection && line.TrimStart().StartsWith("--", StringComparison.Ordinal))
+ {
+ row++;
+ continue; // commented line
+ }
+
+ ParseLine(pp, line, row);
+ row++;
+ }
+ }
+
+ private void ParseLine(ParseParams pp, string line, int row)
+ {
+ line = line + "\n";
+ int count = line.Length;
+ for (int i = 0; i < count; i++)
+ {
+ char current = line[i];
+ bool moveNext = Parse(pp, current, row, i);
+ if (moveNext)
+ {
+ break;
+ }
+ }
+ }
+
+ private bool Parse(ParseParams pp, char current, int row, int column)
+ {
+ switch (current)
+ {
+ case '\n':
+ case '{':
+ case '}':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
+ case ';':
+ case ',':
+ case '|':
+ if (!pp.StringSection)
+ {
+ bool moveNext = ParseLastSymbol(pp, row, column);
+ if (moveNext)
+ {
+ _symbols.Add(CreateSpecialSymbol(pp.File, '\n', row, column));
+ return true;
+ }
+
+ _symbols.Add(CreateSpecialSymbol(pp.File, current, row, column));
+ return false;
+ }
+
+ break;
+ case '"':
+ pp.StringSection = !pp.StringSection;
+ break;
+ case '\r':
+ return false;
+ default:
+ if ((int)current == 0x1A)
+ {
+ // IMPORTANT: ignore invisible characters such as SUB.
+ return false;
+ }
+
+ if (Char.IsWhiteSpace(current) && !pp.AssignSection && !pp.StringSection)
+ {
+ bool moveNext = ParseLastSymbol(pp, row, column);
+ if (moveNext)
+ {
+ _symbols.Add(CreateSpecialSymbol(pp.File, '\n', row, column));
+ return true;
+ }
+
+ return false;
+ }
+
+ if (pp.AssignAhead)
+ {
+ pp.AssignAhead = false;
+ ParseLastSymbol(pp, row, column);
+ break;
+ }
+
+ if (pp.DotSection && current != '.')
+ {
+ ParseLastSymbol(pp, row, column);
+ pp.DotSection = false;
+ }
+
+ if (current == '.' && !pp.StringSection)
+ {
+ if (!pp.DotSection)
+ {
+ ParseLastSymbol(pp, row, column);
+ pp.DotSection = true;
+ }
+ }
+
+ if (current == ':' && !pp.StringSection)
+ {
+ if (!pp.AssignSection)
+ {
+ ParseLastSymbol(pp, row, column);
+ }
+
+ pp.AssignSection = true;
+ }
+
+ if (current == '=' && !pp.StringSection)
+ {
+ pp.AssignSection = false;
+ pp.AssignAhead = true;
+ }
+
+ break;
+ }
+
+ pp.Temp.Append(current);
+ return false;
+ }
+
+ private bool ParseLastSymbol(ParseParams pp, int row, int column)
+ {
+ if (pp.Temp.Length > 0)
+ {
+ Symbol s = new Symbol(pp.File, pp.Temp.ToString(), row, column);
+
+ pp.Temp.Length = 0;
+
+ if (s.ToString().StartsWith(Symbol.Comment.ToString()))
+ {
+ // ignore the rest symbols on this line because they are in comment.
+ return true;
+ }
+
+ _symbols.Add(s);
+ }
+
+ return false;
+ }
+
+ private static Symbol CreateSpecialSymbol(string file, char value, int row, int column)
+ {
+ string str;
+ switch (value)
+ {
+ case '\n':
+ str = Environment.NewLine;
+ break;
+ case '{':
+ str = "{";
+ break;
+ case '}':
+ str = "}";
+ break;
+ case '(':
+ str = "(";
+ break;
+ case ')':
+ str = ")";
+ break;
+ case '[':
+ str = "[";
+ break;
+ case ']':
+ str = "]";
+ break;
+ case ';':
+ str = ";";
+ break;
+ case ',':
+ str = ",";
+ break;
+ case '|':
+ str = "|";
+ break;
+ default:
+ throw new ArgumentException("value is not a special character");
+ }
+
+ return new Symbol(file, str, row, column);
+ }
+
+ #endregion
+
+ #region Static Parse Helper
+
+ public static ITypeAssignment ParseBasicTypeDef(IModule module, string name, ISymbolEnumerator symbols, bool isMacroSyntax = false)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.Bits)
+ {
+ return new BitsType(module, name, symbols);
+ }
+ if (IntegerType.IsIntegerType(current))
+ {
+ return new IntegerType(module, name, current, symbols);
+ }
+ if (UnsignedType.IsUnsignedType(current))
+ {
+ return new UnsignedType(module, name, current, symbols);
+ }
+ if (current == Symbol.Opaque)
+ {
+ return new OpaqueType(module, name, symbols);
+ }
+ if (current == Symbol.IpAddress)
+ {
+ return new IpAddressType(module, name, symbols);
+ }
+ if (current == Symbol.TextualConvention)
+ {
+ return new TextualConvention(module, name, symbols);
+ }
+ if (current == Symbol.Octet)
+ {
+ Symbol next = symbols.NextNonEOLSymbol();
+
+ if (next == Symbol.String)
+ {
+ return new OctetStringType(module, name, symbols);
+ }
+
+ symbols.PutBack(next);
+ }
+ if (current == Symbol.Object)
+ {
+ Symbol next = symbols.NextNonEOLSymbol();
+
+ if (next == Symbol.Identifier)
+ {
+ return new ObjectIdentifierType(module, name, symbols);
+ }
+
+ symbols.PutBack(next);
+ }
+ if (current == Symbol.Sequence)
+ {
+ Symbol next = symbols.NextNonEOLSymbol();
+
+ if (next == Symbol.Of)
+ {
+ return new SequenceOf(module, name, symbols);
+ }
+ else
+ {
+ symbols.PutBack(next);
+ return new Sequence(module, name, symbols);
+ }
+ }
+ if (current == Symbol.Choice)
+ {
+ return new Choice(module, name, symbols);
+ }
+
+
+ return new TypeAssignment(module, name, current, symbols, isMacroSyntax);
+ }
+
+ public static void ParseOidValue(ISymbolEnumerator symbols, out string parent, out uint value)
+ {
+ parent = null;
+ value = 0;
+
+ Symbol current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.OpenBracket);
+
+ Symbol previous = null;
+ StringBuilder longParent = new StringBuilder();
+
+ current = symbols.NextNonEOLSymbol();
+ longParent.Append(current);
+
+ while ((current = symbols.NextNonEOLSymbol()) != null)
+ {
+ bool succeeded;
+
+ if (current == Symbol.OpenParentheses)
+ {
+ longParent.Append(current);
+
+ current = symbols.NextNonEOLSymbol();
+ succeeded = UInt32.TryParse(current.ToString(), out value);
+ current.Assert(succeeded, "not a decimal");
+ longParent.Append(current);
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.CloseParentheses);
+ longParent.Append(current);
+ continue;
+ }
+
+ if (current == Symbol.CloseBracket)
+ {
+ parent = longParent.ToString();
+ return;
+ }
+
+ succeeded = UInt32.TryParse(current.ToString(), out value);
+ if (succeeded)
+ {
+ // numerical way
+ while ((current = symbols.NextNonEOLSymbol()) != Symbol.CloseBracket)
+ {
+ longParent.Append(".").Append(value);
+ succeeded = UInt32.TryParse(current.ToString(), out value);
+ current.Assert(succeeded, "not a decimal");
+ }
+
+ current.Expect(Symbol.CloseBracket);
+ parent = longParent.ToString();
+ return;
+ }
+
+ longParent.Append(".");
+ longParent.Append(current);
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.OpenParentheses);
+ longParent.Append(current);
+ current = symbols.NextNonEOLSymbol();
+ succeeded = UInt32.TryParse(current.ToString(), out value);
+ current.Assert(succeeded, "not a decimal");
+ longParent.Append(current);
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.CloseParentheses);
+ longParent.Append(current);
+ previous = current;
+ }
+
+ throw MibException.Create("end of file reached", previous);
+ }
+
+
+ public static ValueRanges DecodeRanges(ISymbolEnumerator symbols)
+ {
+ ValueRanges result = new ValueRanges();
+
+ Symbol startSymbol = symbols.NextNonEOLSymbol();
+ Symbol current = startSymbol;
+ current.Expect(Symbol.OpenParentheses);
+
+ while (current != Symbol.CloseParentheses)
+ {
+ Symbol value1Symbol = symbols.NextNonEOLSymbol();
+
+ if ((value1Symbol == Symbol.Size) && !result.IsSizeDeclaration)
+ {
+ result.IsSizeDeclaration = true;
+ symbols.NextNonEOLSymbol().Expect(Symbol.OpenParentheses);
+ continue;
+ }
+
+ // check for valid number
+ Int64? value1 = DecodeNumber(value1Symbol);
+ if (!value1.HasValue)
+ {
+ value1Symbol.Assert(false, "Invalid range declaration!");
+ }
+
+ // process next symbol
+ ValueRange range;
+ current = symbols.NextNonEOLSymbol();
+
+ if (current == Symbol.DoubleDot)
+ {
+ // its a continuous range
+ Symbol value2Symbol = symbols.NextNonEOLSymbol();
+ Int64? value2 = DecodeNumber(value2Symbol);
+ value2Symbol.Assert(value2.HasValue && (value2.Value >= value1.Value), "Invalid range declaration!");
+
+ if (value2.Value == value1.Value)
+ {
+ range = new ValueRange(value1.Value, null);
+ }
+ else
+ {
+ range = new ValueRange(value1.Value, value2.Value);
+ }
+
+ current = symbols.NextNonEOLSymbol();
+ }
+ else
+ {
+ // its a single number
+ range = new ValueRange(value1.Value, null);
+ }
+
+ // validate range
+ if (result.IsSizeDeclaration)
+ {
+ value1Symbol.Assert(range.Start >= 0, "Invalid range declaration! Size must be greater than 0");
+ }
+
+ result.Add(range);
+
+ // check next symbol
+ current.Expect(Symbol.Pipe, Symbol.CloseParentheses);
+ }
+
+ if (result.IsSizeDeclaration)
+ {
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.CloseParentheses);
+ }
+
+ // validate ranges in between
+ for (int i=0; i<result.Count; i++)
+ {
+ for (int k=i+1; k<result.Count; k++)
+ {
+ startSymbol.Assert(!result[i].IntersectsWith(result[k]), "Invalid range declaration! Overlapping of ranges!");
+ }
+ }
+
+ return result;
+ }
+
+ public static Int64? DecodeNumber(Symbol number)
+ {
+ Int64 result;
+ string numString = (number != null) ? number.ToString() : null;
+
+ if (!String.IsNullOrEmpty(numString))
+ {
+ if (numString.StartsWith("'") && (numString.Length > 3))
+ {
+ // search second apostrophe
+ int end = numString.IndexOf('\'', 1);
+ if (end == (numString.Length - 2))
+ {
+ try
+ {
+ switch (numString[numString.Length - 1])
+ {
+ case 'b':
+ case 'B':
+ result = Convert.ToInt64(numString.Substring(1, numString.Length - 3), 2);
+ return result;
+ case 'h':
+ case 'H':
+ result = Convert.ToInt64(numString.Substring(1, numString.Length - 3), 16);
+ return result;
+ }
+ }
+ catch
+ {
+ }
+ }
+ }
+ else if (Int64.TryParse(numString, out result))
+ {
+ return result;
+ }
+ }
+
+ return null;
+ }
+
+ public static ValueMap DecodeEnumerations(ISymbolEnumerator symbols)
+ {
+ Symbol current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.OpenBracket);
+
+ ValueMap map = new ValueMap();
+ do
+ {
+ current = symbols.NextNonEOLSymbol();
+ string identifier = current.ToString();
+
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.OpenParentheses);
+
+ current = symbols.NextNonEOLSymbol();
+ Int64 enumValue;
+ if (Int64.TryParse(current.ToString(), out enumValue))
+ {
+ try
+ {
+ // Have to include the number as it seems repeated identifiers are allowed ??
+ map.Add(enumValue, String.Format("{0}({1})", identifier, enumValue));
+ }
+ catch (ArgumentException ex)
+ {
+ current.Assert(false, ex.Message);
+ }
+ }
+ else
+ {
+ // Need to get "DefinedValue".
+ }
+
+ current = symbols.NextNonEOLSymbol();
+ current.Expect(Symbol.CloseParentheses);
+
+ current = symbols.NextNonEOLSymbol();
+ } while (current == Symbol.Comma);
+
+ current.Expect(Symbol.CloseBracket);
+
+ return map;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MaxAccess.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MaxAccess.cs
new file mode 100644
index 00000000000..f8029900b56
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MaxAccess.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public enum MaxAccess
+ {
+ notAccessible,
+ accessibleForNotify,
+ readOnly,
+ readWrite,
+ readCreate
+ }
+
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibDocument.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibDocument.cs
new file mode 100644
index 00000000000..aac3b280ed3
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibDocument.cs
@@ -0,0 +1,57 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/17
+ * Time: 17:38
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ /// <summary>
+ /// MIB document.
+ /// </summary>
+ public sealed class MibDocument
+ {
+ private readonly List<IModule> _modules = new List<IModule>();
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MibDocument" /> class.
+ /// </summary>
+ /// <param name="file">The file.</param>
+ public MibDocument(string file)
+ : this(new Lexer(file))
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MibDocument"/> class.
+ /// </summary>
+ /// <param name="lexer">The lexer.</param>
+ public MibDocument(Lexer lexer)
+ {
+ ISymbolEnumerator symbols = lexer.GetEnumerator();
+
+ Symbol current;
+ while ((current = symbols.NextNonEOLSymbol()) != null)
+ {
+ symbols.PutBack(current);
+ _modules.Add(new MibModule(symbols));
+ }
+ }
+
+ /// <summary>
+ /// <see cref="MibModule"/> containing in this document.
+ /// </summary>
+ public IList<IModule> Modules
+ {
+ get
+ {
+ return _modules;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibException.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibException.cs
new file mode 100644
index 00000000000..efd89b3f756
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibException.cs
@@ -0,0 +1,113 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/17
+ * Time: 16:33
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System;
+using System.Globalization;
+#if (!SILVERLIGHT)
+using System.Runtime.Serialization;
+using System.Security.Permissions;
+#endif
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ /// <summary>
+ /// Description of MibException.
+ /// </summary>
+ [Serializable]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mib")]
+ public sealed class MibException : Exception
+ {
+ /// <summary>
+ /// Symbol.
+ /// </summary>
+ public Symbol Symbol { get; private set; }
+
+ /// <summary>
+ /// Creates a <see cref="MibException"/>.
+ /// </summary>
+ public MibException()
+ {
+ }
+
+ /// <summary>
+ /// Creates a <see cref="SnmpException"/> instance with a specific <see cref="string"/>.
+ /// </summary>
+ /// <param name="message">Message</param>
+ public MibException(string message) : base(message)
+ {
+ }
+
+ /// <summary>
+ /// Creates a <see cref="MibException"/> instance with a specific <see cref="string"/> and an <see cref="Exception"/>.
+ /// </summary>
+ /// <param name="message">Message</param>
+ /// <param name="inner">Inner exception</param>
+ public MibException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+#if (!SILVERLIGHT)
+ /// <summary>
+ /// Creates a <see cref="MibException"/> instance.
+ /// </summary>
+ /// <param name="info">Info</param>
+ /// <param name="context">Context</param>
+ private MibException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ if (info == null)
+ {
+ throw new ArgumentNullException("info");
+ }
+
+ Symbol = (Symbol)info.GetValue("Symbol", typeof(Symbol));
+ }
+
+ /// <summary>
+ /// Gets object data.
+ /// </summary>
+ /// <param name="info">Info</param>
+ /// <param name="context">Context</param>
+ [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
+ public override void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ base.GetObjectData(info, context);
+ info.AddValue("Symbol", Symbol);
+ }
+#endif
+
+ /// <summary>
+ /// Creates a <see cref="MibException"/> with a specific <see cref="Symbol"/>.
+ /// </summary>
+ /// <param name="message">Message</param>
+ /// <param name="symbol">Symbol</param>
+ /// <returns></returns>
+ public static MibException Create(string message, Symbol symbol)
+ {
+ if (symbol == null)
+ {
+ throw new ArgumentNullException("symbol");
+ }
+
+ if (String.IsNullOrEmpty(message))
+ {
+ message = "Unknown MIB Exception";
+ }
+
+ message = String.Format(
+ "{0} (file: \"{1}\"; row: {2}; column: {3})",
+ message,
+ symbol.File,
+ symbol.Row + 1,
+ symbol.Column + 1);
+
+ MibException ex = new MibException(message) { Symbol = symbol };
+ return ex;
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibModule.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibModule.cs
new file mode 100644
index 00000000000..cacfd045979
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibModule.cs
@@ -0,0 +1,294 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/17
+ * Time: 17:38
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System;
+using System.Collections.Generic;
+using Lextm.SharpSnmpLib.Mib.Elements;
+using Lextm.SharpSnmpLib.Mib.Elements.Entities;
+using Lextm.SharpSnmpLib.Mib.Elements.Types;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ /// <summary>
+ /// MIB module class.
+ /// </summary>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mib")]
+ public sealed class MibModule : IModule
+ {
+ private readonly string _name;
+ private readonly Imports _imports;
+ private readonly Exports _exports;
+ private readonly List<IElement> _tokens = new List<IElement>();
+
+ /// <summary>
+ /// Creates a <see cref="MibModule"/> with a specific <see cref="Lexer"/>.
+ /// </summary>
+ /// <param name="name">Module name</param>
+ /// <param name="symbols">Lexer</param>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "lexer")]
+ public MibModule(ISymbolEnumerator symbols)
+ {
+ if (symbols == null)
+ {
+ throw new ArgumentNullException("lexer");
+ }
+
+ Symbol temp = symbols.NextNonEOLSymbol();
+ temp.AssertIsValidIdentifier();
+ _name = temp.ToString().ToUpperInvariant(); // all module names are uppercase
+
+ temp = symbols.NextNonEOLSymbol();
+ temp.Expect(Symbol.Definitions);
+
+ temp = symbols.NextNonEOLSymbol();
+ temp.Expect(Symbol.Assign);
+
+ temp = symbols.NextSymbol();
+ temp.Expect(Symbol.Begin);
+
+ temp = symbols.NextNonEOLSymbol();
+ if (temp == Symbol.Imports)
+ {
+ _imports = ParseDependents(symbols);
+ }
+ else if (temp == Symbol.Exports)
+ {
+ _exports = ParseExports(symbols);
+ }
+ else
+ {
+ symbols.PutBack(temp);
+ }
+
+ ParseEntities(symbols);
+ }
+
+ #region Accessors
+
+ /// <summary>
+ /// Module name.
+ /// </summary>
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ public Exports Exports
+ {
+ get { return _exports; }
+ }
+
+ public Imports Imports
+ {
+ get { return _imports; }
+ }
+
+ public List<IElement> Tokens
+ {
+ get { return this._tokens; }
+ }
+
+ /// <summary>
+ /// Entities + Types + all other elements implementing IDeclaration
+ /// </summary>
+ public IList<IDeclaration> Declarations
+ {
+ get
+ {
+ IList<IDeclaration> result = new List<IDeclaration>();
+ foreach (IElement e in _tokens)
+ {
+ IDeclaration decl = e as IDeclaration;
+ if (decl != null)
+ {
+ result.Add(decl);
+ }
+ }
+
+ return result;
+ }
+ }
+
+ /// <summary>
+ /// OID nodes.
+ /// </summary>
+ public IList<IEntity> Entities
+ {
+ get
+ {
+ IList<IEntity> result = new List<IEntity>();
+ foreach (IElement e in _tokens)
+ {
+ IEntity entity = e as IEntity;
+ if (entity != null)
+ {
+ result.Add(entity);
+ }
+ }
+
+ return result;
+ }
+ }
+
+ public IList<ITypeAssignment> Types
+ {
+ get
+ {
+ IList<ITypeAssignment> result = new List<ITypeAssignment>();
+ foreach (IElement e in _tokens)
+ {
+ ITypeAssignment type = e as ITypeAssignment;
+ if (type != null)
+ {
+ result.Add(type);
+ }
+ }
+
+ return result;
+ }
+ }
+
+ #endregion
+
+ #region Parsing of Symbols
+
+ private Exports ParseExports(ISymbolEnumerator symbols)
+ {
+ return new Exports(this, symbols);
+ }
+
+ private Imports ParseDependents(ISymbolEnumerator symbols)
+ {
+ return new Imports(this, symbols);
+ }
+
+ private void ParseEntities(ISymbolEnumerator symbols)
+ {
+ Symbol temp = symbols.NextNonEOLSymbol();
+ SymbolList buffer = new SymbolList();
+
+ while (temp != Symbol.End)
+ {
+ if (temp == Symbol.Assign)
+ {
+ ParseEntity(buffer, symbols);
+ buffer.Clear();
+ // skip linebreaks behind an entity
+ temp = symbols.NextNonEOLSymbol();
+ }
+ else
+ {
+ buffer.Add(temp);
+ temp = symbols.NextSymbol();
+ }
+ }
+ }
+
+ private void ParseEntity(SymbolList preAssignSymbols, ISymbolEnumerator symbols)
+ {
+ if ((preAssignSymbols == null) || (preAssignSymbols.Count == 0))
+ {
+ Symbol s = symbols.NextSymbol();
+ if (s != null)
+ {
+ s.Assert(false, "Invalid Entity declaration");
+ }
+ else
+ {
+ throw new MibException("Invalid Entity declaration");
+ }
+ }
+
+ // check for a valid identifier
+ preAssignSymbols[0].AssertIsValidIdentifier();
+
+ if (preAssignSymbols.Count == 1)
+ {
+ // its a typedef
+ _tokens.Add(Lexer.ParseBasicTypeDef(this, preAssignSymbols[0].ToString(), symbols, isMacroSyntax: false));
+ return;
+ }
+
+ ISymbolEnumerator preAssignSymbolsEnumerator = preAssignSymbols.GetSymbolEnumerator();
+ preAssignSymbolsEnumerator.NextNonEOLSymbol(); // returns identifier
+ Symbol type = preAssignSymbolsEnumerator.NextNonEOLSymbol();
+
+ // parse declarations
+ if (type == Symbol.Object)
+ {
+ Symbol next = preAssignSymbolsEnumerator.NextNonEOLSymbol();
+
+ if (next == Symbol.Identifier)
+ {
+ _tokens.Add(new OidValueAssignment(this, preAssignSymbols, symbols));
+ return;
+ }
+ else if (next != null)
+ {
+ preAssignSymbolsEnumerator.PutBack(next);
+ }
+ }
+ if (type == Symbol.ModuleIdentity)
+ {
+ _tokens.Add(new ModuleIdentity(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.ObjectType)
+ {
+ _tokens.Add(new ObjectType(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.ObjectGroup)
+ {
+ _tokens.Add(new ObjectGroup(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.NotificationGroup)
+ {
+ _tokens.Add(new NotificationGroup(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.ModuleCompliance)
+ {
+ _tokens.Add(new ModuleCompliance(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.NotificationType)
+ {
+ _tokens.Add(new NotificationType(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.ObjectIdentity)
+ {
+ _tokens.Add(new ObjectIdentity(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.Macro)
+ {
+ _tokens.Add(new Macro(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.TrapType)
+ {
+ _tokens.Add(new TrapType(this, preAssignSymbols, symbols));
+ return;
+ }
+ if (type == Symbol.AgentCapabilities)
+ {
+ _tokens.Add(new AgentCapabilities(this, preAssignSymbols, symbols));
+ return;
+ }
+
+ preAssignSymbols[1].Assert(false, "Unknown/Invalid declaration");
+ }
+
+ #endregion
+
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibResolver.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibResolver.cs
new file mode 100644
index 00000000000..96978e1ae3a
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibResolver.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+using System.Reflection;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public interface IMibResolver
+ {
+ IModule Resolve(string moduleName);
+ }
+
+ public class FileSystemMibResolver : IMibResolver
+ {
+ private string _path;
+ private bool _recursive;
+
+ public FileSystemMibResolver(string path, bool recursive)
+ {
+ _path = path;
+ _recursive = recursive;
+ }
+
+ #region IMibResolver Member
+
+ public IModule Resolve(string moduleName)
+ {
+ if (Directory.Exists(_path))
+ {
+ string[] matchedFiles = Directory.GetFiles(
+ _path,
+ "*",
+ (_recursive) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
+
+ if ((matchedFiles != null) && (matchedFiles.Length >= 1))
+ {
+ foreach (string matchedFile in matchedFiles)
+ {
+ if (Path.GetFileNameWithoutExtension(matchedFile.ToLowerInvariant()) == moduleName.ToLowerInvariant())
+ {
+ try
+ {
+ MibDocument md = new MibDocument (matchedFile);
+ if (md.Modules.Count > 0)
+ {
+ return md.Modules [0];
+ }
+ } catch
+ {
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ #endregion
+
+ }
+
+ // earlier code for search of versioned MIBs:
+ //
+ //private const string Pattern = "-V[0-9]+$";
+ //public static bool AllDependentsAvailable(MibModule module, IDictionary<string, MibModule> modules)
+ //{
+ // foreach (string dependent in module.Dependents)
+ // {
+ // if (!DependentFound(dependent, modules))
+ // {
+ // return false;
+ // }
+ // }
+
+ // return true;
+ //}
+
+ //private static bool DependentFound(string dependent, IDictionary<string, MibModule> modules)
+ //{
+ // if (!Regex.IsMatch(dependent, Pattern))
+ // {
+ // return modules.ContainsKey(dependent);
+ // }
+
+ // if (modules.ContainsKey(dependent))
+ // {
+ // return true;
+ // }
+
+ // string dependentNonVersion = Regex.Replace(dependent, Pattern, string.Empty);
+ // return modules.ContainsKey(dependentNonVersion);
+ //}
+
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTree.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTree.cs
new file mode 100644
index 00000000000..a5174bc19e9
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTree.cs
@@ -0,0 +1,130 @@
+using System.Collections.Generic;
+using Lextm.SharpSnmpLib.Mib.Elements.Entities;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ /// <summary>
+ /// Builds up a tree from a single MIB
+ /// </summary>
+ public class MibTree
+ {
+ private readonly List<MibTreeNode> _root = new List<MibTreeNode>();
+
+ public MibTree(MibModule module)
+ {
+ IList<IEntity> entities = module.Entities;
+
+ if (entities.Count > 0)
+ {
+ // try to find module identity as root
+ foreach (IEntity element in entities)
+ {
+ ModuleIdentity mi = element as ModuleIdentity;
+
+ if (mi != null)
+ {
+ _root.Add(new MibTreeNode(null, mi));
+ }
+ }
+
+ // find OID assignments as root, if there are any that are not below ModuleIdentity
+ foreach (IEntity element in entities)
+ {
+ OidValueAssignment oa = element as OidValueAssignment;
+
+ if (oa != null)
+ {
+ _root.Add(new MibTreeNode(null, oa));
+ }
+ }
+
+ FilterRealRoots (entities);
+
+ foreach (MibTreeNode mibTreeNode in _root)
+ {
+ entities.Remove (mibTreeNode.Entity);
+ }
+
+ if (_root.Count == 0)
+ {
+ //no module identity, assume first entity is root
+ _root.Add(new MibTreeNode(null, entities[0]));
+ }
+
+ foreach (MibTreeNode mibTreeNode in _root)
+ {
+ if (entities.Contains (mibTreeNode.Entity))
+ {
+ entities.Remove (mibTreeNode.Entity);
+ }
+ BuildTree(mibTreeNode, entities);
+ UpdateTreeNodeTypes(mibTreeNode);
+ }
+ }
+ }
+
+ public IList<MibTreeNode> Root
+ {
+ get { return _root; }
+ }
+
+ private bool EntityExists(IList<IEntity> entities, string name)
+ {
+ foreach(IEntity entity in entities)
+ {
+ if (entity.Name == name)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void FilterRealRoots(IList<IEntity> entities)
+ {
+ int i = 0;
+ while (i < _root.Count)
+ {
+ if (EntityExists(entities, _root[i].Entity.Parent))
+ {
+ _root.RemoveAt(i);
+ }
+ else
+ {
+ i++;
+ }
+ }
+ }
+
+ private void BuildTree(MibTreeNode node, IList<IEntity> entities)
+ {
+ int i = 0;
+ while (i < entities.Count)
+ {
+ if (entities[i].Parent == node.Entity.Name)
+ {
+ node.AddChild(entities[i]);
+ entities.RemoveAt(i);
+ }
+ else
+ {
+ i++;
+ }
+ }
+
+ foreach (MibTreeNode childNode in node.ChildNodes)
+ {
+ BuildTree(childNode, entities);
+ }
+ }
+
+ private void UpdateTreeNodeTypes(MibTreeNode node)
+ {
+ node.UpdateNodeType();
+ foreach (MibTreeNode childNode in node.ChildNodes)
+ {
+ UpdateTreeNodeTypes(childNode);
+ }
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTreeNode.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTreeNode.cs
new file mode 100644
index 00000000000..386c8e5cde7
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTreeNode.cs
@@ -0,0 +1,112 @@
+using System;
+using System.Collections.Generic;
+using Lextm.SharpSnmpLib.Mib.Elements.Entities;
+using Lextm.SharpSnmpLib.Mib.Elements.Types;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ [Flags]
+ public enum MibTreeNodeType
+ {
+ Unknown = 0,
+ Container = (1 << 0),
+ Scalar = (1 << 1),
+ Table = (1 << 2),
+ TableRow = (1 << 3),
+ TableCell = (1 << 4),
+ NotificationRelated = (1 << 5),
+ ConformanceRelated = (1 << 6)
+ }
+
+
+ public class MibTreeNode
+ {
+ private MibTreeNode _parent = null;
+ private List<MibTreeNode> _childNodes = new List<MibTreeNode>();
+ private IEntity _entity = null;
+ private MibTreeNodeType _nodeType = MibTreeNodeType.Unknown;
+
+ public MibTreeNode(MibTreeNode parent, IEntity entity)
+ {
+ _parent = parent;
+ _entity = entity;
+ }
+
+ public MibTreeNode Parent
+ {
+ get { return _parent; }
+ }
+
+ public IEntity Entity
+ {
+ get { return _entity; }
+ }
+
+ public MibTreeNodeType NodeType
+ {
+ get { return _nodeType; }
+ }
+
+ public List<MibTreeNode> ChildNodes
+ {
+ get { return _childNodes; }
+ }
+
+ public MibTreeNode AddChild(IEntity element)
+ {
+ MibTreeNode result = new MibTreeNode(this, element);
+ this.ChildNodes.Add(result);
+
+ return result;
+ }
+
+ public void UpdateNodeType()
+ {
+ _nodeType = MibTreeNodeType.Unknown;
+
+ if (_entity != null)
+ {
+ if ((_entity is OidValueAssignment) || (_entity is ObjectIdentity))
+ {
+ _nodeType |= MibTreeNodeType.Container;
+ return;
+ }
+ else if (_childNodes.Count > 0)
+ {
+ _nodeType |= MibTreeNodeType.Container;
+ }
+
+ if (_entity is ObjectType)
+ {
+ ObjectType ot = _entity as ObjectType;
+
+ if (ot.Syntax is SequenceOf)
+ {
+ _nodeType |= MibTreeNodeType.Table;
+ }
+ else if (ot.Syntax is Sequence)
+ {
+ _nodeType |= MibTreeNodeType.TableRow;
+ }
+ else if ((_parent != null) && ((_parent.NodeType & MibTreeNodeType.TableRow) != 0))
+ {
+ _nodeType |= MibTreeNodeType.TableCell;
+ _nodeType |= MibTreeNodeType.Scalar;
+ }
+ else
+ {
+ _nodeType |= MibTreeNodeType.Scalar;
+ }
+ }
+ else if ((_entity is ModuleCompliance) || (_entity is ObjectGroup) || (_entity is NotificationGroup))
+ {
+ _nodeType |= MibTreeNodeType.ConformanceRelated;
+ }
+ else if ((_entity is NotificationGroup) || (_entity is NotificationType))
+ {
+ _nodeType |= MibTreeNodeType.NotificationRelated;
+ }
+ }
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTypesResolver.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTypesResolver.cs
new file mode 100644
index 00000000000..1e7529af14f
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTypesResolver.cs
@@ -0,0 +1,216 @@
+using System;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using Lextm.SharpSnmpLib.Mib.Elements;
+using Lextm.SharpSnmpLib.Mib.Elements.Entities;
+using Lextm.SharpSnmpLib.Mib.Elements.Types;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public static class MibTypesResolver
+ {
+ private static readonly Regex _namedOidPathRegex = new Regex(@"^(?<Name>[^\(]+)\((?<Value>\d+)\)$");
+ private static readonly List<IMibResolver> _resolver = new List<IMibResolver>();
+ private static readonly List<IModule> _cachedModules = new List<IModule>();
+
+ public static void RegisterResolver(IMibResolver resolver)
+ {
+ if (resolver != null)
+ {
+ _resolver.Add(resolver);
+ }
+ }
+
+ public static IModule ResolveModule(string moduleName)
+ {
+ // check if module is already cached
+ foreach (MibModule cachedModule in _cachedModules)
+ {
+ if (cachedModule.Name == moduleName)
+ {
+ return cachedModule;
+ }
+ }
+
+ foreach (IMibResolver resolver in _resolver)
+ {
+ IModule resolvedModule = resolver.Resolve(moduleName);
+ if (resolvedModule != null)
+ {
+ ResolveTypes(resolvedModule);
+ _cachedModules.Add(resolvedModule);
+ return resolvedModule;
+ }
+ }
+
+ return null;
+ }
+
+ public static void ResolveTypes(IModule module)
+ {
+ foreach (IEntity entity in module.Entities)
+ {
+ ITypeReferrer typeReferringEntity = entity as ITypeReferrer;
+
+ if (typeReferringEntity != null)
+ {
+ CheckTypeReferrer(module, typeReferringEntity);
+ }
+ }
+
+ if (!_cachedModules.Contains(module))
+ {
+ _cachedModules.Add(module);
+ }
+ }
+
+ private static void CheckTypeReferrer(IModule module, ITypeReferrer typeReferringEntity)
+ {
+ TypeAssignment unknownType = typeReferringEntity.ReferredType as TypeAssignment;
+ if (unknownType != null)
+ {
+ typeReferringEntity.ReferredType = ResolveType(module, unknownType);
+
+ if (typeReferringEntity.ReferredType is TypeAssignment)
+ {
+ Console.WriteLine(String.Format("Could not resolve type '{0}' declared in module '{1}'", (typeReferringEntity.ReferredType as TypeAssignment).Type, typeReferringEntity.ReferredType.Module.Name));
+ }
+ }
+
+ ITypeReferrer nextTypeReferringEntity = typeReferringEntity.ReferredType as ITypeReferrer;
+ if (nextTypeReferringEntity != null)
+ {
+ CheckTypeReferrer(module, nextTypeReferringEntity);
+ }
+ }
+
+ public static ITypeAssignment ResolveType(IModule module, TypeAssignment type)
+ {
+ ITypeAssignment result = ResolveDeclaration(module, type.Type) as ITypeAssignment;
+
+ return (result != null) ? result : type;
+ }
+
+ public static IDeclaration ResolveDeclaration(IModule module, string name)
+ {
+ if ((module == null) || String.IsNullOrEmpty(name))
+ {
+ return null;
+ }
+
+ // check module internal types
+ foreach (IDeclaration decl in module.Declarations)
+ {
+ if (decl.Name == name)
+ {
+ return decl;
+ }
+ }
+
+ // check if type is imported
+ if (module.Imports != null)
+ {
+ ImportsFrom imports = module.Imports.GetImportFromType(name);
+ if (imports != null)
+ {
+ IModule importedModule = ResolveModule(imports.Module);
+ if (importedModule != null)
+ {
+ return ResolveDeclaration(importedModule, name);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static ObjectIdentifier ResolveOid(IEntity entity)
+ {
+ ObjectIdentifier result = new ObjectIdentifier();
+
+ if (entity != null)
+ {
+ ResolveOid(entity, result);
+ }
+
+ return result;
+ }
+
+ private static void ResolveOid(IEntity entity, ObjectIdentifier result)
+ {
+ result.Prepend(entity.Name, entity.Value);
+
+ // check parent
+ if (!String.IsNullOrEmpty(entity.Parent))
+ {
+ string[] pathParts = entity.Parent.Split('.');
+ uint value;
+
+ // all parts except the first should have their value directly or indirectly with them
+ if (pathParts.Length > 1)
+ {
+ for (int i=pathParts.Length-1; i>=1; i--)
+ {
+ if (uint.TryParse(pathParts[i], out value))
+ {
+ result.Prepend("", value);
+ }
+ else
+ {
+ Match m = _namedOidPathRegex.Match(pathParts[i]);
+ if (m.Success)
+ {
+ result.Prepend(m.Groups["Name"].Value, uint.Parse(m.Groups["Value"].Value));
+ }
+ else
+ {
+ throw new MibException("Invalid OID path detected for entity '" + entity.Name + "' in module '" + entity.Module + "'!");
+ }
+ }
+ }
+ }
+
+ // parse root part: either another entity or a standard root object
+ if (IsOidRoot(pathParts[0], out value))
+ {
+ result.Prepend(pathParts[0], value);
+ }
+ else
+ {
+ // try to find entity inside this module
+ if (entity.Module != null)
+ {
+ entity = ResolveDeclaration(entity.Module, pathParts[0]) as IEntity;
+
+ if (entity != null)
+ {
+ ResolveOid(entity, result);
+ }
+ else
+ {
+ result.Prepend("", uint.MaxValue);
+ }
+ }
+ else
+ {
+ result.Prepend("", uint.MaxValue);
+ }
+ }
+ }
+ }
+
+ public static bool IsOidRoot(string name, out uint value)
+ {
+ value = uint.MaxValue;
+
+ switch (name)
+ {
+ case "ccitt": value = 0; return true;
+ case "iso": value = 1; return true;
+ case "joint-iso-ccitt": value = 2; return true;
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ObjectIdentifier.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ObjectIdentifier.cs
new file mode 100644
index 00000000000..04248043926
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ObjectIdentifier.cs
@@ -0,0 +1,54 @@
+using System.Collections.Generic;
+using System.Text;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public class ObjectIdentifier: List<KeyValuePair<string, uint>>
+ {
+ public void Add(string name, uint oid)
+ {
+ this.Add(new KeyValuePair<string, uint>(name, oid));
+ }
+
+ public void Prepend(string name, uint oid)
+ {
+ this.Insert(0, new KeyValuePair<string, uint>(name, oid));
+ }
+
+ public void Insert(int index, string name, uint oid)
+ {
+ this.Insert(index, new KeyValuePair<string, uint>(name, oid));
+ }
+
+ public string GetOidString()
+ {
+ StringBuilder result = new StringBuilder();
+
+ foreach (KeyValuePair<string, uint> level in this)
+ {
+ result.Append(level.Value);
+ result.Append('.');
+ }
+
+ if (result.Length > 0)
+ {
+ result.Length--;
+ }
+
+ return result.ToString();
+ }
+
+ public uint[] GetOidValues()
+ {
+ List<uint> result = new List<uint>();
+
+ foreach (KeyValuePair<string, uint> level in this)
+ {
+ result.Add(level.Value);
+ }
+
+ return result.ToArray();
+ }
+
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Status.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Status.cs
new file mode 100644
index 00000000000..4ddd3babeb5
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Status.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public enum Status
+ {
+ current,
+ deprecated,
+ obsolete,
+ mandatory,
+ optional
+ }
+
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Symbol.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Symbol.cs
new file mode 100644
index 00000000000..b11386d8715
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/Symbol.cs
@@ -0,0 +1,357 @@
+/*
+ * Created by SharpDevelop.
+ * User: lextm
+ * Date: 2008/5/17
+ * Time: 17:14
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+
+using System;
+using System.Configuration;
+using System.Globalization;
+using System.Text;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ /// <summary>
+ /// Description of Symbol.
+ /// </summary>
+ public sealed class Symbol : IEquatable<Symbol>
+ {
+ private readonly string _text;
+ private readonly int _row;
+ private readonly int _column;
+ private readonly string _file;
+
+ private Symbol(string text) : this(null, text, -1, -1)
+ {
+ }
+
+ /// <summary>
+ /// Creates a <see cref="Symbol"/>.
+ /// </summary>
+ /// <param name="file">File</param>
+ /// <param name="text">Text</param>
+ /// <param name="row">Row number</param>
+ /// <param name="column">column number</param>
+ public Symbol(string file, string text, int row, int column)
+ {
+ _file = file;
+ _text = text;
+ _row = row;
+ _column = column;
+ }
+
+ /// <summary>
+ /// File.
+ /// </summary>
+ public string File
+ {
+ get
+ {
+ return _file;
+ }
+ }
+
+ /// <summary>
+ /// Row number.
+ /// </summary>
+ public int Row
+ {
+ get
+ {
+ return _row;
+ }
+ }
+
+ /// <summary>
+ /// Column number.
+ /// </summary>
+ public int Column
+ {
+ get
+ {
+ return _column;
+ }
+ }
+
+ /// <summary>
+ /// Returns a <see cref="String"/> that represents this <see cref="Symbol"/>.
+ /// </summary>
+ /// <returns></returns>
+ public override string ToString()
+ {
+ return _text;
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="Object"/> is equal to the current <see cref="Symbol"/>.
+ /// </summary>
+ /// <param name="obj">The <see cref="Object"/> to compare with the current <see cref="Symbol"/>. </param>
+ /// <returns><value>true</value> if the specified <see cref="Object"/> is equal to the current <see cref="Symbol"/>; otherwise, <value>false</value>.
+ /// </returns>
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ return GetType() == obj.GetType() && Equals((Symbol)obj);
+ }
+
+ /// <summary>
+ /// Serves as a hash function for a particular type.
+ /// </summary>
+ /// <returns>A hash code for the current <see cref="Symbol"/>.</returns>
+ public override int GetHashCode()
+ {
+ return _text.GetHashCode();
+ }
+
+ /// <summary>
+ /// The equality operator.
+ /// </summary>
+ /// <param name="left">Left <see cref="Symbol"/> object</param>
+ /// <param name="right">Right <see cref="Symbol"/> object</param>
+ /// <returns>
+ /// Returns <c>true</c> if the values of its operands are equal, <c>false</c> otherwise.</returns>
+ public static bool operator ==(Symbol left, Symbol right)
+ {
+ return Equals(left, right);
+ }
+
+ /// <summary>
+ /// Determines whether the specified <see cref="Symbol"/> is equal to the current <see cref="Symbol"/>.
+ /// </summary>
+ /// <param name="left">Left <see cref="Symbol"/> object</param>
+ /// <param name="right">Right <see cref="Symbol"/> object</param>
+ /// <returns>
+ /// Returns <c>true</c> if the values of its operands are equal, <c>false</c> otherwise.</returns>
+ public static bool Equals(Symbol left, Symbol right)
+ {
+ object l = left;
+ object r = right;
+ if (l == r)
+ {
+ return true;
+ }
+
+ if (l == null || r == null)
+ {
+ return false;
+ }
+
+ return left._text.Equals(right._text);
+ }
+
+ /// <summary>
+ /// The inequality operator.
+ /// </summary>
+ /// <param name="left">Left <see cref="Symbol"/> object</param>
+ /// <param name="right">Right <see cref="Symbol"/> object</param>
+ /// <returns>
+ /// Returns <c>true</c> if the values of its operands are not equal, <c>false</c> otherwise.</returns>
+ public static bool operator !=(Symbol left, Symbol right)
+ {
+ return !(left == right);
+ }
+
+ #region IEquatable<Symbol> Members
+ /// <summary>
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// </summary>
+ /// <param name="other">An object to compare with this object.</param>
+ /// <returns><value>true</value> if the current object is equal to the <paramref name="other"/> parameter; otherwise, <value>false</value>.
+ /// </returns>
+ public bool Equals(Symbol other)
+ {
+ return Equals(this, other);
+ }
+
+ #endregion
+
+ public static readonly Symbol Definitions = new Symbol("DEFINITIONS");
+ public static readonly Symbol Begin = new Symbol("BEGIN");
+ public static readonly Symbol Object = new Symbol("OBJECT");
+ public static readonly Symbol Identifier = new Symbol("IDENTIFIER");
+ public static readonly Symbol Assign = new Symbol("::=");
+ public static readonly Symbol OpenBracket = new Symbol("{");
+ public static readonly Symbol CloseBracket = new Symbol("}");
+ public static readonly Symbol Comment = new Symbol("--");
+ public static readonly Symbol Imports = new Symbol("IMPORTS");
+ public static readonly Symbol Semicolon = new Symbol(";");
+ public static readonly Symbol From = new Symbol("FROM");
+ public static readonly Symbol ModuleIdentity = new Symbol("MODULE-IDENTITY");
+ public static readonly Symbol ObjectType = new Symbol("OBJECT-TYPE");
+ public static readonly Symbol ObjectGroup = new Symbol("OBJECT-GROUP");
+ public static readonly Symbol NotificationGroup = new Symbol("NOTIFICATION-GROUP");
+ public static readonly Symbol ModuleCompliance = new Symbol("MODULE-COMPLIANCE");
+ public static readonly Symbol Sequence = new Symbol("SEQUENCE");
+ public static readonly Symbol NotificationType = new Symbol("NOTIFICATION-TYPE");
+ public static readonly Symbol EOL = new Symbol(Environment.NewLine);
+ public static readonly Symbol ObjectIdentity = new Symbol("OBJECT-IDENTITY");
+ public static readonly Symbol End = new Symbol("END");
+ public static readonly Symbol Macro = new Symbol("MACRO");
+ public static readonly Symbol Choice = new Symbol("CHOICE");
+ public static readonly Symbol TrapType = new Symbol("TRAP-TYPE");
+ public static readonly Symbol AgentCapabilities = new Symbol("AGENT-CAPABILITIES");
+ public static readonly Symbol Comma = new Symbol(",");
+ public static readonly Symbol TextualConvention = new Symbol("TEXTUAL-CONVENTION");
+ public static readonly Symbol Syntax = new Symbol("SYNTAX");
+ public static readonly Symbol Bits = new Symbol("BITS");
+ public static readonly Symbol Octet = new Symbol("OCTET");
+ public static readonly Symbol String = new Symbol("STRING");
+ public static readonly Symbol OpenParentheses = new Symbol("(");
+ public static readonly Symbol CloseParentheses = new Symbol(")");
+ public static readonly Symbol Exports = new Symbol("EXPORTS");
+ public static readonly Symbol DisplayHint = new Symbol("DISPLAY-HINT");
+ public static readonly Symbol Status = new Symbol("STATUS");
+ public static readonly Symbol Description = new Symbol("DESCRIPTION");
+ public static readonly Symbol Reference = new Symbol("REFERENCE");
+ public static readonly Symbol DoubleDot = new Symbol("..");
+ public static readonly Symbol Pipe = new Symbol("|");
+ public static readonly Symbol Size = new Symbol("SIZE");
+ public static readonly Symbol Units = new Symbol("UNITS");
+ public static readonly Symbol MaxAccess = new Symbol("MAX-ACCESS");
+ public static readonly Symbol Access = new Symbol("ACCESS");
+ public static readonly Symbol Index = new Symbol("INDEX");
+ public static readonly Symbol Augments = new Symbol("AUGMENTS");
+ public static readonly Symbol DefVal = new Symbol("DEFVAL");
+ public static readonly Symbol Of = new Symbol("OF");
+ public static readonly Symbol Integer = new Symbol("INTEGER");
+ public static readonly Symbol Integer32 = new Symbol("Integer32");
+ public static readonly Symbol IpAddress = new Symbol("IpAddress");
+ public static readonly Symbol Counter32 = new Symbol("Counter32");
+ public static readonly Symbol Counter = new Symbol("Counter");
+ public static readonly Symbol TimeTicks = new Symbol("TimeTicks");
+ public static readonly Symbol Opaque = new Symbol("Opaque");
+ public static readonly Symbol Counter64 = new Symbol("Counter64");
+ public static readonly Symbol Unsigned32 = new Symbol("Unsigned32");
+ public static readonly Symbol Gauge32 = new Symbol("Gauge32");
+ public static readonly Symbol Gauge = new Symbol("Gauge");
+ public static readonly Symbol TruthValue = new Symbol("TruthValue");
+ public static readonly Symbol Implied = new Symbol("IMPLIED");
+
+ internal void Expect(Symbol expected, params Symbol[] orExpected)
+ {
+ bool isExpected = (this == expected);
+
+ if (!isExpected && (orExpected != null) && (orExpected.Length > 0))
+ {
+ // check the alternatives
+ for (int i=0; i<orExpected.Length; i++)
+ {
+ if (this == orExpected[i])
+ {
+ isExpected = true;
+ break;
+ }
+ }
+ }
+
+ if (!isExpected)
+ {
+ if ((orExpected == null) || (orExpected.Length == 0))
+ {
+ Assert(false, "Unexpected symbol found! Expected '" + expected.ToString() + "'");
+ }
+ else
+ {
+ StringBuilder msg = new StringBuilder("Unexpected symbol found! Expected one of the following: '");
+ msg.Append(expected);
+
+ // check the alternatives
+ for (int i=0; i<orExpected.Length; i++)
+ {
+ msg.Append("', '");
+ msg.Append(expected);
+ }
+ msg.Append("'");
+
+ Assert(false, msg.ToString());
+ }
+ }
+ }
+
+ internal void Assert(bool condition, string message)
+ {
+ if (!condition)
+ {
+ throw MibException.Create(message, this);
+ }
+ }
+
+ internal void AssertIsValidIdentifier()
+ {
+ string message;
+ bool isValid = IsValidIdentifier(ToString(), out message);
+ Assert(isValid, message);
+ }
+
+ internal bool IsValidIdentifier()
+ {
+ string message;
+ return IsValidIdentifier(ToString(), out message);
+ }
+
+ private static bool IsValidIdentifier(string name, out string message)
+ {
+ if (UseStricterValidation && (name.Length < 1 || name.Length > 64))
+ {
+ message = "an identifier must consist of 1 to 64 letters, digits, and hyphens";
+ return false;
+ }
+
+ if (!Char.IsLetter(name[0]))
+ {
+ message = "the initial character must be a letter";
+ return false;
+ }
+
+ if (name.EndsWith("-", StringComparison.Ordinal))
+ {
+ message = "a hyphen cannot be the last character of an identifier";
+ return false;
+ }
+
+ if (name.Contains("--"))
+ {
+ message = "a hyphen cannot be immediately followed by another hyphen in an identifier";
+ return false;
+ }
+
+ if (UseStricterValidation && name.Contains("_"))
+ {
+ message = "underscores are not allowed in identifiers";
+ return false;
+ }
+
+ // TODO: SMIv2 forbids "-" except in module names and keywords
+ message = null;
+ return true;
+ }
+
+ private static bool? _useStricterValidation;
+
+ private static bool UseStricterValidation
+ {
+ get
+ {
+ if (_useStricterValidation == null)
+ {
+ object setting = ConfigurationManager.AppSettings["StricterValidationEnabled"];
+ _useStricterValidation = setting != null && Convert.ToBoolean(setting.ToString(), CultureInfo.InvariantCulture);
+ }
+
+ return _useStricterValidation.Value;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/SymbolList.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/SymbolList.cs
new file mode 100644
index 00000000000..5b2218e8bf5
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/SymbolList.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public class SymbolList : List<Symbol>
+ {
+ public class SymbolEnumerator : ISymbolEnumerator
+ {
+ private SymbolList _list = null;
+ private int _index = -1;
+
+ internal SymbolEnumerator(SymbolList list)
+ {
+ if (list == null)
+ {
+ throw new ArgumentNullException("lexer");
+ }
+
+ _list = list;
+ }
+
+ #region ISymbolEnumerator Member
+
+ public bool PutBack(Symbol item)
+ {
+ if ((_index < 0) || (_index >= _list.Count) || (item != _list[_index]))
+ {
+ throw new ArgumentException(@"wrong last symbol", "last");
+ //return false;
+ }
+
+ _index--;
+ return true;
+ }
+
+ #endregion
+
+ #region IEnumerator<Symbol> Member
+
+ public Symbol Current
+ {
+ get
+ {
+ if ((_index >= 0) && (_index <= _list.Count))
+ {
+ return _list[_index];
+ }
+
+ return null;
+ }
+ }
+
+ #endregion
+
+ #region IDisposable Member
+
+ public void Dispose()
+ {
+ }
+
+ #endregion
+
+ #region IEnumerator Member
+
+ object System.Collections.IEnumerator.Current
+ {
+ get { return this.Current; }
+ }
+
+ public bool MoveNext()
+ {
+ _index++;
+ return (_index >= 0) && (_index < _list.Count);
+ }
+
+ public void Reset()
+ {
+ _index = -1;
+ }
+
+ #endregion
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="SymbolList"/> class.
+ /// </summary>
+ public SymbolList()
+ {
+ }
+
+ public ISymbolEnumerator GetSymbolEnumerator()
+ {
+ return new SymbolEnumerator(this);
+ }
+
+ public string Join(string separator)
+ {
+ if (separator == null)
+ separator = "";
+
+ StringBuilder result = new StringBuilder();
+
+ foreach (Symbol s in this)
+ {
+ result.Append(s);
+ result.Append(separator);
+ }
+
+ if (result.Length > 0)
+ {
+ result.Length -= separator.Length;
+ }
+
+ return result.ToString();
+ }
+ }
+
+ public static class SymbolEnumeratorExtension
+ {
+ public static Symbol NextSymbol(this IEnumerator<Symbol> enumerator)
+ {
+ if (enumerator.MoveNext())
+ {
+ return enumerator.Current;
+ }
+
+ return null;
+ }
+
+ public static Symbol NextNonEOLSymbol(this IEnumerator<Symbol> enumerator)
+ {
+ while (enumerator.MoveNext())
+ {
+ if (enumerator.Current != Symbol.EOL)
+ {
+ return enumerator.Current;
+ }
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueMap.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueMap.cs
new file mode 100644
index 00000000000..48842356a20
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueMap.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public class ValueMap : Dictionary<Int64, string>
+ {
+ public ValueMap()
+ {
+ }
+
+ /// <summary>
+ /// Returns the values of the map as continuous range. At best as one range.
+ /// </summary>
+ /// <returns></returns>
+ public ValueRanges GetContinousRanges()
+ {
+ ValueRanges result = new ValueRanges();
+
+ if (this.Count > 0)
+ {
+ List<Int64> values = new List<long>(this.Keys);
+ values.Sort();
+
+ Int64 last = values[0];
+ Int64 offset = values[0];
+ for (int i=1; i<values.Count; i++)
+ {
+ if (values[i] != last + 1)
+ {
+ if (last == offset)
+ {
+ result.Add(new ValueRange(offset, null));
+ }
+ else
+ {
+ result.Add(new ValueRange(offset, last));
+ }
+
+ offset = values[i];
+ }
+
+ last = values[i];
+ }
+
+ if (last == offset)
+ {
+ result.Add(new ValueRange(offset, null));
+ }
+ else
+ {
+ result.Add(new ValueRange(offset, last));
+ }
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Gets the highest value contained in this value map.
+ /// </summary>
+ /// <returns></returns>
+ public Int64 GetHighestValue()
+ {
+ Int64 result = 0;
+
+ foreach (Int64 value in this.Keys)
+ {
+ if (value > result)
+ {
+ result = value;
+ }
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Interprets the single values as bit positions and creates a mask of it.
+ /// </summary>
+ /// <returns></returns>
+ public UInt32 GetBitMask()
+ {
+ UInt32 result = 0;
+
+ foreach (Int64 key in this.Keys)
+ {
+ if (key < 0)
+ {
+ throw new NotSupportedException("Negative numbers are not allowed for Bits!");
+ }
+ if (key > 31)
+ {
+ throw new NotSupportedException("Bits with more than 32 bits are not supported!");
+ }
+
+ result |= (UInt32)(1 << (int)key);
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueRange.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueRange.cs
new file mode 100644
index 00000000000..3ff5bcb7d0d
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueRange.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+
+namespace Lextm.SharpSnmpLib.Mib
+{
+ public class ValueRanges: List<ValueRange>
+ {
+ public bool IsSizeDeclaration { get; internal set; }
+
+ public ValueRanges(bool isSizeDecl = false)
+ {
+ IsSizeDeclaration = isSizeDecl;
+ }
+
+ public bool Contains(Int64 value)
+ {
+ foreach (ValueRange range in this)
+ {
+ if (range.Contains(value))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+
+ public class ValueRange
+ {
+ private readonly Int64 _start;
+ private readonly Int64? _end;
+
+ public ValueRange(Int64 first, Int64? second)
+ {
+ _start = first;
+ _end = second;
+ }
+
+ public Int64 Start
+ {
+ get { return _start; }
+ }
+
+ public Int64? End
+ {
+ get { return _end; }
+ }
+
+ public bool IntersectsWith(ValueRange other)
+ {
+ if (this._end == null)
+ {
+ return other.Contains(this._start);
+ }
+ else if (other._end == null)
+ {
+ return this.Contains(other._start);
+ }
+
+ return (this._start <= other.End) && (this._end >= other._start);
+ }
+
+ public bool Contains(Int64 value)
+ {
+ if (_end == null)
+ {
+ return value == _start;
+ }
+ else
+ {
+ return (_start <= value) && (value <= _end);
+ }
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/AssemblyInfo.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000000..f96080d092f
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/AssemblyInfo.cs
@@ -0,0 +1,61 @@
+// <summary>#SNMP Library. An open source SNMP implementation for .NET.</summary>
+// <copyright company="Lex Y. Li" file="AssemblyInfo.cs">Copyright (C) 2008 Lex Y. Li</copyright>
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#region Using directives
+
+using System;
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+#endregion
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SharpSnmpLib")]
+[assembly: AssemblyDescription("#SNMP Library for .NET")]
+[assembly: AssemblyConfiguration("Lesser GPL 2.1+")]
+[assembly: AssemblyCompany("LeXtudio")]
+[assembly: AssemblyProduct("#SNMPLib")]
+[assembly: AssemblyCopyright("(C) 2008-2010 Malcolm Crowe, Lex Li, Steve Santacroce, and other contributors.")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// This sets the default COM visibility of types in the assembly to invisible.
+// If you need to expose index type to COM, use [ComVisible(true)] on that type.
+[assembly: ComVisible(false)]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all the values or you can use the default the Revision and
+// Build Numbers by using the '*' as shown below:
+[assembly: AssemblyVersion("7.0.011207.31")]
+#if (!CF)
+[assembly: AssemblyFileVersion("7.0.011207.31")]
+#endif
+[assembly: NeutralResourcesLanguage("en-US")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lextm")]
+
+[assembly: InternalsVisibleTo("SharpSnmpLib.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f7030532c52524"
++ "993841a0d09420340f3814e1b65473851bdcd18815510b035a2ae9ecee69c4cd2d9e4d6e6d5fbf"
++ "a564e86c4a4cddc9597619a31c060846ebb2e99511a0323ff82b1ebd95d6a4912502945f0e769f"
++ "190a69a439dbfb969ebad72a6f7e2e047907da4a7b9c08c6e98d5f1be8b8cafaf3eb978914059a"
++ "245d4bc1")]
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/Resources.Designer.cs b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/Resources.Designer.cs
new file mode 100644
index 00000000000..38bc6bb94f5
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.225
+//
+// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
+// der Code erneut generiert wird.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Lextm.SharpSnmpLib.Mib {
+ using System;
+
+
+ /// <summary>
+ /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+ /// </summary>
+ // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
+ // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
+ // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
+ // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lextm.SharpSnmpLib.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
+ /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/Resources.resx b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/Resources.resx
new file mode 100644
index 00000000000..7080a7d118e
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/Properties/Resources.resx
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root> \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/SharpSnmpLib.Mib.csproj b/contrib/apps/LwipMibCompiler/SharpSnmpLib/SharpSnmpLib.Mib.csproj
new file mode 100644
index 00000000000..2cf86578e22
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/SharpSnmpLib.Mib.csproj
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{CBE20411-5DB7-487D-825D-7694267BB6F5}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Lextm.SharpSnmpLib</RootNamespace>
+ <AssemblyName>SharpSnmpLib.Mib</AssemblyName>
+ <DocumentationFile>..\bin\SharpSnmpLib.Mib.xml</DocumentationFile>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile />
+ <SignAssembly>True</SignAssembly>
+ <AssemblyOriginatorKeyFile>sharpsnmplib.snk</AssemblyOriginatorKeyFile>
+ <DelaySign>False</DelaySign>
+ <AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
+ <SccProjectName>
+ </SccProjectName>
+ <SccLocalPath>
+ </SccLocalPath>
+ <SccAuxPath>
+ </SccAuxPath>
+ <SccProvider>
+ </SccProvider>
+ <RunSourceAnalysis>False</RunSourceAnalysis>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>
+ </DocumentationFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>
+ </DocumentationFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Configuration" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Mib\DisplayHint.cs" />
+ <Compile Include="Mib\Elements\Entities\AgentCapabilities.cs" />
+ <Compile Include="Mib\Elements\Entities\EntityBase.cs" />
+ <Compile Include="Mib\Elements\Entities\IEntity.cs" />
+ <Compile Include="Mib\Elements\Entities\ModuleCompliance.cs" />
+ <Compile Include="Mib\Elements\Entities\ModuleIdentity.cs" />
+ <Compile Include="Mib\Elements\Entities\NotificationGroup.cs" />
+ <Compile Include="Mib\Elements\Entities\NotificationType.cs" />
+ <Compile Include="Mib\Elements\Entities\ObjectGroup.cs" />
+ <Compile Include="Mib\Elements\Entities\ObjectIdentity.cs" />
+ <Compile Include="Mib\Elements\Entities\ObjectType.cs" />
+ <Compile Include="Mib\Elements\Entities\OidValueAssignment.cs" />
+ <Compile Include="Mib\Elements\Exports.cs" />
+ <Compile Include="Mib\Elements\IElement.cs" />
+ <Compile Include="Mib\Elements\Imports.cs" />
+ <Compile Include="Mib\Elements\ImportsFrom.cs" />
+ <Compile Include="Mib\Elements\IDeclaration.cs" />
+ <Compile Include="Mib\Elements\TrapType.cs" />
+ <Compile Include="Mib\Elements\Types\BaseType.cs" />
+ <Compile Include="Mib\Elements\Types\BitsType.cs" />
+ <Compile Include="Mib\Elements\Types\Choice.cs" />
+ <Compile Include="Mib\Elements\Types\IntegerType.cs" />
+ <Compile Include="Mib\Elements\Types\IpAddressType.cs" />
+ <Compile Include="Mib\Elements\Types\ITypeAssignment.cs" />
+ <Compile Include="Mib\Elements\ITypeReferrer.cs" />
+ <Compile Include="Mib\Elements\Types\Macro.cs" />
+ <Compile Include="Mib\Elements\Types\ObjectIdentifierType.cs" />
+ <Compile Include="Mib\Elements\Types\OctetStringType.cs" />
+ <Compile Include="Mib\Elements\Types\OpaqueType.cs" />
+ <Compile Include="Mib\Elements\Types\Sequence.cs" />
+ <Compile Include="Mib\Elements\Types\SequenceOf.cs" />
+ <Compile Include="Mib\Elements\Types\TextualConvention.cs" />
+ <Compile Include="Mib\Elements\Types\TypeAssignment.cs" />
+ <Compile Include="Mib\Elements\Types\UnsignedType.cs" />
+ <Compile Include="Mib\IModule.cs" />
+ <Compile Include="Mib\ISymbolEnumerator.cs" />
+ <Compile Include="Mib\MaxAccess.cs" />
+ <Compile Include="Mib\MibResolver.cs" />
+ <Compile Include="Mib\MibTree.cs" />
+ <Compile Include="Mib\MibTreeNode.cs" />
+ <Compile Include="Mib\MibTypesResolver.cs" />
+ <Compile Include="Mib\ObjectIdentifier.cs" />
+ <Compile Include="Mib\Status.cs" />
+ <Compile Include="Mib\SymbolList.cs" />
+ <Compile Include="Mib\Lexer.cs" />
+ <Compile Include="Mib\MibDocument.cs" />
+ <Compile Include="Mib\MibModule.cs" />
+ <Compile Include="Mib\MibException.cs" />
+ <Compile Include="Mib\Symbol.cs" />
+ <Compile Include="Mib\ValueMap.cs" />
+ <Compile Include="Mib\ValueRange.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="sharpsnmplib.snk" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="license.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <CustomToolNamespace>Lextm.SharpSnmpLib.Mib</CustomToolNamespace>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="Resources\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project> \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/license.txt b/contrib/apps/LwipMibCompiler/SharpSnmpLib/license.txt
new file mode 100644
index 00000000000..27946de2100
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/license.txt
@@ -0,0 +1,458 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS \ No newline at end of file
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/readme.txt b/contrib/apps/LwipMibCompiler/SharpSnmpLib/readme.txt
new file mode 100644
index 00000000000..67b5a655712
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/readme.txt
@@ -0,0 +1 @@
+See docs in src/apps/snmp/snmp_core.c.
diff --git a/contrib/apps/LwipMibCompiler/SharpSnmpLib/sharpsnmplib.snk b/contrib/apps/LwipMibCompiler/SharpSnmpLib/sharpsnmplib.snk
new file mode 100644
index 00000000000..fe6f345af48
--- /dev/null
+++ b/contrib/apps/LwipMibCompiler/SharpSnmpLib/sharpsnmplib.snk
Binary files differ