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 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #ifndef _IPMGMT_IMPL_H
27 #define _IPMGMT_IMPL_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #include <net/if.h>
34 #include <libnvpair.h>
35 #include <libipadm.h>
36 #include <ipadm_ipmgmt.h>
37 #include <syslog.h>
38 #include <pthread.h>
39 #include <libscf.h>
40
41 #define IPMGMT_STRSIZE 256
42 #define IPMGMTD_FMRI "svc:/network/ip-interface-management:default"
43
117 uint32_t am_flags;
118 boolean_t am_linklocal;
119 struct sockaddr_storage am_ifid;
120 } ipmgmt_aobjmap_t;
121
122 /* linked list of `aobjmap' nodes, protected by RW lock */
123 typedef struct ipmgmt_aobjmap_list_s {
124 ipmgmt_aobjmap_t *aobjmap_head;
125 pthread_rwlock_t aobjmap_rwlock;
126 } ipmgmt_aobjmap_list_t;
127
128 /* global `aobjmap' defined in ipmgmt_main.c */
129 extern ipmgmt_aobjmap_list_t aobjmap;
130
131 /* operations on the `aobjmap' linked list */
132 #define ADDROBJ_ADD 0x00000001
133 #define ADDROBJ_DELETE 0x00000002
134 #define ADDROBJ_LOOKUPADD 0x00000004
135 #define ADDROBJ_SETLIFNUM 0x00000008
136
137 /* Permanent data store for ipadm */
138 #define IPADM_DB_FILE "/etc/ipadm/ipadm.conf"
139 #define IPADM_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
140
141 /*
142 * With the initial integration of the daemon (PSARC 2010/080), the version
143 * of the ipadm data-store (/etc/ipadm/ipadm.conf) was 0. A subsequent fix
144 * needed an upgrade to the data-store and we bumped the version to 1.
145 */
146 #define IPADM_DB_VERSION 1
147
148 /*
149 * A temporary file created in SMF volatile filesystem. This file captures the
150 * in-memory copy of list `aobjmap' on disk. This is done to recover from
151 * daemon reboot (using svcadm) or crashes.
152 */
153 #define IPADM_TMPFS_DIR "/etc/svc/volatile/ipadm"
154 #define ADDROBJ_MAPPING_DB_FILE IPADM_TMPFS_DIR"/aobjmap.conf"
155
156 /*
157 * A temporary copy of the ipadm configuration file might need
158 * to be created if write requests are encountered during boottime
159 * and the root filesystem is mounted read-only.
160 */
161 #define IPADM_VOL_DB_FILE IPADM_TMPFS_DIR"/ipadm.conf"
162
163 /* SCF resources required to interact with svc.configd */
164 typedef struct scf_resources {
165 scf_handle_t *sr_handle;
166 scf_instance_t *sr_inst;
167 scf_propertygroup_t *sr_pg;
168 scf_property_t *sr_prop;
169 scf_value_t *sr_val;
170 scf_transaction_t *sr_tx;
171 scf_transaction_entry_t *sr_ent;
172 } scf_resources_t;
173
174 extern int ipmgmt_db_walk(db_wfunc_t *, void *, ipadm_db_op_t);
175 extern int ipmgmt_aobjmap_op(ipmgmt_aobjmap_t *, uint32_t);
176 extern boolean_t ipmgmt_aobjmap_init(void *, nvlist_t *, char *,
177 size_t, int *);
178 extern int ipmgmt_persist_aobjmap(ipmgmt_aobjmap_t *,
179 ipadm_db_op_t);
180 extern boolean_t ipmgmt_ngz_firstboot_postinstall();
181 extern int ipmgmt_persist_if(ipmgmt_if_arg_t *);
182 extern void ipmgmt_init_prop();
183 extern boolean_t ipmgmt_db_upgrade(void *, nvlist_t *, char *,
184 size_t, int *);
185 extern int ipmgmt_create_scf_resources(const char *,
186 scf_resources_t *);
187 extern void ipmgmt_release_scf_resources(scf_resources_t *);
188 extern boolean_t ipmgmt_needs_upgrade(scf_resources_t *);
189 extern void ipmgmt_update_dbver(scf_resources_t *);
190
191 #ifdef __cplusplus
192 }
193 #endif
194
195 #endif /* _IPMGMT_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 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Joyent, Inc.
25 */
26
27 #ifndef _IPMGMT_IMPL_H
28 #define _IPMGMT_IMPL_H
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #include <net/if.h>
35 #include <libnvpair.h>
36 #include <libipadm.h>
37 #include <ipadm_ipmgmt.h>
38 #include <syslog.h>
39 #include <pthread.h>
40 #include <libscf.h>
41
42 #define IPMGMT_STRSIZE 256
43 #define IPMGMTD_FMRI "svc:/network/ip-interface-management:default"
44
118 uint32_t am_flags;
119 boolean_t am_linklocal;
120 struct sockaddr_storage am_ifid;
121 } ipmgmt_aobjmap_t;
122
123 /* linked list of `aobjmap' nodes, protected by RW lock */
124 typedef struct ipmgmt_aobjmap_list_s {
125 ipmgmt_aobjmap_t *aobjmap_head;
126 pthread_rwlock_t aobjmap_rwlock;
127 } ipmgmt_aobjmap_list_t;
128
129 /* global `aobjmap' defined in ipmgmt_main.c */
130 extern ipmgmt_aobjmap_list_t aobjmap;
131
132 /* operations on the `aobjmap' linked list */
133 #define ADDROBJ_ADD 0x00000001
134 #define ADDROBJ_DELETE 0x00000002
135 #define ADDROBJ_LOOKUPADD 0x00000004
136 #define ADDROBJ_SETLIFNUM 0x00000008
137
138 #define IPADM_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
139
140 /*
141 * With the initial integration of the daemon (PSARC 2010/080), the version
142 * of the ipadm data-store (/etc/ipadm/ipadm.conf) was 0. A subsequent fix
143 * needed an upgrade to the data-store and we bumped the version to 1.
144 */
145 #define IPADM_DB_VERSION 1
146
147 typedef enum ipadm_path {
148 IPADM_PATH_TMPFS_DIR = 1,
149 IPADM_PATH_ADDROBJ_MAP_DB,
150 IPADM_PATH_DB,
151 IPADM_PATH_VOL_DB
152 } ipadm_path_t;
153
154 /* SCF resources required to interact with svc.configd */
155 typedef struct scf_resources {
156 scf_handle_t *sr_handle;
157 scf_instance_t *sr_inst;
158 scf_propertygroup_t *sr_pg;
159 scf_property_t *sr_prop;
160 scf_value_t *sr_val;
161 scf_transaction_t *sr_tx;
162 scf_transaction_entry_t *sr_ent;
163 } scf_resources_t;
164
165 extern int ipmgmt_db_walk(db_wfunc_t *, void *, ipadm_db_op_t);
166 extern int ipmgmt_aobjmap_op(ipmgmt_aobjmap_t *, uint32_t);
167 extern boolean_t ipmgmt_aobjmap_init(void *, nvlist_t *, char *,
168 size_t, int *);
169 extern int ipmgmt_persist_aobjmap(ipmgmt_aobjmap_t *,
170 ipadm_db_op_t);
171 extern boolean_t ipmgmt_ngz_firstboot_postinstall();
172 extern int ipmgmt_persist_if(ipmgmt_if_arg_t *);
173 extern void ipmgmt_init_prop();
174 extern boolean_t ipmgmt_db_upgrade(void *, nvlist_t *, char *,
175 size_t, int *);
176 extern int ipmgmt_create_scf_resources(const char *,
177 scf_resources_t *);
178 extern void ipmgmt_release_scf_resources(scf_resources_t *);
179 extern boolean_t ipmgmt_needs_upgrade(scf_resources_t *);
180 extern void ipmgmt_update_dbver(scf_resources_t *);
181
182 extern void ipmgmt_path(ipadm_path_t, char *, size_t);
183
184 #ifdef __cplusplus
185 }
186 #endif
187
188 #endif /* _IPMGMT_IMPL_H */
|