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.
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.
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]
22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
25 #ifndef _IPADM_IPMGMT_H
26 #define _IPADM_IPMGMT_H
31 #include <sys/types.h>
37 #include <inet/tunables.h>
40 * Function declarations and data structures shared by libipadm.so and
41 * the IP management daemon.
44 /* Authorization required to configure network interfaces */
45 #define NETWORK_INTERFACE_CONFIG_AUTH "solaris.network.interface.config"
48 * Data store read/write utilities related declarations.
51 * For more information on these definitions please refer to the top of
52 * ipadm_persist.c. These are the name of the nvpairs which hold the
53 * respective values. All nvpairs private to ipadm have names that begin
54 * with "_". Note below that 'prefixlen' is an address property and therefore
55 * not a private nvpair name.
57 #define IPADM_NVP_PROTONAME "_protocol" /* protocol name */
58 #define IPADM_NVP_IFNAME "_ifname" /* interface name */
59 #define IPADM_NVP_AOBJNAME "_aobjname" /* addrobj name */
60 #define IPADM_NVP_FAMILY "_family" /* address family */
61 #define IPADM_NVP_IPV4ADDR "_ipv4addr" /* name of IPv4 addr nvlist */
62 #define IPADM_NVP_IPNUMADDR "_addr" /* local address */
63 #define IPADM_NVP_IPADDRHNAME "_aname" /* local hostname */
64 #define IPADM_NVP_IPDADDRHNAME "_dname" /* remote hostname */
65 #define IPADM_NVP_PREFIXLEN "prefixlen" /* prefixlen */
66 #define IPADM_NVP_IPV6ADDR "_ipv6addr" /* name of IPv6 addr nvlist */
67 #define IPADM_NVP_DHCP "_dhcp" /* name of DHCP nvlist */
68 #define IPADM_NVP_WAIT "_wait" /* DHCP timeout value */
69 #define IPADM_NVP_PRIMARY "_primary" /* DHCP primary interface */
70 #define IPADM_NVP_LIFNUM "_lifnum" /* logical interface number */
71 #define IPADM_NVP_INTFID "_intfid" /* name of IPv6 intfid nvlist */
72 #define IPADM_NVP_STATELESS "_stateless" /* IPv6 autoconf stateless */
73 #define IPADM_NVP_STATEFUL "_stateful" /* IPv6 autoconf dhcpv6 */
75 #define IPADM_PRIV_NVP(s) ((s)[0] == '_' && (s)[1] != '_')
78 * All protocol properties that are private to ipadm are stored in the
79 * ipadm datastore with "__" as prefix. This is to ensure there
80 * is no collision of namespace between ipadm private nvpair names and
81 * the private protocol property names.
83 #define IPADM_PERSIST_PRIVPROP_PREFIX "__"
85 /* data-store operations */
87 IPADM_DB_WRITE
= 0, /* Writes to DB */
88 IPADM_DB_DELETE
, /* Deletes an entry from DB */
89 IPADM_DB_READ
/* Read from DB */
93 * callback arg used by db_wfunc_t that writes to DB. The contents to be
94 * written to DB are captured in `dbw_nvl'.
96 typedef struct ipadm_dbwrite_cbarg_s
{
99 } ipadm_dbwrite_cbarg_t
;
102 * door related function declarations and data structures.
105 /* The door file for the ipmgmt (ip-interface management) daemon */
106 #define IPMGMT_DOOR "/etc/svc/volatile/ipadm/ipmgmt_door"
107 #define MAXPROTONAMELEN 32
109 /* door call command type */
111 IPMGMT_CMD_SETPROP
= 1, /* persist property */
112 IPMGMT_CMD_SETIF
, /* persist interface */
113 IPMGMT_CMD_SETADDR
, /* persist address */
114 IPMGMT_CMD_GETPROP
, /* retrieve persisted property value */
115 IPMGMT_CMD_GETIF
, /* retrieve persisted interface conf. */
116 IPMGMT_CMD_GETADDR
, /* retrieve persisted addresses */
117 IPMGMT_CMD_RESETIF
, /* purge interface configuration */
118 IPMGMT_CMD_RESETADDR
, /* purge address configuration */
119 IPMGMT_CMD_RESETPROP
, /* purge property configuration */
120 IPMGMT_CMD_INITIF
, /* retrieve interfaces to initialize */
121 IPMGMT_CMD_ADDROBJ_LOOKUPADD
, /* addr. object lookup & add */
122 IPMGMT_CMD_ADDROBJ_SETLIFNUM
, /* set lifnum on the addrobj */
123 IPMGMT_CMD_ADDROBJ_ADD
, /* add addr. object to addrobj map */
124 IPMGMT_CMD_LIF2ADDROBJ
, /* lifname to addrobj mapping */
125 IPMGMT_CMD_AOBJNAME2ADDROBJ
/* aobjname to addrobj mapping */
126 } ipmgmt_door_cmd_type_t
;
129 * Note: We need to keep the size of the structure the same on amd64 and i386
130 * for all door_call arguments and door_return structures.
132 /* door_call argument */
133 typedef struct ipmgmt_arg
{
134 ipmgmt_door_cmd_type_t ia_cmd
;
137 /* IPMGMT_CMD_{SETPROP|GETPROP|RESETPROP} door_call argument */
138 typedef struct ipmgmt_prop_arg_s
{
139 ipmgmt_door_cmd_type_t ia_cmd
;
141 char ia_ifname
[LIFNAMSIZ
];
142 char ia_aobjname
[IPADM_AOBJSIZ
];
143 char ia_module
[MAXPROTONAMELEN
];
144 char ia_pname
[MAXPROPNAMELEN
];
145 char ia_pval
[MAXPROPVALLEN
];
148 * ia_flags used in ipmgmt_prop_arg_t.
149 * - APPEND updates the multi-valued property entry with a new value
150 * - REDUCE updates the multi-valued property entry by removing a value
152 #define IPMGMT_APPEND 0x00000001
153 #define IPMGMT_REMOVE 0x00000002
155 /* IPMGMT_CMD_GETIF door_call argument structure */
156 typedef struct ipmgmt_getif_arg_s
{
157 ipmgmt_door_cmd_type_t ia_cmd
;
159 char ia_ifname
[LIFNAMSIZ
];
160 } ipmgmt_getif_arg_t
;
162 /* IPMGMT_CMD_RESETIF, IPMGMT_CMD_SETIF door_call argument structure */
163 typedef struct ipmgmt_if_arg_s
{
164 ipmgmt_door_cmd_type_t ia_cmd
;
166 char ia_ifname
[LIFNAMSIZ
];
167 sa_family_t ia_family
;
170 /* IPMGMT_CMD_INITIF door_call argument structure */
171 typedef struct ipmgmt_initif_arg_s
{
172 ipmgmt_door_cmd_type_t ia_cmd
;
174 sa_family_t ia_family
;
176 /* packed nvl follows */
177 } ipmgmt_initif_arg_t
;
179 /* IPMGMT_CMD_SETADDR door_call argument */
180 typedef struct ipmgmt_setaddr_arg_s
{
181 ipmgmt_door_cmd_type_t ia_cmd
;
184 /* packed nvl follows */
185 } ipmgmt_setaddr_arg_t
;
187 /* IPMGMT_CMD_GETADDR door_call argument */
188 typedef struct ipmgmt_getaddr_arg_s
{
189 ipmgmt_door_cmd_type_t ia_cmd
;
191 char ia_ifname
[LIFNAMSIZ
];
192 sa_family_t ia_family
;
193 char ia_aobjname
[IPADM_AOBJSIZ
];
194 } ipmgmt_getaddr_arg_t
;
196 /* IPMGMT_CMD_RESETADDR door_call argument */
197 typedef struct ipmgmt_addr_arg_s
{
198 ipmgmt_door_cmd_type_t ia_cmd
;
200 char ia_aobjname
[IPADM_AOBJSIZ
];
205 * IPMGMT_CMD_{ADDROBJ_ADD|ADDROBJ_LOOKUPADD|LIFNUM2ADDROBJ|
206 * ADDROBJ2LIFNUM} door_call argument.
208 typedef struct ipmgmt_aobjop_arg_s
{
209 ipmgmt_door_cmd_type_t ia_cmd
;
211 char ia_aobjname
[IPADM_AOBJSIZ
];
212 char ia_ifname
[LIFNAMSIZ
];
214 sa_family_t ia_family
;
215 ipadm_addr_type_t ia_atype
;
216 } ipmgmt_aobjop_arg_t
;
219 * ia_flags used inside the arguments for interface/address commands
220 * - ACTIVE updates the running configuration
221 * - PERSIST updates the permanent data store
222 * - INIT indicates that operation being performed is under init
225 #define IPMGMT_ACTIVE 0x00000001
226 #define IPMGMT_PERSIST 0x00000002
227 #define IPMGMT_INIT 0x00000004
229 /* door call return value */
230 typedef struct ipmgmt_retval_s
{
234 /* IPMGMT_CMD_GETADDR door_return value */
235 typedef struct ipmgmt_get_rval_s
{
238 /* packed nvl follows */
241 /* IPMGMT_CMD_GETPROP door_return value */
242 typedef struct ipmgmt_getprop_rval_s
{
244 char ir_pval
[MAXPROPVALLEN
];
245 } ipmgmt_getprop_rval_t
;
247 /* IPMGMT_CMD_GETIF door_return value */
248 typedef struct ipmgmt_getif_rval_s
{
251 ipadm_if_info_t ir_ifinfo
[1];
252 } ipmgmt_getif_rval_t
;
254 /* IPMGMT_CMD_{LOOKUPADD|LIFNUM2ADDROBJ|ADDROBJ2LIFNUM} door_return value */
255 typedef struct ipmgmt_aobjop_rval_s
{
257 char ir_aobjname
[IPADM_AOBJSIZ
];
258 char ir_ifname
[LIFNAMSIZ
];
260 sa_family_t ir_family
;
262 ipadm_addr_type_t ir_atype
;
263 struct sockaddr_storage ir_ifid
;
264 } ipmgmt_aobjop_rval_t
;
266 /* DB walk callback functions */
267 typedef boolean_t
db_wfunc_t(void *, nvlist_t
*, char *, size_t, int *);
268 extern int ipadm_rw_db(db_wfunc_t
*, void *, const char *, mode_t
,
271 /* zone related functions */
273 * callback function to persist an interface in ipmgmtd data store
275 typedef void (*persist_cb_t
)(char *, boolean_t
, boolean_t
);
277 * ipmgmtd/libipadm network initialization interface.
279 extern ipadm_status_t
ipadm_init_net_from_gz(ipadm_handle_t
, char *,
286 #endif /* _IPADM_IPMGMT_H */