2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _IPADM_IPMGMT_H
2N/A#define _IPADM_IPMGMT_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A#include <sys/types.h>
2N/A#include <sys/stat.h>
2N/A#include <paths.h>
2N/A#include <fcntl.h>
2N/A#include <sys/mman.h>
2N/A#include <door.h>
2N/A#include <libipadm.h>
2N/A#include <libnetcfg.h>
2N/A#include <inet/tunables.h>
2N/A
2N/A/*
2N/A * Function declarations and data structures shared by libipadm.so and
2N/A * the IP management daemon.
2N/A */
2N/A
2N/A/* Authorization required to configure network interfaces */
2N/A#define NETWORK_INTERFACE_CONFIG_AUTH "solaris.network.interface.config"
2N/A
2N/A/*
2N/A * Data store read/write utilities related declarations.
2N/A */
2N/A/*
2N/A * For more information on these definitions please refer to the top of
2N/A * ipadm_persist.c. These are the name of the nvpairs which hold the
2N/A * respective values. All nvpairs private to ipadm have names that begin
2N/A * with "_". Note below that 'prefixlen' is an address property and therefore
2N/A * not a private nvpair name.
2N/A */
2N/A#define IPADM_NVP_PROTONAME "_protocol" /* protocol name */
2N/A#define IPADM_NVP_IFNAME "_ifname" /* interface name */
2N/A#define IPADM_NVP_AOBJNAME "_aobjname" /* addrobj name */
2N/A#define IPADM_NVP_FAMILY "_family" /* address family */
2N/A#define IPADM_NVP_IFCLASS "_class" /* interface class */
2N/A#define IPADM_NVP_UNDERIF "_underif" /* underlying interface */
2N/A#define IPADM_NVP_IPMPIF "_ipmpif" /* IPMP interface name */
2N/A#define IPADM_NVP_IPV4SADDR "_ipv4saddr" /* IPv4 local/src addr */
2N/A#define IPADM_NVP_IPV4DADDR "_ipv4daddr" /* IPv4 remote/dst addr */
2N/A#define IPADM_NVP_IPV6SADDR "_ipv6saddr" /* IPv6 local/src addr */
2N/A#define IPADM_NVP_IPV6DADDR "_ipv6daddr" /* IPv6 remote/dst addr */
2N/A#define IPADM_NVP_IPNUMADDR "_addr" /* local address */
2N/A#define IPADM_NVP_PREFIXLEN "prefixlen" /* prefixlen */
2N/A#define IPADM_NVP_DHCP "_dhcp" /* name of DHCP nvlist */
2N/A#define IPADM_NVP_WAIT "_wait" /* DHCP timeout value */
2N/A#define IPADM_NVP_PRIMARY "_primary" /* DHCP primary interface */
2N/A#define IPADM_NVP_LIFNUM "_lifnum" /* logical interface number */
2N/A#define IPADM_NVP_INTFID "_intfid" /* name of IPv6 intfid nvlist */
2N/A#define IPADM_NVP_STATELESS "_stateless" /* IPv6 autoconf stateless */
2N/A#define IPADM_NVP_STATEFUL "_stateful" /* IPv6 autoconf dhcpv6 */
2N/A#define IPADM_NVP_DINTFID "_dintfid" /* destination intfid */
2N/A#define IPADM_NVP_REQHOST "reqhost" /* ddns requested host */
2N/A
2N/A/*
2N/A * These nvpair names are obsoleted with the transition to version 2, where
2N/A * nvpairs of data type nvlist are flattened out into individual name-value
2N/A * pairs. Their definitions must be retained for the upgrade code.
2N/A */
2N/A#define IPADM_NVP_IPV4ADDR "_ipv4addr" /* name of IPv4 addr nvlist */
2N/A#define IPADM_NVP_IPV6ADDR "_ipv6addr" /* name of IPv6 addr nvlist */
2N/A#define IPADM_NVP_IPADDRHNAME "_aname" /* local hostname */
2N/A#define IPADM_NVP_IPDADDRHNAME "_dname" /* remote hostname */
2N/A
2N/A#define IPADM_PRIV_NVP(s) ((s)[0] == '_' && (s)[1] != '_')
2N/A
2N/A/*
2N/A * All protocol properties that are private to ipadm are stored in the
2N/A * ipadm datastore with "__" as prefix. This is to ensure there
2N/A * is no collision of namespace between ipadm private nvpair names and
2N/A * the private protocol property names.
2N/A */
2N/A#define IPADM_PERSIST_PRIVPROP_PREFIX "__"
2N/A
2N/A/* Loopback address object names */
2N/A#define IPADM_V4_LOOPBACK_AOBJ "lo0/v4"
2N/A#define IPADM_V6_LOOPBACK_AOBJ "lo0/v6"
2N/A
2N/A/* data-store operations */
2N/Atypedef enum {
2N/A IPADM_DB_WRITE = 0, /* Writes to DB */
2N/A IPADM_DB_DELETE, /* Deletes an entry from DB */
2N/A IPADM_DB_WALK /* Walk the DB, calling cb for each entry */
2N/A} ipadm_db_op_t;
2N/A
2N/A/*
2N/A * door related function declarations and data structures.
2N/A */
2N/A
2N/A/* The door file for the ipmgmt (ip-interface management) daemon */
2N/A#define IPMGMT_DOOR _PATH_SYSVOL "/ipadm/ipmgmt_door"
2N/A#define MAXPROTONAMELEN 32
2N/A
2N/A/* door call command type */
2N/Atypedef enum {
2N/A IPMGMT_CMD_SETPROP = 1, /* persist property */
2N/A IPMGMT_CMD_SETIF, /* persist interface */
2N/A IPMGMT_CMD_SETADDR, /* persist address */
2N/A IPMGMT_CMD_GETPROP, /* retrieve persisted property value */
2N/A IPMGMT_CMD_GETIF, /* retrieve persisted interface conf. */
2N/A IPMGMT_CMD_GETADDR, /* retrieve persisted addresses */
2N/A IPMGMT_CMD_RESETIF, /* purge interface configuration */
2N/A IPMGMT_CMD_RESETADDR, /* purge address configuration */
2N/A IPMGMT_CMD_RESETPROP, /* purge property configuration */
2N/A IPMGMT_CMD_INITIF, /* retrieve interfaces to initialize */
2N/A IPMGMT_CMD_UPDATE_IPMP, /* Add or remove underif to ipmpif */
2N/A IPMGMT_CMD_MOVE_ADDROBJ, /* Migrate data address object */
2N/A IPMGMT_CMD_ADDROBJ_LOOKUPADD, /* addr. object lookup & add */
2N/A IPMGMT_CMD_ADDROBJ_SETLIFNUM, /* set lifnum on the addrobj */
2N/A IPMGMT_CMD_ADDROBJ_ADD, /* add addr. object to addrobj map */
2N/A IPMGMT_CMD_LIF2ADDROBJ, /* lifname to addrobj mapping */
2N/A IPMGMT_CMD_AOBJNAME2ADDROBJ, /* aobjname to addrobj mapping */
2N/A IPMGMT_CMD_INIT_PROFILE, /* initialize profile */
2N/A IPMGMT_CMD_FINI_PROFILE /* finish profile */
2N/A} ipmgmt_door_cmd_type_t;
2N/A
2N/A/*
2N/A * Note: We need to keep the size of the structure the same on amd64 and i386
2N/A * for all door_call arguments and door_return structures.
2N/A */
2N/A/* door_call argument */
2N/Atypedef struct ipmgmt_arg {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A} ipmgmt_arg_t;
2N/A
2N/A/* IPMGMT_CMD_{SETPROP|GETPROP|RESETPROP} door_call argument */
2N/Atypedef struct ipmgmt_prop_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A uint32_t ia_flags;
2N/A char ia_ifname[LIFNAMSIZ];
2N/A char ia_aobjname[IPADM_AOBJSIZ];
2N/A char ia_module[MAXPROTONAMELEN];
2N/A char ia_pname[MAXPROPNAMELEN];
2N/A char ia_pval[MAXPROPVALLEN];
2N/A} ipmgmt_prop_arg_t;
2N/A
2N/A/* IPMGMT_CMD_GETIF and IPMGMT_CMD_INITIF door_call argument structure */
2N/Atypedef struct ipmgmt_getif_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A uint32_t ia_flags;
2N/A char ia_ifname[LIFNAMSIZ];
2N/A} ipmgmt_getif_arg_t;
2N/A
2N/A/* IPMGMT_CMD_RESETIF door_call argument structure */
2N/Atypedef struct ipmgmt_resetif_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A uint32_t ia_flags;
2N/A char ia_ifname[LIFNAMSIZ];
2N/A sa_family_t ia_family;
2N/A} ipmgmt_resetif_arg_t;
2N/A
2N/A/* IPMGMT_CMD_SETIF door_call argument structure */
2N/Atypedef struct ipmgmt_setif_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A uint32_t ia_flags;
2N/A char ia_ifname[LIFNAMSIZ];
2N/A sa_family_t ia_family;
2N/A ipadm_if_class_t ia_class;
2N/A} ipmgmt_setif_arg_t;
2N/A
2N/A/* IPMGMT_CMD_UPDATE_IPMP door_call argument structure */
2N/Atypedef struct ipmgmt_ipmp_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A uint32_t ia_flags;
2N/A char ia_ipmpif[LIFNAMSIZ];
2N/A char ia_underif[LIFNAMSIZ];
2N/A} ipmgmt_ipmp_arg_t;
2N/A
2N/A/* IPMGMT_CMD_SETADDR door_call argument */
2N/Atypedef struct ipmgmt_setaddr_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A uint32_t ia_flags;
2N/A size_t ia_nvlsize;
2N/A /* packed nvl follows */
2N/A} ipmgmt_setaddr_arg_t;
2N/A
2N/A/* IPMGMT_CMD_GETADDR door_call argument */
2N/Atypedef struct ipmgmt_getaddr_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A uint32_t ia_flags;
2N/A char ia_ifname[LIFNAMSIZ];
2N/A sa_family_t ia_family;
2N/A char ia_aobjname[IPADM_AOBJSIZ];
2N/A} ipmgmt_getaddr_arg_t;
2N/A
2N/A/* IPMGMT_CMD_RESETADDR door_call argument */
2N/Atypedef struct ipmgmt_addr_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A uint32_t ia_flags;
2N/A char ia_aobjname[IPADM_AOBJSIZ];
2N/A int32_t ia_lnum;
2N/A} ipmgmt_addr_arg_t;
2N/A
2N/A/* IPMGMT_CMD_MOVEADDRS door_call argument */
2N/Atypedef struct ipmgmt_migrateaddr_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_underif[LIFNAMSIZ];
2N/A char ia_ipmpif[LIFNAMSIZ];
2N/A size_t ia_nvlsize;
2N/A /* packed nvl follows */
2N/A} ipmgmt_migrateaddr_arg_t;
2N/A
2N/A/*
2N/A * IPMGMT_CMD_{ADDROBJ_ADD|ADDROBJ_LOOKUPADD|LIFNUM2ADDROBJ|ADDROBJ2LIFNUM}
2N/A * door_call argument.
2N/A */
2N/Atypedef struct ipmgmt_aobjop_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A uint32_t ia_flags;
2N/A char ia_aobjname[IPADM_AOBJSIZ];
2N/A char ia_owner[IPADM_OWNERSIZ];
2N/A char ia_ifname[LIFNAMSIZ];
2N/A int32_t ia_lnum;
2N/A sa_family_t ia_family;
2N/A ipadm_addr_type_t ia_atype;
2N/A} ipmgmt_aobjop_arg_t;
2N/A
2N/A/* IPMGMT_CMD_{INIT|FINI}_PROFILE door_call argument */
2N/Atypedef struct ipmgmt_prof_arg_s {
2N/A ipmgmt_door_cmd_type_t ia_cmd;
2N/A char ia_profile[NETCFG_PROFILE_LEN];
2N/A} ipmgmt_prof_arg_t;
2N/A
2N/A/*
2N/A * ia_flags used inside the arguments for interface/address commands
2N/A * - ACTIVE updates the running configuration
2N/A * - PERSIST updates the permanent data store
2N/A * - MODIFY updates the running configuration even though persistent
2N/A * configuration exists.
2N/A */
2N/A#define IPMGMT_ACTIVE 0x00000001
2N/A#define IPMGMT_PERSIST 0x00000002
2N/A#define IPMGMT_MODIFY 0x00000004
2N/A
2N/A/*
2N/A * ia_flags used in ipmgmt_prop_arg_t and ipmgmt_ipmp_arg_t.
2N/A * - APPEND updates the multi-valued property entry with a new value, or
2N/A * adds an underlying interface to an IPMP interface
2N/A * - REMOVE updates the multi-valued property entry by removing a value, or
2N/A * removes an underlying interface from an IPMP interface
2N/A */
2N/A#define IPMGMT_APPEND 0x00000008
2N/A#define IPMGMT_REMOVE 0x00000010
2N/A
2N/A/* door call return value */
2N/Atypedef struct ipmgmt_retval_s {
2N/A int32_t ir_err;
2N/A} ipmgmt_retval_t;
2N/A
2N/A/* IPMGMT_CMD_GETADDR door_return value */
2N/Atypedef struct ipmgmt_get_rval_s {
2N/A int32_t ir_err;
2N/A size_t ir_nvlsize;
2N/A /* packed nvl follows */
2N/A} ipmgmt_get_rval_t;
2N/A
2N/A/* IPMGMT_CMD_GETPROP door_return value */
2N/Atypedef struct ipmgmt_getprop_rval_s {
2N/A int32_t ir_err;
2N/A char ir_pval[MAXPROPVALLEN];
2N/A} ipmgmt_getprop_rval_t;
2N/A
2N/A/* IPMGMT_CMD_GETIF door_return value */
2N/Atypedef struct ipmgmt_getif_rval_s {
2N/A int32_t ir_err;
2N/A uint32_t ir_ifcnt;
2N/A ipadm_if_info_t ir_ifinfo[1];
2N/A} ipmgmt_getif_rval_t;
2N/A
2N/A/* IPMGMT_CMD_{LOOKUPADD|LIFNUM2ADDROBJ|ADDROBJ2LIFNUM} door_return value */
2N/Atypedef struct ipmgmt_aobjop_rval_s {
2N/A int32_t ir_err;
2N/A char ir_aobjname[IPADM_AOBJSIZ];
2N/A char ir_ifname[LIFNAMSIZ];
2N/A int32_t ir_lnum;
2N/A sa_family_t ir_family;
2N/A uint32_t ir_flags;
2N/A ipadm_addr_type_t ir_atype;
2N/A struct sockaddr_storage ir_ifid;
2N/A uint32_t ir_ifidplen;
2N/A} ipmgmt_aobjop_rval_t;
2N/A
2N/A/* DB walk callback functions */
2N/Atypedef boolean_t db_wfunc_t(void *, nvlist_t *, char *, size_t, int *);
2N/Aextern int ipadm_rw_db(db_wfunc_t *, void *, const char *, mode_t,
2N/A ipadm_db_op_t);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _IPADM_IPMGMT_H */