]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/connection.h
Remove SpanningTreeProtocolInterface::SendOperNotice - it was translated to a SendSNO...
[user/henk/code/inspircd.git] / include / connection.h
index 954cc919bd7838995ffa942795098af5e369b796..f24fc303d18c7925602d656f9e836a880258ea16 100644 (file)
-/*
-
-*/
-
-#include "inspircd_config.h"
-#include "base.h"
-#include <string>
-#include <map>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <unistd.h>
-#include <errno.h>
-#include <time.h>
-#include <vector>
-#include <deque>
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
 
 #ifndef __CONNECTION_H__
 #define __CONNECTION_H__
 
-#define STATE_DISCONNECTED     0
-#define STATE_CONNECTED                1
-#define STATE_SYNC             2
-#define STATE_NOAUTH_INBOUND   3
-#define STATE_NOAUTH_OUTBOUND  4
+#include <time.h>
+#include "inspircd_config.h"
+#include "base.h"
+#include "socketengine.h"
 
-/** Each connection has one or more of these
- * each represents ONE outbound connection to another ircd
- * so each inbound has multiple outbounds.
+/** connection is the base class of User, and holds basic user properties.
+ * This can be extended for holding other user-like objects in the future.
  */
-class ircd_connector : public classbase
+class CoreExport connection : public EventHandler
 {
- private:
-       /** Sockaddr of the outbound ip and port
+ public:
+       /** Hostname of connection.
+        * This should be valid as per RFC1035.
         */
-       sockaddr_in addr;
-       
-       /** File descriptor of the connection
+       char host[65];
+
+       /** Stats counter for bytes inbound
         */
-       int fd;
-       
-       /** Server name
+       int bytes_in;
+
+       /** Stats counter for bytes outbound
         */
-       std::string servername;
-       
-       /** Server 'GECOS'
+       int bytes_out;
+
+       /** Stats counter for commands inbound
         */
-       std::string description;
-       
-       /** Server names of servers that this server is linked to
-        * So for A->B->C, if this was the record for B it would contain A and C
-        * whilever both servers are connected to B.
+       int cmds_in;
+
+       /** Stats counter for commands outbound
         */
-       std::vector<std::string> routes;
-       
-       /** State. STATE_NOAUTH_INBOUND, STATE_NOAUTH_OUTBOUND
-        * STATE_SYNC, STATE_DISCONNECTED, STATE_CONNECTED
+       int cmds_out;
+
+       /** True if user has authenticated, false if otherwise
         */
-       int state;
-       
-       bool SetHostAddress(char* host, int port);
+       bool haspassed;
 
- public:
-       char host[MAXBUF];
-       int port;
+       /** Used by User to indicate the registration status of the connection
+        * It is a bitfield of the REG_NICK, REG_USER and REG_ALL bits to indicate
+        * the connection state.
+        */
+       char registered;
        
-       bool MakeOutboundConnection(char* host, int port);
-       std::string GetServerName();
-       void SetServerName(std::string serv);
-       int GetDescriptor();
-       void SetDescriptor(int fd);
-       int GetState();
-       void SetState(int state);
-       char* GetServerIP();
-       std::string GetDescription();
-       void SetDescription(std::string desc);
-       int GetServerPort();
-       bool SetHostAndPort(char* host, int port);
-};
-
-
-class packet : public classbase
-{
- public:
-       long key;
-       int id;
-       short int type;
-       char data[MAXBUF];
-
-       packet();
-       ~packet();
-};
-
-
-class connection : public classbase
-{
- public:
-       long key;
-       int fd;                 // file descriptor
-       char host[256];         // hostname
-       long ip;                // ipv4 address
-       char inbuf[MAXBUF];     // recvQ
-       long bytes_in;
-       long bytes_out;
-       long cmds_in;
-       long cmds_out;
-       bool haspassed;
-       int port;
-       int registered;
-       short int state;
+       /** Time the connection was last pinged
+        */
        time_t lastping;
+       
+       /** Time the connection was created, set in the constructor. This
+        * may be different from the time the user's classbase object was
+        * created.
+        */
        time_t signon;
+       
+       /** Time that the connection last sent a message, used to calculate idle time
+        */
        time_t idle_lastmsg;
-       time_t nping;
-       char internal_addr[1024];
-       int internal_port;
-       std::vector<ircd_connector> connectors;
        
-       connection();
-       bool CreateListener(char* host, int p);
-       bool BeginLink(char* targethost, int port, char* password, char* servername);
-       bool MeshCookie(char* targethost, int port, long cookie, char* servername);
-       void TerminateLink(char* targethost);
-       bool SendPacket(char *message, const char* host);
-       bool RecvPacket(std::deque<std::string> &messages, char* host);
-       ircd_connector* FindHost(std::string host);
-       bool AddIncoming(int fd,char* targethost, int sourceport);
-       long GenKey();
+       /** Used by PING checking code
+        */
+       time_t nping;
 };
 
 
 #endif
-