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