예제 #1
0
 private System.Collections.Generic.List <SnmpConfiger> createSnmpConfig(System.Collections.Generic.List <string> ips)
 {
     System.Collections.Generic.List <SnmpConfiger> list = new System.Collections.Generic.List <SnmpConfiger>();
     foreach (string current in ips)
     {
         SnmpConfig snmpConfig;
         if (this.snmpCfg.snmpVer == 0)
         {
             snmpConfig = new SnmpV1Config(current);
             ((SnmpV1Config)snmpConfig).Community = this.snmpCfg.userName;
         }
         else
         {
             if (this.snmpCfg.snmpVer == 1)
             {
                 snmpConfig = new SnmpV2Config(current);
                 ((SnmpV2Config)snmpConfig).Community = this.snmpCfg.userName;
             }
             else
             {
                 snmpConfig = new SnmpV3Config(current);
                 SnmpV3Config snmpV3Config = snmpConfig as SnmpV3Config;
                 snmpV3Config.UserName       = this.snmpCfg.userName;
                 snmpV3Config.Authentication = (Authentication)System.Enum.Parse(typeof(Authentication), this.snmpCfg.authType);
                 snmpV3Config.AuthSecret     = this.snmpCfg.authPSW;
                 snmpV3Config.Privacy        = (Privacy)System.Enum.Parse(typeof(Privacy), this.snmpCfg.privType);
                 snmpV3Config.PrivacySecret  = this.snmpCfg.privPSW;
             }
         }
         snmpConfig.Port    = this.snmpCfg.devPort;
         snmpConfig.Retry   = this.snmpCfg.retry;
         snmpConfig.Timeout = this.snmpCfg.timeout;
         SnmpConfiger item = new SnmpConfiger(snmpConfig);
         list.Add(item);
     }
     return(list);
 }
예제 #2
0
        public SnmpConfig getSnmpConfig(DevSnmpConfig snmpCfg)
        {
            SnmpConfig snmpConfig = null;

            switch (snmpCfg.snmpVer)
            {
            case 0:
                snmpConfig = new SnmpV1Config(snmpCfg.devIP);
                ((SnmpV1Config)snmpConfig).Community = snmpCfg.userName;
                ((SnmpV1Config)snmpConfig).Retry     = snmpCfg.retry;
                ((SnmpV1Config)snmpConfig).Port      = snmpCfg.devPort;
                ((SnmpV1Config)snmpConfig).Timeout   = snmpCfg.timeout;
                break;

            case 1:
                snmpConfig = new SnmpV2Config(snmpCfg.devIP);
                ((SnmpV2Config)snmpConfig).Community = snmpCfg.userName;
                ((SnmpV2Config)snmpConfig).Retry     = snmpCfg.retry;
                ((SnmpV2Config)snmpConfig).Port      = snmpCfg.devPort;
                ((SnmpV2Config)snmpConfig).Timeout   = snmpCfg.timeout;
                break;

            case 3:
                snmpConfig         = new SnmpV3Config(snmpCfg.devIP);
                snmpConfig.Retry   = snmpCfg.retry;
                snmpConfig.Timeout = snmpCfg.timeout;
                snmpConfig.Port    = snmpCfg.devPort;
                ((SnmpV3Config)snmpConfig).Authentication = (Authentication)System.Enum.Parse(typeof(Authentication), snmpCfg.authType);
                ((SnmpV3Config)snmpConfig).AuthSecret     = snmpCfg.authPSW;
                ((SnmpV3Config)snmpConfig).Privacy        = (Privacy)System.Enum.Parse(typeof(Privacy), snmpCfg.privType);
                ((SnmpV3Config)snmpConfig).PrivacySecret  = snmpCfg.privPSW;
                ((SnmpV3Config)snmpConfig).UserName       = snmpCfg.userName;
                break;
            }
            return(snmpConfig);
        }
예제 #3
0
 public SnmpV1Session(SnmpV1Config config) : base(config)
 {
 }