plptools
Loading...
Searching...
No Matches
Link Class Reference

#include <link.h>

Collaboration diagram for Link:

Public Types

enum  link_type { LINK_TYPE_UNKNOWN = 0 , LINK_TYPE_SIBO = 1 , LINK_TYPE_EPOC = 2 }
 

Public Member Functions

 Link (const char *fname, int baud, NCP *ncp, unsigned short verbose, const int cancellationFd)
 Construct a new link instance. More...
 
 ~Link ()
 Disconnects from device and destroys instance. More...
 
void send (const bufferStore &buff)
 Send a PLP packet to the Peer. More...
 
bool stuffToSend ()
 Query outstanding packets. More...
 
bool hasFailed ()
 Query connection failure. More...
 
void reset ()
 Reset connection and attempt to reconnect to the peer. More...
 
void flush ()
 Wait, until all outstanding packets are acknowledged or timed out. More...
 
void purgeQueue (int channel)
 Purge all outstanding packets for a specified remote channel. More...
 
void setVerbose (unsigned short _verbose)
 Set verbosity of Link and underlying packet instance. More...
 
unsigned short getVerbose ()
 Get current verbosity of Link. More...
 
Enum< link_typegetLinkType ()
 Get the current link type. More...
 
int getSpeed ()
 Get current speed of the serial device. More...
 

Private Member Functions

void receive (bufferStore buf)
 Effectively a delegate method that accepts data from our packet instance. More...
 
void transmit (bufferStore buf)
 
void sendAck (int seq)
 
void sendReqReq ()
 
void sendReqCon ()
 
void sendReq ()
 
void multiAck (struct timeval)
 
void retransmit ()
 
void transmitHoldQueue (int channel)
 
void transmitWaitQueue ()
 
void purgeAllQueues ()
 
unsigned long retransTimeout ()
 

Private Attributes

pthread_t checkthread
 
pthread_mutex_t queueMutex
 
NCPtheNCP
 
packetp
 
int txSequence
 
int rxSequence
 
int seqMask
 
int maxOutstanding
 
unsigned long conMagic
 
unsigned short verbose
 
bool failed
 
Enum< link_typelinkType
 
std::vector< ackWaitQueueElementackWaitQueue
 
std::vector< bufferStoreholdQueue
 
std::vector< bufferStorewaitQueue
 
bool xoff [256]
 

Friends

class packet
 
void * expire_check (void *)
 

Detailed Description

Definition at line 63 of file link.h.

Member Enumeration Documentation

◆ link_type

Enumerator
LINK_TYPE_UNKNOWN 
LINK_TYPE_SIBO 
LINK_TYPE_EPOC 

Definition at line 66 of file link.h.

Constructor & Destructor Documentation

◆ Link()

Link::Link ( const char *  fname,
int  baud,
NCP ncp,
unsigned short  verbose,
const int  cancellationFd 
)

Construct a new link instance.

Parameters
fnameName of serial device.
baudSpeed of serial device.
ncpThe calling NCP instance.
verboseVerbosity (for debugging/troubleshooting)
cancellationFdFile descriptor that can be used to signal that the Link should shutdown.

Definition at line 59 of file link.cc.

◆ ~Link()

Link::~Link ( )

Disconnects from device and destroys instance.

Definition at line 85 of file link.cc.

Member Function Documentation

◆ flush()

void Link::flush ( )

Wait, until all outstanding packets are acknowledged or timed out.

Definition at line 635 of file link.cc.

◆ getLinkType()

Enum< Link::link_type > Link::getLinkType ( )

Get the current link type.

Returns
One of LINK_TYPE_... values.

Definition at line 659 of file link.cc.

◆ getSpeed()

int Link::getSpeed ( )

Get current speed of the serial device.

Returns
The current speed in baud.

Definition at line 665 of file link.cc.

◆ getVerbose()

unsigned short Link::getVerbose ( )

Get current verbosity of Link.

Returns
The verbosity, specified at construction or last call to setVerbosity();

Definition at line 116 of file link.cc.

◆ hasFailed()

bool Link::hasFailed ( )

Query connection failure.

Returns
true, if the peer could not be contacted or did not response, false if everything is ok.

Definition at line 647 of file link.cc.

◆ multiAck()

