Definition at line 44 of file socket.h.
Public Member Functions | |
SocketZero (SocketRoutingQueue &queue, int writeEndpoint, uint8_t zeroSocketSequenceStart=0) | |
SocketZero (Usb::Device &dev, int writeEndpoint, int readEndpoint, uint8_t zeroSocketSequenceStart=0) | |
~SocketZero () | |
uint8_t | GetZeroSocketSequence () const |
void | SetRoutingQueue (SocketRoutingQueue &queue) |
void | UnlinkRoutingQueue () |
void | Send (Data &send, int timeout=-1) |
void | Send (Data &send, Data &receive, int timeout=-1) |
void | Send (Barry::Packet &packet, int timeout=-1) |
SocketHandle | Open (uint16_t socket, const char *password=0) |
Open a logical socket on the device. | |
void | Close (Socket &socket) |
Closes a non-default socket (i.e. | |
Protected Member Functions | |
bool | SequencePacket (const Data &data) |
Returns true if this is a sequence packet that should be ignored. | |
Friends | |
class | Socket |
bool Barry::SocketZero::SequencePacket | ( | const Data & | data | ) | [protected] |
Returns true if this is a sequence packet that should be ignored.
This function is used in SocketZero::RawReceive() in order to determine whether to keep reading or not. By default, this function checks whether the packet is a sequence packet or not, and returns true if so. Also, if it is a sequence packet, it checks the validity of the sequence number.
If sequence packets become important in the future, this function could be changed to call a user-defined callback, in order to handle these things out of band.
Definition at line 340 of file socket.cc.
References Barry::Data::GetSize(), IS_COMMAND, MIN_PACKET_SIZE, and SB_COMMAND_SEQUENCE_HANDSHAKE.
SocketHandle Barry::SocketZero::Open | ( | uint16_t | socket, | |
const char * | password = 0 | |||
) |
Open a logical socket on the device.
Both the socket number and the flag are based on the response to the SELECT_MODE command. See Controller::SelectMode() for more info on this.
The packet sequence is normal for most socket operations.
Barry::Error | Thrown on protocol error. | |
Barry::BadPassword | Thrown on invalid password, or not enough retries left on device. |
Definition at line 420 of file socket.cc.
References BARRY_MIN_PASSWORD_TRIES, BARRY_MIN_PASSWORD_TRIES_ASC, Barry::ZeroPacket::ChallengeSeed(), Barry::Packet::Command(), GetZeroSocketSequence(), Barry::ZeroPacket::RemainingTries(), SB_COMMAND_OPENED_SOCKET, SB_COMMAND_PASSWORD_CHALLENGE, SB_COMMAND_PASSWORD_FAILED, Socket, Barry::ZeroPacket::SocketResponse(), and Barry::ZeroPacket::SocketSequence().
Referenced by Barry::Mode::Serial::Open(), and Barry::Mode::Desktop::RetryPassword().
void Barry::SocketZero::Close | ( | Socket & | socket | ) |
Closes a non-default socket (i.e.
non-zero socket number)
The packet sequence is just like Open(), except the command is CLOSE_SOCKET.
Barry::Error |
Definition at line 507 of file socket.cc.
References btohs, Barry::Protocol::CheckSize(), Barry::Protocol::Packet::command, Barry::Socket::ForceClosed(), Barry::Socket::GetCloseFlag(), Barry::Socket::GetSocket(), htobs, IS_COMMAND, MAKE_PACKET, SB_COMMAND_CLOSE_SOCKET, SB_COMMAND_CLOSED_SOCKET, SB_COMMAND_SEQUENCE_HANDSHAKE, SB_SOCKET_PACKET_HEADER_SIZE, Send(), Barry::Protocol::Packet::size, Barry::Protocol::Packet::PacketData::socket, Barry::Protocol::Packet::socket, and Barry::Protocol::Packet::u.
Referenced by Barry::Socket::Close().