1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* $OpenBSD: unwind.h,v 1.2 2019/01/24 17:39:43 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif
#define CONF_FILE "/etc/unwind.conf"
#define UNWIND_SOCKET "/var/run/unwind.sock"
#define UNWIND_USER "_unwind"
#define OPT_VERBOSE 0x00000001
#define OPT_VERBOSE2 0x00000002
#define OPT_NOACTION 0x00000004
enum {
PROC_MAIN,
PROC_RESOLVER,
PROC_FRONTEND
} unwind_process;
static const char * const log_procnames[] = {
"main",
"resolver",
"frontend",
};
struct imsgev {
struct imsgbuf ibuf;
void (*handler)(int, short, void *);
struct event ev;
short events;
};
enum imsg_type {
IMSG_NONE,
IMSG_CTL_LOG_VERBOSE,
IMSG_CTL_RELOAD,
IMSG_CTL_STATUS,
IMSG_RECONF_CONF,
IMSG_RECONF_FORWARDER,
IMSG_RECONF_END,
IMSG_UDP4SOCK,
IMSG_UDP6SOCK,
IMSG_ROUTESOCK,
IMSG_CONTROLFD,
IMSG_STARTUP,
IMSG_STARTUP_DONE,
IMSG_SHUTDOWN,
IMSG_SOCKET_IPC,
IMSG_QUERY,
IMSG_ANSWER_HEADER,
IMSG_ANSWER,
IMSG_OPEN_DHCP_LEASE,
IMSG_LEASEFD,
IMSG_FORWARDER,
IMSG_RESOLVER_DOWN,
IMSG_RESOLVER_UP,
IMSG_OPEN_PORTS,
IMSG_CTL_RESOLVER_INFO,
IMSG_CTL_RESOLVER_WHY_BOGUS,
IMSG_CTL_RESOLVER_HISTOGRAM,
IMSG_CTL_END
};
struct unwind_forwarder {
SIMPLEQ_ENTRY(unwind_forwarder) entry;
char name[1024]; /* XXX */
};
struct unwind_conf {
SIMPLEQ_HEAD(unwind_forwarder_head, unwind_forwarder) unwind_forwarder_list;
int unwind_options;
};
struct query_imsg {
uint64_t id;
char qname[255];
int t;
int c;
int err;
int bogus;
int async_id;
void *resolver;
struct timespec tp;
};
extern uint32_t cmd_opts;
/* unwind.c */
void main_imsg_compose_frontend(int, pid_t, void *, uint16_t);
void main_imsg_compose_frontend_fd(int, pid_t, int);
void main_imsg_compose_resolver(int, pid_t, void *, uint16_t);
void merge_config(struct unwind_conf *, struct unwind_conf *);
void imsg_event_add(struct imsgev *);
int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t,
int, void *, uint16_t);
struct unwind_conf *config_new_empty(void);
void config_clear(struct unwind_conf *);
/* printconf.c */
void print_config(struct unwind_conf *);
/* parse.y */
struct unwind_conf *parse_config(char *);
int cmdline_symset(char *);
|