Cisco Packet Tracer Extensions API 8.1.0
API for communication between Cisco Packet Tracer application and its extension applications and modules.
Public Member Functions | List of all members
CiscoDevice Class Reference

CiscoDevice is any Cisco-branded device with a terminal line. More...

Inheritance diagram for CiscoDevice:
Device ASA Router WirelessRouter

Public Member Functions

void setHostName (string)
 Sets the hostname of this device with the specified string. More...
 
string getHostName ()
 Returns the hostname of this device. More...
 
void setEnableSecret (string)
 Sets the encrypted enable secret password with the specified string. More...
 
string getEnableSecret ()
 Returns the encrypted enable secret string. More...
 
void setEnablePassword (string, int)
 Sets the enable password. More...
 
string getEnablePassword ()
 Returns the enable password. More...
 
void setStartupFile (string)
 Sets the startup file to the specified file. More...
 
vector< string > getStartupFile ()
 Returns the contents of the current startup file. More...
 
bool addBootSystem (string)
 Modifies the system parameters to add a particular boot system image. More...
 
bool removeBootSystem (string)
 Removes the specified boot system from this device. More...
 
void removeAllBootSystem ()
 Removes all boot system images from this device. More...
 
vector< BootSystemEntrygetBootSystems ()
 Returns the list of current boot system images. More...
 
short getConfigRegister ()
 Returns the current config register. More...
 
void setNextConfigRegister (short)
 Sets the next config register. More...
 
short getNextConfigRegister ()
 Returns the next config register. More...
 
void setBannerMotd (string)
 Sets the message of the day banner when the device boots. More...
 
string getBannerMotd ()
 Returns the message of the day banner. More...
 
void setTimeZone (string, short, short)
 Sets the timezone for this device. More...
 
string getTimeZone ()
 Returns the timezone of this device. More...
 
mac getBia ()
 Returns the burned-in address of this device. More...
 
void setServicePasswordEncryption (bool)
 Enables or disables service password encryption. More...
 
bool getServicePasswordEncryption ()
 Returns true if service password encryption is enabled, otherwise false. More...
 
Port getConsole ()
 Returns the console port of this device. More...
 
TerminalLine getConsoleLine ()
 Returns the console line of this device. More...
 
TerminalLine getVtyLine (int)
 Returns the vty line specified by num. More...
 
TerminalLine getLine (int)
 Returns the line specified by num. More...
 
TerminalLine getIpcTerminalLine ()
 Returns the IPC terminal line of this device. More...
 
pair< CommandStatus, string > enterCommand (string, string)
 Enters the specified command in the specified mode to the terminal. More...
 
bool isBooting ()
 Checks whether the device is currently booting. More...
 
void skipBoot ()
 Skips the booting process. More...
 
void doneBooting ()
 This event is emitted when the device is done booting. More...
 
void setFtpUsername (string)
 Sets the FTP username for the device. More...
 
void setFtpPasswd (string, int)
 Sets the FTP password for the device. More...
 
string getFtpUsername ()
 Returns the FTP username for the device. More...
 
string getFtpPasswd ()
 Returns the FTP password for the device. More...
 
void clearFtpUsername ()
 Clears the current FTP username. More...
 
void clearFtpPasswd ()
 Clears the current FTP password. More...
 
int getUserPassCount ()
 Returns the number of authenticated users. More...
 
void addUserPassEntry (string, string, int)
 Adds an authenticated user with the specified username, password, and type. More...
 
void removeUserPassEntry (string)
 Removes the authenticated user with the specified username. More...
 
string getUserEntryAt (int)
 Returns the username of the authenticated user at the specified index. More...
 
void removeUserPassAt (int)
 Removes the username of the authenticated user at the specified index. More...
 
bool isUserExist (string)
 Returns true if the specified authenticated user exists, otherwise false. More...
 
void lineConnected (int, ip, short, LoginMethod)
 This event is emitted when a terminal line has connected. More...
 
void lineDisconnected (int)
 This event is emitted when a terminal line has disconnected. More...
 
void lineAuthenticationStarted (int, ip, short, LoginMethod)
 This event is emitted when a terminal line has started authentication. More...
 
void lineAuthenticationFailed (int)
 This event is emitted when a terminal line failed authentication. More...
 
void lineAuthenticationFinished (int, bool)
 This event is emitted when a terminal line finished authentication. More...
 
void closeTableEvent ()
 IPC event. More...
 
