Print this page
7388 Support DHCP Client FQDN. Allow IAID/DUID for all v4.
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/libipadm/common/libipadm.h
+++ new/usr/src/lib/libipadm/common/libipadm.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 + * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
23 24 */
24 25 #ifndef _LIBIPADM_H
25 26 #define _LIBIPADM_H
26 27
27 28 #ifdef __cplusplus
28 29 extern "C" {
29 30 #endif
30 31
31 32 #include <sys/types.h>
33 +#include <sys/param.h>
32 34 #include <sys/socket.h>
33 35 #include <net/if.h>
34 36 #include <netdb.h>
35 37 #include <ifaddrs.h>
36 38 #include <libnvpair.h>
37 39 #include <netinet/tcp.h>
38 40 #include <sys/stropts.h>
39 41
40 42 #define IPADM_AOBJ_USTRSIZ 32
41 43 #define IPADM_AOBJSIZ (LIFNAMSIZ + IPADM_AOBJ_USTRSIZ)
42 44 #define MAXPROPVALLEN 512
43 45 #define LOOPBACK_IF "lo0"
44 46
45 47 /* special timeout values for dhcp operations */
46 48 #define IPADM_DHCP_WAIT_DEFAULT (-1)
47 49 #define IPADM_DHCP_WAIT_FOREVER (-2)
48 50
49 51 /*
50 52 * Specifies that the string passed to ipadm_str2nvlist() is a string of comma
51 53 * separated names and that each name does not have values associated with it.
52 54 */
53 55 #define IPADM_NORVAL 0x00000001
54 56
55 57 /* error codes */
56 58 typedef enum {
57 59 IPADM_SUCCESS, /* No error occurred */
58 60 IPADM_FAILURE, /* Generic failure */
59 61 IPADM_EAUTH, /* Insufficient user authorizations */
60 62 IPADM_EPERM, /* Permission denied */
61 63 IPADM_NO_BUFS, /* No Buffer space available */
62 64 IPADM_NO_MEMORY, /* Insufficient memory */
63 65 IPADM_BAD_ADDR, /* Invalid address */
64 66 IPADM_BAD_PROTOCOL, /* Wrong protocol family for operation */
65 67 IPADM_DAD_FOUND, /* Duplicate address detected */
66 68 IPADM_EXISTS, /* Already exists */
67 69 IPADM_IF_EXISTS, /* Interface already exists */
68 70 IPADM_ADDROBJ_EXISTS, /* Address object already exists */
69 71 IPADM_ADDRCONF_EXISTS, /* Addrconf already in progress */
70 72 IPADM_ENXIO, /* Interface does not exist */
71 73 IPADM_GRP_NOTEMPTY, /* IPMP Group non-empty on unplumb */
72 74 IPADM_INVALID_ARG, /* Invalid argument */
73 75 IPADM_INVALID_NAME, /* Invalid name */
74 76 IPADM_DLPI_FAILURE, /* Could not open DLPI link */
75 77 IPADM_DLADM_FAILURE, /* DLADM error encountered */
76 78 IPADM_PROP_UNKNOWN, /* Unknown property */
77 79 IPADM_ERANGE, /* Value is outside the allowed range */
78 80 IPADM_ESRCH, /* Value does not exist */
79 81 IPADM_EOVERFLOW, /* Number of values exceed the allowed limit */
80 82 IPADM_NOTFOUND, /* Object not found */
81 83 IPADM_IF_INUSE, /* Interface already in use */
82 84 IPADM_ADDR_INUSE, /* Address alrelady in use */
83 85 IPADM_BAD_HOSTNAME, /* hostname maps to multiple IP addresses */
84 86 IPADM_ADDR_NOTAVAIL, /* Can't assign requested address */
85 87 IPADM_ALL_ADDRS_NOT_ENABLED, /* All addresses could not be enabled */
86 88 IPADM_NDPD_NOT_RUNNING, /* in.ndpd not running */
87 89 IPADM_DHCP_START_ERROR, /* Cannot start dhcpagent */
88 90 IPADM_DHCP_IPC_ERROR, /* Cannot communicate with dhcpagent */
89 91 IPADM_DHCP_IPC_TIMEOUT, /* Communication with dhcpagent timed out */
90 92 IPADM_TEMPORARY_OBJ, /* Permanent operation on temporary object */
91 93 IPADM_IPC_ERROR, /* Cannot communicate with ipmgmtd */
92 94 IPADM_OP_DISABLE_OBJ, /* Operation on disable object */
93 95 IPADM_NOTSUP, /* Operation not supported */
|
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
94 96 IPADM_EBADE, /* Invalid data exchange with ipmgmtd */
95 97 IPADM_GZ_PERM /* Operation not permitted on from-gz intf */
96 98 } ipadm_status_t;
97 99
98 100 /*
99 101 * option flags taken by the libipadm functions
100 102 *
101 103 * - IPADM_OPT_PERSIST:
102 104 * For all the create/delete/up/down/set/get functions,
103 105 * requests to persist the configuration so that it can be
104 - * re-enabled or reapplied on boot.
106 + * re-enabled or re-applied on boot.
105 107 *
106 108 * - IPADM_OPT_ACTIVE:
107 109 * Requests to apply configuration without persisting it and
108 110 * used by show-* subcommands to retrieve current values.
109 111 *
110 112 * - IPADM_OPT_DEFAULT:
111 113 * retrieves the default value for a given property
112 114 *
113 115 * - IPADM_OPT_PERM
114 116 * retrieves the permission for a given property
115 117 *
116 118 * - IPADM_OPT_POSSIBLE
117 119 * retrieves the range of values for a given property
118 120 *
119 121 * - IPADM_OPT_APPEND
120 122 * for multi-valued properties, appends a new value.
121 123 *
122 124 * - IPADM_OPT_REMOVE
123 125 * for multi-valued properties, removes the specified value
124 126 *
125 127 * - IPADM_OPT_IPMP
126 128 * Used in ipadm_create_if() to plumb ipmp interfaces.
127 129 *
128 130 * - IPADM_OPT_GENPPA
129 131 * Used in ipadm_create_if() to generate a ppa for the given interface.
130 132 *
131 133 * - IPADM_OPT_ZEROADDR
132 134 * return :: or INADDR_ANY
133 135 *
|
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
134 136 * - IPADM_OPT_RELEASE
135 137 * Used to release the lease on a dhcp address object
136 138 *
137 139 * - IPADM_OPT_INFORM
138 140 * Used to perform DHCP_INFORM on a specified static address object
139 141 *
140 142 * - IPADM_OPT_UP
141 143 * Used to bring up a static address on creation
142 144 *
143 145 * - IPADM_OPT_V46
144 - * Used to plumb both IPv4 and IPv6 interfaces by ipadm_create_addr()
146 + * Used to plumb both IPv4 and IPv6 interfaces by ipadm_create_addr()
147 + *
148 + * - IPADM_OPT_SET_PROPS
149 + * Used to indicate the update changes the running configuration of
150 + * "props" data on the object. The props are cached there on the parent,
151 + * but the PROPS_ONLY change does not affect the ACTIVE/PERSIST state of
152 + * the parent.
153 + *
154 + * - IPADM_OPT_PERSIST_PROPS
155 + * Used when IPADM_OPT_SET_PROPS is active to indicate the update changes
156 + * the persistent configuration of the "props" data on the object.
145 157 */
146 158 #define IPADM_OPT_PERSIST 0x00000001
147 159 #define IPADM_OPT_ACTIVE 0x00000002
148 160 #define IPADM_OPT_DEFAULT 0x00000004
149 161 #define IPADM_OPT_PERM 0x00000008
150 162 #define IPADM_OPT_POSSIBLE 0x00000010
151 163 #define IPADM_OPT_APPEND 0x00000020
152 164 #define IPADM_OPT_REMOVE 0x00000040
153 165 #define IPADM_OPT_IPMP 0x00000080
154 166 #define IPADM_OPT_GENPPA 0x00000100
155 167 #define IPADM_OPT_ZEROADDR 0x00000200
156 168 #define IPADM_OPT_RELEASE 0x00000400
157 169 #define IPADM_OPT_INFORM 0x00000800
158 170 #define IPADM_OPT_UP 0x00001000
159 171 #define IPADM_OPT_V46 0x00002000
172 +#define IPADM_OPT_SET_PROPS 0x00004000
173 +#define IPADM_OPT_PERSIST_PROPS 0x00008000
160 174
161 175 /* IPADM property class */
162 176 #define IPADMPROP_CLASS_MODULE 0x00000001 /* on 'protocol' only */
163 177 #define IPADMPROP_CLASS_IF 0x00000002 /* on 'IP interface' only */
164 178 #define IPADMPROP_CLASS_ADDR 0x00000004 /* on 'IP address' only */
165 179 /* protocol property that can be applied on interface too */
166 180 #define IPADMPROP_CLASS_MODIF (IPADMPROP_CLASS_MODULE | IPADMPROP_CLASS_IF)
167 181
168 182 /* opaque ipadm handle to libipadm functions */
169 183 struct ipadm_handle;
170 184 typedef struct ipadm_handle *ipadm_handle_t;
171 185
172 186 /* ipadm_handle flags */
173 187 #define IPH_VRRP 0x00000001 /* Caller is VRRP */
174 188 #define IPH_LEGACY 0x00000002 /* Caller is legacy app */
175 189 #define IPH_IPMGMTD 0x00000004 /* Caller is ipmgmtd itself */
176 190 /*
177 191 * Indicates that the operation being invoked is in 'init' context. This is
178 192 * a library private flag.
179 193 */
180 194 #define IPH_INIT 0x10000000
181 195
182 196 /* opaque address object structure */
183 197 typedef struct ipadm_addrobj_s *ipadm_addrobj_t;
184 198
185 199 /* ipadm_if_info_t states */
186 200 typedef enum {
187 201 IFIS_OK, /* Interface is usable */
188 202 IFIS_DOWN, /* Interface has no UP addresses */
189 203 IFIS_FAILED, /* Interface has failed. */
190 204 IFIS_OFFLINE, /* Interface has been offlined */
191 205 IFIS_DISABLED /* Interface has been disabled. */
192 206 } ipadm_if_state_t;
193 207
194 208 typedef struct ipadm_if_info_s {
195 209 struct ipadm_if_info_s *ifi_next;
196 210 char ifi_name[LIFNAMSIZ]; /* interface name */
197 211 ipadm_if_state_t ifi_state; /* see above */
198 212 uint_t ifi_cflags; /* current flags */
199 213 uint_t ifi_pflags; /* persistent flags */
200 214 } ipadm_if_info_t;
201 215
202 216 /* ipadm_if_info_t flags */
203 217 #define IFIF_BROADCAST 0x00000001
204 218 #define IFIF_MULTICAST 0x00000002
205 219 #define IFIF_POINTOPOINT 0x00000004
206 220 #define IFIF_VIRTUAL 0x00000008
207 221 #define IFIF_IPMP 0x00000010
208 222 #define IFIF_STANDBY 0x00000020
209 223 #define IFIF_INACTIVE 0x00000040
210 224 #define IFIF_VRRP 0x00000080
211 225 #define IFIF_NOACCEPT 0x00000100
212 226 #define IFIF_IPV4 0x00000200
213 227 #define IFIF_IPV6 0x00000400
214 228 #define IFIF_L3PROTECT 0x00000800
215 229
216 230 /* ipadm_addr_info_t state */
217 231 typedef enum {
218 232 IFA_DISABLED, /* Address not in active configuration. */
219 233 IFA_DUPLICATE, /* DAD failed. */
220 234 IFA_DOWN, /* Address is not IFF_UP */
221 235 IFA_TENTATIVE, /* DAD verification initiated */
222 236 IFA_OK, /* Address is usable */
223 237 IFA_INACCESSIBLE /* Interface has failed */
224 238 } ipadm_addr_state_t;
225 239
226 240 /* possible address types */
227 241 typedef enum {
228 242 IPADM_ADDR_NONE,
229 243 IPADM_ADDR_STATIC,
230 244 IPADM_ADDR_IPV6_ADDRCONF,
231 245 IPADM_ADDR_DHCP
232 246 } ipadm_addr_type_t;
233 247
234 248 typedef struct ipadm_addr_info_s {
235 249 struct ifaddrs ia_ifa; /* list of addresses */
236 250 char ia_sname[NI_MAXHOST]; /* local hostname */
237 251 char ia_dname[NI_MAXHOST]; /* remote hostname */
238 252 char ia_aobjname[IPADM_AOBJSIZ];
239 253 uint_t ia_cflags; /* active flags */
240 254 uint_t ia_pflags; /* persistent flags */
241 255 ipadm_addr_type_t ia_atype; /* see above */
242 256 ipadm_addr_state_t ia_state; /* see above */
243 257 } ipadm_addr_info_t;
244 258 #define IA_NEXT(ia) ((ipadm_addr_info_t *)(ia->ia_ifa.ifa_next))
245 259
246 260 /* ipadm_addr_info_t flags */
247 261 #define IA_UP 0x00000001
248 262 #define IA_UNNUMBERED 0x00000002
249 263 #define IA_PRIVATE 0x00000004
|
↓ open down ↓ |
80 lines elided |
↑ open up ↑ |
250 264 #define IA_TEMPORARY 0x00000008
251 265 #define IA_DEPRECATED 0x00000010
252 266
253 267 /* open/close libipadm handle */
254 268 extern ipadm_status_t ipadm_open(ipadm_handle_t *, uint32_t);
255 269 extern void ipadm_close(ipadm_handle_t);
256 270
257 271 /* Check authorization for network configuration */
258 272 extern boolean_t ipadm_check_auth(void);
259 273 /*
260 - * Interface mangement functions
274 + * Interface management functions
261 275 */
262 276 extern ipadm_status_t ipadm_create_if(ipadm_handle_t, char *, sa_family_t,
263 277 uint32_t);
264 278 extern ipadm_status_t ipadm_disable_if(ipadm_handle_t, const char *,
265 279 uint32_t);
266 280 extern ipadm_status_t ipadm_enable_if(ipadm_handle_t, const char *, uint32_t);
267 281 extern ipadm_status_t ipadm_if_info(ipadm_handle_t, const char *,
268 282 ipadm_if_info_t **, uint32_t, int64_t);
269 283 extern void ipadm_free_if_info(ipadm_if_info_t *);
270 284 extern ipadm_status_t ipadm_delete_if(ipadm_handle_t, const char *,
271 285 sa_family_t, uint32_t);
272 286 extern void ipadm_if_move(ipadm_handle_t, const char *);
273 287
274 288 /*
275 289 * Address management functions
276 290 */
277 291 extern ipadm_status_t ipadm_create_addr(ipadm_handle_t, ipadm_addrobj_t,
278 292 uint32_t);
279 293 extern ipadm_status_t ipadm_disable_addr(ipadm_handle_t, const char *,
280 294 uint32_t);
281 295 extern ipadm_status_t ipadm_enable_addr(ipadm_handle_t, const char *,
282 296 uint32_t);
283 297 extern ipadm_status_t ipadm_addr_info(ipadm_handle_t, const char *,
284 298 ipadm_addr_info_t **, uint32_t, int64_t);
285 299 extern void ipadm_free_addr_info(ipadm_addr_info_t *);
286 300 extern ipadm_status_t ipadm_up_addr(ipadm_handle_t, const char *,
287 301 uint32_t);
288 302 extern ipadm_status_t ipadm_down_addr(ipadm_handle_t, const char *,
289 303 uint32_t);
290 304 extern ipadm_status_t ipadm_refresh_addr(ipadm_handle_t, const char *,
291 305 uint32_t);
292 306 extern ipadm_status_t ipadm_delete_addr(ipadm_handle_t, const char *,
293 307 uint32_t);
294 308
295 309 /* Functions related to creating/deleting/modifying opaque address object */
296 310 extern ipadm_status_t ipadm_create_addrobj(ipadm_addr_type_t, const char *,
297 311 ipadm_addrobj_t *);
298 312 extern void ipadm_destroy_addrobj(ipadm_addrobj_t);
299 313 extern ipadm_status_t ipadm_get_aobjname(const ipadm_addrobj_t, char *,
300 314 size_t);
301 315
302 316 /* Functions to set fields in addrobj for static addresses */
303 317 extern ipadm_status_t ipadm_set_addr(ipadm_addrobj_t, const char *,
304 318 sa_family_t);
305 319 extern ipadm_status_t ipadm_set_dst_addr(ipadm_addrobj_t, const char *,
306 320 sa_family_t);
307 321 extern ipadm_status_t ipadm_get_addr(const ipadm_addrobj_t,
|
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
308 322 struct sockaddr_storage *);
309 323
310 324 /* Functions to set fields in addrobj for IPv6 addrconf */
311 325 extern ipadm_status_t ipadm_set_interface_id(ipadm_addrobj_t, const char *);
312 326 extern ipadm_status_t ipadm_set_stateless(ipadm_addrobj_t, boolean_t);
313 327 extern ipadm_status_t ipadm_set_stateful(ipadm_addrobj_t, boolean_t);
314 328
315 329 /* Functions to set fields in addrobj for DHCP */
316 330 extern ipadm_status_t ipadm_set_primary(ipadm_addrobj_t, boolean_t);
317 331 extern ipadm_status_t ipadm_set_wait_time(ipadm_addrobj_t, int32_t);
332 +extern ipadm_status_t ipadm_set_reqhost(ipadm_addrobj_t, const char *);
318 333
319 334 /*
320 335 * Property management functions
321 336 */
322 337 /* call back function for the property walker */
323 338 typedef boolean_t ipadm_prop_wfunc_t(void *, const char *, uint_t);
324 339 extern ipadm_status_t ipadm_walk_proptbl(uint_t, uint_t, ipadm_prop_wfunc_t *,
325 340 void *);
326 341 extern ipadm_status_t ipadm_walk_prop(const char *, uint_t, uint_t,
327 342 ipadm_prop_wfunc_t *, void *);
328 343
329 344 /* Interface property management - set, reset and get */
330 345 extern ipadm_status_t ipadm_set_ifprop(ipadm_handle_t, const char *,
331 346 const char *, const char *, uint_t, uint_t);
332 347 extern ipadm_status_t ipadm_get_ifprop(ipadm_handle_t, const char *,
333 348 const char *, char *, uint_t *, uint_t, uint_t);
334 349
335 350 /* Address property management - set, reset and get */
336 351 extern ipadm_status_t ipadm_set_addrprop(ipadm_handle_t, const char *,
337 352 const char *, const char *, uint_t);
338 353 extern ipadm_status_t ipadm_get_addrprop(ipadm_handle_t, const char *, char *,
339 354 uint_t *, const char *, uint_t);
340 355
341 356 /* Protoocl property management - set, reset and get */
342 357 extern ipadm_status_t ipadm_set_prop(ipadm_handle_t, const char *,
343 358 const char *, uint_t, uint_t);
344 359 extern ipadm_status_t ipadm_get_prop(ipadm_handle_t, const char *, char *,
345 360 uint_t *, uint_t, uint_t);
346 361
347 362 /*
348 363 * miscellaneous helper functions.
349 364 */
|
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
350 365 extern const char *ipadm_status2str(ipadm_status_t);
351 366 extern int ipadm_str2nvlist(const char *, nvlist_t **, uint_t);
352 367 extern size_t ipadm_nvlist2str(nvlist_t *, char *, size_t);
353 368 extern char *ipadm_proto2str(uint_t);
354 369 extern uint_t ipadm_str2proto(const char *);
355 370 extern ipadm_status_t ipadm_open_arp_on_udp(const char *, int *);
356 371 extern int ipadm_legacy2new_propname(const char *, char *,
357 372 uint_t, uint_t *);
358 373 extern int ipadm_new2legacy_propname(const char *, char *,
359 374 uint_t, uint_t);
375 +extern boolean_t ipadm_is_valid_hostname(const char *hostname);
376 +extern boolean_t ipadm_is_nil_hostname(const char *hostname);
360 377
361 378 #ifdef __cplusplus
362 379 }
363 380 #endif
364 381
365 382 #endif /* _LIBIPADM_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX