749f21d359d8fbd020c974a1a5227316221bfc9cwesolows/*
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * CDDL HEADER START
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * The contents of this file are subject to the terms of the
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Common Development and Distribution License (the "License").
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * You may not use this file except in compliance with the License.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * or http://www.opensolaris.org/os/licensing.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * See the License for the specific language governing permissions
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * and limitations under the License.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * When distributing Covered Code, include this CDDL HEADER in each
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * If applicable, add the following below this CDDL HEADER, with the
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * fields enclosed by brackets "[]" replaced with your own identifying
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * information: Portions Copyright [yyyy] [name of copyright owner]
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows *
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * CDDL HEADER END
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows */
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows/*
888e055994b8b0dc77b98c53dd97026237caec5dRobert Johnston * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * Use is subject to license terms.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows */
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows#include <fm/fmd_snmp.h>
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows#include <net-snmp/net-snmp-config.h>
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows#include <net-snmp/net-snmp-includes.h>
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows#include <net-snmp/agent/net-snmp-agent-includes.h>
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows#include "sunFM_impl.h"
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows#include "module.h"
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows#include "resource.h"
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows#include "problem.h"
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolowsstatic const sunFm_table_t sun_fm_tables[] = {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows TABLE_REG(sunFmModuleTable),
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows TABLE_REG(sunFmResourceTable),
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows TABLE_REG(sunFmProblemTable),
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows TABLE_REG(sunFmFaultEventTable),
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows TABLE_NULL
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows};
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows/*
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * This is our entry point for initialization by the agent, which
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * (for reasons unknown) ignores the return value. The name is fixed
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows * by the agent API.
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows */
749f21d359d8fbd020c974a1a5227316221bfc9cwesolowsint
749f21d359d8fbd020c974a1a5227316221bfc9cwesolowsinit_sunFM(void)
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows{
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows int max_err = MIB_REGISTERED_OK;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows const sunFm_table_t *table;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows for (table = sun_fm_tables; table->t_name != NULL; table++) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows int err = table->t_init();
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows switch (err) {
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows case MIB_REGISTERED_OK:
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows DEBUGMSGTL((MODNAME_STR, "registered table %s\n",
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows table->t_name));
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows break;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows case MIB_DUPLICATE_REGISTRATION:
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows (void) snmp_log(LOG_ERR, MODNAME_STR
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows ": table %s initialization failed: duplicate "
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows "registration\n", table->t_name);
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows break;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows case MIB_REGISTRATION_FAILED:
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows (void) snmp_log(LOG_ERR, MODNAME_STR
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows ": table %s initialization failed: agent "
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows "registration failure\n", table->t_name);
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows break;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows default:
888e055994b8b0dc77b98c53dd97026237caec5dRobert Johnston (void) snmp_log(LOG_ERR, MODNAME_STR
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows ": table %s initialization failed: "
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows "unknown reason\n", table->t_name);
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows }
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows if (err > max_err)
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows max_err = err;
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows }
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows return (max_err);
749f21d359d8fbd020c974a1a5227316221bfc9cwesolows}