- Public Member Functions inherited from Device
void setName (QString)
 Sets the display name of this device. More...
 
QString getName ()
 Returns the display name of this device. More...
 
void nameChanged (QString, QString)
 IPC event. More...
 
void setPower (bool)
 Sets the power on or off. More...
 
void addSound (QString, QString)
 Adds sound to the device. More...
 
void playSound (QString, int)
 Play sound to the device. More...
 
void stopSound (QString)
 Stop playing sound on the device. More...
 
void stopSounds ()
 Stops playing all sounds on the device. More...
 
void destroySounds ()
 Destroy all of the sounds on the device. More...
 
bool getPower ()
 Returns the current power state of this device. More...
 
double getXCoordinate ()
 Returns the current x-coordinate position in the Logical workspace for this device. More...
 
double getYCoordinate ()
 Returns the current y-coordinate position in the Logical workspace for this device. More...
 
double getCenterXCoordinate ()
 Returns the current x-coordinate position in the Logical workspace for this device. More...
 
double getCenterYCoordinate ()
 Returns the current y-coordinate position in the Logical workspace for this device. More...
 
double getAreaTopY ()
 Returns the current topmost y-coordinate position in the for this device. More...
 
double getAreaLeftX ()
 Returns the current leftmost x-coordinate position in the for this device. More...
 
bool moveToLocationCentered (int, int)
 Moves this device to the specified location for its center in Logical workspace. More...
 
bool moveToLocation (int, int)
 Moves this device to the specified location in Logical workspace. More...
 
int getXPhysicalWS ()
 Returns the current x-coordinate position in the Physical workspace for this device. More...
 
int getYPhysicalWS ()
 Returns the current y-coordinate position in the Physical workspace for this device. More...
 
double getGlobalXPhysicalWS ()
 Returns the current global x-coordinate position in the Physical workspace for this device. More...
 
double getGlobalYPhysicalWS ()
 Returns the current global y-coordinate position in the Physical workspace for this device. More...
 
bool moveToLocInPhysicalWS (int, int)
 Moves this device to the specified location in Physical workspace. More...
 
bool moveByInPhysicalWS (int, int)
 Moves this device by the specified amount in Physical workspace. More...
 
void powerChanged (bool)
 IPC event. More...
 
void poweringOff ()
 IPC event. More...
 
DeviceType getType ()
 Returns the type of this device. More...
 
string getModel ()
 Returns the model of this device. More...
 
DeviceDescriptor getDescriptor ()
 Returns the device descriptor that user can get information on the device like type, model, module supported.. More...
 
string getSerialNumber ()
 Returns the device serial number. More...
 
Port getPort (string)
 Returns the Port object with the specified port name. More...
 
int getPortCount ()
 Returns the number of ports in this device. More...
 
Port getPortAt (int)
 Returns the Port object at the specified index. More...
 
Process getProcess (string)
 Returns the Process object associated the process name. More...
 
int getUsbPortCount ()
 Return the number of usb port. More...
 
UsbPort getUsbPortAt (int)
 Returns the usb port at a specified index. More...
 
Module getRootModule ()
 Returns the root module of the device. More...
 
bool addModule (string, ModuleType, string)
 Adds a specific module to a particular slot. More...
 
bool removeModule (string)
 Removes the module from the slot. More...
 
void moduleAdded (ModuleType, string, string)
 This event is emitted when a module is added. More...
 
void moduleRemoved (ModuleType, string, string)
 This event is emitted when a module is removed. More...
 
void portAdded (string)
 This event is emitted when a port is added. More...
 
void portRemoved (string)
 This event is emitted when a port is removed. More...
 
void portRemoving (string)
 This event is emitted when a port is being removed but before it is actually removed. This is useful for script modules to clean up things before the port is removed. More...
 
TerminalLine getCommandLine ()
 Returns the command line TerminalLine object. More...
 
void addCustomVar (QString, QString)
 Adds a custom variable. More...
 
bool removeCustomVar (QString)
 Removes a custom variable. More...
 
bool hasCustomVar (QString)
 Returns true if this device has a custom variable with the specified name. More...
 
QString getCustomVarStr (QString)
 Returns the value of the variable with the specified name. More...
 
int getCustomVarsCount ()
 Returns the number of custom variables this device has. More...
 
QString getCustomVarNameAt (int)
 Returns the name of the custom variable at the specified index. More...
 
QString getCustomVarValueStrAt (int)
 Returns the value of the custom variable at the specified index. More...
 
