com.h3c.util.snmp

## Class SnmpTarget

- java.lang.Object
- - com.h3c.util.snmp.SnmpTarget

-     public class SnmpTarget
      extends Object

  SNMP Target. This object is immutable to the creator. It is updated internally to store V3 discovery parameters. It is still thread-safe because all the V3 discovery related methods are synchronized. TODO: Important note the engine time is being incremented as time goes by but the engine boots is not. If a SnmpTarget is cached and the device reboots a SNMPv3 discovery must be sent again. Revisit this later or provide documentation. Maybe: fix for PCM is to keep track of when the discovery was made and mark the target stale. Actually what was happening is that the device was rebooted and so the bootCount was out of sync. When traffic issued a set, the device responding with no error but the V3 discovery "report". We will have to handle this and/or document that you can not have long lived SnmpTargets (>= 3 minutes) TODO: The actual fix was to clear out the target cache when a USM_ERROR is detected. Be careful because for walks (bulk or normal) the response VB count does not match the request VB count and you may short circuit the error handling code before you get to the USM_ERROR. This needs to be unit tested: 1) Set up device in V3 with a target 2) Reboot the device 3) Attempt to communicate with the target (should reset and rediscovery engine time and boot counts)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SnmpTarget(SnmpTargetArgs args)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `SnmpRequest` | `createRequest(SnmpRequestListener listener)` Creates a new request based on the SNMP version.
    `SnmpTrapRequest` | `createTrap()` Creates a new trap request based on the SNMP version.
    `boolean` | `equals(Object obj)`
    `Usm.AuthorizationType` | `getAuthorization()`
    `InetAddress` | `getInetAddress()`
    `Usm.PrivacyType` | `getPrivacy()`
    `String` | `getReadCommunity()`
    `int` | `getRequestsSent()`
    `int` | `getSendPort()`
    `int[]` | `getTimeout()`
    `String` | `getUserName()`
    `int` | `getValidResponsesReceived()`
    `SnmpVersionType` | `getVersion()`
    `String` | `getWriteCommunity()`
    `int` | `hashCode()`
    `void` | `incrementRequestsSent()`
    `void` | `incrementValidResponses()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SnmpTarget

          public SnmpTarget(SnmpTargetArgs args)

      Constructor.
      Parameters:
        `args` - SNMP target arguments object

  - ### Method Detail

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### createRequest

          public SnmpRequest createRequest(SnmpRequestListener listener)

      Creates a new request based on the SNMP version.
      Parameters:
        `listener` - SNMP request listener attached to new request
      Returns:
        new SNMP request

    - #### createTrap

          public SnmpTrapRequest createTrap()

      Creates a new trap request based on the SNMP version.
      Returns:
        new SNMP request

    - #### getAuthorization

          public Usm.AuthorizationType getAuthorization()

    - #### getPrivacy

          public Usm.PrivacyType getPrivacy()

    - #### getSendPort

          public int getSendPort()

    - #### getTimeout

          public int[] getTimeout()

    - #### getInetAddress

          public InetAddress getInetAddress()

    - #### getReadCommunity

          public String getReadCommunity()

    - #### getWriteCommunity

          public String getWriteCommunity()

    - #### getUserName

          public String getUserName()

    - #### getVersion

          public SnmpVersionType getVersion()

    - #### incrementRequestsSent

          public void incrementRequestsSent()

    - #### getRequestsSent

          public int getRequestsSent()

    - #### incrementValidResponses

          public void incrementValidResponses()

    - #### getValidResponsesReceived

          public int getValidResponsesReceived()

Copyright © 2014. All Rights Reserved.