diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CCodeGeneration.csproj b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CCodeGeneration.csproj
new file mode 100644
index 00000000..06d5075e
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CCodeGeneration.csproj
@@ -0,0 +1,67 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}
+ Library
+ Properties
+ CCodeGeneration
+ CCodeGeneration
+ v4.0
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CFile.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CFile.cs
new file mode 100644
index 00000000..6f122742
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CFile.cs
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+
+namespace CCodeGeneration
+{
+ public class CFile: CodeContainerBase
+ {
+ public CFile()
+ {
+ base.IncreaseLevel = false;
+ }
+
+ public void Save(CGenerator generator)
+ {
+ if (generator == null)
+ {
+ throw new ArgumentNullException("generator");
+ }
+
+ this.GenerateCode(0, generator);
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CGenerator.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CGenerator.cs
new file mode 100644
index 00000000..4e8dfbc7
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CGenerator.cs
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+using System.IO;
+
+namespace CCodeGeneration
+{
+ public class CGenerator
+ {
+ public TextWriter OutputStream { get; private set; }
+ public string File { get; private set; }
+ public uint IndentCount { get; private set; }
+ public string IndentChar { get; private set; }
+ public string NewLine { get; private set; }
+
+ public CGenerator(System.IO.TextWriter outputStream, string file, uint indentCount, string indentChar, string newLine)
+ {
+ this.OutputStream = outputStream;
+ this.File = file;
+ this.IndentCount = indentCount;
+ this.IndentChar = indentChar;
+ this.NewLine = newLine;
+ }
+
+ public string FileName
+ {
+ get
+ {
+ if (!String.IsNullOrWhiteSpace(this.File))
+ {
+ return Path.GetFileName(this.File);
+ }
+
+ return null;
+ }
+ }
+
+ public void WriteSequence(string value, uint repetitions)
+ {
+ while (repetitions > 0)
+ {
+ this.OutputStream.Write(value);
+ repetitions--;
+ }
+ }
+
+ public void IndentLine(int level)
+ {
+ while (level > 0)
+ {
+ WriteSequence(this.IndentChar, this.IndentCount);
+ level--;
+ }
+ }
+
+ public void WriteNewLine()
+ {
+ this.OutputStream.Write(this.NewLine);
+ }
+
+ public void WriteMultilineString(string value, int level = 0)
+ {
+ if (String.IsNullOrEmpty(value))
+ {
+ return;
+ }
+
+ // only \n and \r\n are recognized as linebreaks
+ string[] lines = value.Split(new char[] { '\n' }, StringSplitOptions.None);
+
+ for (int l = 0; l < (lines.Length - 1); l++)
+ {
+ if (lines[l].EndsWith("\r"))
+ {
+ this.OutputStream.Write(lines[l].Substring(0, lines[l].Length-1));
+ }
+ else
+ {
+ this.OutputStream.Write(lines[l]);
+ }
+
+ this.WriteNewLine();
+ this.IndentLine(level);
+ }
+
+ this.OutputStream.Write(lines[lines.Length - 1]);
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Code.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Code.cs
new file mode 100644
index 00000000..4834508a
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Code.cs
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+namespace CCodeGeneration
+{
+ public class Code: CodeElement
+ {
+ public string Code_ { get; set; }
+
+ public Code()
+ {
+ }
+
+ public Code(string code)
+ {
+ this.Code_ = code;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ generator.IndentLine(level);
+ generator.WriteMultilineString(this.Code_, level);
+ generator.WriteNewLine();
+ }
+
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CodeContainerBase.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CodeContainerBase.cs
new file mode 100644
index 00000000..4327d92d
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CodeContainerBase.cs
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System.Collections.Generic;
+using System;
+
+namespace CCodeGeneration
+{
+ public class CodeContainerBase: CodeElement
+ {
+ private readonly List declarations = new List();
+ private readonly List innerElements = new List();
+ private bool increaseLevel = true;
+
+ public List Declarations
+ {
+ get { return this.declarations; }
+ }
+
+ public List InnerElements
+ {
+ get { return this.innerElements; }
+ }
+
+ protected bool IncreaseLevel
+ {
+ get { return this.increaseLevel; }
+ set { this.increaseLevel = value; }
+ }
+
+ public void AddElements(IList elements, params CodeElement[] spacerElements)
+ {
+ if (elements != null)
+ {
+ if ((spacerElements == null) || (spacerElements.Length == 0))
+ {
+ this.innerElements.AddRange(elements);
+ }
+ else
+ {
+ bool spacerAdded = false;
+
+ foreach (CodeElement element in elements)
+ {
+ this.innerElements.Add(element);
+ this.innerElements.AddRange(spacerElements);
+ spacerAdded = true;
+ }
+
+ if (spacerAdded)
+ {
+ // remove last spacer again
+ this.innerElements.RemoveRange(this.innerElements.Count - spacerElements.Length, spacerElements.Length);
+ }
+ }
+ }
+ }
+
+ public CodeElement AddElement(CodeElement element)
+ {
+ if (element != null)
+ {
+ this.innerElements.Add(element);
+ }
+
+ return element;
+ }
+
+ public Code AddCode(string code)
+ {
+ return this.AddElement(new Code(code)) as Code;
+ }
+
+ public Code AddCodeFormat(string codeFormat, params object[] args)
+ {
+ return this.AddElement(new Code(String.Format(codeFormat, args))) as Code;
+ }
+
+ public CodeElement AddDeclaration(CodeElement declaration)
+ {
+ if (declaration != null)
+ {
+ this.declarations.Add(declaration);
+ }
+
+ return declaration;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (this.increaseLevel)
+ level++;
+
+ if (this.declarations.Count > 0)
+ {
+ foreach (CodeElement element in this.declarations)
+ {
+ element.GenerateCode(level, generator);
+ }
+
+ EmptyLine.SingleLine.GenerateCode(level, generator);
+ }
+
+ foreach (CodeElement element in this.innerElements)
+ {
+ element.GenerateCode(level, generator);
+ }
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CodeElement.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CodeElement.cs
new file mode 100644
index 00000000..51cf2d24
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/CodeElement.cs
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+namespace CCodeGeneration
+{
+ public class CodeElement
+ {
+ public virtual void GenerateCode(int level, CGenerator generator)
+ {
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Comment.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Comment.cs
new file mode 100644
index 00000000..51779bea
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Comment.cs
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+namespace CCodeGeneration
+{
+ public class Comment: CodeElement
+ {
+ public const string CommentStart = "/*";
+ public const string CommentEnd = "*/";
+
+ public string Comment_ { get; set; }
+ public bool SingleLine { get; set; }
+
+ public Comment()
+ {
+ }
+
+ public Comment(string comment, bool singleLine = false)
+ {
+ this.Comment_ = comment;
+ this.SingleLine = singleLine;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ generator.IndentLine(level);
+ generator.OutputStream.Write(CommentStart);
+
+ if (!this.SingleLine)
+ {
+ generator.WriteNewLine();
+ generator.IndentLine(level);
+ generator.WriteMultilineString(this.Comment_, level);
+ generator.WriteNewLine();
+ generator.IndentLine(level);
+ }
+ else
+ {
+ generator.OutputStream.Write(" " + Comment_ + " ");
+ }
+
+ generator.OutputStream.Write(CommentEnd);
+ generator.WriteNewLine();
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/EmptyLine.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/EmptyLine.cs
new file mode 100644
index 00000000..604c9477
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/EmptyLine.cs
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+namespace CCodeGeneration
+{
+ public class EmptyLine : CodeElement
+ {
+ public static readonly EmptyLine SingleLine = new EmptyLine();
+ public static readonly EmptyLine TwoLines = new EmptyLine(2);
+ public static readonly EmptyLine ThreeLines = new EmptyLine(3);
+
+ public uint Count { get; set; }
+
+ public EmptyLine()
+ {
+ this.Count = 1;
+ }
+
+ public EmptyLine(uint count)
+ {
+ this.Count = count;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ uint c = this.Count;
+
+ while (c > 0)
+ {
+ generator.WriteNewLine();
+ c--;
+ }
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Function.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Function.cs
new file mode 100644
index 00000000..d81f6e56
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Function.cs
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace CCodeGeneration
+{
+ public class Function: CodeContainerBase
+ {
+ public string Name { get; set; }
+ public bool IsStatic { get; set; }
+
+ private readonly List parameter = new List();
+ private VariableType returnType = VariableType.Void;
+
+ public Function()
+ {
+ }
+
+ public Function(string name, bool isStatic = false)
+ {
+ this.Name = name;
+ this.IsStatic = isStatic;
+ }
+
+ public List Parameter
+ {
+ get { return this.parameter; }
+ }
+
+ public VariableType ReturnType
+ {
+ get { return this.returnType; }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException("ReturnValue");
+ }
+ this.returnType = value;
+ }
+ }
+
+ public static Function FromDeclaration(FunctionDeclaration decl)
+ {
+ Function result = new Function(decl.Name, decl.IsStatic);
+ result.ReturnType = decl.ReturnType.Clone() as VariableType;
+
+ foreach (VariableType param in decl.Parameter)
+ {
+ result.parameter.Add(param.Clone() as VariableType);
+ }
+
+ return result;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ generator.IndentLine(level);
+
+ if (this.IsStatic)
+ {
+ generator.OutputStream.Write("static ");
+ }
+
+ this.returnType.GenerateCode(generator);
+ generator.OutputStream.Write(" " + this.Name + "(");
+
+ if (this.Parameter.Count > 0)
+ {
+ for (int i = 0; i < this.parameter.Count; i++)
+ {
+ this.parameter[i].GenerateCode(generator);
+
+ if (i < (this.parameter.Count - 1))
+ {
+ generator.OutputStream.Write(", ");
+ }
+ }
+ }
+ else
+ {
+ generator.OutputStream.Write("void");
+ }
+
+ generator.OutputStream.Write(")");
+ generator.WriteNewLine();
+ generator.IndentLine(level);
+ generator.OutputStream.Write("{");
+ generator.WriteNewLine();
+
+ base.GenerateCode(level, generator);
+
+ generator.IndentLine(level);
+ generator.OutputStream.Write("}");
+ generator.WriteNewLine();
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/FunctionDeclaration.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/FunctionDeclaration.cs
new file mode 100644
index 00000000..3bc42888
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/FunctionDeclaration.cs
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace CCodeGeneration
+{
+ public class FunctionDeclaration: CodeElement
+ {
+ public string Name { get; set; }
+ public bool IsStatic { get; set; }
+ public bool IsExtern { get; set; }
+
+ private readonly List parameter = new List();
+ private VariableType returnType = VariableType.Void;
+
+ public FunctionDeclaration()
+ {
+ }
+
+ public FunctionDeclaration(string name, bool isStatic = false, bool isExtern = false)
+ {
+ this.Name = name;
+ this.IsStatic = isStatic;
+ this.IsExtern = isExtern;
+ }
+
+ public List Parameter
+ {
+ get { return this.parameter; }
+ }
+
+ public VariableType ReturnType
+ {
+ get { return this.returnType; }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException("ReturnValue");
+ }
+ this.returnType = value;
+ }
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ generator.IndentLine(level);
+
+ if (this.IsExtern)
+ {
+ generator.OutputStream.Write("extern ");
+ }
+
+ if (this.IsStatic)
+ {
+ generator.OutputStream.Write("static ");
+ }
+
+ this.returnType.GenerateCode(generator);
+ generator.OutputStream.Write(" " + this.Name + "(");
+
+ if (this.Parameter.Count > 0)
+ {
+ for (int i = 0; i < this.parameter.Count; i++)
+ {
+ this.parameter[i].GenerateCode(generator);
+
+ if (i < (this.parameter.Count - 1))
+ {
+ generator.OutputStream.Write(", ");
+ }
+ }
+ }
+ else
+ {
+ generator.OutputStream.Write("void");
+ }
+
+ generator.OutputStream.Write(");");
+ generator.WriteNewLine();
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/IfThenElse.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/IfThenElse.cs
new file mode 100644
index 00000000..c4710225
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/IfThenElse.cs
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace CCodeGeneration
+{
+ public class ElseIf : CodeContainerBase
+ {
+ public string Condition { get; set; }
+
+ public ElseIf()
+ {
+ }
+
+ public ElseIf(string condition)
+ {
+ this.Condition = condition;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (!String.IsNullOrWhiteSpace(this.Condition))
+ {
+ generator.IndentLine(level);
+ generator.OutputStream.Write(String.Format("else if ({0})", this.Condition));
+ generator.WriteNewLine();
+ generator.IndentLine(level);
+ generator.OutputStream.Write("{");
+ generator.WriteNewLine();
+
+ base.GenerateCode(level, generator);
+
+ generator.IndentLine(level);
+ generator.OutputStream.Write("}");
+ generator.WriteNewLine();
+ }
+ }
+ }
+
+ public class IfThenElse: CodeContainerBase
+ {
+ public string Condition { get; set; }
+
+ private List elseIf = new List();
+ private CodeContainerBase else_ = new CodeContainerBase();
+
+ public IfThenElse()
+ {
+ }
+
+ public IfThenElse(string condition)
+ {
+ this.Condition = condition;
+ }
+
+ public List ElseIf
+ {
+ get { return this.elseIf; }
+ }
+
+ public CodeContainerBase Else
+ {
+ get { return this.else_; }
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (!String.IsNullOrWhiteSpace(this.Condition))
+ {
+ generator.IndentLine(level);
+ generator.OutputStream.Write(String.Format("if ({0})", this.Condition));
+ generator.WriteNewLine();
+ generator.IndentLine(level);
+ generator.OutputStream.Write("{");
+ generator.WriteNewLine();
+
+ base.GenerateCode(level, generator);
+
+ generator.IndentLine(level);
+ generator.OutputStream.Write("}");
+ generator.WriteNewLine();
+
+ foreach (ElseIf elif in this.elseIf)
+ {
+ elif.GenerateCode(level, generator);
+ }
+
+ if (this.else_.InnerElements.Count > 0)
+ {
+ generator.IndentLine(level);
+ generator.OutputStream.Write("else");
+ generator.WriteNewLine();
+ generator.IndentLine(level);
+ generator.OutputStream.Write("{");
+ generator.WriteNewLine();
+
+ this.else_.GenerateCode(level, generator);
+
+ generator.IndentLine(level);
+ generator.OutputStream.Write("}");
+ generator.WriteNewLine();
+ }
+ }
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_If.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_If.cs
new file mode 100644
index 00000000..55682155
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_If.cs
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+
+namespace CCodeGeneration
+{
+ public class PP_If: CodeContainerBase
+ {
+ public string Condition { get; set; }
+
+ public PP_If()
+ {
+ base.IncreaseLevel = false;
+ }
+
+ public PP_If(string condition)
+ : this()
+ {
+ this.Condition = condition;
+ }
+
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (!String.IsNullOrWhiteSpace(this.Condition))
+ {
+ generator.OutputStream.Write("#if " + this.Condition);
+ generator.WriteNewLine();
+
+ base.GenerateCode(level, generator);
+
+ generator.OutputStream.Write("#endif /* " + this.Condition + " */");
+ generator.WriteNewLine();
+ }
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Ifdef.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Ifdef.cs
new file mode 100644
index 00000000..fd4f45af
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Ifdef.cs
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+
+namespace CCodeGeneration
+{
+ public class PP_Ifdef: CodeContainerBase
+ {
+ public string Macro { get; set; }
+ public bool Inverted { get; set; }
+
+ public PP_Ifdef()
+ {
+ base.IncreaseLevel = false;
+ }
+
+ public PP_Ifdef(string macro, bool inverted = false)
+ : this()
+ {
+ this.Macro = macro;
+ this.Inverted = inverted;
+ }
+
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (!String.IsNullOrWhiteSpace(this.Macro))
+ {
+ if (this.Inverted)
+ {
+ generator.OutputStream.Write("#ifndef " + this.Macro);
+ }
+ else
+ {
+ generator.OutputStream.Write("#ifdef " + this.Macro);
+ }
+ generator.WriteNewLine();
+
+ base.GenerateCode(level, generator);
+
+ generator.OutputStream.Write("#endif /* " + this.Macro + " */");
+ generator.WriteNewLine();
+ }
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Include.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Include.cs
new file mode 100644
index 00000000..0393d271
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Include.cs
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+
+namespace CCodeGeneration
+{
+ public class PP_Include : CodeElement
+ {
+ public string File { get; set; }
+ public bool IsLocal { get; set; }
+
+ public PP_Include()
+ {
+ this.IsLocal = true;
+ }
+
+ public PP_Include(string file, bool isLocal = true)
+ {
+ this.File = file;
+ this.IsLocal = isLocal;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (!String.IsNullOrWhiteSpace(this.File))
+ {
+ // includes are never indented
+ if (this.IsLocal)
+ {
+ generator.OutputStream.Write("#include \"" + this.File + "\"");
+ }
+ else
+ {
+ generator.OutputStream.Write("#include <" + this.File + ">");
+ }
+
+ generator.WriteNewLine();
+ }
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Macro.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Macro.cs
new file mode 100644
index 00000000..6f302aa9
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PP_Macro.cs
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+namespace CCodeGeneration
+{
+ public class PP_Macro: CodeElement
+ {
+ public string Name { get; set; }
+ public string Value { get; set; }
+
+ public PP_Macro()
+ {
+ }
+
+ public PP_Macro(string name, string value)
+ {
+ this.Name = name;
+ this.Value = value;
+ }
+
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ // macros are not indented at all
+ generator.OutputStream.Write("#define " + this.Name + " ");
+ generator.WriteMultilineString(this.Value);
+ generator.WriteNewLine();
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PlainText.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PlainText.cs
new file mode 100644
index 00000000..d5e076fe
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/PlainText.cs
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+namespace CCodeGeneration
+{
+ public class PlainText : CodeElement
+ {
+ public string Value { get; set; }
+
+ public PlainText(string value)
+ {
+ this.Value = value;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ generator.WriteMultilineString(this.Value);
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Properties/AssemblyInfo.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..4c716ad3
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("CCodeGeneration")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("CCodeGeneration")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("8f07a0fa-86f4-48a0-97c7-f94fc5c3f103")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Switch.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Switch.cs
new file mode 100644
index 00000000..9166fb89
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/Switch.cs
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace CCodeGeneration
+{
+ public class SwitchCase : CodeContainerBase
+ {
+ public string Value { get; set; }
+
+ public SwitchCase()
+ {
+ }
+
+ public SwitchCase(string value)
+ {
+ this.Value = value;
+ }
+
+ public bool IsDefault
+ {
+ get { return (this.Value.ToLowerInvariant() == "default"); }
+ }
+
+ public static SwitchCase GenerateDefault()
+ {
+ return new SwitchCase("default");
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (!String.IsNullOrWhiteSpace(this.Value))
+ {
+ generator.IndentLine(level);
+ if (this.IsDefault)
+ {
+ generator.OutputStream.Write("default:");
+ }
+ else
+ {
+ generator.OutputStream.Write(String.Format("case {0}:", this.Value));
+ }
+ generator.WriteNewLine();
+ generator.IndentLine(level + 1);
+ generator.OutputStream.Write("{");
+ generator.WriteNewLine();
+
+ base.GenerateCode(level + 1, generator);
+
+ generator.IndentLine(level + 1);
+ generator.OutputStream.Write("}");
+ generator.WriteNewLine();
+
+ generator.IndentLine(level + 1);
+ generator.OutputStream.Write("break;");
+ generator.WriteNewLine();
+ }
+ }
+ }
+
+ public class Switch: CodeElement
+ {
+ public string SwitchVar { get; set; }
+
+ private List switches = new List();
+
+ public Switch()
+ {
+ }
+
+ public Switch(string switchVar)
+ {
+ this.SwitchVar = switchVar;
+ }
+
+ public List Switches
+ {
+ get { return this.switches; }
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (!String.IsNullOrWhiteSpace(this.SwitchVar))
+ {
+ generator.IndentLine(level);
+ generator.OutputStream.Write(String.Format("switch ({0})", this.SwitchVar));
+ generator.WriteNewLine();
+ generator.IndentLine(level);
+ generator.OutputStream.Write("{");
+ generator.WriteNewLine();
+
+ SwitchCase defaultCase = null; // generate 'default' always as last case
+ foreach (SwitchCase switchCase in this.switches)
+ {
+ if (switchCase.IsDefault)
+ {
+ defaultCase = switchCase;
+ }
+ else
+ {
+ switchCase.GenerateCode(level + 1, generator);
+ }
+ }
+ if (defaultCase != null)
+ {
+ defaultCase.GenerateCode(level + 1, generator);
+ }
+
+ generator.IndentLine(level);
+ generator.OutputStream.Write("}");
+ generator.WriteNewLine();
+ }
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariableDeclaration.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariableDeclaration.cs
new file mode 100644
index 00000000..bf2c9026
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariableDeclaration.cs
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+
+namespace CCodeGeneration
+{
+ public class VariableDeclaration : CodeElement
+ {
+ public VariableType Type { get; set; }
+ public string InitialValue { get; set; }
+ public bool IsStatic { get; set; }
+
+ public VariableDeclaration()
+ : base()
+ {
+ }
+
+ public VariableDeclaration(VariableType type, string initialValue = null, bool isStatic = false) :
+ base()
+ {
+ this.Type = type;
+ this.InitialValue = initialValue;
+ this.IsStatic = isStatic;
+ }
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (this.Type != null)
+ {
+ generator.IndentLine(level);
+
+ if (this.IsStatic)
+ {
+ generator.OutputStream.Write("static ");
+ }
+
+ // declare the variable
+ this.Type.GenerateCode(generator);
+
+ if (!String.IsNullOrWhiteSpace(this.InitialValue))
+ {
+ // add initialization value
+ generator.OutputStream.Write(" = ");
+ generator.WriteMultilineString(this.InitialValue, level);
+ }
+
+ generator.OutputStream.Write(";");
+ generator.WriteNewLine();
+ }
+ }
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariablePrototype.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariablePrototype.cs
new file mode 100644
index 00000000..38a41663
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariablePrototype.cs
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+namespace CCodeGeneration
+{
+ public class VariablePrototype : CodeElement
+ {
+ public VariableType Type { get; set; }
+
+ public VariablePrototype()
+ : base()
+ {
+ }
+
+ public VariablePrototype(VariableType type) :
+ base()
+ {
+ Type = type;
+ }
+
+ public static VariablePrototype FromVariableDeclaration(VariableDeclaration declaration)
+ {
+ return new VariablePrototype(declaration.Type);
+ }
+
+
+ public override void GenerateCode(int level, CGenerator generator)
+ {
+ if (this.Type != null)
+ {
+ generator.IndentLine(level);
+
+ generator.OutputStream.Write("extern ");
+
+ // declare the variable
+ this.Type.GenerateCode(generator);
+
+ generator.OutputStream.Write(";");
+ generator.WriteNewLine();
+ }
+ }
+
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariableType.cs b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariableType.cs
new file mode 100644
index 00000000..313abbee
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/CCodeGeneration/VariableType.cs
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+using System.Text;
+
+namespace CCodeGeneration
+{
+ public enum ConstType
+ {
+ None,
+ Value,
+ Indirection,
+ Both
+ }
+
+ public class VariableType : ICloneable
+ {
+ public const string VoidString = "void";
+ public static readonly VariableType Void = new VariableType(null, "void");
+
+ public string Name { get; set; }
+ public string Type { get; set; }
+ public string Indirection { get; set; }
+ public ConstType Const { get; set; }
+ public string ArraySpecifier { get; set; }
+
+ public VariableType()
+ {
+ }
+
+ public VariableType(string name, string type, string indirection = null, ConstType const_ = ConstType.None, string arraySpecifier = null)
+ {
+ this.Name = name;
+ this.Type = type;
+ this.Indirection = indirection;
+ this.Const = const_;
+ this.ArraySpecifier = arraySpecifier;
+ }
+
+ public void GenerateCode(CGenerator generator)
+ {
+ if (!String.IsNullOrWhiteSpace(this.Type))
+ {
+ generator.OutputStream.Write(this.ToString().Trim());
+ }
+ }
+
+ public override string ToString()
+ {
+ if (!String.IsNullOrWhiteSpace(this.Type))
+ {
+ StringBuilder vt = new StringBuilder();
+
+ if ((this.Const == ConstType.Value) || (this.Const == ConstType.Both))
+ {
+ vt.Append("const ");
+ }
+
+ vt.Append(this.Type);
+ vt.Append(" ");
+
+ if (!String.IsNullOrWhiteSpace(this.Indirection))
+ {
+ vt.Append(this.Indirection);
+ }
+
+ if ((this.Const == ConstType.Indirection) || (this.Const == ConstType.Both))
+ {
+ vt.Append("const ");
+ }
+
+ if (!String.IsNullOrWhiteSpace(this.Name))
+ {
+ vt.Append(this.Name);
+ }
+
+ if (this.ArraySpecifier != null)
+ {
+ vt.Append("[");
+ vt.Append(this.ArraySpecifier);
+ vt.Append("]");
+ }
+
+ return vt.ToString().Trim();
+ }
+
+ return base.ToString();
+ }
+
+ #region ICloneable Member
+
+ public object Clone()
+ {
+ // we only have value types as members -> simply use .net base function
+ return this.MemberwiseClone();
+ }
+
+ #endregion
+ }
+}
diff --git a/src/apps/snmp/LwipMibCompiler/LwipMibCompiler.sln b/src/apps/snmp/LwipMibCompiler/LwipMibCompiler.sln
new file mode 100644
index 00000000..12ca54de
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/LwipMibCompiler.sln
@@ -0,0 +1,47 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LwipMibCompiler", "LwipMibCompiler\LwipMibCompiler.csproj", "{C25D5640-D999-49BD-82E0-A1975296A91E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LwipSnmpCodeGeneration", "LwipSnmpCodeGeneration\LwipSnmpCodeGeneration.csproj", "{AABCAB90-1540-45D4-A159-14831A54E9A3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CCodeGeneration", "CCodeGeneration\CCodeGeneration.csproj", "{7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpSnmpLib.Mib", "SharpSnmpLib\SharpSnmpLib.Mib.csproj", "{CBE20411-5DB7-487D-825D-7694267BB6F5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LwipMibViewer", "LwipMibViewer\LwipMibViewer.csproj", "{86CC0B65-7985-4017-A252-0A7A18DCAEF3}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {86CC0B65-7985-4017-A252-0A7A18DCAEF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {86CC0B65-7985-4017-A252-0A7A18DCAEF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {86CC0B65-7985-4017-A252-0A7A18DCAEF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {86CC0B65-7985-4017-A252-0A7A18DCAEF3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AABCAB90-1540-45D4-A159-14831A54E9A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AABCAB90-1540-45D4-A159-14831A54E9A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AABCAB90-1540-45D4-A159-14831A54E9A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AABCAB90-1540-45D4-A159-14831A54E9A3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C25D5640-D999-49BD-82E0-A1975296A91E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C25D5640-D999-49BD-82E0-A1975296A91E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C25D5640-D999-49BD-82E0-A1975296A91E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C25D5640-D999-49BD-82E0-A1975296A91E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CBE20411-5DB7-487D-825D-7694267BB6F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CBE20411-5DB7-487D-825D-7694267BB6F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CBE20411-5DB7-487D-825D-7694267BB6F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CBE20411-5DB7-487D-825D-7694267BB6F5}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = LwipMibViewer\LwipMibViewer.csproj
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/LwipMibCompiler.csproj b/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/LwipMibCompiler.csproj
new file mode 100644
index 00000000..eb54c3f1
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/LwipMibCompiler.csproj
@@ -0,0 +1,71 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {C25D5640-D999-49BD-82E0-A1975296A91E}
+ Exe
+ Properties
+ LwipMibCompiler
+ LwipMibCompiler
+ v4.0
+ 512
+
+
+
+ true
+ bin\Debug\
+ DEBUG;TRACE
+ full
+ AnyCPU
+ prompt
+ false
+ false
+ 4
+ false
+
+
+ bin\Release\
+ TRACE
+ true
+ pdbonly
+ AnyCPU
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {7DA7C0AB-0982-4BF5-9324-F59A7A08D65B}
+ CCodeGeneration
+
+
+ {AABCAB90-1540-45D4-A159-14831A54E9A3}
+ LwipSnmpCodeGeneration
+
+
+ {CBE20411-5DB7-487D-825D-7694267BB6F5}
+ SharpSnmpLib.Mib
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/Program.cs b/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/Program.cs
new file mode 100644
index 00000000..20e726ef
--- /dev/null
+++ b/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/Program.cs
@@ -0,0 +1,470 @@
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Martin Hentschel
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Text.RegularExpressions;
+using CCodeGeneration;
+using Lextm.SharpSnmpLib.Mib;
+using Lextm.SharpSnmpLib.Mib.Elements.Entities;
+using Lextm.SharpSnmpLib.Mib.Elements.Types;
+using LwipSnmpCodeGeneration;
+
+namespace LwipMibCompiler
+{
+ class Program
+ {
+ private static readonly Regex _alphaNumericRegex = new Regex("[^a-zA-Z0-9]");
+
+ static void Main(string[] args)
+ {
+ Console.WriteLine("lwIP MIB Compiler");
+ Console.WriteLine("");
+
+ // check args
+ if ((args.Length < 2) || String.IsNullOrWhiteSpace(args[0]) || String.IsNullOrWhiteSpace(args[1]))
+ {
+ PrintUsage();
+ return;
+ }
+
+ string mibFile = args[0];
+ if (!File.Exists(mibFile))
+ {
+ Console.WriteLine(String.Format("Unable to find file '{0}'!", mibFile));
+ }
+
+ string destFile = args[1];
+ string destHeaderFile;
+
+ if (Directory.Exists(destFile))
+ {
+ // only directory passed -> create dest filename from mib filename
+ string mibFileName = Path.GetFileNameWithoutExtension(mibFile).ToLowerInvariant();
+ destFile = Path.Combine(destFile, mibFileName + ".c");
+ }
+
+ string destFileExt = Path.GetExtension(destFile);
+ if (!String.IsNullOrEmpty(destFileExt))
+ {
+ destHeaderFile = destFile.Substring(0, destFile.Length - destFileExt.Length);
+ }
+ else
+ {
+ destHeaderFile = destFile;
+ }
+ destHeaderFile += ".h";
+
+ for (int i=2; i [ ...]", appName));
+ Console.WriteLine("");
+ Console.WriteLine("