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 (c) 2016, Chris Fraire <cfraire@me.com>.
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
45 /* ipmgmt_door.c */
46 extern void ipmgmt_handler(void *, char *, size_t, door_desc_t *, uint_t);
47
48 /* ipmgmt_util.c */
49 extern void ipmgmt_log(int, const char *, ...);
50 extern int ipmgmt_cpfile(const char *, const char *, boolean_t);
51
52 /* ipmgmt_persist.c */
53
54 /*
55 * following are the list of DB walker callback functions and the callback
56 * arguments for each of the callback functions used by the daemon
57 */
58 /* following functions take 'ipmgmt_prop_arg_t' as the callback argument */
59 extern db_wfunc_t ipmgmt_db_getprop, ipmgmt_db_resetprop;
60
61 /* following functions take ipadm_dbwrite_cbarg_t as callback argument */
62 extern db_wfunc_t ipmgmt_db_add, ipmgmt_db_update;
63
64 typedef struct {
65 char *cb_ifname;
66 ipadm_if_info_t *cb_ifinfo;
67 } ipmgmt_getif_cbarg_t;
68 extern db_wfunc_t ipmgmt_db_getif;
69
70 typedef struct {
71 char *cb_aobjname;
72 char *cb_ifname;
73 nvlist_t *cb_onvl;
74 int cb_ocnt;
75 } ipmgmt_getaddr_cbarg_t;
76 extern db_wfunc_t ipmgmt_db_getaddr;
77
78 typedef struct {
79 sa_family_t cb_family;
80 char *cb_ifname;
81 } ipmgmt_if_cbarg_t;
82 extern db_wfunc_t ipmgmt_db_setif, ipmgmt_db_resetif;
83
84 typedef struct {
85 char *cb_aobjname;
86 } ipmgmt_resetaddr_cbarg_t;
87 extern db_wfunc_t ipmgmt_db_resetaddr;
88
89 typedef struct {
90 sa_family_t cb_family;
91 nvlist_t *cb_invl;
92 nvlist_t *cb_onvl;
93 int cb_ocnt;
94 } ipmgmt_initif_cbarg_t;
95 extern db_wfunc_t ipmgmt_db_initif;
96
97 /*
98 * A linked list of address object nodes. Each node in the list tracks
99 * following information for the address object identified by `am_aobjname'.
100 * - interface on which the address is created
164 #define ADDROBJ_MAPPING_DB_FILE IPADM_TMPFS_DIR"/aobjmap.conf"
165
166 /*
167 * A temporary copy of the ipadm configuration file might need
168 * to be created if write requests are encountered during boottime
169 * and the root filesystem is mounted read-only.
170 */
171 #define IPADM_VOL_DB_FILE IPADM_TMPFS_DIR"/ipadm.conf"
172
173 /* SCF resources required to interact with svc.configd */
174 typedef struct scf_resources {
175 scf_handle_t *sr_handle;
176 scf_instance_t *sr_inst;
177 scf_propertygroup_t *sr_pg;
178 scf_property_t *sr_prop;
179 scf_value_t *sr_val;
180 scf_transaction_t *sr_tx;
181 scf_transaction_entry_t *sr_ent;
182 } scf_resources_t;
183
184 extern int ipmgmt_db_walk(db_wfunc_t *, void *, ipadm_db_op_t);
185 extern int ipmgmt_aobjmap_op(ipmgmt_aobjmap_t *, uint32_t);
186 extern boolean_t ipmgmt_aobjmap_init(void *, nvlist_t *, char *,
187 size_t, int *);
188 extern int ipmgmt_persist_aobjmap(ipmgmt_aobjmap_t *,
189 ipadm_db_op_t);
190 extern boolean_t ipmgmt_ngz_firstboot_postinstall();
191 extern int ipmgmt_persist_if(ipmgmt_if_arg_t *);
192 extern void ipmgmt_init_prop();
193 extern boolean_t ipmgmt_db_upgrade(void *, nvlist_t *, char *,
194 size_t, int *);
195 extern int ipmgmt_create_scf_resources(const char *,
196 scf_resources_t *);
197 extern void ipmgmt_release_scf_resources(scf_resources_t *);
198 extern boolean_t ipmgmt_needs_upgrade(scf_resources_t *);
199 extern void ipmgmt_update_dbver(scf_resources_t *);
200
201 #ifdef __cplusplus
202 }
203 #endif
|
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 2014 Nexenta Systems, Inc. All rights reserved.
25 * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
26 */
27
28 #ifndef _IPMGMT_IMPL_H
29 #define _IPMGMT_IMPL_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include <net/if.h>
36 #include <libnvpair.h>
37 #include <libipadm.h>
38 #include <ipadm_ipmgmt.h>
39 #include <syslog.h>
40 #include <pthread.h>
41 #include <libscf.h>
42
43 #define IPMGMT_STRSIZE 256
44 #define IPMGMTD_FMRI "svc:/network/ip-interface-management:default"
45
46 /* ipmgmt_door.c */
47 extern void ipmgmt_handler(void *, char *, size_t, door_desc_t *, uint_t);
48
49 /* ipmgmt_util.c */
50 extern void ipmgmt_log(int, const char *, ...);
51 extern int ipmgmt_cpfile(const char *, const char *, boolean_t);
52
53 /* ipmgmt_persist.c */
54 extern boolean_t ipmgmt_persist_if_exists(const char *, sa_family_t);
55 extern void ipmgmt_get_group_interface(const char *, char *, size_t);
56
57 /*
58 * following are the list of DB walker callback functions and the callback
59 * arguments for each of the callback functions used by the daemon
60 */
61 /* following functions take 'ipmgmt_prop_arg_t' as the callback argument */
62 extern db_wfunc_t ipmgmt_db_getprop, ipmgmt_db_resetprop;
63
64 /* following functions take ipadm_dbwrite_cbarg_t as callback argument */
65 extern db_wfunc_t ipmgmt_db_add, ipmgmt_db_update, ipmgmt_db_update_if;
66
67 typedef struct {
68 char *cb_ifname;
69 char *cb_aobjname;
70 nvlist_t *cb_onvl;
71 int cb_ocnt;
72 } ipmgmt_get_cbarg_t;
73 extern db_wfunc_t ipmgmt_db_getif;
74 extern db_wfunc_t ipmgmt_db_getaddr;
75
76 typedef struct {
77 sa_family_t cb_family;
78 char *cb_ifname;
79 boolean_t cb_ipv4exists;
80 boolean_t cb_ipv6exists;
81 } ipmgmt_if_cbarg_t;
82 extern db_wfunc_t ipmgmt_db_setif, ipmgmt_db_resetif;
83
84 typedef struct {
85 char *cb_aobjname;
86 } ipmgmt_resetaddr_cbarg_t;
87 extern db_wfunc_t ipmgmt_db_resetaddr;
88
89 typedef struct {
90 sa_family_t cb_family;
91 nvlist_t *cb_invl;
92 nvlist_t *cb_onvl;
93 int cb_ocnt;
94 } ipmgmt_initif_cbarg_t;
95 extern db_wfunc_t ipmgmt_db_initif;
96
97 /*
98 * A linked list of address object nodes. Each node in the list tracks
99 * following information for the address object identified by `am_aobjname'.
100 * - interface on which the address is created
164 #define ADDROBJ_MAPPING_DB_FILE IPADM_TMPFS_DIR"/aobjmap.conf"
165
166 /*
167 * A temporary copy of the ipadm configuration file might need
168 * to be created if write requests are encountered during boottime
169 * and the root filesystem is mounted read-only.
170 */
171 #define IPADM_VOL_DB_FILE IPADM_TMPFS_DIR"/ipadm.conf"
172
173 /* SCF resources required to interact with svc.configd */
174 typedef struct scf_resources {
175 scf_handle_t *sr_handle;
176 scf_instance_t *sr_inst;
177 scf_propertygroup_t *sr_pg;
178 scf_property_t *sr_prop;
179 scf_value_t *sr_val;
180 scf_transaction_t *sr_tx;
181 scf_transaction_entry_t *sr_ent;
182 } scf_resources_t;
183
184 extern int ipmgmt_update_family_nvp(nvlist_t *,
185 sa_family_t, uint_t);
186 extern int ipmgmt_db_walk(db_wfunc_t *, void *, ipadm_db_op_t);
187 extern int ipmgmt_aobjmap_op(ipmgmt_aobjmap_t *, uint32_t);
188 extern boolean_t ipmgmt_aobjmap_init(void *, nvlist_t *, char *,
189 size_t, int *);
190 extern int ipmgmt_persist_aobjmap(ipmgmt_aobjmap_t *,
191 ipadm_db_op_t);
192 extern boolean_t ipmgmt_ngz_firstboot_postinstall();
193 extern int ipmgmt_persist_if(ipmgmt_if_arg_t *);
194 extern void ipmgmt_init_prop();
195 extern boolean_t ipmgmt_db_upgrade(void *, nvlist_t *, char *,
196 size_t, int *);
197 extern int ipmgmt_create_scf_resources(const char *,
198 scf_resources_t *);
199 extern void ipmgmt_release_scf_resources(scf_resources_t *);
200 extern boolean_t ipmgmt_needs_upgrade(scf_resources_t *);
201 extern void ipmgmt_update_dbver(scf_resources_t *);
202
203 #ifdef __cplusplus
204 }
205 #endif
|