void setCustomInterface (QString)
 Set custom interface to the device. More...
 
QString getCustomInterface ()
 Get custom interface name on the device. More...
 
QString serializeToXml ()
 Returns the serialization string of this device. More...
 
QString activityTreeToXml ()
 Returns the serialization string of this device's activity tree. More...
 
PhysicalObject getPhysicalObject ()
 Get custom interface name on the device. More...
 
QString getCustomLogicalImage ()
 Get custom logical image path. More...
 
void setCustomLogicalImage (QString)
 Set custom logical image path. More...
 
QString getCustomPhysicalImage ()
 Get custom physical image path. More...
 
void setCustomPhysicalImage (QString)
 Set custom physical image path. More...
 
vector< string > getSupportedModule ()
 Get a vector of supported modules. More...
 
void setTime (int, int, int, int, int, int)
 Set time to the device. More...
 
long getUpTime ()
 Set time to the device. More...
 
vector< string > getPorts ()
 Set time to the device. More...
 
double getDeviceExternalAttributeValue (string)
 Get device external attribute value. More...
 
void setDeviceExternalAttributes (QString)
 Set device external attribute value. More...
 
void addDeviceExternalAttributes (QString)
 Add device external attribute value. More...
 
void subtractDeviceExternalAttributes (QString)
 Remove some of the device external attribute value pairs from the current list. More...
 
QString getDeviceExternalAttributes ()
 Returns the list of external attributes and associated values. More...
 
void clearDeviceExternalAttributes ()
 
bool isOutdated ()
 
bool restoreToDefault (bool, bool)
 
void updateTemplateCreationTime ()
 
bool runProject (string, string)
 Runs a programming project in the mcu. More...
 
bool stopProject (string)
 Stops a programming project in the mcu. More...
 
bool isProjectRunning (string)
 Checks if a programming project with the given name is running. More...
 
bool runCodeInProject (string, string)
 Runs additional code in the given project. More...
 
void addProgrammingSerialOutputs (string)
 Writes to the programming output. Text appears in the programming output dialog. More...
 
string getProgrammingSerialOutputs ()
 Gets the programming output. It is the text that appears in the programming output dialog. More...
 
void clearProgrammingSerialOutputs ()
 Clears the programming output dialog. More...
 
UserDesktopAppConfig addUserDesktopApp (string)
 
UserDesktopAppConfig addUserDesktopAppFrom (UserDesktopAppConfig)
 
UserDesktopAppConfig addUserDesktopAppFromGlobal (string)
 
int getUserDesktopAppCount ()
 
UserDesktopAppConfig getUserDesktopAppAt (int)
 
UserDesktopAppConfig getUserDesktopAppByDir (string)
 
UserDesktopAppConfig getUserDesktopAppById (string)
 
void removeUserDesktopApp (string)
 
void relinkUserDesktopApp (string, string)
 
bool isDesktopAvailable ()
 

Detailed Description

CiscoDevice is any Cisco-branded device with a terminal line.

Member Function Documentation

◆ addBootSystem()

bool CiscoDevice::addBootSystem ( string  )

Modifies the system parameters to add a particular boot system image.

Parameters
name,theboot system name.
Returns
bool, true if successful, otherwise false.

◆ addUserPassEntry()

void CiscoDevice::addUserPassEntry ( string  ,
string  ,
int   
)

Adds an authenticated user with the specified username, password, and type.

Parameters
username,theusername for the authenticated user.
password,thepassword for the authenticated user.
type,thetype for the user. The default is type 0.

◆ clearFtpPasswd()

void CiscoDevice::clearFtpPasswd ( )

Clears the current FTP password.

◆ clearFtpUsername()

void CiscoDevice::clearFtpUsername ( )

Clears the current FTP username.

◆ closeTableEvent()

void CiscoDevice::closeTableEvent ( )

IPC event.

◆ doneBooting()

void CiscoDevice::doneBooting ( )

This event is emitted when the device is done booting.

IPC event.

◆ enterCommand()

pair< CommandStatus, string > CiscoDevice::enterCommand ( string  ,
string   
)

Enters the specified command in the specified mode to the terminal.

Parameters
commandStrthe command string.
modeStrthe mode. Valid modes: user, enable, global. If blank, the command string will be entered into the current mode.
Returns
pair<enum<CommandStatus>, the status of the command entry. Valid command statuses: eStatusOk = 0, eErrorAmbiguous = 1, eErrorInvalid = 2, eErrorIncomplete = 3, eErrorNotImplemented = 4

