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
86 extern db_wfunc_t ipmgmt_db_resetaddr;
87
88 typedef struct {
89 sa_family_t cb_family;
90 nvlist_t *cb_invl;
91 nvlist_t *cb_onvl;
92 int cb_ocnt;
93 } ipmgmt_initif_cbarg_t;
94 extern db_wfunc_t ipmgmt_db_initif;
95
96 /*
97 * A linked list of address object nodes. Each node in the list tracks
98 * following information for the address object identified by `am_aobjname'.
99 * - interface on which the address is created
100 * - logical interface number on which the address is created
101 * - address family
102 * - `am_nextnum' identifies the next number to use to generate user part
103 * of `aobjname'.
104 * - address type (static, dhcp or addrconf)
105 * - `am_flags' indicates if this addrobj in active and/or persist config
106 * - if `am_atype' is IPADM_ADDR_IPV6_ADDRCONF then `am_ifid' holds the
107 * interface-id used to configure auto-configured addresses
108 */
109 typedef struct ipmgmt_aobjmap_s {
110 struct ipmgmt_aobjmap_s *am_next;
111 char am_aobjname[IPADM_AOBJSIZ];
112 char am_ifname[LIFNAMSIZ];
113 int32_t am_lnum;
114 sa_family_t am_family;
115 ipadm_addr_type_t am_atype;
116 uint32_t am_nextnum;
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 /*
|
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
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
101 * - logical interface number on which the address is created
102 * - address family
103 * - `am_nextnum' identifies the next number to use to generate user part
104 * of `aobjname'.
105 * - address type (static, dhcp or addrconf)
106 * - `am_flags' indicates if this addrobj in active and/or persist config
107 * - other, ipadm_addr_type_t-specific values are cached in
108 * am_addr_cache (see type ipmgmt_addr_cache_u):
109 * - ipv6: ipmgmt_am_linklocal (macro)
110 * - ipv6: ipmgmt_am_ifid (macro)
111 * - dhcp: ipmgmt_am_primary (macro)
112 * - dhcp: ipmgmt_am_reqhost (macro)
113 */
114 typedef struct ipmgmt_aobjmap_s {
115 struct ipmgmt_aobjmap_s *am_next;
116 char am_aobjname[IPADM_AOBJSIZ];
117 char am_ifname[LIFNAMSIZ];
118 int32_t am_lnum;
119 sa_family_t am_family;
120 ipadm_addr_type_t am_atype;
121 uint32_t am_nextnum;
122 uint32_t am_flags;
123 ipmgmt_addr_type_cache_u am_atype_cache;
124 } ipmgmt_aobjmap_t;
125
126 #define ipmgmt_am_linklocal am_atype_cache.ipmgmt_ipv6_cache_s.ipmgmt_linklocal
127 #define ipmgmt_am_ifid am_atype_cache.ipmgmt_ipv6_cache_s.ipmgmt_ifid
128 #define ipmgmt_am_primary am_atype_cache.ipmgmt_dhcp_cache_s.ipmgmt_primary
129 #define ipmgmt_am_reqhost am_atype_cache.ipmgmt_dhcp_cache_s.ipmgmt_reqhost
130
131 /* linked list of `aobjmap' nodes, protected by RW lock */
132 typedef struct ipmgmt_aobjmap_list_s {
133 ipmgmt_aobjmap_t *aobjmap_head;
134 pthread_rwlock_t aobjmap_rwlock;
135 } ipmgmt_aobjmap_list_t;
136
137 /* global `aobjmap' defined in ipmgmt_main.c */
138 extern ipmgmt_aobjmap_list_t aobjmap;
139
140 /* operations on the `aobjmap' linked list */
141 #define ADDROBJ_ADD 0x00000001
142 #define ADDROBJ_DELETE 0x00000002
143 #define ADDROBJ_LOOKUPADD 0x00000004
144 #define ADDROBJ_SETLIFNUM 0x00000008
145
146 /* Permanent data store for ipadm */
147 #define IPADM_DB_FILE "/etc/ipadm/ipadm.conf"
148 #define IPADM_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
149
150 /*
|