Print this page
Commit IPMP changes


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 #ifndef _LIBIPADM_H
  25 #define _LIBIPADM_H
  26 
  27 #ifdef  __cplusplus
  28 extern "C" {
  29 #endif
  30 
  31 #include <sys/types.h>
  32 #include <sys/socket.h>
  33 #include <net/if.h>
  34 #include <netdb.h>
  35 #include <ifaddrs.h>
  36 #include <libnvpair.h>
  37 #include <netinet/tcp.h>
  38 #include <sys/stropts.h>


  39 
  40 #define IPADM_AOBJ_USTRSIZ      32
  41 #define IPADM_AOBJSIZ           (LIFNAMSIZ + IPADM_AOBJ_USTRSIZ)
  42 #define MAXPROPVALLEN           512
  43 #define LOOPBACK_IF             "lo0"
  44 
  45 /* special timeout values for dhcp operations */
  46 #define IPADM_DHCP_WAIT_DEFAULT (-1)
  47 #define IPADM_DHCP_WAIT_FOREVER (-2)
  48 
  49 /*
  50  * Specifies that the string passed to ipadm_str2nvlist() is a string of comma
  51  * separated names and that each name does not have values associated with it.
  52  */
  53 #define IPADM_NORVAL            0x00000001
  54 
  55 /* error codes */
  56 typedef enum {
  57         IPADM_SUCCESS,          /* No error occurred */
  58         IPADM_FAILURE,          /* Generic failure */


 174 #define IPH_LEGACY              0x00000002      /* Caller is legacy app */
 175 #define IPH_IPMGMTD             0x00000004      /* Caller is ipmgmtd itself */
 176 /*
 177  * Indicates that the operation being invoked is in 'init' context. This is
 178  * a library private flag.
 179  */
 180 #define IPH_INIT                0x10000000
 181 
 182 /* opaque address object structure */
 183 typedef struct ipadm_addrobj_s  *ipadm_addrobj_t;
 184 
 185 /* ipadm_if_info_t states */
 186 typedef enum {
 187         IFIS_OK,                /* Interface is usable */
 188         IFIS_DOWN,              /* Interface has no UP addresses */
 189         IFIS_FAILED,            /* Interface has failed. */
 190         IFIS_OFFLINE,           /* Interface has been offlined */
 191         IFIS_DISABLED           /* Interface has been disabled. */
 192 } ipadm_if_state_t;
 193 














 194 typedef struct ipadm_if_info_s {
 195         struct ipadm_if_info_s  *ifi_next;
 196         char                    ifi_name[LIFNAMSIZ];    /* interface name */

 197         ipadm_if_state_t        ifi_state;              /* see above */
 198         uint_t                  ifi_cflags;             /* current flags */
 199         uint_t                  ifi_pflags;             /* persistent flags */


 200 } ipadm_if_info_t;
 201 
 202 /* ipadm_if_info_t flags */
 203 #define IFIF_BROADCAST          0x00000001
 204 #define IFIF_MULTICAST          0x00000002
 205 #define IFIF_POINTOPOINT        0x00000004
 206 #define IFIF_VIRTUAL            0x00000008
 207 #define IFIF_IPMP               0x00000010
 208 #define IFIF_STANDBY            0x00000020
 209 #define IFIF_INACTIVE           0x00000040
 210 #define IFIF_VRRP               0x00000080
 211 #define IFIF_NOACCEPT           0x00000100
 212 #define IFIF_IPV4               0x00000200
 213 #define IFIF_IPV6               0x00000400
 214 #define IFIF_L3PROTECT          0x00000800
 215 
 216 /* ipadm_addr_info_t state */
 217 typedef enum {
 218         IFA_DISABLED,           /* Address not in active configuration. */
 219         IFA_DUPLICATE,          /* DAD failed. */


 253 /* open/close libipadm handle */
 254 extern ipadm_status_t   ipadm_open(ipadm_handle_t *, uint32_t);
 255 extern void             ipadm_close(ipadm_handle_t);
 256 
 257 /* Check authorization for network configuration */
 258 extern boolean_t        ipadm_check_auth(void);
 259 /*
 260  * Interface mangement functions
 261  */
 262 extern ipadm_status_t   ipadm_create_if(ipadm_handle_t, char *, sa_family_t,
 263                             uint32_t);
 264 extern ipadm_status_t   ipadm_disable_if(ipadm_handle_t, const char *,
 265                             uint32_t);
 266 extern ipadm_status_t   ipadm_enable_if(ipadm_handle_t, const char *, uint32_t);
 267 extern ipadm_status_t   ipadm_if_info(ipadm_handle_t, const char *,
 268                             ipadm_if_info_t **, uint32_t, int64_t);
 269 extern void             ipadm_free_if_info(ipadm_if_info_t *);
 270 extern ipadm_status_t   ipadm_delete_if(ipadm_handle_t, const char *,
 271                             sa_family_t, uint32_t);
 272 extern void             ipadm_if_move(ipadm_handle_t, const char *);




 273 
 274 /*
 275  * Address management functions
 276  */
 277 extern ipadm_status_t   ipadm_create_addr(ipadm_handle_t, ipadm_addrobj_t,
 278                             uint32_t);
 279 extern ipadm_status_t   ipadm_disable_addr(ipadm_handle_t, const char *,
 280                             uint32_t);
 281 extern ipadm_status_t   ipadm_enable_addr(ipadm_handle_t, const char *,
 282                             uint32_t);
 283 extern ipadm_status_t   ipadm_addr_info(ipadm_handle_t, const char *,
 284                             ipadm_addr_info_t **, uint32_t, int64_t);
 285 extern void             ipadm_free_addr_info(ipadm_addr_info_t *);
 286 extern ipadm_status_t   ipadm_up_addr(ipadm_handle_t, const char *,
 287                             uint32_t);
 288 extern ipadm_status_t   ipadm_down_addr(ipadm_handle_t, const char *,
 289                             uint32_t);
 290 extern ipadm_status_t   ipadm_refresh_addr(ipadm_handle_t, const char *,
 291                             uint32_t);
 292 extern ipadm_status_t   ipadm_delete_addr(ipadm_handle_t, const char *,




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
  24  */
  25 #ifndef _LIBIPADM_H
  26 #define _LIBIPADM_H
  27 
  28 #ifdef  __cplusplus
  29 extern "C" {
  30 #endif
  31 
  32 #include <sys/types.h>
  33 #include <sys/socket.h>
  34 #include <net/if.h>
  35 #include <netdb.h>
  36 #include <ifaddrs.h>
  37 #include <libnvpair.h>
  38 #include <netinet/tcp.h>
  39 #include <sys/stropts.h>
  40 #include <sys/list.h>
  41 #include <stddef.h>
  42 
  43 #define IPADM_AOBJ_USTRSIZ      32
  44 #define IPADM_AOBJSIZ           (LIFNAMSIZ + IPADM_AOBJ_USTRSIZ)
  45 #define MAXPROPVALLEN           512
  46 #define LOOPBACK_IF             "lo0"
  47 
  48 /* special timeout values for dhcp operations */
  49 #define IPADM_DHCP_WAIT_DEFAULT (-1)
  50 #define IPADM_DHCP_WAIT_FOREVER (-2)
  51 
  52 /*
  53  * Specifies that the string passed to ipadm_str2nvlist() is a string of comma
  54  * separated names and that each name does not have values associated with it.
  55  */
  56 #define IPADM_NORVAL            0x00000001
  57 
  58 /* error codes */
  59 typedef enum {
  60         IPADM_SUCCESS,          /* No error occurred */
  61         IPADM_FAILURE,          /* Generic failure */


 177 #define IPH_LEGACY              0x00000002      /* Caller is legacy app */
 178 #define IPH_IPMGMTD             0x00000004      /* Caller is ipmgmtd itself */
 179 /*
 180  * Indicates that the operation being invoked is in 'init' context. This is
 181  * a library private flag.
 182  */
 183 #define IPH_INIT                0x10000000
 184 
 185 /* opaque address object structure */
 186 typedef struct ipadm_addrobj_s  *ipadm_addrobj_t;
 187 
 188 /* ipadm_if_info_t states */
 189 typedef enum {
 190         IFIS_OK,                /* Interface is usable */
 191         IFIS_DOWN,              /* Interface has no UP addresses */
 192         IFIS_FAILED,            /* Interface has failed. */
 193         IFIS_OFFLINE,           /* Interface has been offlined */
 194         IFIS_DISABLED           /* Interface has been disabled. */
 195 } ipadm_if_state_t;
 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 
 211 typedef struct ipadm_if_info_s {
 212         struct ipadm_if_info_s  *ifi_next;
 213         char                    ifi_name[LIFNAMSIZ];    /* interface name */
 214         ipadm_if_class_t ifi_class; /* interface class */
 215         ipadm_if_state_t        ifi_state;              /* see above */
 216         uint_t                  ifi_cflags;             /* current flags */
 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 */
 220 } ipadm_if_info_t;
 221 
 222 /* ipadm_if_info_t flags */
 223 #define IFIF_BROADCAST          0x00000001
 224 #define IFIF_MULTICAST          0x00000002
 225 #define IFIF_POINTOPOINT        0x00000004
 226 #define IFIF_VIRTUAL            0x00000008
 227 #define IFIF_IPMP               0x00000010
 228 #define IFIF_STANDBY            0x00000020
 229 #define IFIF_INACTIVE           0x00000040
 230 #define IFIF_VRRP               0x00000080
 231 #define IFIF_NOACCEPT           0x00000100
 232 #define IFIF_IPV4               0x00000200
 233 #define IFIF_IPV6               0x00000400
 234 #define IFIF_L3PROTECT          0x00000800
 235 
 236 /* ipadm_addr_info_t state */
 237 typedef enum {
 238         IFA_DISABLED,           /* Address not in active configuration. */
 239         IFA_DUPLICATE,          /* DAD failed. */


 273 /* open/close libipadm handle */
 274 extern ipadm_status_t   ipadm_open(ipadm_handle_t *, uint32_t);
 275 extern void             ipadm_close(ipadm_handle_t);
 276 
 277 /* Check authorization for network configuration */
 278 extern boolean_t        ipadm_check_auth(void);
 279 /*
 280  * Interface mangement functions
 281  */
 282 extern ipadm_status_t   ipadm_create_if(ipadm_handle_t, char *, sa_family_t,
 283                             uint32_t);
 284 extern ipadm_status_t   ipadm_disable_if(ipadm_handle_t, const char *,
 285                             uint32_t);
 286 extern ipadm_status_t   ipadm_enable_if(ipadm_handle_t, const char *, uint32_t);
 287 extern ipadm_status_t   ipadm_if_info(ipadm_handle_t, const char *,
 288                             ipadm_if_info_t **, uint32_t, int64_t);
 289 extern void             ipadm_free_if_info(ipadm_if_info_t *);
 290 extern ipadm_status_t   ipadm_delete_if(ipadm_handle_t, const char *,
 291                             sa_family_t, uint32_t);
 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);
 297 
 298 /*
 299  * Address management functions
 300  */
 301 extern ipadm_status_t   ipadm_create_addr(ipadm_handle_t, ipadm_addrobj_t,
 302                             uint32_t);
 303 extern ipadm_status_t   ipadm_disable_addr(ipadm_handle_t, const char *,
 304                             uint32_t);
 305 extern ipadm_status_t   ipadm_enable_addr(ipadm_handle_t, const char *,
 306                             uint32_t);
 307 extern ipadm_status_t   ipadm_addr_info(ipadm_handle_t, const char *,
 308                             ipadm_addr_info_t **, uint32_t, int64_t);
 309 extern void             ipadm_free_addr_info(ipadm_addr_info_t *);
 310 extern ipadm_status_t   ipadm_up_addr(ipadm_handle_t, const char *,
 311                             uint32_t);
 312 extern ipadm_status_t   ipadm_down_addr(ipadm_handle_t, const char *,
 313                             uint32_t);
 314 extern ipadm_status_t   ipadm_refresh_addr(ipadm_handle_t, const char *,
 315                             uint32_t);
 316 extern ipadm_status_t   ipadm_delete_addr(ipadm_handle_t, const char *,