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