289c5ecfb2946af59b3e5b0c55097cd613b50a08
[ircu2.10.12-pk.git] / include / s_bsd.h
1 /*
2  * s_bsd.h
3  *
4  * $Id$
5  */
6 #ifndef INCLUDED_s_bsd_h
7 #define INCLUDED_s_bsd_h
8 #ifndef INCLUDED_sys_types_h
9 #include <sys/types.h>         /* size_t, time_t */
10 #define INCLUDED_sys_types_h
11 #endif
12 #ifndef INCLUDED_netinet_in_h
13 #include <netinet/in.h>
14 #define INCLUDED_netinet_in_h
15 #endif
16
17 struct Client;
18 struct ConfItem;
19 struct Listener;
20 struct MsgQ;
21
22 /*
23  * TCP window sizes
24  * Set server window to a large value for fat pipes,
25  * set client to a smaller size to allow TCP flow control
26  * to reduce flooding
27  */
28 #define SERVER_TCP_WINDOW 61440
29 #define CLIENT_TCP_WINDOW 2048
30
31 extern void report_error(const char* text, const char* who, int err);
32 /*
33  * text for report_error
34  */
35 extern const char* const BIND_ERROR_MSG;
36 extern const char* const LISTEN_ERROR_MSG;
37 extern const char* const NONB_ERROR_MSG;
38 extern const char* const REUSEADDR_ERROR_MSG;
39 extern const char* const SOCKET_ERROR_MSG;
40 extern const char* const CONNLIMIT_ERROR_MSG;
41 extern const char* const ACCEPT_ERROR_MSG;
42 extern const char* const PEERNAME_ERROR_MSG;
43 extern const char* const POLL_ERROR_MSG;
44 extern const char* const SELECT_ERROR_MSG;
45 extern const char* const CONNECT_ERROR_MSG;
46 extern const char* const SETBUFS_ERROR_MSG;
47 extern const char* const TOS_ERROR_MSG;
48 extern const char* const REGISTER_ERROR_MSG;
49
50
51 extern int            HighestFd;
52 extern struct Client* LocalClientArray[MAXCONNECTIONS];
53 extern int            OpenFileDescriptorCount;
54
55 extern struct sockaddr_in VirtualHost;
56
57 enum PollType {
58   PT_NONE,
59   PT_READ,
60   PT_WRITE
61 };
62
63 struct Pollable;
64
65 typedef int (*PollReadyFn)(struct Pollable*);
66
67 struct Pollable {
68   struct Pollable* next;
69   struct Pollable* prev;
70   int              fd;
71   int              index;
72   int              state;
73   PollReadyFn      r_handler;
74   PollReadyFn      w_handler;
75 };
76   
77 /*
78  * Proto types
79  */
80 extern unsigned int deliver_it(struct Client *cptr, struct MsgQ *buf);
81 extern int connect_server(struct ConfItem* aconf, struct Client* by);
82 extern void release_dns_reply(struct Client* cptr);
83 extern int  net_close_unregistered_connections(struct Client* source);
84 extern void close_connection(struct Client *cptr);
85 extern void add_connection(struct Listener* listener, int fd);
86 extern int  read_message(time_t delay);
87 extern void init_server_identity(void);
88 extern void close_connections(int close_stderr);
89 extern int  init_connection_limits(void);
90 extern void set_virtual_host(struct in_addr addr);
91 extern void update_write(struct Client* cptr);
92
93 #endif /* INCLUDED_s_bsd_h */