xref: /titanic_50/usr/src/cmd/cmd-inet/lib/nwamd/util.h (revision 726fad2a65f16c200a03969c29cb5c86c2d427db)
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 _UTIL_H
28 #define	_UTIL_H
29 
30 #include <dhcpagent_ipc.h>
31 #include <libdlwlan.h>
32 #include <libnwam.h>
33 #include <pthread.h>
34 #include <string.h>
35 #include <sys/note.h>
36 #include <sys/time.h>
37 #include <sys/zone.h>
38 #include <syslog.h>
39 
40 #include "events.h"
41 #include "llp.h"
42 #include "ncu.h"
43 
44 /*
45  * A few functions here from files other than util.c, saves having
46  * .h files for one or two functions.
47  */
48 
49 #define	OUR_FMRI				NWAM_FMRI
50 #define	OUR_PG					NWAM_PG
51 #define	OUR_DEBUG_PROP_NAME			"debug"
52 #define	OUR_AUTOCONF_PROP_NAME			"autoconf"
53 #define	OUR_STRICT_BSSID_PROP_NAME		"strict_bssid"
54 #define	OUR_ACTIVE_NCP_PROP_NAME		NWAM_PROP_ACTIVE_NCP
55 #define	OUR_CONDITION_CHECK_INTERVAL_PROP_NAME	"condition_check_interval"
56 #define	OUR_WIRELESS_SCAN_INTERVAL_PROP_NAME	"scan_interval"
57 #define	OUR_WIRELESS_SCAN_LEVEL_PROP_NAME	"scan_level"
58 #define	OUR_NCU_WAIT_TIME_PROP_NAME		"ncu_wait_time"
59 #define	OUR_VERSION_PROP_NAME			"version"
60 #define	NET_LOC_FMRI				"svc:/network/location:default"
61 #define	NET_LOC_PG				"location"
62 #define	NET_LOC_SELECTED_PROP			"selected"
63 
64 #define	NSEC_TO_SEC(nsec)	(nsec) / (long)NANOSEC
65 #define	NSEC_TO_FRACNSEC(nsec)	(nsec) % (long)NANOSEC
66 #define	SEC_TO_NSEC(sec)	(sec) * (long)NANOSEC
67 
68 extern boolean_t debug;
69 extern boolean_t shutting_down;
70 
71 /* logging.c: log support functions */
72 extern void nlog(int, const char *, ...);
73 extern void pfail(const char *fmt, ...);
74 extern int syslog_stack(uintptr_t addr, int sig, void *arg);
75 
76 /* door_if.c: door interface functions */
77 extern void nwamd_door_init(void);
78 extern void nwamd_door_fini(void);
79 
80 /* util.c: utility & ipc functions */
81 extern int nwamd_start_childv(const char *, const char * const *);
82 extern boolean_t nwamd_link_belongs_to_this_zone(const char *);
83 extern void nwamd_escalate(void);
84 extern void nwamd_deescalate(void);
85 extern void nwamd_drop_unneeded_privs(void);
86 extern void nwamd_escalate_privs(void);
87 
88 /* SCF helper functions */
89 extern int nwamd_lookup_boolean_property(const char *, const char *,
90     const char *, boolean_t *);
91 extern int nwamd_lookup_count_property(const char *, const char *, const char *,
92     uint64_t *);
93 extern int nwamd_lookup_string_property(const char *, const char *,
94     const char *, char *, size_t);
95 
96 extern int nwamd_set_count_property(const char *, const char *, const char *,
97     uint64_t);
98 extern int nwamd_set_string_property(const char *, const char *, const char *,
99     const char *);
100 
101 extern int nwamd_delete_scf_property(const char *, const char *, const char *);
102 
103 #endif /* _UTIL_H */
104