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