Print this page
Commit IPMP changes


   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 (c) 2013 by Delphix. All rights reserved.

  24  */
  25 
  26 #ifndef _LIBIPADM_IMPL_H
  27 #define _LIBIPADM_IMPL_H
  28 
  29 #ifdef  __cplusplus
  30 extern "C" {
  31 #endif
  32 
  33 #include <sys/socket.h>

  34 #include <net/if.h>
  35 #include <libipadm.h>
  36 #include <libdladm.h>
  37 #include <ipadm_ipmgmt.h>
  38 #include <inet/tunables.h>
  39 #include <netinet/in.h>
  40 #include <pthread.h>
  41 #include <libinetutil.h>
  42 #include <libsocket_priv.h>
  43 
  44 #define IPADM_STRSIZE           256
  45 #define IPADM_ONSTR             "on"
  46 #define IPADM_OFFSTR            "off"
  47 #define ARP_MOD_NAME            "arp"
  48 #define IPADM_LOGICAL_SEP       ':'
  49 #define IPV6_MIN_MTU            1280    /* rfc2460 */
  50 
  51 /* mask for flags accepted by libipadm functions */
  52 #define IPADM_COMMON_OPT_MASK   (IPADM_OPT_ACTIVE | IPADM_OPT_PERSIST)
  53 





  54 /* Opaque library handle */
  55 struct ipadm_handle {
  56         int             iph_sock;       /* socket to interface */
  57         int             iph_sock6;      /* socket to interface */
  58         int             iph_door_fd;    /* door descriptor to ipmgmtd */
  59         int             iph_rtsock;     /* routing socket */
  60         dladm_handle_t  iph_dlh;        /* handle to libdladm library */
  61         uint32_t        iph_flags;      /* internal flags */
  62         pthread_mutex_t iph_lock;       /* lock to set door_fd */
  63         zoneid_t        iph_zoneid;     /* zoneid where handle was opened */
  64 };
  65 
  66 struct ipadm_addrobj_s {
  67         char                    ipadm_ifname[LIFNAMSIZ];
  68         int32_t                 ipadm_lifnum;
  69         char                    ipadm_aobjname[IPADM_AOBJSIZ];
  70         ipadm_addr_type_t       ipadm_atype;
  71         uint32_t                ipadm_flags;
  72         sa_family_t             ipadm_af;
  73         union {


 133 
 134 extern ipadm_prop_desc_t        ipadm_addrprop_table[];
 135 extern ipadm_pd_getf_t          i_ipadm_get_onoff;
 136 
 137 /* libipadm.c */
 138 extern ipadm_status_t   i_ipadm_get_flags(ipadm_handle_t, const char *,
 139                             sa_family_t, uint64_t *);
 140 extern ipadm_status_t   i_ipadm_set_flags(ipadm_handle_t, const char *,
 141                             sa_family_t, uint64_t, uint64_t);
 142 extern ipadm_status_t   i_ipadm_init_ifs(ipadm_handle_t, const char *,
 143                             nvlist_t **);
 144 extern ipadm_status_t   i_ipadm_init_ifobj(ipadm_handle_t, const char *,
 145                             nvlist_t *);
 146 extern ipadm_status_t   i_ipadm_init_addrobj(ipadm_handle_t, nvlist_t *);
 147 extern ipadm_status_t   i_ipadm_addr_persist(ipadm_handle_t,
 148                             const ipadm_addrobj_t, boolean_t, uint32_t);
 149 extern ipadm_status_t   i_ipadm_delete_addr(ipadm_handle_t, ipadm_addrobj_t);
 150 extern int              i_ipadm_strioctl(int, int, char *, int);
 151 extern boolean_t        i_ipadm_is_loopback(const char *);
 152 extern boolean_t        i_ipadm_is_vni(const char *);
 153 extern boolean_t        i_ipadm_is_ipmp(ipadm_handle_t, const char *);
 154 extern boolean_t        i_ipadm_is_under_ipmp(ipadm_handle_t, const char *);
 155 extern boolean_t        i_ipadm_is_6to4(ipadm_handle_t, char *);
 156 extern boolean_t        i_ipadm_validate_ifname(ipadm_handle_t, const char *);
 157 extern ipadm_status_t   ipadm_errno2status(int);
 158 extern int              ipadm_door_call(ipadm_handle_t, void *, size_t, void **,
 159                             size_t, boolean_t);
 160 extern boolean_t        ipadm_if_enabled(ipadm_handle_t, const char *,
 161                             sa_family_t);


 162 
 163 /* ipadm_ndpd.c */
 164 extern  ipadm_status_t  i_ipadm_create_ipv6addrs(ipadm_handle_t,
 165                             ipadm_addrobj_t, uint32_t);
 166 extern ipadm_status_t   i_ipadm_delete_ipv6addrs(ipadm_handle_t,
 167                             ipadm_addrobj_t);
 168 extern ipadm_status_t   i_ipadm_disable_autoconf(const char *);
 169 extern ipadm_status_t   i_ipadm_enable_autoconf(const char *);
 170 
 171 /* ipadm_persist.c */
 172 extern ipadm_status_t   i_ipadm_add_ipaddr2nvl(nvlist_t *, ipadm_addrobj_t);
 173 extern ipadm_status_t   i_ipadm_add_ip6addr2nvl(nvlist_t *, ipadm_addrobj_t);
 174 extern ipadm_status_t   i_ipadm_add_intfid2nvl(nvlist_t *, ipadm_addrobj_t);
 175 extern ipadm_status_t   i_ipadm_add_dhcp2nvl(nvlist_t *, boolean_t, int32_t);
 176 
 177 /* ipadm_prop.c */
 178 extern ipadm_status_t   i_ipadm_persist_propval(ipadm_handle_t,
 179                             ipadm_prop_desc_t *, const char *, const void *,
 180                             uint_t);
 181 extern ipadm_status_t   i_ipadm_get_persist_propval(ipadm_handle_t,


 209 extern boolean_t        i_ipadm_name2atype(const char *, sa_family_t *,
 210                             ipadm_addr_type_t *);
 211 extern ipadm_status_t   i_ipadm_resolve_addr(const char *, sa_family_t,
 212                             struct sockaddr_storage *);
 213 
 214 /* ipadm_if.c */
 215 extern ipadm_status_t   i_ipadm_create_if(ipadm_handle_t, char *,  sa_family_t,
 216                             uint32_t);
 217 extern ipadm_status_t   i_ipadm_delete_if(ipadm_handle_t, const char *,
 218                             sa_family_t, uint32_t);
 219 extern ipadm_status_t   i_ipadm_plumb_if(ipadm_handle_t, char *, sa_family_t,
 220                             uint32_t);
 221 extern ipadm_status_t   i_ipadm_unplumb_if(ipadm_handle_t, const char *,
 222                             sa_family_t);
 223 extern ipadm_status_t   i_ipadm_if_pexists(ipadm_handle_t, const char *,
 224                             sa_family_t, boolean_t *);
 225 extern ipadm_status_t   i_ipadm_delete_ifobj(ipadm_handle_t, const char *,
 226                             sa_family_t, boolean_t);
 227 extern int              i_ipadm_get_lnum(const char *);
 228 






 229 #ifdef  __cplusplus
 230 }
 231 #endif
 232 
 233 #endif  /* _LIBIPADM_IMPL_H */


   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 (c) 2013 by Delphix. All rights reserved.
  24  * Copyright (c) 2014 Nexenta Systems, Inc. All rights reserved.
  25  */
  26 
  27 #ifndef _LIBIPADM_IMPL_H
  28 #define _LIBIPADM_IMPL_H
  29 
  30 #ifdef  __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 #include <sys/socket.h>
  35 #include <sys/list.h>
  36 #include <net/if.h>
  37 #include <libipadm.h>
  38 #include <libdladm.h>
  39 #include <ipadm_ipmgmt.h>
  40 #include <inet/tunables.h>
  41 #include <netinet/in.h>
  42 #include <pthread.h>
  43 #include <libinetutil.h>
  44 #include <libsocket_priv.h>
  45 
  46 #define IPADM_STRSIZE           256
  47 #define IPADM_ONSTR             "on"
  48 #define IPADM_OFFSTR            "off"
  49 #define ARP_MOD_NAME            "arp"
  50 #define IPADM_LOGICAL_SEP       ':'
  51 #define IPV6_MIN_MTU            1280    /* rfc2460 */
  52 
  53 /* mask for flags accepted by libipadm functions */
  54 #define IPADM_COMMON_OPT_MASK   (IPADM_OPT_ACTIVE | IPADM_OPT_PERSIST)
  55 
  56 typedef enum {
  57     IPADM_ADD_IPMP_MEMBER,
  58     IPADM_REMOVE_IPMP_MEMBER
  59 } ipadm_ipmp_operation_t;
  60 
  61 /* Opaque library handle */
  62 struct ipadm_handle {
  63         int             iph_sock;       /* socket to interface */
  64         int             iph_sock6;      /* socket to interface */
  65         int             iph_door_fd;    /* door descriptor to ipmgmtd */
  66         int             iph_rtsock;     /* routing socket */
  67         dladm_handle_t  iph_dlh;        /* handle to libdladm library */
  68         uint32_t        iph_flags;      /* internal flags */
  69         pthread_mutex_t iph_lock;       /* lock to set door_fd */
  70         zoneid_t        iph_zoneid;     /* zoneid where handle was opened */
  71 };
  72 
  73 struct ipadm_addrobj_s {
  74         char                    ipadm_ifname[LIFNAMSIZ];
  75         int32_t                 ipadm_lifnum;
  76         char                    ipadm_aobjname[IPADM_AOBJSIZ];
  77         ipadm_addr_type_t       ipadm_atype;
  78         uint32_t                ipadm_flags;
  79         sa_family_t             ipadm_af;
  80         union {


 140 
 141 extern ipadm_prop_desc_t        ipadm_addrprop_table[];
 142 extern ipadm_pd_getf_t          i_ipadm_get_onoff;
 143 
 144 /* libipadm.c */
 145 extern ipadm_status_t   i_ipadm_get_flags(ipadm_handle_t, const char *,
 146                             sa_family_t, uint64_t *);
 147 extern ipadm_status_t   i_ipadm_set_flags(ipadm_handle_t, const char *,
 148                             sa_family_t, uint64_t, uint64_t);
 149 extern ipadm_status_t   i_ipadm_init_ifs(ipadm_handle_t, const char *,
 150                             nvlist_t **);
 151 extern ipadm_status_t   i_ipadm_init_ifobj(ipadm_handle_t, const char *,
 152                             nvlist_t *);
 153 extern ipadm_status_t   i_ipadm_init_addrobj(ipadm_handle_t, nvlist_t *);
 154 extern ipadm_status_t   i_ipadm_addr_persist(ipadm_handle_t,
 155                             const ipadm_addrobj_t, boolean_t, uint32_t);
 156 extern ipadm_status_t   i_ipadm_delete_addr(ipadm_handle_t, ipadm_addrobj_t);
 157 extern int              i_ipadm_strioctl(int, int, char *, int);
 158 extern boolean_t        i_ipadm_is_loopback(const char *);
 159 extern boolean_t        i_ipadm_is_vni(const char *);


 160 extern boolean_t        i_ipadm_is_6to4(ipadm_handle_t, char *);
 161 extern boolean_t        i_ipadm_validate_ifname(ipadm_handle_t, const char *);
 162 extern ipadm_status_t   ipadm_errno2status(int);
 163 extern int              ipadm_door_call(ipadm_handle_t, void *, size_t, void **,
 164                             size_t, boolean_t);
 165 extern boolean_t        ipadm_if_enabled(ipadm_handle_t, const char *,
 166                             sa_family_t);
 167 extern ipadm_status_t i_ipadm_call_ipmgmtd(ipadm_handle_t, void *,
 168             size_t, nvlist_t **);
 169 
 170 /* ipadm_ndpd.c */
 171 extern  ipadm_status_t  i_ipadm_create_ipv6addrs(ipadm_handle_t,
 172                             ipadm_addrobj_t, uint32_t);
 173 extern ipadm_status_t   i_ipadm_delete_ipv6addrs(ipadm_handle_t,
 174                             ipadm_addrobj_t);
 175 extern ipadm_status_t   i_ipadm_disable_autoconf(const char *);
 176 extern ipadm_status_t   i_ipadm_enable_autoconf(const char *);
 177 
 178 /* ipadm_persist.c */
 179 extern ipadm_status_t   i_ipadm_add_ipaddr2nvl(nvlist_t *, ipadm_addrobj_t);
 180 extern ipadm_status_t   i_ipadm_add_ip6addr2nvl(nvlist_t *, ipadm_addrobj_t);
 181 extern ipadm_status_t   i_ipadm_add_intfid2nvl(nvlist_t *, ipadm_addrobj_t);
 182 extern ipadm_status_t   i_ipadm_add_dhcp2nvl(nvlist_t *, boolean_t, int32_t);
 183 
 184 /* ipadm_prop.c */
 185 extern ipadm_status_t   i_ipadm_persist_propval(ipadm_handle_t,
 186                             ipadm_prop_desc_t *, const char *, const void *,
 187                             uint_t);
 188 extern ipadm_status_t   i_ipadm_get_persist_propval(ipadm_handle_t,


 216 extern boolean_t        i_ipadm_name2atype(const char *, sa_family_t *,
 217                             ipadm_addr_type_t *);
 218 extern ipadm_status_t   i_ipadm_resolve_addr(const char *, sa_family_t,
 219                             struct sockaddr_storage *);
 220 
 221 /* ipadm_if.c */
 222 extern ipadm_status_t   i_ipadm_create_if(ipadm_handle_t, char *,  sa_family_t,
 223                             uint32_t);
 224 extern ipadm_status_t   i_ipadm_delete_if(ipadm_handle_t, const char *,
 225                             sa_family_t, uint32_t);
 226 extern ipadm_status_t   i_ipadm_plumb_if(ipadm_handle_t, char *, sa_family_t,
 227                             uint32_t);
 228 extern ipadm_status_t   i_ipadm_unplumb_if(ipadm_handle_t, const char *,
 229                             sa_family_t);
 230 extern ipadm_status_t   i_ipadm_if_pexists(ipadm_handle_t, const char *,
 231                             sa_family_t, boolean_t *);
 232 extern ipadm_status_t   i_ipadm_delete_ifobj(ipadm_handle_t, const char *,
 233                             sa_family_t, boolean_t);
 234 extern int              i_ipadm_get_lnum(const char *);
 235 
 236 extern ipadm_status_t i_ipadm_set_groupname_active(ipadm_handle_t,
 237             const char *, const char *);
 238 extern ipadm_status_t i_ipadm_get_groupname_active(ipadm_handle_t,
 239             const char *, char *, size_t);
 240 extern boolean_t i_ipadm_is_under_ipmp(ipadm_handle_t, const char *);
 241 extern boolean_t i_ipadm_is_ipmp(ipadm_handle_t, const char *);
 242 #ifdef  __cplusplus
 243 }
 244 #endif
 245 
 246 #endif  /* _LIBIPADM_IMPL_H */