xref: /titanic_50/usr/src/lib/fm/libfmd_snmp/common/init.c (revision 888e055994b8b0dc77b98c53dd97026237caec5d)
1749f21d3Swesolows /*
2749f21d3Swesolows  * CDDL HEADER START
3749f21d3Swesolows  *
4749f21d3Swesolows  * The contents of this file are subject to the terms of the
5749f21d3Swesolows  * Common Development and Distribution License (the "License").
6749f21d3Swesolows  * You may not use this file except in compliance with the License.
7749f21d3Swesolows  *
8749f21d3Swesolows  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9749f21d3Swesolows  * or http://www.opensolaris.org/os/licensing.
10749f21d3Swesolows  * See the License for the specific language governing permissions
11749f21d3Swesolows  * and limitations under the License.
12749f21d3Swesolows  *
13749f21d3Swesolows  * When distributing Covered Code, include this CDDL HEADER in each
14749f21d3Swesolows  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15749f21d3Swesolows  * If applicable, add the following below this CDDL HEADER, with the
16749f21d3Swesolows  * fields enclosed by brackets "[]" replaced with your own identifying
17749f21d3Swesolows  * information: Portions Copyright [yyyy] [name of copyright owner]
18749f21d3Swesolows  *
19749f21d3Swesolows  * CDDL HEADER END
20749f21d3Swesolows  */
21749f21d3Swesolows 
22749f21d3Swesolows /*
23*888e0559SRobert Johnston  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24749f21d3Swesolows  * Use is subject to license terms.
25749f21d3Swesolows  */
26749f21d3Swesolows 
27749f21d3Swesolows #include <fm/fmd_snmp.h>
28749f21d3Swesolows #include <net-snmp/net-snmp-config.h>
29749f21d3Swesolows #include <net-snmp/net-snmp-includes.h>
30749f21d3Swesolows #include <net-snmp/agent/net-snmp-agent-includes.h>
31749f21d3Swesolows #include "sunFM_impl.h"
32749f21d3Swesolows #include "module.h"
33749f21d3Swesolows #include "resource.h"
34749f21d3Swesolows #include "problem.h"
35749f21d3Swesolows 
36749f21d3Swesolows static const sunFm_table_t sun_fm_tables[] = {
37749f21d3Swesolows 	TABLE_REG(sunFmModuleTable),
38749f21d3Swesolows 	TABLE_REG(sunFmResourceTable),
39749f21d3Swesolows 	TABLE_REG(sunFmProblemTable),
40749f21d3Swesolows 	TABLE_REG(sunFmFaultEventTable),
41749f21d3Swesolows 	TABLE_NULL
42749f21d3Swesolows };
43749f21d3Swesolows 
44749f21d3Swesolows /*
45749f21d3Swesolows  * This is our entry point for initialization by the agent, which
46749f21d3Swesolows  * (for reasons unknown) ignores the return value.  The name is fixed
47749f21d3Swesolows  * by the agent API.
48749f21d3Swesolows  */
49749f21d3Swesolows int
init_sunFM(void)50749f21d3Swesolows init_sunFM(void)
51749f21d3Swesolows {
52749f21d3Swesolows 	int			max_err = MIB_REGISTERED_OK;
53749f21d3Swesolows 	const sunFm_table_t	*table;
54749f21d3Swesolows 
55749f21d3Swesolows 	for (table = sun_fm_tables; table->t_name != NULL; table++) {
56749f21d3Swesolows 		int err = table->t_init();
57749f21d3Swesolows 
58749f21d3Swesolows 		switch (err) {
59749f21d3Swesolows 		case MIB_REGISTERED_OK:
60749f21d3Swesolows 			DEBUGMSGTL((MODNAME_STR, "registered table %s\n",
61749f21d3Swesolows 			    table->t_name));
62749f21d3Swesolows 			break;
63749f21d3Swesolows 		case MIB_DUPLICATE_REGISTRATION:
64749f21d3Swesolows 			(void) snmp_log(LOG_ERR, MODNAME_STR
65749f21d3Swesolows 			    ": table %s initialization failed: duplicate "
66749f21d3Swesolows 			    "registration\n", table->t_name);
67749f21d3Swesolows 			break;
68749f21d3Swesolows 		case MIB_REGISTRATION_FAILED:
69749f21d3Swesolows 			(void) snmp_log(LOG_ERR, MODNAME_STR
70749f21d3Swesolows 			    ": table %s initialization failed: agent "
71749f21d3Swesolows 			    "registration failure\n", table->t_name);
72749f21d3Swesolows 			break;
73749f21d3Swesolows 		default:
74*888e0559SRobert Johnston 			(void) snmp_log(LOG_ERR, MODNAME_STR
75749f21d3Swesolows 			    ": table %s initialization failed: "
76749f21d3Swesolows 			    "unknown reason\n", table->t_name);
77749f21d3Swesolows 		}
78749f21d3Swesolows 
79749f21d3Swesolows 		if (err > max_err)
80749f21d3Swesolows 			max_err = err;
81749f21d3Swesolows 	}
82749f21d3Swesolows 
83749f21d3Swesolows 	return (max_err);
84749f21d3Swesolows }
85