◆ getBannerMotd()

string CiscoDevice::getBannerMotd ( )

Returns the message of the day banner.

Returns
string, the message of the day.

◆ getBia()

mac CiscoDevice::getBia ( )

Returns the burned-in address of this device.

Returns
mac, the burned-in address of this device.

◆ getBootSystems()

vector< BootSystemEntry > CiscoDevice::getBootSystems ( )

Returns the list of current boot system images.

Returns
vector<string>, the list of current boot system images.

◆ getConfigRegister()

short CiscoDevice::getConfigRegister ( )

Returns the current config register.

Returns
short, the current config register.

◆ getConsole()

Port CiscoDevice::getConsole ( )

Returns the console port of this device.

Returns
Port, the console port object.

◆ getConsoleLine()

TerminalLine CiscoDevice::getConsoleLine ( )

Returns the console line of this device.

Returns
TerminalLine, the console line TerminalLine object.

◆ getEnablePassword()

string CiscoDevice::getEnablePassword ( )

Returns the enable password.

Returns
string, the enable password.

◆ getEnableSecret()

string CiscoDevice::getEnableSecret ( )

Returns the encrypted enable secret string.

Returns
string, the encrypted enable secret string.

◆ getFtpPasswd()

string CiscoDevice::getFtpPasswd ( )

Returns the FTP password for the device.

Returns
string, the FTP password for this device.

◆ getFtpUsername()

string CiscoDevice::getFtpUsername ( )

Returns the FTP username for the device.

Returns
string, the FTP username for this device.

◆ getHostName()

string CiscoDevice::getHostName ( )

Returns the hostname of this device.

Returns
string, the hostname of this device.

◆ getIpcTerminalLine()

TerminalLine CiscoDevice::getIpcTerminalLine ( )

Returns the IPC terminal line of this device.

Returns
TerminalLine, the IPC TerminalLine object.

◆ getLine()

TerminalLine CiscoDevice::getLine ( int  )

Returns the line specified by num.

Parameters
num,theline number of interest.
Returns
TerminalLine, the line TerminalLine object.

◆ getNextConfigRegister()

short CiscoDevice::getNextConfigRegister ( )

Returns the next config register.

Returns
short, the next config register.

◆ getServicePasswordEncryption()

bool CiscoDevice::getServicePasswordEncryption ( )

Returns true if service password encryption is enabled, otherwise false.

Returns
bool, true if service password encryption is enabled, otherwise false.

◆ getStartupFile()

vector< string > CiscoDevice::getStartupFile ( )

Returns the contents of the current startup file.

Returns
vector<string>, the contents of the current startup file.

◆ getTimeZone()

string CiscoDevice::getTimeZone ( )

Returns the timezone of this device.

Returns
string, the timezone of this device.

◆ getUserEntryAt()

string CiscoDevice::getUserEntryAt ( int  )

Returns the username of the authenticated user at the specified index.

Parameters
index,theindex of the authenticated user of interest.
Returns
string, the username of the authenticated user at the specified index.

◆ getUserPassCount()

int CiscoDevice::getUserPassCount ( )

Returns the number of authenticated users.

Returns
int, the number of authenticated users.

◆ getVtyLine()

TerminalLine CiscoDevice::getVtyLine ( int  )

Returns the vty line specified by num.

Parameters
num,thevty line number of interest.
Returns
TerminalLine, the vty line TerminalLine object.

◆ isBooting()

bool CiscoDevice::isBooting ( )

Checks whether the device is currently booting.

◆ isUserExist()

bool CiscoDevice::isUserExist ( string  )

Returns true if the specified authenticated user exists, otherwise false.

/param username, the username of the authenticated user of interest.

Returns
bool, true if the specified authenticated user exists, otherwise false.

◆ lineAuthenticationFailed()

void CiscoDevice::lineAuthenticationFailed ( int  )

This event is emitted when a terminal line failed authentication.

  • lineNum, the line number on the device. For example, con 0 is 0, vty 0 is 66. Use TerminalLine getLine(int num) in this class to get the terminal line.

IPC event.

◆ lineAuthenticationFinished()

void CiscoDevice::lineAuthenticationFinished ( int  ,
bool   
)

This event is emitted when a terminal line finished authentication.

  • lineNum, the line number on the device. For example, con 0 is 0, vty 0 is 66. Use TerminalLine getLine(int num) in this class to get the terminal line.
  • success, true if authentication was successful, otherwise false.

