20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include <fm/fmd_snmp.h>
  28 #include <net-snmp/net-snmp-config.h>
  29 #include <net-snmp/net-snmp-includes.h>
  30 #include <net-snmp/agent/net-snmp-agent-includes.h>
  31 #include "sunFM_impl.h"
  32 #include "module.h"
  33 #include "resource.h"
  34 #include "problem.h"
  35 
  36 static const sunFm_table_t sun_fm_tables[] = {
  37         TABLE_REG(sunFmModuleTable),
  38         TABLE_REG(sunFmResourceTable),
  39         TABLE_REG(sunFmProblemTable),
  40         TABLE_REG(sunFmFaultEventTable),
  41         TABLE_NULL
  42 };
  43 
  44 /*
  45  * This is our entry point for initialization by the agent, which
  46  * (for reasons unknown) ignores the return value.  The name is fixed
  47  * by the agent API.
  48  */
  49 int
  50 init_sunFM(void)
  51 {
  52         int                     max_err = MIB_REGISTERED_OK;
  53         const sunFm_table_t     *table;
  54 
  55         for (table = sun_fm_tables; table->t_name != NULL; table++) {
  56                 int err = table->t_init();
  57 
  58                 switch (err) {
  59                 case MIB_REGISTERED_OK:
  60                         DEBUGMSGTL((MODNAME_STR, "registered table %s\n",
  61                             table->t_name));
  62                         break;
  63                 case MIB_DUPLICATE_REGISTRATION:
  64                         (void) snmp_log(LOG_ERR, MODNAME_STR
  65                             ": table %s initialization failed: duplicate "
  66                             "registration\n", table->t_name);
  67                         break;
  68                 case MIB_REGISTRATION_FAILED:
  69                         (void) snmp_log(LOG_ERR, MODNAME_STR
  70                             ": table %s initialization failed: agent "
  71                             "registration failure\n", table->t_name);
  72                         break;
  73                 default:
  74                         (void) snmp_log(LOG_ERR, MODNAME_STR
  75                             ": table %s initialization failed: "
  76                             "unknown reason\n", table->t_name);
  77                 }
  78 
  79                 if (err > max_err)
  80                         max_err = err;
  81         }
  82 
  83         return (max_err);
  84 }
 | 
 
 
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include <fm/fmd_snmp.h>
  28 #include <net-snmp/net-snmp-config.h>
  29 #include <net-snmp/net-snmp-includes.h>
  30 #include <net-snmp/agent/net-snmp-agent-includes.h>
  31 #include "sunFM_impl.h"
  32 #include "module.h"
  33 #include "resource.h"
  34 #include "problem.h"
  35 
  36 static const sunFm_table_t sun_fm_tables[] = {
  37         TABLE_REG(sunFmModuleTable),
  38         TABLE_REG(sunFmResourceTable),
  39         TABLE_REG(sunFmProblemTable),
  40         TABLE_NULL
  41 };
  42 
  43 /*
  44  * This is our entry point for initialization by the agent, which
  45  * (for reasons unknown) ignores the return value.  The name is fixed
  46  * by the agent API.
  47  */
  48 int
  49 init_sunFM(void)
  50 {
  51         static int              once = 0;
  52         int                     max_err = MIB_REGISTERED_OK;
  53         const sunFm_table_t     *table;
  54 
  55         if (once != 0)
  56                 return (MIB_DUPLICATE_REGISTRATION);
  57 
  58         for (table = sun_fm_tables; table->t_name != NULL; table++) {
  59                 int err = table->t_init();
  60 
  61                 switch (err) {
  62                 case MIB_REGISTERED_OK:
  63                         DEBUGMSGTL((MODNAME_STR, "registered table %s\n",
  64                             table->t_name));
  65                         break;
  66                 case MIB_DUPLICATE_REGISTRATION:
  67                         (void) snmp_log(LOG_ERR, MODNAME_STR
  68                             ": table %s initialization failed: duplicate "
  69                             "registration\n", table->t_name);
  70                         break;
  71                 case MIB_REGISTRATION_FAILED:
  72                         (void) snmp_log(LOG_ERR, MODNAME_STR
  73                             ": table %s initialization failed: agent "
  74                             "registration failure\n", table->t_name);
  75                         break;
  76                 default:
  77                         (void) snmp_log(LOG_ERR, MODNAME_STR
  78                             ": table %s initialization failed: "
  79                             "unknown reason\n", table->t_name);
  80                 }
  81 
  82                 if (err > max_err)
  83                         max_err = err;
  84         }
  85 
  86         once = 1;
  87         return (max_err);
  88 }
 |