added basic ssl support to ircu
[ircu2.10.12-pk.git] / include / uping.h
index a9b3eea263ad763b99a58b3be621595762916ed8..d0fa0bec9cf9b65060d031bd68ab8c8f8735f4bd 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
+ */
+/** @file
+ * @brief UDP ping implementation.
+ * @version $Id$
  */
 #ifndef INCLUDED_uping_h
 #define INCLUDED_uping_h
 #ifndef INCLUDED_ircd_defs_h
 #include "ircd_defs.h"
 #endif
+#ifndef INCLUDED_ircd_events_h
+#include "ircd_events.h"
+#endif
+#ifndef INCLUDED_res_h
+#include "res.h"
+#endif
 
 struct Client;
+struct ConfItem;
 
+/** Tracks state of a UDP ping to some other server. */
 struct UPing
 {
-  struct UPing*      next;     /* next ping in list, usually null */
-  int                fd;       /* socket file descriptor */
-  struct sockaddr_in sin;      /* socket name (ip addr, port, family ) */
-  char               count;    /* number of pings requested */
-  char               sent;     /* pings sent */
-  char               received; /* pings received */
-  char               active;   /* ping active flag */
-  struct Client*     client;   /* who requested the pings */
-  time_t             lastsent; /* when last ping was sent */
-  time_t             timeout;  /* current ping timeout time */
-  int                ms_min;   /* minimum time in milliseconds */
-  int                ms_ave;   /* average time in milliseconds */
-  int                ms_max;   /* maximum time in milliseconds */
-  int                index;    /* index into poll array */
-  char               name[HOSTLEN + 1]; /* server name to poing */
-  char               buf[BUFSIZE];      /* buffer to hold ping times */
+  struct UPing*      next;     /**< next ping in list */
+  int                fd;       /**< socket file descriptor */
+  struct irc_sockaddr addr;    /**< socket name (ip addr, port, family ) */
+  char               count;    /**< number of pings requested */
+  char               sent;     /**< pings sent */
+  char               received; /**< pings received */
+  char               active;   /**< ping active flag */
+  struct Client*     client;   /**< who requested the pings */
+  time_t             lastsent; /**< when last ping was sent */
+  int                ms_min;   /**< minimum time in milliseconds */
+  int                ms_ave;   /**< average time in milliseconds */
+  int                ms_max;   /**< maximum time in milliseconds */
+  struct Socket      socket;   /**< socket structure */
+  struct Timer       sender;   /**< timer telling when next to send a ping */
+  struct Timer       killer;   /**< timer to kill us */
+  unsigned int       freeable; /**< zero when structure can be free()'d */
+  char               name[HOSTLEN + 1]; /**< server name to poing */
+  char               buf[BUFSIZE];      /**< buffer to hold ping times */
 };
 
+#define UPING_PENDING_SOCKET   0x01 /**< pending socket destruction event */
+#define UPING_PENDING_SENDER   0x02 /**< pending sender destruction event */
+#define UPING_PENDING_KILLER   0x04 /**< pending killer destruction event */
 
-/*=============================================================================
- * Proto types
- */
-
-extern int  setup_ping(void);
-extern void polludp(int fd);
-extern void send_ping(struct UPing* pptr);
-extern void read_ping(struct UPing* pptr);
-extern int  m_uping(struct Client *cptr, struct Client *sptr, int parc, char* parv[]);
-extern void end_ping(struct UPing* pptr);
-extern void cancel_ping(struct Client *sptr, struct Client *acptr);
-extern struct UPing* pings_begin(void);
+extern int  uping_init(void);
+extern void uping_send(struct UPing* pptr);
+extern void uping_read(struct UPing* pptr);
+extern void uping_end(struct UPing* pptr);
+extern void uping_cancel(struct Client *sptr, struct Client *acptr);
+extern struct UPing* uping_begin(void);
+extern int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int count);
 
-#ifdef DEBUG
-extern void uping_mark_blocks(void);
-#endif
 
 #endif /* INCLUDED_uping_h */