IPC event.

◆ lineAuthenticationStarted()

void CiscoDevice::lineAuthenticationStarted ( int  ,
ip  ,
short  ,
LoginMethod   
)

This event is emitted when a terminal line has started authentication.

  • lineNum, the line number on the device. For example, con 0 is 0, vty 0 is 66. Use TerminalLine getLine(int num) in this class to get the terminal line.
  • srcIp, the connecting device's IP address.
  • srcTcpPort, the connecting device's TCP source port.
  • enum<LoginMethod>, the method used to connect to the device. Login methods: eLoginConsole = 0, eLoginTelnet = 1, eLoginSsh = 2

IPC event.

◆ lineConnected()

void CiscoDevice::lineConnected ( int  ,
ip  ,
short  ,
LoginMethod   
)

This event is emitted when a terminal line has connected.

  • lineNum, the line number on the device. For example, con 0 is 0, vty 0 is 66. Use TerminalLine getLine(int num) in this class to get the terminal line.
  • srcIp, the connecting device's IP address.
  • srcTcpPort, the connecting device's TCP source port.
  • enum<LoginMethod>, the method used to connect to the device. Login methods: eLoginConsole = 0, eLoginTelnet = 1, eLoginSsh = 2

IPC event.

◆ lineDisconnected()

void CiscoDevice::lineDisconnected ( int  )

This event is emitted when a terminal line has disconnected.

  • lineNum, the line number on the device. For example, con 0 is 0, vty 0 is 66. Use TerminalLine getLine(int num) in this class to get the terminal line.

IPC event.

◆ removeAllBootSystem()

void CiscoDevice::removeAllBootSystem ( )

Removes all boot system images from this device.

◆ removeBootSystem()

bool CiscoDevice::removeBootSystem ( string  )

Removes the specified boot system from this device.

Parameters
name,theboot system name.
Returns
bool, true if successful, otherwise false.

◆ removeUserPassAt()

void CiscoDevice::removeUserPassAt ( int  )

Removes the username of the authenticated user at the specified index.

Parameters
index,theindex of the authenticated user of interest.

◆ removeUserPassEntry()

void CiscoDevice::removeUserPassEntry ( string  )

Removes the authenticated user with the specified username.

Parameters
username,theusername of the authenticated user of interest.

◆ setBannerMotd()

void CiscoDevice::setBannerMotd ( string  )

Sets the message of the day banner when the device boots.

Parameters
banner,themessage of the day.

◆ setEnablePassword()

void CiscoDevice::setEnablePassword ( string  ,
int   
)

Sets the enable password.

Parameters
password,theclear text password string.
level,thelevel must be 7 or 0. 7 is hidden.

◆ setEnableSecret()

void CiscoDevice::setEnableSecret ( string  )

Sets the encrypted enable secret password with the specified string.

Parameters
string,theencrypted secret password string.

◆ setFtpPasswd()

void CiscoDevice::setFtpPasswd ( string  ,
int   
)

Sets the FTP password for the device.

Parameters
passwd,thedesired FTP password for this device.
uType,whetherthe password is encrypted or not. 7 is encryped or 0 is unencrypted.

◆ setFtpUsername()

void CiscoDevice::setFtpUsername ( string  )

Sets the FTP username for the device.

Parameters
username,thedesired FTP username for this device.

◆ setHostName()

void CiscoDevice::setHostName ( string  )

Sets the hostname of this device with the specified string.

Parameters
string,thehostname string.

◆ setNextConfigRegister()

void CiscoDevice::setNextConfigRegister ( short  )

Sets the next config register.

Parameters
in_register,thenext config register.

◆ setServicePasswordEncryption()

void CiscoDevice::setServicePasswordEncryption ( bool  )

Enables or disables service password encryption.

Parameters
bEnable,trueto enable service password encryption, false to disable it.

◆ setStartupFile()

void CiscoDevice::setStartupFile ( string  )

Sets the startup file to the specified file.

Parameters
str,thefilename of the config file.

◆ setTimeZone()

void CiscoDevice::setTimeZone ( string  ,
short  ,
short   
)

Sets the timezone for this device.

Parameters
timeZone,thetimezone string.
hourOffset,thehours offset from UTC.
minOffset,theminutes offset from UTC.

◆ skipBoot()

void CiscoDevice::skipBoot ( )

Skips the booting process.


The documentation for this class was generated from the following file: