verinec.adaptation.snmp
Class CiscoTransmit

java.lang.Object
  extended by verinec.adaptation.snmp.CiscoTransmit

public class CiscoTransmit
extends Object

Collection of methods to send and receive configuration file to/from Cisco router.

Version:
1.0
Author:
christoph.ehret at unifr.ch

Field Summary
static org.snmp4j.smi.OID ccCopyFailCause
          SNMP ID for the the failure reason (if copy state returns 4).
static org.snmp4j.smi.OID ccCopyState
          SNMP ID for the state of this copy.
private  org.snmp4j.smi.OctetString communityName
           
private  org.snmp4j.CommunityTarget comtarget
           
private  String hostIP
           
private  Logger logger
           
static int RUNNING_CONFIG
          Specifies the running-config file as configuration file choice
static int STARTUP_CONFIG
          Specifies the startup-config file as configuration file choice
private  org.snmp4j.smi.Address targetaddress
           
private  org.snmp4j.TransportMapping transport
           
 
Constructor Summary
CiscoTransmit(String remoteIP, String localIP, String communityName, String snmpVersion)
          Creates a CiscoTransmit instance for sending or receiving a config file with snmp version 1 or 2c.
CiscoTransmit(String target, String hostIP, String userName, String securityLevel, String authFunction, String authPasswd, String privFunction, String privPasswd)
          Creates a CiscoTransmit instance for sending or receiving a config file with snmp version 3, which add security aspect to snmp in adding authentication and/or encryption.
 
Method Summary
private  org.snmp4j.smi.VariableBinding[] buildReceivingVb(String targFileName)
          Initialisation of the variable binding for receiving running-config
private  org.snmp4j.smi.VariableBinding[] buildSendingVbRC(String srcFileName)
          Initialisation of the variable binding for running-config
private  org.snmp4j.smi.VariableBinding[] buildSendingVbSC(String srcFileName)
          Initialisation of the variable binding for startup-config file
private  void checkStatus(org.snmp4j.Snmp snmp)
          To check if the sending/receiving was sucessful, i.e does not quit until finished the process
 boolean isListeningT()
          Only for test purposes
 void receiveConfig(String targFileName)
          For receiving the configuration file from Cisco router.
 void secureReceiveConfig()
          Still have to be implemented !!
 void secureSendConfig(int choice)
          Still have to be implemented !!
 void sendConfig(int configType, String srcFileName)
          Sends running-config or startup-config file, depending on choice This will be used to send a config file when using snmp version 1 or 2c
