1 |
/* |
---|
2 |
* Copyright (c) 2007, OmniTI Computer Consulting, Inc. |
---|
3 |
* All rights reserved. |
---|
4 |
* |
---|
5 |
* Redistribution and use in source and binary forms, with or without |
---|
6 |
* modification, are permitted provided that the following conditions are |
---|
7 |
* met: |
---|
8 |
* |
---|
9 |
* * Redistributions of source code must retain the above copyright |
---|
10 |
* notice, this list of conditions and the following disclaimer. |
---|
11 |
* * Redistributions in binary form must reproduce the above |
---|
12 |
* copyright notice, this list of conditions and the following |
---|
13 |
* disclaimer in the documentation and/or other materials provided |
---|
14 |
* with the distribution. |
---|
15 |
* * Neither the name OmniTI Computer Consulting, Inc. nor the names |
---|
16 |
* of its contributors may be used to endorse or promote products |
---|
17 |
* derived from this software without specific prior written |
---|
18 |
* permission. |
---|
19 |
* |
---|
20 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
21 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
22 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
23 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
24 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
25 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
26 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
27 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
28 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
29 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
30 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
31 |
*/ |
---|
32 |
|
---|
33 |
#ifndef _NOIT_LISTENER_H |
---|
34 |
#define _NOIT_LISTENER_H |
---|
35 |
|
---|
36 |
#include "noit_defines.h" |
---|
37 |
#include "eventer/eventer.h" |
---|
38 |
#include "utils/noit_hash.h" |
---|
39 |
|
---|
40 |
#include <sys/types.h> |
---|
41 |
#include <sys/socket.h> |
---|
42 |
#ifdef HAVE_SYS_FILIO_H |
---|
43 |
#include <sys/filio.h> |
---|
44 |
#endif |
---|
45 |
#include <netinet/in.h> |
---|
46 |
|
---|
47 |
typedef struct { |
---|
48 |
union { |
---|
49 |
struct sockaddr remote_addr; |
---|
50 |
struct sockaddr_in remote_addr4; |
---|
51 |
struct sockaddr_in6 remote_addr6; |
---|
52 |
} remote; |
---|
53 |
char *remote_cn; |
---|
54 |
noit_hash_table *config; |
---|
55 |
void *service_ctx; |
---|
56 |
eventer_func_t dispatch; |
---|
57 |
u_int32_t cmd; |
---|
58 |
} acceptor_closure_t; |
---|
59 |
|
---|
60 |
typedef struct { |
---|
61 |
int8_t family; |
---|
62 |
unsigned short port; |
---|
63 |
eventer_func_t dispatch_callback; |
---|
64 |
acceptor_closure_t *dispatch_closure; |
---|
65 |
noit_hash_table *sslconfig; |
---|
66 |
} * listener_closure_t; |
---|
67 |
|
---|
68 |
API_EXPORT(void) noit_listener_init(const char *toplevel); |
---|
69 |
|
---|
70 |
API_EXPORT(int) |
---|
71 |
noit_listener(char *host, unsigned short port, int type, |
---|
72 |
int backlog, noit_hash_table *sslconfig, |
---|
73 |
noit_hash_table *config, |
---|
74 |
eventer_func_t handler, void *service_ctx); |
---|
75 |
|
---|
76 |
API_EXPORT(void) |
---|
77 |
acceptor_closure_free(acceptor_closure_t *ac); |
---|
78 |
|
---|
79 |
API_EXPORT(void) |
---|
80 |
noit_control_dispatch_delegate(eventer_func_t listener_dispatch, |
---|
81 |
u_int32_t cmd, |
---|
82 |
eventer_func_t delegate_dispatch); |
---|
83 |
|
---|
84 |
API_EXPORT(int) |
---|
85 |
noit_control_dispatch(eventer_t, int, void *, struct timeval *); |
---|
86 |
|
---|
87 |
API_EXPORT(noit_hash_table *) |
---|
88 |
noit_listener_commands(); |
---|
89 |
|
---|
90 |
#endif |
---|