"Fossies" - the Fresh Open Source Software Archive

Member "plptools-1.0.15/ncpd/ncp.h" (31 Oct 2019, 3333 Bytes) of package /linux/privat/plptools-1.0.15.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ncp.h" see the Fossies "Dox" file reference documentation.

    1 /*-*-c++-*-
    2  * $Id$
    3  *
    4  * This file is part of plptools.
    5  *
    6  *  Copyright (C) 1999  Philip Proudman <philip.proudman@btinternet.com>
    7  *  Copyright (C) 1999-2001 Fritz Elfert <felfert@to.com>
    8  *
    9  *  This program is free software; you can redistribute it and/or modify
   10  *  it under the terms of the GNU General Public License as published by
   11  *  the Free Software Foundation; either version 2 of the License, or
   12  *  (at your option) any later version.
   13  *
   14  *  This program is distributed in the hope that it will be useful,
   15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17  *  GNU General Public License for more details.
   18  *
   19  *  You should have received a copy of the GNU General Public License
   20  *  along with this program; if not, write to the Free Software
   21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22  *
   23  */
   24 #ifndef _ncp_h_
   25 #define _ncp_h_
   26 
   27 #ifdef HAVE_CONFIG_H
   28 #include <config.h>
   29 #endif
   30 
   31 #include <vector>
   32 
   33 #include "bufferstore.h"
   34 #include "linkchan.h"
   35 #include "ppsocket.h"
   36 
   37 class Link;
   38 class channel;
   39 
   40 #define NCP_DEBUG_LOG  1
   41 #define NCP_DEBUG_DUMP 2
   42 
   43 /**
   44  * Representation of a server process on the PC
   45  * A dummy which does not allow connects for now.
   46  */
   47 class PcServer {
   48 public:
   49     PcServer(ppsocket *, std::string _name) { name = _name; }
   50     ~PcServer() {}
   51     bool clientConnect(int, int) { return false; }
   52     std::string getName() { return name; }
   53     PcServer *self() { return this; }
   54 private:
   55     std::string name;
   56 };
   57 
   58 class ncp {
   59 public:
   60     ncp(const char *fname, int baud, unsigned short _verbose = 0);
   61     ~ncp();
   62 
   63     int connect(channel *c); // returns channel, or -1 if failure
   64     void Register(channel *c);
   65     void RegisterAck(int, const char *);
   66     void disconnect(int channel);
   67     void send(int channel, bufferStore &a);
   68     void reset();
   69     int  maxLinks();
   70     bool stuffToSend();
   71     bool hasFailed();
   72     bool gotLinkChannel();
   73 
   74     PcServer *findPcServer(const char *name);
   75     void registerPcServer(ppsocket *skt, const char *name);
   76     void unregisterPcServer(PcServer *server);
   77 
   78     void setVerbose(unsigned short);
   79     unsigned short getVerbose();
   80     short int getProtocolVersion();
   81     int getSpeed();
   82 
   83 private:
   84     friend class Link;
   85 
   86     enum c { MAX_LEN = 200, LAST_MESS = 1, NOT_LAST_MESS = 2 };
   87     enum interControllerMessageType {
   88     // Inter controller message types
   89     NCON_MSG_DATA_XOFF=1,
   90     NCON_MSG_DATA_XON=2,
   91     NCON_MSG_CONNECT_TO_SERVER=3,
   92     NCON_MSG_CONNECT_RESPONSE=4,
   93     NCON_MSG_CHANNEL_CLOSED=5,
   94     NCON_MSG_NCP_INFO=6,
   95     NCON_MSG_CHANNEL_DISCONNECT=7,
   96     NCON_MSG_NCP_END=8
   97     };
   98     enum protocolVersionType { PV_SERIES_5 = 6, PV_SERIES_3 = 3 };
   99     void receive(bufferStore s);
  100     int getFirstUnusedChan();
  101     bool isValidChannel(int);
  102     void decodeControlMessage(bufferStore &buff);
  103     void controlChannel(int chan, enum interControllerMessageType t, bufferStore &command);
  104     char * ctrlMsgName(unsigned char);
  105 
  106     Link *l;
  107     unsigned short verbose;
  108     channel **channelPtr;
  109     bufferStore *messageList;
  110     int *remoteChanList;
  111     bool failed;
  112     short int protocolVersion;
  113     linkChan *lChan;
  114     int maxChannels;
  115     std::vector<PcServer> pcServers;
  116     int lastSentChannel;
  117 };
  118 
  119 #endif
  120 
  121 /*
  122  * Local variables:
  123  * c-basic-offset: 4
  124  * End:
  125  */