Class TimeWindow
getCurrent()
method to access any other method, i.e.
if (TimeWindow.getCurrent() == null) { TimeWindow timew = new TimeWindow(); } boolean known = TimeWindow.getCurrent().isSnmpEngineIdKnown(hostaddr, port);
This class contains two lookup tables. One that maps the host address+port onto the SNMP engine ID and one that keeps the SNMP engine ID with the timeline details about this engine.
- Version:
- $Revision: 3.15 $ $Date: 2007/04/12 12:55:28 $
- Author:
- Birgit Arkesteijn
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The maximum number of seconds the engine time in the PDU is allowed to differ from my estimated engine time. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clearTimeWindow
(String snmpEngineId) Clear all timing information for the given engine ID.static TimeWindow
Returns the current reference to this class.getSnmpEngineId
(String hostaddr, int port) Returns the snmp engine ID.boolean
isEngineIdOK
(String hostaddr, int port, String snmpEngineId) Checks if the engine ID is OK.boolean
isOutsideTimeWindow
(String snmpEngineId, int bootsA, int timeA) Returns if the time details are outside the time window.boolean
isSnmpEngineIdKnown
(String hostaddr, int port) Returns if the snmp engine ID is known.boolean
isTimeLineKnown
(String snmpEngineId) Returns if the timeline details of this snmp engine ID are known.void
setSnmpEngineId
(String hostaddr, int port, String snmpEngineId) Sets the SNMP engine ID that belongs to the specified hostaddr and port.toString()
Returns the string representation.boolean
updateTimeWindow
(String snmpEngineId, int bootsA, int timeA, boolean isAuthentic) Tries to update the time window and returns if succeeded.
-
Field Details
-
MaxTimeDifference
public static final int MaxTimeDifferenceThe maximum number of seconds the engine time in the PDU is allowed to differ from my estimated engine time. Values150
.- See Also:
-
-
Constructor Details
-
TimeWindow
public TimeWindow()Constructor.
-
-
Method Details
-
getCurrent
Returns the current reference to this class. TimeWindow should be created only once. Use this method to access any other method, i.e.if (TimeWindow.getCurrent() == null) { TimeWindow timew = new TimeWindow(); } boolean known = TimeWindow.getCurrent().isSnmpEngineIdKnown(hostaddr, port);
- Returns:
- the current time window
-
getSnmpEngineId
Returns the snmp engine ID. This method will lookup the engine ID based on the host address and port. If it the engine ID is not known, null will be returned.- Parameters:
hostaddr
- The host address of the engine IDport
- The port number of the engine ID- Returns:
- the snmp engine ID
- See Also:
-
isSnmpEngineIdKnown
Returns if the snmp engine ID is known. This method will lookup if the engine ID belonging to this hostaddr and port is known.When the SNMP engine ID is known, this doesn't necessarily mean that the timeline details of this engine ID are known, since it takes a second discovery step to find out.
- Parameters:
hostaddr
- The host address of the engine IDport
- The port number of the engine ID- Returns:
- whether the snmp engine ID is known
-
setSnmpEngineId
Sets the SNMP engine ID that belongs to the specified hostaddr and port. The old SNMP engine ID (if any) will be overwritten.- Parameters:
hostaddr
- The host address of the engine IDport
- The port number of the engine IDsnmpEngineId
- The engine ID
-
isEngineIdOK
Checks if the engine ID is OK. If there is no engine ID known for this hostaddr and port, the specified engine ID is added to the table.If there is already an engine ID for this hostaddr and port, the method returns true if the specified engine ID is the same as the existing one, and false if they differ. In the latter case the engine ID in the table is not updated.
- Parameters:
hostaddr
- The host address of the engine IDport
- The port number of the engine IDsnmpEngineId
- The engine ID- Returns:
- whether the engine ID matches the stored engine ID
- See Also:
-
isTimeLineKnown
Returns if the timeline details of this snmp engine ID are known.- Parameters:
snmpEngineId
- The engine ID- Returns:
- whether the timeline details are known
-
isOutsideTimeWindow
Returns if the time details are outside the time window. When a response or report is received, the stack first checks the time window before updating it. It always does an update afterwards, even if the message was outside the time window!- Parameters:
snmpEngineId
- The SNMP engine IDbootsA
- The SNMP engine bootstimeA
- The SNMP engine time- Returns:
- true if outside or when no details can be found, false if inside time window
- See Also:
-
updateTimeWindow
Tries to update the time window and returns if succeeded. When a response or report is received, first check the time window before updating it.An update will only occur if the message was authentic and the bootsA and timeA meet the requirements. New data will be inserted if the (bootsA > 0), irrespectively whether the message was authentic or not.
- Parameters:
snmpEngineId
- The SNMP engine IDbootsA
- The SNMP engine bootstimeA
- The SNMP engine time- Returns:
- true if update succeeded, or false when not succeeded or when no details could be found.
- See Also:
-
clearTimeWindow
Clear all timing information for the given engine ID. This stinks, but occasionally the router's time window will slip outside of the acceptable window or will reboot without updating its "reboots" parameter. If you care more about security than functionality then never ever use this. Added on request of Steve A Cochran (steve@more.net).- Parameters:
snmpEngineId
- The engine to clear- Since:
- 5_2
-
toString
Returns the string representation.
-