Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | 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 
00031 #ifndef __CONNECTION_H__
00032 #define __CONNECTION_H__
00033 
00034 #define STATE_DISCONNECTED      0
00035 #define STATE_CONNECTED         1
00036 #define STATE_SYNC              2
00037 #define STATE_NOAUTH_INBOUND    3
00038 #define STATE_NOAUTH_OUTBOUND   4
00039 #define STATE_SERVICES          5
00040 
00053 class ircd_connector : public Extensible
00054 {
00055  private:
00058         sockaddr_in addr;
00059         
00062         int fd;
00063         
00066         std::string servername;
00067         
00070         std::string description;
00071         
00075         int state;
00076         
00079         bool SetHostAddress(char* host, int port);
00080 
00081  public:
00082  
00087         char host[MAXBUF];
00088 
00093         int port;
00094         
00099         std::vector<std::string> routes;
00100         
00101 
00104         bool MakeOutboundConnection(char* host, int port);
00105         
00108         std::string GetServerName();
00109         
00112         void SetServerName(std::string serv);
00113         
00116         int GetDescriptor();
00117         
00120         void SetDescriptor(int fd);
00121         
00124         int GetState();
00125         
00128         void SetState(int state);
00129         
00132         char* GetServerIP();
00133         
00136         std::string GetDescription();
00137         
00140         void SetDescription(std::string desc);
00141         
00147         int GetServerPort();
00148         
00151         void SetServerPort(int p);
00152         
00155         bool SetHostAndPort(char* host, int port);
00156         
00160         void CloseConnection();
00161 };
00162 
00163 
00166 class connection : public Extensible
00167 {
00168  public:
00171         int fd;
00172         
00175         char host[256];
00176         
00179         char ip[32];
00180         
00183         char inbuf[MAXBUF];
00184         
00187         long bytes_in;
00188 
00191         long bytes_out;
00192 
00195         long cmds_in;
00196 
00199         long cmds_out;
00200 
00203         bool haspassed;
00204 
00209         int port;
00210         
00213         int registered;
00214         
00217         short int state;
00218         
00221         time_t lastping;
00222         
00225         time_t signon;
00226         
00229         time_t idle_lastmsg;
00230         
00233         time_t nping;
00234         
00237         char internal_addr[MAXBUF];
00238         
00241         int internal_port;
00242 
00246         std::vector<ircd_connector> connectors;
00247         
00250         connection();
00251         
00254         bool CreateListener(char* host, int p);
00255         
00258         bool BeginLink(char* targethost, int port, char* password, char* servername, int myport);
00259         
00262         bool MeshCookie(char* targethost, int port, long cookie, char* servername);
00263         
00266         void TerminateLink(char* targethost);
00267         
00271         bool SendPacket(char *message, const char* host);
00272         
00277         bool RecvPacket(std::deque<std::string> &messages, char* host);
00278         
00281         ircd_connector* FindHost(std::string host);
00282         
00286         bool AddIncoming(int fd,char* targethost, int sourceport);
00287         
00290         long GenKey();
00291 };
00292 
00293 
00294 #endif
00295 

Generated on Sat Apr 16 18:57:13 2005 for InspIRCd by doxygen 1.3.3