xref: /illumos-gate/usr/src/lib/fm/libfmd_snmp/common/sunFM_impl.h (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
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 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SUNFM_IMPL_H
28 #define	_SUNFM_IMPL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <net-snmp/net-snmp-config.h>
35 #include <net-snmp/net-snmp-includes.h>
36 #include <net-snmp/agent/net-snmp-agent-includes.h>
37 #include <libnvpair.h>
38 #include <stdarg.h>
39 
40 #ifdef DEBUG
41 extern void sunFm_panic(const char *format, ...) __NORETURN;
42 extern void sunFm_vpanic(const char *format, va_list ap) __NORETURN;
43 extern int sunFm_assert(const char *, const char *, int);
44 #define	ASSERT(x)	((void)((x) || sunFm_assert(#x, __FILE__, __LINE__)))
45 #else
46 extern void sunFm_panic(const char *format, ...);
47 extern void sunFm_vpanic(const char *format, va_list ap);
48 #define	ASSERT(x)
49 #endif
50 
51 typedef int (*sunFm_table_init_func_t)(void);
52 
53 typedef struct sunFm_table {
54 	const char		*t_name;
55 	sunFm_table_init_func_t	t_init;
56 } sunFm_table_t;
57 
58 #define	TABLE_INIT(__t)	__t##_init
59 #define	TABLE_NAME(__t)	#__t
60 #define	TABLE_REG(__t)	{ TABLE_NAME(__t), TABLE_INIT(__t) }
61 #define	TABLE_NULL	{ NULL, NULL }
62 
63 /*
64  * The definition of netsnmp_table_helper_add_index in <net-snmp/agent/table.h>
65  * is defective; it includes a ; at the end.  We have to use our own.
66  */
67 #ifdef	netsnmp_table_helper_add_index
68 #undef	netsnmp_table_helper_add_index
69 #define	netsnmp_table_helper_add_index(tinfo, type) \
70 	snmp_varlist_add_variable(&tinfo->indexes, NULL, 0, (uchar_t)type, \
71 	NULL, 0)
72 #endif	/* netsnmp_table_helper_add_index */
73 
74 extern char *sunFm_nvl2str(nvlist_t *);
75 
76 #ifdef	__cplusplus
77 }
78 #endif
79 
80 #endif	/* _SUNFM_IMPL_H */
81