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
44 /** Tracks state of a UDP ping to some other server. */
47 struct UPing* next; /**< next ping in list */
48 int fd; /**< socket file descriptor */
49 struct irc_sockaddr addr; /**< socket name (ip addr, port, family ) */
50 char count; /**< number of pings requested */
51 char sent; /**< pings sent */
52 char received; /**< pings received */
53 char active; /**< ping active flag */
54 struct Client* client; /**< who requested the pings */
55 time_t lastsent; /**< when last ping was sent */
56 int ms_min; /**< minimum time in milliseconds */
57 int ms_ave; /**< average time in milliseconds */
58 int ms_max; /**< maximum time in milliseconds */
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 uping_init(void);
72 extern void uping_send(struct UPing* pptr);
73 extern void uping_read(struct UPing* pptr);
74 extern void uping_end(struct UPing* pptr);
75 extern void uping_cancel(struct Client *sptr, struct Client *acptr);
76 extern void uping_echo(void);
77 extern struct UPing* uping_begin(void);
78 extern int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int count);
81 #endif /* INCLUDED_uping_h */