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