44 unsigned short _verbose,
45 const int cancellationFd,
47 void *callbackContext)
49, statusCallback_(statusCallback)
50, callbackContext_(callbackContext) {
65 l =
new Link(fname, baud,
this, noDSRCheck,
verbose, cancellationFd);
70 for (
int i = 0; i <
maxLinks(); i++) {
90 for (
int i = 0; i <
maxLinks(); i++) {
123 lerr <<
"ncp: Got message for unknown channel\n";
130 lerr <<
"ncp: bizarre third byte!\n";
135 lerr <<
"Got null message\n";
152 vector<PcServer>::iterator i;
154 if (i->getName() == name)
166 vector<PcServer>::iterator i;
168 if (i->self() == server) {
176 int remoteChan = buff.
getByte(0);
190 lout <<
" [" << buff <<
"]";
195 if (!strcmp(buff.
getString(0),
"LINK.*")) {
206 lout <<
"ncp: Link UP" << endl;
210 linf <<
_(
"Connected with a S")
216 lout <<
"ncp: new passive LinkChannel" << endl;
237 lout <<
"ncp: ACCEPT client connect" << endl;
242 lout <<
"ncp: REJECT client connect" << endl;
249 lout <<
"ncp: new active LinkChannel" << endl;
265 lout <<
" ch=" << forChan <<
" stat=";
268 lout <<
"OK" << endl;
274 lout <<
"ncp: message for unknown channel" << endl;
278 lout <<
"Unknown " << (int) buff.
getByte(1) << endl;
301 lout <<
" [" << buff <<
"]";
318 lout <<
"ALERT!!!! Unexpected Protocol Version!! (Not Series 3/5?)!" << endl;
340 lout <<
" [" << buff <<
"]";
348 for (
int cNum = 1; cNum <
maxLinks(); cNum++) {
351 lout <<
"ncp: getFirstUnusedChan=" << cNum << endl;
365 lout <<
"ncp: RegisterAck: chan=" << chan << endl;
366 for (
int cNum = 1; cNum <
maxLinks(); cNum++) {
374 lerr <<
"ncp: RegisterAck: no channel to deliver" << endl;
387 lerr <<
"ncp: Out of channels in register" << endl;
389 lerr <<
"ncp: Register without established lChan" << endl;
442 lerr <<
"ncp: Ignored disconnect for unknown channel #" << channel << endl;
447 lout <<
"ncp: disconnect: channel=" << channel << endl;
462 lout <<
"ncp: hasFailed: " <<
failed <<
", " << lfailed << endl;
479 return (
lChan != NULL);
489 return "NCON_MSG_DATA_XOFF";
491 return "NCON_MSG_DATA_XON";
493 return "NCON_MSG_CONNECT_TO_SERVER";
495 return "NCON_MSG_CONNECT_RESPONSE";
497 return "NCON_MSG_CHANNEL_CLOSED";
499 return "NCON_MSG_NCP_INFO";
501 return "NCON_MSG_CHANNEL_DISCONNECT";
503 return "NCON_MSG_NCP_END";
505 return "NCON_MSG_UNKNOWN";
A generic container for an array of bytes.
const char * getString(long pos=0) const
Retrieves the characters at index pos.
void addByte(unsigned char c)
Appends a byte to the content of this instance.
void addBuff(const BufferStore &b, long maxLen=-1)
Appends data to the content of this instance.
void addDWord(long dw)
Appends a dword to the content of this instance.
unsigned long getLen() const
Retrieves the length of a BufferStore.
unsigned char getByte(long pos=0) const
Retrieves the byte at index pos.
void addString(const char *s)
Appends a string to the content of this instance.
void discardFirstBytes(int len=0)
Removes bytes from the start of the buffer.
void init()
Initializes the BufferStore.
const char * getNcpConnectName()
void setVerbose(short int _verbose)
virtual void ncpDataCallback(BufferStore &a)=0
virtual void ncpConnectAck()=0
void setNcpConnectName(const char *)
virtual const char * getNcpRegisterName()=0
void setNcpChannel(int chan)
void terminateWhenAsked()
virtual void ncpRegisterAck()=0
void reset()
Reset connection and attempt to reconnect 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.
void send(const BufferStore &buff)
Send a PLP packet to the Peer.
bool hasFailed()
Query connection failure.
bool stuffToSend()
Query outstanding packets.
const char * ctrlMsgName(unsigned char)
void registerPcServer(TCPSocket *skt, const char *name)
PcServer * findPcServer(const char *name)
void unregisterPcServer(PcServer *server)
BufferStore * messageList
NCP(const char *fname, int baud, bool noDSRCheck, unsigned short verbose, const int cancellationFd, NCPStatusCallback statusCallback, void *context)
interControllerMessageType
@ NCON_MSG_CONNECT_TO_SERVER
@ NCON_MSG_CHANNEL_DISCONNECT
@ NCON_MSG_CHANNEL_CLOSED
@ NCON_MSG_CONNECT_RESPONSE
void decodeControlMessage(BufferStore &buff)
void Register(Channel *c)
void controlChannel(int chan, enum interControllerMessageType t, BufferStore &command)
NCPStatusCallback statusCallback_
void send(int channel, BufferStore &a)
short int getProtocolVersion()
short int protocolVersion
void disconnect(int channel)
std::vector< PcServer > pcServers
void receive(BufferStore s)
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.
#define MAX_CHANNELS_SIBO
#define MAX_CHANNELS_PSION
void(* NCPStatusCallback)(void *context, bool isConnected, int protocolVersion)