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 
00040 class ircd_connector : public classbase
00041 {
00042  private:
00045         sockaddr_in addr;
00046         
00049         int fd;
00050         
00053         std::string servername;
00054         
00057         std::string description;
00058         
00062         int state;
00063         
00066         bool SetHostAddress(char* host, int port);
00067 
00068  public:
00069  
00074         char host[MAXBUF];
00075 
00080         int port;
00081         
00086         std::vector<std::string> routes;
00087         
00088 
00091         bool MakeOutboundConnection(char* host, int port);
00092         
00095         std::string GetServerName();
00096         
00099         void SetServerName(std::string serv);
00100         
00103         int GetDescriptor();
00104         
00107         void SetDescriptor(int fd);
00108         
00111         int GetState();
00112         
00115         void SetState(int state);
00116         
00119         char* GetServerIP();
00120         
00123         std::string GetDescription();
00124         
00127         void SetDescription(std::string desc);
00128         
00134         int GetServerPort();
00135         
00138         void SetServerPort(int p);
00139         
00142         bool SetHostAndPort(char* host, int port);
00143         
00147         void CloseConnection();
00148 };
00149 
00150 
00151 class packet
00152 {
00156 };
00157 
00160 class connection : public classbase
00161 {
00162  public:
00165         int fd;
00166         
00169         char host[256];
00170         
00173         long ip;
00174         
00177         char inbuf[MAXBUF];
00178         
00181         long bytes_in;
00182 
00185         long bytes_out;
00186 
00189         long cmds_in;
00190 
00193         long cmds_out;
00194 
00197         bool haspassed;
00198 
00203         int port;
00204         
00207         int registered;
00208         
00211         short int state;
00212         
00215         time_t lastping;
00216         
00219         time_t signon;
00220         
00223         time_t idle_lastmsg;
00224         
00227         time_t nping;
00228         
00231         char internal_addr[1024];
00232         
00235         int internal_port;
00236 
00240         std::vector<ircd_connector> connectors;
00241         
00244         connection();
00245         
00248         bool CreateListener(char* host, int p);
00249         
00252         bool BeginLink(char* targethost, int port, char* password, char* servername, int myport);
00253         
00256         bool MeshCookie(char* targethost, int port, long cookie, char* servername);
00257         
00260         void TerminateLink(char* targethost);
00261         
00265         bool SendPacket(char *message, const char* host);
00266         
00271         bool RecvPacket(std::deque<std::string> &messages, char* host);
00272         
00275         ircd_connector* FindHost(std::string host);
00276         
00280         bool AddIncoming(int fd,char* targethost, int sourceport);
00281         
00284         long GenKey();
00285 };
00286 
00287 
00288 #endif
00289 

Generated on Sat Apr 17 13:31:38 2004 for InspIRCd by doxygen1.3-rc3