From: <av...@us...> - 2010-07-20 09:40:38
|
Revision: 7129 http://openhpi.svn.sourceforge.net/openhpi/?rev=7129&view=rev Author: avpak Date: 2010-07-20 09:40:32 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Fix for #3031579 Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/include/oHpi.h Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-07-19 13:18:59 UTC (rev 7128) +++ openhpi/trunk/baselib/oh_client.cpp 2010-07-20 09:40:32 UTC (rev 7129) @@ -5799,7 +5799,7 @@ /* oHpiVersionGet */ /*----------------------------------------------------------------------------*/ -SaHpiUint64T oHpiVersionGet(void) +SaHpiUint64T SAHPI_API oHpiVersionGet(void) { SaHpiUint64T v = 0; @@ -5812,8 +5812,8 @@ /* oHpiHandlerCreate */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiHandlerCreate(GHashTable *config, - oHpiHandlerIdT *id) +SaErrorT SAHPI_API oHpiHandlerCreate(GHashTable *config, + oHpiHandlerIdT *id) { SaErrorT err = SA_OK; void *request; @@ -5860,7 +5860,7 @@ /* oHpiHandlerDestroy */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiHandlerDestroy(oHpiHandlerIdT id) +SaErrorT SAHPI_API oHpiHandlerDestroy(oHpiHandlerIdT id) { void *request; char reply[dMaxMessageLength]; @@ -5896,7 +5896,7 @@ /* oHpiHandlerInfo */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiHandlerInfo(oHpiHandlerIdT id, oHpiHandlerInfoT *info) +SaErrorT SAHPI_API oHpiHandlerInfo(oHpiHandlerIdT id, oHpiHandlerInfoT *info) { void *request; char reply[dMaxMessageLength]; @@ -5932,7 +5932,7 @@ /* oHpiHandlerGetNext */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiHandlerGetNext(oHpiHandlerIdT id, oHpiHandlerIdT *next_id) +SaErrorT SAHPI_API oHpiHandlerGetNext(oHpiHandlerIdT id, oHpiHandlerIdT *next_id) { void *request; char reply[dMaxMessageLength]; @@ -5966,9 +5966,9 @@ /*----------------------------------------------------------------------------*/ /* oHpiHandlerFind */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiHandlerFind(SaHpiSessionIdT sid, - SaHpiResourceIdT rid, - oHpiHandlerIdT *id) +SaErrorT SAHPI_API oHpiHandlerFind(SaHpiSessionIdT sid, + SaHpiResourceIdT rid, + oHpiHandlerIdT *id) { void *request; char reply[dMaxMessageLength]; @@ -6011,7 +6011,7 @@ /*----------------------------------------------------------------------------*/ /* oHpiHandlerRetry */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiHandlerRetry(oHpiHandlerIdT id) +SaErrorT SAHPI_API oHpiHandlerRetry(oHpiHandlerIdT id) { void *request; char reply[dMaxMessageLength]; @@ -6055,7 +6055,7 @@ /* oHpiGlobalParamGet */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiGlobalParamGet(oHpiGlobalParamT *param) +SaErrorT SAHPI_API oHpiGlobalParamGet(oHpiGlobalParamT *param) { void *request; char reply[dMaxMessageLength]; @@ -6091,7 +6091,7 @@ /* oHpiGlobalParamSet */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiGlobalParamSet(oHpiGlobalParamT *param) +SaErrorT SAHPI_API oHpiGlobalParamSet(oHpiGlobalParamT *param) { void *request; char reply[dMaxMessageLength]; @@ -6126,10 +6126,10 @@ /*----------------------------------------------------------------------------*/ /* oHpiInjectEvent */ /*----------------------------------------------------------------------------*/ -SaErrorT oHpiInjectEvent(oHpiHandlerIdT id, - SaHpiEventT *event, - SaHpiRptEntryT *rpte, - SaHpiRdrT *rdr) +SaErrorT SAHPI_API oHpiInjectEvent(oHpiHandlerIdT id, + SaHpiEventT *event, + SaHpiRptEntryT *rpte, + SaHpiRdrT *rdr) { void *request; char reply[dMaxMessageLength]; Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-07-19 13:18:59 UTC (rev 7128) +++ openhpi/trunk/include/oHpi.h 2010-07-20 09:40:32 UTC (rev 7129) @@ -80,28 +80,28 @@ } oHpiGlobalParamT; /* Version function */ -SaHpiUint64T oHpiVersionGet(void); +SaHpiUint64T SAHPI_API oHpiVersionGet(void); /* Exported OpenHPI handler (plugin instance) calls */ -SaErrorT oHpiHandlerCreate(GHashTable *config, - oHpiHandlerIdT *id); -SaErrorT oHpiHandlerDestroy(oHpiHandlerIdT id); -SaErrorT oHpiHandlerInfo(oHpiHandlerIdT id, oHpiHandlerInfoT *info); -SaErrorT oHpiHandlerGetNext(oHpiHandlerIdT id, oHpiHandlerIdT *next_id); -SaErrorT oHpiHandlerFind(SaHpiSessionIdT sid, - SaHpiResourceIdT rid, - oHpiHandlerIdT *id); -SaErrorT oHpiHandlerRetry(oHpiHandlerIdT id); +SaErrorT SAHPI_API oHpiHandlerCreate(GHashTable *config, + oHpiHandlerIdT *id); +SaErrorT SAHPI_API oHpiHandlerDestroy(oHpiHandlerIdT id); +SaErrorT SAHPI_API oHpiHandlerInfo(oHpiHandlerIdT id, oHpiHandlerInfoT *info); +SaErrorT SAHPI_API oHpiHandlerGetNext(oHpiHandlerIdT id, oHpiHandlerIdT *next_id); +SaErrorT SAHPI_API oHpiHandlerFind(SaHpiSessionIdT sid, + SaHpiResourceIdT rid, + oHpiHandlerIdT *id); +SaErrorT SAHPI_API oHpiHandlerRetry(oHpiHandlerIdT id); /* Global parameters */ -SaErrorT oHpiGlobalParamGet(oHpiGlobalParamT *param); -SaErrorT oHpiGlobalParamSet(oHpiGlobalParamT *param); +SaErrorT SAHPI_API oHpiGlobalParamGet(oHpiGlobalParamT *param); +SaErrorT SAHPI_API oHpiGlobalParamSet(oHpiGlobalParamT *param); /* Injector */ -SaErrorT oHpiInjectEvent(oHpiHandlerIdT id, - SaHpiEventT *event, - SaHpiRptEntryT *rpte, - SaHpiRdrT *rdr); +SaErrorT SAHPI_API oHpiInjectEvent(oHpiHandlerIdT id, + SaHpiEventT *event, + SaHpiRptEntryT *rpte, + SaHpiRdrT *rdr); #define OHPI_VERSION_GET(v, VER) \ { \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-08-10 09:08:40
|
Revision: 7131 http://openhpi.svn.sourceforge.net/openhpi/?rev=7131&view=rev Author: ulikleber Date: 2010-08-10 09:08:34 +0000 (Tue, 10 Aug 2010) Log Message: ----------- Fix for Feature Request 3032998: New client hpidomain for domain information Man entries for hpidomain and hpigensimdata Fix for Bug 3032617: openhpi.conf.example uncomplete Additional log output for ipmidirect at end of initial discovery Modified Paths: -------------- openhpi/trunk/clients/Makefile.am openhpi/trunk/docs/man/Makefile.am openhpi/trunk/docs/man/hpialarms.pod.1 openhpi/trunk/docs/man/hpiel.pod.1 openhpi/trunk/docs/man/hpievents.pod.1 openhpi/trunk/docs/man/hpifan.pod.1 openhpi/trunk/docs/man/hpiinv.pod.1 openhpi/trunk/docs/man/hpionIBMblade.pod.1 openhpi/trunk/docs/man/hpipower.pod.1 openhpi/trunk/docs/man/hpireset.pod.1 openhpi/trunk/docs/man/hpisensor.pod.1 openhpi/trunk/docs/man/hpisettime.pod.1 openhpi/trunk/docs/man/hpithres.pod.1 openhpi/trunk/docs/man/hpitop.pod.1 openhpi/trunk/docs/man/hpitree.pod.1 openhpi/trunk/docs/man/hpiwdt.pod.1 openhpi/trunk/openhpi.conf.example openhpi/trunk/plugins/ipmidirect/ipmi_discover.cpp Modified: openhpi/trunk/clients/Makefile.am =================================================================== --- openhpi/trunk/clients/Makefile.am 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/clients/Makefile.am 2010-08-10 09:08:34 UTC (rev 7131) @@ -12,6 +12,7 @@ CLIENTS_SRC = clients.c bin_PROGRAMS = \ + hpidomain \ hpievents \ hpifan \ hpiinv \ @@ -33,6 +34,9 @@ hpialarms_SOURCES = hpialarms.c $(CLIENTS_SRC) hpialarms_LDADD = $(COMMONLIBS) +hpidomain_SOURCES = hpidomain.c $(CLIENTS_SRC) +hpidomain_LDADD = $(COMMONLIBS) + hpithres_SOURCES = hpithres.c $(CLIENTS_SRC) hpithres_LDADD = $(COMMONLIBS) Modified: openhpi/trunk/docs/man/Makefile.am =================================================================== --- openhpi/trunk/docs/man/Makefile.am 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/Makefile.am 2010-08-10 09:08:34 UTC (rev 7131) @@ -37,6 +37,7 @@ hpithres.pod.1 hpiwdt.pod.1 \ hpievents.pod.1 hpionIBMblade.pod.1 \ hpisensor.pod.1 hpitop.pod.1 \ + hpidomain.pod.1 hpigensimdata.pod.1 \ hpi_shell.pod.1 @@ -69,7 +70,8 @@ hpithres.1 hpiwdt.1 \ hpievents.1 hpionIBMblade.1 \ hpisensor.1 hpitop.1 \ - hpi_shell.1 + hpidomain.1 hpigensimdata.1 \ + hpi_shell.1 clean-local: am_config_clean-local Modified: openhpi/trunk/docs/man/hpialarms.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpialarms.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpialarms.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -57,8 +57,13 @@ =head1 SEE ALSO -hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpithres, hpitop, hpitree, hpiwdt + hpi_shell + hpidomain hpigensimdata hpireset hpitop + hpiel hpiinv hpisensor hpitree + hpievents hpionIBMblade hpisettime hpiwdt + hpifan hpipower hpithres + =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/docs/man/hpiel.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiel.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpiel.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -65,7 +65,11 @@ =head1 SEE ALSO -hpialarms, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpithres, hpitop, hpitree, hpiwdt + hpi_shell + hpialarms hpigensimdata hpireset hpitop + hpidomain hpiinv hpisensor hpitree + hpievents hpionIBMblade hpisettime hpiwdt + hpifan hpipower hpithres =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpievents.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpievents.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpievents.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -50,7 +50,12 @@ =head1 SEE ALSO -hpialarms, hpiel, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpithres, hpitop, hpitree, hpiwdt + hpi_shell + hpialarms hpigensimdata hpireset hpitop + hpidomain hpiinv hpisensor hpitree + hpiel hpionIBMblade hpisettime hpiwdt + hpifan hpipower hpithres + =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpifan.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpifan.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpifan.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -25,7 +25,12 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpithres, hpitop, hpitree, hpiwdt + hpi_shell + hpialarms hpigensimdata hpireset hpitop + hpidomain hpiinv hpisensor hpitree + hpiel hpionIBMblade hpisettime hpiwdt + hpievents hpipower hpithres + =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpiinv.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiinv.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpiinv.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -37,8 +37,13 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpifan, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpithres, hpitop, hpitree, hpiwdt + hpi_shell + hpialarms hpifan hpireset hpitop + hpidomain hpigensimdata hpisensor hpitree + hpiel hpionIBMblade hpisettime hpiwdt + hpievents hpipower hpithres + =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/docs/man/hpionIBMblade.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpionIBMblade.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpionIBMblade.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -50,7 +50,13 @@ =head1 SEE ALSO + hpi_shell + hpialarms hpifan hpireset hpitop + hpidomain hpigensimdata hpisensor hpitree + hpiel hpiiinv hpisettime hpiwdt + hpievents hpipower hpithres + =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/docs/man/hpipower.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpipower.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpipower.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -29,7 +29,11 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpireset, hpisensor, hpisettime, hpithres, hpitop, hpitree, hpiwdt + hpi_shell + hpialarms hpifan hpireset hpitop + hpidomain hpigensimdata hpisensor hpitree + hpiel hpiiinv hpisettime hpiwdt + hpievents hpionIBMblade hpithres =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpireset.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpireset.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpireset.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -31,9 +31,13 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpisensor, hpisettime, hpithres, hpitop, hpitree, hpiwdt - + hpi_shell + hpialarms hpifan hpipower hpitop + hpidomain hpigensimdata hpisensor hpitree + hpiel hpiiinv hpisettime hpiwdt + hpievents hpionIBMblade hpithres + =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/docs/man/hpisensor.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisensor.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpisensor.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -28,7 +28,11 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisettime, hpithres, hpitop, hpitree, hpiwdt + hpi_shell + hpialarms hpifan hpipower hpitop + hpidomain hpigensimdata hpireset hpitree + hpiel hpiiinv hpisettime hpiwdt + hpievents hpionIBMblade hpithres =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpisettime.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisettime.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpisettime.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -25,8 +25,13 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpithres, hpitop, hpitree, hpiwdt + hpi_shell + hpialarms hpifan hpipower hpitop + hpidomain hpigensimdata hpireset hpitree + hpiel hpiiinv hpisensor hpiwdt + hpievents hpionIBMblade hpithres + =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/docs/man/hpithres.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpithres.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpithres.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -23,10 +23,13 @@ =head1 SEE ALSO + hpi_shell + hpialarms hpifan hpipower hpitop + hpidomain hpigensimdata hpireset hpitree + hpiel hpiiinv hpisensor hpiwdt + hpievents hpionIBMblade hpisettime -hpialarms, hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpitop, hpitree, hpiwdt - =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/docs/man/hpitop.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitop.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpitop.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -34,8 +34,13 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpithres, hpitree, hpiwdt + hpi_shell + hpialarms hpifan hpipower hpithres + hpidomain hpigensimdata hpireset hpitree + hpiel hpiiinv hpisensor hpiwdt + hpievents hpionIBMblade hpisettime + =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/docs/man/hpitree.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitree.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpitree.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -36,7 +36,11 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpithres, hpitop, hpiwdt + hpi_shell + hpialarms hpifan hpipower hpithres + hpidomain hpigensimdata hpireset hpitop + hpiel hpiiinv hpisensor hpiwdt + hpievents hpionIBMblade hpisettime =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpiwdt.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiwdt.pod.1 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/docs/man/hpiwdt.pod.1 2010-08-10 09:08:34 UTC (rev 7131) @@ -28,8 +28,13 @@ =head1 SEE ALSO -hpialarms, hpiel, hpievents, hpifan, hpiinv, hpionIBMblade, hpipower, hpireset, hpisensor, hpisettime, hpithres, hpitop, hpitree + hpi_shell + hpialarms hpifan hpipower hpithres + hpidomain hpigensimdata hpireset hpitop + hpiel hpiiinv hpisensor hpitree + hpievents hpionIBMblade hpisettime + =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/openhpi.conf.example =================================================================== --- openhpi/trunk/openhpi.conf.example 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/openhpi.conf.example 2010-08-10 09:08:34 UTC (rev 7131) @@ -155,6 +155,10 @@ # auth_level = "admin" # operator or admin # username = "arthur" # password = "pieman" +# IpmiConnectionTimeout = "5000" +# AtcaConnectionTimeout = "1000" +# MaxOutstanding = "1" # Allow parallel processing of +# # ipmi commands; change with care # logflags = "" # logging off # # logflags = "file stdout" # # infos goes to logfile and stdout Modified: openhpi/trunk/plugins/ipmidirect/ipmi_discover.cpp =================================================================== --- openhpi/trunk/plugins/ipmidirect/ipmi_discover.cpp 2010-07-20 10:22:18 UTC (rev 7130) +++ openhpi/trunk/plugins/ipmidirect/ipmi_discover.cpp 2010-08-10 09:08:34 UTC (rev 7131) @@ -202,6 +202,11 @@ stdlog << "BMC Discovery done\n"; m_domain->m_bmc_discovered = true; } + else { + stdlog << "BMC Discovery (" << m_addr << ") done\n"; + if (m_domain->m_initial_discover == 0) + stdlog << "All BMC Discoveries Completed\n"; + } } if ( ( m_mc && (m_properties & dIpmiMcThreadPollAliveMc ) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-08-10 09:31:23
|
Revision: 7132 http://openhpi.svn.sourceforge.net/openhpi/?rev=7132&view=rev Author: ulikleber Date: 2010-08-10 09:31:17 +0000 (Tue, 10 Aug 2010) Log Message: ----------- Additional files were missing in revision 7131 Revision Links: -------------- http://openhpi.svn.sourceforge.net/openhpi/?rev=7131&view=rev Added Paths: ----------- openhpi/trunk/clients/hpidomain.c openhpi/trunk/docs/man/hpidomain.pod.1 openhpi/trunk/docs/man/hpigensimdata.pod.1 Added: openhpi/trunk/clients/hpidomain.c =================================================================== --- openhpi/trunk/clients/hpidomain.c (rev 0) +++ openhpi/trunk/clients/hpidomain.c 2010-08-10 09:31:17 UTC (rev 7132) @@ -0,0 +1,321 @@ +/* -*- linux-c -*- + * + * Copyright (C) Copyright Nokia Siemens Networks 2010 + * + * This program 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. This + * file and program are licensed under a BSD style license. See + * the Copying file included with the OpenHPI distribution for + * full licensing terms. + * + * Authors: + * Ulrich Kleber <uli...@us...> + * + * Log: + * Start from hpitop.c + * This routine display highlevel domain topology for a managed + * openHPI complex + * + * Changes: + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <getopt.h> +#include <uuid/uuid.h> +#include <SaHpi.h> +#include <oh_utils.h> +#include <oh_clients.h> + +#define OH_SVN_REV "$Revision: 7112 $" + +/* + * Function prototypes + */ +static SaErrorT show_domain(SaHpiSessionIdT sessionid); +static SaErrorT print_domaininfo(SaHpiDomainInfoT info, int shift); +static SaErrorT set_domaintag(SaHpiSessionIdT sessionid, + SaHpiTextBufferT domtag); + +/* + * Globals for this driver + */ +int fdebug = 0; +int fverbose = 0; + + +/* + * Main + */ +int +main(int argc, char **argv) +{ + SaErrorT rv = SA_OK; + + SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; + SaHpiSessionIdT sessionid; + SaHpiBoolT printusage = FALSE; + SaHpiTextBufferT domtag; + int c; + oh_init_textbuffer(&domtag); + + oh_prog_version(argv[0], OH_SVN_REV); + while ( (c = getopt( argc, argv,"D:t:vx?")) != EOF ) { + switch(c) { + case 'D': + if (optarg) { + domainid = atoi(optarg); + } + else printusage = TRUE; + break; + case 't': + if (optarg) { + oh_append_textbuffer(&domtag, optarg); + } + else printusage = TRUE; + break; + + case 'x': fdebug = 1; break; + case 'v': fverbose = 1; break; + default: printusage = TRUE; break; + } + } + if (printusage == TRUE) + { + printf("\n\tUsage: %s [-option]\n\n", argv[0]); + printf("\t (No Option) Display domain topology via " + "default domain: drt and headers\n"); + printf("\t -D nn Select domain id nn\n"); + printf("\t -v Display in verbose mode including " + "domain info for directly related domains\n"); + printf("\t -x Display debug messages\n"); + printf("\n\n\n\n"); + exit(1); + } + + if (fdebug) { + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("saHpiSessionOpen\n"); + else printf("saHpiSessionOpen to domain %d\n",domainid); + } + rv = saHpiSessionOpen(domainid,&sessionid,NULL); + if (rv != SA_OK) { + printf("saHpiSessionOpen returns %s\n",oh_lookup_error(rv)); + exit(-1); + } + if (fdebug) + printf("saHpiSessionOpen returns with SessionId %d\n", + sessionid); + + /* + * Resource discovery ------ do we need it? + * + if (fdebug) printf("saHpiDiscover\n"); + rv = saHpiDiscover(sessionid); + if (rv != SA_OK) { + printf("saHpiDiscover returns %s\n",oh_lookup_error(rv)); + exit(-1); + } */ + + if (domtag.DataLength>0){ + if (fdebug) printf ("Let's go change the tag\n"); + set_domaintag(sessionid, domtag); + } + + + if (fdebug) printf ("Let's go and list the domains!\n"); + + show_domain(sessionid); + + rv = saHpiSessionClose(sessionid); + + exit(0); +} + + +/* + * + */ +static +SaErrorT show_domain(SaHpiSessionIdT sessionid) +{ + SaErrorT rv = SA_OK; + SaHpiDomainInfoT domaininfo; + SaHpiDrtEntryT drtentry; + SaHpiEntryIdT drtentryid; + SaHpiEntryIdT nextdrtentryid; + SaHpiDomainInfoT relateddomaininfo; + SaHpiDomainIdT relateddomainid = SAHPI_UNSPECIFIED_DOMAIN_ID; + SaHpiSessionIdT relatedsessionid; + + if (fdebug) printf("saHpiDomainInfoGet\n"); + rv = saHpiDomainInfoGet(sessionid,&domaininfo); + if (rv!=SA_OK) { + printf("saHpiDomainInfoGet failed with returncode %s\n", + oh_lookup_error(rv)); + return rv; + } + + /* Print info about this domain */ + rv = print_domaininfo(domaininfo,0); + + /* walk the DRT */ + drtentryid = SAHPI_FIRST_ENTRY; + do { + if (fdebug) printf("saHpiDrtEntryGet\n"); + rv = saHpiDrtEntryGet(sessionid, + drtentryid,&nextdrtentryid,&drtentry); + if ((rv != SA_OK) || fdebug) + printf("DrtEntryGet returns %s\n",oh_lookup_error(rv)); + + if (rv == SA_OK ) { + if (fverbose) { + /* display the domaininfo for that related domain */ + relateddomainid = drtentry.DomainId; + rv = saHpiSessionOpen(relateddomainid, + &relatedsessionid,NULL); + if (rv != SA_OK) { + printf("Related domain found: %d IsPeer: %d\n", + drtentry.DomainId,drtentry.IsPeer); + printf("saHpiSessionOpen to related domain %d " + "returns %s\n", + relateddomainid,oh_lookup_error(rv)); + continue; + } + if (fdebug) { + printf("saHpiSessionOpen returns with SessionId %d\n", + relatedsessionid); + printf("saHpiDomainInfoGet for related domain %d\n", + relateddomainid); + } + rv = saHpiDomainInfoGet(relatedsessionid, + &relateddomaininfo); + if (rv!=SA_OK) { + printf("\nRelated domain found: %d IsPeer: %d\n", + drtentry.DomainId,drtentry.IsPeer); + printf("saHpiDomainInfoGet for related domain " + "%d failed with returncode %s\n", + relateddomainid,oh_lookup_error(rv)); + } + else { + printf("\nRelated domain found:\n"); + /* Print info about related domain */ + rv = print_domaininfo(relateddomaininfo,1); + } + + rv = saHpiSessionClose(relatedsessionid); + if (fdebug) + printf("saHpiSessionClose returns %s\n", + oh_lookup_error(rv)); + + } + else { + printf("Related domain found: %d IsPeer: %d\n", + drtentry.DomainId,drtentry.IsPeer); + } + } + else if (rv == SA_ERR_HPI_NOT_PRESENT) { + if (drtentryid == SAHPI_FIRST_ENTRY) + printf("DRT is empty. \n"); + else printf("Internal error while walking the DRT\n"); + } + else printf("Internal error while walking the DRT\n"); + + drtentryid = nextdrtentryid; + } while ((rv == SA_OK) && (drtentryid != SAHPI_LAST_ENTRY)); + + return(rv); +} + +/* +* +*/ +static SaErrorT print_domaininfo(SaHpiDomainInfoT info, int shift) +{ + SaHpiTextBufferT buf; + SaErrorT rv; + int i; + + for (i=0;i<shift;i++)printf(" "); + printf("Domain: %d Capabil: 0x%x IsPeer: %d Tag: ", + info.DomainId, info.DomainCapabilities, + info.IsPeer); + rv = oh_print_text(&(info.DomainTag)); + + printf("\n"); + for (i=0;i<shift;i++)printf(" "); + printf(" Guid: "); + for (i=0; i<16; i++) { + if ((i == 4) || (i == 6) || (i == 8) || (i == 10)) printf("-"); + printf("%02x",info.Guid[i]); + } + + printf("\n"); + rv = oh_decode_time(info.DrtUpdateTimestamp, &buf); + for (i=0;i<shift;i++)printf(" "); + printf(" DRT update count: %d DRT Timestamp : ", + info.DrtUpdateCount); + oh_print_text(&buf); + printf("\n"); + + rv = oh_decode_time(info.RptUpdateTimestamp, &buf); + for (i=0;i<shift;i++)printf(" "); + printf(" RPT update count: %d RPT Timestamp : ", + info.RptUpdateCount); + oh_print_text(&buf); + printf("\n"); + + rv = oh_decode_time(info.DatUpdateTimestamp, &buf); + for (i=0;i<shift;i++)printf(" "); + printf(" DAT update count: %d DAT Timestamp : ", + info.DatUpdateCount); + oh_print_text(&buf); + printf("\n"); + + for (i=0;i<shift;i++)printf(" "); + printf(" ActiveAlarms: %d CriticalAlarms: %d " + "Major: %d Minor: %d\n", + info.ActiveAlarms, info.CriticalAlarms, info.MajorAlarms, + info.MinorAlarms); + for (i=0;i<shift;i++)printf(" "); + printf(" Limit: %d DatOverflow : %d\n", + info.DatUserAlarmLimit, info.DatOverflow); + + return rv; +} + +/* +* +*/ +static SaErrorT set_domaintag(SaHpiSessionIdT sessionid, + SaHpiTextBufferT domtag) +{ + SaErrorT rv = SA_OK; + SaHpiDomainInfoT domaininfo; + + + if (fdebug) printf("saHpiDomainInfoGet\n"); + rv = saHpiDomainInfoGet(sessionid,&domaininfo); + if (rv!=SA_OK) { + printf("saHpiDomainInfoGet failed with returncode %s\n", + oh_lookup_error(rv)); + return rv; + } + + printf("Old domain Tag: "); + rv = oh_print_text(&(domaininfo.DomainTag)); + printf("\n"); + + rv = saHpiDomainTagSet (sessionid, &domtag); + if (rv!=SA_OK || fdebug) + printf("saHpiDomainTagSet failed with returncode %s. " + "Tag not changed.\n",oh_lookup_error(rv)); + + return rv; +} + +/* end hpidomain.c */ Added: openhpi/trunk/docs/man/hpidomain.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpidomain.pod.1 (rev 0) +++ openhpi/trunk/docs/man/hpidomain.pod.1 2010-08-10 09:31:17 UTC (rev 7132) @@ -0,0 +1,41 @@ +=head1 NAME + +hpidomain - A openhpi sample application that shows information about domains. +It can also set the domain tag. + +=head1 SYNOPSIS + +hpidomain [-D id] [-t tag] [-v -x] + +=head1 DESCRIPTION + +hpidomain displays the domain info for the specified domain. +If no domain is selected, hpidomain works with the default domain. +In verbose mode, it walks the DRT and displays domaininfo for all directly related domains +Option -t allows to change the domain tag. + +=over 2 + + (No Option) Display domain info + -D nn Select domain id nn + -v Verbose: Display domain info for all domains found in DRT + -t tag Set domain tag to the specified string + -x Display debug messages + +=back + +=head1 SEE ALSO + + hpi_shell + hpialarms hpigensimdata hpireset hpitop + hpiel hpiinv hpisensor hpitree + hpievents hpionIBMblade hpisettime hpiwdt + hpifan hpipower hpithres + + +=head1 AUTHORS + +Authors of this man page: + + Ulrich Kleber (uli...@us...) + Added: openhpi/trunk/docs/man/hpigensimdata.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpigensimdata.pod.1 (rev 0) +++ openhpi/trunk/docs/man/hpigensimdata.pod.1 2010-08-10 09:31:17 UTC (rev 7132) @@ -0,0 +1,44 @@ +=head1 NAME + +hpigensimdata - A openhpi client application supplementing the dynamic simulator plugin. + +=head1 SYNOPSIS + +hpidomain [-D domain_id] [-r res_id] [-f filename] [-m UPD|INIT] + +=head1 DESCRIPTION + +hpigensimdata generates data for the dynamic simulator plugin by reading the current +configuration. +Please refer to README and detailed documentation with the plugin. +If no domain is selected, hpidomain works with the default domain. +If no file name is specified, the data is displayed on console. + +=over 2 + + Usage: hpigensimdata [-option] + + -D domain_id Select particular Domain + -r res_id Select particular resource id for an update file + -f filename Name of the file to be generated + -m (UPD|INIT) Write update or initial file + + +=back + +=head1 SEE ALSO + + hpi_shell + hpialarms hpifan hpireset hpitop + hpidomain hpiinv hpisensor hpitree + hpiel hpionIBMblade hpisettime hpiwdt + hpievents hpipower hpithres + + +=head1 AUTHORS + +Authors of this man page: + + Ulrich Kleber (uli...@us...) + Lars Wetzel (lar...@us...) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-08-27 19:54:59
|
Revision: 7134 http://openhpi.svn.sourceforge.net/openhpi/?rev=7134&view=rev Author: avpak Date: 2010-08-27 19:54:53 +0000 (Fri, 27 Aug 2010) Log Message: ----------- Feature request #3052337 Modified Paths: -------------- openhpi/trunk/include/oh_event.h openhpi/trunk/openhpid/event.c openhpi/trunk/openhpid/safhpi.c openhpi/trunk/utils/rpt_utils.c openhpi/trunk/utils/rpt_utils.h Modified: openhpi/trunk/include/oh_event.h =================================================================== --- openhpi/trunk/include/oh_event.h 2010-08-13 16:27:47 UTC (rev 7133) +++ openhpi/trunk/include/oh_event.h 2010-08-27 19:54:53 UTC (rev 7134) @@ -38,35 +38,36 @@ * Optional Fields: * .resource, .rdrs * + * + * Any Resource oh_events: + * Use RESOURCE_UPDATED event for updating RPT entry. + * * FRU Resource oh_events: * If reporting a resource, the plugin sets the appropiate event in .event. * For example, if reporting a new FRU resource, then the event should be * a hotswap type showing the correct hotswap state (any except NOT_PRESENT) * indicating the library that it should add it to the RPT. - * If its just updating the FRU RPT entry, then it should come with a hotswap - * event with appropiate transition (current and previous hotswap states equal - * or as appropiate). The library will update the RPT entry accordingly. * If the plugin needs to report an extracted FRU, then the hotswap * event has to show the NOT_PRESENT current state, indicating to the library * that it should remove it from the RPT. * Hotswap events must have their accompaining resource set its capability bit * for FRU to 1 or it will be dropped by the infrastructure. - * The .resource.ResourceId field can be zero. If so, the RPT will not be - * updated, but the SaHpiEventT will be passed on to the session queues and - * domain event log normally. + * The .resource.ResourceCapabilities field can be zero. + * If so, the RPT will not be updated, but the SaHpiEventT will be passed + * on to the session queues and domain event log normally. * * Non-FRU Resource oh_events: * For adding or updating Non-FRU resources, the .event should be a resource * type HPI event and the ResourceEventType should be RESOURCE_ADDED or * RESOURCE_RESTORED. The resource itself should have its capability bit for * FRU set to zero or the event will be dropped by the infrastructure. - * Removing Non-FRU resource from the RPT is not supported anymore as this is - * not spec compliant. The Non-FRU resource are always there, but they are - * either working or failed. If a resource is failed, then the oh_event should + * Use RESOURCE_REMOVED for removing Non-FRU resource from the RPT. + * If a resource is failed, then the oh_event should * have a resource event type with the resource state as RESOURCE_FAILED. - * The .resource field should have the resource in question. This is used by - * the infrastructure to update the RPT and mark the resource as failed - * (ResourceFailed == True). The .resource.ResourceId field can be zero. If so, + * The .resource field should have the RPT entry for resource in question. + * This is used by the infrastructure to update the RPT and mark the resource + * as failed (ResourceFailed == True). + * The .resource.ResourceCapabilities field can be zero. If so, * the RPT will not be updated, but the SaHpiEventT will be passed on to the * session queues and domain event log normally. * @@ -75,9 +76,10 @@ * not previously exist in the RPT for the domain, then the .rdrs field is * scanned for valid SaHpiRdrTs (RdrType != SAHPI_NO_RECORD) objects and each * one is added as an rdr for the resource to the RPT. If the resource is - * already in the RPT, then the rdrs field will be ignored. - * This is to avoid changes to the RDR repository of a resource once the - * resource has already been added as this is not spec compliant. + * already in the RPT, then the rdrs field will be ignored for all + * event except RESOURCE_UPDATED. + * In addition to updating RPT entry, the RESOURCE_UPDATED event + * can be used for adding, updating or removing RDRs. * * Other event types: * If the event is of type SENSOR, SENSOR_ENABLE_CHANGE, WATCHDOG, or OEM, then @@ -94,6 +96,7 @@ /* If no resource, ResourceCapabilities must be 0 */ SaHpiRptEntryT resource; GSList *rdrs; + GSList *rdrs_to_remove; }; typedef struct _oh_evt_queue oh_evt_queue; Modified: openhpi/trunk/openhpid/event.c =================================================================== --- openhpi/trunk/openhpid/event.c 2010-08-13 16:27:47 UTC (rev 7133) +++ openhpi/trunk/openhpid/event.c 2010-08-27 19:54:53 UTC (rev 7134) @@ -71,6 +71,13 @@ } g_slist_free(e->rdrs); } + if (e->rdrs_to_remove) { + GSList *node = NULL; + for (node = e->rdrs_to_remove; node; node = node->next) { + g_free(node->data); + } + g_slist_free(e->rdrs_to_remove); + } if (!only_rdrs) g_free(e); } } @@ -89,6 +96,11 @@ e->rdrs = g_slist_append(e->rdrs, g_memdup(node->data, sizeof(SaHpiRdrT))); } + e->rdrs_to_remove = NULL; + for (node = old_event->rdrs_to_remove; node; node = node->next) { + e->rdrs_to_remove = g_slist_append(e->rdrs_to_remove, g_memdup(node->data, + sizeof(SaHpiRdrT))); + } return e; } @@ -313,6 +325,12 @@ SaHpiRdrT *rdr = (SaHpiRdrT *)node->data; oh_add_rdr(rpt, e->resource.ResourceId, rdr, NULL, 0); } + for (node = e->rdrs_to_remove; node; node = node->next) { + SaHpiRdrT *rdr = (SaHpiRdrT *)node->data; + SaHpiInstrumentIdT instr_id = oh_get_instrument_id(rdr); + SaHpiEntryIdT rdrid = oh_get_rdr_uid(rdr->RdrType, instr_id); + oh_remove_rdr(rpt, e->resource.ResourceId, rdrid); + } } } Modified: openhpi/trunk/openhpid/safhpi.c =================================================================== --- openhpi/trunk/openhpid/safhpi.c 2010-08-13 16:27:47 UTC (rev 7133) +++ openhpi/trunk/openhpid/safhpi.c 2010-08-27 19:54:53 UTC (rev 7134) @@ -1560,6 +1560,7 @@ e.event = *EvtEntry; /* indicate there is no rdr or resource */ e.rdrs = NULL; + e.rdrs_to_remove = NULL; e.resource.ResourceId = did; e.resource.ResourceCapabilities = 0; /* indicate this is a user-added event */ Modified: openhpi/trunk/utils/rpt_utils.c =================================================================== --- openhpi/trunk/utils/rpt_utils.c 2010-08-13 16:27:47 UTC (rev 7133) +++ openhpi/trunk/utils/rpt_utils.c 2010-08-27 19:54:53 UTC (rev 7134) @@ -159,39 +159,6 @@ return result; } -static SaHpiInstrumentIdT get_rdr_type_num(SaHpiRdrT *rdr) -{ - SaHpiInstrumentIdT num = 0; - - switch (rdr->RdrType) { - case SAHPI_CTRL_RDR: - num = rdr->RdrTypeUnion.CtrlRec.Num; - break; - case SAHPI_SENSOR_RDR: - num = rdr->RdrTypeUnion.SensorRec.Num; - break; - case SAHPI_INVENTORY_RDR: - num = rdr->RdrTypeUnion.InventoryRec.IdrId; - break; - case SAHPI_WATCHDOG_RDR: - num = rdr->RdrTypeUnion.WatchdogRec.WatchdogNum; - break; - case SAHPI_ANNUNCIATOR_RDR: - num = rdr->RdrTypeUnion.AnnunciatorRec.AnnunciatorNum; - break; - case SAHPI_DIMI_RDR: - num = rdr->RdrTypeUnion.DimiRec.DimiNum; - break; - case SAHPI_FUMI_RDR: - num = rdr->RdrTypeUnion.FumiRec.Num; - break; - default: - num = 0; - } - - return num; -} - static void update_rptable(RPTable *table) { struct timeval tv; SaHpiTimeT time; @@ -232,6 +199,48 @@ } /** + * oh_get_instrument_id + * @rdr: RDR + * + * Helper function to derive the Instrument Id of the rdr + * + * Returns: an instrument id or zero + */ +SaHpiInstrumentIdT oh_get_instrument_id(const SaHpiRdrT *rdr) +{ + SaHpiInstrumentIdT num = 0; + + switch (rdr->RdrType) { + case SAHPI_CTRL_RDR: + num = rdr->RdrTypeUnion.CtrlRec.Num; + break; + case SAHPI_SENSOR_RDR: + num = rdr->RdrTypeUnion.SensorRec.Num; + break; + case SAHPI_INVENTORY_RDR: + num = rdr->RdrTypeUnion.InventoryRec.IdrId; + break; + case SAHPI_WATCHDOG_RDR: + num = rdr->RdrTypeUnion.WatchdogRec.WatchdogNum; + break; + case SAHPI_ANNUNCIATOR_RDR: + num = rdr->RdrTypeUnion.AnnunciatorRec.AnnunciatorNum; + break; + case SAHPI_DIMI_RDR: + num = rdr->RdrTypeUnion.DimiRec.DimiNum; + break; + case SAHPI_FUMI_RDR: + num = rdr->RdrTypeUnion.FumiRec.Num; + break; + default: + num = 0; + } + + return num; +} + + +/** * General RPT calls **/ @@ -698,7 +707,7 @@ { RPTEntry *rptentry; RDRecord *rdrecord; - SaHpiInstrumentIdT type_num; + SaHpiInstrumentIdT instr_id; if (!rdr) { err("Failed to add. RDR is NULL."); @@ -716,10 +725,10 @@ return SA_ERR_HPI_INVALID_PARAMS; } - type_num = get_rdr_type_num(rdr); + instr_id = oh_get_instrument_id(rdr); /* Form correct RecordId. */ - rdr->RecordId = oh_get_rdr_uid(rdr->RdrType, type_num); + rdr->RecordId = oh_get_rdr_uid(rdr->RdrType, instr_id); /* Check if record exists */ rdrecord = get_rdrecord_by_id(rptentry, rdr->RecordId); /* If not, create new rdr */ Modified: openhpi/trunk/utils/rpt_utils.h =================================================================== --- openhpi/trunk/utils/rpt_utils.h 2010-08-13 16:27:47 UTC (rev 7133) +++ openhpi/trunk/utils/rpt_utils.h 2010-08-27 19:54:53 UTC (rev 7134) @@ -87,6 +87,7 @@ SaHpiRdrTypeT type, SaHpiInstrumentIdT num); SaHpiUint32T oh_get_rdr_uid(SaHpiRdrTypeT type, SaHpiInstrumentIdT num); SaHpiInstrumentIdT oh_get_rdr_num(SaHpiEntryIdT rdrid); +SaHpiInstrumentIdT oh_get_instrument_id(const SaHpiRdrT *rdr); #ifdef __cplusplus This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-09-08 16:46:17
|
Revision: 7139 http://openhpi.svn.sourceforge.net/openhpi/?rev=7139&view=rev Author: avpak Date: 2010-09-08 16:46:10 +0000 (Wed, 08 Sep 2010) Log Message: ----------- Updating usage output and man page for bugfix #2964284 Modified Paths: -------------- openhpi/trunk/clients/hpifan.c openhpi/trunk/docs/man/hpifan.pod.1 Modified: openhpi/trunk/clients/hpifan.c =================================================================== --- openhpi/trunk/clients/hpifan.c 2010-09-08 16:37:14 UTC (rev 7138) +++ openhpi/trunk/clients/hpifan.c 2010-09-08 16:46:10 UTC (rev 7139) @@ -46,6 +46,7 @@ fprintf( stderr, "\t\t -D domainid select the domain to work on\n" ); fprintf( stderr, "\t\t -h help\n" ); fprintf( stderr, "\t\t -s speed set fan speed for ALL fans in domain\n" ); + fprintf( stderr, "\t\t speed is a number or \"auto\" for setting fan in auto mode\n" ); return 1; } Modified: openhpi/trunk/docs/man/hpifan.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpifan.pod.1 2010-09-08 16:37:14 UTC (rev 7138) +++ openhpi/trunk/docs/man/hpifan.pod.1 2010-09-08 16:46:10 UTC (rev 7139) @@ -18,7 +18,8 @@ =over 2 -D <domainid> select domain id - -s <speed> set fan speed for ALL fans + -s <speed> set fan speed for ALL fans. + <speed> is a number or "auto" for setting fan in auto mode -h help =back This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-09-27 10:26:50
|
Revision: 7143 http://openhpi.svn.sourceforge.net/openhpi/?rev=7143&view=rev Author: avpak Date: 2010-09-27 10:26:44 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Feature Request #3073298 Modified Paths: -------------- openhpi/trunk/acinclude.m4 openhpi/trunk/configure.ac Modified: openhpi/trunk/acinclude.m4 =================================================================== --- openhpi/trunk/acinclude.m4 2010-09-13 14:22:36 UTC (rev 7142) +++ openhpi/trunk/acinclude.m4 2010-09-27 10:26:44 UTC (rev 7143) @@ -162,8 +162,8 @@ ], [ have_netsnmp=yes - SNMPFLAGS=`net-snmp-config --cflags | perl -p -e 's/-O\S*//g'` - SNMPLIBS=`net-snmp-config --libs` + SNMPFLAGS=`${net_snmp_config:-net-snmp-config} --cflags | perl -p -e 's/-O\S*//g'` + SNMPLIBS=`${net_snmp_config:-net-snmp-config} --libs` AC_MSG_RESULT(yes) ], [AC_MSG_RESULT(no. No SNMP based plugins can be built!)]) Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2010-09-13 14:22:36 UTC (rev 7142) +++ openhpi/trunk/configure.ac 2010-09-27 10:26:44 UTC (rev 7143) @@ -148,6 +148,10 @@ AC_CHECK_LIB([sysfs], [sysfs_get_mnt_path], [have_sysfs=yes]) AC_CHECK_HEADER([sysfs/libsysfs.h], [], [have_sysfs=no]) +AC_ARG_WITH(net-snmp-config, + [[ --with-net-snmp-config=SCRIPT run SCRIPT as net-snmp-config]], + [net_snmp_config=$withval]) + OH_CHECK_NETSNMP AC_CHECK_LIB([uuid], [uuid_generate], [have_uuid=yes], [ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-09-29 16:41:47
|
Revision: 7144 http://openhpi.svn.sourceforge.net/openhpi/?rev=7144&view=rev Author: ulikleber Date: 2010-09-29 16:41:41 +0000 (Wed, 29 Sep 2010) Log Message: ----------- implements Feature 3064532: Add a way to configure domains dynamically Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/baselib/oh_client_conf.c openhpi/trunk/baselib/oh_client_conf.h openhpi/trunk/include/oHpi.h openhpi/trunk/openhpid/ohpi.c Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-09-27 10:26:44 UTC (rev 7143) +++ openhpi/trunk/baselib/oh_client.cpp 2010-09-29 16:41:41 UTC (rev 7144) @@ -2,6 +2,7 @@ * * (C) Copyright IBM Corp. 2004-2008 * (C) Copyright Pigeon Point Systems. 2010 + * (C) Copyright Nokia Siemens Networks 2010 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,6 +15,7 @@ * W. David Ashley <da...@us...> * Renier Morales <re...@op...> * Anton Pak <ant...@pi...> + * Ulrich Kleber <uli...@us...> * */ @@ -5956,7 +5958,7 @@ /* oHpiHandlerInfo */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiHandlerInfo(oHpiHandlerIdT id, oHpiHandlerInfoT *info) +SaErrorT SAHPI_API oHpiHandlerInfo( oHpiHandlerIdT id, oHpiHandlerInfoT *info) { void *request; char reply[dMaxMessageLength]; @@ -6228,3 +6230,60 @@ return err; } + + + +/*----------------------------------------------------------------------------*/ +/* oHpiDomainAdd */ +/*----------------------------------------------------------------------------*/ +SaErrorT SAHPI_API oHpiDomainAdd(const SaHpiTextBufferT *host, + SaHpiUint16T port, + SaHpiDomainIdT *domain_id) +{ + if (!host) { + return SA_ERR_HPI_INVALID_PARAMS; + } + if (!domain_id) { + return SA_ERR_HPI_INVALID_PARAMS; + } + if ( (host->DataType != SAHPI_TL_TYPE_BCDPLUS) && + (host->DataType != SAHPI_TL_TYPE_ASCII6) && + (host->DataType != SAHPI_TL_TYPE_TEXT) ) + { + return SA_ERR_HPI_INVALID_DATA; + } + + char buf[SAHPI_MAX_TEXT_BUFFER_LENGTH+1]; + memcpy(&buf[0], &host->Data[0], host->DataLength); + buf[host->DataLength] = '\0'; + + return oh_add_domain_conf(buf, port, domain_id); +} + + + +/*----------------------------------------------------------------------------*/ +/* oHpiDomainAddById */ +/*----------------------------------------------------------------------------*/ +SaErrorT SAHPI_API oHpiDomainAddById(SaHpiDomainIdT domain_id, + const SaHpiTextBufferT *host, + SaHpiUint16T port) +{ + if (!host) { + return SA_ERR_HPI_INVALID_PARAMS; + } + if ( (host->DataType != SAHPI_TL_TYPE_BCDPLUS) && + (host->DataType != SAHPI_TL_TYPE_ASCII6) && + (host->DataType != SAHPI_TL_TYPE_TEXT) ) + { + return SA_ERR_HPI_INVALID_DATA; + } + + char buf[SAHPI_MAX_TEXT_BUFFER_LENGTH+1]; + memcpy(&buf[0], &host->Data[0], host->DataLength); + buf[host->DataLength] = '\0'; + + return oh_add_domain_conf_by_id(domain_id, buf, port); +} + + Modified: openhpi/trunk/baselib/oh_client_conf.c =================================================================== --- openhpi/trunk/baselib/oh_client_conf.c 2010-09-27 10:26:44 UTC (rev 7143) +++ openhpi/trunk/baselib/oh_client_conf.c 2010-09-29 16:41:41 UTC (rev 7144) @@ -2,6 +2,7 @@ * * (C) Copyright IBM Corp. 2008 * (C) Copyright Pigeon Point Systems. 2010 + * (C) Copyright Nokia Siemens Networks 2010 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,6 +14,7 @@ * Authors: * Renier Morales <re...@op...> * Anton Pak <ant...@pi...> + * Ulrich Kleber <uli...@us...> */ #include <stdlib.h> @@ -37,7 +39,10 @@ static void add_domain_conf(SaHpiDomainIdT did, const char *host, unsigned short port); +static void extract_keys(gpointer key, gpointer val, gpointer user_data); +static gint compare_keys(const gint *a, const gint *b); + void oh_client_conf_init(void) { @@ -96,7 +101,87 @@ return dc; } +SaErrorT oh_add_domain_conf(const char *host, + unsigned short port, + SaHpiDomainIdT *did) +{ + g_static_rec_mutex_lock(&ohc_lock); + // get all known domain ids and sort them + GList *keys = 0; + g_hash_table_foreach(ohc_domains, extract_keys, &keys); + keys = g_list_sort(keys, (GCompareFunc)compare_keys); + + // found prev = a gap in domain ids list or max domain id + // so that new did will be prev + 1 + SaHpiDomainIdT prev_did = 0; + GList *item; + for (item = keys; item != NULL; item = item->next) { + SaHpiDomainIdT item_did = *(const SaHpiDomainIdT *)(item->data); + if ((prev_did + 1) < item_did) { + break; + } + prev_did = item_did; + } + + g_list_free(keys); + + if (prev_did == SAHPI_UNSPECIFIED_DOMAIN_ID) { + g_static_rec_mutex_unlock(&ohc_lock); + return SA_ERR_HPI_OUT_OF_SPACE; + } + if ((prev_did + 1) == SAHPI_UNSPECIFIED_DOMAIN_ID) { + g_static_rec_mutex_unlock(&ohc_lock); + return SA_ERR_HPI_OUT_OF_SPACE; + } + + *did = prev_did + 1; + add_domain_conf(*did, host, port); + + g_static_rec_mutex_unlock(&ohc_lock); + + return SA_OK; +} + +SaErrorT oh_add_domain_conf_by_id(SaHpiDomainIdT did, + const char *host, + unsigned short port) +{ + if (did==SAHPI_UNSPECIFIED_DOMAIN_ID || + did==OH_DEFAULT_DOMAIN_ID) + return SA_ERR_HPI_INVALID_PARAMS; + + g_static_rec_mutex_lock(&ohc_lock); + + // check new did against all known domain ids + if (oh_get_domain_conf(did) != NULL) { + g_static_rec_mutex_unlock(&ohc_lock); + return SA_ERR_HPI_DUPLICATE; + } + + add_domain_conf(did, host, port); + g_static_rec_mutex_unlock(&ohc_lock); + return SA_OK; +} + +static void extract_keys(gpointer key, gpointer val, gpointer user_data) +{ + GList ** key_list = (GList **)(user_data); + *key_list = g_list_append(*key_list, key); +} + +static gint compare_keys(const gint *a, const gint *b) +{ + if ( *a < *b ) { + return -1; + } else if ( *a > *b ) { + return 1; + } else { + return 0; + } +} + + /******************************************************************************* * In order to use the glib lexical parser we need to define token * types which we want to switch on @@ -294,7 +379,7 @@ return -10; } - add_domain_conf(did, host, port); + add_domain_conf(did, host, port); return 0; } Modified: openhpi/trunk/baselib/oh_client_conf.h =================================================================== --- openhpi/trunk/baselib/oh_client_conf.h 2010-09-27 10:26:44 UTC (rev 7143) +++ openhpi/trunk/baselib/oh_client_conf.h 2010-09-29 16:41:41 UTC (rev 7144) @@ -2,6 +2,7 @@ * * (C) Copyright IBM Corp. 2008 * (C) Copyright Pigeon Point Systems. 2010 + * (C) Copyright Nokia Siemens Networks 2010 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,6 +14,7 @@ * Author(s): * Renier Morales <re...@op...> * Anton Pak <ant...@pi...> + * Ulrich Kleber <uli...@us...> * */ @@ -36,6 +38,14 @@ void oh_client_conf_init(void); const struct oh_domain_conf * oh_get_domain_conf(SaHpiDomainIdT did); +SaErrorT oh_add_domain_conf(const char *host, + unsigned short port, + SaHpiDomainIdT *did); +SaErrorT oh_add_domain_conf_by_id(SaHpiDomainIdT did, + const char *host, + unsigned short port); + + #ifdef __cplusplus } /* extern "C" */ #endif Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-09-27 10:26:44 UTC (rev 7143) +++ openhpi/trunk/include/oHpi.h 2010-09-29 16:41:41 UTC (rev 7144) @@ -1,6 +1,8 @@ /* -*- linux-c -*- * * (C) Copright IBM Corp 2004-2006 + * (C) Copyright Pigeon Point Systems. 2010 + * (C) Copyright Nokia Siemens Networks 2010 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -11,6 +13,8 @@ * * Authors: * Renier Morales <re...@op...> + * Anton Pak <ant...@pi...> + * Ulrich Kleber <uli...@us...> */ #ifndef __OHPI_H @@ -103,6 +107,14 @@ SaHpiRptEntryT *rpte, SaHpiRdrT *rdr); +/* Domain configuration */ +SaErrorT SAHPI_API oHpiDomainAdd(const SaHpiTextBufferT *host, + SaHpiUint16T port, + SaHpiDomainIdT *domain_id); +SaErrorT SAHPI_API oHpiDomainAddById(SaHpiDomainIdT domain_id, + const SaHpiTextBufferT *host, + SaHpiUint16T port); + #define OHPI_VERSION_GET(v, VER) \ { \ char version[] = VER; \ Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-09-27 10:26:44 UTC (rev 7143) +++ openhpi/trunk/openhpid/ohpi.c 2010-09-29 16:41:41 UTC (rev 7144) @@ -1,6 +1,8 @@ /* -*- linux-c -*- * * (C) Copright IBM Corp 2004,2006 + * (C) Copyright Pigeon Point Systems. 2010 + * (C) Copyright Nokia Siemens Networks 2010 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -11,6 +13,8 @@ * * Authors: * Renier Morales <re...@op...> + * Anton Pak <ant...@pi...> + * Ulrich Kleber <uli...@us...> */ #include <oHpi.h> @@ -356,3 +360,39 @@ return error; } +/** + * oHpiDomainAdd + * @host: host name of domain config item + * @port: port for domain config item + * @domain_id: domain_id for newly created domain config item + * + * Returns: SA_OK on success and fills domain_id. + * + * Currently only available in client library, but not in daemon + **/ +SaErrorT SAHPI_API oHpiDomainAdd(const SaHpiTextBufferT *host, + SaHpiUint16T port, + SaHpiDomainIdT *domain_id) +{ + return SA_ERR_HPI_UNSUPPORTED_API; +} + + +/** + * oHpiDomainAddById + * @host: host name of domain config item + * @port: port for domain config item + * @domain_id: domain_id for newly created domain config item + * + * Returns: SA_OK on success and fills domain_id. + * + * Currently only available in client library, but not in daemon + **/ +SaErrorT SAHPI_API oHpiDomainAddById(SaHpiDomainIdT domain_id, + const SaHpiTextBufferT *host, + SaHpiUint16T port) +{ + return SA_ERR_HPI_UNSUPPORTED_API; +} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-10-12 09:09:24
|
Revision: 7146 http://openhpi.svn.sourceforge.net/openhpi/?rev=7146&view=rev Author: ulikleber Date: 2010-10-12 09:09:17 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Feature Requests-3074880 Extend oHpiHandlerInfo for handler params Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/include/oHpi.h openhpi/trunk/marshal/marshal_hpi.c openhpi/trunk/openhpid/ohpi.c openhpi/trunk/openhpid/openhpid.cpp openhpi/trunk/openhpid/t/ohpi/ohpi_009.c openhpi/trunk/openhpid/t/ohpi/ohpi_030.c openhpi/trunk/openhpid/t/ohpi/ohpi_031.c Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/baselib/oh_client.cpp 2010-10-12 09:09:17 UTC (rev 7146) @@ -5958,13 +5958,19 @@ /* oHpiHandlerInfo */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiHandlerInfo( oHpiHandlerIdT id, oHpiHandlerInfoT *info) +SaErrorT SAHPI_API oHpiHandlerInfo( oHpiHandlerIdT id, + oHpiHandlerInfoT *info, + GHashTable **conf_params ) { void *request; char reply[dMaxMessageLength]; SaErrorT err = SA_OK; char cmd[] = "oHpiHandlerInfo"; pcstrmsock pinst = NULL; + oHpiHandlerConfigT config; + GHashTable *config_table = g_hash_table_new_full( + g_str_hash, g_str_equal, + g_free, g_free ); err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; @@ -5977,8 +5983,18 @@ SendRecv(0, cmd); - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, info); + int mr = HpiDemarshalReply2(pinst->remote_byte_order, hm, + reply + sizeof(cMessageHeader), + &err, info, &config); + for (int n = 0; n < config.NumberOfParams; n++) { + g_hash_table_insert(config_table, + g_strdup((const gchar *)config.Params[n].Name), + g_strdup((const gchar *)config.Params[n].Value)); + } + free(config.Params); + *conf_params = config_table; + oh_delete_connx(pinst); if (request) free(request); Modified: openhpi/trunk/clients/hpionIBMblade.c =================================================================== --- openhpi/trunk/clients/hpionIBMblade.c 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/clients/hpionIBMblade.c 2010-10-12 09:09:17 UTC (rev 7146) @@ -223,6 +223,7 @@ unsigned int i; oHpiHandlerIdT this_handler_id; oHpiHandlerInfoT handler_info; + GHashTable *config = 0; rv = oHpiHandlerFind(sessionid, Rpt->Rpt.ResourceId, @@ -232,7 +233,7 @@ return(0); } - rv = oHpiHandlerInfo(this_handler_id, &handler_info); + rv = oHpiHandlerInfo(this_handler_id, &handler_info, &config); if (rv) { if (fdebug) printf("oHpiHandlerInfo returns %s\n", oh_lookup_error(rv)); return(0); Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/include/oHpi.h 2010-10-12 09:09:17 UTC (rev 7146) @@ -90,7 +90,9 @@ SaErrorT SAHPI_API oHpiHandlerCreate(GHashTable *config, oHpiHandlerIdT *id); SaErrorT SAHPI_API oHpiHandlerDestroy(oHpiHandlerIdT id); -SaErrorT SAHPI_API oHpiHandlerInfo(oHpiHandlerIdT id, oHpiHandlerInfoT *info); +SaErrorT SAHPI_API oHpiHandlerInfo(oHpiHandlerIdT id, + oHpiHandlerInfoT *info, + GHashTable **conf_params); SaErrorT SAHPI_API oHpiHandlerGetNext(oHpiHandlerIdT id, oHpiHandlerIdT *next_id); SaErrorT SAHPI_API oHpiHandlerFind(SaHpiSessionIdT sid, SaHpiResourceIdT rid, Modified: openhpi/trunk/marshal/marshal_hpi.c =================================================================== --- openhpi/trunk/marshal/marshal_hpi.c 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/marshal/marshal_hpi.c 2010-10-12 09:09:17 UTC (rev 7146) @@ -2,6 +2,8 @@ * marshaling/demarshaling of hpi functions * * Copyright (c) 2004 by FORCE Computers. + * (C) Copyright Pigeon Point Systems. 2010 + * (C) Copyright Nokia Siemens Networks 2010 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,6 +17,7 @@ * W. David Ashley <da...@us...> * Renier Morales <re...@op...> * Anton Pak <ant...@pi...> + * Ulrich Kleber <uli...@us...> */ #include "marshal_hpi.h" @@ -1914,6 +1917,7 @@ { &SaErrorType, // result (SaErrorT) &oHpiHandlerInfoType, // handler info + &oHpiHandlerConfigType, // handler config params 0 }; Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/openhpid/ohpi.c 2010-10-12 09:09:17 UTC (rev 7146) @@ -110,8 +110,15 @@ * * Returns: SA_OK on success. Minus SA_OK on error. **/ -SaErrorT oHpiHandlerInfo(oHpiHandlerIdT id, oHpiHandlerInfoT *info) +// function to copy hash table +static void copy_hashed_config_info (gpointer key, gpointer value, gpointer newhash) { + g_hash_table_insert ( newhash, g_strdup(key), g_strdup(value) ); +} +SaErrorT oHpiHandlerInfo( oHpiHandlerIdT id, + oHpiHandlerInfoT *info, + GHashTable **conf_params ) //will be allocated +{ struct oh_handler *h = NULL; if (!id || !info) @@ -133,6 +140,17 @@ if (!h->hnd) info->load_failed = 1; else info->load_failed = 0; + // create a new hash table, so the original config table is not + // transferred and deleted. + *conf_params = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, g_free); + // copy h->config to the output hash table + g_hash_table_foreach(h->config,copy_hashed_config_info,*conf_params); + + //Don't transmit passwords in case the handler has a password in its config + if (g_hash_table_lookup(*conf_params,"password")) + g_hash_table_replace(*conf_params,"password","********"); + oh_release_handler(h); return SA_OK; Modified: openhpi/trunk/openhpid/openhpid.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid.cpp 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/openhpid/openhpid.cpp 2010-10-12 09:09:17 UTC (rev 7146) @@ -1,6 +1,8 @@ /* -*- linux-c -*- * * (C) Copyright IBM Corp. 2004-2008 + * (C) Copyright Pigeon Point Systems. 2010 + * (C) Copyright Nokia Siemens Networks 2010 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,6 +16,7 @@ * David Judkoivcs <dju...@us...> * Renier Morales <re...@op...> * Anton Pak <ant...@pi...> + * Ulrich Kleber <uli...@us...> * */ @@ -98,6 +101,25 @@ #define PVERBOSE3(msg, ...) if (verbose_flag) printf("CRITICAL: "msg, ## __VA_ARGS__) /*--------------------------------------------------------------------*/ +/* Function to dehash handler config for oHpiHandlerInfo */ +/*--------------------------------------------------------------------*/ +static void __dehash_handler_config(gpointer key, gpointer value, gpointer data) +{ + oHpiHandlerConfigT *handler_config = (oHpiHandlerConfigT *)data; + + strncpy((char *)handler_config->Params[handler_config->NumberOfParams].Name, + (const char *)key, + SAHPI_MAX_TEXT_BUFFER_LENGTH); + strncpy((char *)handler_config->Params[handler_config->NumberOfParams].Value, + (const char *)value, + SAHPI_MAX_TEXT_BUFFER_LENGTH); + + handler_config->NumberOfParams = handler_config->NumberOfParams + 1; + + return; +} + +/*--------------------------------------------------------------------*/ /* Function: display_help */ /*--------------------------------------------------------------------*/ @@ -2879,6 +2901,10 @@ case eFoHpiHandlerInfo: { oHpiHandlerIdT id; oHpiHandlerInfoT info; + oHpiHandlerConfigT config; + GHashTable *config_table = g_hash_table_new_full( + g_str_hash, g_str_equal, + g_free, g_free ); PVERBOSE1("%p Processing oHpiHandlerInfo.", thrdid); @@ -2886,9 +2912,18 @@ hm, pReq, &id ) < 0 ) return eResultError; - ret = oHpiHandlerInfo(id, &info); - - thrdinst->header.m_len = HpiMarshalReply1( hm, pReq, &ret, &info ); + ret = oHpiHandlerInfo(id, &info, &config_table); + + config.NumberOfParams = 0; + config.Params = (oHpiHandlerConfigParamT *) + g_malloc0(sizeof(oHpiHandlerConfigParamT) + *g_hash_table_size(config_table)); + // add each hash table entry to the marshable handler_config + g_hash_table_foreach(config_table, __dehash_handler_config, &config); + + thrdinst->header.m_len = HpiMarshalReply2( hm, pReq, + &ret, &info, &config ); + result = eResultClose; } break; Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_009.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_009.c 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_009.c 2010-10-12 09:09:17 UTC (rev 7146) @@ -30,6 +30,7 @@ GHashTable *config = g_hash_table_new(g_str_hash, g_str_equal); oHpiHandlerIdT hid = 0; oHpiHandlerInfoT hinfo; + GHashTable *configinfo = 0; setenv("OPENHPI_CONF","./noconfig", 1); @@ -45,7 +46,7 @@ if (oHpiHandlerCreate(config, &hid)) return -1; - if (oHpiHandlerInfo(hid, &hinfo)) + if (oHpiHandlerInfo(hid, &hinfo, &configinfo)) return -1; if (strcmp("libsimulator",hinfo.plugin_name)) Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_030.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_030.c 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_030.c 2010-10-12 09:09:17 UTC (rev 7146) @@ -43,7 +43,7 @@ if (oHpiHandlerCreate(config, &hid)) return -1; - if (!oHpiHandlerInfo(0, NULL)) + if (!oHpiHandlerInfo(0, NULL, NULL)) return -1; Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_031.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_031.c 2010-10-10 19:02:29 UTC (rev 7145) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_031.c 2010-10-12 09:09:17 UTC (rev 7146) @@ -29,6 +29,7 @@ GHashTable *config = g_hash_table_new(g_str_hash, g_str_equal); oHpiHandlerIdT hid = 0; oHpiHandlerInfoT hinfo; + GHashTable *configinfo = 0; setenv("OPENHPI_CONF","./noconfig", 1); @@ -44,7 +45,7 @@ if (oHpiHandlerCreate(config, &hid)) return -1; - if (!oHpiHandlerInfo(555, &hinfo)) + if (!oHpiHandlerInfo(555, &hinfo, &configinfo)) return -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-10-12 10:07:38
|
Revision: 7147 http://openhpi.svn.sourceforge.net/openhpi/?rev=7147&view=rev Author: ulikleber Date: 2010-10-12 10:07:31 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Fixed Bug 3078684: oHpi functions should useSAHPI_API etc. consistently Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/include/oHpi.h openhpi/trunk/openhpid/ohpi.c Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-10-12 09:09:17 UTC (rev 7146) +++ openhpi/trunk/baselib/oh_client.cpp 2010-10-12 10:07:31 UTC (rev 7147) @@ -5874,8 +5874,9 @@ /* oHpiHandlerCreate */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiHandlerCreate(GHashTable *config, - oHpiHandlerIdT *id) +SaErrorT SAHPI_API oHpiHandlerCreate ( + SAHPI_IN GHashTable *config, + SAHPI_OUT oHpiHandlerIdT *id ) { SaErrorT err = SA_OK; void *request; @@ -5922,7 +5923,8 @@ /* oHpiHandlerDestroy */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiHandlerDestroy(oHpiHandlerIdT id) +SaErrorT SAHPI_API oHpiHandlerDestroy ( + SAHPI_IN oHpiHandlerIdT id ) { void *request; char reply[dMaxMessageLength]; @@ -5958,9 +5960,10 @@ /* oHpiHandlerInfo */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiHandlerInfo( oHpiHandlerIdT id, - oHpiHandlerInfoT *info, - GHashTable **conf_params ) +SaErrorT SAHPI_API oHpiHandlerInfo ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_OUT oHpiHandlerInfoT *info, + SAHPI_OUT GHashTable **conf_params ) //hash table will be allocated { void *request; char reply[dMaxMessageLength]; @@ -6010,7 +6013,9 @@ /* oHpiHandlerGetNext */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiHandlerGetNext(oHpiHandlerIdT id, oHpiHandlerIdT *next_id) +SaErrorT SAHPI_API oHpiHandlerGetNext ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_OUT oHpiHandlerIdT *next_id ) { void *request; char reply[dMaxMessageLength]; @@ -6044,9 +6049,10 @@ /*----------------------------------------------------------------------------*/ /* oHpiHandlerFind */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiHandlerFind(SaHpiSessionIdT sid, - SaHpiResourceIdT rid, - oHpiHandlerIdT *id) +SaErrorT SAHPI_API oHpiHandlerFind ( + SAHPI_IN SaHpiSessionIdT sid, + SAHPI_IN SaHpiResourceIdT rid, + SAHPI_OUT oHpiHandlerIdT *id ) { void *request; char reply[dMaxMessageLength]; @@ -6089,7 +6095,8 @@ /*----------------------------------------------------------------------------*/ /* oHpiHandlerRetry */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiHandlerRetry(oHpiHandlerIdT id) +SaErrorT SAHPI_API oHpiHandlerRetry ( + SAHPI_IN oHpiHandlerIdT id ) { void *request; char reply[dMaxMessageLength]; @@ -6133,7 +6140,8 @@ /* oHpiGlobalParamGet */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiGlobalParamGet(oHpiGlobalParamT *param) +SaErrorT SAHPI_API oHpiGlobalParamGet ( + SAHPI_OUT oHpiGlobalParamT *param ) { void *request; char reply[dMaxMessageLength]; @@ -6169,7 +6177,8 @@ /* oHpiGlobalParamSet */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiGlobalParamSet(oHpiGlobalParamT *param) +SaErrorT SAHPI_API oHpiGlobalParamSet ( + SAHPI_IN oHpiGlobalParamT *param ) { void *request; char reply[dMaxMessageLength]; @@ -6204,10 +6213,11 @@ /*----------------------------------------------------------------------------*/ /* oHpiInjectEvent */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiInjectEvent(oHpiHandlerIdT id, - SaHpiEventT *event, - SaHpiRptEntryT *rpte, - SaHpiRdrT *rdr) +SaErrorT SAHPI_API oHpiInjectEvent ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_IN SaHpiEventT *event, + SAHPI_IN SaHpiRptEntryT *rpte, + SAHPI_IN SaHpiRdrT *rdr) { void *request; char reply[dMaxMessageLength]; @@ -6252,9 +6262,10 @@ /*----------------------------------------------------------------------------*/ /* oHpiDomainAdd */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiDomainAdd(const SaHpiTextBufferT *host, - SaHpiUint16T port, - SaHpiDomainIdT *domain_id) +SaErrorT SAHPI_API oHpiDomainAdd ( + SAHPI_IN const SaHpiTextBufferT *host, + SAHPI_IN SaHpiUint16T port, + SAHPI_OUT SaHpiDomainIdT *domain_id ) { if (!host) { return SA_ERR_HPI_INVALID_PARAMS; @@ -6281,9 +6292,10 @@ /*----------------------------------------------------------------------------*/ /* oHpiDomainAddById */ /*----------------------------------------------------------------------------*/ -SaErrorT SAHPI_API oHpiDomainAddById(SaHpiDomainIdT domain_id, - const SaHpiTextBufferT *host, - SaHpiUint16T port) +SaErrorT SAHPI_API oHpiDomainAddById ( + SAHPI_IN SaHpiDomainIdT domain_id, + SAHPI_IN const SaHpiTextBufferT *host, + SAHPI_IN SaHpiUint16T port ) { if (!host) { return SA_ERR_HPI_INVALID_PARAMS; Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-10-12 09:09:17 UTC (rev 7146) +++ openhpi/trunk/include/oHpi.h 2010-10-12 10:07:31 UTC (rev 7147) @@ -87,35 +87,47 @@ SaHpiUint64T SAHPI_API oHpiVersionGet(void); /* Exported OpenHPI handler (plugin instance) calls */ -SaErrorT SAHPI_API oHpiHandlerCreate(GHashTable *config, - oHpiHandlerIdT *id); -SaErrorT SAHPI_API oHpiHandlerDestroy(oHpiHandlerIdT id); -SaErrorT SAHPI_API oHpiHandlerInfo(oHpiHandlerIdT id, - oHpiHandlerInfoT *info, - GHashTable **conf_params); -SaErrorT SAHPI_API oHpiHandlerGetNext(oHpiHandlerIdT id, oHpiHandlerIdT *next_id); -SaErrorT SAHPI_API oHpiHandlerFind(SaHpiSessionIdT sid, - SaHpiResourceIdT rid, - oHpiHandlerIdT *id); -SaErrorT SAHPI_API oHpiHandlerRetry(oHpiHandlerIdT id); +SaErrorT SAHPI_API oHpiHandlerCreate ( + SAHPI_IN GHashTable *config, + SAHPI_OUT oHpiHandlerIdT *id ); +SaErrorT SAHPI_API oHpiHandlerDestroy ( + SAHPI_IN oHpiHandlerIdT id ); +SaErrorT SAHPI_API oHpiHandlerInfo ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_OUT oHpiHandlerInfoT *info, + SAHPI_OUT GHashTable **conf_params ); //hash table will be allocated +SaErrorT SAHPI_API oHpiHandlerGetNext ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_OUT oHpiHandlerIdT *next_id ); +SaErrorT SAHPI_API oHpiHandlerFind ( + SAHPI_IN SaHpiSessionIdT sid, + SAHPI_IN SaHpiResourceIdT rid, + SAHPI_OUT oHpiHandlerIdT *id ); +SaErrorT SAHPI_API oHpiHandlerRetry ( + SAHPI_IN oHpiHandlerIdT id ); /* Global parameters */ -SaErrorT SAHPI_API oHpiGlobalParamGet(oHpiGlobalParamT *param); -SaErrorT SAHPI_API oHpiGlobalParamSet(oHpiGlobalParamT *param); +SaErrorT SAHPI_API oHpiGlobalParamGet ( + SAHPI_OUT oHpiGlobalParamT *param ); +SaErrorT SAHPI_API oHpiGlobalParamSet ( + SAHPI_IN oHpiGlobalParamT *param ); /* Injector */ -SaErrorT SAHPI_API oHpiInjectEvent(oHpiHandlerIdT id, - SaHpiEventT *event, - SaHpiRptEntryT *rpte, - SaHpiRdrT *rdr); +SaErrorT SAHPI_API oHpiInjectEvent ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_IN SaHpiEventT *event, + SAHPI_IN SaHpiRptEntryT *rpte, + SAHPI_IN SaHpiRdrT *rdr); /* Domain configuration */ -SaErrorT SAHPI_API oHpiDomainAdd(const SaHpiTextBufferT *host, - SaHpiUint16T port, - SaHpiDomainIdT *domain_id); -SaErrorT SAHPI_API oHpiDomainAddById(SaHpiDomainIdT domain_id, - const SaHpiTextBufferT *host, - SaHpiUint16T port); +SaErrorT SAHPI_API oHpiDomainAdd ( + SAHPI_IN const SaHpiTextBufferT *host, + SAHPI_IN SaHpiUint16T port, + SAHPI_OUT SaHpiDomainIdT *domain_id ); +SaErrorT SAHPI_API oHpiDomainAddById ( + SAHPI_IN SaHpiDomainIdT domain_id, + SAHPI_IN const SaHpiTextBufferT *host, + SAHPI_IN SaHpiUint16T port ); #define OHPI_VERSION_GET(v, VER) \ { \ Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-10-12 09:09:17 UTC (rev 7146) +++ openhpi/trunk/openhpid/ohpi.c 2010-10-12 10:07:31 UTC (rev 7147) @@ -63,8 +63,9 @@ * created, but failed to open. oHpiHandlerRetry can be used to retry * opening the handler. **/ -SaErrorT oHpiHandlerCreate(GHashTable *config, - oHpiHandlerIdT *id) +SaErrorT SAHPI_API oHpiHandlerCreate ( + SAHPI_IN GHashTable *config, + SAHPI_OUT oHpiHandlerIdT *id ) { SaErrorT error = SA_OK; @@ -88,7 +89,8 @@ * * Returns: SA_OK on success. Minus SA_OK on error. **/ -SaErrorT oHpiHandlerDestroy(oHpiHandlerIdT id) +SaErrorT SAHPI_API oHpiHandlerDestroy ( + SAHPI_IN oHpiHandlerIdT id ) { if (!id) return SA_ERR_HPI_INVALID_PARAMS; @@ -115,9 +117,10 @@ { g_hash_table_insert ( newhash, g_strdup(key), g_strdup(value) ); } -SaErrorT oHpiHandlerInfo( oHpiHandlerIdT id, - oHpiHandlerInfoT *info, - GHashTable **conf_params ) //will be allocated +SaErrorT SAHPI_API oHpiHandlerInfo ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_OUT oHpiHandlerInfoT *info, + SAHPI_OUT GHashTable **conf_params ) //hash table will be allocated { struct oh_handler *h = NULL; @@ -168,7 +171,9 @@ * * Returns: SA_OK on success. Minus SA_OK on error. **/ -SaErrorT oHpiHandlerGetNext(oHpiHandlerIdT id, oHpiHandlerIdT *next_id) +SaErrorT SAHPI_API oHpiHandlerGetNext ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_OUT oHpiHandlerIdT *next_id ) { if (!next_id) { err("Invalid parameters."); @@ -195,9 +200,10 @@ * * Returns: SA_OK if handler was found. **/ -SaErrorT oHpiHandlerFind(SaHpiSessionIdT sid, - SaHpiResourceIdT rid, - oHpiHandlerIdT *id) +SaErrorT SAHPI_API oHpiHandlerFind ( + SAHPI_IN SaHpiSessionIdT sid, + SAHPI_IN SaHpiResourceIdT rid, + SAHPI_OUT oHpiHandlerIdT *id ) { SaHpiDomainIdT did; struct oh_domain *d = NULL; @@ -234,7 +240,8 @@ * * Returns: SA_OK if handler opens successfully. **/ -SaErrorT oHpiHandlerRetry(oHpiHandlerIdT id) +SaErrorT SAHPI_API oHpiHandlerRetry ( + SAHPI_IN oHpiHandlerIdT id ) { struct oh_handler *h = NULL; SaErrorT error = SA_OK; @@ -270,7 +277,8 @@ * * Returns: SA_OK on success. Minus SA_OK on error. **/ -SaErrorT oHpiGlobalParamGet(oHpiGlobalParamT *param) +SaErrorT SAHPI_API oHpiGlobalParamGet ( + SAHPI_OUT oHpiGlobalParamT *param ) { struct oh_global_param p; @@ -300,7 +308,8 @@ * * Returns: SA_OK on success. Minus SA_OK on error. **/ -SaErrorT oHpiGlobalParamSet(oHpiGlobalParamT *param) +SaErrorT SAHPI_API oHpiGlobalParamSet ( + SAHPI_IN oHpiGlobalParamT *param ) { struct oh_global_param p; @@ -339,10 +348,11 @@ * and Entity will be assigned. This will also be reflected in the passed @rdrs * list so that the caller can know what the assigned values were. **/ -SaErrorT oHpiInjectEvent(oHpiHandlerIdT id, - SaHpiEventT *event, - SaHpiRptEntryT *rpte, - SaHpiRdrT *rdr) +SaErrorT SAHPI_API oHpiInjectEvent ( + SAHPI_IN oHpiHandlerIdT id, + SAHPI_IN SaHpiEventT *event, + SAHPI_IN SaHpiRptEntryT *rpte, + SAHPI_IN SaHpiRdrT *rdr) { SaErrorT (*inject_event)(void *hnd, SaHpiEventT *evt, @@ -388,9 +398,10 @@ * * Currently only available in client library, but not in daemon **/ -SaErrorT SAHPI_API oHpiDomainAdd(const SaHpiTextBufferT *host, - SaHpiUint16T port, - SaHpiDomainIdT *domain_id) +SaErrorT SAHPI_API oHpiDomainAdd ( + SAHPI_IN const SaHpiTextBufferT *host, + SAHPI_IN SaHpiUint16T port, + SAHPI_OUT SaHpiDomainIdT *domain_id ) { return SA_ERR_HPI_UNSUPPORTED_API; } @@ -406,9 +417,10 @@ * * Currently only available in client library, but not in daemon **/ -SaErrorT SAHPI_API oHpiDomainAddById(SaHpiDomainIdT domain_id, - const SaHpiTextBufferT *host, - SaHpiUint16T port) +SaErrorT SAHPI_API oHpiDomainAddById ( + SAHPI_IN SaHpiDomainIdT domain_id, + SAHPI_IN const SaHpiTextBufferT *host, + SAHPI_IN SaHpiUint16T port ) { return SA_ERR_HPI_UNSUPPORTED_API; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-10-12 13:38:14
|
Revision: 7149 http://openhpi.svn.sourceforge.net/openhpi/?rev=7149&view=rev Author: ulikleber Date: 2010-10-12 13:38:06 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Implements Feature Request 3085861: Provide Clients using oHpi functions Modified Paths: -------------- openhpi/trunk/clients/Makefile.am openhpi/trunk/docs/man/Makefile.am openhpi/trunk/docs/man/hpi_shell.pod.1 openhpi/trunk/docs/man/hpialarms.pod.1 openhpi/trunk/docs/man/hpidomain.pod.1 openhpi/trunk/docs/man/hpiel.pod.1 openhpi/trunk/docs/man/hpievents.pod.1 openhpi/trunk/docs/man/hpifan.pod.1 openhpi/trunk/docs/man/hpigensimdata.pod.1 openhpi/trunk/docs/man/hpiinv.pod.1 openhpi/trunk/docs/man/hpionIBMblade.pod.1 openhpi/trunk/docs/man/hpipower.pod.1 openhpi/trunk/docs/man/hpireset.pod.1 openhpi/trunk/docs/man/hpisensor.pod.1 openhpi/trunk/docs/man/hpisettime.pod.1 openhpi/trunk/docs/man/hpithres.pod.1 openhpi/trunk/docs/man/hpitop.pod.1 openhpi/trunk/docs/man/hpitree.pod.1 openhpi/trunk/docs/man/hpiwdt.pod.1 Added Paths: ----------- openhpi/trunk/clients/ohhandler.c openhpi/trunk/clients/ohparam.c openhpi/trunk/docs/man/ohhandler.pod.1 openhpi/trunk/docs/man/ohparam.pod.1 Modified: openhpi/trunk/clients/Makefile.am =================================================================== --- openhpi/trunk/clients/Makefile.am 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/clients/Makefile.am 2010-10-12 13:38:06 UTC (rev 7149) @@ -27,7 +27,9 @@ hpithres \ hpitop \ hpisettime \ - hpionIBMblade + hpionIBMblade \ + ohhandler \ + ohparam include_HEADERS = @@ -79,6 +81,12 @@ hpionIBMblade_SOURCES = hpionIBMblade.c $(CLIENTS_SRC) hpionIBMblade_LDADD = $(COMMONLIBS) +ohhandler_SOURCES = ohhandler.c $(CLIENTS_SRC) +ohhandler_LDADD = $(COMMONLIBS) + +ohparam_SOURCES = ohparam.c $(CLIENTS_SRC) +ohparam_LDADD = $(COMMONLIBS) + clean-local: rm -f *~ *.o Added: openhpi/trunk/clients/ohhandler.c =================================================================== --- openhpi/trunk/clients/ohhandler.c (rev 0) +++ openhpi/trunk/clients/ohhandler.c 2010-10-12 13:38:06 UTC (rev 7149) @@ -0,0 +1,515 @@ +/* -*- linux-c -*- + * + * Copyright (C) Copyright Nokia Siemens Networks 2010 + * + * This program 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. This + * file and program are licensed under a BSD style license. See + * the Copying file included with the OpenHPI distribution for + * full licensing terms. + * + * Authors: + * Ulrich Kleber <uli...@us...> + * + * Log: + * Start from hpidomain.c + * This routine controls the handlers loaded by OpenHPI daemons + * using the OpenHPI extensions as described in ohpi.c + * + * Changes: + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <getopt.h> +#include <uuid/uuid.h> +#include <SaHpi.h> +#include <oh_utils.h> +#include <oh_clients.h> +#include <oHpi.h> + +#define OH_SVN_REV "$Revision: 7133 $" + +/********************************************/ +/* Function prototypes */ +/********************************************/ +static SaErrorT exechandlercreate(int, char **, int); +static SaErrorT exechandlerdestroy(oHpiHandlerIdT); +static SaErrorT exechandlerinfo(oHpiHandlerIdT); +static SaErrorT exechandlergetnext(oHpiHandlerIdT); +static SaErrorT exechandlerfind(SaHpiResourceIdT); +static SaErrorT exechandlerretry(oHpiHandlerIdT); +static SaErrorT exechandlerlist(void); + + +/********************************************/ +/* Globals */ +/********************************************/ +int fdebug = 0; +SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; +SaHpiSessionIdT sessionid; + + +/********************************************/ +/* Main */ +/********************************************/ +int +main(int argc, char **argv) +{ + SaErrorT rv = SA_OK; + + oHpiHandlerIdT handlerid = 0; + SaHpiResourceIdT resid = 0; + SaHpiBoolT printusage = FALSE; + int i=1; + + enum cmdT {eUndefined, + eHandlerCreate, + eHandlerDestroy, + eHandlerInfo, + eHandlerGetNext, + eHandlerFind, + eHandlerRetry, + eHandlerList} cmd=eUndefined; + + oh_prog_version(argv[0], OH_SVN_REV); + + while (i<argc && !printusage && cmd!=eHandlerCreate) { + if (strcmp(argv[i],"-D")==0) { + if (++i<argc) domainid = atoi(argv[i]); + else printusage = TRUE; + } + else if (strcmp(argv[i],"-x")==0) fdebug=1; + + else if (strcmp(argv[i],"create")==0) { + cmd=eHandlerCreate; + // exechandlercreate will do the remaining reading of + // parameters itself + rv = exechandlercreate (argc, argv, ++i); + if (rv == SA_OK) exit (0); + if (rv != SA_ERR_HPI_INVALID_PARAMS) exit (1); + printusage = TRUE; + } + + else if (strcmp(argv[i],"destroy")==0) { + cmd=eHandlerDestroy; + if (++i<argc) handlerid = atoi(argv[i]); + else printusage = TRUE; + } + + else if (strcmp(argv[i],"info")==0) { + cmd=eHandlerInfo; + if (++i<argc) handlerid = atoi(argv[i]); + else printusage = TRUE; + } + + else if (strcmp(argv[i],"getnext")==0) { + cmd=eHandlerGetNext; + if (++i<argc) handlerid = atoi(argv[i]); + else printusage = TRUE; + } + + else if (strcmp(argv[i],"find")==0) { + cmd=eHandlerFind; + if (++i<argc) resid = atoi(argv[i]); + else printusage = TRUE; + } + + else if (strcmp(argv[i],"retry")==0) { + cmd=eHandlerRetry; + if (++i<argc) handlerid = atoi(argv[i]); + else printusage = TRUE; + } + + else if (strcmp(argv[i],"list")==0) { + cmd=eHandlerList; + if (++i<argc) printusage = TRUE; + } + + else printusage = TRUE; + + i++; + } + + if (cmd == eHandlerCreate) { + rv = exechandlercreate (argc, argv, i); + if (rv == SA_OK) exit (0); + if (rv == SA_ERR_HPI_INVALID_PARAMS) + printusage = TRUE; + else exit (1); + } + + if (printusage == TRUE || cmd == eUndefined) + { + printf("\n"); + printf("Usage: %s [-D domain] [-x] command [specific arguments]\n\n", + argv[0]); + printf(" -D nn Select domain id nn (not supported yet by oh-functions)\n"); + printf(" -x Display debug messages\n"); + printf("\n"); + printf(" ohhander [-D domain] [-x] list\n"); + printf(" List the handlers loaded in specified domain\n\n"); + printf(" ohhander [-D domain] [-x] info <handler-id>\n"); + printf(" Display info about handler <handler-id> \n\n"); + printf(" ohhander [-D domain] [-x] destroy <handler-id>\n"); + printf(" Unload handler <handler-id> and delete its config \n\n"); + printf(" ohhander [-D domain] [-x] getnext <handler-id>\n"); + printf(" Find next valid handler id from <handler-id> \n\n"); + printf(" ohhander [-D domain] [-x] find <resource-id>\n"); + printf(" Find the right handler for a resource id \n\n"); + printf(" ohhander [-D domain] [-x] retry <handler-id>\n"); + printf(" Retry loading of handler <handler-id> \n\n"); + printf(" ohhander [-D domain] [-x] create plugin <name> <params>\n"); + printf(" Create handler with the specified parameters.\n"); + printf(" Pairs of strings in commandline like in openhpi.conf.\n"); + printf(" Keyword plugin to select type of handler.\n"); + printf(" Entity root and other complex strings must be \n"); + printf(" enclosed in \".\n"); + printf(" example:\n"); + printf(" ohhandler create plugin libsimulator " + "entity_root \"{SYSTEM_CHASSIS,1}\" name sim\n"); + + printf("\n\n"); + exit(1); + } + + if (fdebug) { + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("saHpiSessionOpen\n"); + else printf("saHpiSessionOpen to domain %d\n",domainid); + } + rv = saHpiSessionOpen(domainid,&sessionid,NULL); + if (rv != SA_OK) { + printf("saHpiSessionOpen returns %d (%s)\n", + rv, oh_lookup_error(rv)); + exit(-1); + } + if (fdebug) + printf("saHpiSessionOpen returns with SessionId %d\n", + sessionid); + + switch (cmd){ + case eHandlerCreate: break; //already done + case eHandlerDestroy: + exechandlerdestroy ( handlerid ); + break; + case eHandlerInfo: + exechandlerinfo ( handlerid ); + break; + case eHandlerGetNext: + exechandlergetnext ( handlerid ); + break; + case eHandlerFind: + exechandlerfind ( resid ); + break; + case eHandlerRetry: + exechandlerretry ( handlerid ); + break; + case eHandlerList: + exechandlerlist ( ); + break; + case eUndefined: break; //already done + } + + rv = saHpiSessionClose(sessionid); + + exit(0); +} + +/********************************************/ +/* exechandlercreate */ +/********************************************/ +static SaErrorT exechandlercreate (int argc, char **argv, int i) +{ + SaErrorT rv = SA_OK; + oHpiHandlerIdT handlerid = 0; + GHashTable * createparams = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, g_free); + SaHpiBoolT pluginnamegiven = SAHPI_FALSE; + + if (fdebug) printf ("createhandler started\n"); + + while (i<argc){ + if (strcmp(argv[i],"-f")==0) { + printf("input from file not implemented yet\n"); + return (SA_OK); + } + else if (++i<argc) { + if (strcmp(argv[i-1],"plugin")==0) pluginnamegiven = SAHPI_TRUE; + g_hash_table_insert( createparams, + g_strdup( argv[i-1] ), + g_strdup( argv[i] )); + if (fdebug) printf ("Pair of arguments: %s - %s\n", + g_strdup( argv[i-1] ), + g_strdup( argv[i] )); + } + else // parameters not in pairs + return (SA_ERR_HPI_INVALID_PARAMS); + i++; + } + + if (!pluginnamegiven) { + printf("You must enter a valid plugin name\n"); + return (SA_ERR_HPI_INVALID_PARAMS); + } + + if (fdebug) { + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("saHpiSessionOpen\n"); + else printf("saHpiSessionOpen to domain %d\n",domainid); + } + rv = saHpiSessionOpen(domainid,&sessionid,NULL); + if (rv != SA_OK) { + printf("saHpiSessionOpen returns %d (%s)\n", + rv, oh_lookup_error(rv)); + return (SA_ERR_HPI_INVALID_PARAMS); + } + if (fdebug) + printf("saHpiSessionOpen returns with SessionId %d\n", + sessionid); + + if (fdebug) printf ("Calling oHpiHandlerCreate!\n"); + rv = oHpiHandlerCreate(createparams, &handlerid ); + + if ( rv != SA_OK ) { + printf("oHpiHandlerCreate returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return(rv); + } + + printf("Handler %d successfully created!\n", handlerid); + + rv = saHpiSessionClose(sessionid); + + return(SA_OK); + +} + +/********************************************/ +/* exechandlerdestroy */ +/********************************************/ +static SaErrorT exechandlerdestroy(oHpiHandlerIdT handlerid) +{ + SaErrorT rv = SA_OK; + if (fdebug) printf("Go and unload handler %d in domain %d\n", + handlerid, domainid); + + rv = oHpiHandlerDestroy ( handlerid ); + + if (fdebug) printf("oHpiHandlerDestroy returned %d (%s)\n", + rv, oh_lookup_error(rv)); + + if (rv==SA_OK) { + printf("Handler %d successfully unloaded.\n\n", handlerid); + return rv; + } + else if (rv==SA_ERR_HPI_NOT_PRESENT) { + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("Handler %d is not existing in default domain.\n", + handlerid); + else printf("Handler %d is not existing in domain %d.\n", + handlerid, domainid); + return rv; + } + else printf("\nHandler %d couldn't be unloaded, Returncode %d (%s)\n", + handlerid, rv, oh_lookup_error(rv)); + return rv; +} + +/********************************************/ +/* exechandlerinfo */ +/********************************************/ +// function to print from hash table +static void print_pair (gpointer key, gpointer value, gpointer user_data) +{ + printf (" %s %s\n ", (gchar *)key, (gchar *)value); +} + +static +SaErrorT exechandlerinfo(oHpiHandlerIdT handlerid) +{ + oHpiHandlerInfoT handlerinfo; + SaErrorT rv = SA_OK; + GHashTable *handlerconfig = g_hash_table_new_full( + g_str_hash, g_str_equal, + g_free, g_free ); + + + if (fdebug) printf("Go and display handler info for %d\n", handlerid); + + rv = oHpiHandlerInfo ( /* sessionid,*/ handlerid, &handlerinfo, &handlerconfig ); + + if (rv==SA_ERR_HPI_NOT_PRESENT) { + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("Handler %d is not existing in default domain.\n", + handlerid); + else printf("Handler %d is not existing in domain %d.\n", + handlerid, domainid); + g_hash_table_destroy(handlerconfig); + return SA_OK; + } + else if (rv!=SA_OK) { + printf("oHpiHandlerInfo returned %d (%s)\n", + rv, oh_lookup_error(rv)); + g_hash_table_destroy(handlerconfig); + return rv; + } + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("\n\nInfo for handler %d in default domain:\n\n",handlerid); + else printf("\n\nInfo for handler %d in domain %d:\n\n",handlerid, domainid); + printf("Plugin name: %s\n",handlerinfo.plugin_name); + + printf("Root Entity Path: "); + oh_print_ep (&(handlerinfo.entity_root),0); + + printf("Failed attempts to load handler: %d\n",handlerinfo.load_failed); + + printf("Handler configuration:\n"); + g_hash_table_foreach(handlerconfig, print_pair, NULL); + printf("\n"); + + g_hash_table_destroy(handlerconfig); + return rv; +} + +/********************************************/ +/* exechandlergetnext */ +/********************************************/ +static SaErrorT exechandlergetnext(oHpiHandlerIdT handlerid) +{ + SaErrorT rv = SA_OK; + oHpiHandlerIdT nexthandlerid; + + if (fdebug) printf("Go and get next handler from %d in domain %d\n", + handlerid, domainid); + + rv = oHpiHandlerGetNext ( handlerid, &nexthandlerid ); + + if (fdebug) printf("oHpiHandlerGetNext returned %d (%s)\n", + rv, oh_lookup_error(rv)); + + if (rv==SA_OK) { + printf("Next Handler found from %d is %d.\n\n", + handlerid, nexthandlerid); + } + else if (rv==SA_ERR_HPI_NOT_PRESENT) { + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("No next Handler found from %d in default domain.\n", + handlerid); + else printf("No next Handler found from %d in domain %d.\n", + handlerid, domainid); + } + else printf("\noHpiHandlerGetNext returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; +} + +/********************************************/ +/* exechandlerfind */ +/********************************************/ +static SaErrorT exechandlerfind(SaHpiResourceIdT resid) +{ + SaErrorT rv = SA_OK; + oHpiHandlerIdT handlerid; + + if (fdebug) printf("Go and find handler for resource %d in domain " + "%d using session %d\n", + resid, domainid, sessionid); + + rv = oHpiHandlerFind ( sessionid, resid, &handlerid ); + + if (fdebug) printf("oHpiHandlerFind returned %d (%s)\n", + rv, oh_lookup_error(rv)); + + if (rv==SA_OK) { + printf("Handler found for resource %d: Handler-id %d.\n\n", + resid, handlerid); + } + else if (rv==SA_ERR_HPI_NOT_PRESENT) { + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("No Handler found for resource %d in default domain.\n", + resid); + else printf("No Handler found for resource %d in domain %d.\n", + resid, domainid); + } + else printf("\noHpiHandlerFind returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; +} + +/********************************************/ +/* exechandlerretry */ +/********************************************/ +static SaErrorT exechandlerretry(oHpiHandlerIdT handlerid) +{ + SaErrorT rv = SA_OK; + + if (fdebug) printf("Go and retry loading handler %d in domain %d\n", + handlerid, domainid); + + rv = oHpiHandlerRetry ( handlerid ); + + if (rv!=SA_OK) { + printf("oHpiHandlerRetry returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("\nHandler %d in default domain successfully re-loaded.\n", + handlerid); + else printf("\nHandler %d in domain %d successfully re-loaded.\n", + handlerid, domainid); + return rv; +} + +/********************************************/ +/* exechandlerlist */ +/********************************************/ +static SaErrorT exechandlerlist() +{ + SaErrorT rv = SA_OK; + oHpiHandlerIdT handlerid = 0; + oHpiHandlerIdT nexthandlerid; + oHpiHandlerInfoT handlerinfo; + GHashTable *config = 0; + + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("Handlers defined in default domain:\n"); + else printf("Handlers defined in Domain %d:\n",domainid); + while (rv==SA_OK) { + rv = oHpiHandlerGetNext ( handlerid, &nexthandlerid ); + + if (fdebug) printf("oHpiHandlerGetNext (%d) returned %d (%s)\n", + handlerid, rv, oh_lookup_error(rv)); + + if (rv==SA_OK) { + //display info for that handler + rv = oHpiHandlerInfo ( /* sessionid, */ nexthandlerid, &handlerinfo, &config ); + if (rv!=SA_OK) { + printf("oHpiHandlerInfo for handler %d returned %d (%s)\n", + nexthandlerid, rv, oh_lookup_error(rv)); + rv = SA_OK; + } + else { + printf("Handler %d: %s, ", + nexthandlerid, handlerinfo.plugin_name); + oh_print_ep (&(handlerinfo.entity_root),0); + // g_hash_table_destroy(config); + } + } + else if (rv!=SA_ERR_HPI_NOT_PRESENT) { + printf("Error: oHpiHandlerGetNext (%d) returned %d (%s)\n", + handlerid, rv, oh_lookup_error(rv)); + } + handlerid = nexthandlerid; + } + printf("\n"); + if (rv==SA_ERR_HPI_NOT_PRESENT) return SA_OK; + return rv; +} + +/* end ohhandler.c */ Added: openhpi/trunk/clients/ohparam.c =================================================================== --- openhpi/trunk/clients/ohparam.c (rev 0) +++ openhpi/trunk/clients/ohparam.c 2010-10-12 13:38:06 UTC (rev 7149) @@ -0,0 +1,384 @@ +/* -*- linux-c -*- + * + * Copyright (C) Copyright Nokia Siemens Networks 2010 + * + * This program 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. This + * file and program are licensed under a BSD style license. See + * the Copying file included with the OpenHPI distribution for + * full licensing terms. + * + * Authors: + * Ulrich Kleber <uli...@us...> + * + * Log: + * Start from hpidomain.c + * This routine can display and manipulate parameters of the + * openHPI daemon as specified in openhpi.conf file, using + * the OpenHPI extensions as described in ohpi.c + * + * Changes: + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <getopt.h> +#include <uuid/uuid.h> +#include <SaHpi.h> +#include <oh_utils.h> +#include <oh_clients.h> +#include <oHpi.h> + +#define OH_SVN_REV "$Revision: 7142 $" + +/* + * Function prototypes + */ +static SaErrorT execglobalparamget (void); +static SaErrorT execglobalparamset (oHpiGlobalParamTypeT,char *); + + +/* + * Globals + */ +int fdebug = 0; +SaHpiDomainIdT domainid = SAHPI_UNSPECIFIED_DOMAIN_ID; +SaHpiSessionIdT sessionid; + + +/* + * Main + */ +int +main(int argc, char **argv) +{ + SaErrorT rv = SA_OK; + + oHpiGlobalParamTypeT paramtype = OHPI_CONF; + char setparam[OH_MAX_TEXT_BUFFER_LENGTH]; + SaHpiBoolT printusage = FALSE; + int i=1; + + enum cmdT {eUndefined, + eGlobalParamGet, + eGlobalParamSet} cmd=eUndefined; + + oh_prog_version(argv[0], OH_SVN_REV); + + while (i<argc && !printusage) { + if (strcmp(argv[i],"-D")==0) { + if (++i<argc) domainid = atoi(argv[i]); + else printusage = TRUE; + } + else if (strcmp(argv[i],"-x")==0) fdebug=1; + else if (strcmp(argv[i],"get")==0) { + cmd=eGlobalParamGet; + } + else if (strcmp(argv[i],"set")==0) { + cmd=eGlobalParamSet; + if (++i<argc) { + if (strcmp(argv[i],"OPENHPI_ON_EP")==0) + paramtype=OHPI_ON_EP; + else if (strcmp(argv[i],"OPENHPI_LOG_ON_SEV")==0) + paramtype=OHPI_LOG_ON_SEV; + else if (strcmp(argv[i],"OPENHPI_EVT_QUEUE_LIMIT")==0) + paramtype=OHPI_EVT_QUEUE_LIMIT; + else if (strcmp(argv[i],"OPENHPI_DEL_SIZE_LIMIT")==0) + paramtype=OHPI_DEL_SIZE_LIMIT; + else if (strcmp(argv[i],"OPENHPI_DEL_SAVE")==0) + paramtype=OHPI_DEL_SAVE; + else if (strcmp(argv[i],"OPENHPI_DAT_SIZE_LIMIT")==0) + paramtype=OHPI_DAT_SIZE_LIMIT; + else if (strcmp(argv[i],"OPENHPI_DAT_USER_LIMIT")==0) + paramtype=OHPI_DAT_USER_LIMIT; + else if (strcmp(argv[i],"OPENHPI_DAT_SAVE")==0) + paramtype=OHPI_DAT_SAVE; + else if (strcmp(argv[i],"OPENHPI_PATH")==0) + paramtype=OHPI_PATH; + else if (strcmp(argv[i],"OPENHPI_VARPATH")==0) + paramtype=OHPI_VARPATH; + else if (strcmp(argv[i],"OPENHPI_CONF")==0) + paramtype=OHPI_CONF; + else printusage = TRUE; + } + else printusage = TRUE; + + if (++i<argc) strcpy(setparam, argv[i]); + + else if (i>=argc) printusage = TRUE; + } + + else printusage = TRUE; + i++; + } + + if (printusage == TRUE || cmd == eUndefined) + { + printf("\n"); + printf("Usage: %s [-D domain] [-x] command [specific arguments]\n\n", + argv[0]); + printf(" -D nn Select domain id nn (not supported yet by oh-functions)\n"); + printf(" -x Display debug messages\n"); + printf("\n"); + printf(" Command get: display info about all global parameters\n"); + printf(" no specific arguments\n"); + printf(" Command set:\n"); + printf(" one of the daemon's global parameters:\n"); + printf(" (without the OPENHPI prefix)\n"); + printf(" ON_EP, LOG_ON_SEV, EVT_QUEUE_LIMIT, \n"); + printf(" DEL_SIZE_LIMIT, DEL_SAVE\n"); + printf(" DAT_SIZE_LIMIT, DAT_USER_LIMIT, DAT_SAVE\n"); + printf(" PATH, VARPATH, CONF\n"); + printf(" and the desired new value. Example:\n"); + printf(" ohparam set DEL_SIZE_LIMIT 20000\n"); + printf("\n\n"); + exit(1); + } + + if (fdebug) { + if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) + printf("saHpiSessionOpen\n"); + else printf("saHpiSessionOpen to domain %d\n",domainid); + } + rv = saHpiSessionOpen(domainid,&sessionid,NULL); + if (rv != SA_OK) { + printf("saHpiSessionOpen returns %d (%s)\n", + rv, oh_lookup_error(rv)); + exit(-1); + } + if (fdebug) + printf("saHpiSessionOpen returns with SessionId %d\n", + sessionid); + + switch (cmd){ + case eGlobalParamGet: + rv = execglobalparamget ( ); + break; + case eGlobalParamSet: + rv = execglobalparamset ( paramtype, setparam ); + break; + default: + printf("\n\nSorry, this function is not implemented yet\n\n"); + rv = SA_ERR_HPI_INVALID_PARAMS; + } + + if (rv == SA_OK) { + rv = saHpiSessionClose(sessionid); + exit(0); + } + printf("Param set failed with returncode %d (%s)\n", + rv, oh_lookup_error(rv)); + exit(-1); + +} + +/* + * + */ +static SaErrorT execglobalparamget () +{ + SaErrorT rv = SA_OK; + oHpiGlobalParamT param; + + if (fdebug) printf("Go and read global parameters in domain %d\n", domainid); + + param.Type = OHPI_ON_EP; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_ON_EP) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_ON_EP: "); + oh_print_ep (&(param.u.OnEP),0); + + param.Type = OHPI_LOG_ON_SEV; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_LOG_ON_SEV) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_LOG_ON_SEV = %s\n", oh_lookup_severity (param.u.LogOnSev)); + + param.Type =OHPI_EVT_QUEUE_LIMIT; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_EVT_QUEUE_LIMIT) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_EVT_QUEUE_LIMIT = %d\n", param.u.EvtQueueLimit); + + param.Type =OHPI_DEL_SIZE_LIMIT; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_DEL_SIZE_LIMIT) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_DEL_SIZE_LIMIT = %d\n", param.u.DelSizeLimit); + + param.Type =OHPI_DEL_SAVE; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_DEL_SAVE) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_DEL_SAVE = "); + if (param.u.DelSave) printf("TRUE\n"); + else printf("FALSE\n"); + + param.Type =OHPI_DAT_SIZE_LIMIT; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_DAT_SIZE_LIMIT) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_DAT_SIZE_LIMIT = %d\n", param.u.DatSizeLimit); + + param.Type =OHPI_DAT_USER_LIMIT; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_DAT_USER_LIMIT) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_DAT_USER_LIMIT = %d\n", param.u.DatUserLimit); + + param.Type =OHPI_DAT_SAVE; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_DAT_SAVE) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_DAT_SAVE = "); + if (param.u.DatSave) printf("TRUE\n"); + else printf("FALSE\n"); + + param.Type =OHPI_PATH; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_PATH) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_PATH = %s\n",param.u.Path); + + param.Type =OHPI_VARPATH; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_VARPATH) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_VARPATH = %s\n",param.u.VarPath); + + param.Type =OHPI_CONF; + rv = oHpiGlobalParamGet (¶m); + if (rv!=SA_OK) { + printf("oHpiGlobalParamGet(OHPI_CONF) returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + printf("OPENHPI_CONF = %s\n",param.u.Conf); + + return SA_OK; +} + +/* + * + */ +static SaErrorT execglobalparamset (oHpiGlobalParamTypeT ptype, char *setparam) +{ + SaErrorT rv = SA_OK; + oHpiGlobalParamT param; + SaHpiTextBufferT buffer; + + if (fdebug) printf("Go and set global parameter %d in domain %d to %s\n", ptype, domainid, setparam); + + param.Type = ptype; + switch (ptype){ + //strings + case OHPI_PATH: strcpy(param.u.Path, setparam);break; + case OHPI_VARPATH: strcpy(param.u.VarPath, setparam);break; + case OHPI_CONF: strcpy(param.u.Conf, setparam);break; + //ep + case OHPI_ON_EP: + if (oh_encode_entitypath(setparam,¶m.u.OnEP)!=SA_OK) + return SA_ERR_HPI_INVALID_PARAMS; + break; + //severity + case OHPI_LOG_ON_SEV: + strncpy((char *)buffer.Data, setparam, SAHPI_MAX_TEXT_BUFFER_LENGTH); + if (oh_encode_severity(&buffer, ¶m.u.LogOnSev)!=SA_OK) + return SA_ERR_HPI_INVALID_PARAMS; + break; + //integers + case OHPI_EVT_QUEUE_LIMIT: param.u.EvtQueueLimit = atoi(setparam);break; + case OHPI_DEL_SIZE_LIMIT: param.u.DelSizeLimit = atoi(setparam);break; + case OHPI_DAT_SIZE_LIMIT: param.u.DatSizeLimit = atoi(setparam);break; + case OHPI_DAT_USER_LIMIT: param.u.DatUserLimit = atoi(setparam);break; + //bools + case OHPI_DEL_SAVE: + if (strcmp(setparam,"TRUE")==0) param.u.DelSave = SAHPI_TRUE; + else if (strcmp(setparam,"FALSE")==0) param.u.DelSave = SAHPI_FALSE; + else return SA_ERR_HPI_INVALID_PARAMS; + break; + case OHPI_DAT_SAVE: + if (strcmp(setparam,"TRUE")==0) param.u.DatSave = SAHPI_TRUE; + else if (strcmp(setparam,"FALSE")==0) param.u.DatSave = SAHPI_FALSE; + else return SA_ERR_HPI_INVALID_PARAMS; + break; + } + rv = oHpiGlobalParamSet (¶m); + + if (rv!=SA_OK) { + printf("oHpiGlobalParamSet returned %d (%s)\n", + rv, oh_lookup_error(rv)); + return rv; + } + + switch (param.Type){ + case OHPI_ON_EP: printf("OPENHPI_ON_EP: "); + oh_print_ep (&(param.u.OnEP),0); + break; + case OHPI_LOG_ON_SEV: printf("OPENHPI_LOG_ON_SEV = %s\n", + oh_lookup_severity (param.u.LogOnSev)); + break; + case OHPI_EVT_QUEUE_LIMIT: printf("OPENHPI_EVT_QUEUE_LIMIT = %d\n", + param.u.EvtQueueLimit); + break; + case OHPI_DEL_SIZE_LIMIT: printf("OPENHPI_DEL_SIZE_LIMIT = %d\n", + param.u.DelSizeLimit); + break; + case OHPI_DEL_SAVE: printf("OPENHPI_DEL_SAVE = "); + if (param.u.DelSave) printf("TRUE\n"); + else printf("FALSE\n"); + break; + case OHPI_DAT_SIZE_LIMIT: printf("OPENHPI_DAT_SIZE_LIMIT = %d\n", + param.u.DatSizeLimit); + break; + case OHPI_DAT_USER_LIMIT: printf("OPENHPI_DAT_USER_LIMIT = %d\n", + param.u.DatUserLimit); + break; + case OHPI_DAT_SAVE: printf("OPENHPI_DAT_SAVE = "); + if (param.u.DatSave) printf("TRUE\n"); + else printf("FALSE\n"); + break; + case OHPI_PATH: printf("OHPENPI_PATH = %s\n",param.u.Path);break; + case OHPI_VARPATH: printf("OPENHPI_VARPATH = %s\n",param.u.VarPath);break; + case OHPI_CONF: printf("OPENHPI_CONF = %s\n",param.u.Conf);break; + } + return SA_OK; + +} + +/* end ohparam.c */ Modified: openhpi/trunk/docs/man/Makefile.am =================================================================== --- openhpi/trunk/docs/man/Makefile.am 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/Makefile.am 2010-10-12 13:38:06 UTC (rev 7149) @@ -38,6 +38,7 @@ hpievents.pod.1 hpionIBMblade.pod.1 \ hpisensor.pod.1 hpitop.pod.1 \ hpidomain.pod.1 hpigensimdata.pod.1 \ + ohhandler.pod.1 ohparam.pod.1 \ hpi_shell.pod.1 @@ -71,6 +72,7 @@ hpievents.1 hpionIBMblade.1 \ hpisensor.1 hpitop.1 \ hpidomain.1 hpigensimdata.1 \ + ohhandler.1 ohparam.1 \ hpi_shell.1 clean-local: am_config_clean-local Modified: openhpi/trunk/docs/man/hpi_shell.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpi_shell.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpi_shell.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -31,11 +31,13 @@ =head1 SEE ALSO - hpi_shell hpifan hpipower hpithres - hpialarms hpiinv hpireset hpitop - hpiel hpijs hpisensor hpitree + hpialarms hpifan hpipower hpithres + hpidomain hpigensimdata hpireset hpitop + hpiel hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt + ohhandler ohparam + =head1 AUTHORS Author(s) of this man page: Modified: openhpi/trunk/docs/man/hpialarms.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpialarms.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpialarms.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -62,6 +62,7 @@ hpiel hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt hpifan hpipower hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpidomain.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpidomain.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpidomain.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -31,8 +31,10 @@ hpiel hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt hpifan hpipower hpithres + ohhandler ohparam + =head1 AUTHORS Authors of this man page: Modified: openhpi/trunk/docs/man/hpiel.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiel.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpiel.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -70,6 +70,7 @@ hpidomain hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt hpifan hpipower hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpievents.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpievents.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpievents.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -55,6 +55,7 @@ hpidomain hpiinv hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpifan hpipower hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpifan.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpifan.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpifan.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -31,6 +31,7 @@ hpidomain hpiinv hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpievents hpipower hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpigensimdata.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpigensimdata.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpigensimdata.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -33,6 +33,7 @@ hpidomain hpiinv hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpievents hpipower hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpiinv.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiinv.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpiinv.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -42,6 +42,7 @@ hpidomain hpigensimdata hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpievents hpipower hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpionIBMblade.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpionIBMblade.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpionIBMblade.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -55,6 +55,7 @@ hpidomain hpigensimdata hpisensor hpitree hpiel hpiiinv hpisettime hpiwdt hpievents hpipower hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpipower.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpipower.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpipower.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -34,6 +34,7 @@ hpidomain hpigensimdata hpisensor hpitree hpiel hpiiinv hpisettime hpiwdt hpievents hpionIBMblade hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpireset.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpireset.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpireset.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -36,6 +36,7 @@ hpidomain hpigensimdata hpisensor hpitree hpiel hpiiinv hpisettime hpiwdt hpievents hpionIBMblade hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpisensor.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisensor.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpisensor.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -33,6 +33,7 @@ hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisettime hpiwdt hpievents hpionIBMblade hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpisettime.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisettime.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpisettime.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -30,6 +30,7 @@ hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpithres + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpithres.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpithres.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpithres.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -28,6 +28,7 @@ hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpisettime + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpitop.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitop.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpitop.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -39,6 +39,7 @@ hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpisettime + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpitree.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitree.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpitree.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -41,6 +41,7 @@ hpidomain hpigensimdata hpireset hpitop hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpisettime + ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpiwdt.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiwdt.pod.1 2010-10-12 11:00:45 UTC (rev 7148) +++ openhpi/trunk/docs/man/hpiwdt.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -33,6 +33,7 @@ hpidomain hpigensimdata hpireset hpitop hpiel hpiiinv hpisensor hpitree hpievents hpionIBMblade hpisettime + ohhandler ohparam =head1 AUTHORS Added: openhpi/trunk/docs/man/ohhandler.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohhandler.pod.1 (rev 0) +++ openhpi/trunk/docs/man/ohhandler.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -0,0 +1,63 @@ +=head1 NAME + +ohhandler - An openhpi sample application that uses the openhpi additional interfaces to control openhpi configuration. That is plugins can be loaded, plugin instances (handlers) created, unloaded or their configuration displayed. + +=head1 SYNOPSIS + + ohhandler [-D domain] [-x] list + ohhandler [-D domain] [-x] info <handler-id> + ohhandler [-D domain] [-x] destroy <handler-id> + ohhandler [-D domain] [-x] getnext <handler-id> + ohhandler [-D domain] [-x] find <resource-id> + ohhandler [-D domain] [-x] retry <handler-id> + ohhandler [-D domain] [-x] create plugin <plugin-name> <configuration-parameters> + +=head1 DESCRIPTION + +ohhandler list will display a list of all plugin instances (handlers) currently defined in the openhpi daemon for the specified domain. Part of the output is the handler-id that can be used in subsequent commands. + +ohhandler info will display specific info for the handler with the specified id. This information includes all configuration parameters of the handler as specified in the openhpi.conf file or as dynamically defined during a "ohhandler create" call. + +ohhandler destroy will unload the specified handler and delete all its configuration information. + +ohhandler getnext will allows to walk through all hanlers currently defined in the openhpi daemon for the specified domain. + +ohhandler find will find the handler that is managing the specified resource. + +ohhandler retry allows to try again to load and initialize the specified handler. + +ohhandler create allows to dynamically create a new handler with configuration parameters like they are specified in the openhpi.conf file. + - The type of plugin is specified with the keyword plugin + - Configuration parameters should follow as name value pairs + - Complex strings like entity paths must be enclosed with "" + Example: + ohhandler create plugin libsimulator entity_root "{SYSTEM_CHASSIS,1}" name sim + +If no domain is selected, ohhandler uses the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. + +=head1 OPTIONS + +=over 2 + + -D <domainid> select domain id + -x display debug messages. + -h help + +=back + +=head1 SEE ALSO + + hpi_shell + hpialarms hpigensimdata hpireset hpitop + hpidomain hpiinv hpisensor hpitree + hpiel hpionIBMblade hpisettime hpiwdt + hpievents hpipower hpithres + ohparam + + +=head1 AUTHORS + +Authors of this man page: + + Ulrich Kleber (uli...@us...) + Added: openhpi/trunk/docs/man/ohparam.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohparam.pod.1 (rev 0) +++ openhpi/trunk/docs/man/ohparam.pod.1 2010-10-12 13:38:06 UTC (rev 7149) @@ -0,0 +1,43 @@ +=head1 NAME + +ohparam - An openhpi sample application that uses the openhpi additional interface to control openhpi configuration parameters + +=head1 SYNOPSIS + + ohparam [-D domain] [-x] get + ohparam [-D domain] [-x] set <paramname newvalue> + +=head1 DESCRIPTION + +ohparam get will display all global configuration parameters of the openhpi daemon for the specified domain. + +ohparam set will change the given global configuration parameters of the openhpi daemon for the specified domain to the new value. + +If no domain is selected, ohparam uses the default domain. The selected domain id must be configured via the openhpidclient.conf file specified in the environment. + +=head1 OPTIONS + +=over 2 + + -D <domainid> select domain id + -x display debug messages. + -h help + +=back + +=head1 SEE ALSO + + hpi_shell + hpialarms hpigensimdata hpireset hpitop + hpidomain hpiinv hpisensor hpitree + hpiel hpionIBMblade hpisettime hpiwdt + hpievents hpipower hpithres + ohhandler + + +=head1 AUTHORS + +Authors of this man page: + + Ulrich Kleber (uli...@us...) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-10-19 10:05:50
|
Revision: 7150 http://openhpi.svn.sourceforge.net/openhpi/?rev=7150&view=rev Author: ulikleber Date: 2010-10-19 10:05:44 +0000 (Tue, 19 Oct 2010) Log Message: ----------- Fixed usage of hash tables in the implementation of Feature Requests 3074880: ExtendoHpiHandlerInfo for handler params Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/clients/ohhandler.c openhpi/trunk/include/oHpi.h openhpi/trunk/openhpid/ohpi.c openhpi/trunk/openhpid/openhpid.cpp openhpi/trunk/openhpid/t/ohpi/ohpi_009.c Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-10-12 13:38:06 UTC (rev 7149) +++ openhpi/trunk/baselib/oh_client.cpp 2010-10-19 10:05:44 UTC (rev 7150) @@ -5963,7 +5963,7 @@ SaErrorT SAHPI_API oHpiHandlerInfo ( SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerInfoT *info, - SAHPI_OUT GHashTable **conf_params ) //hash table will be allocated + SAHPI_IN GHashTable *conf_params ) { void *request; char reply[dMaxMessageLength]; @@ -5971,9 +5971,6 @@ char cmd[] = "oHpiHandlerInfo"; pcstrmsock pinst = NULL; oHpiHandlerConfigT config; - GHashTable *config_table = g_hash_table_new_full( - g_str_hash, g_str_equal, - g_free, g_free ); err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; @@ -5991,12 +5988,11 @@ &err, info, &config); for (int n = 0; n < config.NumberOfParams; n++) { - g_hash_table_insert(config_table, + g_hash_table_insert(conf_params, g_strdup((const gchar *)config.Params[n].Name), g_strdup((const gchar *)config.Params[n].Value)); } free(config.Params); - *conf_params = config_table; oh_delete_connx(pinst); if (request) Modified: openhpi/trunk/clients/hpionIBMblade.c =================================================================== --- openhpi/trunk/clients/hpionIBMblade.c 2010-10-12 13:38:06 UTC (rev 7149) +++ openhpi/trunk/clients/hpionIBMblade.c 2010-10-19 10:05:44 UTC (rev 7150) @@ -223,7 +223,9 @@ unsigned int i; oHpiHandlerIdT this_handler_id; oHpiHandlerInfoT handler_info; - GHashTable *config = 0; + GHashTable *config = g_hash_table_new_full( + g_str_hash, g_str_equal, + g_free, g_free ); rv = oHpiHandlerFind(sessionid, Rpt->Rpt.ResourceId, Modified: openhpi/trunk/clients/ohhandler.c =================================================================== --- openhpi/trunk/clients/ohhandler.c 2010-10-12 13:38:06 UTC (rev 7149) +++ openhpi/trunk/clients/ohhandler.c 2010-10-19 10:05:44 UTC (rev 7150) @@ -341,7 +341,7 @@ if (fdebug) printf("Go and display handler info for %d\n", handlerid); - rv = oHpiHandlerInfo ( /* sessionid,*/ handlerid, &handlerinfo, &handlerconfig ); + rv = oHpiHandlerInfo ( handlerid, &handlerinfo, handlerconfig ); if (rv==SA_ERR_HPI_NOT_PRESENT) { if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) @@ -488,7 +488,10 @@ if (rv==SA_OK) { //display info for that handler - rv = oHpiHandlerInfo ( /* sessionid, */ nexthandlerid, &handlerinfo, &config ); + config = g_hash_table_new_full( + g_str_hash, g_str_equal, + g_free, g_free ); + rv = oHpiHandlerInfo ( nexthandlerid, &handlerinfo, config ); if (rv!=SA_OK) { printf("oHpiHandlerInfo for handler %d returned %d (%s)\n", nexthandlerid, rv, oh_lookup_error(rv)); @@ -498,8 +501,8 @@ printf("Handler %d: %s, ", nexthandlerid, handlerinfo.plugin_name); oh_print_ep (&(handlerinfo.entity_root),0); - // g_hash_table_destroy(config); } + g_hash_table_destroy(config); } else if (rv!=SA_ERR_HPI_NOT_PRESENT) { printf("Error: oHpiHandlerGetNext (%d) returned %d (%s)\n", Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-10-12 13:38:06 UTC (rev 7149) +++ openhpi/trunk/include/oHpi.h 2010-10-19 10:05:44 UTC (rev 7150) @@ -95,7 +95,7 @@ SaErrorT SAHPI_API oHpiHandlerInfo ( SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerInfoT *info, - SAHPI_OUT GHashTable **conf_params ); //hash table will be allocated + SAHPI_IN GHashTable *conf_params ); SaErrorT SAHPI_API oHpiHandlerGetNext ( SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerIdT *next_id ); Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-10-12 13:38:06 UTC (rev 7149) +++ openhpi/trunk/openhpid/ohpi.c 2010-10-19 10:05:44 UTC (rev 7150) @@ -107,6 +107,8 @@ * oHpiHandlerInfo * @id: IN. The id of the handler to query * @info: IN/OUT. Pointer to struct for holding handler information + * @conf_params: IN/OUT Pointer to pre-allocated hash-table, for holding the + * handler's configuration parameters * * Queries a handler for the information associated with it. * @@ -120,14 +122,16 @@ SaErrorT SAHPI_API oHpiHandlerInfo ( SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerInfoT *info, - SAHPI_OUT GHashTable **conf_params ) //hash table will be allocated + SAHPI_IN GHashTable *conf_params ) { struct oh_handler *h = NULL; - if (!id || !info) + if (!id || !info || !conf_params) return SA_ERR_HPI_INVALID_PARAMS; + if (g_hash_table_size(conf_params)!=0) + return SA_ERR_HPI_INVALID_PARAMS; - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; + if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; h = oh_get_handler(id); if (!h) { @@ -143,16 +147,12 @@ if (!h->hnd) info->load_failed = 1; else info->load_failed = 0; - // create a new hash table, so the original config table is not - // transferred and deleted. - *conf_params = g_hash_table_new_full ( - g_str_hash, g_str_equal, g_free, g_free); // copy h->config to the output hash table - g_hash_table_foreach(h->config,copy_hashed_config_info,*conf_params); + g_hash_table_foreach(h->config,copy_hashed_config_info,conf_params); //Don't transmit passwords in case the handler has a password in its config - if (g_hash_table_lookup(*conf_params,"password")) - g_hash_table_replace(*conf_params,"password","********"); + if (g_hash_table_lookup(conf_params,"password")) + g_hash_table_replace(conf_params,"password","********"); oh_release_handler(h); Modified: openhpi/trunk/openhpid/openhpid.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid.cpp 2010-10-12 13:38:06 UTC (rev 7149) +++ openhpi/trunk/openhpid/openhpid.cpp 2010-10-19 10:05:44 UTC (rev 7150) @@ -2902,17 +2902,19 @@ oHpiHandlerIdT id; oHpiHandlerInfoT info; oHpiHandlerConfigT config; - GHashTable *config_table = g_hash_table_new_full( - g_str_hash, g_str_equal, - g_free, g_free ); - + GHashTable *config_table = 0; + PVERBOSE1("%p Processing oHpiHandlerInfo.", thrdid); if ( HpiDemarshalRequest1( thrdinst->remote_byte_order, hm, pReq, &id ) < 0 ) return eResultError; - ret = oHpiHandlerInfo(id, &info, &config_table); + config_table = g_hash_table_new_full( + g_str_hash, g_str_equal, + g_free, g_free ); + + ret = oHpiHandlerInfo(id, &info, config_table); config.NumberOfParams = 0; config.Params = (oHpiHandlerConfigParamT *) @@ -2921,6 +2923,10 @@ // add each hash table entry to the marshable handler_config g_hash_table_foreach(config_table, __dehash_handler_config, &config); + //It should be possible to free the hash table here, + //but it crashes the daemon. + //g_hash_table_destroy(config_table); + thrdinst->header.m_len = HpiMarshalReply2( hm, pReq, &ret, &info, &config ); Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_009.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_009.c 2010-10-12 13:38:06 UTC (rev 7149) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_009.c 2010-10-19 10:05:44 UTC (rev 7150) @@ -30,7 +30,9 @@ GHashTable *config = g_hash_table_new(g_str_hash, g_str_equal); oHpiHandlerIdT hid = 0; oHpiHandlerInfoT hinfo; - GHashTable *configinfo = 0; + GHashTable *configinfo = g_hash_table_new_full( + g_str_hash, g_str_equal, + g_free, g_free );; setenv("OPENHPI_CONF","./noconfig", 1); @@ -46,7 +48,7 @@ if (oHpiHandlerCreate(config, &hid)) return -1; - if (oHpiHandlerInfo(hid, &hinfo, &configinfo)) + if (oHpiHandlerInfo(hid, &hinfo, configinfo)) return -1; if (strcmp("libsimulator",hinfo.plugin_name)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-10-25 13:39:56
|
Revision: 7152 http://openhpi.svn.sourceforge.net/openhpi/?rev=7152&view=rev Author: avpak Date: 2010-10-25 13:39:47 +0000 (Mon, 25 Oct 2010) Log Message: ----------- Feature request #3084837 Modified Paths: -------------- openhpi/trunk/configure.ac openhpi/trunk/openhpi.spec.in openhpi/trunk/plugins/Makefile.am Added Paths: ----------- openhpi/trunk/plugins/slave/ openhpi/trunk/plugins/slave/Makefile.am openhpi/trunk/plugins/slave/baselib.cpp openhpi/trunk/plugins/slave/baselib.h openhpi/trunk/plugins/slave/handler.cpp openhpi/trunk/plugins/slave/handler.h openhpi/trunk/plugins/slave/lock.h openhpi/trunk/plugins/slave/resourcemap.cpp openhpi/trunk/plugins/slave/resourcemap.h openhpi/trunk/plugins/slave/slave.cpp openhpi/trunk/plugins/slave/util.cpp openhpi/trunk/plugins/slave/util.h Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2010-10-22 14:35:48 UTC (rev 7151) +++ openhpi/trunk/configure.ac 2010-10-25 13:39:47 UTC (rev 7152) @@ -422,6 +422,13 @@ fi ]) +# configure argument for the slave plugin +AC_ARG_ENABLE([slave], + [ --enable-slave build slave plugin [[default=no]]], + [if test "x$enableval" = "xyes"; then + AC_SUBST(SLAVE,slave) + fi]) + dnl dnl create static plugin config dnl @@ -724,6 +731,7 @@ plugins/rtas/Makefile plugins/ilo2_ribcl/Makefile plugins/oa_soap/Makefile + plugins/slave/Makefile scripts/Makefile scripts/test/Makefile snmp/Makefile Modified: openhpi/trunk/openhpi.spec.in =================================================================== --- openhpi/trunk/openhpi.spec.in 2010-10-22 14:35:48 UTC (rev 7151) +++ openhpi/trunk/openhpi.spec.in 2010-10-25 13:39:47 UTC (rev 7152) @@ -35,6 +35,10 @@ %define with_oa_soap @WITH_OA_SOAP@ %define with_docbook2html @WITH_DOCBOOK2HTML@ +%if "x@SLAVE@" == "xslave" +%define with_slave 1 +%endif + Name: @HPI_PKG@ Version: @VERSION@ Release: 1 @@ -150,6 +154,13 @@ Requires: openhpi = %{version} libxml2 openssl %endif +%if 0%{?with_slave} +%package slave +Summary: OpenHPI plugin for a slave OpenHPI daemon +Group: System/Monitoring +Requires: openhpi = %{version} +%endif + %description An open implementation of the Service Availability Forum (SAF) Hardware Platform Interface (HPI). It includes support for multiple types of @@ -228,6 +239,12 @@ using an XML-encoded SOAP interface. %endif +%if 0%{?with_slave} +%description slave +OpenHPI plug-in that connects to a specified OpenHPI daemon and +represents the remote daemon resources at its owns. +%endif + ################################################### %prep ################################################### @@ -371,3 +388,11 @@ %{_libdir}/%{name}/liboa_soap.* %endif +################################################### +%if 0%{?with_slave} +%files slave +################################################### +%defattr(-,root,root) +%{_libdir}/%{name}/libslave.* +%endif + Modified: openhpi/trunk/plugins/Makefile.am =================================================================== --- openhpi/trunk/plugins/Makefile.am 2010-10-22 14:35:48 UTC (rev 7151) +++ openhpi/trunk/plugins/Makefile.am 2010-10-25 13:39:47 UTC (rev 7152) @@ -32,7 +32,7 @@ MAINTAINERCLEANFILES = Makefile.in SUBDIRS = @IPMI@ @WATCHDOG@ @SYSFS@ @SNMP_BC@ @IPMIDIRECT@ @DYNAMIC_SIMULATOR@ @SIMULATOR@ \ - @RTAS@ @ILO2_RIBCL@ @OA_SOAP@ + @RTAS@ @ILO2_RIBCL@ @OA_SOAP@ @SLAVE@ DIST_SUBDIRS = ipmi \ watchdog \ sysfs \ @@ -42,5 +42,6 @@ simulator \ rtas \ ilo2_ribcl \ - oa_soap + oa_soap \ + slave Added: openhpi/trunk/plugins/slave/Makefile.am =================================================================== --- openhpi/trunk/plugins/slave/Makefile.am (rev 0) +++ openhpi/trunk/plugins/slave/Makefile.am 2010-10-25 13:39:47 UTC (rev 7152) @@ -0,0 +1,35 @@ +# -*- linux-c++ -*- +# +# (C) Copyright Pigeon Point Systems. 2010 +# +# This program 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. This +# file and program are licensed under a BSD style license. See +# the Copying file included with the OpenHPI distribution for +# full licensing terms. +# +# Author(s): +# Anton Pak <ant...@pi...> +# + +MAINTAINERCLEANFILES = Makefile.in + +INCLUDES = @OPENHPI_INCLUDES@ + +pkglib_LTLIBRARIES = libslave.la + +libslave_la_SOURCES = baselib.cpp \ + baselib.h \ + handler.cpp \ + handler.h \ + lock.h \ + resourcemap.cpp \ + resourcemap.h \ + slave.cpp \ + util.cpp \ + util.h + +libslave_la_LIBADD = -ldl +libslave_la_LDFLAGS = -module -version-info @HPI_LIB_VERSION@ + Added: openhpi/trunk/plugins/slave/baselib.cpp =================================================================== --- openhpi/trunk/plugins/slave/baselib.cpp (rev 0) +++ openhpi/trunk/plugins/slave/baselib.cpp 2010-10-25 13:39:47 UTC (rev 7152) @@ -0,0 +1,584 @@ +/* -*- linux-c++ -*- + * + *(C) Copyright Pigeon Point Systems. 2010 + * + * This program 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. This + * file and program are licensed under a BSD style license. See + * the Copying file included with the OpenHPI distribution for + * full licensing terms. + * + * Author(s): + * Anton Pak <ant...@pi...> + */ + +#include <dlfcn.h> + +#include <string> + +#include <oh_error.h> + +#include "baselib.h" + + +namespace Slave { + + +/************************************************************** + * class cBaseLib + *************************************************************/ +cBaseLib::cBaseLib() + : m_handle( 0 ) +{ + // empty + memset( &m_abi, 0, sizeof(m_abi) ); +} + +cBaseLib::~cBaseLib() +{ + if ( m_handle ) { + m_abi.saHpiFinalize(); + dlclose( m_handle ); + } +} + + +template <typename F> +void GetF( void * handle, const char * name, F& f, std::string& error ) +{ + dlerror(); + f = 0; + void * ptr = dlsym( handle, name ); + const char * dlerr = dlerror(); + if ( dlerr ) { + error += dlerr; + error.push_back( '\n' ); + } + f = reinterpret_cast<F>(ptr); +} + +bool cBaseLib::LoadBaseLib() +{ + m_handle = dlopen( "libopenhpi.so", RTLD_NOW | RTLD_LOCAL ); + if ( !m_handle ) { + return false; + } + + std::string error; + + GetF( m_handle, + "saHpiVersionGet", + m_abi.saHpiVersionGet, + error ); + GetF( m_handle, + "saHpiInitialize", + m_abi.saHpiInitialize, + error ); + GetF( m_handle, + "saHpiFinalize", + m_abi.saHpiFinalize, + error ); + GetF( m_handle, + "saHpiSessionOpen", + m_abi.saHpiSessionOpen, + error ); + GetF( m_handle, + "saHpiSessionClose", + m_abi.saHpiSessionClose, + error ); + GetF( m_handle, + "saHpiDiscover", + m_abi.saHpiDiscover, + error ); + GetF( m_handle, + "saHpiDomainInfoGet", + m_abi.saHpiDomainInfoGet, + error ); + GetF( m_handle, + "saHpiDrtEntryGet", + m_abi.saHpiDrtEntryGet, + error ); + GetF( m_handle, + "saHpiDomainTagSet", + m_abi.saHpiDomainTagSet, + error ); + GetF( m_handle, + "saHpiRptEntryGet", + m_abi.saHpiRptEntryGet, + error ); + GetF( m_handle, + "saHpiRptEntryGetByResourceId", + m_abi.saHpiRptEntryGetByResourceId, + error ); + GetF( m_handle, + "saHpiResourceSeveritySet", + m_abi.saHpiResourceSeveritySet, + error ); + GetF( m_handle, + "saHpiResourceTagSet", + m_abi.saHpiResourceTagSet, + error ); + GetF( m_handle, + "saHpiMyEntityPathGet", + m_abi.saHpiMyEntityPathGet, + error ); + GetF( m_handle, + "saHpiResourceIdGet", + m_abi.saHpiResourceIdGet, + error ); + GetF( m_handle, + "saHpiGetIdByEntityPath", + m_abi.saHpiGetIdByEntityPath, + error ); + GetF( m_handle, + "saHpiGetChildEntityPath", + m_abi.saHpiGetChildEntityPath, + error ); + GetF( m_handle, + "saHpiResourceFailedRemove", + m_abi.saHpiResourceFailedRemove, + error ); + GetF( m_handle, + "saHpiEventLogInfoGet", + m_abi.saHpiEventLogInfoGet, + error ); + GetF( m_handle, + "saHpiEventLogCapabilitiesGet", + m_abi.saHpiEventLogCapabilitiesGet, + error ); + GetF( m_handle, + "saHpiEventLogEntryGet", + m_abi.saHpiEventLogEntryGet, + error ); + GetF( m_handle, + "saHpiEventLogEntryAdd", + m_abi.saHpiEventLogEntryAdd, + error ); + GetF( m_handle, + "saHpiEventLogClear", + m_abi.saHpiEventLogClear, + error ); + GetF( m_handle, + "saHpiEventLogTimeGet", + m_abi.saHpiEventLogTimeGet, + error ); + GetF( m_handle, + "saHpiEventLogTimeSet", + m_abi.saHpiEventLogTimeSet, + error ); + GetF( m_handle, + "saHpiEventLogStateGet", + m_abi.saHpiEventLogStateGet, + error ); + GetF( m_handle, + "saHpiEventLogStateSet", + m_abi.saHpiEventLogStateSet, + error ); + GetF( m_handle, + "saHpiEventLogOverflowReset", + m_abi.saHpiEventLogOverflowReset, + error ); + GetF( m_handle, + "saHpiSubscribe", + m_abi.saHpiSubscribe, + error ); + GetF( m_handle, + "saHpiUnsubscribe", + m_abi.saHpiUnsubscribe, + error ); + GetF( m_handle, + "saHpiEventGet", + m_abi.saHpiEventGet, + error ); + GetF( m_handle, + "saHpiEventAdd", + m_abi.saHpiEventAdd, + error ); + GetF( m_handle, + "saHpiAlarmGetNext", + m_abi.saHpiAlarmGetNext, + error ); + GetF( m_handle, + "saHpiAlarmGet", + m_abi.saHpiAlarmGet, + error ); + GetF( m_handle, + "saHpiAlarmAcknowledge", + m_abi.saHpiAlarmAcknowledge, + error ); + GetF( m_handle, + "saHpiAlarmAdd", + m_abi.saHpiAlarmAdd, + error ); + GetF( m_handle, + "saHpiAlarmDelete", + m_abi.saHpiAlarmDelete, + error ); + GetF( m_handle, + "saHpiRdrGet", + m_abi.saHpiRdrGet, + error ); + GetF( m_handle, + "saHpiRdrGetByInstrumentId", + m_abi.saHpiRdrGetByInstrumentId, + error ); + GetF( m_handle, + "saHpiRdrUpdateCountGet", + m_abi.saHpiRdrUpdateCountGet, + error ); + GetF( m_handle, + "saHpiSensorReadingGet", + m_abi.saHpiSensorReadingGet, + error ); + GetF( m_handle, + "saHpiSensorThresholdsGet", + m_abi.saHpiSensorThresholdsGet, + error ); + GetF( m_handle, + "saHpiSensorThresholdsSet", + m_abi.saHpiSensorThresholdsSet, + error ); + GetF( m_handle, + "saHpiSensorTypeGet", + m_abi.saHpiSensorTypeGet, + error ); + GetF( m_handle, + "saHpiSensorEnableGet", + m_abi.saHpiSensorEnableGet, + error ); + GetF( m_handle, + "saHpiSensorEnableSet", + m_abi.saHpiSensorEnableSet, + error ); + GetF( m_handle, + "saHpiSensorEventEnableGet", + m_abi.saHpiSensorEventEnableGet, + error ); + GetF( m_handle, + "saHpiSensorEventEnableSet", + m_abi.saHpiSensorEventEnableSet, + error ); + GetF( m_handle, + "saHpiSensorEventMasksGet", + m_abi.saHpiSensorEventMasksGet, + error ); + GetF( m_handle, + "saHpiSensorEventMasksSet", + m_abi.saHpiSensorEventMasksSet, + error ); + GetF( m_handle, + "saHpiControlTypeGet", + m_abi.saHpiControlTypeGet, + error ); + GetF( m_handle, + "saHpiControlGet", + m_abi.saHpiControlGet, + error ); + GetF( m_handle, + "saHpiControlSet", + m_abi.saHpiControlSet, + error ); + GetF( m_handle, + "saHpiIdrInfoGet", + m_abi.saHpiIdrInfoGet, + error ); + GetF( m_handle, + "saHpiIdrAreaHeaderGet", + m_abi.saHpiIdrAreaHeaderGet, + error ); + GetF( m_handle, + "saHpiIdrAreaAdd", + m_abi.saHpiIdrAreaAdd, + error ); + GetF( m_handle, + "saHpiIdrAreaAddById", + m_abi.saHpiIdrAreaAddById, + error ); + GetF( m_handle, + "saHpiIdrAreaDelete", + m_abi.saHpiIdrAreaDelete, + error ); + GetF( m_handle, + "saHpiIdrFieldGet", + m_abi.saHpiIdrFieldGet, + error ); + GetF( m_handle, + "saHpiIdrFieldAdd", + m_abi.saHpiIdrFieldAdd, + error ); + GetF( m_handle, + "saHpiIdrFieldAddById", + m_abi.saHpiIdrFieldAddById, + error ); + GetF( m_handle, + "saHpiIdrFieldSet", + m_abi.saHpiIdrFieldSet, + error ); + GetF( m_handle, + "saHpiIdrFieldDelete", + m_abi.saHpiIdrFieldDelete, + error ); + GetF( m_handle, + "saHpiWatchdogTimerGet", + m_abi.saHpiWatchdogTimerGet, + error ); + GetF( m_handle, + "saHpiWatchdogTimerSet", + m_abi.saHpiWatchdogTimerSet, + error ); + GetF( m_handle, + "saHpiWatchdogTimerReset", + m_abi.saHpiWatchdogTimerReset, + error ); + GetF( m_handle, + "saHpiAnnunciatorGetNext", + m_abi.saHpiAnnunciatorGetNext, + error ); + GetF( m_handle, + "saHpiAnnunciatorGet", + m_abi.saHpiAnnunciatorGet, + error ); + GetF( m_handle, + "saHpiAnnunciatorAcknowledge", + m_abi.saHpiAnnunciatorAcknowledge, + error ); + GetF( m_handle, + "saHpiAnnunciatorAdd", + m_abi.saHpiAnnunciatorAdd, + error ); + GetF( m_handle, + "saHpiAnnunciatorDelete", + m_abi.saHpiAnnunciatorDelete, + error ); + GetF( m_handle, + "saHpiAnnunciatorModeGet", + m_abi.saHpiAnnunciatorModeGet, + error ); + GetF( m_handle, + "saHpiAnnunciatorModeSet", + m_abi.saHpiAnnunciatorModeSet, + error ); + GetF( m_handle, + "saHpiDimiInfoGet", + m_abi.saHpiDimiInfoGet, + error ); + GetF( m_handle, + "saHpiDimiTestInfoGet", + m_abi.saHpiDimiTestInfoGet, + error ); + GetF( m_handle, + "saHpiDimiTestReadinessGet", + m_abi.saHpiDimiTestReadinessGet, + error ); + GetF( m_handle, + "saHpiDimiTestStart", + m_abi.saHpiDimiTestStart, + error ); + GetF( m_handle, + "saHpiDimiTestCancel", + m_abi.saHpiDimiTestCancel, + error ); + GetF( m_handle, + "saHpiDimiTestStatusGet", + m_abi.saHpiDimiTestStatusGet, + error ); + GetF( m_handle, + "saHpiDimiTestResultsGet", + m_abi.saHpiDimiTestResultsGet, + error ); + GetF( m_handle, + "saHpiFumiSpecInfoGet", + m_abi.saHpiFumiSpecInfoGet, + error ); + GetF( m_handle, + "saHpiFumiServiceImpactGet", + m_abi.saHpiFumiServiceImpactGet, + error ); + GetF( m_handle, + "saHpiFumiSourceSet", + m_abi.saHpiFumiSourceSet, + error ); + GetF( m_handle, + "saHpiFumiSourceInfoValidateStart", + m_abi.saHpiFumiSourceInfoValidateStart, + error ); + GetF( m_handle, + "saHpiFumiSourceInfoGet", + m_abi.saHpiFumiSourceInfoGet, + error ); + GetF( m_handle, + "saHpiFumiSourceComponentInfoGet", + m_abi.saHpiFumiSourceComponentInfoGet, + error ); + GetF( m_handle, + "saHpiFumiTargetInfoGet", + m_abi.saHpiFumiTargetInfoGet, + error ); + GetF( m_handle, + "saHpiFumiTargetComponentInfoGet", + m_abi.saHpiFumiTargetComponentInfoGet, + error ); + GetF( m_handle, + "saHpiFumiLogicalTargetInfoGet", + m_abi.saHpiFumiLogicalTargetInfoGet, + error ); + GetF( m_handle, + "saHpiFumiLogicalTargetComponentInfoGet", + m_abi.saHpiFumiLogicalTargetComponentInfoGet, + error ); + GetF( m_handle, + "saHpiFumiBackupStart", + m_abi.saHpiFumiBackupStart, + error ); + GetF( m_handle, + "saHpiFumiBankBootOrderSet", + m_abi.saHpiFumiBankBootOrderSet, + error ); + GetF( m_handle, + "saHpiFumiBankCopyStart", + m_abi.saHpiFumiBankCopyStart, + error ); + GetF( m_handle, + "saHpiFumiInstallStart", + m_abi.saHpiFumiInstallStart, + error ); + GetF( m_handle, + "saHpiFumiUpgradeStatusGet", + m_abi.saHpiFumiUpgradeStatusGet, + error ); + GetF( m_handle, + "saHpiFumiTargetVerifyStart", + m_abi.saHpiFumiTargetVerifyStart, + error ); + GetF( m_handle, + "saHpiFumiTargetVerifyMainStart", + m_abi.saHpiFumiTargetVerifyMainStart, + error ); + GetF( m_handle, + "saHpiFumiUpgradeCancel", + m_abi.saHpiFumiUpgradeCancel, + error ); + GetF( m_handle, + "saHpiFumiAutoRollbackDisableGet", + m_abi.saHpiFumiAutoRollbackDisableGet, + error ); + GetF( m_handle, + "saHpiFumiAutoRollbackDisableSet", + m_abi.saHpiFumiAutoRollbackDisableSet, + error ); + GetF( m_handle, + "saHpiFumiRollbackStart", + m_abi.saHpiFumiRollbackStart, + error ); + GetF( m_handle, + "saHpiFumiActivate", + m_abi.saHpiFumiActivate, + error ); + GetF( m_handle, + "saHpiFumiActivateStart", + m_abi.saHpiFumiActivateStart, + error ); + GetF( m_handle, + "saHpiFumiCleanup", + m_abi.saHpiFumiCleanup, + error ); + GetF( m_handle, + "saHpiHotSwapPolicyCancel", + m_abi.saHpiHotSwapPolicyCancel, + error ); + GetF( m_handle, + "saHpiResourceActiveSet", + m_abi.saHpiResourceActiveSet, + error ); + GetF( m_handle, + "saHpiResourceInactiveSet", + m_abi.saHpiResourceInactiveSet, + error ); + GetF( m_handle, + "saHpiAutoInsertTimeoutGet", + m_abi.saHpiAutoInsertTimeoutGet, + error ); + GetF( m_handle, + "saHpiAutoInsertTimeoutSet", + m_abi.saHpiAutoInsertTimeoutSet, + error ); + GetF( m_handle, + "saHpiAutoExtractTimeoutGet", + m_abi.saHpiAutoExtractTimeoutGet, + error ); + GetF( m_handle, + "saHpiAutoExtractTimeoutSet", + m_abi.saHpiAutoExtractTimeoutSet, + error ); + GetF( m_handle, + "saHpiHotSwapStateGet", + m_abi.saHpiHotSwapStateGet, + error ); + GetF( m_handle, + "saHpiHotSwapActionRequest", + m_abi.saHpiHotSwapActionRequest, + error ); + GetF( m_handle, + "saHpiHotSwapIndicatorStateGet", + m_abi.saHpiHotSwapIndicatorStateGet, + error ); + GetF( m_handle, + "saHpiHotSwapIndicatorStateSet", + m_abi.saHpiHotSwapIndicatorStateSet, + error ); + GetF( m_handle, + "saHpiParmControl", + m_abi.saHpiParmControl, + error ); + GetF( m_handle, + "saHpiResourceLoadIdGet", + m_abi.saHpiResourceLoadIdGet, + error ); + GetF( m_handle, + "saHpiResourceLoadIdSet", + m_abi.saHpiResourceLoadIdSet, + error ); + GetF( m_handle, + "saHpiResourceResetStateGet", + m_abi.saHpiResourceResetStateGet, + error ); + GetF( m_handle, + "saHpiResourceResetStateSet", + m_abi.saHpiResourceResetStateSet, + error ); + GetF( m_handle, + "saHpiResourcePowerStateGet", + m_abi.saHpiResourcePowerStateGet, + error ); + GetF( m_handle, + "saHpiResourcePowerStateSet", + m_abi.saHpiResourcePowerStateSet, + error ); + + GetF( m_handle, + "oHpiDomainAdd", + m_abi.oHpiDomainAdd, + error ); + + if ( !error.empty() ) { + dlclose( m_handle ); + m_handle = 0; + err( "Slave: %s\n", error.c_str() ); + return false; + } + + SaErrorT rv = m_abi.saHpiInitialize( SAHPI_INTERFACE_VERSION, 0, 0, 0, 0 ); + if ( rv != SA_OK ) { + dlclose( m_handle ); + m_handle = 0; + err( "Slave: saHpiInitialize failed with rv = %d\n", rv ); + return false; + } + + return true; +} + + +}; // namespace Slave + Added: openhpi/trunk/plugins/slave/baselib.h =================================================================== --- openhpi/trunk/plugins/slave/baselib.h (rev 0) +++ openhpi/trunk/plugins/slave/baselib.h 2010-10-25 13:39:47 UTC (rev 7152) @@ -0,0 +1,1154 @@ +/* -*- linux-c++ -*- + * + *(C) Copyright Pigeon Point Systems. 2010 + * + * This program 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. This + * file and program are licensed under a BSD style license. See + * the Copying file included with the OpenHPI distribution for + * full licensing terms. + * + * Author(s): + * Anton Pak <ant...@pi...> + */ + +#ifndef __BASELIB_H__ +#define __BASELIB_H__ + +#include <string> + +#include <SaHpi.h> + + +/************************************************************** + * Pointers to Base Lib API functions (SAI-HPI-B.03.02) + *************************************************************/ + +typedef +SaHpiVersionT SAHPI_API (*saHpiVersionGetPtr)( void ); + +typedef +SaErrorT SAHPI_API (*saHpiInitializePtr) ( + SAHPI_IN SaHpiVersionT RequestedVersion, + SAHPI_IN SaHpiUint32T NumOptions, + SAHPI_INOUT SaHpiInitOptionT *Options, + SAHPI_OUTNN SaHpiUint32T *FailedOption, + SAHPI_OUTNN SaErrorT *OptionError +); + +typedef +SaErrorT SAHPI_API (*saHpiFinalizePtr)( void ); + +typedef +SaErrorT SAHPI_API (*saHpiSessionOpenPtr)( + SAHPI_IN SaHpiDomainIdT DomainId, + SAHPI_OUT SaHpiSessionIdT *SessionId, + SAHPI_IN void *SecurityParams +); + +typedef +SaErrorT SAHPI_API (*saHpiSessionClosePtr)( + SAHPI_IN SaHpiSessionIdT SessionId +); + +typedef +SaErrorT SAHPI_API (*saHpiDiscoverPtr)( + SAHPI_IN SaHpiSessionIdT SessionId +); + +typedef +SaErrorT SAHPI_API (*saHpiDomainInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_OUT SaHpiDomainInfoT *DomainInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiDrtEntryGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEntryIdT *NextEntryId, + SAHPI_OUT SaHpiDrtEntryT *DrtEntry +); + +typedef +SaErrorT SAHPI_API (*saHpiDomainTagSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiTextBufferT *DomainTag +); + +typedef +SaErrorT SAHPI_API (*saHpiRptEntryGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEntryIdT *NextEntryId, + SAHPI_OUT SaHpiRptEntryT *RptEntry +); + +typedef +SaErrorT SAHPI_API (*saHpiRptEntryGetByResourceIdPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiRptEntryT *RptEntry +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceSeveritySetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSeverityT Severity +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceTagSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiTextBufferT *ResourceTag +); + +typedef +SaErrorT SAHPI_API (*saHpiMyEntityPathGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_OUT SaHpiEntityPathT *EntityPath +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceIdGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_OUT SaHpiResourceIdT *ResourceId +); + +typedef +SaErrorT SAHPI_API (*saHpiGetIdByEntityPathPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEntityPathT EntityPath, + SAHPI_IN SaHpiRdrTypeT InstrumentType, + SAHPI_INOUT SaHpiUint32T *InstanceId, + SAHPI_OUT SaHpiResourceIdT *ResourceId, + SAHPI_OUT SaHpiInstrumentIdT *InstrumentId, + SAHPI_OUT SaHpiUint32T *RptUpdateCount +); + +typedef +SaErrorT SAHPI_API (*saHpiGetChildEntityPathPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEntityPathT ParentEntityPath, + SAHPI_INOUT SaHpiUint32T *InstanceId, + SAHPI_OUT SaHpiEntityPathT *ChildEntityPath, + SAHPI_OUT SaHpiUint32T *RptUpdateCount +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceFailedRemovePtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiEventLogInfoT *Info +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogCapabilitiesGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiEventLogCapabilitiesT *EventLogCapabilities +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogEntryGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiEventLogEntryIdT EntryId, + SAHPI_OUT SaHpiEventLogEntryIdT *PrevEntryId, + SAHPI_OUT SaHpiEventLogEntryIdT *NextEntryId, + SAHPI_OUT SaHpiEventLogEntryT *EventLogEntry, + SAHPI_INOUT SaHpiRdrT *Rdr, + SAHPI_INOUT SaHpiRptEntryT *RptEntry +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogEntryAddPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiEventT *EvtEntry +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogClearPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogTimeGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiTimeT *Time +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogTimeSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiTimeT Time +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogStateGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiBoolT *EnableState +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogStateSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiBoolT EnableState +); + +typedef +SaErrorT SAHPI_API (*saHpiEventLogOverflowResetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId +); + +typedef +SaErrorT SAHPI_API (*saHpiSubscribePtr)( + SAHPI_IN SaHpiSessionIdT SessionId +); + +typedef +SaErrorT SAHPI_API (*saHpiUnsubscribePtr)( + SAHPI_IN SaHpiSessionIdT SessionId +); + +typedef +SaErrorT SAHPI_API (*saHpiEventGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiTimeoutT Timeout, + SAHPI_OUT SaHpiEventT *Event, + SAHPI_INOUT SaHpiRdrT *Rdr, + SAHPI_INOUT SaHpiRptEntryT *RptEntry, + SAHPI_INOUT SaHpiEvtQueueStatusT *EventQueueStatus +); + +typedef +SaErrorT SAHPI_API (*saHpiEventAddPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEventT *EvtEntry +); + +typedef +SaErrorT SAHPI_API (*saHpiAlarmGetNextPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiSeverityT Severity, + SAHPI_IN SaHpiBoolT UnacknowledgedOnly, + SAHPI_INOUT SaHpiAlarmT *Alarm +); + +typedef +SaErrorT SAHPI_API (*saHpiAlarmGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiAlarmIdT AlarmId, + SAHPI_OUT SaHpiAlarmT *Alarm +); + +typedef +SaErrorT SAHPI_API (*saHpiAlarmAcknowledgePtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiAlarmIdT AlarmId, + SAHPI_IN SaHpiSeverityT Severity +); + +typedef +SaErrorT SAHPI_API (*saHpiAlarmAddPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_INOUT SaHpiAlarmT *Alarm +); + +typedef +SaErrorT SAHPI_API (*saHpiAlarmDeletePtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiAlarmIdT AlarmId, + SAHPI_IN SaHpiSeverityT Severity +); + +typedef +SaErrorT SAHPI_API (*saHpiRdrGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEntryIdT *NextEntryId, + SAHPI_OUT SaHpiRdrT *Rdr +); + +typedef +SaErrorT SAHPI_API (*saHpiRdrGetByInstrumentIdPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiRdrTypeT RdrType, + SAHPI_IN SaHpiInstrumentIdT InstrumentId, + SAHPI_OUT SaHpiRdrT *Rdr +); + +typedef +SaErrorT SAHPI_API (*saHpiRdrUpdateCountGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiUint32T *UpdateCount +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorReadingGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_INOUT SaHpiSensorReadingT *Reading, + SAHPI_INOUT SaHpiEventStateT *EventState +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorThresholdsGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_OUT SaHpiSensorThresholdsT *SensorThresholds +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorThresholdsSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_IN SaHpiSensorThresholdsT *SensorThresholds +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorTypeGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_OUT SaHpiSensorTypeT *Type, + SAHPI_OUT SaHpiEventCategoryT *Category +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorEnableGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_OUT SaHpiBoolT *SensorEnabled +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorEnableSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_IN SaHpiBoolT SensorEnabled +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorEventEnableGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_OUT SaHpiBoolT *SensorEventsEnabled +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorEventEnableSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_IN SaHpiBoolT SensorEventsEnabled +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorEventMasksGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_INOUT SaHpiEventStateT *AssertEventMask, + SAHPI_INOUT SaHpiEventStateT *DeassertEventMask +); + +typedef +SaErrorT SAHPI_API (*saHpiSensorEventMasksSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSensorNumT SensorNum, + SAHPI_IN SaHpiSensorEventMaskActionT Action, + SAHPI_IN SaHpiEventStateT AssertEventMask, + SAHPI_IN SaHpiEventStateT DeassertEventMask +); + +typedef +SaErrorT SAHPI_API (*saHpiControlTypeGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiCtrlNumT CtrlNum, + SAHPI_OUT SaHpiCtrlTypeT *Type +); + +typedef +SaErrorT SAHPI_API (*saHpiControlGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiCtrlNumT CtrlNum, + SAHPI_OUT SaHpiCtrlModeT *CtrlMode, + SAHPI_INOUT SaHpiCtrlStateT *CtrlState +); + +typedef +SaErrorT SAHPI_API (*saHpiControlSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiCtrlNumT CtrlNum, + SAHPI_IN SaHpiCtrlModeT CtrlMode, + SAHPI_IN SaHpiCtrlStateT *CtrlState +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_OUT SaHpiIdrInfoT *IdrInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrAreaHeaderGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_IN SaHpiIdrAreaTypeT AreaType, + SAHPI_IN SaHpiEntryIdT AreaId, + SAHPI_OUT SaHpiEntryIdT *NextAreaId, + SAHPI_OUT SaHpiIdrAreaHeaderT *Header +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrAreaAddPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_IN SaHpiIdrAreaTypeT AreaType, + SAHPI_OUT SaHpiEntryIdT *AreaId +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrAreaAddByIdPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_IN SaHpiIdrAreaTypeT AreaType, + SAHPI_IN SaHpiEntryIdT AreaId +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrAreaDeletePtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_IN SaHpiEntryIdT AreaId +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrFieldGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_IN SaHpiEntryIdT AreaId, + SAHPI_IN SaHpiIdrFieldTypeT FieldType, + SAHPI_IN SaHpiEntryIdT FieldId, + SAHPI_OUT SaHpiEntryIdT *NextFieldId, + SAHPI_OUT SaHpiIdrFieldT *Field +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrFieldAddPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_INOUT SaHpiIdrFieldT *Field +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrFieldAddByIdPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_INOUT SaHpiIdrFieldT *Field +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrFieldSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_IN SaHpiIdrFieldT *Field +); + +typedef +SaErrorT SAHPI_API (*saHpiIdrFieldDeletePtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiIdrIdT IdrId, + SAHPI_IN SaHpiEntryIdT AreaId, + SAHPI_IN SaHpiEntryIdT FieldId +); + +typedef +SaErrorT SAHPI_API (*saHpiWatchdogTimerGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiWatchdogNumT WatchdogNum, + SAHPI_OUT SaHpiWatchdogT *Watchdog +); + +typedef +SaErrorT SAHPI_API (*saHpiWatchdogTimerSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiWatchdogNumT WatchdogNum, + SAHPI_IN SaHpiWatchdogT *Watchdog +); + +typedef +SaErrorT SAHPI_API (*saHpiWatchdogTimerResetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiWatchdogNumT WatchdogNum +); + +typedef +SaErrorT SAHPI_API (*saHpiAnnunciatorGetNextPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiAnnunciatorNumT AnnunciatorNum, + SAHPI_IN SaHpiSeverityT Severity, + SAHPI_IN SaHpiBoolT UnacknowledgedOnly, + SAHPI_INOUT SaHpiAnnouncementT *Announcement +); + +typedef +SaErrorT SAHPI_API (*saHpiAnnunciatorGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiAnnunciatorNumT AnnunciatorNum, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiAnnouncementT *Announcement +); + +typedef +SaErrorT SAHPI_API (*saHpiAnnunciatorAcknowledgePtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiAnnunciatorNumT AnnunciatorNum, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_IN SaHpiSeverityT Severity +); + +typedef +SaErrorT SAHPI_API (*saHpiAnnunciatorAddPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiAnnunciatorNumT AnnunciatorNum, + SAHPI_INOUT SaHpiAnnouncementT *Announcement +); + +typedef +SaErrorT SAHPI_API (*saHpiAnnunciatorDeletePtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiAnnunciatorNumT AnnunciatorNum, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_IN SaHpiSeverityT Severity +); + +typedef +SaErrorT SAHPI_API (*saHpiAnnunciatorModeGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiAnnunciatorNumT AnnunciatorNum, + SAHPI_OUT SaHpiAnnunciatorModeT *Mode +); + +typedef +SaErrorT SAHPI_API (*saHpiAnnunciatorModeSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiAnnunciatorNumT AnnunciatorNum, + SAHPI_IN SaHpiAnnunciatorModeT Mode +); + +typedef +SaErrorT SAHPI_API (*saHpiDimiInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiDimiNumT DimiNum, + SAHPI_OUT SaHpiDimiInfoT *DimiInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiDimiTestInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiDimiNumT DimiNum, + SAHPI_IN SaHpiDimiTestNumT TestNum, + SAHPI_OUT SaHpiDimiTestT *DimiTest +); + +typedef +SaErrorT SAHPI_API (*saHpiDimiTestReadinessGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiDimiNumT DimiNum, + SAHPI_IN SaHpiDimiTestNumT TestNum, + SAHPI_OUT SaHpiDimiReadyT *DimiReady +); + +typedef +SaErrorT SAHPI_API (*saHpiDimiTestStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiDimiNumT DimiNum, + SAHPI_IN SaHpiDimiTestNumT TestNum, + SAHPI_IN SaHpiUint8T NumberOfParams, + SAHPI_IN SaHpiDimiTestVariableParamsT *ParamsList +); + +typedef +SaErrorT SAHPI_API (*saHpiDimiTestCancelPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiDimiNumT DimiNum, + SAHPI_IN SaHpiDimiTestNumT TestNum +); + +typedef +SaErrorT SAHPI_API (*saHpiDimiTestStatusGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiDimiNumT DimiNum, + SAHPI_IN SaHpiDimiTestNumT TestNum, + SAHPI_OUT SaHpiDimiTestPercentCompletedT *PercentCompleted, + SAHPI_OUT SaHpiDimiTestRunStatusT *RunStatus +); + +typedef +SaErrorT SAHPI_API (*saHpiDimiTestResultsGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiDimiNumT DimiNum, + SAHPI_IN SaHpiDimiTestNumT TestNum, + SAHPI_OUT SaHpiDimiTestResultsT *TestResults +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiSpecInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_OUT SaHpiFumiSpecInfoT *SpecInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiServiceImpactGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_OUT SaHpiFumiServiceImpactDataT *ServiceImpact +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiSourceSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum, + SAHPI_IN SaHpiTextBufferT *SourceUri +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiSourceInfoValidateStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiSourceInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum, + SAHPI_OUT SaHpiFumiSourceInfoT *SourceInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiSourceComponentInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum, + SAHPI_IN SaHpiEntryIdT ComponentEntryId, + SAHPI_OUT SaHpiEntryIdT *NextComponentEntryId, + SAHPI_OUT SaHpiFumiComponentInfoT *ComponentInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiTargetInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum, + SAHPI_OUT SaHpiFumiBankInfoT *BankInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiTargetComponentInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum, + SAHPI_IN SaHpiEntryIdT ComponentEntryId, + SAHPI_OUT SaHpiEntryIdT *NextComponentEntryId, + SAHPI_OUT SaHpiFumiComponentInfoT *ComponentInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiLogicalTargetInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_OUT SaHpiFumiLogicalBankInfoT *BankInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiLogicalTargetComponentInfoGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiEntryIdT ComponentEntryId, + SAHPI_OUT SaHpiEntryIdT *NextComponentEntryId, + SAHPI_OUT SaHpiFumiLogicalComponentInfoT *ComponentInfo +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiBackupStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiBankBootOrderSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum, + SAHPI_IN SaHpiUint32T Position +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiBankCopyStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT SourceBankNum, + SAHPI_IN SaHpiBankNumT TargetBankNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiInstallStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiUpgradeStatusGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum, + SAHPI_OUT SaHpiFumiUpgradeStatusT *UpgradeStatus +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiTargetVerifyStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiTargetVerifyMainStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiUpgradeCancelPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiAutoRollbackDisableGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_OUT SaHpiBoolT *Disable +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiAutoRollbackDisableSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBoolT Disable +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiRollbackStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiActivatePtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiActivateStartPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBoolT Logical +); + +typedef +SaErrorT SAHPI_API (*saHpiFumiCleanupPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiFumiNumT FumiNum, + SAHPI_IN SaHpiBankNumT BankNum +); + +typedef +SaErrorT SAHPI_API (*saHpiHotSwapPolicyCancelPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceActiveSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceInactiveSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId +); + +typedef +SaErrorT SAHPI_API (*saHpiAutoInsertTimeoutGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_OUT SaHpiTimeoutT *Timeout +); + +typedef +SaErrorT SAHPI_API (*saHpiAutoInsertTimeoutSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiTimeoutT Timeout +); + +typedef +SaErrorT SAHPI_API (*saHpiAutoExtractTimeoutGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiTimeoutT *Timeout +); + +typedef +SaErrorT SAHPI_API (*saHpiAutoExtractTimeoutSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiTimeoutT Timeout +); + +typedef +SaErrorT SAHPI_API (*saHpiHotSwapStateGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiHsStateT *State +); + +typedef +SaErrorT SAHPI_API (*saHpiHotSwapActionRequestPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiHsActionT Action +); + +typedef +SaErrorT SAHPI_API (*saHpiHotSwapIndicatorStateGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiHsIndicatorStateT *State +); + +typedef +SaErrorT SAHPI_API (*saHpiHotSwapIndicatorStateSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiHsIndicatorStateT State +); + +typedef +SaErrorT SAHPI_API (*saHpiParmControlPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiParmActionT Action +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceLoadIdGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiLoadIdT *LoadId +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceLoadIdSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiLoadIdT *LoadId +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceResetStateGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiResetActionT *ResetAction +); + +typedef +SaErrorT SAHPI_API (*saHpiResourceResetStateSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiResetActionT ResetAction +); + +typedef +SaErrorT SAHPI_API (*saHpiResourcePowerStateGetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiPowerStateT *State +); + +typedef +SaErrorT SAHPI_API (*saHpiResourcePowerStateSetPtr)( + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiPowerStateT State +); + + +/************************************************************** + * Pointers to oHpi* functions + *************************************************************/ +typedef +SaErrorT SAHPI_API (*oHpiDomainAddPtr)( + const SaHpiTextBufferT *host, + SaHpiUint16T port, + SaHpiDomainIdT *domain_id +); + + +namespace Slave { + + +/************************************************************** + * struct BaseLibAbi + *************************************************************/ +struct BaseLibAbi +{ + saHpiVersionGetPtr saHpiVersionGet; + saHpiInitializePtr saHpiInitialize; + saHpiFinalizePtr saHpiFinalize; + saHpiSessionOpenPtr saHpiSessionOpen; + saHpiSessionClosePtr saHpiSessionClose; + saHpiDiscoverPtr saHpiDiscover; + saHpiDomainInfoGetPtr saHpiDomainInfoGet; + saHpiDrtEntryGetPtr saHpiDrtEntryGet; + saHpiDomainTagSetPtr saHpiDomainTagSet; + saHpiRptEntryGetPtr saHpiRptEntryGet; + saHpiRptEntryGetByResourceIdPtr saHpiRptEntryGetByResourceId; + saHpiResourceSeveritySetPtr saHpiResourceSeveritySet; + saHpiResourceTagSetPtr saHpiResourceTagSet; + saHpiMyEntityPathGetPtr saHpiMyEntityPathGet; + saHpiResourceIdGetPtr saHpiResourceIdGet; + saHpiGetIdByEntityPathPtr saHpiGetIdByEntityPath; + saHpiGetChildEntityPathPtr saHpiGetChildEntityPath; + saHpiResourceFailedRemovePtr saHpiResourceFailedRemove; + saHpiEventLogInfoGetPtr saHpiEventLogInfoGet; + saHpiEventLogCapabilitiesGetPtr saHpiEventLogCapabilitiesGet; + saHpiEventLogEntryGetPtr saHpiEventLogEntryGet; + saHpiEventLogEntryAddPtr saHpiEventLogEntryAdd; + saHpiEventLogClearPtr saHpiEventLogClear; + saHpiEventLogTimeGetPtr saHpiEventLogTimeGet; + saHpiEventLogTimeSetPtr saHpiEventLogTimeSet; + saHpiEventLogStateGetPtr saHpiEventLogStateGet; + saHpiEventLogStateSetPtr saHpiEventLogStateSet; + saHpiEventLogOverflowResetPtr saHpiEventLogOverflowReset; + saHpiSubscribePtr saHpiSubscribe; + saHpiUnsubscribePtr saHpiUnsubscribe; + saHpiEventGetPtr saHpiEventGet; + saHpiEventAddPtr saHpiEventAdd; + saHpiAlarmGetNextPtr saHpiAlarmGetNext; + saHpiAlarmGetPtr saHpiAlarmGet; + saHpiAlarmAcknowledgePtr saHpiAlarmAcknowledge; + saHpiAlarmAddPtr saHpiAlarmAdd; + saHpiAlarmDeletePtr saHpiAlarmDelete; + saHpiRdrGetPtr saHpiRdrGet; + saHpiRdrGetByInstrumentIdPtr saHpiRdrGetByInstrumentId; + saHpiRdrUpdateCountGetPtr saHpiRdrUpdateCountGet; + saHpiSensorReadingGetPtr saHpiSensorReadingGet; + saHpiSensorThresholdsGetPtr saHpiSensorThresholdsGet; + saHpiSensorThresholdsSetPtr saHpiSensorThresholdsSet; + saHpiSensorTypeGetPtr saHpiSensorTypeGet; + saHpiSensorEnableGetPtr saHpiSensorEnableGet; + saHpiSensorEnableSetPtr saHpiSensorEnableSet; + saHpiSensorEventEnableGetPtr saHpiSensorEventEnableGet; + saHpiSensorEventEnableSetPtr saHpiSensorEventEnableSet; + saHpiSensorEventMasksGetPtr saHpiSensorEventMasksGet; + saHpiSensorEventMasksSetPtr saHpiSensorEventMasksSet; + saHpiControlTypeGetPtr saHpiControlTypeGet; + saHpiControlGetPtr saHpiControlGet; + saHpiControlSetPtr saHpiControlSet; + saHpiIdrInfoGetPtr saHpiIdrInfoGet; + saHpiIdrAreaHeaderGetPtr saHpiIdrAreaHeaderGet; + saHpiIdrAreaAddPtr saHpiIdrAreaAdd; + saHpiIdrAreaAddByIdPtr saHpiIdrAreaAddById; + saHpiIdrAreaDeletePtr saHpiIdrAreaDelete; + saHpiIdrFieldGetPtr saHpiIdrFieldGet; + saHpiIdrFieldAddPtr saHpiIdrFieldAdd; + saHpiIdrFieldAddByIdPtr saHpiIdrFieldAddById; + saHpiIdrFieldSetPtr saHpiIdrFieldSet; + saHpiIdrFieldDeletePtr saHpiIdrFieldDelete; + saHpiWatchdogTimerGetPtr saHpiWatchdogTimerGet; + saHpiWatchdogTimerSetPtr saHpiWatchdogTimerSet; + saHpiWatchdogTimerResetPtr saHpiWatchdogTimerReset; + saHpiAnnunciatorGetNextPtr saHpiAnnunciatorGetNext; + saHpiAnnunciatorGetPtr saHpiAnnunciatorGet; + saHpiAnnunciatorAcknowledgePtr saHpiAnnunciatorAcknowledge; + saHpiAnnunciatorAddPtr saHpiAnnunciatorAdd; + saHpiAnnunciatorDeletePtr saHpiAnnunciatorDelete; + saHpiAnnunciatorModeGetPtr saHpiAnnunciatorModeGet; + saHpiAnnunciatorModeSetPtr saHpiAnnunciatorModeSet; + saHpiDimiInfoGetPtr saHpiDimiInfoGet; + saHpiDimiTestInfoGetPtr saHpiDimiTestInfoGet; + saHpiDimiTestReadinessGetPtr saHpiDimiTestReadinessGet; + saHpiDimiTestStartPtr saHpiDimiTestStart; + saHpiDimiTestCancelPtr saHpiDimiTestCancel; + saHpiDimiTestStatusGetPtr saHpiDimiTestStatusGet; + saHpiDimiTestResultsGetPtr saHpiDimiTestResultsGet; + saHpiFumiSpecInfoGetPtr saHpiFumiSpecInfoGet; + saHpiFumiServiceImpactGetPtr saHpiFumiServiceImpactGet; + saHpiFumiSourceSetPtr saHpiFumiSourceSet; + saHpiFumiSourceInfoValidateStartPtr saHpiFumiSourceInfoValidateStart; + saHpiFumiSourceInfoGetPtr saHpiFumiSourceInfoGet; + saHpiFumiSourceComponentInfoGetPtr saHpiFumiSourceComponentInfoGet; + saHpiFumiTargetInfoGetPtr saHpiFumiTargetInfoGet; + saHpiFumiTargetComponentInfoGetPtr saHpiFumiTargetComponentInfoGet; + saHpiFumiLogicalTargetInfoGetPtr saHpiFumiLogicalTargetInfoGet; + saHpiFumiLogicalTargetComponentInfoGetPtr saHpiFumiLogicalTargetComponentInfoGet; + saHpiFumiBackupStartPtr saHpiFumiBackupStart; + saHpiFumiBankBootOrderSetPtr ... [truncated message content] |
From: <av...@us...> - 2010-10-28 16:01:25
|
Revision: 7153 http://openhpi.svn.sourceforge.net/openhpi/?rev=7153&view=rev Author: avpak Date: 2010-10-28 16:01:18 +0000 (Thu, 28 Oct 2010) Log Message: ----------- Fix for #3074867 Modified Paths: -------------- openhpi/trunk/docs/man/hpi_shell.pod.1 openhpi/trunk/hpi_shell/hpi_cmd.c Modified: openhpi/trunk/docs/man/hpi_shell.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpi_shell.pod.1 2010-10-25 13:39:47 UTC (rev 7152) +++ openhpi/trunk/docs/man/hpi_shell.pod.1 2010-10-28 16:01:18 UTC (rev 7153) @@ -20,7 +20,7 @@ =over 2 - -c Use the specified openhpi config file + -c Use the specified openhpi client config file -e Show short events, discover after subscribe -f Read commands from "file" rather than standard input -n Connect to the OpenHPI daemon on "hostname" rather than the Modified: openhpi/trunk/hpi_shell/hpi_cmd.c =================================================================== --- openhpi/trunk/hpi_shell/hpi_cmd.c 2010-10-25 13:39:47 UTC (rev 7152) +++ openhpi/trunk/hpi_shell/hpi_cmd.c 2010-10-28 16:01:18 UTC (rev 7153) @@ -32,7 +32,7 @@ while ( (c = getopt( argc, argv,"c:ef:xn:?")) != EOF ) switch(c) { case 'c': - setenv("OPENHPI_CONF", optarg, 1); + setenv("OPENHPICLIENT_CONF", optarg, 1); break; case 'e': eflag = 1; @@ -48,7 +48,7 @@ break; default: printf("Usage: %s [-c <cfgfile>][-e][-f <file>][-n <hostname>]\n", argv[0]); - printf(" -c <cfgfile> - use passed file as configuration file\n"); + printf(" -c <cfgfile> - use passed file as client configuration file\n"); printf(" -e - show short events, discover after subscribe\n"); printf(" -f <file> - execute command file\n"); printf(" -n <hostname> use passed hostname as OpenHPI daemon host\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-10-29 13:49:51
|
Revision: 7154 http://openhpi.svn.sourceforge.net/openhpi/?rev=7154&view=rev Author: avpak Date: 2010-10-29 13:49:44 +0000 (Fri, 29 Oct 2010) Log Message: ----------- Feature request #3097473 Modified Paths: -------------- openhpi/trunk/docs/man/hpi_shell.pod.1 openhpi/trunk/hpi_shell/commands.c openhpi/trunk/hpi_shell/hpi_cmd.c openhpi/trunk/hpi_shell/hpi_cmd.h openhpi/trunk/hpi_shell/session.c Modified: openhpi/trunk/docs/man/hpi_shell.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpi_shell.pod.1 2010-10-28 16:01:18 UTC (rev 7153) +++ openhpi/trunk/docs/man/hpi_shell.pod.1 2010-10-29 13:49:44 UTC (rev 7154) @@ -5,7 +5,7 @@ =head1 SYNOPSIS -hpi_shell [-c <cfgfile>] [-e] [-f <file>] [-n <hostname>] +hpi_shell [-D id] [-c <cfgfile>] [-e] [-f <file>] [-n <hostname>] =head1 DESCRIPTION @@ -20,6 +20,7 @@ =over 2 + -D nn Select domain id nn -c Use the specified openhpi client config file -e Show short events, discover after subscribe -f Read commands from "file" rather than standard input Modified: openhpi/trunk/hpi_shell/commands.c =================================================================== --- openhpi/trunk/hpi_shell/commands.c 2010-10-28 16:01:18 UTC (rev 7153) +++ openhpi/trunk/hpi_shell/commands.c 2010-10-29 13:49:44 UTC (rev 7154) @@ -1213,7 +1213,7 @@ if (rv != SA_OK) { printf("saHpiSessionClose error %s\n", oh_lookup_error(rv)); } - if (open_session(eflag) != 0) { + if (open_session(Domain->domainId, eflag) != 0) { printf("Can not open session\n"); return(HPI_SHELL_CMD_ERROR); } Modified: openhpi/trunk/hpi_shell/hpi_cmd.c =================================================================== --- openhpi/trunk/hpi_shell/hpi_cmd.c 2010-10-28 16:01:18 UTC (rev 7153) +++ openhpi/trunk/hpi_shell/hpi_cmd.c 2010-10-29 13:49:44 UTC (rev 7154) @@ -11,10 +11,12 @@ * * Authors: * Racing Guo <rac...@in...> + * * Changes: * 11.30.2004 - Kouzmich: porting to HPI-B + * 28.10.2010 - Anton Pak: fixed -c command line argument + * 28.10.2010 - Anton Pak: added -D command line argument * - * */ #include <stdio.h> @@ -28,9 +30,18 @@ int main(int argc, char **argv) { int c, eflag = 0; + SaHpiBoolT printusage = SAHPI_FALSE; + SaHpiDomainIdT domainId = SAHPI_UNSPECIFIED_DOMAIN_ID; - while ( (c = getopt( argc, argv,"c:ef:xn:?")) != EOF ) + while ( (c = getopt( argc, argv,"D:c:ef:xn:?")) != EOF ) { switch(c) { + case 'D': + if (optarg) { + domainId = atoi(optarg); + } else { + printusage = SAHPI_TRUE; + } + break; case 'c': setenv("OPENHPICLIENT_CONF", optarg, 1); break; @@ -47,16 +58,23 @@ setenv("OPENHPI_DAEMON_HOST", optarg, 1); break; default: - printf("Usage: %s [-c <cfgfile>][-e][-f <file>][-n <hostname>]\n", argv[0]); - printf(" -c <cfgfile> - use passed file as client configuration file\n"); - printf(" -e - show short events, discover after subscribe\n"); - printf(" -f <file> - execute command file\n"); - printf(" -n <hostname> use passed hostname as OpenHPI daemon host\n"); - return(1); + printusage = SAHPI_TRUE; } + } + if (printusage != SAHPI_FALSE) { + printf("Usage: %s [-c <cfgfile>][-e][-f <file>][-n <hostname>]\n", argv[0]); + printf(" -D <did> - select domain id\n"); + printf(" -c <cfgfile> - use passed file as client configuration file\n"); + printf(" -e - show short events, discover after subscribe\n"); + printf(" -f <file> - execute command file\n"); + printf(" -x - display debug messages\n"); + printf(" -n <hostname> - use passed hostname as OpenHPI daemon host\n"); + return 1; + } + domainlist = (GSList *)NULL; - if (open_session(eflag) == -1) + if (open_session(domainId, eflag) == -1) return(1); cmd_shell(); close_session(); Modified: openhpi/trunk/hpi_shell/hpi_cmd.h =================================================================== --- openhpi/trunk/hpi_shell/hpi_cmd.h 2010-10-28 16:01:18 UTC (rev 7153) +++ openhpi/trunk/hpi_shell/hpi_cmd.h 2010-10-29 13:49:44 UTC (rev 7154) @@ -141,7 +141,7 @@ extern ret_code_t inv_block_setfield(void); extern ret_code_t list_sensor(void); extern ret_code_t open_file(char *path); -extern int open_session(int eflag); +extern int open_session(SaHpiDomainIdT domainId, int eflag); extern void restore_term_flags(void); extern int run_command(void); extern ret_code_t sen_block(void); Modified: openhpi/trunk/hpi_shell/session.c =================================================================== --- openhpi/trunk/hpi_shell/session.c 2010-10-28 16:01:18 UTC (rev 7153) +++ openhpi/trunk/hpi_shell/session.c 2010-10-29 13:49:44 UTC (rev 7154) @@ -225,7 +225,7 @@ return(0); } -int open_session(int eflag) +int open_session(SaHpiDomainIdT domainId, int eflag) { Domain_t *par_domain; @@ -236,7 +236,7 @@ thread_mutex = g_mutex_new(); par_domain = (Domain_t *)malloc(sizeof(Domain_t)); memset(par_domain, 0, sizeof(Domain_t)); - par_domain->domainId = SAHPI_UNSPECIFIED_DOMAIN_ID; + par_domain->domainId = domainId; if (get_sessionId(par_domain) != SA_OK) return(-1); // set current domain Domain = par_domain; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-11-12 11:47:20
|
Revision: 7160 http://openhpi.svn.sourceforge.net/openhpi/?rev=7160&view=rev Author: avpak Date: 2010-11-12 11:47:13 +0000 (Fri, 12 Nov 2010) Log Message: ----------- Feature request #3094865 Modified Paths: -------------- openhpi/trunk/baselib/oh_client_session.cpp openhpi/trunk/transport/strmsock.cpp openhpi/trunk/transport/strmsock.h Modified: openhpi/trunk/baselib/oh_client_session.cpp =================================================================== --- openhpi/trunk/baselib/oh_client_session.cpp 2010-11-09 14:25:22 UTC (rev 7159) +++ openhpi/trunk/baselib/oh_client_session.cpp 2010-11-12 11:47:13 UTC (rev 7160) @@ -96,6 +96,10 @@ delete connx; return SA_ERR_HPI_NO_RESPONSE; } + // TODO configuration file, env vars? + connx->EnableKeepAliveProbes(/* keepalive_time*/ 1, + /* keepalive_intvl */ 1, + /* keepalive_probes */ 3 ); *pinst = connx; dbg("Client instance created"); Modified: openhpi/trunk/transport/strmsock.cpp =================================================================== --- openhpi/trunk/transport/strmsock.cpp 2010-11-09 14:25:22 UTC (rev 7159) +++ openhpi/trunk/transport/strmsock.cpp 2010-11-12 11:47:13 UTC (rev 7160) @@ -22,6 +22,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> +#include <netinet/tcp.h> #include <arpa/inet.h> #include <sys/ioctl.h> #include <netdb.h> @@ -268,7 +269,51 @@ return(FALSE); } +bool cstrmsock::EnableKeepAliveProbes( int keepalive_time, + int keepalive_intvl, + int keepalive_probes ) +{ +#ifdef __linux__ + int rc; + int optval; + optval = 1; + rc = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)); + if ( rc != 0 ) { + err( "failed to set SO_KEEPALIVE option, errno = %d\n", errno ); + return true; + } + optval = keepalive_time; + rc = setsockopt(s, SOL_TCP, TCP_KEEPIDLE, &optval, sizeof(optval)); + if ( rc != 0 ) { + err( "failed to set TCP_KEEPIDLE option, errno = %d\n", errno ); + return true; + } + optval = keepalive_intvl; + rc = setsockopt(s, SOL_TCP, TCP_KEEPINTVL, &optval, sizeof(optval)); + if ( rc != 0 ) { + err( "failed to set TCP_KEEPINTVL option, errno = %d\n", errno ); + return true; + } + optval = keepalive_probes; + rc = setsockopt(s, SOL_TCP, TCP_KEEPCNT, &optval, sizeof(optval)); + if ( rc != 0 ) { + err( "failed to set TCP_KEEPCNT option, errno = %d\n", errno ); + return true; + } + + return false; + +#else + + err( "TCP Keep-Alive Probes are not supported\n" ); + + return true; + +#endif /* __linux__ */ +} + + /*--------------------------------------------------------------------*/ /* Stream Sockets server class methods */ /*--------------------------------------------------------------------*/ Modified: openhpi/trunk/transport/strmsock.h =================================================================== --- openhpi/trunk/transport/strmsock.h 2010-11-09 14:25:22 UTC (rev 7159) +++ openhpi/trunk/transport/strmsock.h 2010-11-12 11:47:13 UTC (rev 7160) @@ -107,6 +107,19 @@ cstrmsock (); ~cstrmsock (); bool Open (const char *, unsigned short); + + /*********************** + * TCP Keep-Alive + * + * keepalive_time - interval(sec) between the last data packet sent and + * the first keepalive probe + * keepalive_intvl - interval(sec) between subsequential keepalive probes + * keepalive_probes - number of unacknowledged probes to send before + * considering the connection dead + **********************/ + bool EnableKeepAliveProbes( int keepalive_time, + int keepalive_intvl, + int keepalive_probes ); }; typedef cstrmsock *pcstrmsock; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-11-25 10:54:49
|
Revision: 7167 http://openhpi.svn.sourceforge.net/openhpi/?rev=7167&view=rev Author: ulikleber Date: 2010-11-25 10:54:42 +0000 (Thu, 25 Nov 2010) Log Message: ----------- feature 30225777: support for domain discovery New function oHpiDomainEntryGet and new client ohdomainlist Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/baselib/oh_client_conf.c openhpi/trunk/baselib/oh_client_conf.h openhpi/trunk/clients/Makefile.am openhpi/trunk/docs/man/Makefile.am openhpi/trunk/docs/man/hpi_shell.pod.1 openhpi/trunk/docs/man/hpialarms.pod.1 openhpi/trunk/docs/man/hpidomain.pod.1 openhpi/trunk/docs/man/hpiel.pod.1 openhpi/trunk/docs/man/hpievents.pod.1 openhpi/trunk/docs/man/hpifan.pod.1 openhpi/trunk/docs/man/hpigensimdata.pod.1 openhpi/trunk/docs/man/hpiinv.pod.1 openhpi/trunk/docs/man/hpionIBMblade.pod.1 openhpi/trunk/docs/man/hpipower.pod.1 openhpi/trunk/docs/man/hpireset.pod.1 openhpi/trunk/docs/man/hpisensor.pod.1 openhpi/trunk/docs/man/hpisettime.pod.1 openhpi/trunk/docs/man/hpithres.pod.1 openhpi/trunk/docs/man/hpitop.pod.1 openhpi/trunk/docs/man/hpitree.pod.1 openhpi/trunk/docs/man/hpiwdt.pod.1 openhpi/trunk/docs/man/ohhandler.pod.1 openhpi/trunk/docs/man/ohparam.pod.1 openhpi/trunk/include/oHpi.h openhpi/trunk/openhpi.spec.in openhpi/trunk/openhpid/ohpi.c Added Paths: ----------- openhpi/trunk/clients/ohdomainlist.c openhpi/trunk/docs/man/ohdomainlist.pod.1 Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/baselib/oh_client.cpp 2010-11-25 10:54:42 UTC (rev 7167) @@ -6310,4 +6310,44 @@ return oh_add_domain_conf_by_id(domain_id, buf, port); } +/*----------------------------------------------------------------------------*/ +/* oHpiDomainEntryGet */ +/*----------------------------------------------------------------------------*/ +SaErrorT SAHPI_API oHpiDomainEntryGet ( + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEntryIdT *NextEntryId, + SAHPI_OUT oHpiDomainEntryT *DomainEntry ) +{ + SaHpiDomainIdT did; + + if (!NextEntryId || !DomainEntry) { + return SA_ERR_HPI_INVALID_PARAMS; + } + /* Function may be called outside sessions, so we may need to initialize */ + oh_client_init(); + + if (EntryId == SAHPI_FIRST_ENTRY) // get first valid domain id + did = oh_getnext_domainid (SAHPI_UNSPECIFIED_DOMAIN_ID); + else // EntryId already must be a valid domain id + did = (SaHpiDomainIdT) EntryId; + + const oh_domain_conf *entry = oh_get_domain_conf ( did ); + if (entry == NULL) { // no config for did found + return SA_ERR_HPI_NOT_PRESENT; + } + + DomainEntry->id = did; + if (oh_init_textbuffer(&DomainEntry->daemonhost) != SA_OK) return SA_ERR_HPI_INVALID_PARAMS; + if (oh_append_textbuffer(&DomainEntry->daemonhost, entry->host)!= SA_OK) + return SA_ERR_HPI_INVALID_PARAMS; + DomainEntry->port = entry->port; + + *NextEntryId = (SaHpiEntryIdT) oh_getnext_domainid (did); // will return SAHPI_LAST_ENTRY + // if no other domain is found. + + return SA_OK; + +} + + Modified: openhpi/trunk/baselib/oh_client_conf.c =================================================================== --- openhpi/trunk/baselib/oh_client_conf.c 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/baselib/oh_client_conf.c 2010-11-25 10:54:42 UTC (rev 7167) @@ -164,6 +164,33 @@ return SA_OK; } +SaHpiDomainIdT oh_getnext_domainid (SaHpiDomainIdT did) +{ + int nextdid = SAHPI_UNSPECIFIED_DOMAIN_ID; + int startdid = did; + oh_client_conf_init(); //TODO: if this is correct here, the other functions need it, too! + + g_static_rec_mutex_lock(&ohc_lock); + + // get all known domain ids and sort them + GList *keys = 0; + g_hash_table_foreach(ohc_domains, extract_keys, &keys); + keys = g_list_sort(keys, (GCompareFunc)compare_keys); + + // search first domain id > did + GList *item; + item = keys; + while (item != NULL && nextdid <= startdid) { + nextdid = *(const SaHpiDomainIdT *)(item->data); + item = item->next; + } + + g_list_free(keys); + g_static_rec_mutex_unlock(&ohc_lock); + if (startdid==nextdid) return SAHPI_UNSPECIFIED_DOMAIN_ID; + return nextdid; +} + static void extract_keys(gpointer key, gpointer val, gpointer user_data) { GList ** key_list = (GList **)(user_data); Modified: openhpi/trunk/baselib/oh_client_conf.h =================================================================== --- openhpi/trunk/baselib/oh_client_conf.h 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/baselib/oh_client_conf.h 2010-11-25 10:54:42 UTC (rev 7167) @@ -45,6 +45,7 @@ const char *host, unsigned short port); +SaHpiDomainIdT oh_getnext_domainid (SaHpiDomainIdT did); #ifdef __cplusplus } /* extern "C" */ Modified: openhpi/trunk/clients/Makefile.am =================================================================== --- openhpi/trunk/clients/Makefile.am 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/clients/Makefile.am 2010-11-25 10:54:42 UTC (rev 7167) @@ -28,6 +28,7 @@ hpitop \ hpisettime \ hpionIBMblade \ + ohdomainlist \ ohhandler \ ohparam @@ -81,6 +82,9 @@ hpionIBMblade_SOURCES = hpionIBMblade.c $(CLIENTS_SRC) hpionIBMblade_LDADD = $(COMMONLIBS) +ohdomainlist_SOURCES = ohdomainlist.c $(CLIENTS_SRC) +ohdomainlist_LDADD = $(COMMONLIBS) + ohhandler_SOURCES = ohhandler.c $(CLIENTS_SRC) ohhandler_LDADD = $(COMMONLIBS) Added: openhpi/trunk/clients/ohdomainlist.c =================================================================== --- openhpi/trunk/clients/ohdomainlist.c (rev 0) +++ openhpi/trunk/clients/ohdomainlist.c 2010-11-25 10:54:42 UTC (rev 7167) @@ -0,0 +1,230 @@ +/* -*- linux-c -*- + * + * Copyright (C) Copyright Nokia Siemens Networks 2010 + * + * This program 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. This + * file and program are licensed under a BSD style license. See + * the Copying file included with the OpenHPI distribution for + * full licensing terms. + * + * Authors: + * Ulrich Kleber <uli...@us...> + * + * Log: + * Start from hpitop.c + * This routine display highlevel domain topology for a managed + * openHPI complex + * + * Changes: + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <getopt.h> +#include <uuid/uuid.h> +#include <SaHpi.h> +#include <oHpi.h> +#include <oh_utils.h> +#include <oh_clients.h> + +#define OH_SVN_REV "$Revision: 7112 $" + +/* + * Function prototypes + */ +static SaErrorT show_domains(void); +static SaErrorT print_domaininfo(SaHpiDomainInfoT info, int shift); + +/* + * Globals for this driver + */ +int fdebug = 0; +int fverbose = 0; + + +/* + * Main + */ +int +main(int argc, char **argv) +{ + SaHpiBoolT printusage = FALSE; + int c; + + oh_prog_version(argv[0], OH_SVN_REV); + while ( (c = getopt( argc, argv,"vx?")) != EOF ) { + switch(c) { + case 'x': fdebug = 1; break; + case 'v': fverbose = 1; break; + default: printusage = TRUE; break; + } + } + if (printusage == TRUE) + { + printf("\n\tUsage: %s [-option]\n\n", argv[0]); + printf("\t (No Option) Display domains known to baselib \n"); + printf("\t -v Display in verbose mode including " + "domain info for directly related domains\n"); + printf("\t -x Display debug messages\n"); + printf("\n\n\n\n"); + exit(1); + } + + show_domains(); + + exit(0); +} + + +/* + * + */ +static +SaErrorT show_domains(void) +{ + SaErrorT rv = SA_OK; + oHpiDomainEntryT domainentry; + SaHpiEntryIdT domainentryid; + SaHpiEntryIdT nextdomainentryid; + SaHpiDomainInfoT relateddomaininfo; + SaHpiDomainIdT relateddomainid = SAHPI_UNSPECIFIED_DOMAIN_ID; + SaHpiSessionIdT relatedsessionid; + + /* walk the Domain Table */ + domainentryid = SAHPI_FIRST_ENTRY; + do { + if (fdebug) printf("oHpiDomainEntryGet called with entry=%u\n", + domainentryid); + rv = oHpiDomainEntryGet( + domainentryid,&nextdomainentryid,&domainentry); + + if ((rv != SA_OK) || fdebug) + printf("oHpiDomainEntryGet returns %s\n", + oh_lookup_error(rv)); + + if (rv == SA_OK ) { + if (fdebug) printf("oHpiDomainEntryGet provides domainid=%u," + " nextentryid=%u\n", + domainentry.id, nextdomainentryid); + + printf("Domain defined on host(%s:%u) with id: %u\n", + (char *)domainentry.daemonhost.Data, + domainentry.port, + domainentry.id); + + if (fverbose) { + /* display the domaininfo for that related domain */ + relateddomainid = domainentry.id; + rv = saHpiSessionOpen(relateddomainid, + &relatedsessionid,NULL); + if (rv != SA_OK) { + printf("Domain %u cannot be opened\n", + relateddomainid); + continue; + } + if (fdebug) { + printf("saHpiSessionOpen returns with SessionId %u\n", + relatedsessionid); + printf("saHpiDomainInfoGet for domain %u\n", + relateddomainid); + } + rv = saHpiDomainInfoGet(relatedsessionid, + &relateddomaininfo); + if (rv!=SA_OK) { + printf("\nDomaininfo of domain %u cannot be " + "retrieved.\n", + relateddomainid); + if (fdebug) + printf("saHpiDomainInfoGet for domain " + "%u failed with returncode %s\n", + relateddomainid, oh_lookup_error(rv)); + } + else { + /* Print info about related domain */ + rv = print_domaininfo(relateddomaininfo,1); + } + + rv = saHpiSessionClose(relatedsessionid); + if (fdebug) + printf("saHpiSessionClose returns %s\n", + oh_lookup_error(rv)); + + } //verbose + } + else if (rv == SA_ERR_HPI_NOT_PRESENT) { + if (domainentryid == SAHPI_FIRST_ENTRY) + printf("Domain list is empty. \n"); + else printf("Internal error while walking the Domainlist\n"); + } + else printf("Internal error while walking the Domainlist\n"); + + domainentryid = nextdomainentryid; + } while ((rv == SA_OK) && (domainentryid != SAHPI_LAST_ENTRY)); + + return(rv); +} + +/* +* +*/ +static SaErrorT print_domaininfo(SaHpiDomainInfoT info, int shift) +{ + SaHpiTextBufferT buf; + SaErrorT rv; + int i; + + for (i=0;i<shift;i++)printf(" "); + printf("Domain: %u Capabil: 0x%x IsPeer: %d Tag: ", + info.DomainId, info.DomainCapabilities, + info.IsPeer); + rv = oh_print_text(&(info.DomainTag)); + + printf("\n"); + for (i=0;i<shift;i++)printf(" "); + printf(" Guid: "); + for (i=0; i<16; i++) { + if ((i == 4) || (i == 6) || (i == 8) || (i == 10)) printf("-"); + printf("%02x",info.Guid[i]); + } + + printf("\n"); + rv = oh_decode_time(info.DrtUpdateTimestamp, &buf); + for (i=0;i<shift;i++)printf(" "); + printf(" DRT update count: %d DRT Timestamp : ", + info.DrtUpdateCount); + oh_print_text(&buf); + printf("\n"); + + rv = oh_decode_time(info.RptUpdateTimestamp, &buf); + for (i=0;i<shift;i++)printf(" "); + printf(" RPT update count: %d RPT Timestamp : ", + info.RptUpdateCount); + oh_print_text(&buf); + printf("\n"); + + rv = oh_decode_time(info.DatUpdateTimestamp, &buf); + for (i=0;i<shift;i++)printf(" "); + printf(" DAT update count: %d DAT Timestamp : ", + info.DatUpdateCount); + oh_print_text(&buf); + printf("\n"); + + for (i=0;i<shift;i++)printf(" "); + printf(" ActiveAlarms: %d CriticalAlarms: %d " + "Major: %d Minor: %d\n", + info.ActiveAlarms, info.CriticalAlarms, info.MajorAlarms, + info.MinorAlarms); + for (i=0;i<shift;i++)printf(" "); + printf(" Limit: %d DatOverflow : %d\n", + info.DatUserAlarmLimit, info.DatOverflow); + + return rv; +} + + +/* end hpidomain.c */ Modified: openhpi/trunk/docs/man/Makefile.am =================================================================== --- openhpi/trunk/docs/man/Makefile.am 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/Makefile.am 2010-11-25 10:54:42 UTC (rev 7167) @@ -73,6 +73,7 @@ hpisensor.1 hpitop.1 \ hpidomain.1 hpigensimdata.1 \ ohhandler.1 ohparam.1 \ + ohdomainlist.1 \ hpi_shell.1 clean-local: am_config_clean-local Modified: openhpi/trunk/docs/man/hpi_shell.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpi_shell.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpi_shell.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -36,7 +36,7 @@ hpidomain hpigensimdata hpireset hpitop hpiel hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpialarms.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpialarms.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpialarms.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -62,7 +62,7 @@ hpiel hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt hpifan hpipower hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpidomain.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpidomain.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpidomain.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -31,7 +31,7 @@ hpiel hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt hpifan hpipower hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam Modified: openhpi/trunk/docs/man/hpiel.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiel.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpiel.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -70,7 +70,7 @@ hpidomain hpiinv hpisensor hpitree hpievents hpionIBMblade hpisettime hpiwdt hpifan hpipower hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpievents.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpievents.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpievents.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -55,7 +55,7 @@ hpidomain hpiinv hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpifan hpipower hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpifan.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpifan.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpifan.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -31,7 +31,7 @@ hpidomain hpiinv hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpievents hpipower hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpigensimdata.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpigensimdata.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpigensimdata.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -33,7 +33,7 @@ hpidomain hpiinv hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpievents hpipower hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpiinv.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiinv.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpiinv.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -42,7 +42,7 @@ hpidomain hpigensimdata hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpievents hpipower hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpionIBMblade.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpionIBMblade.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpionIBMblade.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -55,7 +55,7 @@ hpidomain hpigensimdata hpisensor hpitree hpiel hpiiinv hpisettime hpiwdt hpievents hpipower hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpipower.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpipower.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpipower.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -34,7 +34,7 @@ hpidomain hpigensimdata hpisensor hpitree hpiel hpiiinv hpisettime hpiwdt hpievents hpionIBMblade hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpireset.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpireset.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpireset.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -36,7 +36,7 @@ hpidomain hpigensimdata hpisensor hpitree hpiel hpiiinv hpisettime hpiwdt hpievents hpionIBMblade hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpisensor.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisensor.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpisensor.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -33,7 +33,7 @@ hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisettime hpiwdt hpievents hpionIBMblade hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpisettime.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpisettime.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpisettime.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -30,7 +30,7 @@ hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpithres - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpithres.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpithres.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpithres.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -28,7 +28,7 @@ hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpisettime - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpitop.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitop.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpitop.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -39,7 +39,7 @@ hpidomain hpigensimdata hpireset hpitree hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpisettime - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpitree.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpitree.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpitree.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -41,7 +41,7 @@ hpidomain hpigensimdata hpireset hpitop hpiel hpiiinv hpisensor hpiwdt hpievents hpionIBMblade hpisettime - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/hpiwdt.pod.1 =================================================================== --- openhpi/trunk/docs/man/hpiwdt.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/hpiwdt.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -33,7 +33,7 @@ hpidomain hpigensimdata hpireset hpitop hpiel hpiiinv hpisensor hpitree hpievents hpionIBMblade hpisettime - ohhandler ohparam + ohdomainlist ohhandler ohparam =head1 AUTHORS Added: openhpi/trunk/docs/man/ohdomainlist.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohdomainlist.pod.1 (rev 0) +++ openhpi/trunk/docs/man/ohdomainlist.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -0,0 +1,47 @@ +=head1 NAME + +ohdomainlist - A openhpi sample application that shows information about domains on the +level of the openhpi base library. + +=head1 SYNOPSIS + +hpidomain [-D id] [-t tag] [-v -x] + +=head1 DESCRIPTION + +ohdomainlist displays the list of domains known to the openhpi base library. +In verbose mode, it displays more information about those domains. +Clients can only access domains known to the library. + +Please note that ohdomainlist can only display the domains defined in the +openhpiclient.conf file as specified in the OPENHPICLIEN_CONF environment +variable. +Dynamic changes of the domain list done using the oHpiDomainAdd and oHpiDomainAddById +API are valid only for the life-time of the client library. + +=over 2 + + (No Option) Display domain info + -v Verbose: Display domain info for all domains found in DRT + -x Display debug messages + +=back + +=head1 SEE ALSO + + hpi_shell + + hpialarms hpifan hpipower hpithres + hpidomain hpigensimdata hpireset hpitop + hpiel hpiiinv hpisensor hpitree + hpievents hpionIBMblade hpisettime hpiwdt + + ohhandler ohparam + + +=head1 AUTHORS + +Authors of this man page: + + Ulrich Kleber (uli...@us...) + Modified: openhpi/trunk/docs/man/ohhandler.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohhandler.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/ohhandler.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -52,7 +52,7 @@ hpidomain hpiinv hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpievents hpipower hpithres - ohparam + ohdomainlist ohparam =head1 AUTHORS Modified: openhpi/trunk/docs/man/ohparam.pod.1 =================================================================== --- openhpi/trunk/docs/man/ohparam.pod.1 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/docs/man/ohparam.pod.1 2010-11-25 10:54:42 UTC (rev 7167) @@ -32,7 +32,7 @@ hpidomain hpiinv hpisensor hpitree hpiel hpionIBMblade hpisettime hpiwdt hpievents hpipower hpithres - ohhandler + ohdomainlist ohhandler =head1 AUTHORS Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/include/oHpi.h 2010-11-25 10:54:42 UTC (rev 7167) @@ -43,6 +43,14 @@ int load_failed; } oHpiHandlerInfoT; +typedef struct { + SaHpiDomainIdT id; + SaHpiTextBufferT daemonhost; + SaHpiUint16T port; +} oHpiDomainEntryT; + + + typedef enum { OHPI_ON_EP = 1, OHPI_LOG_ON_SEV, @@ -128,7 +136,13 @@ SAHPI_IN SaHpiDomainIdT domain_id, SAHPI_IN const SaHpiTextBufferT *host, SAHPI_IN SaHpiUint16T port ); +SaErrorT SAHPI_API oHpiDomainEntryGet ( + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEntryIdT *NextEntryId, + SAHPI_OUT oHpiDomainEntryT *DomainEntry ); + + #define OHPI_VERSION_GET(v, VER) \ { \ char version[] = VER; \ Modified: openhpi/trunk/openhpi.spec.in =================================================================== --- openhpi/trunk/openhpi.spec.in 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/openhpi.spec.in 2010-11-25 10:54:42 UTC (rev 7167) @@ -307,6 +307,7 @@ %{_bindir}/hpi* %{_bindir}/ohhandler %{_bindir}/ohparam +%{_bindir}/ohdomainlist %{_mandir}/man1/*.1* %{_sysconfdir}/openhpi/openhpiclient.conf Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-11-23 16:15:49 UTC (rev 7166) +++ openhpi/trunk/openhpid/ohpi.c 2010-11-25 10:54:42 UTC (rev 7167) @@ -426,3 +426,25 @@ } +/** + * oHpiDomainEntryGet + * @EntryId: id of an entry of the library's domain table + * or SAHPI_FIRST_ENTRY + * @NextEntryId: id of the next entry of the library's domain table + * or SAHPI_LAST_ENTRY + * @DomainEntry: configuration info of the domain listed in + * the entry identified by NextEntryId + * + * Returns: SA_OK on success and fills DomainEntry + * + * Currently only available in client library, but not in daemon + **/ +SaErrorT SAHPI_API oHpiDomainEntryGet ( + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEntryIdT *NextEntryId, + SAHPI_OUT oHpiDomainEntryT *DomainEntry ) +{ + return SA_ERR_HPI_UNSUPPORTED_API; +} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-11-25 12:33:59
|
Revision: 7168 http://openhpi.svn.sourceforge.net/openhpi/?rev=7168&view=rev Author: ulikleber Date: 2010-11-25 12:33:50 +0000 (Thu, 25 Nov 2010) Log Message: ----------- fix for Bug 3118202 Paramter checks on oHpi APIs small correction on last commit in Makefile. Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/docs/man/Makefile.am openhpi/trunk/openhpid/ohpi.c Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-11-25 10:54:42 UTC (rev 7167) +++ openhpi/trunk/baselib/oh_client.cpp 2010-11-25 12:33:50 UTC (rev 7168) @@ -5888,6 +5888,8 @@ if (!config || !id) return SA_ERR_HPI_INVALID_PARAMS; + if (g_hash_table_size(config)==0) + return SA_ERR_HPI_INVALID_PARAMS; err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; @@ -5932,6 +5934,9 @@ char cmd[] = "oHpiHandlerDestroy"; pcstrmsock pinst = NULL; + if (id == 0) + return SA_ERR_HPI_INVALID_PARAMS; + err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; @@ -5972,6 +5977,11 @@ pcstrmsock pinst = NULL; oHpiHandlerConfigT config; + if (id == 0 || !info || !conf_params) + return SA_ERR_HPI_INVALID_PARAMS; + if (g_hash_table_size(conf_params)!=0) + return SA_ERR_HPI_INVALID_PARAMS; + err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; @@ -6019,6 +6029,9 @@ char cmd[] = "oHpiHandlerGetNext"; pcstrmsock pinst = NULL; + if (!next_id) + return SA_ERR_HPI_INVALID_PARAMS; + err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; @@ -6056,12 +6069,14 @@ char cmd[] = "oHpiHandlerFind"; pcstrmsock pinst = NULL; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; + if (!id || !rid) + return SA_ERR_HPI_INVALID_PARAMS; + err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; - if (!id || !sid || !rid) { - return SA_ERR_HPI_INVALID_PARAMS; - } *id = 0; //Initialize output var cHpiMarshal *hm = HpiMarshalFind(eFoHpiHandlerFind); @@ -6103,9 +6118,8 @@ err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; - if (!id) { - return SA_ERR_HPI_INVALID_PARAMS; - } + if (id == 0) + return SA_ERR_HPI_INVALID_PARAMS; cHpiMarshal *hm = HpiMarshalFind(eFoHpiHandlerRetry); pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerRetry, hm->m_request_len); @@ -6145,6 +6159,9 @@ char cmd[] = "oHpiGlobalParamGet"; pcstrmsock pinst = NULL; + if (!param) + return SA_ERR_HPI_INVALID_PARAMS; + err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; @@ -6182,6 +6199,9 @@ char cmd[] = "oHpiGlobalParamSet"; pcstrmsock pinst = NULL; + if (!param) + return SA_ERR_HPI_INVALID_PARAMS; + err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; @@ -6224,11 +6244,8 @@ err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); if (err) return err; - if (!id) { - return SA_ERR_HPI_INVALID_PARAMS; - } else if (!event) { - return SA_ERR_HPI_INVALID_PARAMS; - } + if (id == 0 || !event || !rpte || !rdr) + return SA_ERR_HPI_INVALID_PARAMS; cHpiMarshal *hm = HpiMarshalFind(eFoHpiInjectEvent); pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiInjectEvent, hm->m_request_len); Modified: openhpi/trunk/docs/man/Makefile.am =================================================================== --- openhpi/trunk/docs/man/Makefile.am 2010-11-25 10:54:42 UTC (rev 7167) +++ openhpi/trunk/docs/man/Makefile.am 2010-11-25 12:33:50 UTC (rev 7168) @@ -39,6 +39,7 @@ hpisensor.pod.1 hpitop.pod.1 \ hpidomain.pod.1 hpigensimdata.pod.1 \ ohhandler.pod.1 ohparam.pod.1 \ + ohdomainlist.pod.1 \ hpi_shell.pod.1 Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-11-25 10:54:42 UTC (rev 7167) +++ openhpi/trunk/openhpid/ohpi.c 2010-11-25 12:33:50 UTC (rev 7168) @@ -69,10 +69,10 @@ { SaErrorT error = SA_OK; - if (!config || !id) { - err("Invalid parameters."); + if (!config || !id) return SA_ERR_HPI_INVALID_PARAMS; - } + if (g_hash_table_size(config)==0) + return SA_ERR_HPI_INVALID_PARAMS; if (oh_init()) return SA_ERR_HPI_ERROR; @@ -92,7 +92,7 @@ SaErrorT SAHPI_API oHpiHandlerDestroy ( SAHPI_IN oHpiHandlerIdT id ) { - if (!id) + if (id == 0) return SA_ERR_HPI_INVALID_PARAMS; if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; @@ -126,7 +126,7 @@ { struct oh_handler *h = NULL; - if (!id || !info || !conf_params) + if (id == 0 || !info || !conf_params) return SA_ERR_HPI_INVALID_PARAMS; if (g_hash_table_size(conf_params)!=0) return SA_ERR_HPI_INVALID_PARAMS; @@ -152,7 +152,8 @@ //Don't transmit passwords in case the handler has a password in its config if (g_hash_table_lookup(conf_params,"password")) - g_hash_table_replace(conf_params,"password","********"); + g_hash_table_replace(conf_params, + g_strdup("password"), g_strdup("********")); oh_release_handler(h); @@ -176,7 +177,6 @@ SAHPI_OUT oHpiHandlerIdT *next_id ) { if (!next_id) { - err("Invalid parameters."); return SA_ERR_HPI_INVALID_PARAMS; } @@ -190,9 +190,9 @@ /** * oHpiHandlerFind - * @sid: a valid session id - * @rid: resource id - * @id: pointer where handler id found will be placed. + * @sid: IN. a valid session id + * @rid: IN. resource id + * @id: OUT pointer where handler id found will be placed. * * Inputs are the @sid and @rid. @rid corresponds to some resource available * in that session. The function then will return the handler that served such @@ -209,17 +209,20 @@ struct oh_domain *d = NULL; unsigned int *hid = NULL; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; + if (!id || !rid) + return SA_ERR_HPI_INVALID_PARAMS; + OH_CHECK_INIT_STATE(sid); OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ - if (sid == 0 || rid == 0 || !id) { - return SA_ERR_HPI_INVALID_PARAMS; + if (oh_init()) { + oh_release_domain(d); /* Unlock domain */ + return SA_ERR_HPI_INTERNAL_ERROR; } - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; - - OH_GET_DOMAIN(did, d); /* Lock domain */ - hid = (unsigned int *)oh_get_resource_data(&d->rpt, rid); if (hid == NULL) { @@ -362,13 +365,22 @@ struct oh_handler *h = NULL; SaErrorT error = SA_OK; - if (!id) { + if (id == 0) { err("Invalid handler id %d passed",id); return SA_ERR_HPI_INVALID_PARAMS; - } else if (!event) { + } + if (!event) { err("Invalid NULL event passed"); return SA_ERR_HPI_INVALID_PARAMS; } + if (!rpte) { + err("Invalid NULL rpte passed"); + return SA_ERR_HPI_INVALID_PARAMS; + } + if (!rdr) { + err("Invalid NULL rdr passed"); + return SA_ERR_HPI_INVALID_PARAMS; + } if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-11-28 11:14:02
|
Revision: 7172 http://openhpi.svn.sourceforge.net/openhpi/?rev=7172&view=rev Author: avpak Date: 2010-11-28 11:13:55 +0000 (Sun, 28 Nov 2010) Log Message: ----------- Feature request #3121221 Modified Paths: -------------- openhpi/trunk/openhpid/alarm.c openhpi/trunk/openhpid/domain.c openhpi/trunk/openhpid/safhpi.c openhpi/trunk/utils/announcement_utils.c openhpi/trunk/utils/el_utils.c openhpi/trunk/utils/rpt_utils.c openhpi/trunk/utils/sahpi_time_utils.c openhpi/trunk/utils/sahpi_time_utils.h Modified: openhpi/trunk/openhpid/alarm.c =================================================================== --- openhpi/trunk/openhpid/alarm.c 2010-11-27 19:38:27 UTC (rev 7171) +++ openhpi/trunk/openhpid/alarm.c 2010-11-28 11:13:55 UTC (rev 7172) @@ -14,7 +14,6 @@ * */ -#include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -28,14 +27,10 @@ static void __update_dat(struct oh_domain *d) { - struct timeval tv; - if (!d) return; - gettimeofday(&tv, NULL); - d->dat.update_count++; - d->dat.update_timestamp = (SaHpiTimeT) tv.tv_sec * 1000000000 + tv.tv_usec * 1000; + oh_gettimeofday(&d->dat.update_timestamp); } static GSList *__get_alarm_node(struct oh_domain *d, @@ -123,7 +118,6 @@ **/ SaHpiAlarmT *oh_add_alarm(struct oh_domain *d, SaHpiAlarmT *alarm, int fromfile) { - struct timeval tv1; SaHpiAlarmT *a = NULL; struct oh_global_param param = { .type = OPENHPI_DAT_SIZE_LIMIT }; @@ -165,9 +159,7 @@ } } else { a->AlarmId = ++(d->dat.next_id); - gettimeofday(&tv1, NULL); - a->Timestamp = - (SaHpiTimeT) tv1.tv_sec * 1000000000 + tv1.tv_usec * 1000; + oh_gettimeofday(&a->Timestamp); a->Acknowledged = SAHPI_FALSE; } a->AlarmCond.DomainId = d->id; Modified: openhpi/trunk/openhpid/domain.c =================================================================== --- openhpi/trunk/openhpid/domain.c 2010-11-27 19:38:27 UTC (rev 7171) +++ openhpi/trunk/openhpid/domain.c 2010-11-28 11:13:55 UTC (rev 7172) @@ -22,7 +22,6 @@ #include <oh_event.h> #include <oh_utils.h> #include <string.h> -#include <sys/time.h> #define domains_lock() g_static_rec_mutex_lock(&oh_domains.lock) #define domains_unlock() g_static_rec_mutex_unlock(&oh_domains.lock) @@ -122,7 +121,6 @@ SaHpiBoolT addition) { struct oh_event *e = NULL; - struct timeval tv1; SaHpiDomainEventTypeT type = (addition) ? SAHPI_DOMAIN_REF_ADDED : SAHPI_DOMAIN_REF_REMOVED; @@ -133,9 +131,7 @@ e->event.Severity = SAHPI_INFORMATIONAL; e->event.EventDataUnion.DomainEvent.Type = type; e->event.EventDataUnion.DomainEvent.DomainId = subject_id; - gettimeofday(&tv1, NULL); - e->event.Timestamp = (SaHpiTimeT) tv1.tv_sec * - 1000000000 + tv1.tv_usec * 1000; + oh_gettimeofday(&e->event.Timestamp); dbg("domain %d %s domain %d", subject_id, type == SAHPI_DOMAIN_REF_ADDED ? "added to" : "removed from", target_id); @@ -149,7 +145,6 @@ { struct oh_domain *domain = NULL; SaHpiDrtEntryT *drtentry = NULL; - struct timeval tv1; int found = 0; domain = oh_get_domain(target_id); @@ -195,9 +190,7 @@ } if (addition || found) { - gettimeofday(&tv1, NULL); - domain->drt.update_timestamp = (SaHpiTimeT) tv1.tv_sec * - 1000000000 + tv1.tv_usec * 1000; + oh_gettimeofday(&domain->drt.update_timestamp); domain->drt.update_count++; } oh_release_domain(domain); Modified: openhpi/trunk/openhpid/safhpi.c =================================================================== --- openhpi/trunk/openhpid/safhpi.c 2010-11-27 19:38:27 UTC (rev 7171) +++ openhpi/trunk/openhpid/safhpi.c 2010-11-28 11:13:55 UTC (rev 7172) @@ -27,6 +27,7 @@ #include <SaHpi.h> #include <openhpi.h> #include <oh_threaded.h> +#include <oh_utils.h> #include <sahpimacros.h> /********************************************************************* @@ -1550,11 +1551,7 @@ /* Timestamp the incoming user event * only if it is SAHPI_TIME_UNSPECIFIED */ if (EvtEntry->Timestamp == SAHPI_TIME_UNSPECIFIED) { - struct timeval tv1; - gettimeofday(&tv1, NULL); - EvtEntry->Timestamp = - (SaHpiTimeT) tv1.tv_sec * 1000000000 + - tv1.tv_usec * 1000; + oh_gettimeofday(&EvtEntry->Timestamp); } /* Copy SaHpiEventT into oh_event struct */ e.event = *EvtEntry; Modified: openhpi/trunk/utils/announcement_utils.c =================================================================== --- openhpi/trunk/utils/announcement_utils.c 2010-11-27 19:38:27 UTC (rev 7171) +++ openhpi/trunk/utils/announcement_utils.c 2010-11-28 11:13:55 UTC (rev 7172) @@ -15,18 +15,15 @@ * Renier Morales <re...@op...> */ -#include <stdio.h> -#include <stdlib.h> -#include <glib.h> -#include <fcntl.h> #include <string.h> -#include <unistd.h> -#include <time.h> +#include <glib.h> + #include <SaHpi.h> #include <oh_utils.h> #include <oh_error.h> + /* allocate and initialize an announcement list */ oh_announcement *oh_announcement_create(void) { @@ -59,7 +56,6 @@ SaErrorT oh_announcement_append(oh_announcement *ann, SaHpiAnnouncementT *myann) { oh_ann_entry *entry; - time_t tt1; /* check for valid el params and state */ if (ann == NULL || myann == NULL) { @@ -75,8 +71,7 @@ /* initialize the struct and append the new entry */ entry->annentry.EntryId = ann->nextId++; - time(&tt1); - entry->annentry.Timestamp = ((SaHpiTimeT) tt1) * 1000000000; + oh_gettimeofday(&entry->annentry.Timestamp); entry->annentry.AddedByUser = TRUE; ann->annentries = g_list_append(ann->annentries, entry); Modified: openhpi/trunk/utils/el_utils.c =================================================================== --- openhpi/trunk/utils/el_utils.c 2010-11-27 19:38:27 UTC (rev 7171) +++ openhpi/trunk/utils/el_utils.c 2010-11-28 11:13:55 UTC (rev 7172) @@ -20,7 +20,6 @@ #include <fcntl.h> #include <unistd.h> #include <string.h> -#include <sys/time.h> #include <SaHpi.h> #include <oh_utils.h> @@ -73,7 +72,6 @@ const SaHpiRptEntryT *res) { oh_el_entry *entry; - struct timeval tv; SaHpiTimeT cursystime; /* check for valid el params and state */ @@ -105,8 +103,7 @@ /* Set the event log entry id and timestamp */ entry->event.EntryId = el->nextid++; if (el->gentimestamp) { - gettimeofday(&tv, NULL); - cursystime = (SaHpiTimeT) tv.tv_sec * 1000000000 + tv.tv_usec * 1000; + oh_gettimeofday(&cursystime); el->info.UpdateTimestamp = el->basetime + (cursystime - el->sysbasetime); } else { @@ -134,7 +131,6 @@ { GList *node = NULL; oh_el_entry *entry; - struct timeval tv; SaHpiTimeT cursystime; /* check for valid el params and state */ @@ -173,8 +169,7 @@ /* prepare & prepend the new entry */ entry->event.EntryId = SAHPI_OLDEST_ENTRY + 1; if (el->gentimestamp) { - gettimeofday(&tv, NULL); - cursystime = (SaHpiTimeT) tv.tv_sec * 1000000000 + tv.tv_usec * 1000; + oh_gettimeofday(&cursystime); el->info.UpdateTimestamp = el->basetime + (cursystime - el->sysbasetime); } else { @@ -286,7 +281,6 @@ /* get EL info */ SaErrorT oh_el_info(oh_el *el, SaHpiEventLogInfoT *info) { - struct timeval tv; SaHpiTimeT cursystime; if (el == NULL || info == NULL) { @@ -295,8 +289,7 @@ *info = el->info; info->Entries = g_list_length(el->list); - gettimeofday(&tv, NULL); - cursystime = (SaHpiTimeT) tv.tv_sec * 1000000000 + tv.tv_usec * 1000; + oh_gettimeofday(&cursystime); info->CurrentTime = el->basetime + (cursystime - el->sysbasetime); return SA_OK; @@ -403,14 +396,11 @@ /* set the EL timestamp offset */ SaErrorT oh_el_timeset(oh_el *el, SaHpiTimeT timestamp) { - struct timeval tv; - if (el == NULL || timestamp == SAHPI_TIME_UNSPECIFIED) { return SA_ERR_HPI_INVALID_PARAMS; } - gettimeofday(&tv, NULL); - el->sysbasetime = (SaHpiTimeT) tv.tv_sec * 1000000000 + tv.tv_usec * 1000; + oh_gettimeofday(&el->sysbasetime); el->basetime = timestamp; return SA_OK; Modified: openhpi/trunk/utils/rpt_utils.c =================================================================== --- openhpi/trunk/utils/rpt_utils.c 2010-11-27 19:38:27 UTC (rev 7171) +++ openhpi/trunk/utils/rpt_utils.c 2010-11-28 11:13:55 UTC (rev 7172) @@ -14,7 +14,6 @@ */ #include <string.h> -#include <sys/time.h> #include <oh_utils.h> #include <oh_error.h> @@ -160,18 +159,11 @@ } static void update_rptable(RPTable *table) { - struct timeval tv; - SaHpiTimeT time; - if (!table) { err("ERROR: Cannot work on a null table pointer."); return; } - - gettimeofday(&tv, NULL); - time = (SaHpiTimeT) tv.tv_sec * 1000000000 + tv.tv_usec * 1000; - - table->update_timestamp = time; + oh_gettimeofday(&table->update_timestamp); table->update_count++; } Modified: openhpi/trunk/utils/sahpi_time_utils.c =================================================================== --- openhpi/trunk/utils/sahpi_time_utils.c 2010-11-27 19:38:27 UTC (rev 7171) +++ openhpi/trunk/utils/sahpi_time_utils.c 2010-11-28 11:13:55 UTC (rev 7172) @@ -1,6 +1,7 @@ /* -*- linux-c -*- * * (C) Copyright IBM Corp. 2004 + * (C) Copyright Pigeon Point Systems. 2010 * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -11,19 +12,63 @@ * * Author(s): * Steve Sherman <st...@us...> + * Anton Pak <ant...@pi...> */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <time.h> -#include <sys/time.h> +#include <glib.h> + #include <SaHpi.h> #include <oh_utils.h> #include <oh_error.h> + /** + * oh_localtime: + * @time: SaHpiTimeT time to be converted. + * @tm: Location to store the converted broken-down time. + * + * Converts an SaHpiTimeT time value to broken-down + * time representation. + * + * Returns: + * SA_OK - normal operation. + * SA_ERR_HPI_INVALID_PARAMS - @buffer is NULL. + * SA_ERR_HPI_INTERNAL_ERROR - conversion failed + **/ +SaErrorT oh_localtime(const SaHpiTimeT time, struct tm *tm) +{ + time_t t; + struct tm *tm2; + + if (!tm) { + return(SA_ERR_HPI_INVALID_PARAMS); + } + + t = (time_t)(time / 1000000000); + +#ifndef _WIN32 + tm2 = localtime_r(&t, tm); +#else /* _WIN32 */ + // Windows version of localtime is thread-safe + tm2 = localtime(&t); + if (tm2) { + *tm = *tm2; + } +#endif /* _WIN32 */ + + if (!tm2) { + return SA_ERR_HPI_INTERNAL_ERROR; + } + + return(SA_OK); +} + +/** * oh_decode_time: * @time: SaHpiTimeT time to be converted. * @buffer: Location to store the converted string. @@ -36,13 +81,12 @@ * SA_OK - normal operation. * SA_ERR_HPI_INVALID_PARAMS - @buffer is NULL. * SA_ERR_HPI_INTERNAL_ERROR - @buffer not big enough to accomodate - * date/time representation string. + * date/time representation string or + * conversion failed. **/ SaErrorT oh_decode_time(SaHpiTimeT time, SaHpiTextBufferT *buffer) { int count; - struct tm t; - time_t tt; SaErrorT err; SaHpiTextBufferT working; @@ -54,8 +98,12 @@ if (err != SA_OK) { return(err); } if (time > SAHPI_TIME_MAX_RELATIVE) { /*absolute time*/ - tt = time / 1000000000; - count = strftime((char *)working.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH, "%Y-%m-%d %H:%M:%S", localtime(&tt)); + struct tm tm; + err = oh_localtime(time, &tm); + if (err != SA_OK) { + return(err); + } + count = strftime((char *)working.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH, "%Y-%m-%d %H:%M:%S", &tm); } else if (time == SAHPI_TIME_UNSPECIFIED) { strcpy((char *)working.Data,"SAHPI_TIME_UNSPECIFIED "); count = sizeof("SAHPI_TIME_UNSPECIFIED "); @@ -63,10 +111,13 @@ strcpy((char *)working.Data,"Invalid time "); count = sizeof("Invalid time "); } else { /*relative time*/ - tt = time / 1000000000; - localtime_r(&tt, &t); + struct tm tm; + err = oh_localtime(time, &tm); + if (err != SA_OK) { + return(err); + } /* count = strftime(str, size, "%b %d, %Y - %H:%M:%S", &t); */ - count = strftime((char *)working.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH, "%c", &t); + count = strftime((char *)working.Data, SAHPI_MAX_TEXT_BUFFER_LENGTH, "%c", &tm); } if (count == 0) { return(SA_ERR_HPI_INTERNAL_ERROR); } @@ -90,18 +141,13 @@ **/ SaErrorT oh_gettimeofday(SaHpiTimeT *time) { - int err; - struct timeval now; + GTimeVal now; if (!time) { return(SA_ERR_HPI_INVALID_PARAMS); } - err = gettimeofday(&now, NULL); - if (err) { - err("gettimeofday failed"); - return(SA_ERR_HPI_INTERNAL_ERROR); - } + g_get_current_time(&now); *time = (SaHpiTimeT)now.tv_sec * 1000000000 + now.tv_usec * 1000; Modified: openhpi/trunk/utils/sahpi_time_utils.h =================================================================== --- openhpi/trunk/utils/sahpi_time_utils.h 2010-11-27 19:38:27 UTC (rev 7171) +++ openhpi/trunk/utils/sahpi_time_utils.h 2010-11-28 11:13:55 UTC (rev 7172) @@ -20,10 +20,14 @@ #warning *** Include oh_utils.h instead of individual utility header files *** #endif +#include <time.h> + #ifdef __cplusplus extern "C" { #endif +SaErrorT oh_localtime(const SaHpiTimeT time, struct tm *tm); + SaErrorT oh_decode_time(SaHpiTimeT time, SaHpiTextBufferT *buffer); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-11-29 09:52:25
|
Revision: 7173 http://openhpi.svn.sourceforge.net/openhpi/?rev=7173&view=rev Author: avpak Date: 2010-11-29 09:52:17 +0000 (Mon, 29 Nov 2010) Log Message: ----------- Bugfix for #3108399 Feature request #3118484 Modified Paths: -------------- openhpi/trunk/configure.ac openhpi/trunk/marshal/Makefile.am openhpi/trunk/marshal/marshal.c openhpi/trunk/marshal/marshal.h openhpi/trunk/marshal/marshal_hpi.c openhpi/trunk/marshal/marshal_hpi.h openhpi/trunk/marshal/marshal_hpi_types.c Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2010-11-28 11:13:55 UTC (rev 7172) +++ openhpi/trunk/configure.ac 2010-11-29 09:52:17 UTC (rev 7173) @@ -110,6 +110,8 @@ exact_version=`pkg-config --modversion $GLIB`; GLIB_CFLAGS=`pkg-config --cflags $GLIB gthread-2.0` GLIB_LIBS=`pkg-config --libs $GLIB gthread-2.0` +GLIB_ONLY_CFLAGS=`pkg-config --cflags $GLIB` +GLIB_ONLY_LIBS=`pkg-config --libs $GLIB` # On some versions of Solaris the pkg-config file for gthread-2.0 contains a # compiler option, '-mt', that is incompatible with gcc @@ -139,7 +141,10 @@ CFLAGS=$old_cflags LIBS=$old_libs +AC_SUBST(GLIB_ONLY_CFLAGS) +AC_SUBST(GLIB_ONLY_LIBS) + AC_CHECK_LIB([ltdl], [lt_dlopen], [], [ OH_CHECK_FAIL(libltdl,libltdl-devel,, this is required for plugin loading) Modified: openhpi/trunk/marshal/Makefile.am =================================================================== --- openhpi/trunk/marshal/Makefile.am 2010-11-28 11:13:55 UTC (rev 7172) +++ openhpi/trunk/marshal/Makefile.am 2010-11-29 09:52:17 UTC (rev 7173) @@ -34,7 +34,8 @@ marshal.h \ marshal.c -libopenhpimarshal_la_LDFLAGS= -version-info @HPI_LIB_VERSION@ +# we need glib-2.0 for gmalloc +libopenhpimarshal_la_LDFLAGS= -version-info @HPI_LIB_VERSION@ @GLIB_ONLY_LIBS@ clean-local: rm -f *~ core core.* Modified: openhpi/trunk/marshal/marshal.c =================================================================== --- openhpi/trunk/marshal/marshal.c 2010-11-28 11:13:55 UTC (rev 7172) +++ openhpi/trunk/marshal/marshal.c 2010-11-29 09:52:17 UTC (rev 7173) @@ -13,13 +13,16 @@ * Authors: * Thomas Kanngieser <tho...@fc...> * W. David Ashley <da...@us...> + * Anton Pak <anton.pak.pigeonpoint.com> */ +#include <assert.h> #include <stdlib.h> -// #include <stdio.h> +//#include <stdio.h> #include <string.h> -#include <assert.h> + #include <glib.h> + #include "marshal.h" @@ -80,29 +83,23 @@ -int +static int IsSimpleType( tMarshalType type ) { - assert( type != eMtUnknown ); - switch( type ) { - case eMtUnknown: - assert( type != eMtUnknown ); - return 0; - case eMtVoid: - case eMtUint8: - case eMtUint16: - case eMtUint32: - case eMtUint64: case eMtInt8: + case eMtUint8: case eMtInt16: + case eMtUint16: case eMtInt32: + case eMtUint32: case eMtInt64: + case eMtUint64: case eMtFloat32: case eMtFloat64: - return 1; + return 1; case eMtArray: case eMtVarArray: @@ -111,301 +108,270 @@ case eMtUnion: case eMtUnionElement: case eMtUserDefined: - return 0; - } + return 0; - // not reached - assert( 0 ); - return 0; + default: + assert( 0 ); + return 0; + } } -int +static size_t MarshalSize( const cMarshalType *type ) { switch( type->m_type ) { - case eMtUnknown: - assert( 0 ); - return 0; - case eMtVoid: return 0; - case eMtUint8: case eMtInt8: - return sizeof( tUint8 ); - - case eMtUint16: + return sizeof(tInt8); + case eMtUint8: + return sizeof(tUint8); case eMtInt16: - return sizeof( tUint16 ); - - case eMtUint32: + return sizeof(tInt16); + case eMtUint16: + return sizeof(tUint16); case eMtInt32: - return sizeof( tUint32 ); - - case eMtUint64: + return sizeof(tInt32); + case eMtUint32: + return sizeof(tUint32); case eMtInt64: - return sizeof( tUint64 ); - + return sizeof(tInt64); + case eMtUint64: + return sizeof(tUint64); case eMtFloat32: - return sizeof( tFloat32 ); - + return sizeof(tFloat32); case eMtFloat64: - return sizeof( tFloat64 ); + return sizeof(tFloat64); case eMtArray: - assert( type->m_u.m_array.m_size > 0 ); - assert( type->m_u.m_array.m_type ); + { + size_t nelems = type->u.m_array.m_nelements; + assert( nelems > 0 ); + const cMarshalType *elem = type->u.m_array.m_element; + assert( elem ); - return type->m_u.m_array.m_size * MarshalSize( type->m_u.m_array.m_type ); + return nelems * MarshalSize( elem ); + } case eMtVarArray: - return 0xffff; + // TODO investigate and fix me if necessary + return 0xffff; case eMtStruct: { - assert( type->m_u.m_struct.m_elements ); + size_t size = 0; - int i; - int size = 0; + const cMarshalType *elems = &type->u.m_struct.m_elements[0]; + assert( elems ); - for( i = 0; type->m_u.m_struct.m_elements[i].m_type == eMtStructElement; i++ ) + size_t i; + for( i = 0; elems[i].m_type == eMtStructElement; i++ ) { - cMarshalType *elem = &type->m_u.m_struct.m_elements[i]; - - int s = MarshalSize( elem->m_u.m_struct_element.m_type ); - - if ( s < 0 ) { - assert( 0 ); - return -1; - } - - size += s; + const cMarshalType *elem = elems[i].u.m_struct_element.m_element; + size += MarshalSize( elem ); } return size; } case eMtUnion: - { - assert( type->m_u.m_union.m_elements ); + { + size_t max = 0; - int i; - int max = 0; + const cMarshalType *elems = &type->u.m_union.m_elements[0]; + assert( elems ); - for( i = 0; type->m_u.m_union.m_elements[i].m_type == eMtUnionElement; i++ ) + size_t i; + for( i = 0; elems[i].m_type == eMtUnionElement; i++ ) { - cMarshalType *elem = &type->m_u.m_union.m_elements[i]; - - int s = MarshalSize( elem->m_u.m_union_element.m_type ); - - if ( s < 0 ) { - assert( 0 ); - return -1; - } - - if ( max < s ) - max = s; + const cMarshalType *elem = elems[i].u.m_union_element.m_element; + size_t s = MarshalSize( elem ); + if ( max < s ) + { + max = s; + } } return max; - } + } case eMtUserDefined: - return 0xffff; + // TODO investigate and fix me if necessary + return 0xffff; - case eMtStructElement: - case eMtUnionElement: + default: // including eMtUnknown, eMtStructElement, eMtUnionElement assert( 0 ); - return -1; + return 0; } - - // not reached - assert( 0 ); - return -1; } -int +size_t MarshalSizeArray( const cMarshalType **types ) { - int size = 0; - int i; + size_t size = 0; + size_t i; for( i = 0; types[i]; i++ ) { - int s = MarshalSize( types[i] ); - - if ( s < 0 ) { - assert( 0 ); - return -1; - } - - size += s; + size += MarshalSize( types[i] ); } return size; } -int -MarshalSimpleTypes( tMarshalType type, const void *data, - void *buffer ) +static int +MarshalSimpleType( tMarshalType type, const void *data, void *buffer ) { switch( type ) { case eMtVoid: - return 0; + return 0; - case eMtUint8: case eMtInt8: - { - memcpy(buffer, data, sizeof(tUint8)); - } - - return sizeof( tUint8 ); - + memcpy(buffer, data, sizeof(tInt8)); + return sizeof(tInt8); + case eMtUint8: + memcpy(buffer, data, sizeof(tUint8)); + return sizeof(tUint8); case eMtInt16: + memcpy(buffer, data, sizeof(tInt16)); + return sizeof(tInt16); case eMtUint16: - { - memcpy(buffer, data, sizeof(tUint16)); - } - - return sizeof( tUint16 ); - - case eMtUint32: + memcpy(buffer, data, sizeof(tUint16)); + return sizeof(tUint16); case eMtInt32: - { - memcpy(buffer, data, sizeof(tUint32)); - } - - return sizeof( tUint32 ); - - case eMtUint64: + memcpy(buffer, data, sizeof(tInt32)); + return sizeof(tInt32); + case eMtUint32: + memcpy(buffer, data, sizeof(tUint32)); + return sizeof(tUint32); case eMtInt64: - { - memcpy(buffer, data, sizeof(tUint64)); - } - - return sizeof( tUint64 ); - + memcpy(buffer, data, sizeof(tInt64)); + return sizeof(tInt64); + case eMtUint64: + memcpy(buffer, data, sizeof(tUint64)); + return sizeof(tUint64); case eMtFloat32: - { - memcpy(buffer, data, sizeof(tFloat32)); - } - - return sizeof( tFloat32 ); - + memcpy(buffer, data, sizeof(tFloat32)); + return sizeof(tFloat32); case eMtFloat64: - { - memcpy(buffer, data, sizeof(tFloat64)); - } - - return sizeof( tFloat64 ); - + memcpy(buffer, data, sizeof(tFloat64)); + return sizeof(tFloat64); default: - break; + assert( 0 ); + return -1; } - - assert( 0 ); - return -1; } - -static const cMarshalType * -FindUnionModifierType( const cMarshalType *type, cMarshalType *st_type, const void *d ) +/*********************************************************** + * Gets value of integer structure element + * @type - marshal type of the structure + * @idx - element index in the structure + * @data - raw pointer to the structure data + * + * structure element shall be of + * eMtUint{8,16,32} and eMtInt{8,16,32} type + * + * returns obtained integer value (casted to size_t) + * or + * returns (size_t)(-1) and throws assertion + * + * NB + * function does NOT check for + * - type is valid pointer + * - type is pointer to marshal type for a structure + * - idx is valid for the type + * - data is valid pointer + ***********************************************************/ +static size_t +GetStructElementIntegerValue( const cMarshalType *type, size_t idx, const void * data ) { - cMarshalType *mod_struct_element = &type->m_u.m_struct.m_elements[st_type->m_u.m_union.m_offset]; - assert( mod_struct_element->m_type == eMtStructElement ); - cMarshalType *mod_type = mod_struct_element->m_u.m_struct_element.m_type; - const unsigned char *so = (const unsigned char *)d + mod_struct_element->m_u.m_struct_element.m_offset; + const cMarshalType *elems = &type->u.m_struct.m_elements[0]; + const cMarshalType *elem = elems[idx].u.m_struct_element.m_element; + const size_t offset = elems[idx].u.m_struct_element.m_offset; - tUint32 m; + union + { + const void *raw; + const tInt8 *i8; + const tUint8 *ui8; + const tInt16 *i16; + const tUint16 *ui16; + const tInt32 *i32; + const tUint32 *ui32; + const tInt64 *i64; + const tUint64 *ui64; + } u; - switch( mod_type->m_type ) + u.raw = (const unsigned char *)data + offset; + + switch( elem->m_type ) { - case eMtUint8: case eMtInt8: - m = (tUint32)*so; - break; - - case eMtUint16: + return (size_t)(*u.i8); + case eMtUint8: + return (size_t)(*u.ui8); case eMtInt16: - /* compile error */ -// m = (tUint32)*(const tUint16 *)so; - m = (tUint32)(*(const tUint16 *)(const void *)so); - break; - - case eMtUint32: + return (size_t)(*u.i16); + case eMtUint16: + return (size_t)(*u.ui16); case eMtInt32: - /* compile error */ -// m = *(const tUint32 *)so; - m = *(const tUint32 *)(const void *)so; - break; - + return (size_t)(*u.i32); + case eMtUint32: + return (size_t)(*u.ui32); + case eMtInt64: + return (size_t)(*u.i64); + case eMtUint64: + return (size_t)(*u.ui64); default: assert( 0 ); - m = 0; - - return 0; + return (size_t)(-1); } - - int i; - - for( i = 0; st_type->m_u.m_union.m_elements[i].m_type == eMtUnionElement; i++ ) - if ( st_type->m_u.m_union.m_elements[i].m_u.m_union_element.m_mod == m ) - return st_type->m_u.m_union.m_elements[i].m_u.m_union_element.m_type; - - return 0; } - -static int -FindArraySize( const cMarshalType *type, cMarshalType *st_type, const void *d ) +/*********************************************************** + * Gets marshal type for union element specified by modifier + * @type - marshal type of the union + * @modifier - modifier value + * + * returns union element or 0 + * + * NB + * function does NOT check for + * - type is valid pointer + * - type is pointer to marshal type for a union + ***********************************************************/ +static const cMarshalType * +GetUnionElement( const cMarshalType *type, size_t modifier ) { - cMarshalType *size_struct_element = &type->m_u.m_struct.m_elements[st_type->m_u.m_var_array.m_size]; - assert( size_struct_element->m_type == eMtStructElement ); - cMarshalType *size_type = size_struct_element->m_u.m_struct_element.m_type; - const unsigned char *so = (const unsigned char *)d + size_struct_element->m_u.m_struct_element.m_offset; + const cMarshalType *elems = &type->u.m_union.m_elements[0]; - tUint32 size; - - switch( size_type->m_type ) + size_t i; + for( i = 0; elems[i].m_type == eMtUnionElement; i++ ) { - case eMtUint8: - case eMtInt8: - size = (tUint32)*so; - break; - - case eMtUint16: - case eMtInt16: - /* compile error */ -// size = (tUint32)*(const tUint16 *)so; - size = (tUint32)*(const tUint16 *)(const void *)so; - break; - - case eMtUint32: - case eMtInt32: - /* compile error */ -// size = *(const tUint32 *)so; - size = *(const tUint32 *)(const void *)so; - break; - - default: - assert( 0 ); - return -1; + const size_t mod = elems[i].u.m_union_element.m_mod; + if ( mod == modifier ) + { + const cMarshalType *elem = elems[i].u.m_union_element.m_element; + return elem; + } } - return size; + return 0; } - int Marshal( const cMarshalType *type, const void *d, void *b ) { if ( IsSimpleType( type->m_type ) ) - return MarshalSimpleTypes( type->m_type, d, b ); + { + return MarshalSimpleType( type->m_type, d, b ); + } int size = 0; const unsigned char *data = d; @@ -414,122 +380,123 @@ switch( type->m_type ) { case eMtArray: - { - int i; + { + const size_t nelems = type->u.m_array.m_nelements; + assert( nelems > 0 ); - //assert( IsSimpleType( type->m_u.m_array.m_type->m_type ) ); + size_t i; + for( i = 0; i < nelems; i++ ) + { + const cMarshalType *elem = type->u.m_array.m_element; + const size_t elem_sizeof = type->u.m_array.m_element_sizeof; - for( i = 0; i < type->m_u.m_array.m_size; i++ ) - { - int s = Marshal( type->m_u.m_array.m_type, data, buffer ); + int s = Marshal( elem, data, buffer ); + if ( s < 0 ) + { + assert( 0 ); + return -1; + } - if ( s < 0 ) { - assert( 0 ); - return -1; - } + data += elem_sizeof; + buffer += s; + size += s; + } + } + break; - data += s; - buffer += s; - size += s; - } - } - break; - case eMtStruct: { - int i; - - for( i = 0; type->m_u.m_struct.m_elements[i].m_type == eMtStructElement; i++ ) + const cMarshalType *elems = &type->u.m_struct.m_elements[0]; + assert( elems ); + + size_t i; + for( i = 0; elems[i].m_type == eMtStructElement; i++ ) { - cMarshalType *struct_element = &type->m_u.m_struct.m_elements[i]; - assert( struct_element->m_type == eMtStructElement ); + const cMarshalType *elem = elems[i].u.m_struct_element.m_element; + const size_t offset = elems[i].u.m_struct_element.m_offset; + int s = 0; - cMarshalType *st_type = struct_element->m_u.m_struct_element.m_type; + if ( elem->m_type == eMtUnion ) + { + size_t mod2_idx = elem->u.m_union.m_mod_idx; + // the union modifier field must be before this entry. + // this is a limitation of demarshaling of unions + assert( mod2_idx < i ); + size_t mod2 = GetStructElementIntegerValue( type, mod2_idx, data ); + const cMarshalType *elem2 = GetUnionElement( elem, mod2 ); + assert( elem2 ); - int s = 0; - - if ( st_type->m_type == eMtUnion ) - { - // the mod must be before this entry. - // this is a limitation of demarshaling of unions - assert( st_type->m_u.m_union.m_offset < i ); - const cMarshalType *mod = FindUnionModifierType( type, st_type, data ); - - if ( mod ) + s = Marshal( elem2, data + offset, buffer ); + if ( s < 0 ) { - s = Marshal( mod, data + struct_element->m_u.m_struct_element.m_offset, buffer ); - - if ( s < 0 ) { - assert( 0 ); - return -1; - } + assert( 0 ); + return -1; } - else { - assert( 0 ); - return -1; - } - } - else if ( st_type->m_type == eMtVarArray ) - { - // the array size must be before this entry. - // this is a limitation of demarshaling of var arrays - assert( st_type->m_u.m_var_array.m_size < i ); + } + else if ( elem->m_type == eMtVarArray ) + { + const size_t nelems2_idx = elem->u.m_var_array.m_nelements_idx; + const cMarshalType *elem2 = elem->u.m_var_array.m_element; + const size_t elem2_sizeof = elem->u.m_var_array.m_element_sizeof; - int array_size = FindArraySize( type, st_type, data ); + // the array nelements field must be before this entry. + // this is a limitation of demarshaling of var arrays + assert( nelems2_idx < i ); - // only simple types can be array elements - //assert( IsSimpleType( st_type->m_u.m_var_array.m_type->m_type ) ); + const size_t nelems2 = GetStructElementIntegerValue( type, nelems2_idx, data ); - unsigned char *bb = buffer; - const unsigned char *vardata = data + struct_element->m_u.m_struct_element.m_offset; - const unsigned char *dd; - tUint32 j; - memcpy(&dd, vardata, sizeof(void *)); + // (data + offset ) points to pointer to var array content + const unsigned char *data2; + memcpy(&data2, data + offset, sizeof(void *)); - for( j = 0; j < array_size; j++ ) - { - int si = Marshal( st_type->m_u.m_var_array.m_type, - dd, bb ); + unsigned char *buffer2 = buffer; + size_t i2; + for( i2 = 0; i2 < nelems2; i2++ ) + { + int s2 = Marshal( elem2, data2, buffer2 ); + if ( s2 < 0 ) + { + assert( 0 ); + return -1; + } - if ( si < 0 ) { - assert( 0 ); - return -1; - } - - bb += si; - dd += si; - s += si; - } - } - else + data2 += elem2_sizeof; + buffer2 += s2; + s += s2; + } + } + else { - s = Marshal( st_type, data + struct_element->m_u.m_struct_element.m_offset, - buffer ); - - if ( s < 0 ) { - assert( 0 ); - return -1; - } + s = Marshal( elem, data + offset, buffer ); + if ( s < 0 ) + { + assert( 0 ); + return -1; + } } buffer += s; - size += s; + size += s; } } break; case eMtUnion: - assert( 0 ); + assert( 0 ); return -1; case eMtUserDefined: - assert( type->m_u.m_user_defined.m_marshal ); - size = type->m_u.m_user_defined.m_marshal( type, d, b, type->m_u.m_user_defined.m_user_data ); + { + tMarshalFunction marshaller = type->u.m_user_defined.m_marshaller; + assert( marshaller ); + void * user_data = type->u.m_user_defined.m_user_data; + size = marshaller( type, d, b, user_data ); + } break; default: - assert( 0 ); - return -1; + assert( 0 ); + return -1; } return size; @@ -537,22 +504,21 @@ int -MarshalArray( const cMarshalType **types, - const void **data, void *b ) +MarshalArray( const cMarshalType **types, const void **data, void *b ) { - int i; int size = 0; unsigned char *buffer = b; + size_t i; for( i = 0; types[i]; i++ ) { int s = Marshal( types[i], data[i], buffer ); + if ( s < 0 ) + { + assert( 0 ); + return -1; + } - if ( s < 0 ) { - assert( 0 ); - return -1; - } - size += s; buffer += s; } @@ -561,125 +527,123 @@ } -// for byte swap float 32 -typedef union +static int +DemarshalSimpleTypes( int byte_order, tMarshalType type, void *data, const void *buffer ) { - tUint32 m_u32; - tFloat32 m_f32; -} tFloat32Uint32; + union + { + tInt16 i16; + tUint16 ui16; + tInt32 i32; + tUint32 ui32; + tInt64 i64; + tUint64 ui64; + tFloat32 f32; + tFloat64 f64; + } u; + // NB Glib does not provide SWAP_LE_BE macro for signed types! -// for byte swap float 64 -typedef union -{ - tUint64 m_u64; - tFloat64 m_f64; -} tFloat64Uint64; - - -int -DemarshalSimpleTypes( int byte_order, tMarshalType type, - void *data, const void *buffer ) -{ switch( type ) { case eMtVoid: return 0; - case eMtUint8: case eMtInt8: - { - tUint8 v = *(const tUint8 *)buffer; - *(tUint8 *)data = v; - } + memcpy(data, buffer, sizeof(tInt8)); + return sizeof(tInt8); - return sizeof( tUint8 ); + case eMtUint8: + memcpy(data, buffer, sizeof(tUint8)); + return sizeof(tUint8); case eMtInt16: + memcpy(&u.i16, buffer, sizeof(tInt16)); + if ( G_BYTE_ORDER != byte_order ) + { + u.ui16 = GUINT16_SWAP_LE_BE( u.ui16 ); + } + memcpy(data, &u.i16, sizeof(tInt16)); + return sizeof(tInt16); + case eMtUint16: - { - tUint16 v; - memcpy( &v, buffer, sizeof( tUint16 ) ); + memcpy(&u.ui16, buffer, sizeof(tUint16)); + if ( G_BYTE_ORDER != byte_order ) + { + u.ui16 = GUINT16_SWAP_LE_BE( u.ui16 ); + } + memcpy(data, &u.ui16, sizeof(tUint16)); + return sizeof(tUint16); - if ( G_BYTE_ORDER != byte_order ) - v = GUINT16_SWAP_LE_BE( v ); - - *(tUint16 *)data = v; - } - - return sizeof( tUint16 ); - - case eMtUint32: case eMtInt32: - { - tUint32 v; - memcpy( &v, buffer, sizeof( tUint32 ) ); + memcpy(&u.i32, buffer, sizeof(tInt32)); + if ( G_BYTE_ORDER != byte_order ) + { + u.ui32 = GUINT32_SWAP_LE_BE( u.ui32 ); + } + memcpy(data, &u.i32, sizeof(tInt32)); + return sizeof(tInt32); + + case eMtUint32: + memcpy(&u.ui32, buffer, sizeof(tUint32)); + if ( G_BYTE_ORDER != byte_order ) + { + u.ui32 = GUINT32_SWAP_LE_BE( u.ui32 ); + } + memcpy(data, &u.ui32, sizeof(tUint32)); + return sizeof(tUint32); - if ( G_BYTE_ORDER != byte_order ) - v = GUINT32_SWAP_LE_BE( v ); - - *(tUint32 *)data = v; - } - - return sizeof( tUint32 ); - - case eMtUint64: case eMtInt64: - { - tUint64 v; - memcpy( &v, buffer, sizeof( tUint64 ) ); - - if ( G_BYTE_ORDER != byte_order ) - v = GUINT64_SWAP_LE_BE( v ); - - *(tUint64 *)data = v; - } - - return sizeof( tUint64 ); - + memcpy(&u.i64, buffer, sizeof(tInt64)); + if ( G_BYTE_ORDER != byte_order ) + { + u.ui64 = GUINT64_SWAP_LE_BE( u.ui64 ); + } + memcpy(data, &u.i64, sizeof(tInt64)); + return sizeof(tInt64); + + case eMtUint64: + memcpy(&u.ui64, buffer, sizeof(tUint64)); + if ( G_BYTE_ORDER != byte_order ) + { + u.ui64 = GUINT64_SWAP_LE_BE( u.ui64 ); + } + memcpy(data, &u.ui64, sizeof(tUint64)); + return sizeof(tUint64); + case eMtFloat32: - { - // this has been tested for i386 and PPC - tFloat32Uint32 v; - memcpy( &(v.m_f32), buffer, sizeof( tFloat32 ) ); - - if ( G_BYTE_ORDER != byte_order ) - v.m_u32 = GUINT32_SWAP_LE_BE( v.m_u32 ); - - *(tFloat32 *)data = v.m_f32; - } - - return sizeof( tFloat32 ); - + + memcpy(&u.f32, buffer, sizeof(tFloat32)); + if ( G_BYTE_ORDER != byte_order ) + { + u.ui32 = GUINT32_SWAP_LE_BE( u.ui32 ); + } + memcpy(data, &u.f32, sizeof(tFloat32)); + return sizeof(tFloat32); + case eMtFloat64: - { - // this has been tested for i386 and PPC - tFloat64Uint64 v; - memcpy( &(v.m_f64), buffer, sizeof( tFloat64 ) ); - - if ( G_BYTE_ORDER != byte_order ) - v.m_u64 = GUINT64_SWAP_LE_BE( v.m_u64 ); - - *(tFloat64 *)data = v.m_f64; - } - - return sizeof( tFloat64 ); - + memcpy(&u.f64, buffer, sizeof(tFloat64)); + if ( G_BYTE_ORDER != byte_order ) + { + u.ui64 = GUINT64_SWAP_LE_BE( u.ui64 ); + } + memcpy(data, &u.f64, sizeof(tFloat64)); + return sizeof(tFloat64); + default: - break; + assert( 0 ); + return -1; } - - assert( 0 ); - return -1; } int -Demarshal( int byte_order, const cMarshalType *type, - void *d, const void *b ) +Demarshal( int byte_order, const cMarshalType *type, void *d, const void *b ) { if ( IsSimpleType( type->m_type ) ) + { return DemarshalSimpleTypes( byte_order, type->m_type, d, b ); + } int size = 0; unsigned char *data = d; @@ -688,111 +652,104 @@ switch( type->m_type ) { case eMtArray: - { - int i; + { + const size_t nelems = type->u.m_array.m_nelements; + assert( nelems > 0 ); - for( i = 0; i < type->m_u.m_array.m_size; i++ ) - { - int s = Demarshal( byte_order, type->m_u.m_array.m_type, - data, buffer ); + size_t i; + for( i = 0; i < nelems; i++ ) + { + const cMarshalType *elem = type->u.m_array.m_element; + const size_t elem_sizeof = type->u.m_array.m_element_sizeof; - if ( s < 0 ) { - assert( 0 ); - return -1; - } + int s = Demarshal( byte_order, elem, data, buffer ); + if ( s < 0 ) + { + assert( 0 ); + return -1; + } - data += s; - buffer += s; - size += s; - } - } - break; + data += elem_sizeof; + buffer += s; + size += s; + } + } + break; case eMtStruct: { - int i; - - for( i = 0; type->m_u.m_struct.m_elements[i].m_type == eMtStructElement; i++ ) - { - cMarshalType *struct_element = &type->m_u.m_struct.m_elements[i]; - assert( struct_element->m_type == eMtStructElement ); + const cMarshalType *elems = &type->u.m_struct.m_elements[0]; + assert( elems ); - cMarshalType *st_type = struct_element->m_u.m_struct_element.m_type; + size_t i; + for( i = 0; elems[i].m_type == eMtStructElement; i++ ) + { + const cMarshalType *elem = elems[i].u.m_struct_element.m_element; + const size_t offset = elems[i].u.m_struct_element.m_offset; int s = 0; - if ( st_type->m_type == eMtUnion ) + if ( elem->m_type == eMtUnion ) { - // the mod must be before this entry. - // this is a limitation of demarshaling of unions - assert( st_type->m_u.m_union.m_offset < i ); - const cMarshalType *mod = FindUnionModifierType( type, st_type, data ); + size_t mod2_idx = elem->u.m_union.m_mod_idx; + // the union modifier field must be before this entry. + // this is a limitation of demarshaling of unions + assert( mod2_idx < i ); + size_t mod2 = GetStructElementIntegerValue( type, mod2_idx, data ); + const cMarshalType *elem2 = GetUnionElement( elem, mod2 ); + assert( elem2 ); - if ( mod ) + s = Demarshal( byte_order, elem2, data + offset, buffer ); + if ( s < 0 ) { - s = Demarshal( byte_order, mod, data + struct_element->m_u.m_struct_element.m_offset, buffer ); - - if ( s < 0 ) { - assert( 0 ); - return -1; - } + assert( 0 ); + return -1; } - else { - assert( 0 ); - return -1; - } } - else if ( st_type->m_type == eMtVarArray ) + else if ( elem->m_type == eMtVarArray ) { - // the array size must be before this entry. - // this is a limitation of demarshaling of var arrays - assert( st_type->m_u.m_var_array.m_size < i ); + const size_t nelems2_idx = elem->u.m_var_array.m_nelements_idx; + const cMarshalType *elem2 = elem->u.m_var_array.m_element; + const size_t elem2_sizeof = elem->u.m_var_array.m_element_sizeof; - tUint32 array_size = FindArraySize( type, st_type, data ); + // the array nelements field must be before this entry. + // this is a limitation of demarshaling of var arrays + assert( nelems2_idx < i ); - // only simple types can be array elements - //assert( IsSimpleType( st_type->m_u.m_var_array.m_type->m_type ) ); - - const unsigned char *bb = buffer; - const cMarshalType *va_type = st_type->m_u.m_var_array.m_type; - // FIXME: This is a hack! I'm assuming the elements in - // the variable array are structs. That's because this - // is the only instance for which we use var arrays. - unsigned char *dd = - (unsigned char *)malloc(va_type->m_u.m_struct.m_size*array_size); - memset(dd, 0, va_type->m_u.m_struct.m_size*array_size); - unsigned char *vardata = data + struct_element->m_u.m_struct_element.m_offset; - tUint32 j; - memcpy(vardata, &dd, sizeof(void *)); + const size_t nelems2 = GetStructElementIntegerValue( type, nelems2_idx, data ); - for( j = 0; j < array_size; j++ ) - { - int si = Demarshal( byte_order, st_type->m_u.m_var_array.m_type, - dd, bb ); + // allocate storage for var array content + unsigned char *data2 = (unsigned char *)g_malloc0( nelems2 * elem2_sizeof ); + // (data + offset ) points to pointer to var array content + memcpy(data + offset, &data2, sizeof(void *)); - if ( si < 0 ) { - assert( 0 ); - return -1; - } + const unsigned char *buffer2 = buffer; + size_t i2; + for( i2 = 0; i2 < nelems2; i2++ ) + { + int s2 = Demarshal( byte_order, elem2, data2, buffer2 ); + if ( s2 < 0 ) + { + assert( 0 ); + return -1; + } - bb += si; - dd += si; - s += si; - } - } - else + data2 += elem2_sizeof; + buffer2 += s2; + s += s2; + } + } + else { - s = Demarshal( byte_order, st_type, - data + struct_element->m_u.m_struct_element.m_offset, - buffer ); - - if ( s < 0 ) { - assert( 0 ); - return -1; - } + s = Demarshal( byte_order, elem, data + offset, buffer ); + if ( s < 0 ) + { + assert( 0 ); + return -1; + } } buffer += s; - size += s; + size += s; } } @@ -800,7 +757,7 @@ case eMtUnion: // unions must me encapsulate in structs - assert( 0 ); + assert( 0 ); return -1; case eMtStructElement: @@ -809,20 +766,17 @@ return -1; case eMtUserDefined: - assert( type->m_u.m_user_defined.m_demarshal ); - size = type->m_u.m_user_defined.m_demarshal( byte_order, type, d, b, - type->m_u.m_user_defined. m_user_data ); - - if ( size < 0 ) { - assert( 0 ); - return -1; + { + tDemarshalFunction demarshaller = type->u.m_user_defined.m_demarshaller; + assert( demarshaller ); + void * user_data = type->u.m_user_defined.m_user_data; + size = demarshaller( byte_order, type, d, b, user_data ); } - break; default: - assert( 0 ); - return -1; + assert( 0 ); + return -1; } return size; @@ -830,25 +784,25 @@ int -DemarshalArray( int byte_order, const cMarshalType **types, - void **data, const void *b ) +DemarshalArray( int byte_order, const cMarshalType **types, void **data, const void *b ) { - int i; int size = 0; const unsigned char *buffer = b; + size_t i; for( i = 0; types[i]; i++ ) { int s = Demarshal( byte_order, types[i], data[i], buffer ); + if ( s < 0 ) + { + assert( 0 ); + return -1; + } - if ( s < 0 ) { - assert( 0 ); - return -1; - } - size += s; buffer += s; } return size; } + Modified: openhpi/trunk/marshal/marshal.h =================================================================== --- openhpi/trunk/marshal/marshal.h 2010-11-28 11:13:55 UTC (rev 7172) +++ openhpi/trunk/marshal/marshal.h 2010-11-29 09:52:17 UTC (rev 7173) @@ -13,17 +13,21 @@ * Authors: * Thomas Kanngieser <tho...@fc...> * W. David Ashley <da...@us...> + * Anton Pak <anton.pak.pigeonpoint.com> */ #ifndef dMarshal_h #define dMarshal_h +#include <stddef.h> + #ifdef __cplusplus extern "C" { #endif +// TODO use (u)int_xxx_t or SaHpi types instead typedef unsigned char tUint8; typedef unsigned short tUint16; typedef unsigned int tUint32; @@ -39,7 +43,7 @@ typedef enum { eMtUnknown, - eMtVoid, // do nothing + eMtVoid, // do nothing eMtUint8, eMtUint16, eMtUint32, @@ -51,60 +55,67 @@ eMtFloat32, eMtFloat64, eMtArray, - eMtVarArray, // only possible in structs + eMtVarArray, eMtStruct, eMtStructElement, eMtUnion, eMtUnionElement, - eMtUserDefined // user defined marshalling + eMtUserDefined // user defined marshalling } tMarshalType; +// NB +// +// VarArray can be used as a structure element only +// The struct must have "number of elements" field before the VarArray field +// +// Union can be used as a structure element only +// The struct must have "union modifier" field before the Union field +// -int IsSimpleType( tMarshalType type ); - -#define dStructOffset(type,field) ((unsigned int)(((char *) (&(((type *)0)->field)))-((char*)0))) - - // helper macro for arrays -#define dArray( type, size ) \ -{ \ - .m_type = eMtArray, \ - .m_u.m_array = \ - { \ - .m_size = size, \ - .m_type = &type \ - } \ +#define dArray( nelements, element_type, element ) \ +{ \ + .m_type = eMtArray, \ + .u.m_array = \ + { \ + .m_nelements = nelements, \ + .m_element_sizeof = sizeof( element_type ), \ + .m_element = &element \ + } \ } // helper macro for var arrays -#define dVarArray( type, size_pos ) \ -{ \ - .m_type = eMtVarArray, \ - .m_u.m_var_array = \ - { \ - .m_size = size_pos, \ - .m_type = &type \ - } \ +#define dVarArray( nelements_idx, element_type, element ) \ +{ \ + .m_type = eMtVarArray, \ + .u.m_var_array = \ + { \ + .m_nelements_idx = nelements_idx, \ + .m_element_sizeof = sizeof( element_type ), \ + .m_element = &element \ + } \ } // helper marco for struct -#define dStruct( type, elems ) \ -{ \ - .m_type = eMtStruct, \ - .m_u.m_struct = \ - { \ - .m_size = sizeof( type ), \ - .m_elements = elems \ - } \ +#define dStruct( elements ) \ +{ \ + .m_type = eMtStruct, \ + .u.m_struct = \ + { \ + .m_elements = &elements[0] \ + } \ } // helper marco for struct elements -#define dStructElement( struct_type, field, type ) \ -{ \ - .m_type = eMtStructElement, \ - .m_u.m_struct_element.m_offset = dStructOffset( struct_type, field ), \ - .m_u.m_struct_element.m_type = &type \ +#define dStructElement( struct_type, field, element ) \ +{ \ + .m_type = eMtStructElement, \ + .u.m_struct_element = \ + { \ + .m_offset = offsetof( struct_type, field ), \ + .m_element = &element \ + } \ } // helper marco for struct end @@ -114,23 +125,25 @@ } // helper marco for unions -#define dUnion( offset, type, elems ) \ -{ \ - .m_type = eMtUnion, \ - .m_u.m_union = \ - { \ - .m_offset = offset, \ - .m_size = sizeof( type ), \ - .m_elements = elems \ - } \ +#define dUnion( mod_idx, elements ) \ +{ \ + .m_type = eMtUnion, \ + .u.m_union = \ + { \ + .m_mod_idx = mod_idx, \ + .m_elements = &elements[0] \ + } \ } // helper marco for union elements -#define dUnionElement( mod, type ) \ +#define dUnionElement( mod, element ) \ { \ .m_type = eMtUnionElement, \ - .m_u.m_union_element.m_mod = mod, \ - .m_u.m_union_element.m_type = &type \ + .u.m_union_element = \ + { \ + .m_mod = mod, \ + .m_element = &element \ + } \ } // helper marco for union end @@ -143,9 +156,12 @@ #define dUserDefined( marshaller, demarshaller, user_data ) \ { \ .m_type = eMtUserDefined, \ - .m_u.m_user_defined.m_marshal = marshaller, \ - .m_u.m_user_defined.m_demarshal = demarshaller, \ - .m_u.m_user_defined.m_user_data = user_data \ + .u.m_user_defined = \ + { \ + .m_marshaller = marshaller, \ + .m_demarshaller = demarshaller, \ + .m_user_data = user_data \ + } \ } @@ -165,48 +181,48 @@ { struct { - int m_size; // array size - cMarshalType *m_type; // array element + size_t m_nelements; + size_t m_element_sizeof; + cMarshalType *m_element; } m_array; struct { - unsigned int m_size; // struct pos where size is - cMarshalType *m_type; // array element + size_t m_nelements_idx; // nelements field ids in parent struct + size_t m_element_sizeof; + cMarshalType *m_element; } m_var_array; struct { - unsigned int m_size; // size of structure - cMarshalType *m_elements; // struct elements + cMarshalType *m_elements; } m_struct; struct { - unsigned int m_offset; - cMarshalType *m_type; + size_t m_offset; // element offset in parent struct + cMarshalType *m_element; } m_struct_element; struct { - int m_offset; // mod offset in struct - unsigned int m_size; // size of structure - cMarshalType *m_elements; // union elements + size_t m_mod_idx; // mod field index in parent struct + cMarshalType *m_elements; } m_union; struct { - unsigned int m_mod; - cMarshalType *m_type; // union element + size_t m_mod; + cMarshalType *m_element; } m_union_element; struct { - tMarshalFunction m_marshal; - tDemarshalFunction m_demarshal; + tMarshalFunction m_marshaller; + tDemarshalFunction m_demarshaller; void *m_user_data; } m_user_defined; - } m_u; + } u; }; @@ -225,25 +241,17 @@ // size in bytes -int MarshalSize( const cMarshalType *type ); -int MarshalSizeArray( const cMarshalType **types ); +size_t MarshalSizeArray( const cMarshalType **types ); // marshal data into buffer -int Marshal( const cMarshalType *type, const void *data, - void *buffer ); -int MarshalArray( const cMarshalType **types, const void **data, - void *buffer ); -int MarshalSimpleTypes( tMarshalType type, const void *data, - void *buffer ); +int Marshal( const cMarshalType *type, const void *data, void *buffer ); +int MarshalArray( const cMarshalType **types, const void **data, void *buffer ); // demarshal buffer into data -int Demarshal( int byte_order, const cMarshalType *type, - void *data, const void *buffer ); -int DemarshalArray( int byte_order, const cMarshalType **types, - void **data, const void *buffer ); -int DemarshalSimpleTypes( int byte_order, tMarshalType type, - void *data, const void *buffer ); +int Demarshal( int byte_order, const cMarshalType *type, void *data, const void *buffer ); +int DemarshalArray( int byte_order, const cMarshalType **types, void **data, const void *buffer ); + #ifdef __cplusplus } #endif Modified: openhpi/trunk/marshal/marshal_hpi.c =================================================================== --- openhpi/trunk/marshal/marshal_hpi.c 2010-11-28 11:13:55 UTC (rev 7172) +++ openhpi/trunk/marshal/marshal_hpi.c 2010-11-29 09:52:17 UTC (rev 7173) @@ -20,10 +20,12 @@ * Ulrich Kleber <uli...@us...> */ -#include "marshal_hpi.h" +#include <stddef.h> #include <stdio.h> +#include "marshal_hpi.h" + static const cMarshalType *saHpiSessionOpenIn[] = { &SaHpiDomainIdType, // domain id (SaHpiDomainIdT) @@ -2141,7 +2143,7 @@ }; -static int hpi_marshal_num = sizeof( hpi_marshal ) / sizeof( cHpiMarshal ); +static size_t hpi_marshal_num = sizeof( hpi_marshal ) / sizeof( cHpiMarshal ); static int hpi_marshal_init = 0; @@ -2151,8 +2153,7 @@ { if ( !hpi_marshal_init ) { - int i; - + size_t i; for( i = 0; i < hpi_marshal_num; i++ ) { // printf("Entry %d\n", i); Modified: openhpi/trunk/marshal/marshal_hpi.h =================================================================== --- openhpi/trunk/marshal/marshal_hpi.h 2010-11-28 11:13:55 UTC (rev 7172) +++ openhpi/trunk/marshal/marshal_hpi.h 2010-11-29 09:52:17 UTC (rev 7173) @@ -19,6 +19,7 @@ #ifndef dMarshalHpi_h #define dMarshalHpi_h +#include <stddef.h> #ifndef dMarshalHpiTypes_h #include "marshal_hpi_types.h" @@ -30,9 +31,6 @@ #endif -#define dDefaultDaemonPort 4743 - - typedef enum { eFsaHpiNull, @@ -176,8 +174,8 @@ int m_id; const cMarshalType **m_request; const cMarshalType **m_reply; // the first param is the result - unsigned int m_request_len; - unsigned int m_reply_len; + size_t m_request_len; + size_t m_reply_len; } cHpiMarshal; Modified: openhpi/trunk/marshal/marshal_hpi_types.c =================================================================== --- openhpi/trunk/marshal/marshal_hpi_types.c 2010-11-28 11:13:55 UTC (rev 7172) +++ openhpi/trunk/marshal/marshal_hpi_types.c 2010-11-29 09:52:17 UTC (rev 7173) @@ -27,7 +27,7 @@ // SaHpiTextBuffer -static cMarshalType SaHpiTextBufferDataArray = dArray( SaHpiUint8Type, SAHPI_MAX_TEXT_BUFFER_LENGTH ); +static cMarshalType SaHpiTextBufferDataArray = dArray( SAHPI_MAX_TEXT_BUFFER_LENGTH, SaHpiUint8T, SaHpiUint8Type ); static cMarshalType SaHpiTextBufferElements[] = { @@ -38,27 +38,27 @@ dStructElementEnd() }; -cMarshalType SaHpiTextBufferType = dStruct( SaHpiTextBufferT, SaHpiTextBufferElements ); +cMarshalType SaHpiTextBufferType = dStruct( SaHpiTextBufferElements ); // oHpi -static cMarshalType oHpiHandlerConfigParamTypeNameArray = dArray( SaHpiUint8Type, SAHPI_MAX_TEXT_BUFFER_LENGTH ); -static cMarshalType oHpiHandlerConfigParamTypeValueArray = dArray( SaHpiUint8Type, SAHPI_MAX_TEXT_BUFFER_LENGTH ); +static cMarshalType oHpiHandlerConfigParamTypeNameArray = dArray( SAHPI_MAX_TEXT_BUFFER_LENGTH, SaHpiUint8T, SaHpiUint8Type ); +static cMarshalType oHpiHandlerConfigParamTypeValueArray = dArray( SAHPI_MAX_TEXT_BUFFER_LENGTH, SaHpiUint8T, SaHpiUint8Type ); static cMarshalType oHpiHandlerConfigParamTypeElements[] = { dStructElement( oHpiHandlerConfigParamT, Name, oHpiHandlerConfigParamTypeNameArray ), dStructElement( oHpiHandlerConfigParamT, Value, oHpiHandlerConfigParamTypeValueArray ), dStructElementEnd() }; -cMarshalType oHpiHandlerConfigParamType = dStruct( oHpiHandlerConfigParamT, oHpiHandlerConfigParamTypeElements ); +cMarshalType oHpiHandlerConfigParamType = dStruct( oHpiHandlerConfigParamTypeElements ); -static cMarshalType HandlerConfigParamsArray = dVarArray( oHpiHandlerConfigParamType, dStructOffset( oHpiHandlerConfigT, NumberOfParams ) ); +static cMarshalType HandlerConfigParamsArray = dVarArray( 0, oHpiHandlerConfigParamT, oHpiHandlerConfigParamType ); static cMarshalType oHpiHandlerConfigTypeElements[] = { dStructElement( oHpiHandlerConfigT, NumberOfParams, SaHpiUint8Type ), dStructElement( oHpiHandlerConfigT, Params, HandlerConfigParamsArray ), dStructElementEnd() }; -cMarshalType oHpiHandlerConfigType = dStruct( oHpiHandlerConfigT, oHpiHandlerConfigTypeElements ); +cMarshalType oHpiHandlerConfigType = dStruct( oHpiHandlerConfigTypeElements ); // entity static cMarshalType SaHpiEntityElements[] = @@ -68,10 +68,10 @@ dStructElementEnd() }; -cMarshalType SaHpiEntityType = dStruct( SaHpiEntityT, SaHpiEntityElements ); +cMarshalType SaHpiEntityType = dStruct( SaHpiEntityElements ); // entity path -static cMarshalType SaHpiEntityPathEntryArray = dArray( SaHpiEntityType, SAHPI_MAX_ENTITY_PATH ); +static cMarshalType SaHpiEntityPathEntryArray = dArray( SAHPI_MAX_ENTITY_PATH, SaHpiEntityT, SaHpiEntityType ); static cMarshalType SaHpiEntityPathElements[] = @@ -80,10 +80,10 @@ dStructElementEnd() }; -cMarshalType SaHpiEntityPathType = dStruct( SaHpiEntityPathT, SaHpiEntityPathElements ); +cMarshalType SaHpiEntityPathType = dStruct( SaHpiEntityPathElements ); // sensors -static cMarshalType SaHpiSensorInterpretedUnionBufferArray = dArray( SaHpiUint8Type, SAHPI_SENSOR_BUFFER_LENGTH ); +static cMarshalType SaHpiSensorInterpretedUnionBufferArray = dArray( SAHPI_SENSOR_BUFFER_LENGTH, SaHpiUint8T, SaHpiUint8Type ); static cMarshalType SaHpiSensorReadingUnionElements[] = { @@ -94,9 +94,7 @@ dUnionElementEnd() }; -static cMarshalType SaHpiSensorReadingUnionType = dUnion( 1, - SaHpiSensorReadingUnionT, - SaHpiSensorReadingUnionElements ); +static cMarshalType SaHpiSensorReadingUnionType = dUnion( 1, SaHpiSensorReadingUnionElements ); // sensor reading static cMarshalType SaHpiSensorReadingTElements[] = @@ -107,7 +105,7 @@ dStructElementEnd() }; -cMarshalType SaHpiSensorReadingType = dStruct( SaHpiSensorReadingT, SaHpiSensorReadingTElements ); +cMarshalType SaHpiSensorReadingType = dStruct( SaHpiSensorReadingTElements ); // sensor threshold values @@ -125,7 +123,7 @@ dStructElementEnd() }; -cMarshalType SaHpiSensorThresholdsType = dStruct( SaHpiSensorThresholdsT, SaHpiSensorThresholdsElements ); +cMarshalType SaHpiSensorThresholdsType = dStruct( SaHpiSensorThresholdsElements ); // sensor range @@ -142,7 +140,7 @@ }; -cMarshalType SaHpiSensorRangeType = dStruct( SaHpiSensorRangeT, SaHpiSensorRangeElements ); +cMarshalType SaHpiSensorRangeType = dStruct( SaHpiSensorRangeElements ); // sensor units @@ -160,7 +158,7 @@ dStructElementEnd() }; -cMarshalType SaHpiSensorDataFormatType = dStruct( SaHpiSensorDataFormatT, SaHpiSensorDataFormatElements ); +cMarshalType SaHpiSensorDataFormatType = dStruct( SaHpiSensorDataFormatElements ); // threshold support @@ -174,7 +172,7 @@ dStructElementEnd() }; -cMarshalType SaHpiSensorThdDefnType = dStruct( SaHpiSensorThdDefnT, SaHpiSensorThdDefnElements ); +cMarshalType SaHpiSensorThdDefnType = dStruct( SaHpiSensorThdDefnElements ); // sensor record @@ -193,12 +191,12 @@ dStructElementEnd() }; -cMarshalType SaHpiSensorRecType = dStruct( SaHpiSensorRecT, SaHpiSensorRecElements ); +cMarshalType SaHpiSensorRecType = dStruct( SaHpiSensorRecElements ); // stream control state -static cMarshalType SaHpiCtrlStateStreamArray = dArray( SaHpiUint8Type, SAHPI_CTRL_MAX_STREAM_LENGTH ); +static cMarshalType SaHpiCtrlStateStreamArray = dArray( SAHPI_CTRL_MAX_STREAM_LENGTH, SaHpiUint8T, SaHpiUint8Type ); static cMarshalType SaHpiCtrlStateStreamElements[] = @@ -209,7 +207,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlStateStreamType = dStruct( SaHpiCtrlStateStreamT, SaHpiCtrlStateStreamElements ); +cMarshalType SaHpiCtrlStateStreamType = dStruct( SaHpiCtrlStateStreamElements ); // text control state @@ -221,12 +219,12 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlStateTextType = dStruct( SaHpiCtrlStateTextT, SaHpiCtrlStateTextElements ); +cMarshalType SaHpiCtrlStateTextType = dStruct( SaHpiCtrlStateTextElements ); // OEM control state -static cMarshalType SaHpiCtrlStateOemBodyArray = dArray( SaHpiUint8Type, SAHPI_CTRL_MAX_OEM_BODY_LENGTH ); +static cMarshalType SaHpiCtrlStateOemBodyArray = dArray( SAHPI_CTRL_MAX_OEM_BODY_LENGTH, SaHpiUint8T, SaHpiUint8Type ); static cMarshalType SaHpiCtrlStateOemElements[] = { @@ -236,7 +234,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlStateOemType = dStruct( SaHpiCtrlStateOemT, SaHpiCtrlStateOemElements ); +cMarshalType SaHpiCtrlStateOemType = dStruct( SaHpiCtrlStateOemElements ); static cMarshalType SaHpiCtrlStateUnionElements[] = @@ -251,7 +249,7 @@ }; -static cMarshalType SaHpiCtrlStateUnionType = dUnion( 0, SaHpiCtrlStateUnionT, SaHpiCtrlStateUnionElements ); +static cMarshalType SaHpiCtrlStateUnionType = dUnion( 0, SaHpiCtrlStateUnionElements ); static cMarshalType SaHpiCtrlStateElements[] = { @@ -260,7 +258,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlStateType = dStruct( SaHpiCtrlStateT, SaHpiCtrlStateElements ); +cMarshalType SaHpiCtrlStateType = dStruct( SaHpiCtrlStateElements ); // control rdr record types @@ -271,7 +269,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlRecDigitalType = dStruct( SaHpiCtrlRecDigitalT, SaHpiCtrlRecDigitalElements ); +cMarshalType SaHpiCtrlRecDigitalType = dStruct( SaHpiCtrlRecDigitalElements ); static cMarshalType SaHpiCtrlRecDiscreteElements[] = @@ -280,7 +278,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlRecDiscreteType = dStruct( SaHpiCtrlRecDiscreteT, SaHpiCtrlRecDiscreteElements ); +cMarshalType SaHpiCtrlRecDiscreteType = dStruct( SaHpiCtrlRecDiscreteElements ); static cMarshalType SaHpiCtrlRecAnalogElements[] = @@ -291,7 +289,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlRecAnalogType = dStruct( SaHpiCtrlRecAnalogT, SaHpiCtrlRecAnalogElements ); +cMarshalType SaHpiCtrlRecAnalogType = dStruct( SaHpiCtrlRecAnalogElements ); static cMarshalType SaHpiCtrlRecStreamElements[] = @@ -300,7 +298,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlRecStreamType = dStruct( SaHpiCtrlRecStreamT, SaHpiCtrlRecStreamElements ); +cMarshalType SaHpiCtrlRecStreamType = dStruct( SaHpiCtrlRecStreamElements ); static cMarshalType SaHpiCtrlRecTextElements[] = @@ -313,10 +311,10 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlRecTextType = dStruct( SaHpiCtrlRecTextT, SaHpiCtrlRecTextElements ); +cMarshalType SaHpiCtrlRecTextType = dStruct( SaHpiCtrlRecTextElements ); -static cMarshalType SaHpiCtrlRecOemConfigDataArray = dArray( SaHpiUint8Type, SAHPI_CTRL_OEM_CONFIG_LENGTH ); +static cMarshalType SaHpiCtrlRecOemConfigDataArray = dArray( SAHPI_CTRL_OEM_CONFIG_LENGTH, SaHpiUint8T, SaHpiUint8Type ); static cMarshalType SaHpiCtrlRecOemElements[] = { @@ -326,7 +324,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlRecOemType = dStruct( SaHpiCtrlRecOemT, SaHpiCtrlRecOemElements ); +cMarshalType SaHpiCtrlRecOemType = dStruct( SaHpiCtrlRecOemElements ); static cMarshalType SaHpiCtrlRecUnionElements[] = @@ -340,7 +338,7 @@ dUnionElementEnd() }; -static cMarshalType SaHpiCtrlRecUnionType = dUnion( 2, SaHpiCtrlRecUnionT, SaHpiCtrlRecUnionElements ); +static cMarshalType SaHpiCtrlRecUnionType = dUnion( 2, SaHpiCtrlRecUnionElements ); // control rdr mode @@ -352,7 +350,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlDefaultModeType = dStruct( SaHpiCtrlDefaultModeT, SaHpiCtrlDefaultModeElements ); +cMarshalType SaHpiCtrlDefaultModeType = dStruct( SaHpiCtrlDefaultModeElements ); static cMarshalType SaHpiCtrlRecElements[] = @@ -368,7 +366,7 @@ dStructElementEnd() }; -cMarshalType SaHpiCtrlRecType = dStruct( SaHpiCtrlRecT, SaHpiCtrlRecElements ); +cMarshalType SaHpiCtrlRecType = dStruct( SaHpiCtrlRecElements ); // entity inventory data @@ -383,7 +381,7 @@ dStructElementEnd() }; -cMarshalType SaHpiIdrFieldType = dStruct( SaHpiIdrFieldT, SaHpiIdrFieldTElements ); +cMarshalType SaHpiIdrFieldType = dStruct( SaHpiIdrFieldTElements ); static cMarshalType SaHpiIdrAreaHeaderTElements[] = { @@ -394,7 +392,7 @@ dStructElementEnd() }; -cMarshalType SaHpiIdrAreaHeaderType = dStruct( SaHpiIdrAreaHeaderT, SaHpiIdrAreaHeaderTElements ); +cMarshalType SaHpiIdrAreaHeaderType = dStruct( SaHpiIdrAreaHeaderTElements ); static cMarshalType SaHpiIdrInfoTElements[] = { @@ -405,7 +403,7 @@ dStructElementEnd() }; -cMarshalType SaHpiIdrInfoType = dStruct( SaHpiIdrInfoT, SaHpiIdrInfoTElements ); +cMarshalType SaHpiIdrInfoType = dStruct( SaHpiIdrInfoTElements ); // inventory resource data records @@ -418,7 +416,7 @@ dStructElementEnd() }; -cMarshalType SaHpiInventoryRecType = dStruct( SaHpiInventoryRecT, SaHpiInventoryRecElements ); +cMarshalType SaHpiInventoryRecType = dStruct( SaHpiInventoryRecElements ); // watchdogs @@ -437,7 +435,7 @@ dStructElementEnd() }; -cMarshalType SaHpiWatchdogType = dStruct( SaHpiWatchdogT, SaHpiWatchdogElements ); +cMarshalType SaHpiWatchdogType = dStruct( SaHpiWatchdogElements ); // watchdog resource data records @@ -449,12 +447,12 @@ dStructElementEnd() }; -cMarshalType SaHpiWatchdogRecType = dStruct( SaHpiWatchdogRecT, SaHpiWatchdogRecElements ); +cMarshalType SaHpiWatchdogRecType = dStruct( SaHpiWatchdogRecElements ); // annunciators -static cMarshalType SaHpiNameDataArray = dArray( SaHpiUint8Type, SA_HPI_MAX_NAME_LENGTH ); +static cMarshalType SaHpiNameDataArray = dArray( SA_HPI_MAX_NAME_LENGTH, SaHpiUint8T, SaHpiUint8Type ); static cMarshalType SaHpiNameElements[] = { @@ -463,7 +461,7 @@ dStructElementEnd() }; -cMarshalType SaHpiNameType = dStruct( SaHpiNameT, SaHpiNameElements ); +cMarshalType SaHpiNameType = dStruct( SaHpiNameElements ); @@ -481,7 +479,7 @@ dStructElementEnd() }; -cMarshalType SaHpiConditionType = dStruct( SaHpiConditionT, SaHpiConditionTypeElements ); +cMarshalType SaHpiConditionType = dStruct( SaHpiConditionTypeElements ); static cMarshalType SaHpiAnnouncementTypeElements[] = @@ -495,7 +493,7 @@ dStructElementEnd() }; -cMarshalType SaHpiAnnouncementType = dStruct( SaHpiAnnouncementT, SaHpiAnnouncementTypeElements ); +cMarshalType SaHpiAnnouncementType = dStruct( SaHpiAnnouncementTypeElements ); // annunciators rdr @@ -510,7 +508,7 @@ dStructElementEnd() }; -cMarshalType SaHpiAnnunciatorRecType = dStruct( SaHpiAnnunciatorRecT, SaHpiAnnunciatorRecElements ); +cMarshalType SaHpiAnnunciatorRecType = dStruct( SaHpiAnnunciatorRecElements ); //DIMIs @@ -521,7 +519,7 @@ dStructElement( SaHpiDimiInfoT, TestNumUpdateCounter, SaHpiUint32Type ), dStructElementEnd() }; -cMarshalType SaHpiDimiInfoType = dStruct ( SaHpiDimiInfoT, SaHpiDimiInfoElements ); +cMarshalType SaHpiDimiInfoType = dStruct( SaHpiDimiInfoElements ); static cMarshalType SaHpiDimiTestParameterValueUnionTypeElements[] = { @@ -532,7 +530,7 @@ dUnionElement( SAHPI_DIMITEST_PARAM_TYPE_TEXT, SaHpiFloat64Type ), dUnionElementEnd() }; -cMarshalType SaHpiDimiTestParameterValueUnionType = dUnion( 2, SaHpiDimiTestParameterValueUnionT, SaHpiDimiTestParameterValueUnionTypeElements ); +cMarshalType SaHpiDimiTestParameterValueUnionType = dUnion( 2, SaHpiDimiTestParameterValueUnionTypeElements ); static cMarshalType SaHpiDimiTestParamValue2TypeElements[] = { @@ -542,7 +540,7 @@ dUnionElement( SAHPI_DIMITEST_PARAM_TYPE_TEXT, SaHpi... [truncated message content] |
From: <av...@us...> - 2010-11-30 13:28:28
|
Revision: 7177 http://openhpi.svn.sourceforge.net/openhpi/?rev=7177&view=rev Author: avpak Date: 2010-11-30 13:28:22 +0000 (Tue, 30 Nov 2010) Log Message: ----------- Fixed broken tests Modified Paths: -------------- openhpi/trunk/include/oHpi.h openhpi/trunk/openhpid/ohpi.c Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-11-30 12:09:25 UTC (rev 7176) +++ openhpi/trunk/include/oHpi.h 2010-11-30 13:28:22 UTC (rev 7177) @@ -20,6 +20,8 @@ #ifndef __OHPI_H #define __OHPI_H +#include <stdlib.h> + #include <SaHpi.h> #include <glib.h> #include <oh_utils.h> Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-11-30 12:09:25 UTC (rev 7176) +++ openhpi/trunk/openhpid/ohpi.c 2010-11-30 13:28:22 UTC (rev 7177) @@ -17,6 +17,8 @@ * Ulrich Kleber <uli...@us...> */ +#include <string.h> + #include <oHpi.h> #include <oh_config.h> #include <oh_init.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-12-01 13:17:05
|
Revision: 7180 http://openhpi.svn.sourceforge.net/openhpi/?rev=7180&view=rev Author: avpak Date: 2010-12-01 13:16:58 +0000 (Wed, 01 Dec 2010) Log Message: ----------- Feature request #3064210 Modified Paths: -------------- openhpi/trunk/clients/hpigensimdata.c openhpi/trunk/plugins/dynamic_simulator/new_sim_file.cpp openhpi/trunk/plugins/dynamic_simulator/new_sim_file_util.h openhpi/trunk/plugins/dynamic_simulator/new_sim_file_watchdog.cpp openhpi/trunk/simulation.data.example Modified: openhpi/trunk/clients/hpigensimdata.c =================================================================== --- openhpi/trunk/clients/hpigensimdata.c 2010-11-30 15:46:30 UTC (rev 7179) +++ openhpi/trunk/clients/hpigensimdata.c 2010-12-01 13:16:58 UTC (rev 7180) @@ -65,7 +65,7 @@ #define INVENTORY_DATA "INVENTORY_DATA" #define INV_AREA_DATA "INV_AREA" #define INV_FIELD_DATA "INV_FIELD" -#define WTD_GET "WTD_GET" +#define WDT_GET "WDT_GET" #define ANN_DATA "ANNUNCIATOR_DATA" #define ANNOUNCEMENT "ANNOUNCEMENT" #define DIMI_DATA "DIMI_DATA" @@ -193,7 +193,7 @@ int offset, SaHpiSessionIdT sessionId, SaHpiResourceIdT resId, - SaHpiWatchdogRecT *wtd); + SaHpiWatchdogRecT *wdt); static void print_annunciator_rdr(FILE *out, int offset, @@ -1138,32 +1138,32 @@ * Watchdog functions **/ static SaErrorT print_watchdog_rdr(FILE *out, int offset, SaHpiSessionIdT sessionId, - SaHpiResourceIdT resId, SaHpiWatchdogRecT *wtd) { + SaHpiResourceIdT resId, SaHpiWatchdogRecT *wdt) { int myoffset = offset; SaErrorT rv = SA_OK; - fprintf(out,"%sWatchdogNum=%u\n", offSet[myoffset], wtd->WatchdogNum); - fprintf(out,"%sOem=%u\n", offSet[myoffset], wtd->Oem); + fprintf(out,"%sWatchdogNum=%u\n", offSet[myoffset], wdt->WatchdogNum); + fprintf(out,"%sOem=%u\n", offSet[myoffset], wdt->Oem); - SaHpiWatchdogT wtdTimer; - rv = saHpiWatchdogTimerGet(sessionId, resId, wtd->WatchdogNum, &wtdTimer); + SaHpiWatchdogT wdtTimer; + rv = saHpiWatchdogTimerGet(sessionId, resId, wdt->WatchdogNum, &wdtTimer); if (rv != SA_OK) { fprintf(stderr, "WatchdogTimerGet returns %s for ResId %u Num %u\n", - oh_lookup_error(rv), resId, wtd->WatchdogNum); + oh_lookup_error(rv), resId, wdt->WatchdogNum); return rv; } - fprintf(out,"%s%s={\n",offSet[myoffset++],WTD_GET); - fprintf(out,"%sLog=%d\n", offSet[myoffset], wtdTimer.Log); - fprintf(out,"%sRunning=%d\n", offSet[myoffset], wtdTimer.Running); - fprintf(out,"%sTimerUse=0x%02X\n", offSet[myoffset], wtdTimer.TimerUse); - fprintf(out,"%sTimerAction=0x%02X\n", offSet[myoffset], wtdTimer.TimerAction); - fprintf(out,"%sPretimerInterrupt=0x%02X\n", offSet[myoffset], wtdTimer.PretimerInterrupt); - fprintf(out,"%sPreTimeoutInterval=%u\n", offSet[myoffset], wtdTimer.PreTimeoutInterval); - fprintf(out,"%sTimerUseExpFlags=0x%02X\n", offSet[myoffset], wtdTimer.TimerUseExpFlags); - fprintf(out,"%sInitialCount=%u\n", offSet[myoffset], wtdTimer.InitialCount); - fprintf(out,"%sPresentCount=%u\n", offSet[myoffset], wtdTimer.PresentCount); - fprintf(out, "%s}\n", offSet[--myoffset]); // WTD_GET + fprintf(out,"%s%s={\n",offSet[myoffset++],WDT_GET); + fprintf(out,"%sLog=%d\n", offSet[myoffset], wdtTimer.Log); + fprintf(out,"%sRunning=%d\n", offSet[myoffset], wdtTimer.Running); + fprintf(out,"%sTimerUse=0x%02X\n", offSet[myoffset], wdtTimer.TimerUse); + fprintf(out,"%sTimerAction=0x%02X\n", offSet[myoffset], wdtTimer.TimerAction); + fprintf(out,"%sPretimerInterrupt=0x%02X\n", offSet[myoffset], wdtTimer.PretimerInterrupt); + fprintf(out,"%sPreTimeoutInterval=%u\n", offSet[myoffset], wdtTimer.PreTimeoutInterval); + fprintf(out,"%sTimerUseExpFlags=0x%02X\n", offSet[myoffset], wdtTimer.TimerUseExpFlags); + fprintf(out,"%sInitialCount=%u\n", offSet[myoffset], wdtTimer.InitialCount); + fprintf(out,"%sPresentCount=%u\n", offSet[myoffset], wdtTimer.PresentCount); + fprintf(out, "%s}\n", offSet[--myoffset]); // WDT_GET return rv; } Modified: openhpi/trunk/plugins/dynamic_simulator/new_sim_file.cpp =================================================================== --- openhpi/trunk/plugins/dynamic_simulator/new_sim_file.cpp 2010-11-30 15:46:30 UTC (rev 7179) +++ openhpi/trunk/plugins/dynamic_simulator/new_sim_file.cpp 2010-12-01 13:16:58 UTC (rev 7180) @@ -191,7 +191,7 @@ m_tokens.Add(new SimulatorToken( "INVENTORY_DATA", INVENTORY_DATA_TOKEN_HANDLER )); m_tokens.Add(new SimulatorToken( "INV_AREA", INV_AREA_TOKEN_HANDLER )); m_tokens.Add(new SimulatorToken( "INV_FIELD", INV_FIELD_TOKEN_HANDLER )); - m_tokens.Add(new SimulatorToken( "WTD_GET", WTD_GET_TOKEN_HANDLER )); + m_tokens.Add(new SimulatorToken( "WDT_GET", WDT_GET_TOKEN_HANDLER )); m_tokens.Add(new SimulatorToken( "ANNUNCIATOR_DATA", ANNUNCIATOR_DATA_TOKEN_HANDLER )); m_tokens.Add(new SimulatorToken( "ANNOUNCEMENT", ANNOUNCEMENT_TOKEN_HANDLER )); m_tokens.Add(new SimulatorToken( "DIMI_DATA", DIMI_DATA_TOKEN_HANDLER )); Modified: openhpi/trunk/plugins/dynamic_simulator/new_sim_file_util.h =================================================================== --- openhpi/trunk/plugins/dynamic_simulator/new_sim_file_util.h 2010-11-30 15:46:30 UTC (rev 7179) +++ openhpi/trunk/plugins/dynamic_simulator/new_sim_file_util.h 2010-12-01 13:16:58 UTC (rev 7180) @@ -57,7 +57,7 @@ INVENTORY_DATA_TOKEN_HANDLER, INV_AREA_TOKEN_HANDLER, INV_FIELD_TOKEN_HANDLER, - WTD_GET_TOKEN_HANDLER, + WDT_GET_TOKEN_HANDLER, ANNUNCIATOR_DATA_TOKEN_HANDLER, ANNOUNCEMENT_TOKEN_HANDLER, DIMI_DATA_TOKEN_HANDLER, Modified: openhpi/trunk/plugins/dynamic_simulator/new_sim_file_watchdog.cpp =================================================================== --- openhpi/trunk/plugins/dynamic_simulator/new_sim_file_watchdog.cpp 2010-11-30 15:46:30 UTC (rev 7179) +++ openhpi/trunk/plugins/dynamic_simulator/new_sim_file_watchdog.cpp 2010-12-01 13:16:58 UTC (rev 7180) @@ -117,7 +117,7 @@ break; - case WTD_GET_TOKEN_HANDLER: + case WDT_GET_TOKEN_HANDLER: stdlog << "DBG: Start parsing watchdog data.\n"; success = process_watchdog_data(); stdlog << "DBG: Parsing returns success = " << success << "\n"; @@ -147,7 +147,7 @@ /** * Parse the Watchdog Get section * - * Startpoint is the \c WTD_GET_TOKEN_HANDLER. Endpoint is the last \c G_TOKEN_RIGHT_CURLY. + * Startpoint is the \c WDT_GET_TOKEN_HANDLER. Endpoint is the last \c G_TOKEN_RIGHT_CURLY. * * @return bool value success * @@ -166,7 +166,7 @@ cur_token = g_scanner_get_next_token(m_scanner); if (cur_token != G_TOKEN_LEFT_CURLY) { - err("Processing parse control rdr entry - Missing left curly in WTD_GET section"); + err("Processing parse control rdr entry - Missing left curly in WDT_GET section"); success = false; } Modified: openhpi/trunk/simulation.data.example =================================================================== --- openhpi/trunk/simulation.data.example 2010-11-30 15:46:30 UTC (rev 7179) +++ openhpi/trunk/simulation.data.example 2010-12-01 13:16:58 UTC (rev 7180) @@ -538,7 +538,7 @@ RDR_DETAIL { WatchdogNum=0 Oem=0 - WTD_GET={ + WDT_GET={ Log=1 Running=0 TimerUse=0x00 @@ -1615,7 +1615,7 @@ RDR_DETAIL { WatchdogNum=0 Oem=0 - WTD_GET={ + WDT_GET={ Log=1 Running=0 TimerUse=0x00 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-12-01 16:22:29
|
Revision: 7184 http://openhpi.svn.sourceforge.net/openhpi/?rev=7184&view=rev Author: ulikleber Date: 2010-12-01 16:22:19 +0000 (Wed, 01 Dec 2010) Log Message: ----------- Fix for Bug 2986517 oHpi API drawback in multi-domain configurations. New session parameter for oHpiXXX interfaces and necessary changes in clients and tests Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/clients/ohhandler.c openhpi/trunk/clients/ohparam.c openhpi/trunk/include/oHpi.h openhpi/trunk/marshal/marshal_hpi.c openhpi/trunk/openhpid/ohpi.c openhpi/trunk/openhpid/openhpid.cpp openhpi/trunk/openhpid/t/ohpi/hpiinjector.c openhpi/trunk/openhpid/t/ohpi/ohpi_007.c openhpi/trunk/openhpid/t/ohpi/ohpi_008.c openhpi/trunk/openhpid/t/ohpi/ohpi_009.c openhpi/trunk/openhpid/t/ohpi/ohpi_010.c openhpi/trunk/openhpid/t/ohpi/ohpi_024.c openhpi/trunk/openhpid/t/ohpi/ohpi_025.c openhpi/trunk/openhpid/t/ohpi/ohpi_026.c openhpi/trunk/openhpid/t/ohpi/ohpi_027.c openhpi/trunk/openhpid/t/ohpi/ohpi_028.c openhpi/trunk/openhpid/t/ohpi/ohpi_029.c openhpi/trunk/openhpid/t/ohpi/ohpi_030.c openhpi/trunk/openhpid/t/ohpi/ohpi_031.c openhpi/trunk/openhpid/t/ohpi/ohpi_032.c openhpi/trunk/openhpid/t/ohpi/ohpi_033.c openhpi/trunk/openhpid/t/ohpi/ohpi_034.c openhpi/trunk/openhpid/t/ohpi/ohpi_035.c openhpi/trunk/openhpid/t/ohpi/ohpi_036.c openhpi/trunk/openhpid/t/ohpi/ohpi_037.c openhpi/trunk/openhpid/t/ohpi/ohpi_038.c openhpi/trunk/openhpid/t/ohpi/ohpi_039.c openhpi/trunk/openhpid/t/ohpi_tests.txt Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/baselib/oh_client.cpp 2010-12-01 16:22:19 UTC (rev 7184) @@ -5875,6 +5875,7 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiHandlerCreate ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN GHashTable *config, SAHPI_OUT oHpiHandlerIdT *id ) { @@ -5882,16 +5883,19 @@ void *request; char reply[dMaxMessageLength]; char cmd[] = "oHpiHandlerCreate"; - /* TODO: Change oHpi apis to send a domain id */ pcstrmsock pinst = NULL; oHpiHandlerConfigT handler_config; + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (!config || !id) return SA_ERR_HPI_INVALID_PARAMS; if (g_hash_table_size(config)==0) return SA_ERR_HPI_INVALID_PARAMS; - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); + err = oh_get_connx(sid, &dsid, &pinst, &did); if (err) return err; handler_config.NumberOfParams = 0; @@ -5901,16 +5905,18 @@ // now create the handler cHpiMarshal *hm = HpiMarshalFind(eFoHpiHandlerCreate); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerCreate, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerCreate, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest1(hm, request, &handler_config); + pinst->header.m_len = HpiMarshalRequest2(hm, request, + &dsid, &handler_config); + + SendRecv(sid, cmd); - SendRecv(0, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, id); - - oh_delete_connx(pinst); + int mr = HpiDemarshalReply1(pinst->remote_byte_order, + hm, reply + sizeof(cMessageHeader), &err, id); + if (request) g_free(request); @@ -5926,6 +5932,7 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiHandlerDestroy ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id ) { void *request; @@ -5933,24 +5940,30 @@ SaErrorT err = SA_OK; char cmd[] = "oHpiHandlerDestroy"; pcstrmsock pinst = NULL; + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (id == 0) - return SA_ERR_HPI_INVALID_PARAMS; + return SA_ERR_HPI_INVALID_PARAMS; - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); + err = oh_get_connx(sid, &dsid, &pinst, &did); if (err) return err; cHpiMarshal *hm = HpiMarshalFind(eFoHpiHandlerDestroy); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerDestroy, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerDestroy, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest1(hm, request, &id); + pinst->header.m_len = HpiMarshalRequest2(hm, request, + &dsid, &id); + + SendRecv(sid, cmd); - SendRecv(0, cmd); + int mr = HpiDemarshalReply0(pinst->remote_byte_order, + hm, reply + sizeof(cMessageHeader), &err); - int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - - oh_delete_connx(pinst); if (request) g_free(request); @@ -5966,6 +5979,7 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiHandlerInfo ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerInfoT *info, SAHPI_IN GHashTable *conf_params ) @@ -5976,23 +5990,29 @@ char cmd[] = "oHpiHandlerInfo"; pcstrmsock pinst = NULL; oHpiHandlerConfigT config; + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (id == 0 || !info || !conf_params) return SA_ERR_HPI_INVALID_PARAMS; if (g_hash_table_size(conf_params)!=0) return SA_ERR_HPI_INVALID_PARAMS; - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); + err = oh_get_connx(sid, &dsid, &pinst, &did); if (err) return err; cHpiMarshal *hm = HpiMarshalFind(eFoHpiHandlerInfo); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerInfo, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerInfo, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest1(hm, request, &id); + pinst->header.m_len = HpiMarshalRequest2(hm, request, + &dsid, &id); + + SendRecv(sid, cmd); - SendRecv(0, cmd); - int mr = HpiDemarshalReply2(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, info, &config); @@ -6004,7 +6024,6 @@ } g_free(config.Params); - oh_delete_connx(pinst); if (request) g_free(request); @@ -6020,6 +6039,7 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiHandlerGetNext ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerIdT *next_id ) { @@ -6028,24 +6048,30 @@ SaErrorT err = SA_OK; char cmd[] = "oHpiHandlerGetNext"; pcstrmsock pinst = NULL; + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (!next_id) return SA_ERR_HPI_INVALID_PARAMS; - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); + err = oh_get_connx(sid, &dsid, &pinst, &did); if (err) return err; cHpiMarshal *hm = HpiMarshalFind(eFoHpiHandlerGetNext); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerGetNext, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerGetNext, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest1(hm, request, &id); + pinst->header.m_len = HpiMarshalRequest2(hm, request, + &dsid, &id); + + SendRecv(sid, cmd); - SendRecv(0, cmd); + int mr = HpiDemarshalReply1(pinst->remote_byte_order, + hm, reply + sizeof(cMessageHeader), &err, next_id); - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, next_id); - - oh_delete_connx(pinst); if (request) g_free(request); @@ -6068,23 +6094,27 @@ SaErrorT err = SA_OK; char cmd[] = "oHpiHandlerFind"; pcstrmsock pinst = NULL; - + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; + if (sid == 0) return SA_ERR_HPI_INVALID_SESSION; if (!id || !rid) return SA_ERR_HPI_INVALID_PARAMS; - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); + err = oh_get_connx(sid, &dsid, &pinst, &did); if (err) return err; *id = 0; //Initialize output var cHpiMarshal *hm = HpiMarshalFind(eFoHpiHandlerFind); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerFind, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerFind, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &sid, &rid); + pinst->header.m_len = HpiMarshalRequest3(hm, request, + &dsid, &sid, &rid); - SendRecv(0, cmd); + SendRecv(sid, cmd); int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, @@ -6092,8 +6122,6 @@ &err, id); - oh_delete_connx(pinst); - if (request) g_free(request); @@ -6107,6 +6135,7 @@ /* oHpiHandlerRetry */ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiHandlerRetry ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id ) { void *request; @@ -6114,28 +6143,32 @@ SaErrorT err = SA_OK; char cmd[] = "oHpiHandlerRetry"; pcstrmsock pinst = NULL; - - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; + + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; + if (id == 0) + return SA_ERR_HPI_INVALID_PARAMS; + + err = oh_get_connx(sid, &dsid, &pinst, &did); if (err) return err; - if (id == 0) - return SA_ERR_HPI_INVALID_PARAMS; - cHpiMarshal *hm = HpiMarshalFind(eFoHpiHandlerRetry); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerRetry, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiHandlerRetry, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest1(hm, request, &id); + pinst->header.m_len = HpiMarshalRequest2(hm, request, + &dsid, &id); - SendRecv(0, cmd); + SendRecv(sid, cmd); int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - oh_delete_connx(pinst); - if (request) g_free(request); @@ -6151,6 +6184,7 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiGlobalParamGet ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_OUT oHpiGlobalParamT *param ) { void *request; @@ -6158,24 +6192,30 @@ SaErrorT err = SA_OK; char cmd[] = "oHpiGlobalParamGet"; pcstrmsock pinst = NULL; + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (!param) return SA_ERR_HPI_INVALID_PARAMS; - - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); + + err = oh_get_connx(sid, &dsid, &pinst, &did); if (err) return err; cHpiMarshal *hm = HpiMarshalFind(eFoHpiGlobalParamGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiGlobalParamGet, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiGlobalParamGet, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest1(hm, request, param); + pinst->header.m_len = HpiMarshalRequest2(hm, request, + &dsid, param); - SendRecv(0, cmd); + SendRecv(sid, cmd); - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, param); + int mr = HpiDemarshalReply1(pinst->remote_byte_order, + hm, reply + sizeof(cMessageHeader), &err, param); - oh_delete_connx(pinst); if (request) g_free(request); @@ -6191,6 +6231,7 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiGlobalParamSet ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiGlobalParamT *param ) { void *request; @@ -6198,24 +6239,30 @@ SaErrorT err = SA_OK; char cmd[] = "oHpiGlobalParamSet"; pcstrmsock pinst = NULL; + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (!param) - return SA_ERR_HPI_INVALID_PARAMS; - - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); + return SA_ERR_HPI_INVALID_PARAMS; + + err = oh_get_connx(sid, &dsid, &pinst, &did); if (err) return err; cHpiMarshal *hm = HpiMarshalFind(eFoHpiGlobalParamSet); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiGlobalParamSet, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiGlobalParamSet, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest1(hm, request, param); + pinst->header.m_len = HpiMarshalRequest2(hm, request, + &dsid, param); - SendRecv(0, cmd); + SendRecv(sid, cmd); - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, param); + int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, + reply + sizeof(cMessageHeader), &err, param); - oh_delete_connx(pinst); if (request) g_free(request); @@ -6230,6 +6277,7 @@ /* oHpiInjectEvent */ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiInjectEvent ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_IN SaHpiEventT *event, SAHPI_IN SaHpiRptEntryT *rpte, @@ -6240,27 +6288,31 @@ SaErrorT err = SA_OK; char cmd[] = "oHpiInjectEvent"; pcstrmsock pinst = NULL; + SaHpiSessionIdT dsid = 0; + SaHpiDomainIdT did = 0; - err = oh_create_connx(OH_DEFAULT_DOMAIN_ID, &pinst); - if (err) return err; - + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (id == 0 || !event || !rpte || !rdr) return SA_ERR_HPI_INVALID_PARAMS; + + err = oh_get_connx(sid, &dsid, &pinst, &did); + if (err) return err; cHpiMarshal *hm = HpiMarshalFind(eFoHpiInjectEvent); - pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiInjectEvent, hm->m_request_len); + pinst->MessageHeaderInit(eMhMsg, 0, eFoHpiInjectEvent, + hm->m_request_len); request = g_malloc(hm->m_request_len); - pinst->header.m_len = HpiMarshalRequest4(hm, request, &id, event, rpte, rdr); + pinst->header.m_len = HpiMarshalRequest5(hm, request, + &dsid, &id, event, rpte, rdr); - SendRecv(0, cmd); + SendRecv(sid, cmd); int mr = HpiDemarshalReply4(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, &id, event, rpte, rdr); - oh_delete_connx(pinst); - if (request) g_free(request); Modified: openhpi/trunk/clients/hpionIBMblade.c =================================================================== --- openhpi/trunk/clients/hpionIBMblade.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/clients/hpionIBMblade.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -235,7 +235,7 @@ return(0); } - rv = oHpiHandlerInfo(this_handler_id, &handler_info, &config); + rv = oHpiHandlerInfo(sessionid, this_handler_id, &handler_info, &config); if (rv) { if (fdebug) printf("oHpiHandlerInfo returns %s\n", oh_lookup_error(rv)); return(0); Modified: openhpi/trunk/clients/ohhandler.c =================================================================== --- openhpi/trunk/clients/ohhandler.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/clients/ohhandler.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -283,7 +283,7 @@ sessionid); if (fdebug) printf ("Calling oHpiHandlerCreate!\n"); - rv = oHpiHandlerCreate(createparams, &handlerid ); + rv = oHpiHandlerCreate(sessionid, createparams, &handlerid ); if ( rv != SA_OK ) { printf("oHpiHandlerCreate returned %d (%s)\n", @@ -308,7 +308,7 @@ if (fdebug) printf("Go and unload handler %u in domain %u\n", handlerid, domainid); - rv = oHpiHandlerDestroy ( handlerid ); + rv = oHpiHandlerDestroy ( sessionid, handlerid ); if (fdebug) printf("oHpiHandlerDestroy returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -353,7 +353,7 @@ if (fdebug) printf("Go and display handler info for %u\n", handlerid); - rv = oHpiHandlerInfo ( handlerid, &handlerinfo, handlerconfig ); + rv = oHpiHandlerInfo ( sessionid, handlerid, &handlerinfo, handlerconfig ); if (rv==SA_ERR_HPI_NOT_PRESENT) { if (domainid==SAHPI_UNSPECIFIED_DOMAIN_ID) @@ -401,7 +401,7 @@ if (fdebug) printf("Go and get next handler from %u in domain %u\n", handlerid, domainid); - rv = oHpiHandlerGetNext ( handlerid, &nexthandlerid ); + rv = oHpiHandlerGetNext ( sessionid, handlerid, &nexthandlerid ); if (fdebug) printf("oHpiHandlerGetNext returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -465,7 +465,7 @@ if (fdebug) printf("Go and retry loading handler %u in domain %u\n", handlerid, domainid); - rv = oHpiHandlerRetry ( handlerid ); + rv = oHpiHandlerRetry ( sessionid, handlerid ); if (rv!=SA_OK) { printf("oHpiHandlerRetry returned %d (%s)\n", @@ -495,7 +495,7 @@ printf("Handlers defined in default domain:\n"); else printf("Handlers defined in Domain %u:\n",domainid); while (rv==SA_OK) { - rv = oHpiHandlerGetNext ( handlerid, &nexthandlerid ); + rv = oHpiHandlerGetNext ( sessionid, handlerid, &nexthandlerid ); if (fdebug) printf("oHpiHandlerGetNext (%u) returned %d (%s)\n", handlerid, rv, oh_lookup_error(rv)); @@ -505,7 +505,7 @@ config = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, g_free ); - rv = oHpiHandlerInfo ( nexthandlerid, &handlerinfo, config ); + rv = oHpiHandlerInfo ( sessionid, nexthandlerid, &handlerinfo, config ); if (rv!=SA_OK) { printf("oHpiHandlerInfo for handler %u returned %d (%s)\n", nexthandlerid, rv, oh_lookup_error(rv)); Modified: openhpi/trunk/clients/ohparam.c =================================================================== --- openhpi/trunk/clients/ohparam.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/clients/ohparam.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -187,7 +187,7 @@ if (fdebug) printf("Go and read global parameters in domain %u\n", domainid); param.Type = OHPI_ON_EP; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_ON_EP) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -197,7 +197,7 @@ oh_print_ep (&(param.u.OnEP),0); param.Type = OHPI_LOG_ON_SEV; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_LOG_ON_SEV) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -206,7 +206,7 @@ printf("OPENHPI_LOG_ON_SEV = %s\n", oh_lookup_severity (param.u.LogOnSev)); param.Type =OHPI_EVT_QUEUE_LIMIT; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_EVT_QUEUE_LIMIT) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -215,7 +215,7 @@ printf("OPENHPI_EVT_QUEUE_LIMIT = %u\n", param.u.EvtQueueLimit); param.Type =OHPI_DEL_SIZE_LIMIT; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_DEL_SIZE_LIMIT) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -224,7 +224,7 @@ printf("OPENHPI_DEL_SIZE_LIMIT = %u\n", param.u.DelSizeLimit); param.Type =OHPI_DEL_SAVE; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_DEL_SAVE) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -235,7 +235,7 @@ else printf("FALSE\n"); param.Type =OHPI_DAT_SIZE_LIMIT; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_DAT_SIZE_LIMIT) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -244,7 +244,7 @@ printf("OPENHPI_DAT_SIZE_LIMIT = %u\n", param.u.DatSizeLimit); param.Type =OHPI_DAT_USER_LIMIT; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_DAT_USER_LIMIT) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -253,7 +253,7 @@ printf("OPENHPI_DAT_USER_LIMIT = %u\n", param.u.DatUserLimit); param.Type =OHPI_DAT_SAVE; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_DAT_SAVE) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -264,7 +264,7 @@ else printf("FALSE\n"); param.Type =OHPI_PATH; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_PATH) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -273,7 +273,7 @@ printf("OPENHPI_PATH = %s\n",param.u.Path); param.Type =OHPI_VARPATH; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_VARPATH) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -282,7 +282,7 @@ printf("OPENHPI_VARPATH = %s\n",param.u.VarPath); param.Type =OHPI_CONF; - rv = oHpiGlobalParamGet (¶m); + rv = oHpiGlobalParamGet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamGet(OHPI_CONF) returned %d (%s)\n", rv, oh_lookup_error(rv)); @@ -338,7 +338,7 @@ else return SA_ERR_HPI_INVALID_PARAMS; break; } - rv = oHpiGlobalParamSet (¶m); + rv = oHpiGlobalParamSet (sessionid, ¶m); if (rv!=SA_OK) { printf("oHpiGlobalParamSet returned %d (%s)\n", Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/include/oHpi.h 2010-12-01 16:22:19 UTC (rev 7184) @@ -98,15 +98,19 @@ /* Exported OpenHPI handler (plugin instance) calls */ SaErrorT SAHPI_API oHpiHandlerCreate ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN GHashTable *config, SAHPI_OUT oHpiHandlerIdT *id ); SaErrorT SAHPI_API oHpiHandlerDestroy ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id ); SaErrorT SAHPI_API oHpiHandlerInfo ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerInfoT *info, SAHPI_IN GHashTable *conf_params ); SaErrorT SAHPI_API oHpiHandlerGetNext ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerIdT *next_id ); SaErrorT SAHPI_API oHpiHandlerFind ( @@ -114,16 +118,20 @@ SAHPI_IN SaHpiResourceIdT rid, SAHPI_OUT oHpiHandlerIdT *id ); SaErrorT SAHPI_API oHpiHandlerRetry ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id ); /* Global parameters */ SaErrorT SAHPI_API oHpiGlobalParamGet ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_OUT oHpiGlobalParamT *param ); SaErrorT SAHPI_API oHpiGlobalParamSet ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiGlobalParamT *param ); /* Injector */ SaErrorT SAHPI_API oHpiInjectEvent ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_IN SaHpiEventT *event, SAHPI_IN SaHpiRptEntryT *rpte, Modified: openhpi/trunk/marshal/marshal_hpi.c =================================================================== --- openhpi/trunk/marshal/marshal_hpi.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/marshal/marshal_hpi.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -1884,7 +1884,8 @@ static const cMarshalType *oHpiHandlerCreateIn[] = { - &oHpiHandlerConfigType, // dummy entry + &SaHpiSessionIdType, // session id (SaHpiSessionIdT) + &oHpiHandlerConfigType, // handler config params 0 }; @@ -1898,6 +1899,7 @@ static const cMarshalType *oHpiHandlerDestroyIn[] = { + &SaHpiSessionIdType, // session id (SaHpiSessionIdT) &oHpiHandlerIdType, // handler id 0 }; @@ -1911,6 +1913,7 @@ static const cMarshalType *oHpiHandlerInfoIn[] = { + &SaHpiSessionIdType, // session id (SaHpiSessionIdT) &oHpiHandlerIdType, // handler id 0 }; @@ -1926,6 +1929,7 @@ static const cMarshalType *oHpiHandlerGetNextIn[] = { + &SaHpiSessionIdType, // session id (SaHpiSessionIdT) &oHpiHandlerIdType, // handler id 0 }; @@ -1939,33 +1943,35 @@ static const cMarshalType *oHpiHandlerFindIn[] = { - &SaHpiSessionIdType, // session id - &SaHpiResourceIdType, // resource id - 0 + &SaHpiSessionIdType, // session id + &SaHpiResourceIdType, // resource id + 0 }; static const cMarshalType *oHpiHandlerFindOut[] = { - &SaErrorType, // result (SaErrorT) - &oHpiHandlerIdType, // handler id - 0 + &SaErrorType, // result (SaErrorT) + &oHpiHandlerIdType, // handler id + 0 }; static const cMarshalType *oHpiHandlerRetryIn[] = { - &oHpiHandlerIdType, // handler id - 0 + &SaHpiSessionIdType, // session id (SaHpiSessionIdT) + &oHpiHandlerIdType, // handler id + 0 }; static const cMarshalType *oHpiHandlerRetryOut[] = { - &SaErrorType, // result (SaErrorT) - 0 + &SaErrorType, // result (SaErrorT) + 0 }; static const cMarshalType *oHpiGlobalParamGetIn[] = { + &SaHpiSessionIdType, // session id (SaHpiSessionIdT) &oHpiGlobalParamType, // global param 0 }; @@ -1980,6 +1986,7 @@ static const cMarshalType *oHpiGlobalParamSetIn[] = { + &SaHpiSessionIdType, // session id (SaHpiSessionIdT) &oHpiGlobalParamType, // global param 0 }; @@ -1993,6 +2000,7 @@ static const cMarshalType *oHpiInjectEventIn[] = { + &SaHpiSessionIdType, // session id (SaHpiSessionIdT) &oHpiHandlerIdType, // global param &SaHpiEventType, &SaHpiRptEntryType, Modified: openhpi/trunk/openhpid/ohpi.c =================================================================== --- openhpi/trunk/openhpid/ohpi.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/openhpid/ohpi.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -53,8 +53,9 @@ /** * oHpiHandlerCreate - * @config: IN. Hash table. Holds configuration information used by handler. - * @id: IN/OUT. The id of the newly created handler is returned here. + * @sid: IN. a valid session id + * @config: IN. Hash table. Holds configuration information used by handler. + * @id: IN/OUT. The id of the newly created handler is returned here. * * Creates a new handler (instance of a plugin). Plugin handlers are what * respond to most API calls. @@ -66,49 +67,75 @@ * opening the handler. **/ SaErrorT SAHPI_API oHpiHandlerCreate ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN GHashTable *config, SAHPI_OUT oHpiHandlerIdT *id ) { SaErrorT error = SA_OK; - + SaHpiDomainIdT did; + struct oh_domain *d = NULL; + + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (!config || !id) return SA_ERR_HPI_INVALID_PARAMS; if (g_hash_table_size(config)==0) return SA_ERR_HPI_INVALID_PARAMS; + + OH_CHECK_INIT_STATE(sid); + OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ - if (oh_init()) return SA_ERR_HPI_ERROR; + if (oh_init()) error = SA_ERR_HPI_INTERNAL_ERROR; - error = oh_create_handler(config, id); + if (error == SA_OK) + error = oh_create_handler(config, id); + + oh_release_domain(d); /* Unlock domain */ return error; } /** * oHpiHandlerDestroy - * @id: IN. The id of the handler to destroy + * @sid: IN. a valid session id + * @id: IN. The id of the handler to destroy * * Destroys a handler. Calls the plugin's abi close function. * * Returns: SA_OK on success. Minus SA_OK on error. **/ SaErrorT SAHPI_API oHpiHandlerDestroy ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id ) { + SaHpiDomainIdT did; + struct oh_domain *d = NULL; + SaErrorT error = SA_OK; + + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (id == 0) return SA_ERR_HPI_INVALID_PARAMS; - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; + OH_CHECK_INIT_STATE(sid); + OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ + + if (oh_init()) error = SA_ERR_HPI_INTERNAL_ERROR; - if (oh_destroy_handler(id)) - return SA_ERR_HPI_ERROR; - - return SA_OK; + if (error == SA_OK) + if (oh_destroy_handler(id)) error = SA_ERR_HPI_ERROR; + + oh_release_domain(d); /* Unlock domain */ + return error; } /** * oHpiHandlerInfo - * @id: IN. The id of the handler to query - * @info: IN/OUT. Pointer to struct for holding handler information + * @sid: IN. a valid session id + * @id: IN. The id of the handler to query + * @info: IN/OUT. Pointer to struct for holding handler information * @conf_params: IN/OUT Pointer to pre-allocated hash-table, for holding the * handler's configuration parameters * @@ -122,22 +149,35 @@ g_hash_table_insert ( newhash, g_strdup(key), g_strdup(value) ); } SaErrorT SAHPI_API oHpiHandlerInfo ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerInfoT *info, - SAHPI_IN GHashTable *conf_params ) + SAHPI_INOUT GHashTable *conf_params ) { + SaHpiDomainIdT did; + struct oh_domain *d = NULL; struct oh_handler *h = NULL; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (id == 0 || !info || !conf_params) return SA_ERR_HPI_INVALID_PARAMS; if (g_hash_table_size(conf_params)!=0) return SA_ERR_HPI_INVALID_PARAMS; - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; + OH_CHECK_INIT_STATE(sid); + OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ + if (oh_init()) { + oh_release_domain(d); /* Unlock domain */ + return SA_ERR_HPI_INTERNAL_ERROR; + } + h = oh_get_handler(id); if (!h) { err("Handler %d not found.", id); + oh_release_domain(d); /* Unlock domain */ return SA_ERR_HPI_NOT_PRESENT; } @@ -158,15 +198,17 @@ g_strdup("password"), g_strdup("********")); oh_release_handler(h); + oh_release_domain(d); /* Unlock domain */ return SA_OK; } /** * oHpiHandlerGetNext - * @id: IN. Id of handler to search for. - * @next_id: IN/OUT. The id of the handler next to the handler being searched for - * will be returned here. + * @sid: IN. a valid session id + * @id: IN. Id of handler to search for. + * @next_id: OUT. The id of the handler next to the handler being searched for + * will be returned here. * * Used for iterating through all loaded handlers. If you pass * 0 (SAHPI_FIRST_ENTRY), you will get the id of the first handler returned @@ -175,19 +217,31 @@ * Returns: SA_OK on success. Minus SA_OK on error. **/ SaErrorT SAHPI_API oHpiHandlerGetNext ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_OUT oHpiHandlerIdT *next_id ) { - if (!next_id) { + SaHpiDomainIdT did; + struct oh_domain *d = NULL; + SaErrorT error = SA_OK; + + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; + if (!next_id) return SA_ERR_HPI_INVALID_PARAMS; - } - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; + OH_CHECK_INIT_STATE(sid); + OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ + + if (oh_init()) error = SA_ERR_HPI_INTERNAL_ERROR; - if (oh_getnext_handler_id(id, next_id)) - return SA_ERR_HPI_NOT_PRESENT; + if (error == SA_OK) + if (oh_getnext_handler_id(id, next_id)) + error = SA_ERR_HPI_NOT_PRESENT; - return SA_OK; + oh_release_domain(d); /* Unlock domain */ + return error; } /** @@ -241,25 +295,43 @@ /** * oHpiHandlerRetry - * @id: handler id + * @sid: IN. a valid session id + * @id: IN handler id * * Returns: SA_OK if handler opens successfully. **/ SaErrorT SAHPI_API oHpiHandlerRetry ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id ) { + SaHpiDomainIdT did; + struct oh_domain *d = NULL; struct oh_handler *h = NULL; SaErrorT error = SA_OK; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (id == 0) return SA_ERR_HPI_INVALID_PARAMS; - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; + OH_CHECK_INIT_STATE(sid); + OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ + if (oh_init()) { + oh_release_domain(d); /* Unlock domain */ + return SA_ERR_HPI_INTERNAL_ERROR; + } + h = oh_get_handler(id); - if (!h) return SA_ERR_HPI_NOT_PRESENT; + if (!h) { + oh_release_domain(d); /* Unlock domain */ + return SA_ERR_HPI_NOT_PRESENT; + } if (h->hnd != NULL) { - oh_release_handler(h); + // handler already running + oh_release_handler(h); + oh_release_domain(d); /* Unlock domain */ return SA_OK; } @@ -268,6 +340,7 @@ else error = SA_OK; oh_release_handler(h); + oh_release_domain(d); /* Unlock domain */ return error; } @@ -276,70 +349,103 @@ /** * oHpiGlobalParamGet - * @param: param->type needs to be set to know what parameter to fetch. + * @sid: IN. a valid session id + * @param: IN/OUT param->type needs to be set to know what parameter to fetch. * * Gets the value of the specified global parameter. * * Returns: SA_OK on success. Minus SA_OK on error. **/ SaErrorT SAHPI_API oHpiGlobalParamGet ( - SAHPI_OUT oHpiGlobalParamT *param ) + SAHPI_IN SaHpiSessionIdT sid, + SAHPI_INOUT oHpiGlobalParamT *param ) { + SaHpiDomainIdT did; + struct oh_domain *d = NULL; struct oh_global_param p; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (!param || !param->Type) { err("Invalid parameters. oHpiGlobalParamGet()"); return SA_ERR_HPI_INVALID_PARAMS; } - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; + OH_CHECK_INIT_STATE(sid); + OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ + if (oh_init()) { + oh_release_domain(d); /* Unlock domain */ + return SA_ERR_HPI_INTERNAL_ERROR; + } + p.type = param->Type; - if (oh_get_global_param(&p)) + if (oh_get_global_param(&p)) { + oh_release_domain(d); /* Unlock domain */ return SA_ERR_HPI_UNKNOWN; + } memcpy(¶m->u, &p.u, sizeof(oh_global_param_union)); + oh_release_domain(d); /* Unlock domain */ return SA_OK; } /** * oHpiGlobalParamSet - * @param: param->type needs to be set to know what parameter to set. - * Also, the appropiate value in param->u needs to be filled in. + * @sid: IN. a valid session id + * @param: IN. param->type needs to be set to know what parameter to set. + * Also, the appropiate value in param->u needs to be filled in. * * Sets a global parameter. * * Returns: SA_OK on success. Minus SA_OK on error. **/ SaErrorT SAHPI_API oHpiGlobalParamSet ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiGlobalParamT *param ) { + SaHpiDomainIdT did; + struct oh_domain *d = NULL; struct oh_global_param p; + if (sid == 0) + return SA_ERR_HPI_INVALID_SESSION; if (!param || !param->Type) { err("Invalid parameters. oHpiGlobalParamSet()"); return SA_ERR_HPI_INVALID_PARAMS; } - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; + OH_CHECK_INIT_STATE(sid); + OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ + if (oh_init()) { + oh_release_domain(d); /* Unlock domain */ + return SA_ERR_HPI_INTERNAL_ERROR; + } + p.type = param->Type; memcpy(&p.u, ¶m->u, sizeof(oh_global_param_union)); - if (oh_set_global_param(&p)) + if (oh_set_global_param(&p)){ + oh_release_domain(d); /* Unlock domain */ return SA_ERR_HPI_ERROR; - + } + + oh_release_domain(d); /* Unlock domain */ return SA_OK; } /** * oHpiInjectEvent - * @id: id of handler into which the event will be injected. - * @event: pointer to the event to be injected. - * @rpte: pointer to the resource to be injected. - * @rdrs: pointer to the list of RDRs to be injected along with @resoruce + * @sid: IN. a valid session id + * @id: IN. id of handler into which the event will be injected. + * @event: IN. pointer to the event to be injected. + * @rpte: IN. pointer to the resource to be injected. + * @rdrs: IN. pointer to the list of RDRs to be injected along with @resoruce * * @id and @event are required parameters. @rpte is only required if the event * is of RESOURCE type or HOTSWAP type. @rdrs is an optional argument in all @@ -354,11 +460,14 @@ * list so that the caller can know what the assigned values were. **/ SaErrorT SAHPI_API oHpiInjectEvent ( + SAHPI_IN SaHpiSessionIdT sid, SAHPI_IN oHpiHandlerIdT id, SAHPI_IN SaHpiEventT *event, SAHPI_IN SaHpiRptEntryT *rpte, SAHPI_IN SaHpiRdrT *rdr) { + SaHpiDomainIdT did; + struct oh_domain *d = NULL; SaErrorT (*inject_event)(void *hnd, SaHpiEventT *evt, SaHpiRptEntryT *rpte, @@ -367,6 +476,10 @@ struct oh_handler *h = NULL; SaErrorT error = SA_OK; + if (sid == 0){ + err("Invalid session id %d passed",sid); + return SA_ERR_HPI_INVALID_SESSION; + } if (id == 0) { err("Invalid handler id %d passed",id); return SA_ERR_HPI_INVALID_PARAMS; @@ -384,12 +497,20 @@ return SA_ERR_HPI_INVALID_PARAMS; } - if (oh_init()) return SA_ERR_HPI_INTERNAL_ERROR; + OH_CHECK_INIT_STATE(sid); + OH_GET_DID(sid, did); + OH_GET_DOMAIN(did, d); /* Lock domain */ + if (oh_init()) { + oh_release_domain(d); /* Unlock domain */ + return SA_ERR_HPI_INTERNAL_ERROR; + } + h = oh_get_handler(id); inject_event = h ? h->abi->inject_event : NULL; if (!inject_event) { oh_release_handler(h); + oh_release_domain(d); /* Unlock domain */ return SA_ERR_HPI_INVALID_CMD; } @@ -399,6 +520,7 @@ } oh_release_handler(h); + oh_release_domain(d); /* Unlock domain */ return error; } Modified: openhpi/trunk/openhpid/openhpid.cpp =================================================================== --- openhpi/trunk/openhpid/openhpid.cpp 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/openhpid/openhpid.cpp 2010-12-01 16:22:19 UTC (rev 7184) @@ -2855,6 +2855,7 @@ break; case eFoHpiHandlerCreate: { + SaHpiSessionIdT session_id; oHpiHandlerIdT id; oHpiHandlerConfigT config; GHashTable *config_table = g_hash_table_new_full( @@ -2864,41 +2865,42 @@ PVERBOSE1("%p Processing oHpiHandlerCreate.", thrdid); - if ( HpiDemarshalRequest1( thrdinst->remote_byte_order, - hm, pReq, &config ) < 0 ) + if ( HpiDemarshalRequest2( thrdinst->remote_byte_order, + hm, pReq, &session_id, &config ) < 0 ) return eResultError; for (int n = 0; n < config.NumberOfParams; n++) { g_hash_table_insert(config_table, - g_strdup((const gchar *)config.Params[n].Name), - g_strdup((const gchar *)config.Params[n].Value)); + g_strdup((const gchar *)config.Params[n].Name), + g_strdup((const gchar *)config.Params[n].Value)); } g_free(config.Params); - ret = oHpiHandlerCreate(config_table, &id); + + ret = oHpiHandlerCreate(session_id, config_table, &id); g_hash_table_destroy(config_table); thrdinst->header.m_len = HpiMarshalReply1( hm, pReq, &ret, &id ); - result = eResultClose; } break; case eFoHpiHandlerDestroy: { + SaHpiSessionIdT session_id; oHpiHandlerIdT id; PVERBOSE1("%p Processing oHpiHandlerDestroy.", thrdid); - if ( HpiDemarshalRequest1( thrdinst->remote_byte_order, - hm, pReq, &id ) < 0 ) + if ( HpiDemarshalRequest2( thrdinst->remote_byte_order, + hm, pReq, &session_id, &id ) < 0 ) return eResultError; - ret = oHpiHandlerDestroy(id); + ret = oHpiHandlerDestroy(session_id, id); thrdinst->header.m_len = HpiMarshalReply0( hm, pReq, &ret ); - result = eResultClose; } break; case eFoHpiHandlerInfo: { + SaHpiSessionIdT session_id; oHpiHandlerIdT id; oHpiHandlerInfoT info; oHpiHandlerConfigT config; @@ -2906,47 +2908,46 @@ PVERBOSE1("%p Processing oHpiHandlerInfo.", thrdid); - if ( HpiDemarshalRequest1( thrdinst->remote_byte_order, - hm, pReq, &id ) < 0 ) + if ( HpiDemarshalRequest2( thrdinst->remote_byte_order, + hm, pReq, &session_id, &id ) < 0 ) return eResultError; config_table = g_hash_table_new_full( g_str_hash, g_str_equal, g_free, g_free ); - ret = oHpiHandlerInfo(id, &info, config_table); + ret = oHpiHandlerInfo(session_id, id, &info, config_table); config.NumberOfParams = 0; config.Params = (oHpiHandlerConfigParamT *) g_malloc0(sizeof(oHpiHandlerConfigParamT) *g_hash_table_size(config_table)); // add each hash table entry to the marshable handler_config - g_hash_table_foreach(config_table, __dehash_handler_config, &config); + g_hash_table_foreach(config_table, + __dehash_handler_config, + &config); - //It should be possible to free the hash table here, - //but it crashes the daemon. - //g_hash_table_destroy(config_table); - thrdinst->header.m_len = HpiMarshalReply2( hm, pReq, - &ret, &info, &config ); - - result = eResultClose; + &ret, &info, &config ); + // cleanup + g_hash_table_destroy(config_table); } break; case eFoHpiHandlerGetNext: { + SaHpiSessionIdT session_id; oHpiHandlerIdT id, next_id; PVERBOSE1("%p Processing oHpiHandlerGetNext.", thrdid); - if ( HpiDemarshalRequest1( thrdinst->remote_byte_order, - hm, pReq, &id ) < 0 ) + if ( HpiDemarshalRequest2( thrdinst->remote_byte_order, + hm, pReq, &session_id, &id ) < 0 ) return eResultError; - ret = oHpiHandlerGetNext(id, &next_id); + ret = oHpiHandlerGetNext(session_id, id, &next_id); - thrdinst->header.m_len = HpiMarshalReply1( hm, pReq, &ret, &next_id ); - result = eResultClose; + thrdinst->header.m_len = HpiMarshalReply1( hm, + pReq, &ret, &next_id ); } break; @@ -2963,60 +2964,62 @@ ret = oHpiHandlerFind(session_id, rid, &hid); - thrdinst->header.m_len = HpiMarshalReply1( hm, pReq, &ret, &hid ); - result = eResultClose; + thrdinst->header.m_len = HpiMarshalReply1( hm, + pReq, &ret, &hid ); } break; case eFoHpiHandlerRetry: { + SaHpiSessionIdT session_id; oHpiHandlerIdT hid; PVERBOSE1("%p Processing oHpiHandlerRetry.", thrdid); - if ( HpiDemarshalRequest1( thrdinst->remote_byte_order, - hm, pReq, &hid ) < 0 ) + if ( HpiDemarshalRequest2( thrdinst->remote_byte_order, + hm, pReq, &session_id, &hid ) < 0 ) return eResultError; - ret = oHpiHandlerRetry(hid); + ret = oHpiHandlerRetry(session_id, hid); thrdinst->header.m_len = HpiMarshalReply0( hm, pReq, &ret ); - result = eResultClose; } break; case eFoHpiGlobalParamGet: { + SaHpiSessionIdT session_id; oHpiGlobalParamT param; PVERBOSE1("%p Processing oHpiGlobalParamGet.", thrdid); - if ( HpiDemarshalRequest1( thrdinst->remote_byte_order, - hm, pReq, ¶m ) < 0 ) + if ( HpiDemarshalRequest2( thrdinst->remote_byte_order, + hm, pReq, &session_id, ¶m ) < 0 ) return eResultError; - ret = oHpiGlobalParamGet(¶m); + ret = oHpiGlobalParamGet(session_id, ¶m); - thrdinst->header.m_len = HpiMarshalReply1( hm, pReq, &ret, ¶m ); - result = eResultClose; + thrdinst->header.m_len = HpiMarshalReply1( hm, + pReq, &ret, ¶m ); } break; case eFoHpiGlobalParamSet: { + SaHpiSessionIdT session_id; oHpiGlobalParamT param; PVERBOSE1("%p Processing oHpiGlobalParamSet.", thrdid); - if ( HpiDemarshalRequest1( thrdinst->remote_byte_order, - hm, pReq, ¶m ) < 0 ) + if ( HpiDemarshalRequest2( thrdinst->remote_byte_order, + hm, pReq, &session_id, ¶m ) < 0 ) return eResultError; - ret = oHpiGlobalParamSet(¶m); + ret = oHpiGlobalParamSet(session_id, ¶m); thrdinst->header.m_len = HpiMarshalReply0( hm, pReq, &ret ); - result = eResultClose; } break; case eFoHpiInjectEvent: { + SaHpiSessionIdT session_id; oHpiHandlerIdT id = 0; SaHpiEventT event; SaHpiRptEntryT rpte; @@ -3029,9 +3032,10 @@ PVERBOSE1("%p Processing oHpiInjectEvent.\n", thrdid); - if ( HpiDemarshalRequest4( thrdinst->remote_byte_order, + if ( HpiDemarshalRequest5( thrdinst->remote_byte_order, hm, pReq, + &session_id, &id, &event, &rpte, @@ -3039,11 +3043,9 @@ return eResultError; - ret = oHpiInjectEvent(id, &event, &rpte, &rdr); + ret = oHpiInjectEvent(session_id, id, &event, &rpte, &rdr); thrdinst->header.m_len = HpiMarshalReply0( hm, pReq, &ret ); - - result = eResultClose; } break; Modified: openhpi/trunk/openhpid/t/ohpi/hpiinjector.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/hpiinjector.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/openhpid/t/ohpi/hpiinjector.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -61,11 +61,12 @@ SaHpiVersionT hpiVer; SaHpiSessionIdT sessionid; + oHpiHandlerIdT handlerid = 1; //TODO: Use oHpiHandlerFind to find right handler SaHpiResourceIdT resourceid = all_resources; int c; - while ( (c = getopt( argc, argv,"adrsoiwcn:x?")) != EOF ) { + while ( (c = getopt( argc, argv,"adrsoiwcn:x?")) != EOF ) { //TODO: Domains switch(c) { case 'a': f_listall = 1; break; case 'c': f_ctrl = 1; break; @@ -176,6 +177,7 @@ event.EventDataUnion.HotSwapEvent.PreviousHotSwapState=SAHPI_HS_STATE_ACTIVE; rv = oHpiInjectEvent(sessionid, + handlerid, &event, &rpte, &rdr); Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_007.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_007.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_007.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -59,10 +59,12 @@ g_hash_table_insert(h3, "entity_root", "{SYSTEM_CHASSIS,4}"); g_hash_table_insert(h3, "addr", "1"); - if (oHpiHandlerCreate(h0,&hid0) || oHpiHandlerCreate(h1,&hid1)) + if (oHpiHandlerCreate(sid, h0,&hid0) + || oHpiHandlerCreate(sid, h1,&hid1)) return -1; - if (oHpiHandlerCreate(h2,&hid2) || oHpiHandlerCreate(h3,&hid3)) + if (oHpiHandlerCreate(sid, h2,&hid2) + || oHpiHandlerCreate(sid, h3,&hid3)) return -1; Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_008.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_008.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_008.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -60,16 +60,16 @@ g_hash_table_insert(h3, "entity_root", "{SYSTEM_CHASSIS,4}"); g_hash_table_insert(h3, "addr", "1"); - if (oHpiHandlerCreate(h0,&hid0) || oHpiHandlerCreate(h1,&hid1)) + if (oHpiHandlerCreate(sid, h0,&hid0) || oHpiHandlerCreate(sid, h1,&hid1)) return -1; - if (oHpiHandlerCreate(h2,&hid2) || oHpiHandlerCreate(h3,&hid3)) + if (oHpiHandlerCreate(sid, h2,&hid2) || oHpiHandlerCreate(sid, h3,&hid3)) return -1; - if (oHpiHandlerDestroy(hid0) || oHpiHandlerDestroy(hid1)) + if (oHpiHandlerDestroy(sid, hid0) || oHpiHandlerDestroy(sid, hid1)) return -1; - if (oHpiHandlerDestroy(hid2) || oHpiHandlerDestroy(hid3)) + if (oHpiHandlerDestroy(sid, hid2) || oHpiHandlerDestroy(sid, hid3)) return -1; return 0; Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_009.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_009.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_009.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -45,16 +45,16 @@ g_hash_table_insert(config, "name", "test"); g_hash_table_insert(config, "addr", "0"); - if (oHpiHandlerCreate(config, &hid)) + if (oHpiHandlerCreate(sid, config, &hid)) return -1; - if (oHpiHandlerInfo(hid, &hinfo, configinfo)) + if (oHpiHandlerInfo(sid, hid, &hinfo, configinfo)) return -1; if (strcmp("libsimulator",hinfo.plugin_name)) return -1; - if (oHpiHandlerDestroy(hid)) + if (oHpiHandlerDestroy(sid, hid)) return -1; return 0; Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_010.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_010.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_010.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -53,26 +53,26 @@ g_hash_table_insert(h2, "name", "test"); g_hash_table_insert(h2, "addr", "0"); - if (oHpiHandlerCreate(h0, &hid0) || - oHpiHandlerCreate(h1, &hid1) || - oHpiHandlerCreate(h2, &hid2)) + if (oHpiHandlerCreate(sid, h0, &hid0) || + oHpiHandlerCreate(sid, h1, &hid1) || + oHpiHandlerCreate(sid, h2, &hid2)) return -1; - if (oHpiHandlerGetNext(0, &next_id) || next_id != 1) + if (oHpiHandlerGetNext(sid, 0, &next_id) || next_id != 1) return -1; - if (oHpiHandlerGetNext(1, &next_id) || next_id != 2) + if (oHpiHandlerGetNext(sid, 1, &next_id) || next_id != 2) return -1; - if (oHpiHandlerGetNext(2, &next_id) || next_id != 3) + if (oHpiHandlerGetNext(sid, 2, &next_id) || next_id != 3) return -1; - if (!oHpiHandlerGetNext(3, &next_id)) + if (!oHpiHandlerGetNext(sid, 3, &next_id)) return -1; - if (oHpiHandlerDestroy(hid0) || - oHpiHandlerDestroy(hid1) || - oHpiHandlerDestroy(hid2)) + if (oHpiHandlerDestroy(sid, hid0) || + oHpiHandlerDestroy(sid, hid1) || + oHpiHandlerDestroy(sid, hid2)) return -1; return 0; Modified: openhpi/trunk/openhpid/t/ohpi/ohpi_024.c =================================================================== --- openhpi/trunk/openhpid/t/ohpi/ohpi_024.c 2010-12-01 15:01:56 UTC (rev 7183) +++ openhpi/trunk/openhpid/t/ohpi/ohpi_024.c 2010-12-01 16:22:19 UTC (rev 7184) @@ -31,7 +31,7 @@ if (saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL)) return -1; - if (!oHpiHandlerCreate(NULL, NULL)... [truncated message content] |
From: <av...@us...> - 2010-12-01 18:31:46
|
Revision: 7185 http://openhpi.svn.sourceforge.net/openhpi/?rev=7185&view=rev Author: avpak Date: 2010-12-01 18:31:39 +0000 (Wed, 01 Dec 2010) Log Message: ----------- Fix for #2964276 and for #2964278 Modified Paths: -------------- openhpi/trunk/README openhpi/trunk/configure.ac openhpi/trunk/openhpi.spec.in Modified: openhpi/trunk/README =================================================================== --- openhpi/trunk/README 2010-12-01 16:22:19 UTC (rev 7184) +++ openhpi/trunk/README 2010-12-01 18:31:39 UTC (rev 7185) @@ -44,6 +44,22 @@ libxml2 --------------------------------------------------------- +RPM BUILD NOTE +--------------------------------------------------------- +The library libuuid.so can be provided with e2fsprogs RPM +or with libuuid RPM. +And the header file uuid.h can be provided with +e2fsprogs-devel RPM or with libuuid-devel RPM +correspondingly. + +The default RPM spec for openhpi is configured for the +first case libuuid/libuuid-devel. + +If your distribution falls into the second case just +change uuid_provider in openhpi.spec.in before +running ./configure script. + +--------------------------------------------------------- BUILD / INSTALLATION --------------------------------------------------------- Modified: openhpi/trunk/configure.ac =================================================================== --- openhpi/trunk/configure.ac 2010-12-01 16:22:19 UTC (rev 7184) +++ openhpi/trunk/configure.ac 2010-12-01 18:31:39 UTC (rev 7185) @@ -646,6 +646,9 @@ if test "x$have_openssl" = "xyes"; then SSLDIR=ssl AC_DEFINE([HAVE_OPENSSL],[1],[openssl library was found]) + AC_SUBST(WITH_OPENSSL, 1) +else + AC_SUBST(WITH_OPENSSL, 0) fi AM_CONDITIONAL(HAVE_OPENSSL, test x$have_openssl = xyes) OH_SSL_INCLUDES="-I\$(top_srcdir)/ssl" Modified: openhpi/trunk/openhpi.spec.in =================================================================== --- openhpi/trunk/openhpi.spec.in 2010-12-01 16:22:19 UTC (rev 7184) +++ openhpi/trunk/openhpi.spec.in 2010-12-01 18:31:39 UTC (rev 7185) @@ -8,6 +8,13 @@ %define _srcrpmdir %{_rpmtopdir}/SRPMS %define _docdir %{_datadir}/doc/%{name}-%{version} +# For systems where libuuid is provided in e2fsprogs rpm +#%define uuid_provider e2fsprogs +# For systems where libuuid is provided in libuuid rpm +%define uuid_provider libuuid + +%define with_openssl @WITH_OPENSSL@ + %define with_ipmi @WITH_IPMI@ %if "x@IPMIDIRECT@" == "xipmidirect" @@ -55,7 +62,10 @@ Source: http://prdownloads.sourceforge.net/openhpi/%{name}-%{version}.tar.gz # Buildroot: %{_rpmtopdir}/INSTALL -BuildRequires: pkgconfig glib2-devel automake autoconf libtool gcc-c++ +BuildRequires: pkgconfig automake autoconf libtool gcc-c++ glib2-devel libstdc++-devel %{uuid_provider}-devel +%if 0%{?with_openssl} +BuildRequires: openssl-devel +%endif %if 0%{?suse_version} BuildRequires: tcpd-devel %else @@ -64,7 +74,10 @@ %if 0%{?with_docbook2html} BuildRequires: docbook-utils %endif -Requires: e2fsprogs-devel openssl-devel libstdc++-devel glib2-devel +Requires: glib2 libstdc++ %{uuid_provider} +%if 0%{?with_openssl} +Requires: openssl +%endif %package devel Summary: OpenHPI and SAF header files This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <uli...@us...> - 2010-12-03 10:02:40
|
Revision: 7186 http://openhpi.svn.sourceforge.net/openhpi/?rev=7186&view=rev Author: ulikleber Date: 2010-12-03 10:02:32 +0000 (Fri, 03 Dec 2010) Log Message: ----------- Fix for Feature 3125482 Additional function oHpiDomainEntryGetById Also added oh_client_init to other oHpiDomain functions, so they will work befor the first session was opened. Addiion to hpidomain client so it will now output also host:port of the serving daemon. Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/clients/hpidomain.c openhpi/trunk/include/oHpi.h Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-12-01 18:31:39 UTC (rev 7185) +++ openhpi/trunk/baselib/oh_client.cpp 2010-12-03 10:02:32 UTC (rev 7186) @@ -6345,6 +6345,10 @@ return SA_ERR_HPI_INVALID_DATA; } + // Function may be called before first session was opened, + // so we may need to initialize + oh_client_init(); + char buf[SAHPI_MAX_TEXT_BUFFER_LENGTH+1]; memcpy(&buf[0], &host->Data[0], host->DataLength); buf[host->DataLength] = '\0'; @@ -6372,6 +6376,10 @@ return SA_ERR_HPI_INVALID_DATA; } + // Function may be called before first session was opened, + // so we may need to initialize + oh_client_init(); + char buf[SAHPI_MAX_TEXT_BUFFER_LENGTH+1]; memcpy(&buf[0], &host->Data[0], host->DataLength); buf[host->DataLength] = '\0'; @@ -6380,7 +6388,7 @@ } /*----------------------------------------------------------------------------*/ -/* oHpiDomainEntryGet */ +/* oHpiDomainEntryGet */ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API oHpiDomainEntryGet ( SAHPI_IN SaHpiEntryIdT EntryId, @@ -6393,7 +6401,8 @@ if (!NextEntryId || !DomainEntry) { return SA_ERR_HPI_INVALID_PARAMS; } - /* Function may be called outside sessions, so we may need to initialize */ + // Function may be called before first session was opened, + // so we may need to initialize oh_client_init(); if (EntryId == SAHPI_FIRST_ENTRY) // get first valid domain id @@ -6420,3 +6429,35 @@ } +/*----------------------------------------------------------------------------*/ +/* oHpiDomainEntryGetByDomainId */ +/*----------------------------------------------------------------------------*/ +SaErrorT SAHPI_API oHpiDomainEntryGetByDomainId ( + SAHPI_IN SaHpiDomainIdT DomainId, + SAHPI_OUT oHpiDomainEntryT *DomainEntry ) + +{ + SaHpiDomainIdT did; + + if (!DomainEntry) { + return SA_ERR_HPI_INVALID_PARAMS; + } + // Function may be called before first session was opened, + // so we may need to initialize + oh_client_init(); + + const oh_domain_conf *entry = oh_get_domain_conf ( DomainId ); + if (entry == NULL) { // no config for did found + return SA_ERR_HPI_NOT_PRESENT; + } + + DomainEntry->id = did; + if (oh_init_textbuffer(&DomainEntry->daemonhost) != SA_OK) return SA_ERR_HPI_INVALID_PARAMS; + if (oh_append_textbuffer(&DomainEntry->daemonhost, entry->host)!= SA_OK) + return SA_ERR_HPI_INVALID_PARAMS; + DomainEntry->port = entry->port; + + return SA_OK; +} + + Modified: openhpi/trunk/clients/hpidomain.c =================================================================== --- openhpi/trunk/clients/hpidomain.c 2010-12-01 18:31:39 UTC (rev 7185) +++ openhpi/trunk/clients/hpidomain.c 2010-12-03 10:02:32 UTC (rev 7186) @@ -30,6 +30,7 @@ #include <SaHpi.h> #include <oh_utils.h> #include <oh_clients.h> +#include <oHpi.h> #define OH_SVN_REV "$Revision: 7112 $" @@ -169,7 +170,7 @@ if (fdebug) printf("saHpiDrtEntryGet\n"); rv = saHpiDrtEntryGet(sessionid, drtentryid,&nextdrtentryid,&drtentry); - if ((rv != SA_OK) || fdebug) + if ((rv != SA_OK && rv != SA_ERR_HPI_NOT_PRESENT) || fdebug) printf("DrtEntryGet returns %s\n",oh_lookup_error(rv)); if (rv == SA_OK ) { @@ -220,7 +221,7 @@ } else if (rv == SA_ERR_HPI_NOT_PRESENT) { if (drtentryid == SAHPI_FIRST_ENTRY) - printf("DRT is empty. \n"); + printf(" DRT is empty. \n"); else printf("Internal error while walking the DRT\n"); } else printf("Internal error while walking the DRT\n"); @@ -239,6 +240,7 @@ SaHpiTextBufferT buf; SaErrorT rv; int i; + oHpiDomainEntryT ohdomainentry; for (i=0;i<shift;i++)printf(" "); printf("Domain: %u Capabil: 0x%x IsPeer: %u Tag: ", @@ -284,7 +286,16 @@ for (i=0;i<shift;i++)printf(" "); printf(" Limit: %u DatOverflow : %u\n", info.DatUserAlarmLimit, info.DatOverflow); - + + // Now print also OpenHPI specific info for the domain + rv = oHpiDomainEntryGetByDomainId ( info.DomainId, &ohdomainentry ); + if (rv==SA_OK) { + for (i=0;i<shift;i++)printf(" "); + printf(" Serving Daemon on Host: %s:%u\n", + (char *)ohdomainentry.daemonhost.Data, + ohdomainentry.port ); + } + return rv; } Modified: openhpi/trunk/include/oHpi.h =================================================================== --- openhpi/trunk/include/oHpi.h 2010-12-01 18:31:39 UTC (rev 7185) +++ openhpi/trunk/include/oHpi.h 2010-12-03 10:02:32 UTC (rev 7186) @@ -150,6 +150,9 @@ SAHPI_IN SaHpiEntryIdT EntryId, SAHPI_OUT SaHpiEntryIdT *NextEntryId, SAHPI_OUT oHpiDomainEntryT *DomainEntry ); +SaErrorT SAHPI_API oHpiDomainEntryGetByDomainId ( + SAHPI_IN SaHpiDomainIdT DomainId, + SAHPI_OUT oHpiDomainEntryT *DomainEntry ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <av...@us...> - 2010-12-13 14:33:52
|
Revision: 7193 http://openhpi.svn.sourceforge.net/openhpi/?rev=7193&view=rev Author: avpak Date: 2010-12-13 14:33:43 +0000 (Mon, 13 Dec 2010) Log Message: ----------- Feature request #3129960 Modified Paths: -------------- openhpi/trunk/baselib/oh_client.cpp openhpi/trunk/baselib/oh_client_conf.c openhpi/trunk/baselib/oh_client_conf.h openhpi/trunk/baselib/oh_client_session.cpp openhpi/trunk/baselib/oh_client_session.h openhpi/trunk/clients/clients.c openhpi/trunk/clients/hpialarms.c openhpi/trunk/clients/hpidomain.c openhpi/trunk/clients/hpiel.c openhpi/trunk/clients/hpievents.c openhpi/trunk/clients/hpifan.c openhpi/trunk/clients/hpigensimdata.c openhpi/trunk/clients/hpiinv.c openhpi/trunk/clients/hpionIBMblade.c openhpi/trunk/clients/hpipower.c openhpi/trunk/clients/hpireset.c openhpi/trunk/clients/hpisensor.c openhpi/trunk/clients/hpisettime.c openhpi/trunk/clients/hpithres.c openhpi/trunk/clients/hpitop.c openhpi/trunk/clients/hpitree.c openhpi/trunk/clients/hpiwdt.c openhpi/trunk/clients/ohdomainlist.c openhpi/trunk/clients/ohhandler.c openhpi/trunk/clients/ohparam.c openhpi/trunk/hpi_shell/commands.c openhpi/trunk/include/oHpi.h openhpi/trunk/marshal/marshal.c openhpi/trunk/marshal/marshal.h openhpi/trunk/marshal/marshal_hpi.c openhpi/trunk/marshal/marshal_hpi.h openhpi/trunk/marshal/t/marshal_026.c openhpi/trunk/marshal/t/marshal_029.c openhpi/trunk/openhpid/config.c openhpi/trunk/openhpid/event.c openhpi/trunk/openhpid/openhpid.cpp openhpi/trunk/openhpid/plugin.c openhpi/trunk/openhpid/safhpi.c openhpi/trunk/transport/strmsock.cpp openhpi/trunk/transport/strmsock.h openhpi/trunk/utils/announcement_utils.c openhpi/trunk/utils/el_utils.c openhpi/trunk/utils/epath_utils.c openhpi/trunk/utils/rpt_utils.c openhpi/trunk/utils/uid_utils.c Modified: openhpi/trunk/baselib/oh_client.cpp =================================================================== --- openhpi/trunk/baselib/oh_client.cpp 2010-12-13 12:10:07 UTC (rev 7192) +++ openhpi/trunk/baselib/oh_client.cpp 2010-12-13 14:33:43 UTC (rev 7193) @@ -1,5 +1,5 @@ /* -*- linux-c -*- - * + * * (C) Copyright IBM Corp. 2004-2008 * (C) Copyright Pigeon Point Systems. 2010 * (C) Copyright Nokia Siemens Networks 2010 @@ -19,7 +19,9 @@ * */ +#include <stddef.h> #include <string.h> + #include <glib.h> #include <SaHpi.h> @@ -42,121 +44,92 @@ /*----------------------------------------------------------------------------*/ -/* Macros */ -/*----------------------------------------------------------------------------*/ - -#define client_dbg(cmd, str) dbg("%s: %s\n", cmd, str) -#define client_err(cmd, str) err("%s: %s\n", cmd, str) - -#define SendRecv(sid, cmd) \ - if (pinst->WriteMsg(request)) { \ - client_err(cmd, "WriteMsg failed\n"); \ - g_free(request); \ - if (sid) { \ - oh_close_connx(sid); \ - } else { \ - oh_delete_connx(pinst); \ - } \ - return SA_ERR_HPI_NO_RESPONSE; \ - } \ - if (pinst->ReadMsg(reply)) { \ - client_err(cmd, "Read failed\n"); \ - g_free(request); \ - if (sid) { \ - oh_close_connx(sid); \ - } else { \ - oh_delete_connx(pinst); \ - } \ - return SA_ERR_HPI_NO_RESPONSE; \ - } - -/*----------------------------------------------------------------------------*/ /* Utility functions */ /*----------------------------------------------------------------------------*/ static SaErrorT clean_reading(SaHpiSensorReadingT *read_in, - SaHpiSensorReadingT *read_out) + SaHpiSensorReadingT *read_out) { - /* This is a workaround against unknown bugs in the marshal code */ - if (!read_in || !read_out) return SA_ERR_HPI_INVALID_PARAMS; - - memset(read_out, 0, sizeof(SaHpiSensorReadingT)); - - read_out->IsSupported = read_in->IsSupported; + /* This is a workaround against unknown bugs in the marshal code */ + if (!read_in || !read_out) return SA_ERR_HPI_INVALID_PARAMS; - if (read_in->IsSupported == SAHPI_TRUE) { - if (!oh_lookup_sensorreadingtype(read_in->Type)) { - //printf("Invalid reading type: %d\n", read_in->Type); - return SA_ERR_HPI_INVALID_DATA; - } - read_out->Type = read_in->Type; + memset(read_out, 0, sizeof(SaHpiSensorReadingT)); + + read_out->IsSupported = read_in->IsSupported; + + if (read_in->IsSupported == SAHPI_TRUE) { + if (!oh_lookup_sensorreadingtype(read_in->Type)) { + //printf("Invalid reading type: %d\n", read_in->Type); + return SA_ERR_HPI_INVALID_DATA; } - else { - /* Do we need to set dummy & reading type just to keep marshalling happy? */ - read_out->Type = SAHPI_SENSOR_READING_TYPE_INT64; - read_out->Value.SensorInt64 = 0; - return SA_OK; - } + read_out->Type = read_in->Type; + } + else { + // TODO: Do we need to set dummy & reading type + // just to keep marshalling happy? + read_out->Type = SAHPI_SENSOR_READING_TYPE_INT64; + read_out->Value.SensorInt64 = 0; + return SA_OK; + } - if (read_in->Type == SAHPI_SENSOR_READING_TYPE_INT64) { - read_out->Value.SensorInt64 = read_in->Value.SensorInt64; - } else if (read_in->Type == SAHPI_SENSOR_READING_TYPE_UINT64) { - read_out->Value.SensorUint64 = read_in->Value.SensorUint64; - } else if (read_in->Type == SAHPI_SENSOR_READING_TYPE_FLOAT64) { - read_out->Value.SensorFloat64 = read_in->Value.SensorFloat64; - } else if (read_in->Type == SAHPI_SENSOR_READING_TYPE_BUFFER) { - memcpy(read_out->Value.SensorBuffer, - read_in->Value.SensorBuffer, - SAHPI_SENSOR_BUFFER_LENGTH); - } + if (read_in->Type == SAHPI_SENSOR_READING_TYPE_INT64) { + read_out->Value.SensorInt64 = read_in->Value.SensorInt64; + } else if (read_in->Type == SAHPI_SENSOR_READING_TYPE_UINT64) { + read_out->Value.SensorUint64 = read_in->Value.SensorUint64; + } else if (read_in->Type == SAHPI_SENSOR_READING_TYPE_FLOAT64) { + read_out->Value.SensorFloat64 = read_in->Value.SensorFloat64; + } else if (read_in->Type == SAHPI_SENSOR_READING_TYPE_BUFFER) { + memcpy(read_out->Value.SensorBuffer, + read_in->Value.SensorBuffer, + SAHPI_SENSOR_BUFFER_LENGTH); + } - return SA_OK; + return SA_OK; } static SaErrorT clean_thresholds(SaHpiSensorThresholdsT *thrds_in, - SaHpiSensorThresholdsT *thrds_out) + SaHpiSensorThresholdsT *thrds_out) { - /* This is a workaround against unknown bugs in the marshal code */ - SaErrorT err = SA_OK; - if (!thrds_in || !thrds_out) return SA_ERR_HPI_INVALID_PARAMS; + /* This is a workaround against unknown bugs in the marshal code */ + SaErrorT rv; + if (!thrds_in || !thrds_out) return SA_ERR_HPI_INVALID_PARAMS; - err = clean_reading(&thrds_in->LowCritical, &thrds_out->LowCritical); - if (err) return err; - err = clean_reading(&thrds_in->LowMajor, &thrds_out->LowMajor); - if (err) return err; - err = clean_reading(&thrds_in->LowMinor, &thrds_out->LowMinor); - if (err) return err; - err = clean_reading(&thrds_in->UpCritical, &thrds_out->UpCritical); - if (err) return err; - err = clean_reading(&thrds_in->UpMajor, &thrds_out->UpMajor); - if (err) return err; - err = clean_reading(&thrds_in->UpMinor, &thrds_out->UpMinor); - if (err) return err; - err = clean_reading(&thrds_in->PosThdHysteresis, - &thrds_out->PosThdHysteresis); - if (err) return err; - err = clean_reading(&thrds_in->NegThdHysteresis, - &thrds_out->NegThdHysteresis); + rv = clean_reading(&thrds_in->LowCritical, &thrds_out->LowCritical); + if (rv != SA_OK) return rv; + rv = clean_reading(&thrds_in->LowMajor, &thrds_out->LowMajor); + if (rv != SA_OK) return rv; + rv = clean_reading(&thrds_in->LowMinor, &thrds_out->LowMinor); + if (rv != SA_OK) return rv; + rv = clean_reading(&thrds_in->UpCritical, &thrds_out->UpCritical); + if (rv != SA_OK) return rv; + rv = clean_reading(&thrds_in->UpMajor, &thrds_out->UpMajor); + if (rv != SA_OK) return rv; + rv = clean_reading(&thrds_in->UpMinor, &thrds_out->UpMinor); + if (rv != SA_OK) return rv; + rv = clean_reading(&thrds_in->PosThdHysteresis, + &thrds_out->PosThdHysteresis); + if (rv != SA_OK) return rv; + rv = clean_reading(&thrds_in->NegThdHysteresis, + &thrds_out->NegThdHysteresis); - return err; + return rv; } static void __dehash_config(gpointer key, gpointer value, gpointer data) { - oHpiHandlerConfigT *handler_config = (oHpiHandlerConfigT *)data; - - strncpy((char *)handler_config->Params[handler_config->NumberOfParams].Name, - (const char *)key, - SAHPI_MAX_TEXT_BUFFER_LENGTH); - strncpy((char *)handler_config->Params[handler_config->NumberOfParams].Value, - (const char *)value, - SAHPI_MAX_TEXT_BUFFER_LENGTH); + oHpiHandlerConfigT *hc = (oHpiHandlerConfigT *)data; - handler_config->NumberOfParams = handler_config->NumberOfParams + 1; - - return; + strncpy((char *)hc->Params[hc->NumberOfParams].Name, + (const char *)key, + SAHPI_MAX_TEXT_BUFFER_LENGTH); + strncpy((char *)hc->Params[hc->NumberOfParams].Value, + (const char *)value, + SAHPI_MAX_TEXT_BUFFER_LENGTH); + + ++hc->NumberOfParams; } + /*----------------------------------------------------------------------------*/ /* Initialization function */ /*----------------------------------------------------------------------------*/ @@ -164,18 +137,18 @@ { static SaHpiBoolT initialized = SAHPI_FALSE; - if ( initialized != SAHPI_FALSE ) { + if (initialized != SAHPI_FALSE) { return; } initialized = SAHPI_TRUE; // Initialize GLIB thread engine - if ( g_thread_supported() == FALSE ) { + if (g_thread_supported() == FALSE) { g_thread_init(0); } oh_client_conf_init(); - oh_client_session_init(); + ohc_sess_init(); } @@ -189,7 +162,7 @@ SaHpiVersionT SAHPI_API saHpiVersionGet (void) { - return SAHPI_INTERFACE_VERSION; + return SAHPI_INTERFACE_VERSION; } /*----------------------------------------------------------------------------*/ @@ -197,30 +170,31 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiInitialize( - SAHPI_IN SaHpiVersionT RequestedVersion, - SAHPI_IN SaHpiUint32T NumOptions, - SAHPI_INOUT SaHpiInitOptionT *Options, - SAHPI_OUT SaHpiUint32T *FailedOption, - SAHPI_OUT SaErrorT *OptionError) + SAHPI_IN SaHpiVersionT RequestedVersion, + SAHPI_IN SaHpiUint32T NumOptions, + SAHPI_INOUT SaHpiInitOptionT *Options, + SAHPI_OUT SaHpiUint32T *FailedOption, + SAHPI_OUT SaErrorT *OptionError) { - if ( RequestedVersion < OH_SAHPI_INTERFACE_VERSION_MIN_SUPPORTED || - RequestedVersion > OH_SAHPI_INTERFACE_VERSION_MAX_SUPPORTED ) { - return SA_ERR_HPI_UNSUPPORTED_API; - } - if ( ( NumOptions != 0 ) && ( Options == NULL ) ) { - return SA_ERR_HPI_INVALID_PARAMS; - } + if (RequestedVersion < OH_SAHPI_INTERFACE_VERSION_MIN_SUPPORTED || + RequestedVersion > OH_SAHPI_INTERFACE_VERSION_MAX_SUPPORTED) + { + return SA_ERR_HPI_UNSUPPORTED_API; + } + if ((NumOptions != 0) && (Options == 0)) { + return SA_ERR_HPI_INVALID_PARAMS; + } - // TODO implement more checks from section 5.2.1 of B.03.01 spec - // Current implementation does not cover options check + // TODO implement more checks from section 5.2.1 of B.03.01 spec + // Current implementation does not cover options check - // TODO implement any library initialization code here - // Current implementation does not utilize this function - // + // TODO implement any library initialization code here + // Current implementation does not utilize this function + // - oh_client_init(); + oh_client_init(); - return SA_OK; + return SA_OK; } /*----------------------------------------------------------------------------*/ @@ -229,10 +203,10 @@ SaErrorT SAHPI_API saHpiFinalize() { - // TODO implement - // TODO implement any library finalization code here - // Current implementation does not utilize this function - return SA_OK; + // TODO implement + // TODO implement any library finalization code here + // Current implementation does not utilize this function + return SA_OK; } /*----------------------------------------------------------------------------*/ @@ -240,56 +214,19 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiSessionOpen( - SAHPI_IN SaHpiDomainIdT DomainId, - SAHPI_OUT SaHpiSessionIdT *SessionId, - SAHPI_IN void *SecurityParams) + SAHPI_IN SaHpiDomainIdT DomainId, + SAHPI_OUT SaHpiSessionIdT *SessionId, + SAHPI_IN void *SecurityParams) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - SaHpiSessionIdT domain_sid = 0; - char cmd[] = "saHpiSessionOpen"; - pcstrmsock pinst = NULL; - SaHpiDomainIdT default_did = SAHPI_UNSPECIFIED_DOMAIN_ID; - + if (!SessionId || SecurityParams) { + return SA_ERR_HPI_INVALID_PARAMS; + } - if (!SessionId || SecurityParams) - return SA_ERR_HPI_INVALID_PARAMS; + if (DomainId == SAHPI_UNSPECIFIED_DOMAIN_ID) { + DomainId = OH_DEFAULT_DOMAIN_ID; + } - if (DomainId == SAHPI_UNSPECIFIED_DOMAIN_ID) (DomainId = OH_DEFAULT_DOMAIN_ID); - - err = oh_create_connx(DomainId, &pinst); - if (err) { - client_err(cmd, "Could not create client connection"); - return err; - } - - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiSessionOpen); - pinst->MessageHeaderInit( - eMhMsg, 0, eFsaHpiSessionOpen, hm->m_request_len); - request = g_malloc(hm->m_request_len); - /* TODO: Does daemon need domain id param in this call*/ - pinst->header.m_len = HpiMarshalRequest1(hm, request, &default_did); - SendRecv(0, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, - hm, reply + sizeof(cMessageHeader), - &err, &domain_sid); - - if (request) - g_free(request); - if (err != SA_OK) { - oh_delete_connx(pinst); - return err; - } - if (mr < 0) { - oh_delete_connx(pinst); - return SA_ERR_HPI_INVALID_PARAMS; - } - - *SessionId = oh_open_session(DomainId, domain_sid, pinst); - - return err; + return ohc_sess_open(DomainId, *SessionId); } @@ -298,42 +235,9 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiSessionClose( - SAHPI_IN SaHpiSessionIdT SessionId) + SAHPI_IN SaHpiSessionIdT SessionId) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiSessionClose"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; - - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiSessionClose); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiSessionClose, - hm->m_request_len); - request = g_malloc(hm->m_request_len); - - pinst->header.m_len = HpiMarshalRequest1(hm, request, &dsid); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, - hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - - oh_close_session(SessionId); - - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return ohc_sess_close(SessionId); } @@ -342,45 +246,15 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiDiscover( - SAHPI_IN SaHpiSessionIdT SessionId) + SAHPI_IN SaHpiSessionIdT SessionId) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiDiscover"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; - + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; + Params iparams; + Params oparams; + rv = ohc_sess_rpc(eFsaHpiDiscover, SessionId, iparams, oparams); - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiDiscover); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiDiscover, - hm->m_request_len); - request = g_malloc(hm->m_request_len); - - pinst->header.m_len = HpiMarshalRequest1(hm, request, &dsid); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, - hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -389,46 +263,25 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiDomainInfoGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_OUT SaHpiDomainInfoT *DomainInfo) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_OUT SaHpiDomainInfoT *DomainInfo) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiDomainInfoGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - - /* oh_get_connx() places the real Domain Id to dsid */ - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (DomainInfo == NULL) - return SA_ERR_HPI_INVALID_PARAMS; + if (!DomainInfo) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiDomainInfoGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiDomainInfoGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams; + Params oparams(DomainInfo); + rv = ohc_sess_rpc(eFsaHpiDomainInfoGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest1(hm, request, &dsid); + /* Set Domain Id to real Domain Id */ + if (rv == SA_OK) { + rv = ohc_sess_get_did(SessionId, DomainInfo->DomainId); + } - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, DomainInfo); - - /* Set Domain Id to real Domain Id */ - DomainInfo->DomainId = did; - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -437,52 +290,28 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiDrtEntryGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiEntryIdT EntryId, - SAHPI_OUT SaHpiEntryIdT *NextEntryId, - SAHPI_OUT SaHpiDrtEntryT *DrtEntry) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEntryIdT *NextEntryId, + SAHPI_OUT SaHpiDrtEntryT *DrtEntry) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiDrtEntryGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - - /* oh_get_connx() places the real Domain Id to dsid */ - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if((DrtEntry == NULL) || - (NextEntryId == NULL) || - (EntryId == SAHPI_LAST_ENTRY)) { - return SA_ERR_HPI_INVALID_PARAMS; - } + if ((!DrtEntry) || (!NextEntryId) || (EntryId == SAHPI_LAST_ENTRY)) + { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiDrtEntryGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiDrtEntryGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&EntryId); + Params oparams(NextEntryId, DrtEntry); + rv = ohc_sess_rpc(eFsaHpiDrtEntryGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &EntryId); + /* Set Domain Id to real Domain Id */ + if (rv == SA_OK) { + rv = ohc_sess_get_did(SessionId, DrtEntry->DomainId); + } - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply2(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, NextEntryId, DrtEntry); - - /* Set Domain Id to real Domain Id */ - DrtEntry->DomainId = did; - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -491,44 +320,23 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiDomainTagSet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiTextBufferT *DomainTag) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiTextBufferT *DomainTag) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiDomainTagSet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (!DomainTag) - return SA_ERR_HPI_INVALID_PARAMS; - if (!oh_lookup_texttype(DomainTag->DataType)) - return SA_ERR_HPI_INVALID_PARAMS; + if (!DomainTag) { + return SA_ERR_HPI_INVALID_PARAMS; + } + if (!oh_lookup_texttype(DomainTag->DataType)) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiDomainTagSet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiDomainTagSet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(DomainTag); + Params oparams; + rv = ohc_sess_rpc(eFsaHpiDomainTagSet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, DomainTag); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -537,48 +345,25 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiRptEntryGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiEntryIdT EntryId, - SAHPI_OUT SaHpiEntryIdT *NextEntryId, - SAHPI_OUT SaHpiRptEntryT *RptEntry) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEntryIdT *NextEntryId, + SAHPI_OUT SaHpiRptEntryT *RptEntry) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiRptEntryGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if ((NextEntryId == NULL) || (RptEntry == NULL)) { - return SA_ERR_HPI_INVALID_PARAMS; - } - if (EntryId == SAHPI_LAST_ENTRY) { - return SA_ERR_HPI_INVALID_PARAMS; - } + if ((!NextEntryId) || (!RptEntry)) { + return SA_ERR_HPI_INVALID_PARAMS; + } + if (EntryId == SAHPI_LAST_ENTRY) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiRptEntryGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiRptEntryGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&EntryId); + Params oparams(NextEntryId, RptEntry); + rv = ohc_sess_rpc(eFsaHpiRptEntryGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &EntryId); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply2(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, NextEntryId, RptEntry); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -587,45 +372,21 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiRptEntryGetByResourceId( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_OUT SaHpiRptEntryT *RptEntry) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiRptEntryT *RptEntry) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiRptEntryGetByResourceId"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (ResourceId == SAHPI_UNSPECIFIED_RESOURCE_ID || - RptEntry == NULL) { - return SA_ERR_HPI_INVALID_PARAMS; - } + if (ResourceId == SAHPI_UNSPECIFIED_RESOURCE_ID || (!RptEntry)) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiRptEntryGetByResourceId); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiRptEntryGetByResourceId, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&ResourceId); + Params oparams(RptEntry); + rv = ohc_sess_rpc(eFsaHpiRptEntryGetByResourceId, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &ResourceId); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, RptEntry); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -634,45 +395,24 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiResourceSeveritySet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_IN SaHpiSeverityT Severity) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiSeverityT Severity) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiResourceSeveritySet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (ResourceId == SAHPI_UNSPECIFIED_RESOURCE_ID) - return SA_ERR_HPI_INVALID_PARAMS; - if (!oh_lookup_severity(Severity)) - return SA_ERR_HPI_INVALID_PARAMS; + if (ResourceId == SAHPI_UNSPECIFIED_RESOURCE_ID) { + return SA_ERR_HPI_INVALID_PARAMS; + } + if (!oh_lookup_severity(Severity)) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiResourceSeveritySet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiResourceSeveritySet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&ResourceId, &Severity); + Params oparams; + rv = ohc_sess_rpc(eFsaHpiResourceSeveritySet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest3(hm, request, &dsid, &ResourceId, &Severity); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -681,43 +421,21 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiResourceTagSet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_IN SaHpiTextBufferT *ResourceTag) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiTextBufferT *ResourceTag) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiResourceTagSet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (ResourceTag == NULL) - return SA_ERR_HPI_INVALID_PARAMS; + if (!ResourceTag) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiResourceTagSet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiResourceTagSet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&ResourceId, ResourceTag); + Params oparams; + rv = ohc_sess_rpc(eFsaHpiResourceTagSet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest3(hm, request, &dsid, &ResourceId, ResourceTag); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -726,42 +444,20 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiMyEntityPathGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_OUT SaHpiEntityPathT *EntityPath) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_OUT SaHpiEntityPathT *EntityPath) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiMyEntityPathGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (EntityPath == NULL) - return SA_ERR_HPI_INVALID_PARAMS; + if (!EntityPath) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiMyEntityPathGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiMyEntityPathGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams; + Params oparams(EntityPath); + rv = ohc_sess_rpc(eFsaHpiMyEntityPathGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest1(hm, request, &dsid); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, EntityPath); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -770,42 +466,20 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiResourceIdGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_OUT SaHpiResourceIdT *ResourceId) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_OUT SaHpiResourceIdT *ResourceId) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiResourceIdGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (ResourceId == NULL) - return SA_ERR_HPI_INVALID_PARAMS; + if (!ResourceId) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiResourceIdGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiResourceIdGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams; + Params oparams(ResourceId); + rv = ohc_sess_rpc(eFsaHpiResourceIdGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest1(hm, request, &dsid); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, ResourceId); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -814,56 +488,32 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiGetIdByEntityPath( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiEntityPathT EntityPath, - SAHPI_IN SaHpiRdrTypeT InstrumentType, - SAHPI_INOUT SaHpiUint32T *InstanceId, - SAHPI_OUT SaHpiResourceIdT *ResourceId, - SAHPI_OUT SaHpiInstrumentIdT *InstrumentId, - SAHPI_OUT SaHpiUint32T *RptUpdateCount) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEntityPathT EntityPath, + SAHPI_IN SaHpiRdrTypeT InstrumentType, + SAHPI_INOUT SaHpiUint32T *InstanceId, + SAHPI_OUT SaHpiResourceIdT *ResourceId, + SAHPI_OUT SaHpiInstrumentIdT *InstrumentId, + SAHPI_OUT SaHpiUint32T *RptUpdateCount) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiGetIdByEntityPath"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; - SaHpiInstrumentIdT instrument_id; + SaErrorT rv; + SaHpiInstrumentIdT instrument_id; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (ResourceId == NULL || InstanceId == NULL || - *InstanceId == SAHPI_LAST_ENTRY || RptUpdateCount == NULL || - (InstrumentId == NULL && InstrumentType != SAHPI_NO_RECORD)) - return SA_ERR_HPI_INVALID_PARAMS; - if (InstrumentId == NULL) - InstrumentId = &instrument_id; - - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiGetIdByEntityPath); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiGetIdByEntityPath, hm->m_request_len); - request = g_malloc(hm->m_request_len); + if ((!ResourceId) || (!InstanceId) || + (*InstanceId == SAHPI_LAST_ENTRY) || (!RptUpdateCount) || + ((!InstrumentId) && (InstrumentType != SAHPI_NO_RECORD))) + { + return SA_ERR_HPI_INVALID_PARAMS; + } + if (!InstrumentId) { + InstrumentId = &instrument_id; + } - pinst->header.m_len = HpiMarshalRequest4(hm, request, &dsid, - &EntityPath, &InstrumentType, - InstanceId); + Params iparams(&EntityPath, &InstrumentType, InstanceId); + Params oparams(InstanceId, ResourceId, InstrumentId, RptUpdateCount); + rv = ohc_sess_rpc(eFsaHpiGetIdByEntityPath, SessionId, iparams, oparams); - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply4(pinst->remote_byte_order, hm, - reply + sizeof(cMessageHeader), &err, - InstanceId, ResourceId, InstrumentId, RptUpdateCount); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -872,50 +522,23 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiGetChildEntityPath( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiEntityPathT ParentEntityPath, - SAHPI_INOUT SaHpiUint32T *InstanceId, - SAHPI_OUT SaHpiEntityPathT *ChildEntityPath, - SAHPI_OUT SaHpiUint32T *RptUpdateCount) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiEntityPathT ParentEntityPath, + SAHPI_INOUT SaHpiUint32T *InstanceId, + SAHPI_OUT SaHpiEntityPathT *ChildEntityPath, + SAHPI_OUT SaHpiUint32T *RptUpdateCount) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiGetChildEntityPath"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (InstanceId == NULL || *InstanceId == SAHPI_LAST_ENTRY || - RptUpdateCount == NULL) - return SA_ERR_HPI_INVALID_PARAMS; - - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiGetChildEntityPath); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiGetChildEntityPath, hm->m_request_len); - request = g_malloc(hm->m_request_len); + if ((!InstanceId) || (*InstanceId == SAHPI_LAST_ENTRY) || (!RptUpdateCount)) { + return SA_ERR_HPI_INVALID_PARAMS; + } - pinst->header.m_len = HpiMarshalRequest3(hm, request, &dsid, - &ParentEntityPath, - InstanceId); + Params iparams(&ParentEntityPath, InstanceId); + Params oparams(InstanceId, ChildEntityPath, RptUpdateCount); + rv = ohc_sess_rpc(eFsaHpiGetChildEntityPath, SessionId, iparams, oparams); - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply3(pinst->remote_byte_order, hm, - reply + sizeof(cMessageHeader), &err, - InstanceId, ChildEntityPath, RptUpdateCount); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -924,40 +547,16 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiResourceFailedRemove( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiResourceFailedRemove"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; + Params iparams(&ResourceId); + Params oparams; + rv = ohc_sess_rpc(eFsaHpiResourceFailedRemove, SessionId, iparams, oparams); - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiResourceFailedRemove); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiResourceFailedRemove, hm->m_request_len); - request = g_malloc(hm->m_request_len); - - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &ResourceId); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } /*----------------------------------------------------------------------------*/ @@ -965,43 +564,21 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogInfoGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_OUT SaHpiEventLogInfoT *Info) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiEventLogInfoT *Info) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogInfoGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (Info == NULL) - return SA_ERR_HPI_INVALID_PARAMS; + if (!Info) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogInfoGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogInfoGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&ResourceId); + Params oparams(Info); + rv = ohc_sess_rpc(eFsaHpiEventLogInfoGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &ResourceId); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, Info); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } /*----------------------------------------------------------------------------*/ @@ -1009,44 +586,21 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogCapabilitiesGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_OUT SaHpiEventLogCapabilitiesT *EventLogCapabilities) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiEventLogCapabilitiesT *EventLogCapabilities) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogCapabilitiesGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (EventLogCapabilities == NULL) - return SA_ERR_HPI_INVALID_PARAMS; + if (!EventLogCapabilities) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogCapabilitiesGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogCapabilitiesGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&ResourceId); + Params oparams(EventLogCapabilities); + rv = ohc_sess_rpc(eFsaHpiEventLogCapabilitiesGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &ResourceId); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), - &err, EventLogCapabilities); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } /*----------------------------------------------------------------------------*/ @@ -1054,65 +608,49 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogEntryGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_IN SaHpiEntryIdT EntryId, - SAHPI_OUT SaHpiEventLogEntryIdT *PrevEntryId, - SAHPI_OUT SaHpiEventLogEntryIdT *NextEntryId, - SAHPI_OUT SaHpiEventLogEntryT *EventLogEntry, - SAHPI_INOUT SaHpiRdrT *Rdr, - SAHPI_INOUT SaHpiRptEntryT *RptEntry) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiEntryIdT EntryId, + SAHPI_OUT SaHpiEventLogEntryIdT *PrevEntryId, + SAHPI_OUT SaHpiEventLogEntryIdT *NextEntryId, + SAHPI_OUT SaHpiEventLogEntryT *EventLogEntry, + SAHPI_INOUT SaHpiRdrT *Rdr, + SAHPI_INOUT SaHpiRptEntryT *RptEntry) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogEntryGet"; - SaHpiRdrT tmp_rdr; - SaHpiRptEntryT tmp_rpt; - pcstrmsock pinst; - SaHpiSessionIdT dsid =0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (!PrevEntryId || !EventLogEntry || !NextEntryId || - EntryId == SAHPI_NO_MORE_ENTRIES) { - return SA_ERR_HPI_INVALID_PARAMS; - } + if ((!PrevEntryId) || (!EventLogEntry) || (!NextEntryId) || + (EntryId == SAHPI_NO_MORE_ENTRIES)) + { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogEntryGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogEntryGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + SaHpiRdrT rdr; + SaHpiRptEntryT rpte; - pinst->header.m_len = HpiMarshalRequest3(hm, request, &dsid, &ResourceId, &EntryId); + Params iparams(&ResourceId, &EntryId); + Params oparams(PrevEntryId, NextEntryId, EventLogEntry, &rdr, &rpte); + rv = ohc_sess_rpc(eFsaHpiEventLogEntryGet, SessionId, iparams, oparams); - SendRecv(SessionId, cmd); + if (Rdr) { + memcpy(Rdr, &rdr, sizeof(SaHpiRdrT)); + } + if (RptEntry) { + memcpy(RptEntry, &rpte, sizeof(SaHpiRptEntryT)); + } - int mr = HpiDemarshalReply5(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, PrevEntryId, NextEntryId, EventLogEntry, &tmp_rdr, &tmp_rpt); - - if (Rdr != NULL) { - memcpy(Rdr, &tmp_rdr, sizeof(SaHpiRdrT)); + /* If this event is Domain Event, then adjust DomainId */ + if ((ResourceId == SAHPI_UNSPECIFIED_RESOURCE_ID) && + (EventLogEntry->Event.EventType == SAHPI_ET_DOMAIN)) + { + if (rv == SA_OK) { + SaHpiDomainIdT did; + rv = ohc_sess_get_did(SessionId, did ); + EventLogEntry->Event.EventDataUnion.DomainEvent.DomainId = did; } - if (RptEntry != NULL) { - memcpy(RptEntry, &tmp_rpt, sizeof(SaHpiRptEntryT)); - } + } - /* If this event is Domain Event, then adjust DomainId */ - if ((ResourceId == SAHPI_UNSPECIFIED_RESOURCE_ID) && - (EventLogEntry->Event.EventType == SAHPI_ET_DOMAIN)) { - EventLogEntry->Event.EventDataUnion.DomainEvent.DomainId = did; - } - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -1121,50 +659,33 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogEntryAdd( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_IN SaHpiEventT *EvtEntry) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiEventT *EvtEntry) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogEntryAdd"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (EvtEntry == NULL) - return SA_ERR_HPI_INVALID_PARAMS; - if (EvtEntry->EventType != SAHPI_ET_USER || - EvtEntry->Source != SAHPI_UNSPECIFIED_RESOURCE_ID) - return SA_ERR_HPI_INVALID_PARAMS; - if (!oh_lookup_severity(EvtEntry->Severity)) - return SA_ERR_HPI_INVALID_PARAMS; - if (!oh_valid_textbuffer(&EvtEntry->EventDataUnion.UserEvent.UserEventData)) - return SA_ERR_HPI_INVALID_PARAMS; + if (!EvtEntry) { + return SA_ERR_HPI_INVALID_PARAMS; + } + if (EvtEntry->EventType != SAHPI_ET_USER || + EvtEntry->Source != SAHPI_UNSPECIFIED_RESOURCE_ID) + { + return SA_ERR_HPI_INVALID_PARAMS; + } + if (!oh_lookup_severity(EvtEntry->Severity)) { + return SA_ERR_HPI_INVALID_PARAMS; + } + if (!oh_valid_textbuffer(&EvtEntry->EventDataUnion.UserEvent.UserEventData)) + { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogEntryAdd); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogEntryAdd, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&ResourceId, EvtEntry); + Params oparams; + rv = ohc_sess_rpc(eFsaHpiEventLogEntryAdd, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest3(hm, request, &dsid, &ResourceId, EvtEntry); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -1173,40 +694,16 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogClear( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogClear"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; + Params iparams(&ResourceId); + Params oparams; + rv = ohc_sess_rpc(eFsaHpiEventLogClear, SessionId, iparams, oparams); - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogClear); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogClear, hm->m_request_len); - request = g_malloc(hm->m_request_len); - - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &ResourceId); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -1215,43 +712,21 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogTimeGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_OUT SaHpiTimeT *Time) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiTimeT *Time) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogTimeGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (Time == NULL) - return SA_ERR_HPI_INVALID_PARAMS; + if (!Time) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogTimeGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogTimeGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&ResourceId); + Params oparams(Time); + rv = ohc_sess_rpc(eFsaHpiEventLogTimeGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &ResourceId); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, Time); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -1260,41 +735,17 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogTimeSet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_IN SaHpiTimeT Time) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiTimeT Time) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogTimeSet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; + Params iparams(&ResourceId, &Time); + Params oparams; + rv = ohc_sess_rpc(eFsaHpiEventLogTimeSet, SessionId, iparams, oparams); - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogTimeSet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogTimeSet, hm->m_request_len); - request = g_malloc(hm->m_request_len); - - pinst->header.m_len = HpiMarshalRequest3(hm, request, &dsid, &ResourceId, &Time); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply0(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -1303,43 +754,21 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogStateGet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_OUT SaHpiBoolT *EnableState) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_OUT SaHpiBoolT *EnableState) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogStateGet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; - if (EnableState == NULL) - return SA_ERR_HPI_INVALID_PARAMS; + if (!EnableState) { + return SA_ERR_HPI_INVALID_PARAMS; + } - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogStateGet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogStateGet, hm->m_request_len); - request = g_malloc(hm->m_request_len); + Params iparams(&ResourceId); + Params oparams(EnableState); + rv = ohc_sess_rpc(eFsaHpiEventLogStateGet, SessionId, iparams, oparams); - pinst->header.m_len = HpiMarshalRequest2(hm, request, &dsid, &ResourceId); - - SendRecv(SessionId, cmd); - - int mr = HpiDemarshalReply1(pinst->remote_byte_order, hm, reply + sizeof(cMessageHeader), &err, EnableState); - - if (request) - g_free(request); - if (pinst->header.m_type == eMhError) - return SA_ERR_HPI_INVALID_PARAMS; - if (mr < 0) - return SA_ERR_HPI_INVALID_PARAMS; - - return err; + return rv; } @@ -1348,41 +777,17 @@ /*----------------------------------------------------------------------------*/ SaErrorT SAHPI_API saHpiEventLogStateSet( - SAHPI_IN SaHpiSessionIdT SessionId, - SAHPI_IN SaHpiResourceIdT ResourceId, - SAHPI_IN SaHpiBoolT EnableState) + SAHPI_IN SaHpiSessionIdT SessionId, + SAHPI_IN SaHpiResourceIdT ResourceId, + SAHPI_IN SaHpiBoolT EnableState) { - void *request; - char reply[dMaxMessageLength]; - SaErrorT err = SA_OK; - char cmd[] = "saHpiEventLogStateSet"; - pcstrmsock pinst; - SaHpiSessionIdT dsid = 0; - SaHpiDomainIdT did = 0; + SaErrorT rv; - if (SessionId == 0) - return SA_ERR_HPI_INVALID_SESSION; - err = oh_get_connx(SessionId, &dsid, &pinst, &did); - if (err) return err; + Params iparams(&ResourceId, &EnableState); + Params oparams; + rv = ohc_sess_rpc(eFsaHpiEventLogStateSet, SessionId, iparams, oparams); - cHpiMarshal *hm = HpiMarshalFind(eFsaHpiEventLogStateSet); - pinst->MessageHeaderInit(eMhMsg, 0, eFsaHpiEventLogStateSet, hm->m_request_len); - request = g_malloc(hm->m_request_len); - - ... [truncated message content] |