void Link::multiAck ( struct timeval  refstamp)
private

Definition at line 587 of file link.cc.

◆ purgeAllQueues()

void Link::purgeAllQueues ( )
private

Definition at line 138 of file link.cc.

◆ purgeQueue()

void Link::purgeQueue ( int  channel)

Purge all outstanding packets for a specified remote channel.

Parameters
channelThe of the channel for which to remove outstanding packets.

Definition at line 147 of file link.cc.

◆ receive()

void Link::receive ( bufferStore  buf)
private

Effectively a delegate method that accepts data from our packet instance.

Called on the packet's internal thread.

Definition at line 238 of file link.cc.

◆ reset()

void Link::reset ( )

Reset connection and attempt to reconnect to the peer.

Definition at line 100 of file link.cc.

◆ retransmit()

void Link::retransmit ( )
private

Definition at line 600 of file link.cc.

◆ retransTimeout()

unsigned long Link::retransTimeout ( )
private

Definition at line 94 of file link.cc.

◆ send()

void Link::send ( const bufferStore buff)

Send a PLP packet to the Peer.

Parameters
buffThe contents of the PLP packet.

Definition at line 129 of file link.cc.

◆ sendAck()

void Link::sendAck ( int  seq)
private

Definition at line 166 of file link.cc.

◆ sendReq()

void Link::sendReq ( )
private

Definition at line 225 of file link.cc.

◆ sendReqCon()

void Link::sendReqCon ( )
private

Definition at line 184 of file link.cc.

◆ sendReqReq()

void Link::sendReqReq ( )
private

Definition at line 205 of file link.cc.

◆ setVerbose()

void Link::setVerbose ( unsigned short  _verbose)

Set verbosity of Link and underlying packet instance.

Parameters
_verboseVerbosity (a bitmapped value, see LINK_DEBUG_.. constants)

Definition at line 122 of file link.cc.

◆ stuffToSend()

bool Link::stuffToSend ( )

Query outstanding packets.

Returns
true, if packets are outstanding (not yet acknowledged), false otherwise.

Definition at line 641 of file link.cc.

◆ transmit()

void Link::transmit ( bufferStore  buf)
private

Definition at line 504 of file link.cc.

◆ transmitHoldQueue()

void Link::transmitHoldQueue ( int  channel)
private

Definition at line 467 of file link.cc.

◆ transmitWaitQueue()

void Link::transmitWaitQueue ( )
private

Definition at line 488 of file link.cc.

Friends And Related Function Documentation

◆ expire_check

void * expire_check ( void *  )
friend

Definition at line 40 of file link.cc.

◆ packet

friend class packet
friend

Definition at line 159 of file link.h.

Member Data Documentation

◆ ackWaitQueue

std::vector<ackWaitQueueElement> Link::ackWaitQueue
private

Definition at line 194 of file link.h.

◆ checkthread

pthread_t Link::checkthread
private

Definition at line 180 of file link.h.

◆ conMagic

unsigned long Link::conMagic
private

Definition at line 189 of file link.h.

◆ failed

bool Link::failed
private

Definition at line 191 of file link.h.

◆ holdQueue

std::vector<bufferStore> Link::holdQueue
private

Definition at line 195 of file link.h.

◆ linkType

Enum<link_type> Link::linkType
private

Definition at line 192 of file link.h.

◆ maxOutstanding

int Link::maxOutstanding
private

Definition at line 188 of file link.h.

◆ p

packet* Link::p
private

Definition at line 184 of file link.h.

◆ queueMutex

pthread_mutex_t Link::queueMutex
private

Definition at line 181 of file link.h.

◆ rxSequence

int Link::rxSequence
private

Definition at line 186 of file link.h.

◆ seqMask

int Link::seqMask
private

Definition at line 187 of file link.h.

◆ theNCP

NCP* Link::theNCP
private

Definition at line 183 of file link.h.

◆ txSequence

int Link::txSequence
private

Definition at line 185 of file link.h.

◆ verbose

unsigned short Link::verbose
private

Definition at line 190 of file link.h.

◆ waitQueue

std::vector<bufferStore> Link::waitQueue
private

Definition at line 196 of file link.h.

◆ xoff

bool Link::xoff[256]
private

Definition at line 197 of file link.h.


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