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. |