/* $Id: apcsnmp.h 301 2007-09-20 22:16:34Z fil $ */ /* Copyright 2007 Philip Gwyn. All rights reserved */ /* Based on http://net-snmp.sourceforge.net/wiki/index.php/TUT:Simple_Application Copyright Net-SNMP */ /* This file is maintained by: Philip Gwyn */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #ifndef _APCSNMP_H #define _APCSNMP_H 1 #ifndef DEVICE #define DEVICE "apcsnmp" #endif #define MAX_STRING 512 #define MAX_OUTLETS 32 #define APC_OP_OFF 0 #define APC_OP_ON 1 #define APC_OP_RESET 2 #define APC_OK 0 #define APC_ERROR -1 #define APC_TIMEOUT -2 #define APC_NOT -3 typedef struct req_s { netsnmp_pdu *req; netsnmp_pdu *resp; } req_t; typedef struct MID_s { const char *outletPorts; const char *outletNames; const char *outletState; const char *outletCtl; const char *ctlOn; const char *ctlOff; const char *ctlReset; } MID_t; typedef struct OID_s { char text[MAX_STRING]; oid oid[MAX_OID_LEN]; size_t len; } OID_t; typedef struct PDU_s { const char *name; const char *sysOID; MID_t *OID; int outlets; } PDU_t; typedef struct outlet_s { int n; char name[MAX_STRING]; OID_t outletState; OID_t outletCtl; } outlet_t; typedef struct host_s { char *name; int port; char *sysName; char *community; PDU_t *PDU; unsigned int timeout; int open; netsnmp_session session; netsnmp_session *ss; } host_t; extern PDU_t userPDU; extern int host_init ( host_t *); extern void host_deinit ( host_t *); extern int host_identify ( host_t *); extern int host_power ( host_t *, const char *, int); extern int host_outlets ( host_t *host ); extern int host_outlet_name( host_t *host, int q, char *name ); #ifndef LOG /* Little bits so that we can be compiled outside of PIL */ extern int verbosity_level; #define LOG(lvl, fmt, ...) if(verbosity_level >= (lvl) ) \ printf( fmt "\n", __VA_ARGS__ ) #define PIL_FATAL 1 #define PIL_CRIT 2 #define PIL_WARN 3 #define PIL_INFO 4 #define PIL_DEBUG 5 #endif #endif