2 * IRC - Internet Relay Chat, include/uping.h
3 * Copyright (C) 1995 Carlo Wood
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)
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.
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.
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
27 #ifndef INCLUDED_netinet_in_h
28 #include <netinet/in.h>
29 #define INCLUDED_netinet_in_h
31 #ifndef INCLUDED_ircd_defs_h
32 #include "ircd_defs.h"
34 #ifndef INCLUDED_ircd_events_h
35 #include "ircd_events.h"
37 #ifndef INCLUDED_res_h
46 struct UPing* next; /* next ping in list, usually null */
47 int fd; /* socket file descriptor */
48 struct irc_sockaddr addr; /* socket name (ip addr, port, family ) */
49 char count; /* number of pings requested */
50 char sent; /* pings sent */
51 char received; /* pings received */
52 char active; /* ping active flag */
53 struct Client* client; /* who requested the pings */
54 time_t lastsent; /* when last ping was sent */
55 int ms_min; /* minimum time in milliseconds */
56 int ms_ave; /* average time in milliseconds */
57 int ms_max; /* maximum time in milliseconds */
58 int index; /* index into poll array */
59 struct Socket socket; /* socket structure */
60 struct Timer sender; /* timer telling when next to send a ping */
61 struct Timer killer; /* timer to kill us */
62 unsigned int freeable; /* zero when structure can be free()'d */
63 char name[HOSTLEN + 1]; /* server name to poing */
64 char buf[BUFSIZE]; /* buffer to hold ping times */
67 #define UPING_PENDING_SOCKET 0x01 /* pending socket destruction event */
68 #define UPING_PENDING_SENDER 0x02 /* pending sender destruction event */
69 #define UPING_PENDING_KILLER 0x04 /* pending killer destruction event */
71 extern int UPingFileDescriptor;
73 extern int uping_init(void);
74 extern void uping_send(struct UPing* pptr);
75 extern void uping_read(struct UPing* pptr);
76 extern void uping_end(struct UPing* pptr);
77 extern void uping_cancel(struct Client *sptr, struct Client *acptr);
78 extern void uping_echo(void);
79 extern struct UPing* uping_begin(void);
80 extern int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int count);
83 #endif /* INCLUDED_uping_h */