plptools
Loading...
Searching...
No Matches
ncp.h
Go to the documentation of this file.
1/*
2 * This file is part of plptools.
3 *
4 * Copyright (C) 1999 Philip Proudman <philip.proudman@btinternet.com>
5 * Copyright (C) 1999-2001 Fritz Elfert <felfert@to.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * along with this program; if not, see <https://www.gnu.org/licenses/>.
19 *
20 */
21#ifndef _ncp_h_
22#define _ncp_h_
23
24#include "config.h"
25
26#include <vector>
27
28#include "bufferstore.h"
29#include "linkchan.h"
30#include "tcpsocket.h"
31
32#define MAX_CHANNELS_PSION 256
33#define MAX_CHANNELS_SIBO 8
34#define NCP_SENDLEN 250
35
36class Link;
37class channel;
38
43class PcServer {
44public:
45 PcServer(TCPSocket *, std::string _name) { name = _name; }
47 bool clientConnect(int, int) { return false; }
48 std::string getName() { return name; }
49 PcServer *self() { return this; }
50private:
51 std::string name;
52};
53
54class NCP {
55public:
56 NCP(const char *fname, int baud, unsigned short verbose, const int cancellationFd);
57 ~NCP();
58
59 int connect(channel *c); // returns channel, or -1 if failure
60 void Register(channel *c);
61 void RegisterAck(int, const char *);
62 void disconnect(int channel);
63 void send(int channel, bufferStore &a);
64 void reset();
65 int maxLinks();
66 bool stuffToSend();
67 bool hasFailed();
68 bool gotLinkChannel();
69
70 PcServer *findPcServer(const char *name);
71 void registerPcServer(TCPSocket *skt, const char *name);
72 void unregisterPcServer(PcServer *server);
73
74 void setVerbose(unsigned short);
75 unsigned short getVerbose();
76 short int getProtocolVersion();
77 int getSpeed();
78
79private:
80 friend class Link;
81
82 enum c { MAX_LEN = 200, LAST_MESS = 1, NOT_LAST_MESS = 2 };
84 // Inter controller message types
93 };
95 void receive(bufferStore s);
97 bool isValidChannel(int);
99 void controlChannel(int chan, enum interControllerMessageType t, bufferStore &command);
100 const char * ctrlMsgName(unsigned char);
101
103 unsigned short verbose;
107 bool failed;
111 std::vector<PcServer> pcServers;
113};
114
115#endif
Definition: ncp.h:54
c
Definition: ncp.h:82
@ LAST_MESS
Definition: ncp.h:82
@ MAX_LEN
Definition: ncp.h:82
@ NOT_LAST_MESS
Definition: ncp.h:82
const char * ctrlMsgName(unsigned char)
Definition: ncp.cc:518
bool failed
Definition: ncp.h:107
int * remoteChanList
Definition: ncp.h:106
protocolVersionType
Definition: ncp.h:94
@ PV_SERIES_3
Definition: ncp.h:94
@ PV_SERIES_5
Definition: ncp.h:94
unsigned short getVerbose()
Definition: ncp.cc:99
void registerPcServer(TCPSocket *skt, const char *name)
Definition: ncp.cc:175
PcServer * findPcServer(const char *name)
Definition: ncp.cc:163
void unregisterPcServer(PcServer *server)
Definition: ncp.cc:180
bufferStore * messageList
Definition: ncp.h:105
bool isValidChannel(int)
Definition: ncp.cc:374
channel ** channelPtr
Definition: ncp.h:104
int maxLinks()
Definition: ncp.cc:79
int lastSentChannel
Definition: ncp.h:112
linkChan * lChan
Definition: ncp.h:109
bool hasFailed()
Definition: ncp.cc:487
interControllerMessageType
Definition: ncp.h:83
@ NCON_MSG_NCP_END
Definition: ncp.h:92
@ NCON_MSG_DATA_XOFF
Definition: ncp.h:85
@ NCON_MSG_NCP_INFO
Definition: ncp.h:90
@ NCON_MSG_CONNECT_TO_SERVER
Definition: ncp.h:87
@ NCON_MSG_CHANNEL_DISCONNECT
Definition: ncp.h:91
@ NCON_MSG_CHANNEL_CLOSED
Definition: ncp.h:89
@ NCON_MSG_CONNECT_RESPONSE
Definition: ncp.h:88
@ NCON_MSG_DATA_XON
Definition: ncp.h:86
int connect(channel *c)
Definition: ncp.cc:413
Link * l
Definition: ncp.h:102
void Register(channel *c)
Definition: ncp.cc:396
void receive(bufferStore s)
Definition: ncp.cc:118
void decodeControlMessage(bufferStore &buff)
Definition: ncp.cc:192
int maxChannels
Definition: ncp.h:110
bool gotLinkChannel()
Definition: ncp.cc:506
void reset()
Definition: ncp.cc:84
int getFirstUnusedChan()
Definition: ncp.cc:360
void setVerbose(unsigned short)
Definition: ncp.cc:105
int getSpeed()
Definition: ncp.cc:512
unsigned short verbose
Definition: ncp.h:103
short int getProtocolVersion()
Definition: ncp.cc:112
bool stuffToSend()
Definition: ncp.cc:481
~NCP()
Definition: ncp.cc:60
short int protocolVersion
Definition: ncp.h:108
void disconnect(int channel)
Definition: ncp.cc:465
std::vector< PcServer > pcServers
Definition: ncp.h:111
void send(int channel, bufferStore &a)
Definition: ncp.cc:438
void controlChannel(int chan, enum interControllerMessageType t, bufferStore &command)
Definition: ncp.cc:149
void RegisterAck(int, const char *)
Definition: ncp.cc:380
Representation of a server process on the PC A dummy which does not allow connects for now.
Definition: ncp.h:43
PcServer * self()
Definition: ncp.h:49
std::string getName()
Definition: ncp.h:48
~PcServer()
Definition: ncp.h:46
bool clientConnect(int, int)
Definition: ncp.h:47
PcServer(TCPSocket *, std::string _name)
Definition: ncp.h:45
std::string name
Definition: ncp.h:51
A class for dealing with sockets.
Definition: tcpsocket.h:38
A generic container for an array of bytes.
Definition: bufferstore.h:37
static rfsv * a
Definition: main.cc:53