private  void sendResetRow(int row, org.snmp4j.Snmp snmp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ccCopyState

public static final org.snmp4j.smi.OID ccCopyState
SNMP ID for the state of this copy.


ccCopyFailCause

public static final org.snmp4j.smi.OID ccCopyFailCause
SNMP ID for the the failure reason (if copy state returns 4).


targetaddress

private org.snmp4j.smi.Address targetaddress

communityName

private org.snmp4j.smi.OctetString communityName

hostIP

private String hostIP

transport

private org.snmp4j.TransportMapping transport

comtarget

private org.snmp4j.CommunityTarget comtarget

RUNNING_CONFIG

public static final int RUNNING_CONFIG
Specifies the running-config file as configuration file choice

See Also:
Constant Field Values

STARTUP_CONFIG

public static final int STARTUP_CONFIG
Specifies the startup-config file as configuration file choice

See Also:
Constant Field Values

logger

private Logger logger
Constructor Detail

CiscoTransmit

public CiscoTransmit(String remoteIP,
                     String localIP,
                     String communityName,
                     String snmpVersion)
              throws VerinecException
Creates a CiscoTransmit instance for sending or receiving a config file with snmp version 1 or 2c.

Parameters:
remoteIP - IP address of the Cisco router
localIP - IP address of the host
communityName - Community name that have to be used with snmp version 1 or 2c
snmpVersion - SNMP version to use : v1 or v2c
Throws:
VerinecException - Throws VerinecException if could not create the transport channel

CiscoTransmit

public CiscoTransmit(String target,
                     String hostIP,
                     String userName,
                     String securityLevel,
                     String authFunction,
                     String authPasswd,
                     String privFunction,
                     String privPasswd)
              throws VerinecException
Creates a CiscoTransmit instance for sending or receiving a config file with snmp version 3, which add security aspect to snmp in adding authentication and/or encryption.

Parameters:
target - IP address of the Cisco router
hostIP - IP address of the host
userName - User name that have to be used for snmp version 3
securityLevel - Specifies the security level to use :
  • NOAUTH_NOPRIV : no authentication, no privacy
  • AUTH_NOPRIV : authentication, no privacy
  • AUTH_PRIV : authentication, privacy
authFunction - Cryptography function to use for authentication : MD5 | SHA
authPasswd - Choosen password for authentication
privFunction - Cryptography function to use for encryption : AES128 | AES192 | AES256 | DES
privPasswd - Choosen password for encryption
Throws:
VerinecException - Throws VerinecException if could not create the transport channel
Method Detail

buildSendingVbSC

private org.snmp4j.smi.VariableBinding[] buildSendingVbSC(String srcFileName)
Initialisation of the variable binding for startup-config file

Parameters:
srcFileName - The filename of configuration to send relative to the tftp root folder
Returns:
List of variables to initiate a file download to the cisco device.

buildSendingVbRC

private org.snmp4j.smi.VariableBinding[] buildSendingVbRC(String srcFileName)
Initialisation of the variable binding for running-config

Parameters:
srcFileName - The filename of configuration to send relative to the tftp root folder
Returns:
List of variables to initiate a file download to the cisco device.

buildReceivingVb

private org.snmp4j.smi.VariableBinding[] buildReceivingVb(String targFileName)
Initialisation of the variable binding for receiving running-config

Parameters:
targFileName - The filename where the cisco has to store the configuration to. Relative to tftp root folder.
Returns:
List of variables to initiate a file upload by the cisco device.

sendResetRow

private void sendResetRow(int row,
                          org.snmp4j.Snmp snmp)
                   throws VerinecException
Throws:
VerinecException

checkStatus

private void checkStatus(org.snmp4j.Snmp snmp)
                  throws VerinecException
To check if the sending/receiving was sucessful, i.e does not quit until finished the process

Parameters:
snmp - The connection
Throws:
VerinecException - On communication error

sendConfig

public void sendConfig(int configType,
                       String srcFileName)
                throws VerinecException
Sends running-config or startup-config file, depending on choice

This will be used to send a config file when using snmp version 1 or 2c

Parameters:
configType - To decide if sending running-config or startup-config file
srcFileName - File that have to be sent to the router (can be NULL for receiving). local to the root directory of the tftp server
Throws:
VerinecException - If it is not possible to listen on the givent transport channel
See Also:
RUNNING_CONFIG, STARTUP_CONFIG

secureSendConfig

public void secureSendConfig(int choice)
Still have to be implemented !! Sends running-config or startup-config file, depending on choice

This will actually be used to send a config file when using snmp version 3

Parameters:
choice - To decide if sending running-config or startup-config file
See Also:
RUNNING_CONFIG, STARTUP_CONFIG

receiveConfig

public void receiveConfig(String targFileName)
                   throws VerinecException
For receiving the configuration file from Cisco router. Copies the running-config from Cisco router to local machine. Expects tftp to be running, filename is determined by the CiscoTransmit constructor.

Uses snmp version 1 or 2c to tell cisco to upload the config file

Parameters:
targFileName - Target file name for the upload, relative to tftp server root.
Throws:
VerinecException - If impossible to listen on the transport chanel or problems to receive the configuration file

secureReceiveConfig

public void secureReceiveConfig()
Still have to be implemented !! For receiving the configuration file from Cisco router.

This will actually be used to receive a config file when using snmp version 3


isListeningT

public boolean isListeningT()
Only for test purposes

Returns:
Whether transport is listening.

Copyright © 2005 Verinec, DIUF