mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-09 17:13:49 +08:00
Import lwIP contrib rep
... from http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git/ into contrib/ subdir, STABLE-2_1_0_RELEASE tag lwIP contrib is now officially frozen TODO: Fix build
This commit is contained in:
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user