Exemple #1
0
        public static Variable[,] GetTable(VersionCode version, IPEndPoint endpoint, OctetString community, ObjectIdentifier table, int timeout, int maxRepetitions, IObjectRegistry registry)
        {
            if (version == VersionCode.V3)
            {
                throw new NotSupportedException("SNMP v3 is not supported");
            }

            var canContinue = registry == null || registry.ValidateTable(table);
            if (!canContinue)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "not a table OID: {0}", table));
            }

            IList<Variable> list = new List<Variable>();
            var rows = version == VersionCode.V1 ? Walk(version, endpoint, community, table, list, timeout, WalkMode.WithinSubtree) : BulkWalk(version, endpoint, community, table, list, timeout, maxRepetitions, WalkMode.WithinSubtree, null, null);

            if (rows == 0)
            {
                return new Variable[0, 0];
            }

            var cols = list.Count / rows;
            var k = 0;
            var result = new Variable[rows, cols];

            for (var j = 0; j < cols; j++)
            {
                for (var i = 0; i < rows; i++)
                {
                    result[i, j] = list[k];
                    k++;
                }
            }

            return result;
        }
Exemple #2
0
 public string ToString(IObjectRegistry objects)
 {
     return string.Format(
         CultureInfo.InvariantCulture,
         "SNMPv1 trap: {0}",
         ((TrapV1Pdu)_pdu).ToString(objects));
 }
Exemple #3
0
 public string ToString(IObjectRegistry objects)
 {
     return string.Format(
         CultureInfo.InvariantCulture,
         "SNMPv1 TRAP PDU: agent address: {0}; time stamp: {1}; enterprise: {2}; generic: {3}; specific: {4}; varbind count: {5}",
         AgentAddress,
         TimeStamp,
         Enterprise.ToString(objects),
         Generic,
         Specific.ToString(CultureInfo.InvariantCulture),
         Variables.Count.ToString(CultureInfo.InvariantCulture));
 }
Exemple #4
0
 public string ToString(IObjectRegistry objects)
 {
     return string.Format(CultureInfo.InvariantCulture, "Variable: Id: {0}; Data: {1}", Id.ToString(objects), Data);
 }
 public string ToString(IObjectRegistry objects)
 {
     return string.Format(
         CultureInfo.InvariantCulture,
         "SNMPv2 trap: time stamp: {0}; community: {1}; enterprise: {2}; varbind count: {3}",
         TimeStamp.ToString(CultureInfo.InvariantCulture),
         Community,
         Enterprise.ToString(objects),
         Variables.Count.ToString(CultureInfo.InvariantCulture));
 }
        public static string GetStringOf(ObjectIdentifier id, IObjectRegistry objects)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            
            if (objects == null)
            {
                return id.ToString();
            }

            string result = objects.Tree.Search(id.ToNumerical()).AlternativeText;
            return string.IsNullOrEmpty(result) ? id.ToString() : result;
        }
Exemple #7
0
 public string ToString(IObjectRegistry objects)
 {
     return(string.Format(CultureInfo.InvariantCulture, "Variable: Id: {0}; Data: {1}", Id.ToString(objects), Data));
 }
Exemple #8
0
        public static Variable[,] GetTable(VersionCode version, IPEndPoint endpoint, OctetString community, ObjectIdentifier table, int timeout, int maxRepetitions, IObjectRegistry registry)
        {
            if (version == VersionCode.V3)
            {
                throw new NotSupportedException("SNMP v3 is not supported");
            }

            var canContinue = registry == null || registry.ValidateTable(table);

            if (!canContinue)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "not a table OID: {0}", table));
            }

            IList <Variable> list = new List <Variable>();
            var rows = version == VersionCode.V1 ? Walk(version, endpoint, community, table, list, timeout, WalkMode.WithinSubtree) : BulkWalk(version, endpoint, community, table, list, timeout, maxRepetitions, WalkMode.WithinSubtree, null, null);

            if (rows == 0)
            {
                return(new Variable[0, 0]);
            }

            var cols   = list.Count / rows;
            var k      = 0;
            var result = new Variable[rows, cols];

            for (var j = 0; j < cols; j++)
            {
                for (var i = 0; i < rows; i++)
                {
                    result[i, j] = list[k];
                    k++;
                }
            }

            return(result);
        }
 public string ToString(IObjectRegistry objects)
 {
     return string.Format(
         CultureInfo.InvariantCulture,
         "INFORM request message: time stamp: {0}; community: {1}; enterprise: {2}; varbind count: {3}",
         TimeStamp.ToString(CultureInfo.InvariantCulture),
         this.Community(),
         Enterprise.ToString(objects),
         this.Variables().Count.ToString(CultureInfo.InvariantCulture));
 }
Exemple #10
0
 public static string GetTextual(ObjectIdentifier id, IObjectRegistry registry)
 {
     if (id == null)
     {
         throw new ArgumentNullException("id");
     }
     
     IObjectRegistry objects = registry ?? ObjectRegistry.Default;
     return objects.Translate(id.ToNumerical());
 }