public override bool HandleMembership() { var request = Request; var parameters = request.Parameters; var typeCode = Request.TypeCode(); if (typeCode == SnmpType.Unknown) { HandleFailure(Group.DecryptionError); return(false); } if (typeCode != SnmpType.TrapV2Pdu && parameters.EngineId != Group.EngineId) { HandleDiscovery(); return(true); } var user = Users.Find(parameters.UserName); if (user == null) { HandleFailure(Group.UnknownSecurityName); return(false); } if (typeCode == SnmpType.TrapV2Pdu && (user.EngineIds == null || !user.EngineIds.Contains(parameters.EngineId))) { HandleFailure(Group.UnknownEngineId); return(false); } if (parameters.IsInvalid) { HandleFailure(Group.AuthenticationFailure); return(false); } if (typeCode == SnmpType.TrapV2Pdu) { return(true); } if ((user.ToSecurityLevel() | Levels.Reportable) != request.Header.SecurityLevel) { HandleFailure(Group.UnsupportedSecurityLevel); return(false); } var inTime = EngineGroup.IsInTime(Group.EngineTimeData, parameters.EngineBoots.ToInt32(), parameters.EngineTime.ToInt32()); if (!inTime) { HandleFailure(Group.NotInTimeWindow); return(false); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="SnmpContextBase"/> class. /// </summary> /// <param name="request">The request.</param> /// <param name="sender">The sender.</param> /// <param name="users">The users.</param> /// <param name="group">The engine core group.</param> /// <param name="binding">The binding.</param> protected SnmpContextBase(ISnmpMessage request, IPEndPoint sender, UserRegistry users, EngineGroup group, IListenerBinding binding) { Request = request; Binding = binding; Users = users; Sender = sender; CreatedTime = DateTime.Now; Group = group; }
/// <summary> /// Creates the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="sender">The sender.</param> /// <param name="users">The users.</param> /// <param name="group">The engine group.</param> /// <param name="binding">The binding.</param> /// <returns></returns> public static ISnmpContext Create(ISnmpMessage request, IPEndPoint sender, UserRegistry users, EngineGroup group, IListenerBinding binding) { if (request.Version == VersionCode.V3) { return(new SecureSnmpContext(request, sender, users, group, binding)); } return(new NormalSnmpContext(request, sender, users, binding)); }
/// <summary> /// Initializes a new instance of the <see cref="SnmpEngine"/> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="listener">The listener.</param> /// <param name="group">Engine core group.</param> public SnmpEngine(SnmpApplicationFactory factory, Listener listener, EngineGroup group) { _factory = factory; Listener = listener; _group = group; }
/// <summary> /// Initializes a new instance of the <see cref="SecureSnmpContext"/> class. /// </summary> /// <param name="request">The request.</param> /// <param name="sender">The sender.</param> /// <param name="users">The users.</param> /// <param name="group">The engine core group.</param> /// <param name="binding">The binding.</param> public SecureSnmpContext(ISnmpMessage request, IPEndPoint sender, UserRegistry users, EngineGroup group, IListenerBinding binding) : base(request, sender, users, group, binding) { }