com.cisco.provisioning.cpe.extensions.configuration
Class TFTPFilename

java.lang.Object
  extended by com.cisco.provisioning.cpe.extensions.configuration.TFTPFilename

public final class TFTPFilename
extends Object

TFTPFilename helper class. This class provides methods to encode and decode compressed TFTP filenames. DHCP-based devices that use TFTP to request their configuration files typically specify the filename in the DHCPConfig "file" field and/or "boot-file" option. If the configuration file is stored within the TFTPConfig object in the ConfigContext it is necessary to include the device identifier, provisioning group, (optionally) the filename identifier in this filename. The DPE TFTP server uses this information to locate the ConfigContext which contains the TFTPConfig TFTPFile object that is sent to a device.

Due to limitations in the filename length and contents supported by devices it is necessary to compress the TFTP filename. This class encapsulates the TFTP filename encoding/decoding algorithm. RDU configuration extensions should use this helper class to create the file/boot-file filenames that they populate into the DHCPConfig. RDU configuration extension authors should take care to use file identifiers that do not exceed the maximum supported filename length for their devices.

See Also:
DHCPConfig, TFTPConfig, TFTPFile

Method Summary
static TFTPFilename decodeFilename(String encodedFilename)
          Decodes an encoded TFTP filename.
static String encodeFilename(com.cisco.provisioning.cpe.api.DeviceID deviceID, Integer provGroupNumericID)
          Create an encoded TFTP filename with the given device ID.
static String encodeFilename(com.cisco.provisioning.cpe.api.DeviceID deviceID, Integer provGroupNumericID, String filename)
          Create an encoded TFTP filename with the given device ID.
static String encodeOldFilename(com.cisco.provisioning.cpe.api.MACAddress deviceID, Integer provGroupNumericID)
          Create an old format encoded TFTP filename.
static String encodeOldFilename(com.cisco.provisioning.cpe.api.MACAddress deviceID, Integer provGroupNumericID, String filename)
          Create an old format encoded TFTP filename.
 com.cisco.provisioning.cpe.api.DeviceID getDeviceID()
          Get the device ID value.
 String getEncodedFilename()
          Get the encoded filename string.
 String getFilename()
          Get the file ID
 Integer getProvGroupNumericID()
          Get the prov group ID
static boolean isDynamicFile(String filename)
          Returns true if the given filename is a dynamic encoded filename.
static boolean isPacketCableFile(String filename)
          Returns true if the given filename is a PacketCable encoded filename.
 String toString()
          Return human-readable string containing contents of TFTPFilename.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

isPacketCableFile

public static boolean isPacketCableFile(String filename)
Returns true if the given filename is a PacketCable encoded filename. Otherwise returns false.

Parameters:
filename - the encoded filename.
Returns:
true if the given filename is a PacketCable encoded filename.

isDynamicFile

public static boolean isDynamicFile(String filename)
Returns true if the given filename is a dynamic encoded filename. Otherwise returns false.

Parameters:
filename - the encoded filename.
Returns:
true if the given filename is a dynamic encoded filename.

encodeFilename

public static String encodeFilename(com.cisco.provisioning.cpe.api.DeviceID deviceID,
                                    Integer provGroupNumericID)
Create an encoded TFTP filename with the given device ID. Use this method is there is only one TFTPFile object in the TFTPConfig object and the DPEs in the provisioning group are updated.

Parameters:
deviceID - the device identifer for the TFTPFile.
provGroupNumericID - the prov group ID for the device
Returns:
String encoded filename string
Throws:
IllegalArgumentException - if deviceID or provGroupNumericID is null or invalid

encodeFilename

public static String encodeFilename(com.cisco.provisioning.cpe.api.DeviceID deviceID,
                                    Integer provGroupNumericID,
                                    String filename)
Create an encoded TFTP filename with the given device ID. Use this method is there is more than one TFTPFile object within the TFTPConfig and the DPEs in the provisioning group are updated.. The file ID parameter must match the name assigned to the TFTPFile object.

Parameters:
deviceID - the device identifer for the TFTPFile.
provGroupNumericID - the prov group ID for the device
filename - the file ID
Returns:
String encoded filename
Throws:
IllegalArgumentException - if deviceID or provGroupNumericID is null or invalid

encodeOldFilename

public static String encodeOldFilename(com.cisco.provisioning.cpe.api.MACAddress deviceID,
                                       Integer provGroupNumericID)
Create an old format encoded TFTP filename. Use this method is there is only one TFTPFile object in the TFTPConfig object and the DPEs in the provisioning group are not yet updated.

Parameters:
deviceID - the device identifer for the TFTPFile. Must be a MAC address.
provGroupNumericID - the prov group ID for the device
Returns:
String encoded filename string
Throws:
IllegalArgumentException - if deviceID or provGroupNumericID is null or invalid

encodeOldFilename

public static String encodeOldFilename(com.cisco.provisioning.cpe.api.MACAddress deviceID,
                                       Integer provGroupNumericID,
                                       String filename)
Create an old format encoded TFTP filename. Use this method is there is more than one TFTPFile object within the TFTPConfig and the DPEs in the provisioning group are not yet updated.. The file ID parameter must match the name assigned to the TFTPFile object.

Parameters:
deviceID - the device identifer for the TFTPFile. Must be a MAC address.
provGroupNumericID - the prov group ID for the device
filename - the file ID
Returns:
String encoded filename
Throws:
IllegalArgumentException - if deviceID or provGroupNumericID is null or invalid

decodeFilename

public static TFTPFilename decodeFilename(String encodedFilename)
Decodes an encoded TFTP filename.

Parameters:
encodedFilename - The encoded file name
Returns:
TFTPFilename object. Use accessor methods to retrieve the decoded deviceID, provGroup ID, and file ID values
Throws:
IllegalArgumentException - if encodedFilename is null or invalid

getDeviceID

public com.cisco.provisioning.cpe.api.DeviceID getDeviceID()
Get the device ID value.

Returns:
String device ID

getProvGroupNumericID

public Integer getProvGroupNumericID()
Get the prov group ID

Returns:
Integer prov group ID

getFilename

public String getFilename()
Get the file ID

Returns:
String file ID, or null if no file ID is found

getEncodedFilename

public String getEncodedFilename()
Get the encoded filename string.

Returns:
String encoded filename string

toString

public String toString()
Return human-readable string containing contents of TFTPFilename. For debugging purposes only.

Overrides:
toString in class Object
Returns:
String representing values of TFTPFilename