| 1 |
/* |
| 2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
* |
| 4 |
* Copyright (c) 1997-2020 ircd-hybrid development team |
| 5 |
* |
| 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 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
* USA |
| 20 |
*/ |
| 21 |
|
| 22 |
/*! \file fdlist.h |
| 23 |
* \brief The file descriptor list header. |
| 24 |
* \version $Id$ |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef INCLUDED_fdlist_h |
| 28 |
#define INCLUDED_fdlist_h |
| 29 |
|
| 30 |
#include "ircd_defs.h" |
| 31 |
#include "tls.h" |
| 32 |
|
| 33 |
|
| 34 |
enum { FD_DESC_SIZE = 80 }; /* HOSTLEN + comment */ |
| 35 |
|
| 36 |
typedef struct _fde |
| 37 |
{ |
| 38 |
/* New-school stuff, again pretty much ripped from squid */ |
| 39 |
/* |
| 40 |
* Yes, this gives us only one pending read and one pending write per |
| 41 |
* filedescriptor. Think though: when do you think we'll need more? |
| 42 |
*/ |
| 43 |
int fd; /* So we can use the fde_t as a callback ptr */ |
| 44 |
int comm_index; /* where in the poll list we live */ |
| 45 |
int evcache; /* current fd events as set up by the underlying I/O */ |
| 46 |
char *desc; |
| 47 |
|
| 48 |
void (*read_handler)(struct _fde *, void *); |
| 49 |
void *read_data; |
| 50 |
|
| 51 |
void (*write_handler)(struct _fde *, void *); |
| 52 |
void *write_data; |
| 53 |
|
| 54 |
void (*timeout_handler)(struct _fde *, void *); |
| 55 |
void *timeout_data; |
| 56 |
uintmax_t timeout; |
| 57 |
|
| 58 |
void (*flush_handler)(struct _fde *, void *); |
| 59 |
void *flush_data; |
| 60 |
uintmax_t flush_timeout; |
| 61 |
|
| 62 |
struct |
| 63 |
{ |
| 64 |
bool open; |
| 65 |
bool is_socket; |
| 66 |
} flags; |
| 67 |
|
| 68 |
struct |
| 69 |
{ |
| 70 |
/* We don't need the host here ? */ |
| 71 |
struct irc_ssaddr hostaddr; |
| 72 |
|
| 73 |
void (*callback)(struct _fde *, int, void *); |
| 74 |
void *data; |
| 75 |
/* We'd also add the retry count here when we get to that -- adrian */ |
| 76 |
} connect; |
| 77 |
|
| 78 |
tls_data_t tls; |
| 79 |
} fde_t; |
| 80 |
|
| 81 |
extern int number_fd; |
| 82 |
extern int hard_fdlimit; |
| 83 |
extern int highest_fd; |
| 84 |
extern fde_t *fd_table; |
| 85 |
|
| 86 |
extern void fdlist_init(void); |
| 87 |
extern fde_t *fd_open(int, bool, const char *); |
| 88 |
extern fde_t *fd_close(fde_t *); |
| 89 |
extern void fd_note(fde_t *, const char *, ...); |
| 90 |
extern void close_standard_fds(void); |
| 91 |
extern void close_fds(void); |
| 92 |
#endif |