public SnmpScalarNodeOctetString(SnmpDataType dataType, SnmpTreeNode parentNode)
            : base(parentNode)
        {
            System.Diagnostics.Debug.Assert(
                (dataType == SnmpDataType.OctetString) ||
                (dataType == SnmpDataType.Opaque) ||
                (dataType == SnmpDataType.IpAddress));

            this.DataType = dataType;
        }
Пример #2
0
        public SnmpScalarNodeUint(SnmpDataType dataType, SnmpTreeNode parentNode)
            : base(parentNode)
        {
            System.Diagnostics.Debug.Assert(
                (dataType == SnmpDataType.Counter) ||
                (dataType == SnmpDataType.Gauge) ||
                (dataType == SnmpDataType.TimeTicks));

            this.DataType = dataType;
        }
Пример #3
0
		public SnmpScalarNodeOctetString(SnmpDataType dataType, SnmpTreeNode parentNode)
			: base(parentNode)
		{
			System.Diagnostics.Debug.Assert(
				(dataType == SnmpDataType.OctetString) || 
				 (dataType == SnmpDataType.Opaque) || 
				 (dataType == SnmpDataType.IpAddress));

			this.DataType = dataType;
		}
Пример #4
0
		public SnmpScalarNodeUint(SnmpDataType dataType, SnmpTreeNode parentNode)
			: base(parentNode)
		{
			System.Diagnostics.Debug.Assert(
				(dataType == SnmpDataType.Counter) || 
				 (dataType == SnmpDataType.Gauge) || 
				 (dataType == SnmpDataType.TimeTicks));

			this.DataType = dataType;
		}
Пример #5
0
        public static SnmpScalarNode CreateFromDatatype(SnmpDataType dataType, SnmpTreeNode parentNode)
        {
            switch (dataType)
            {
            case SnmpDataType.Integer:
                return(new SnmpScalarNodeInt(parentNode));

            case SnmpDataType.Gauge:
            case SnmpDataType.Counter:
            case SnmpDataType.TimeTicks:
                return(new SnmpScalarNodeUint(dataType, parentNode));
            }

            return(new SnmpScalarNode(parentNode));
        }
 public SnmpScalarNodeInt(SnmpTreeNode parentNode)
     : base(parentNode)
 {
     this.DataType = SnmpDataType.Integer;
 }
Пример #7
0
 public SnmpScalarNode(SnmpTreeNode parentNode)
     : base(parentNode)
 {
 }
Пример #8
0
		public SnmpScalarNodeTruthValue(SnmpTreeNode parentNode)
			: base(parentNode)
		{
		}
 protected SnmpNode(SnmpTreeNode parentNode)
 {
     this.parentNode = parentNode;
 }
Пример #10
0
		private static SnmpTableNode GenerateSnmpTableNode(MibTreeNode mibTreeNode, SnmpTreeNode parentNode)
		{
			SnmpTableNode result = new SnmpTableNode(parentNode);
			result.Name = mibTreeNode.Entity.Name;
			result.Oid  = mibTreeNode.Entity.Value;

			// expect exactly one row entry
			if ((mibTreeNode.ChildNodes.Count != 1) || ((mibTreeNode.ChildNodes[0].NodeType & MibTreeNodeType.TableRow) == 0) || (mibTreeNode.ChildNodes[0].Entity.Value != 1))
			{
				Console.WriteLine("Found table with unsupported properties! Table needs exactly one (fixed) TableRow with OID=1 ! (" + mibTreeNode.Entity.Name + ")");
				return null;
			}

			MibTreeNode rowNode = mibTreeNode.ChildNodes[0];
			
			ObjectType rot = rowNode.Entity as ObjectType;
			if (rot != null)
			{
				if (!String.IsNullOrWhiteSpace(rot.Augments))
				{
					result.AugmentedTableRow = rot.Augments;

					// the indeces from another table shall be used because this table is only an extension of it
					rot = MibTypesResolver.ResolveDeclaration(rot.Module, rot.Augments) as ObjectType;
				}

				if (rot.Indices != null)
				{
					foreach (string index in rot.Indices)
					{
						ObjectType indexEntity = MibTypesResolver.ResolveDeclaration(rot.Module, index) as ObjectType;
						if (indexEntity == null)
						{
							Console.WriteLine(String.Format("Could not resolve index '{0}' for table '{1}'! Table omitted!", index, result.Name));
							return null;
						}

						result.IndexNodes.Add(GenerateSnmpScalarNode(indexEntity, parentNode, ignoreAccessibleFlag: true));
					}
				}
			}

			if (result.IndexNodes.Count == 0)
			{
				// a table cannot be used without index
				Console.WriteLine("Found table without any index column ! (" + mibTreeNode.Entity.Name + ")");
				return null;
			}

			// add child nodes
			foreach (MibTreeNode cellNode in rowNode.ChildNodes)
			{
				SnmpScalarNode ssn = GenerateSnmpScalarNode(cellNode, parentNode);
				if (ssn != null)
				{
					result.CellNodes.Add(ssn);
				}
			}

			return result;
		}
