plptools
Loading...
Searching...
No Matches
channel.cc
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#include "config.h"
22#include <cstdlib>
23#include <iostream>
24#include <string>
25#include <cstring>
26
27#include "channel.h"
28#include "ncp.h"
29
30Channel::Channel(NCP * _ncpController) {
31 verbose = 0;
32 ncpChannel = 0;
33 connectName = 0;
34 ncpController = _ncpController;
35 _terminate = false;
36}
37
39 if (connectName) {
40 free((void *)connectName);
41 }
42}
43
46}
47
49shouldTerminate() const
50{
51 return _terminate;
52}
53
56{
57 _terminate = true;
58}
59
62}
63
66}
67
68void Channel::ncpDoRegisterAck(int ch, const char *name) {
69 ncpController->RegisterAck(ch, name);
70}
71
74}
75
77 return ncpController->findPcServer(name);
78}
79
80void Channel::ncpRegisterPcServer(TCPSocket *skt, const char *name) {
82}
83
86}
87
89 return ncpController->getSpeed();
90}
91
94}
95
96void Channel::setNcpChannel(int chan) {
97 ncpChannel = chan;
98}
99
101 return ncpChannel;
102}
103
104void Channel::newNcpController(NCP * _ncpController) {
105 ncpController = _ncpController;
106}
107
108void Channel::setVerbose(short int _verbose) {
109 verbose = _verbose;
110}
111
113 return verbose;
114}
115
117 return connectName;
118}
119
120void Channel::setNcpConnectName(const char *name) {
121 if (name) {
122 if (connectName) {
123 free((void *)connectName);
124 }
125 connectName = strdup(name);
126 }
127}
A generic container for an array of bytes.
Definition: bufferstore.h:36
NCP * ncpController
Definition: channel.h:74
void ncpUnregisterPcServer(PcServer *server)
Definition: channel.cc:84
void ncpDoRegisterAck(int ch, const char *name)
Definition: channel.cc:68
const char * getNcpConnectName()
Definition: channel.cc:116
void setVerbose(short int _verbose)
Definition: channel.cc:108
short int ncpProtocolVersion()
Definition: channel.cc:92
Channel(NCP *ncpController)
Definition: channel.cc:30
void newNcpController(NCP *ncpController)
Definition: channel.cc:104
void ncpRegisterPcServer(TCPSocket *skt, const char *name)
Definition: channel.cc:80
PcServer * ncpFindPcServer(const char *name)
Definition: channel.cc:76
void setNcpConnectName(const char *)
Definition: channel.cc:120
int ncpGetSpeed()
Definition: channel.cc:88
void ncpDisconnect()
Definition: channel.cc:72
void setNcpChannel(int chan)
Definition: channel.cc:96
short int getVerbose()
Definition: channel.cc:112
short int verbose
Definition: channel.h:70
void ncpConnect()
Definition: channel.cc:60
virtual ~Channel()=0
Definition: channel.cc:38
void terminateWhenAsked()
Definition: channel.cc:55
bool _terminate
Definition: channel.h:76
void ncpRegister()
Definition: channel.cc:64
const char * connectName
Definition: channel.h:71
int getNcpChannel(void)
Definition: channel.cc:100
void ncpSend(BufferStore &a)
Definition: channel.cc:44
int ncpChannel
Definition: channel.h:75
bool shouldTerminate() const
Indicates that the channel needs termination and should be cleaned-up.
Definition: channel.cc:49
Definition: ncp.h:55
void registerPcServer(TCPSocket *skt, const char *name)
Definition: ncp.cc:160
PcServer * findPcServer(const char *name)
Definition: ncp.cc:150
void unregisterPcServer(PcServer *server)
Definition: ncp.cc:164
void Register(Channel *c)
Definition: ncp.cc:377
int getSpeed()
Definition: ncp.cc:482
void send(int channel, BufferStore &a)
Definition: ncp.cc:415
int connect(Channel *c)
Definition: ncp.cc:392
short int getProtocolVersion()
Definition: ncp.cc:103
void disconnect(int channel)
Definition: ncp.cc:440
void RegisterAck(int, const char *)
Definition: ncp.cc:363
Representation of a server process on the PC A dummy which does not allow connects for now.
Definition: ncp.h:44
A class for dealing with sockets.
Definition: tcpsocket.h:37
static RFSV * a
Definition: main.cc:55