annotate usr/src/lib/fm/libfmd_snmp/common/init.c @ 11050:be69f645ce17

6894028 Some fm libraries are not lint clean 6897387 IPMI facility provider methods not registered on some platforms 6893713 Some fm cmds are not lint clean
author Robert Johnston <Robert.Johnston@Sun.COM>
date Wed, 11 Nov 2009 18:52:48 -0800
parents 6e5751a0b831
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1303
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
1 /*
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
2 * CDDL HEADER START
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
3 *
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
5 * Common Development and Distribution License (the "License").
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
6 * You may not use this file except in compliance with the License.
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
7 *
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
10 * See the License for the specific language governing permissions
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
11 * and limitations under the License.
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
12 *
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
18 *
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
19 * CDDL HEADER END
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
20 */
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
21
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
22 /*
11050
be69f645ce17 6894028 Some fm libraries are not lint clean
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 1303
diff changeset
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
1303
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
24 * Use is subject to license terms.
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
25 */
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
26
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
27 #include <fm/fmd_snmp.h>
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
28 #include <net-snmp/net-snmp-config.h>
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
29 #include <net-snmp/net-snmp-includes.h>
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
30 #include <net-snmp/agent/net-snmp-agent-includes.h>
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
31 #include "sunFM_impl.h"
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
32 #include "module.h"
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
33 #include "resource.h"
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
34 #include "problem.h"
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
35
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
36 static const sunFm_table_t sun_fm_tables[] = {
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
37 TABLE_REG(sunFmModuleTable),
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
38 TABLE_REG(sunFmResourceTable),
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
39 TABLE_REG(sunFmProblemTable),
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
40 TABLE_REG(sunFmFaultEventTable),
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
41 TABLE_NULL
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
42 };
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
43
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
44 /*
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
45 * This is our entry point for initialization by the agent, which
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
46 * (for reasons unknown) ignores the return value. The name is fixed
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
47 * by the agent API.
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
48 */
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
49 int
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
50 init_sunFM(void)
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
51 {
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
52 int max_err = MIB_REGISTERED_OK;
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
53 const sunFm_table_t *table;
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
54
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
55 for (table = sun_fm_tables; table->t_name != NULL; table++) {
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
56 int err = table->t_init();
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
57
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
58 switch (err) {
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
59 case MIB_REGISTERED_OK:
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
60 DEBUGMSGTL((MODNAME_STR, "registered table %s\n",
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
61 table->t_name));
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
62 break;
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
63 case MIB_DUPLICATE_REGISTRATION:
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
64 (void) snmp_log(LOG_ERR, MODNAME_STR
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
65 ": table %s initialization failed: duplicate "
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
66 "registration\n", table->t_name);
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
67 break;
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
68 case MIB_REGISTRATION_FAILED:
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
69 (void) snmp_log(LOG_ERR, MODNAME_STR
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
70 ": table %s initialization failed: agent "
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
71 "registration failure\n", table->t_name);
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
72 break;
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
73 default:
11050
be69f645ce17 6894028 Some fm libraries are not lint clean
Robert Johnston <Robert.Johnston@Sun.COM>
parents: 1303
diff changeset
74 (void) snmp_log(LOG_ERR, MODNAME_STR
1303
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
75 ": table %s initialization failed: "
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
76 "unknown reason\n", table->t_name);
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
77 }
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
78
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
79 if (err > max_err)
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
80 max_err = err;
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
81 }
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
82
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
83 return (max_err);
6e5751a0b831 PSARC 2005/754 FMA SNMP Agent
wesolows
parents:
diff changeset
84 }