xref: /titanic_51/usr/src/cmd/cmd-inet/lib/ipmgmtd/ipmgmt_impl.h (revision f045d8d6fec1759551cc2bce1d26628931f14fce)
1 /*
2  * CDDL HEADER START
3  *
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 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
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 
41 #define	IPMGMT_STRSIZE		256
42 
43 /* ipmgmt_door.c */
44 extern void	ipmgmt_handler(void *, char *, size_t, door_desc_t *, uint_t);
45 
46 /* ipmgmt_util.c */
47 extern void	ipmgmt_log(int, const char *, ...);
48 
49 /* ipmgmt_persist.c */
50 
51 /*
52  * following are the list of DB walker callback functions and the callback
53  * arguments for each of the callback functions used by the daemon
54  */
55 /* following functions take 'ipmgmt_prop_arg_t' as the callback argument */
56 extern db_wfunc_t	ipmgmt_db_getprop, ipmgmt_db_resetprop;
57 
58 /* following functions take ipadm_dbwrite_cbarg_t as callback argument */
59 extern db_wfunc_t	ipmgmt_db_add, ipmgmt_db_update;
60 
61 typedef struct {
62 	char		*cb_ifname;
63 	ipadm_if_info_t	*cb_ifinfo;
64 } ipmgmt_getif_cbarg_t;
65 extern db_wfunc_t	ipmgmt_db_getif;
66 
67 typedef struct {
68 	char		*cb_aobjname;
69 	char		*cb_ifname;
70 	nvlist_t	*cb_onvl;
71 	int		cb_ocnt;
72 } ipmgmt_getaddr_cbarg_t;
73 extern db_wfunc_t	ipmgmt_db_getaddr;
74 
75 typedef struct {
76 	sa_family_t	cb_family;
77 	char		*cb_ifname;
78 } ipmgmt_if_cbarg_t;
79 extern db_wfunc_t	ipmgmt_db_setif, ipmgmt_db_resetif;
80 
81 typedef struct {
82 	char		*cb_aobjname;
83 } ipmgmt_resetaddr_cbarg_t;
84 extern db_wfunc_t	ipmgmt_db_resetaddr;
85 
86 typedef struct {
87 	sa_family_t	cb_family;
88 	nvlist_t	*cb_invl;
89 	nvlist_t	*cb_onvl;
90 	int		cb_ocnt;
91 } ipmgmt_initif_cbarg_t;
92 extern db_wfunc_t	ipmgmt_db_initif;
93 
94 /*
95  * A linked list of address object nodes. Each node in the list tracks
96  * following information for the address object identified by `am_aobjname'.
97  *	- interface on which the address is created
98  * 	- logical interface number on which the address is created
99  *	- address family
100  *	- `am_nextnum' identifies the next number to use to generate user part
101  *	  of `aobjname'.
102  *	- address type (static, dhcp or addrconf)
103  *	- `am_flags' indicates if this addrobj in active and/or persist config
104  *	- if `am_atype' is IPADM_ADDR_IPV6_ADDRCONF then `am_ifid' holds the
105  *	  interface-id used to configure auto-configured addresses
106  */
107 typedef struct ipmgmt_aobjmap_s {
108 	struct ipmgmt_aobjmap_s	*am_next;
109 	char			am_aobjname[IPADM_AOBJSIZ];
110 	char			am_ifname[LIFNAMSIZ];
111 	int32_t			am_lnum;
112 	sa_family_t		am_family;
113 	ipadm_addr_type_t	am_atype;
114 	uint32_t		am_nextnum;
115 	uint32_t		am_flags;
116 	boolean_t		am_linklocal;
117 	struct sockaddr_storage	am_ifid;
118 } ipmgmt_aobjmap_t;
119 
120 /* linked list of `aobjmap' nodes, protected by RW lock */
121 typedef struct ipmgmt_aobjmap_list_s {
122 	ipmgmt_aobjmap_t	*aobjmap_head;
123 	pthread_rwlock_t	aobjmap_rwlock;
124 } ipmgmt_aobjmap_list_t;
125 
126 /* global `aobjmap' defined in ipmgmt_main.c */
127 extern ipmgmt_aobjmap_list_t aobjmap;
128 
129 /* operations on the `aobjmap' linked list */
130 #define	ADDROBJ_ADD		0x00000001
131 #define	ADDROBJ_DELETE		0x00000002
132 #define	ADDROBJ_LOOKUPADD	0x00000004
133 
134 /*
135  * A temporary file created in SMF volatile filesystem. This file captures the
136  * in-memory copy of list `aobjmap' on disk. This is done to recover from
137  * daemon reboot (using svcadm) or crashes.
138  */
139 #define	ADDROBJ_MAPPING_DB_FILE	IPADM_TMPFS_DIR"/aobjmap.conf"
140 
141 extern int		ipmgmt_db_walk(db_wfunc_t *, void *, ipadm_db_op_t);
142 extern int		ipmgmt_aobjmap_op(ipmgmt_aobjmap_t *, uint32_t);
143 extern boolean_t	ipmgmt_aobjmap_init(void *, nvlist_t *, char *,
144 			    size_t, int *);
145 extern int 		ipmgmt_persist_aobjmap(ipmgmt_aobjmap_t *,
146 			    ipadm_db_op_t);
147 
148 #ifdef  __cplusplus
149 }
150 #endif
151 
152 #endif	/* _IPMGMT_IMPL_H */
153