ec03e1699b16a4b900c3c0fe21bcad51710f8929
[ircu2.10.12-pk.git] / include / listener.h
1 /* - Internet Relay Chat, include/listener.h
2  *   Copyright (C) 1999 Thomas Helvey <tomh@inxpress.net>
3  *
4  *   This program is free software; you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 1, or (at your option)
7  *   any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *   GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program; if not, write to the Free Software
16  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  *
19  * $Id$
20  */
21 #ifndef INCLUDED_listener_h
22 #define INCLUDED_listener_h
23 #ifndef INCLUDED_ircd_defs_h
24 #include "ircd_defs.h"       /* HOSTLEN */
25 #endif
26 #ifndef INCLUDED_ircd_events_h
27 #include "ircd_events.h"
28 #endif
29 #ifndef INCLUDED_sys_types_h
30 #include <sys/types.h>       /* size_t, broken BSD system headers */
31 #define INCLUDED_sys_types_h
32 #endif
33 #ifndef INCLUDED_netinet_in_h
34 #include <netinet/in.h>      /* in_addr */
35 #define INCLUDED_netinet_in_h
36 #endif
37
38 struct Client;
39 struct StatDesc;
40
41 struct Listener {
42   struct Listener* next;               /* list node pointer */
43   int              fd;                 /* file descriptor */
44   int              port;               /* listener IP port */
45   int              ref_count;          /* number of connection references */
46   unsigned char    active;             /* current state of listener */
47   unsigned char    hidden;             /* hidden in stats output for clients */
48   unsigned char    server;             /* 1 if port is a server listener */
49   int              index;              /* index into poll array */
50   time_t           last_accept;        /* last time listener accepted */
51   struct in_addr   addr;               /* virtual address or INADDR_ANY */
52   struct in_addr   mask;               /* listener hostmask */
53   struct Socket    socket;             /* describe socket to event system */
54 };
55
56 extern struct Listener* ListenerPollList; /* GLOBAL - listener list */
57
58 extern void        add_listener(int port, const char* vaddr_ip, 
59                                 const char* mask, int is_server, 
60                                 int is_hidden);
61 extern void        close_listener(struct Listener* listener);
62 extern void        close_listeners(void);
63 extern void        count_listener_memory(int* count_out, size_t* size_out);
64 extern const char* get_listener_name(const struct Listener* listener);
65 extern void        mark_listeners_closing(void);
66 extern void show_ports(struct Client* client, struct StatDesc* sd, int stat,
67                        char* param);
68 extern void        release_listener(struct Listener* listener);
69
70 #endif /* INCLUDED_listener_h */
71