Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            Container = new UnityContainer();
            Container.LoadConfiguration("agent");

            _oidControlUnitIp.ControlUnitIpAdded += oidControlUnitIp_ControlUnitIpAdded;

            var oidElements = new List<ScalarObject>();
            oidElements.Add(_oidControlUnitIp);

            _snmpListenerlistener = new SnmpListener(Container, IPAddress.Any, 163);
            _mibTestTreeFactory = new MibTestTreeFactory(oidElements);

            _mibTestTreeFactory.TestValueChanged += TestValueChanged;

            var store = Container.Resolve<ObjectStore>();
            store.Add(new SysDescr());
            store.Add(new SysObjectId());
            store.Add(new SysUpTime());
            store.Add(new SysContact());
            store.Add(new SysName());
            store.Add(new SysLocation());
            store.Add(new SysServices());
            store.Add(new SysORLastChange());
            store.Add(new SysORTable());
            store.Add(_mibTestTreeFactory);

            var users = Container.Resolve<UserRegistry>();
            users.Add(new OctetString("neither"), DefaultPrivacyProvider.DefaultPair);
            users.Add(new OctetString("authen"),
                      new DefaultPrivacyProvider(new MD5AuthenticationProvider(new OctetString("authentication"))));
            users.Add(new OctetString("privacy"), new DESPrivacyProvider(new OctetString("privacyphrase"),
                                                                         new MD5AuthenticationProvider(
                                                                             new OctetString("authentication"))));

            _snmpListenerlistener.StartListen();

            Console.ReadLine();
            _snmpListenerlistener.StopListen();
        }
Ejemplo n.º 2
0
        protected override void OnStart(string[] args)
        {
            _container = new UnityContainer();
            _container.LoadConfiguration("agent");

            var oidStartTest = new OidStartTest();
            oidStartTest.StartTest += mibTestTree_StartTest;

            var oidElements = new List<ScalarObject>();
            oidElements.Add(oidStartTest);

            _mibTestTreeFactory = new MibTestTreeFactory(oidElements);
            _mibTestTreeFactory.TestValueChanged += TestValueChanged;

            var store = _container.Resolve<ObjectStore>();
            store.Add(new SysDescr());
            store.Add(new SysObjectId());
            store.Add(new SysUpTime());
            store.Add(new SysContact());
            store.Add(new SysName());
            store.Add(new SysLocation());
            store.Add(new SysServices());
            store.Add(new SysORLastChange());
            store.Add(new SysORTable());
            store.Add(_mibTestTreeFactory);

            var users = _container.Resolve<UserRegistry>();
            users.Add(new OctetString("neither"), DefaultPrivacyProvider.DefaultPair);
            users.Add(new OctetString("authen"),
                      new DefaultPrivacyProvider(new MD5AuthenticationProvider(new OctetString("authentication"))));
            users.Add(new OctetString("privacy"), new DESPrivacyProvider(new OctetString("privacyphrase"),
                                                                         new MD5AuthenticationProvider(
                                                                             new OctetString("authentication"))));

            _snmpListenerlistener = new SnmpListener(_container, IPAddress.Any, 161);
            _snmpListenerlistener.StartListen();
            _testListener.StartListen();
        }