Local or remote USB device representation. If invalid arguments are passed to any constructor,
Null Object will be returned.
Instances of this class are often used as a key in containers such as
map/set/unordered_map/unordered_set. Thus, key members cannot be changed after object
creation. Strings encoding is UTF-8.
Methods:
● Device(const std::string &dev, bool is_local);
● Device(const std::vector<std::string> &fields, bool is_local);
● bool isa(const Device &dev) const;
● bool update(const Device &dev);
● std::string asString(bool with_password = false) const;
● unsigned short port() const;
● std::string reverse_host() const;
● std::string usbport() const;
● std::string devicenick() const;
● void setDeviceNick(const std::string &nick);
● std::string devicename() const;
● void setDeviceName(const std::string &name);
● std::string kernel_devname() const;
● void setAuthorization(bool auth);
● void setEncryption(bool encr);
● void setCompression(bool compr);
● std::string password() const;
● void setPassword(const std::string &cleartext);
● std::string sharedWith() const;
● void setSharedWith(const std::string &peername);
● bool allowRDisconnect() const;
● void setAllowRDisconnect(bool rDisconnect);
Device(const std::string &reverse_host_, unsigned short tcp_port, const std::string &kernel_devname_);
Creates local USB device representation.
Parameters:
reverse_host_ - optional. The address of the host to which the TCP connection is established. Is
used for callback connections when the host where the device is shared acts as a TCP client. If
not empty, server will permanently try to connect to the client on reverse_host_:tcp_port
tcp_port - port number to share device on or to connect to reverse host (if specified).
kernel_devname_ - unique USB device identifier obtained from kernel
Device( const std::string &host_, const std::string &reverse_host_, unsigned short tcp_port, const std::string &usbhub_, const std::string &usbport_);
Creates remote USB device representation.
Parameters:
host_ - server IP or hostname, mandatory
reverse_host_ - optional. Localhost network hostname or numerical address for reverse
connection with server. You can pass wildcard addresses "*", "0.0.0.0" or "::" which are intended
to accept connections on any of the host's network addresses (INADDR_ANY or
IN6ADDR_ANY_INIT)
tcp_port - port number on host_
usbhub_ - mandatory
usbport_ - mandatory
Device(const std::string &dev, bool is_local);
Creates local or remote USB device representation from string.
Parameters:
dev - string representation of device, comma-separated values
is_local - true if this is a local device
Note:
See asString()
Device(const std::vector<std::string> &fields, bool is_local);
Creates local or remote USB device representation from parsed device string.
Parameters:
fields - split values of string representation
is_local - true if this is a local device
bool isa(const Device &dev) const;
Return:
Returns true if the argument shares internal representation with this instance.
size_t hash() const;
Return:
Returns hash value of object
bool update(const Device &dev);
Copies all mutable members from dev (for which setXXX members present).
Parameters:
dev - object to copy members from
Return:
Returns true if any member really changed its value
Device clone() const;
Return:
Returns an exact copy of self
std::string asString(bool with_password = false) const;
Parameters:
with_password - includes password in result if true
Return:
Returns string representation of device
bool isLocal() const;
Returns true if the device is local
bool isRemote() const;
Returns true if the device is remote
std::string host() const;
Returns the address of the host to which the device is connected physically.
unsigned short port() const;
Returns TCP port to connect to the shared device
std::string reverse_host() const;
Returns the address of the host for callback connection
bool isReverse() const;
Returns true if the device is shared as callback
std::string usbhub() const;
Returns identifier of the hub to which the device is connected
std::string usbport() const;
Returns string of port numbers in the hubs through which the device is connected
std::string devicenick() const;
Returns device description
void setDeviceNick(const std::string &nick);
Sets device description nick - new description of device
std::string devicename() const;
Returns device name
void setDeviceName(const std::string &name);
Sets device name
Parameters:
name - new name
std::string kernel_devname() const;
Returns sys name of device (unique USB device identifier obtained from kernel: hub-port[.port...])
bool authorization() const;
Returns true if password authentication is enabled (i.e. you need to enter password to connect to device)
void setAuthorization(bool auth);
Enables/disables authentication
auth - true if you need to enable authentication, false if you need to disable it.
Note: When turning on the password authentication option, the traffic encryption option will be enabled automatically.
bool encryption() const;
Returns true if traffic encryption is enabled
void setEncryption(bool encr);
Enables/disables encryption
encr - true if you need to enable encryption, false if you need to disable encryption
Note: When turning off the traffic encryption option, (if enabled) the password authentication
option will be disabled automatically.
bool compression() const;
Returns true if traffic compression is enabled
void setCompression(bool compr);
Enables/disables traffic compression compr - true if you need to enable compression, false if you need to disable compression
bool hasPassword() const;
Returns true if password is set
std::string password() const;
Returns password
void setPassword(const std::string &cleartext);
Sets password (automatically switches the authentication flag depending on whether password is empty or not, see setAuthorization)
Parameters:
cleartext - password
std::string sharedWith() const;
Returns address of the host connected to the shared device
void setSharedWith(const std::string &peername);
Sets address of the host connected to the shared device
Parameters:
peername - host’s address
bool allowRDisconnect() const;
Returns true if any remote client is allowed to disconnect the shared device from other clients
void setAllowRDisconnect(bool rDisconnect);
Enables/disables the option to allow any remote client to disconnect the shared device from other clients