Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / include / uping.h
1 /*
2  * IRC - Internet Relay Chat, include/uping.h
3  * Copyright (C) 1995 Carlo Wood
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * $Id$
20  */
21 #ifndef INCLUDED_uping_h
22 #define INCLUDED_uping_h
23 #ifndef INCLUDED_sys_types_h
24 #include <sys/types.h>
25 #define INCLUDED_sys_types_h
26 #endif
27 #ifndef INCLUDED_netinet_in_h
28 #include <netinet/in.h>
29 #define INCLUDED_netinet_in_h
30 #endif
31 #ifndef INCLUDED_ircd_defs_h
32 #include "ircd_defs.h"
33 #endif
34 #ifndef INCLUDED_ircd_events_h
35 #include "ircd_events.h"
36 #endif
37
38 struct Client;
39 struct ConfItem;
40
41 struct UPing
42 {
43   struct UPing*      next;     /* next ping in list, usually null */
44   int                fd;       /* socket file descriptor */
45   struct sockaddr_in sin;      /* socket name (ip addr, port, family ) */
46   char               count;    /* number of pings requested */
47   char               sent;     /* pings sent */
48   char               received; /* pings received */
49   char               active;   /* ping active flag */
50   struct Client*     client;   /* who requested the pings */
51   time_t             lastsent; /* when last ping was sent */
52   int                ms_min;   /* minimum time in milliseconds */
53   int                ms_ave;   /* average time in milliseconds */
54   int                ms_max;   /* maximum time in milliseconds */
55   int                index;    /* index into poll array */
56   struct Socket      socket;   /* socket structure */
57   struct Timer       sender;   /* timer telling when next to send a ping */
58   struct Timer       killer;   /* timer to kill us */
59   unsigned int       freeable; /* zero when structure can be free()'d */
60   char               name[HOSTLEN + 1]; /* server name to poing */
61   char               buf[BUFSIZE];      /* buffer to hold ping times */
62 };
63
64 #define UPING_PENDING_SOCKET    0x01 /* pending socket destruction event */
65 #define UPING_PENDING_SENDER    0x02 /* pending sender destruction event */
66 #define UPING_PENDING_KILLER    0x04 /* pending killer destruction event */
67
68 extern int UPingFileDescriptor;
69
70 extern int  uping_init(void);
71 extern void uping_send(struct UPing* pptr);
72 extern void uping_read(struct UPing* pptr);
73 extern void uping_end(struct UPing* pptr);
74 extern void uping_cancel(struct Client *sptr, struct Client *acptr);
75 extern void uping_echo(void);
76 extern struct UPing* uping_begin(void);
77 extern int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int count);
78
79
80 #endif /* INCLUDED_uping_h */