コード例 #1
0
 public System.Collections.Generic.Dictionary <string, string> GetTable(TableVarBinding tableVariable)
 {
     return(this.SendPacket(SnmpOperationType.GetTable, tableVariable));
 }
コード例 #2
0
        private System.Collections.Generic.Dictionary <string, string> ReceiveResponseWithTableVB(TableVarBinding tableVb, Pdu pdu, UdpTarget target, IAgentParameters param)
        {
            if (string.IsNullOrEmpty(tableVb.TableEntryOid))
            {
                throw new System.ArgumentNullException("The TableEntryOid can not be null or empty.");
            }
            Oid oid  = new Oid(tableVb.TableEntryOid);
            Oid oid2 = null;

            if (string.IsNullOrEmpty(tableVb.ColumnOid))
            {
                oid2 = (Oid)oid.Clone();
            }
            else
            {
                oid2 = new Oid(tableVb.ColumnOid);
            }
            System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>();
            while (oid2 != null)
            {
                pdu.VbList.Clear();
                pdu.VbList.Add(oid2);
                SnmpPacket snmpPacket = target.Request(pdu, param);
                this.validateResponse(snmpPacket, pdu);
                foreach (Vb current in snmpPacket.Pdu.VbList)
                {
                    if (!oid.IsRootOf(current.Oid))
                    {
                        oid2 = null;
                        break;
                    }
                    if (current.Value.Type == SnmpConstants.SMI_ENDOFMIBVIEW)
                    {
                        oid2 = null;
                        break;
                    }
                    string key = current.Oid.ToString();
                    if (!dictionary.ContainsKey(key))
                    {
                        dictionary.Add(key, current.Value.ToString());
                        oid2 = current.Oid;
                    }
                }
            }
            return(dictionary);
        }