]>
Commit | Line | Data |
---|---|---|
189935b1 | 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 | /** @file | |
20 | * @brief UDP ping implementation. | |
21 | * @version $Id: uping.h,v 1.9 2004/12/29 03:08:09 entrope Exp $ | |
22 | */ | |
23 | #ifndef INCLUDED_uping_h | |
24 | #define INCLUDED_uping_h | |
25 | #ifndef INCLUDED_sys_types_h | |
26 | #include <sys/types.h> | |
27 | #define INCLUDED_sys_types_h | |
28 | #endif | |
29 | #ifndef INCLUDED_netinet_in_h | |
30 | #include <netinet/in.h> | |
31 | #define INCLUDED_netinet_in_h | |
32 | #endif | |
33 | #ifndef INCLUDED_ircd_defs_h | |
34 | #include "ircd_defs.h" | |
35 | #endif | |
36 | #ifndef INCLUDED_ircd_events_h | |
37 | #include "ircd_events.h" | |
38 | #endif | |
39 | #ifndef INCLUDED_res_h | |
40 | #include "res.h" | |
41 | #endif | |
42 | ||
43 | struct Client; | |
44 | struct ConfItem; | |
45 | ||
46 | /** Tracks state of a UDP ping to some other server. */ | |
47 | struct UPing | |
48 | { | |
49 | struct UPing* next; /**< next ping in list */ | |
50 | int fd; /**< socket file descriptor */ | |
51 | struct irc_sockaddr addr; /**< socket name (ip addr, port, family ) */ | |
52 | char count; /**< number of pings requested */ | |
53 | char sent; /**< pings sent */ | |
54 | char received; /**< pings received */ | |
55 | char active; /**< ping active flag */ | |
56 | struct Client* client; /**< who requested the pings */ | |
57 | time_t lastsent; /**< when last ping was sent */ | |
58 | int ms_min; /**< minimum time in milliseconds */ | |
59 | int ms_ave; /**< average time in milliseconds */ | |
60 | int ms_max; /**< maximum time in milliseconds */ | |
61 | struct Socket socket; /**< socket structure */ | |
62 | struct Timer sender; /**< timer telling when next to send a ping */ | |
63 | struct Timer killer; /**< timer to kill us */ | |
64 | unsigned int freeable; /**< zero when structure can be free()'d */ | |
65 | char name[HOSTLEN + 1]; /**< server name to poing */ | |
66 | char buf[BUFSIZE]; /**< buffer to hold ping times */ | |
67 | }; | |
68 | ||
69 | #define UPING_PENDING_SOCKET 0x01 /**< pending socket destruction event */ | |
70 | #define UPING_PENDING_SENDER 0x02 /**< pending sender destruction event */ | |
71 | #define UPING_PENDING_KILLER 0x04 /**< pending killer destruction event */ | |
72 | ||
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 struct UPing* uping_begin(void); | |
79 | extern int uping_server(struct Client* sptr, struct ConfItem* aconf, int port, int count); | |
80 | ||
81 | ||
82 | #endif /* INCLUDED_uping_h */ |