Пример #11
0
		private static SnmpScalarNode GenerateSnmpScalarNode(ObjectType ote, SnmpTreeNode parentNode, bool ignoreAccessibleFlag = false)
		{
			SnmpScalarNode result;

			ITypeAssignment mibType = ote.BaseType;
			IntegerType it = (mibType as IntegerType);
			if (it != null)
			{
				if (ote.ReferredType.Name == Symbol.TruthValue.ToString())
				{
					result = new SnmpScalarNodeTruthValue(parentNode);
				}
				else if ((it.Type == IntegerType.Types.Integer) || (it.Type == IntegerType.Types.Integer32))
				{
					result = new SnmpScalarNodeInt(parentNode);
				}
				else
				{
					Console.WriteLine(String.Format("Unsupported IntegerType '{0}'!", it.Type));
					return null;
				}
				if (it.IsEnumeration)
				{
					result.Restrictions.AddRange(CreateRestrictions(it.Enumeration));
				}
				else
				{
					result.Restrictions.AddRange(CreateRestrictions(it.Ranges));
				}
			}
			else
			{
				UnsignedType ut = (mibType as UnsignedType);
				if (ut != null)
				{
					if ((ut.Type == UnsignedType.Types.Unsigned32) ||
							  (ut.Type == UnsignedType.Types.Gauge32))
					{
						result = new SnmpScalarNodeUint(SnmpDataType.Gauge, parentNode);
					}
					else if (ut.Type == UnsignedType.Types.Counter32)
					{
						result = new SnmpScalarNodeUint(SnmpDataType.Counter, parentNode);
					}
					else if (ut.Type == UnsignedType.Types.TimeTicks)
					{
						result = new SnmpScalarNodeUint(SnmpDataType.TimeTicks, parentNode);
					}
					else if (ut.Type == UnsignedType.Types.Counter64)
					{
						result = new SnmpScalarNodeCounter64(parentNode);
						if ((ut.Ranges != null) && (ut.Ranges.Count > 0))
						{
							Console.WriteLine(String.Format("Generation of ranges is not supported for Counter64 type!"));
							return null;
						}
					}
					else
					{
						Console.WriteLine(String.Format("Unsupported UnsignedType '{0}'!", ut.Type));
						return null;
					}
					result.Restrictions.AddRange(CreateRestrictions(ut.Ranges));
				}
				else if (mibType is IpAddressType)
				{
					result = new SnmpScalarNodeOctetString(SnmpDataType.IpAddress, parentNode);
					result.Restrictions.AddRange(CreateRestrictions((mibType as OctetStringType).Size));
				}
				else if (mibType is OpaqueType)
				{
					result = new SnmpScalarNodeOctetString(SnmpDataType.Opaque, parentNode);
					result.Restrictions.AddRange(CreateRestrictions((mibType as OctetStringType).Size));
				}
				else if (mibType is OctetStringType)
				{
					result = new SnmpScalarNodeOctetString(SnmpDataType.OctetString, parentNode);
					result.Restrictions.AddRange(CreateRestrictions((mibType as OctetStringType).Size));
				}
				else if (mibType is ObjectIdentifierType)
				{
					result = new SnmpScalarNodeObjectIdentifier(parentNode);
				}
				else if (mibType is BitsType)
				{
					result = new SnmpScalarNodeBits(parentNode, (uint)((mibType as BitsType).Map.GetHighestValue() + 1));
					result.Restrictions.AddRange(CreateRestrictions(mibType as BitsType));
				}
				else
				{
					TypeAssignment ta = mibType as TypeAssignment;
					if (ta != null)
					{
						Console.WriteLine(String.Format("Unsupported BaseType: Module='{0}', Name='{1}', Type='{2}'!", ta.Module.Name, ta.Name, ta.Type));
					}
					else
					{
						Console.WriteLine(String.Format("Unsupported BaseType: Module='{0}', Name='{1}'!", mibType.Module, mibType.Name));
					}
					
					return null;
				}
			}

			result.Name = _alphaNumericRegex.Replace(ote.Name, "").ToLowerInvariant();
			result.Oid  = ote.Value;

			if (ote.Access == MaxAccess.readWrite)
			{
				result.AccessMode = SnmpAccessMode.ReadWrite;
			}
			else if (ote.Access == MaxAccess.readOnly)
			{
				result.AccessMode = SnmpAccessMode.ReadOnly;
			}
			else if (ote.Access == MaxAccess.readCreate)
			{
				result.AccessMode = SnmpAccessMode.ReadOnly;
			}
			else if (ignoreAccessibleFlag && (ote.Access == MaxAccess.notAccessible))
			{
				result.AccessMode = SnmpAccessMode.NotAccessible;
			}
			else
			{
				// not accessible or unsupported accress type
				return null;
			}

			return result;
		}
