Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

connection.h

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
00006  *                       E-mail:
00007  *                <brain@chatspike.net>
00008  *                <Craig@chatspike.net>
00009  *     
00010  * Written by Craig Edwards, Craig McLure, and others.
00011  * This program is free but copyrighted software; see
00012  *            the file COPYING for details.
00013  *
00014  * ---------------------------------------------------
00015  */
00016 
00017 #include "inspircd_config.h"
00018 #include "base.h"
00019 #include <string>
00020 #include <map>
00021 #include <sys/types.h>
00022 #include <sys/socket.h>
00023 #include <netdb.h>
00024 #include <netinet/in.h>
00025 #include <unistd.h>
00026 #include <errno.h>
00027 #include <time.h>
00028 #include <vector>
00029 #include <deque>
00030 #include <sstream>
00031 
00032 #ifndef __CONNECTION_H__
00033 #define __CONNECTION_H__
00034 
00035 #define STATE_DISCONNECTED      0
00036 #define STATE_CONNECTED         1
00037 #define STATE_SYNC              2
00038 #define STATE_NOAUTH_INBOUND    3
00039 #define STATE_NOAUTH_OUTBOUND   4
00040 #define STATE_SERVICES          5
00041 
00042 std::string CreateSum();
00043 
00056 class ircd_connector : public Extensible
00057 {
00058  private:
00061         sockaddr_in addr;
00062         
00065         int fd;
00066         
00069         std::string servername;
00070         
00073         std::string description;
00074         
00078         char state;
00079         
00082         bool SetHostAddress(char* host, int port);
00083 
00086         std::string version;
00087 
00090         std::string sendq;
00091 
00094         std::string WriteError;
00095 
00098         time_t nextping;
00099 
00102         bool replied;
00103 
00104  public:
00105 
00110         std::string ircdbuffer;
00111 
00112  
00117         char host[MAXBUF];
00118 
00123         int port;
00124         
00129         std::vector<std::string> routes;
00130 
00133         ircd_connector();       
00134 
00137         bool MakeOutboundConnection(char* newhost, int newport);
00138         
00141         std::string GetServerName();
00142         
00145         void SetServerName(std::string serv);
00146         
00149         int GetDescriptor();
00150         
00153         void SetDescriptor(int fd);
00154         
00157         int GetState();
00158         
00161         void SetState(int state);
00162         
00165         char* GetServerIP();
00166         
00169         std::string GetDescription();
00170         
00173         void SetDescription(std::string desc);
00174         
00180         int GetServerPort();
00181         
00184         void SetServerPort(int p);
00185         
00188         bool SetHostAndPort(char* newhost, int newport);
00189         
00193         void CloseConnection();
00194 
00199         bool AddBuffer(std::string a);
00200 
00205         bool BufferIsComplete();
00206 
00209         void ClearBuffer();
00210 
00215         std::string GetBuffer();
00216 
00219         void SetVersionString(std::string newversion);
00220 
00224         std::string GetVersionString();
00225 
00229         bool AddWriteBuf(std::string data);
00230 
00234         bool FlushWriteBuf();
00235 
00238         void SetWriteError(std::string error);
00239 
00242         std::string GetWriteError();
00243 
00246         bool HasBufferedOutput();
00247 
00251         bool CheckPing();
00252 
00255         void ResetPing();
00256 };
00257 
00258 
00261 class connection : public Extensible
00262 {
00263  public:
00266         int fd;
00267         
00270         char host[160];
00271         
00274         char ip[16];
00275         
00278         int bytes_in;
00279 
00282         int bytes_out;
00283 
00286         int cmds_in;
00287 
00290         int cmds_out;
00291 
00294         bool haspassed;
00295 
00300         int port;
00301         
00304         char registered;
00305         
00308         time_t lastping;
00309         
00312         time_t signon;
00313         
00316         time_t idle_lastmsg;
00317         
00320         time_t nping;
00321         
00324         connection();
00325 };
00326 
00327 
00328 #endif

Generated on Tue May 24 02:30:02 2005 for InspIRCd by doxygen 1.3.3