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