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