10d63ce2bSvenki /* 20d63ce2bSvenki * CDDL HEADER START 30d63ce2bSvenki * 40d63ce2bSvenki * The contents of this file are subject to the terms of the 50d63ce2bSvenki * Common Development and Distribution License (the "License"). 60d63ce2bSvenki * You may not use this file except in compliance with the License. 70d63ce2bSvenki * 80d63ce2bSvenki * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90d63ce2bSvenki * or http://www.opensolaris.org/os/licensing. 100d63ce2bSvenki * See the License for the specific language governing permissions 110d63ce2bSvenki * and limitations under the License. 120d63ce2bSvenki * 130d63ce2bSvenki * When distributing Covered Code, include this CDDL HEADER in each 140d63ce2bSvenki * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150d63ce2bSvenki * If applicable, add the following below this CDDL HEADER, with the 160d63ce2bSvenki * fields enclosed by brackets "[]" replaced with your own identifying 170d63ce2bSvenki * information: Portions Copyright [yyyy] [name of copyright owner] 180d63ce2bSvenki * 190d63ce2bSvenki * CDDL HEADER END 200d63ce2bSvenki */ 210d63ce2bSvenki 220d63ce2bSvenki /* 23*34f1a571SMichael Bergknoff * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 240d63ce2bSvenki * Use is subject to license terms. 250d63ce2bSvenki */ 260d63ce2bSvenki 270d63ce2bSvenki #ifndef _SNMPPLUGIN_H 280d63ce2bSvenki #define _SNMPPLUGIN_H 290d63ce2bSvenki 300d63ce2bSvenki #ifdef __cplusplus 310d63ce2bSvenki extern "C" { 320d63ce2bSvenki #endif 330d63ce2bSvenki 340d63ce2bSvenki /* 350d63ce2bSvenki * The /physical-platform node 360d63ce2bSvenki */ 370d63ce2bSvenki #define PICL_NODE_PHYSPLAT "physical-platform" 380d63ce2bSvenki 390d63ce2bSvenki /* 400d63ce2bSvenki * List of volatile property OIDs to lookup and update when needed 410d63ce2bSvenki */ 420d63ce2bSvenki typedef struct { 430d63ce2bSvenki picl_prophdl_t prop; 440d63ce2bSvenki char *oidstr; 450d63ce2bSvenki int row; 460d63ce2bSvenki int proptype; 470d63ce2bSvenki } vol_prophdl_t; 480d63ce2bSvenki 490d63ce2bSvenki /* 500d63ce2bSvenki * Types of volatile properties (proptype values) 510d63ce2bSvenki */ 520d63ce2bSvenki #define VPT_PLATOPSTATE 1 530d63ce2bSvenki #define VPT_NUMSENSOR 2 540d63ce2bSvenki #define VPT_BINSENSOR 3 550d63ce2bSvenki #define VPT_ALARMSTATE 4 560d63ce2bSvenki #define VPT_BATTERYSTATUS 5 570d63ce2bSvenki 580d63ce2bSvenki /* 590d63ce2bSvenki * Storage related and miscellaneous definitions 600d63ce2bSvenki */ 610d63ce2bSvenki #define N_ELEMS_IN_VOLPROP_BLOCK 512 620d63ce2bSvenki #define N_ELEMS_IN_NODE_BLOCK 256 630d63ce2bSvenki #define NODE_BLOCK_SHIFT 8 640d63ce2bSvenki #define DEFAULT_SLOT_TYPE "slot" 650d63ce2bSvenki 660d63ce2bSvenki /* 670d63ce2bSvenki * Local macros and property ids 680d63ce2bSvenki */ 690d63ce2bSvenki #define ADD_NODE(cl) \ 700d63ce2bSvenki { \ 710d63ce2bSvenki if (ptree_create_and_add_node(parenth, node_name, cl, \ 720d63ce2bSvenki &nodeh) != PICL_SUCCESS) { \ 730d63ce2bSvenki log_msg(LOG_ERR, SNMPP_ADD_NODE_FAIL, node_name, cl); \ 740d63ce2bSvenki return (NULL); \ 750d63ce2bSvenki } \ 760d63ce2bSvenki } 770d63ce2bSvenki 780d63ce2bSvenki #define CHECK_LINKRESET(errp, retval) \ 790d63ce2bSvenki if ((errp) && (*errp == ECANCELED)) { \ 800d63ce2bSvenki return (retval); \ 810d63ce2bSvenki } 820d63ce2bSvenki 830d63ce2bSvenki #define CHECK_LINKRESET_VOID(errp) \ 840d63ce2bSvenki if ((errp) && (*errp == ECANCELED)) { \ 850d63ce2bSvenki return; \ 860d63ce2bSvenki } 870d63ce2bSvenki 880d63ce2bSvenki #define min(x, y) ((x) < (y) ? (x) : (y)) 890d63ce2bSvenki 900d63ce2bSvenki typedef enum { 910d63ce2bSvenki PP_SERIAL_NUM = 1, 920d63ce2bSvenki PP_SLOT_TYPE, 930d63ce2bSvenki PP_STATE, 940d63ce2bSvenki PP_OPSTATUS, 950d63ce2bSvenki PP_BATT_STATUS, 960d63ce2bSvenki PP_TEMPERATURE, 970d63ce2bSvenki PP_VOLTAGE, 980d63ce2bSvenki PP_CURRENT, 990d63ce2bSvenki PP_SPEED, 1000d63ce2bSvenki PP_SENSOR_VALUE, 1010d63ce2bSvenki PP_BASE_UNITS, 1020d63ce2bSvenki PP_EXPONENT, 1030d63ce2bSvenki PP_RATE_UNITS, 1040d63ce2bSvenki PP_CONDITION, 1050d63ce2bSvenki PP_EXPECTED, 1060d63ce2bSvenki PP_REPLACEABLE, 1070d63ce2bSvenki PP_HOTSWAPPABLE, 1080d63ce2bSvenki PP_IS_FRU, 1090d63ce2bSvenki PP_HW_REVISION, 1100d63ce2bSvenki PP_FW_REVISION, 1110d63ce2bSvenki PP_MFG_NAME, 1120d63ce2bSvenki PP_MODEL_NAME, 1130d63ce2bSvenki PP_DESCRIPTION, 1149d0d62adSJason Beloro PP_LABEL 1150d63ce2bSvenki } sp_propid_t; 1160d63ce2bSvenki 1170d63ce2bSvenki /* 1180d63ce2bSvenki * Plugin global routines 1190d63ce2bSvenki */ 1200d63ce2bSvenki void snmpplugin_init(void); 1210d63ce2bSvenki void snmpplugin_fini(void); 1220d63ce2bSvenki 1230d63ce2bSvenki /* 1240d63ce2bSvenki * Plugin messages 1250d63ce2bSvenki */ 1260d63ce2bSvenki #define SNMPP_NO_ROOT \ 1270d63ce2bSvenki gettext("PICL snmpplugin: cannot get picl tree root (ret=%d)\n") 1280d63ce2bSvenki 1290d63ce2bSvenki #define SNMPP_CANT_INIT \ 1300d63ce2bSvenki gettext("PICL snmpplugin: cannot initialize snmp service\n") 1310d63ce2bSvenki 1320d63ce2bSvenki #define SNMPP_CANT_CREATE_PHYSPLAT \ 1330d63ce2bSvenki gettext("PICL snmpplugin: cannot create physical-platform root (ret=%d)\n") 1340d63ce2bSvenki 1350d63ce2bSvenki #define SNMPP_CANT_CREATE_TREE_BUILDER \ 1360d63ce2bSvenki gettext("PICL snmpplugin: cannot create thr to handle hotplugs (ret=%d)\n") 1370d63ce2bSvenki 1380d63ce2bSvenki #define SNMPP_NO_ENTPHYSNAME \ 1390d63ce2bSvenki gettext("PICL snmpplugin: cannot get entPhysicalName (row=%d)\n") 1400d63ce2bSvenki 1410d63ce2bSvenki #define SNMPP_ADD_NODE_FAIL \ 1420d63ce2bSvenki gettext("PICL snmpplugin: couldn't add node %s (class=%d)\n") 1430d63ce2bSvenki 1440d63ce2bSvenki #define SNMPP_UNSUPP_SENSOR_CLASS \ 1450d63ce2bSvenki gettext("PICL snmpplugin: sunPlatSensorClass %d unsupported (row=%d)\n") 1460d63ce2bSvenki 1470d63ce2bSvenki #define SNMPP_UNKNOWN_ENTPHYSCLASS \ 1480d63ce2bSvenki gettext("PICL snmpplugin: entPhysicalClass %d unknown (row=%d)\n") 1490d63ce2bSvenki 1500d63ce2bSvenki #define SNMPP_NO_MEM \ 1510d63ce2bSvenki gettext("PICL snmpplugin: failed to allocate %d bytes\n") 1520d63ce2bSvenki 1530d63ce2bSvenki #define SNMPP_CANT_FIND_VOLPROP \ 1540d63ce2bSvenki gettext("PICL snmpplugin: cannot find volatile property (proph=%lx)\n") 1550d63ce2bSvenki 1560d63ce2bSvenki #define SNMPP_INV_PLAT_EQUIP_OPSTATE \ 1570d63ce2bSvenki gettext("PICL snmpplugin: invalid sunPlatEquipmentOpState %d (row=%d)\n") 1580d63ce2bSvenki 1590d63ce2bSvenki #define SNMPP_INV_PLAT_BINSNSR_CURRENT \ 1600d63ce2bSvenki gettext("PICL snmpplugin: invalid sunPlatBinarySensorCurrent %d (row=%d)\n") 1610d63ce2bSvenki 1620d63ce2bSvenki #define SNMPP_NO_SLOT_TYPE \ 1630d63ce2bSvenki gettext("PICL snmpplugin: no acceptable slot types (row=%d)\n") 1640d63ce2bSvenki 1650d63ce2bSvenki #define SNMPP_CANT_INIT_PROPINFO \ 1660d63ce2bSvenki gettext("PICL snmpplugin: cannot init picl propinfo (err=%d)\n") 1670d63ce2bSvenki 1680d63ce2bSvenki #define SNMPP_CANT_ADD_PROP \ 1690d63ce2bSvenki gettext("PICL snmpplugin: cannot add property, err=%d (node=%lx)\n") 1700d63ce2bSvenki 1710d63ce2bSvenki #define SNMPP_CANT_INIT_STR_PROPINFO \ 1720d63ce2bSvenki gettext("PICL snmpplugin: cannot init picl str propinfo (err=%d)\n") 1730d63ce2bSvenki 1740d63ce2bSvenki #define SNMPP_CANT_ADD_STR_PROP \ 1750d63ce2bSvenki gettext("PICL snmpplugin: cannot add string property (err=%d, node=%lx)\n") 1760d63ce2bSvenki 1770d63ce2bSvenki #define SNMPP_CANT_INIT_VOID_PROPINFO \ 1780d63ce2bSvenki gettext("PICL snmpplugin: cannot init picl void propinfo (err=%d)\n") 1790d63ce2bSvenki 1800d63ce2bSvenki #define SNMPP_CANT_ADD_VOID_PROP \ 1810d63ce2bSvenki gettext("PICL snmpplugin: cannot add void property (err=%d, node=%lx)\n") 1820d63ce2bSvenki 1830d63ce2bSvenki #define SNMPP_CANT_INIT_INT_PROPINFO \ 1840d63ce2bSvenki gettext("PICL snmpplugin: cannot init picl int propinfo (err=%d)\n") 1850d63ce2bSvenki 1860d63ce2bSvenki #define SNMPP_CANT_ADD_INT_PROP \ 1870d63ce2bSvenki gettext("PICL snmpplugin: cannot add int property (err=%d, node=%lx)\n") 1880d63ce2bSvenki 1890d63ce2bSvenki #define SNMPP_CANT_FETCH_OBJECT_VAL \ 1901c60fca8Sfw157321 gettext("PICL snmpplugin: cannot fetch object value " \ 1911c60fca8Sfw157321 "(err=%d, OID=<%s>, row=%d)\n") 1920d63ce2bSvenki 1930d63ce2bSvenki #define SNMPP_LINK_RESET \ 1940d63ce2bSvenki gettext("PICL snmpplugin: snmp ds reset happened, rebuilding tree\n") 1950d63ce2bSvenki 196*34f1a571SMichael Bergknoff #define SIGACT_FAILED \ 197*34f1a571SMichael Bergknoff gettext("PICL snmpplugin: Failed to install signal handler for %s: %s\n") 198*34f1a571SMichael Bergknoff 1990d63ce2bSvenki #ifdef SNMPPLUGIN_DEBUG 2000d63ce2bSvenki #define SNMPPLUGIN_DBLOCK_SZ 4096 2010d63ce2bSvenki #define SNMPPLUGIN_DMAX_LINE 80 2020d63ce2bSvenki #define LOGINIT() snmpplugin_log_init() 2030d63ce2bSvenki #define LOGPRINTF(s) snmpplugin_log(s) 2040d63ce2bSvenki #define LOGPRINTF1(s, a1) snmpplugin_log(s, a1) 2050d63ce2bSvenki #define LOGPRINTF2(s, a1, a2) snmpplugin_log(s, a1, a2) 2060d63ce2bSvenki #else 2070d63ce2bSvenki #define LOGINIT() 2080d63ce2bSvenki #define LOGPRINTF(s) 2090d63ce2bSvenki #define LOGPRINTF1(s, a1) 2100d63ce2bSvenki #define LOGPRINTF2(s, a1, a2) 2110d63ce2bSvenki #endif 2120d63ce2bSvenki 2130d63ce2bSvenki #ifdef __cplusplus 2140d63ce2bSvenki } 2150d63ce2bSvenki #endif 2160d63ce2bSvenki 2170d63ce2bSvenki #endif /* _SNMPPLUGIN_H */ 218