Пример #12
0
		private static SnmpScalarNode GenerateSnmpScalarNode(MibTreeNode mibTreeNode, SnmpTreeNode parentNode, bool ignoreAccessibleFlag = false)
		{
			ObjectType ote = mibTreeNode.Entity as ObjectType;
			if (ote != null)
			{
				return GenerateSnmpScalarNode(ote, parentNode, ignoreAccessibleFlag);
			}

			return null;
		}
Пример #13
0
		private static SnmpTreeNode GenerateSnmpTreeNode(MibTreeNode mibTreeNode, SnmpTreeNode parentNode)
		{
			SnmpTreeNode result = new SnmpTreeNode(parentNode);
			result.Name    = _alphaNumericRegex.Replace(mibTreeNode.Entity.Name, "").ToLowerInvariant();
			result.Oid     = mibTreeNode.Entity.Value;
			result.FullOid = MibTypesResolver.ResolveOid(mibTreeNode.Entity).GetOidString();

			return result;
		}
Пример #14
0
		private static void ProcessMibTreeNode(MibTreeNode mibTreeNode, SnmpTreeNode assignedSnmpNode)
		{
			foreach (MibTreeNode mtn in mibTreeNode.ChildNodes)
			{
				// in theory container nodes may also be scalars or tables at the same time (for now only process real containers)
				if (mtn.NodeType == MibTreeNodeType.Container)
				{
					SnmpTreeNode snmpTreeNode = GenerateSnmpTreeNode(mtn, assignedSnmpNode);
					assignedSnmpNode.ChildNodes.Add(snmpTreeNode);

					ProcessMibTreeNode(mtn, snmpTreeNode);
				}
				else if ((mtn.NodeType & MibTreeNodeType.Scalar) != 0)
				{
					SnmpScalarNode snmpScalarNode = GenerateSnmpScalarNode(mtn, assignedSnmpNode);
					if (snmpScalarNode != null)
					{
						assignedSnmpNode.ChildNodes.Add(snmpScalarNode);
					}
				}
				else if ((mtn.NodeType & MibTreeNodeType.Table) != 0)
				{
					SnmpTableNode snmpTableNode = GenerateSnmpTableNode(mtn, assignedSnmpNode);
					if (snmpTableNode != null)
					{
						assignedSnmpNode.ChildNodes.Add(snmpTableNode);
					}
				}
			}
		}
