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 
00003 */
00004 
00005 #include "inspircd_config.h"
00006 #include "base.h"
00007 #include <string>
00008 #include <map>
00009 #include <sys/socket.h>
00010 #include <sys/types.h>
00011 #include <netdb.h>
00012 #include <netinet/in.h>
00013 #include <unistd.h>
00014 #include <errno.h>
00015 #include <time.h>
00016 #include <vector>
00017 #include <deque>
00018 
00019 #ifndef __CONNECTION_H__
00020 #define __CONNECTION_H__
00021 
00022 #define STATE_DISCONNECTED      0
00023 #define STATE_CONNECTED         1
00024 #define STATE_SYNC              2
00025 #define STATE_NOAUTH_INBOUND    3
00026 #define STATE_NOAUTH_OUTBOUND   4
00027 #define STATE_SERVICES          5
00028 
00041 class ircd_connector : public Extensible
00042 {
00043  private:
00046         sockaddr_in addr;
00047         
00050         int fd;
00051         
00054         std::string servername;
00055         
00058         std::string description;
00059         
00063         int state;
00064         
00067         bool SetHostAddress(char* host, int port);
00068 
00069  public:
00070  
00075         char host[MAXBUF];
00076 
00081         int port;
00082         
00087         std::vector<std::string> routes;
00088         
00089 
00092         bool MakeOutboundConnection(char* host, int port);
00093         
00096         std::string GetServerName();
00097         
00100         void SetServerName(std::string serv);
00101         
00104         int GetDescriptor();
00105         
00108         void SetDescriptor(int fd);
00109         
00112         int GetState();
00113         
00116         void SetState(int state);
00117         
00120         char* GetServerIP();
00121         
00124         std::string GetDescription();
00125         
00128         void SetDescription(std::string desc);
00129         
00135         int GetServerPort();
00136         
00139         void SetServerPort(int p);
00140         
00143         bool SetHostAndPort(char* host, int port);
00144         
00148         void CloseConnection();
00149 };
00150 
00151 
00155 class packet : public classbase
00156 {
00157 };
00158 
00161 class connection : public Extensible
00162 {
00163  public:
00166         int fd;
00167         
00170         char host[256];
00171         
00174         char ip[32];
00175         
00178         char inbuf[MAXBUF];
00179         
00182         long bytes_in;
00183 
00186         long bytes_out;
00187 
00190         long cmds_in;
00191 
00194         long cmds_out;
00195 
00198         bool haspassed;
00199 
00204         int port;
00205         
00208         int registered;
00209         
00212         short int state;
00213         
00216         time_t lastping;
00217         
00220         time_t signon;
00221         
00224         time_t idle_lastmsg;
00225         
00228         time_t nping;
00229         
00232         char internal_addr[MAXBUF];
00233         
00236         int internal_port;
00237 
00241         std::vector<ircd_connector> connectors;
00242         
00245         connection();
00246         
00249         bool CreateListener(char* host, int p);
00250         
00253         bool BeginLink(char* targethost, int port, char* password, char* servername, int myport);
00254         
00257         bool MeshCookie(char* targethost, int port, long cookie, char* servername);
00258         
00261         void TerminateLink(char* targethost);
00262         
00266         bool SendPacket(char *message, const char* host);
00267         
00272         bool RecvPacket(std::deque<std::string> &messages, char* host);
00273         
00276         ircd_connector* FindHost(std::string host);
00277         
00281         bool AddIncoming(int fd,char* targethost, int sourceport);
00282         
00285         long GenKey();
00286 };
00287 
00288 
00289 #endif
00290 

Generated on Sun May 2 00:09:18 2004 for InspIRCd by doxygen1.3-rc3