39NCP::NCP(
const char *fname,
int baud,
unsigned short _verbose,
const int cancellationFd)
57 l =
new Link(fname, baud,
this,
verbose, cancellationFd);
63 for (
int i = 0; i <
maxLinks(); i++) {
85 for (
int i = 0; i <
maxLinks(); i++) {
133 lerr <<
"ncp: Got message for unknown channel\n";
140 lerr <<
"ncp: bizarre third byte!\n";
145 lerr <<
"Got null message\n";
166 vector<PcServer>::iterator i;
168 if (i->getName() == name)
182 vector<PcServer>::iterator i;
184 if (i->self() == server) {
194 int remoteChan = buff.
getByte(0);
208 lout <<
" [" << buff <<
"]";
213 if (!strcmp(buff.
getString(0),
"LINK.*")) {
224 lout <<
"ncp: Link UP" << endl;
225 linf <<
_(
"Connected with a S")
231 lout <<
"ncp: new passive linkChan" << endl;
252 lout <<
"ncp: ACCEPT client connect" << endl;
257 lout <<
"ncp: REJECT client connect" << endl;
264 lout <<
"ncp: new active linkChan" << endl;
280 lout <<
" ch=" << forChan <<
" stat=";
283 lout <<
"OK" << endl;
289 lout <<
"ncp: message for unknown channel" << endl;
293 lout <<
"Unknown " << (int) buff.
getByte(1) << endl;
316 lout <<
" [" << buff <<
"]";
333 lout <<
"ALERT!!!! Unexpected Protocol Version!! (Not Series 3/5?)!" << endl;
352 lout <<
" [" << buff <<
"]";
362 for (
int cNum = 1; cNum <
maxLinks(); cNum++) {
365 lout <<
"ncp: getFirstUnusedChan=" << cNum << endl;
383 lout <<
"ncp: RegisterAck: chan=" << chan << endl;
384 for (
int cNum = 1; cNum <
maxLinks(); cNum++) {
392 lerr <<
"ncp: RegisterAck: no channel to deliver" << endl;
407 lerr <<
"ncp: Out of channels in register" << endl;
409 lerr <<
"ncp: Register without established lChan" << endl;
468 lerr <<
"ncp: Ignored disconnect for unknown channel #" <<
channel << endl;
473 lout <<
"ncp: disconnect: channel=" <<
channel << endl;
492 lout <<
"ncp: hasFailed: " <<
failed <<
", " << lfailed << endl;
508 return (
lChan != NULL);
522 return "NCON_MSG_DATA_XOFF";
524 return "NCON_MSG_DATA_XON";
526 return "NCON_MSG_CONNECT_TO_SERVER";
528 return "NCON_MSG_CONNECT_RESPONSE";
530 return "NCON_MSG_CHANNEL_CLOSED";
532 return "NCON_MSG_NCP_INFO";
534 return "NCON_MSG_CHANNEL_DISCONNECT";
536 return "NCON_MSG_NCP_END";
538 return "NCON_MSG_UNKNOWN";
void reset()
Reset connection and attempt to reconnect to the peer.
void send(const bufferStore &buff)
Send a PLP packet to the Peer.
void purgeQueue(int channel)
Purge all outstanding packets for a specified remote channel.
int getSpeed()
Get current speed of the serial device.
bool hasFailed()
Query connection failure.
void setVerbose(unsigned short _verbose)
Set verbosity of Link and underlying packet instance.
bool stuffToSend()
Query outstanding packets.
const char * ctrlMsgName(unsigned char)
unsigned short getVerbose()
void registerPcServer(TCPSocket *skt, const char *name)
PcServer * findPcServer(const char *name)
void unregisterPcServer(PcServer *server)
bufferStore * messageList
interControllerMessageType
@ NCON_MSG_CONNECT_TO_SERVER
@ NCON_MSG_CHANNEL_DISCONNECT
@ NCON_MSG_CHANNEL_CLOSED
@ NCON_MSG_CONNECT_RESPONSE
void Register(channel *c)
void receive(bufferStore s)
void decodeControlMessage(bufferStore &buff)
void setVerbose(unsigned short)
short int getProtocolVersion()
NCP(const char *fname, int baud, unsigned short verbose, const int cancellationFd)
short int protocolVersion
void disconnect(int channel)
std::vector< PcServer > pcServers
void send(int channel, bufferStore &a)
void controlChannel(int chan, enum interControllerMessageType t, bufferStore &command)
void RegisterAck(int, const char *)
Representation of a server process on the PC A dummy which does not allow connects for now.
bool clientConnect(int, int)
A class for dealing with sockets.
A generic container for an array of bytes.
void discardFirstBytes(int len=0)
Removes bytes from the start of the buffer.
void init()
Initializes the bufferStore.
void addBuff(const bufferStore &b, long maxLen=-1)
Appends data to the content of this instance.
void addByte(unsigned char c)
Appends a byte to the content of this instance.
const char * getString(long pos=0) const
Retrieves the characters at index pos.
void addDWord(long dw)
Appends a dword to the content of this instance.
unsigned long getLen() const
Retrieves the length of a bufferStore.
void addString(const char *s)
Appends a string to the content of this instance.
unsigned char getByte(long pos=0) const
Retrieves the byte at index pos.
virtual const char * getNcpRegisterName()=0
void setNcpChannel(int chan)
virtual void ncpConnectAck()=0
void terminateWhenAsked()
virtual void ncpRegisterAck()=0
virtual void ncpDataCallback(bufferStore &a)=0
const char * getNcpConnectName()
void setNcpConnectName(const char *)
void setVerbose(short int _verbose)
#define MAX_CHANNELS_SIBO
#define MAX_CHANNELS_PSION