Пример #15
0
		public SnmpTableNode(SnmpTreeNode parentNode)
			: base(parentNode)
		{
		}
		public SnmpScalarNodeObjectIdentifier(SnmpTreeNode parentNode)
			: base(parentNode)
		{
			this.DataType = SnmpDataType.ObjectIdentifier;
		}
Пример #17
0
		public SnmpScalarNodeCounter64(SnmpTreeNode parentNode)
			: base(parentNode)
		{
			this.DataType = SnmpDataType.Counter64;
		}
 public SnmpScalarNodeObjectIdentifier(SnmpTreeNode parentNode)
     : base(parentNode)
 {
     this.DataType = SnmpDataType.ObjectIdentifier;
 }
Пример #19
0
		protected SnmpNode(SnmpTreeNode parentNode)
		{
			this.parentNode = parentNode;
		}
 public SnmpScalarNodeTruthValue(SnmpTreeNode parentNode)
     : base(parentNode)
 {
 }
Пример #21
0
 public SnmpScalarArrayNode(List<SnmpScalarNode> scalarNodes, SnmpTreeNode parentNode)
     : base(parentNode)
 {
     this.scalarNodes = scalarNodes;
 }
Пример #22
0
		public SnmpScalarNodeInt(SnmpTreeNode parentNode)
			: base(parentNode)
		{
			this.DataType = SnmpDataType.Integer;
		}
 public SnmpScalarArrayNode(List <SnmpScalarNode> scalarNodes, SnmpTreeNode parentNode)
     : base(parentNode)
 {
     this.scalarNodes = scalarNodes;
 }
Пример #24
0
        public static SnmpScalarNode CreateFromDatatype(SnmpDataType dataType, SnmpTreeNode parentNode)
        {
            switch (dataType)
            {
                case SnmpDataType.Integer:
                    return new SnmpScalarNodeInt(parentNode);

                case SnmpDataType.Gauge:
                case SnmpDataType.Counter:
                case SnmpDataType.TimeTicks:
                    return new SnmpScalarNodeUint(dataType, parentNode);
            }

            return new SnmpScalarNode(parentNode);
        }
Пример #25
0
 public SnmpTableNode(SnmpTreeNode parentNode)
     : base(parentNode)
 {
 }
Пример #26
0
 protected SnmpScalarAggregationNode(SnmpTreeNode parentNode)
     : base(parentNode)
 {
 }
Пример #27
0
		protected SnmpScalarAggregationNode(SnmpTreeNode parentNode)
			: base(parentNode)
		{
		}
Пример #28
0
 public SnmpScalarNode(SnmpTreeNode parentNode)
     : base(parentNode)
 {
 }
Пример #29
0
		public SnmpScalarNodeBits(SnmpTreeNode parentNode, uint bitCount)
			: base(parentNode)
		{
			this.DataType = SnmpDataType.Bits;
			this.bitCount = bitCount;
		}
Пример #30
0
 public SnmpScalarNodeBits(SnmpTreeNode parentNode, uint bitCount)
     : base(parentNode)
 {
     this.DataType = SnmpDataType.Bits;
     this.bitCount = bitCount;
 }
Пример #31
0
 public SnmpScalarNodeCounter64(SnmpTreeNode parentNode)
     : base(parentNode)
 {
     this.DataType = SnmpDataType.Counter64;
 }