| 1 |
adx |
30 |
/* |
| 2 |
michael |
2865 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
adx |
30 |
* |
| 4 |
michael |
2865 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 5 |
adx |
30 |
* |
| 6 |
|
|
* This program is free software; you can redistribute it and/or modify |
| 7 |
|
|
* it under the terms of the GNU General Public License as published by |
| 8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
|
|
* (at your option) any later version. |
| 10 |
|
|
* |
| 11 |
|
|
* This program is distributed in the hope that it will be useful, |
| 12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
|
|
* GNU General Public License for more details. |
| 15 |
|
|
* |
| 16 |
|
|
* You should have received a copy of the GNU General Public License |
| 17 |
|
|
* along with this program; if not, write to the Free Software |
| 18 |
michael |
4565 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
adx |
30 |
* USA |
| 20 |
|
|
*/ |
| 21 |
|
|
|
| 22 |
michael |
2865 |
/*! \file fdlist.h |
| 23 |
|
|
* \brief The file descriptor list header. |
| 24 |
|
|
* \version $Id$ |
| 25 |
|
|
*/ |
| 26 |
|
|
|
| 27 |
adx |
30 |
#ifndef INCLUDED_fdlist_h |
| 28 |
|
|
#define INCLUDED_fdlist_h |
| 29 |
|
|
#define FILEIO_V2 |
| 30 |
|
|
|
| 31 |
|
|
#include "ircd_defs.h" |
| 32 |
|
|
#define FD_DESC_SZ 128 /* hostlen + comment */ |
| 33 |
|
|
|
| 34 |
michael |
2865 |
enum |
| 35 |
|
|
{ |
| 36 |
|
|
COMM_OK, |
| 37 |
|
|
COMM_ERR_BIND, |
| 38 |
|
|
COMM_ERR_DNS, |
| 39 |
|
|
COMM_ERR_TIMEOUT, |
| 40 |
|
|
COMM_ERR_CONNECT, |
| 41 |
|
|
COMM_ERROR, |
| 42 |
|
|
COMM_ERR_MAX |
| 43 |
adx |
30 |
}; |
| 44 |
|
|
|
| 45 |
|
|
struct _fde; |
| 46 |
|
|
struct Client; |
| 47 |
|
|
|
| 48 |
michael |
2865 |
typedef struct _fde |
| 49 |
|
|
{ |
| 50 |
adx |
30 |
/* New-school stuff, again pretty much ripped from squid */ |
| 51 |
|
|
/* |
| 52 |
|
|
* Yes, this gives us only one pending read and one pending write per |
| 53 |
|
|
* filedescriptor. Think though: when do you think we'll need more? |
| 54 |
|
|
*/ |
| 55 |
michael |
2865 |
int fd; /* So we can use the fde_t as a callback ptr */ |
| 56 |
|
|
int comm_index; /* where in the poll list we live */ |
| 57 |
adx |
30 |
int evcache; /* current fd events as set up by the underlying I/O */ |
| 58 |
|
|
char desc[FD_DESC_SZ]; |
| 59 |
michael |
4461 |
void (*read_handler)(struct _fde *, void *); |
| 60 |
adx |
30 |
void *read_data; |
| 61 |
michael |
4461 |
void (*write_handler)(struct _fde *, void *); |
| 62 |
adx |
30 |
void *write_data; |
| 63 |
michael |
4461 |
void (*timeout_handler)(struct _fde *, void *); |
| 64 |
adx |
30 |
void *timeout_data; |
| 65 |
|
|
time_t timeout; |
| 66 |
michael |
4461 |
void (*flush_handler)(struct _fde *, void *); |
| 67 |
adx |
30 |
void *flush_data; |
| 68 |
|
|
time_t flush_timeout; |
| 69 |
michael |
992 |
|
| 70 |
michael |
2865 |
struct |
| 71 |
|
|
{ |
| 72 |
adx |
30 |
unsigned int open:1; |
| 73 |
|
|
unsigned int is_socket:1; |
| 74 |
|
|
} flags; |
| 75 |
|
|
|
| 76 |
michael |
2865 |
struct |
| 77 |
|
|
{ |
| 78 |
adx |
30 |
/* We don't need the host here ? */ |
| 79 |
|
|
struct irc_ssaddr S; |
| 80 |
|
|
struct irc_ssaddr hostaddr; |
| 81 |
michael |
4464 |
void (*callback)(struct _fde *, int, void *); |
| 82 |
adx |
30 |
void *data; |
| 83 |
|
|
/* We'd also add the retry count here when we get to that -- adrian */ |
| 84 |
|
|
} connect; |
| 85 |
|
|
#ifdef HAVE_LIBCRYPTO |
| 86 |
|
|
SSL *ssl; |
| 87 |
|
|
#endif |
| 88 |
|
|
struct _fde *hnext; |
| 89 |
|
|
} fde_t; |
| 90 |
|
|
|
| 91 |
michael |
1654 |
#define FD_HASH_SIZE 1024 |
| 92 |
adx |
30 |
|
| 93 |
|
|
extern int number_fd; |
| 94 |
|
|
extern int hard_fdlimit; |
| 95 |
|
|
extern fde_t *fd_hash[]; |
| 96 |
|
|
extern fde_t *fd_next_in_loop; |
| 97 |
|
|
|
| 98 |
|
|
extern void fdlist_init(void); |
| 99 |
|
|
extern fde_t *lookup_fd(int); |
| 100 |
|
|
extern void fd_open(fde_t *, int, int, const char *); |
| 101 |
|
|
extern void fd_close(fde_t *); |
| 102 |
michael |
4479 |
extern void fd_dump(struct Client *, int, char *[]); |
| 103 |
michael |
1015 |
extern void fd_note(fde_t *, const char *, ...); |
| 104 |
adx |
30 |
extern void close_standard_fds(void); |
| 105 |
|
|
extern void close_fds(fde_t *); |
| 106 |
|
|
#endif /* INCLUDED_fdlist_h */ |