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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
/* $OpenBSD: slaacd.h,v 1.8 2017/08/21 14:44:26 florian Exp $ */
/*
* Copyright (c) 2017 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.
*/
#define SLAACD_SOCKET "/dev/slaacd.sock"
#define SLAACD_USER "_slaacd"
#define OPT_VERBOSE 0x00000001
#define OPT_VERBOSE2 0x00000002
/* MAXDNAME from arpa/namesr.h */
#define SLAACD_MAX_DNSSL 1025
static const char * const log_procnames[] = {
"main",
"frontend",
"engine"
};
struct imsgev {
struct imsgbuf ibuf;
void (*handler)(int, short, void *);
struct event ev;
short events;
};
enum imsg_type {
IMSG_NONE,
#ifndef SMALL
IMSG_CTL_LOG_VERBOSE,
IMSG_CTL_SHOW_INTERFACE_INFO,
IMSG_CTL_SHOW_INTERFACE_INFO_RA,
IMSG_CTL_SHOW_INTERFACE_INFO_RA_PREFIX,
IMSG_CTL_SHOW_INTERFACE_INFO_RA_RDNS,
IMSG_CTL_SHOW_INTERFACE_INFO_RA_DNSSL,
IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSALS,
IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSAL,
IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSALS,
IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSAL,
IMSG_CTL_END,
#endif /* SMALL */
IMSG_CTL_SEND_SOLICITATION,
IMSG_SOCKET_IPC,
IMSG_STARTUP,
IMSG_UPDATE_IF,
IMSG_REMOVE_IF,
IMSG_RA,
IMSG_PROPOSAL,
IMSG_PROPOSAL_ACK,
IMSG_CONFIGURE_ADDRESS,
IMSG_DEL_ADDRESS,
IMSG_FAKE_ACK,
IMSG_CONFIGURE_DFR,
IMSG_WITHDRAW_DFR,
};
extern const char* imsg_type_name[];
enum {
PROC_MAIN,
PROC_ENGINE,
PROC_FRONTEND
} slaacd_process;
enum rpref {
LOW,
MEDIUM,
HIGH,
};
#ifndef SMALL
struct ctl_engine_info {
uint32_t if_index;
int running;
int autoconfprivacy;
struct ether_addr hw_address;
struct sockaddr_in6 ll_address;
};
struct ctl_engine_info_ra {
struct sockaddr_in6 from;
struct timespec when;
struct timespec uptime;
uint8_t curhoplimit;
int managed;
int other;
char rpref[sizeof("MEDIUM")];
uint16_t router_lifetime; /* in seconds */
uint32_t reachable_time; /* in milliseconds */
uint32_t retrans_time; /* in milliseconds */
};
struct ctl_engine_info_ra_prefix {
struct in6_addr prefix;
uint8_t prefix_len;
int onlink;
int autonomous;
uint32_t vltime;
uint32_t pltime;
};
struct ctl_engine_info_ra_rdns {
uint32_t lifetime;
struct in6_addr rdns;
};
struct ctl_engine_info_ra_dnssl {
uint32_t lifetime;
char dnssl[SLAACD_MAX_DNSSL];
};
struct ctl_engine_info_address_proposal {
int64_t id;
char state[sizeof("PROPOSAL_NEARLY_EXPIRED")];
time_t next_timeout;
int timeout_count;
struct timespec when;
struct timespec uptime;
struct sockaddr_in6 addr;
struct in6_addr prefix;
int privacy;
uint8_t prefix_len;
uint32_t vltime;
uint32_t pltime;
};
struct ctl_engine_info_dfr_proposal {
int64_t id;
char state[sizeof("PROPOSAL_NEARLY_EXPIRED")];
time_t next_timeout;
int timeout_count;
struct timespec when;
struct timespec uptime;
struct sockaddr_in6 addr;
uint32_t router_lifetime;
char rpref[sizeof("MEDIUM")];
};
#endif /* SMALL */
struct imsg_ifinfo {
uint32_t if_index;
int running;
int autoconfprivacy;
struct ether_addr hw_address;
struct sockaddr_in6 ll_address;
};
struct imsg_del_addr {
uint32_t if_index;
struct sockaddr_in6 addr;
};
struct imsg_proposal_ack {
int64_t id;
pid_t pid;
uint32_t if_index;
};
struct imsg_ra {
uint32_t if_index;
struct sockaddr_in6 from;
ssize_t len;
uint8_t packet[1500];
};
extern uint32_t cmd_opts;
/* slaacd.c */
int main_imsg_compose_frontend(int, pid_t, void *, uint16_t);
int main_imsg_compose_engine(int, pid_t, void *, uint16_t);
void imsg_event_add(struct imsgev *);
int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t,
int, void *, uint16_t);
#ifndef SMALL
const char *sin6_to_str(struct sockaddr_in6 *);
#else
#define sin6_to_str(x...) ""
#endif /* SMALL */
|