1 /* $OpenBSD: slaacd.h,v 1.33 2021/03/21 18:25:24 florian Exp $ */ 2 3 /* 4 * Copyright (c) 2017 Florian Obser <florian@openbsd.org> 5 * Copyright (c) 2004 Esben Norby <norby@openbsd.org> 6 * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> 7 * 8 * Permission to use, copy, modify, and distribute this software for any 9 * purpose with or without fee is hereby granted, provided that the above 10 * copyright notice and this permission notice appear in all copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21 #define _PATH_SLAACD_SOCKET "/dev/slaacd.sock" 22 #define SLAACD_USER "_slaacd" 23 #define SLAACD_RTA_LABEL "slaacd" 24 25 #define SLAACD_SOIIKEY_LEN 16 26 27 /* MAXDNAME from arpa/namesr.h */ 28 #define SLAACD_MAX_DNSSL 1025 29 30 #define MAX_RDNS_COUNT 8 /* max nameserver in a RTM_PROPOSAL */ 31 32 #define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE) 33 34 struct imsgev { 35 struct imsgbuf ibuf; 36 void (*handler)(int, short, void *); 37 struct event ev; 38 short events; 39 }; 40 41 enum imsg_type { 42 IMSG_NONE, 43 #ifndef SMALL 44 IMSG_CTL_LOG_VERBOSE, 45 IMSG_CTL_SHOW_INTERFACE_INFO, 46 IMSG_CTL_SHOW_INTERFACE_INFO_RA, 47 IMSG_CTL_SHOW_INTERFACE_INFO_RA_PREFIX, 48 IMSG_CTL_SHOW_INTERFACE_INFO_RA_RDNS, 49 IMSG_CTL_SHOW_INTERFACE_INFO_RA_DNSSL, 50 IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSALS, 51 IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSAL, 52 IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSALS, 53 IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSAL, 54 IMSG_CTL_SHOW_INTERFACE_INFO_RDNS_PROPOSALS, 55 IMSG_CTL_SHOW_INTERFACE_INFO_RDNS_PROPOSAL, 56 IMSG_CTL_END, 57 IMSG_UPDATE_ADDRESS, 58 IMSG_PROPOSE_RDNS, 59 IMSG_REPROPOSE_RDNS, 60 #endif /* SMALL */ 61 IMSG_CTL_SEND_SOLICITATION, 62 IMSG_SOCKET_IPC, 63 IMSG_OPEN_ICMP6SOCK, 64 IMSG_ICMP6SOCK, 65 IMSG_ROUTESOCK, 66 IMSG_CONTROLFD, 67 IMSG_STARTUP, 68 IMSG_UPDATE_IF, 69 IMSG_REMOVE_IF, 70 IMSG_RA, 71 IMSG_CONFIGURE_ADDRESS, 72 IMSG_WITHDRAW_ADDRESS, 73 IMSG_DEL_ADDRESS, 74 IMSG_DEL_ROUTE, 75 IMSG_CONFIGURE_DFR, 76 IMSG_WITHDRAW_DFR, 77 IMSG_DUP_ADDRESS, 78 }; 79 80 enum rpref { 81 LOW, 82 MEDIUM, 83 HIGH, 84 }; 85 86 #ifndef SMALL 87 struct ctl_engine_info { 88 uint32_t if_index; 89 int running; 90 int autoconf; 91 int temporary; 92 int soii; 93 struct ether_addr hw_address; 94 struct sockaddr_in6 ll_address; 95 }; 96 97 struct ctl_engine_info_ra { 98 struct sockaddr_in6 from; 99 struct timespec when; 100 struct timespec uptime; 101 uint8_t curhoplimit; 102 int managed; 103 int other; 104 char rpref[sizeof("MEDIUM")]; 105 uint16_t router_lifetime; /* in seconds */ 106 uint32_t reachable_time; /* in milliseconds */ 107 uint32_t retrans_time; /* in milliseconds */ 108 uint32_t mtu; 109 }; 110 111 struct ctl_engine_info_ra_prefix { 112 struct in6_addr prefix; 113 uint8_t prefix_len; 114 int onlink; 115 int autonomous; 116 uint32_t vltime; 117 uint32_t pltime; 118 }; 119 120 struct ctl_engine_info_ra_rdns { 121 uint32_t lifetime; 122 struct in6_addr rdns; 123 }; 124 125 struct ctl_engine_info_ra_dnssl { 126 uint32_t lifetime; 127 char dnssl[SLAACD_MAX_DNSSL]; 128 }; 129 130 struct ctl_engine_info_address_proposal { 131 int64_t id; 132 char state[sizeof("PROPOSAL_NEARLY_EXPIRED")]; 133 time_t next_timeout; 134 int timeout_count; 135 struct timespec when; 136 struct timespec uptime; 137 struct sockaddr_in6 addr; 138 struct in6_addr prefix; 139 int temporary; 140 uint8_t prefix_len; 141 uint32_t vltime; 142 uint32_t pltime; 143 }; 144 145 struct ctl_engine_info_dfr_proposal { 146 int64_t id; 147 char state[sizeof("PROPOSAL_NEARLY_EXPIRED")]; 148 time_t next_timeout; 149 int timeout_count; 150 struct timespec when; 151 struct timespec uptime; 152 struct sockaddr_in6 addr; 153 uint32_t router_lifetime; 154 char rpref[sizeof("MEDIUM")]; 155 }; 156 157 struct ctl_engine_info_rdns_proposal { 158 int64_t id; 159 char state[sizeof("PROPOSAL_NEARLY_EXPIRED")]; 160 time_t next_timeout; 161 int timeout_count; 162 struct timespec when; 163 struct timespec uptime; 164 struct sockaddr_in6 from; 165 uint32_t rdns_lifetime; 166 int rdns_count; 167 struct in6_addr rdns[MAX_RDNS_COUNT]; 168 }; 169 170 struct imsg_addrinfo { 171 uint32_t if_index; 172 struct sockaddr_in6 addr; 173 struct in6_addr mask; 174 int temporary; 175 uint32_t vltime; 176 uint32_t pltime; 177 }; 178 179 struct imsg_propose_rdns { 180 uint32_t if_index; 181 int rdomain; 182 int rdns_count; 183 struct in6_addr rdns[MAX_RDNS_COUNT]; 184 }; 185 186 #endif /* SMALL */ 187 188 struct imsg_ifinfo { 189 uint32_t if_index; 190 int rdomain; 191 int running; 192 int link_state; 193 int autoconf; 194 int temporary; 195 int soii; 196 struct ether_addr hw_address; 197 struct sockaddr_in6 ll_address; 198 uint8_t soiikey[SLAACD_SOIIKEY_LEN]; 199 }; 200 201 struct imsg_del_addr { 202 uint32_t if_index; 203 struct sockaddr_in6 addr; 204 }; 205 206 struct imsg_del_route { 207 uint32_t if_index; 208 struct sockaddr_in6 gw; 209 }; 210 211 struct imsg_ra { 212 uint32_t if_index; 213 struct sockaddr_in6 from; 214 ssize_t len; 215 uint8_t packet[1500]; 216 }; 217 218 struct imsg_dup_addr { 219 uint32_t if_index; 220 struct sockaddr_in6 addr; 221 }; 222 223 /* slaacd.c */ 224 void imsg_event_add(struct imsgev *); 225 int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, 226 int, void *, uint16_t); 227 #ifndef SMALL 228 const char *sin6_to_str(struct sockaddr_in6 *); 229 #else 230 #define sin6_to_str(x...) "" 231 #endif /* SMALL */ 232