void set_Subscribe(Domain_t *domain, int as) // as = 1 - Subscribe // as = 0 - UnSubscribe // if domain == NULL - for all opened domains { int i, n; gpointer ptr; Domain_t *dmn; if ((domain != (Domain_t *)NULL) && domain->session_opened) { if (as) saHpiSubscribe(domain->sessionId); else saHpiUnsubscribe(domain->sessionId); return; }; n = g_slist_length(domainlist); for (i = 0; i < n; i++) { ptr = g_slist_nth_data(domainlist, i); if (ptr == (gpointer)NULL) return; dmn = (Domain_t *)ptr; if (dmn->session_opened) { if (as) saHpiSubscribe(dmn->sessionId); else saHpiUnsubscribe(dmn->sessionId); } } }
static void* get_event(void *unused) { SaHpiEventT event; SaErrorT rv; rv = saHpiSubscribe(sessionid); if (rv != SA_OK) { printf("OpenHPI>Fail to Subscribe event\n"); return (void *)0; } for(;;) { memset(&event, 0xF, sizeof(event)); rv = saHpiEventGet(sessionid, SAHPI_TIMEOUT_BLOCK, &event, NULL, NULL, NULL); if (rv != SA_OK ) { saHpiUnsubscribe(sessionid); return (void *)1; } if (prt_flag == 1) { if (show_event_short) show_short_event(&event); else oh_print_event(&event, 1); } } /*the loop for retrieving event*/ return (void *)1; }
int closeSaHpiSession () { DEBUGMSGTL ((AGENT, "--- closeSaHpiSession: Entry. ")); if (session_avail == AGENT_TRUE) { err = saHpiUnsubscribe (session_id); if (SA_OK != err) { snmp_log (LOG_ERR, "saHpiUnsubscirbe error: %s.\n", get_error_string (err)); return AGENT_ERR_SESSION_CLOSE; } err = saHpiFinalize (); if (SA_OK != err) { snmp_log (LOG_ERR, "saHpiFinalize error: %s\n", get_error_string (err)); return AGENT_ERR_SESSION_CLOSE; } session_avail = AGENT_FALSE; } DEBUGMSGTL ((AGENT, "--- closeSaHpiSession: Exit. ")); return AGENT_ERR_NOERROR; }
static void* get_event(void *unused) { SaHpiEventT event; SaErrorT rv; rv = saHpiSubscribe(sessionid, SAHPI_FALSE); if (rv != SA_OK) { printf("OpenHPI>Fail to Subscribe event\n"); return (void *)0; } for(;;){ memset(&event, 0xF, sizeof(event)); rv = saHpiEventGet(sessionid, SAHPI_TIMEOUT_BLOCK, &event, NULL, NULL); if (rv != SA_OK ) { goto out; } if ( prt_flag == 1 ) print_event(sessionid,&event); } /*the loop for retrieving event*/ out: printf( "Unsubscribe\n"); rv = saHpiUnsubscribe( sessionid ); return (void *)1; }
SaErrorT unsubscribe(SaHpiSessionIdT sessionId) { SaErrorT status; status = saHpiUnsubscribe(sessionId); if (status != SA_OK) { e_print(saHpiUnsubscribe, SA_OK, status); } return status; }
void cOpenHpiDaemon::Finalize() { while( m_num_connections ) CloseConnection( 0 ); if ( m_pollfd ) delete [] m_pollfd; if ( m_main_socket ) { ServerConnectionMainClose( m_main_socket ); m_main_socket = 0; } saHpiUnsubscribe( m_session ); saHpiSessionClose( m_session ); saHpiFinalize(); }
static void DoEvent( SaHpiSessionIdT sessionid, SaHpiResourceIdT resourceid, SaHpiSensorRecT *sensorrec ) { SaHpiSensorNumT sensornum; SaHpiSensorReadingT reading; SaHpiSensorReadingT conv_reading; SaHpiSensorThresholdsT senstbuff1; SaHpiSensorThresholdsT senstbuff2; SaHpiTimeoutT timeout = (SaHpiInt64T)(12 * HPI_NSEC_PER_SEC); /* 12 seconds */ SaHpiEventT event; SaHpiRptEntryT rptentry; SaHpiRdrT rdr; char *unit; int eventflag = 0; int i; sensornum = sensorrec->Num; /* Get current sensor reading */ rv = saHpiSensorReadingGet( sessionid, resourceid, sensornum, &reading); if (rv != SA_OK) { printf( "\n"); /* printf("ReadingGet ret=%d\n", rv); */ return; } if ((reading.ValuesPresent & SAHPI_SRF_INTERPRETED) == 0 && (reading.ValuesPresent & SAHPI_SRF_RAW)) { /* only try convert if intrepreted not available. */ rv = saHpiSensorReadingConvert(sessionid, resourceid, sensornum, &reading, &conv_reading); if (rv != SA_OK) { printf("raw=%x conv_ret=%d\n", reading.Raw, rv); /* printf("conv_rv=%s\n", decode_error(rv)); */ return; } else { reading.Interpreted.Type = conv_reading.Interpreted.Type; reading.Interpreted.Value.SensorUint32 = conv_reading.Interpreted.Value.SensorUint32; } } /* Determine units of interpreted reading */ i = sensorrec->DataFormat.BaseUnits; if (i > NSU) i = 0; unit = units[i]; printf(" = %05.2f %s \n", reading.Interpreted.Value.SensorFloat32, unit); /* Retrieve current threshold setings, twice */ /* once for backup and once for modification */ /* Get backup copy */ rv = saHpiSensorThresholdsGet( sessionid, resourceid, sensornum, &senstbuff1); if (rv != SA_OK) return; /* Get modification copy */ rv = saHpiSensorThresholdsGet( sessionid, resourceid, sensornum, &senstbuff2); if (rv != SA_OK) return; /* Display current thresholds */ if (rv == SA_OK) { printf( " Current\n"); ShowThresh( &senstbuff2 ); } /* Set new threshold to current reading + 10% */ senstbuff2.LowMajor.Interpreted.Value.SensorFloat32 = reading.Interpreted.Value.SensorFloat32 * (SaHpiFloat32T)1.10; printf( "ValuesPresent = %x\n", senstbuff2.LowMajor.ValuesPresent); printf( "Values Mask = %x\n", (SAHPI_SRF_RAW)); senstbuff2.LowMajor.ValuesPresent = senstbuff2.LowMajor.ValuesPresent ^ (SAHPI_SRF_RAW); printf( "ValuesPresent = %x\n", senstbuff2.LowMajor.ValuesPresent); /* Display new current thresholds */ if (rv == SA_OK) { printf( " New\n"); ShowThresh( &senstbuff2 ); } /* See what Events are Enabled */ rv = saHpiSensorEventEnablesGet( sessionid, resourceid, sensornum, &enables1); if (rv != SA_OK) return; printf( "Sensor Event Enables: \n"); printf( " Sensor Status = %x\n", enables1.SensorStatus); printf( " Assert Events = %x\n", enables1.AssertEvents); printf( " Deassert Events = %x\n", enables1.DeassertEvents); /* enables1.AssertEvents = 0x0400; enables1.DeassertEvents = 0x0400; rv = saHpiSensorEventEnablesSet( sessionid, resourceid, sensornum, &enables1); if (rv != SA_OK) return; */ /************************ Temporary exit */ /* return; */ /* Subscribe to New Events, only */ printf( "Subscribe to events\n"); rv = saHpiSubscribe( sessionid, (SaHpiBoolT)0 ); if (rv != SA_OK) return; /* Set new thresholds */ printf( "Set new thresholds\n"); rv = saHpiSensorThresholdsSet( sessionid, resourceid, sensornum, &senstbuff2); if (rv != SA_OK) return; /* Go wait on event to occur */ printf( "Go and get the event\n"); eventflag = 0; while ( eventflag == 0) { rv = saHpiEventGet( sessionid, timeout, &event, &rdr, &rptentry ); if (rv != SA_OK) { if (rv != SA_ERR_HPI_TIMEOUT) { printf( "Error during EventGet - Test FAILED\n"); return; } else { printf( "Time expired during EventGet - Test FAILED\n"); /* Reset to the original thresholds */ printf( "Reset thresholds\n"); rv = saHpiSensorThresholdsSet( sessionid, resourceid, sensornum, &senstbuff1); if (rv != SA_OK) return; /* Re-read threshold values */ rv = saHpiSensorThresholdsGet( sessionid, resourceid, sensornum, &senstbuff2); if (rv != SA_OK) return; return; } } /* Decode the event information */ printf( "Decode event info\n"); if (event.EventType == SAHPI_ET_SENSOR) { printf( "Sensor # = %2d Severity = %2x\n", event.EventDataUnion.SensorEvent.SensorNum, event.Severity ); if (event.EventDataUnion.SensorEvent.SensorNum == sensornum) { eventflag = 1; printf( "Got it - Test PASSED\n"); } } } /* Reset to the original thresholds */ printf( "Reset thresholds\n"); rv = saHpiSensorThresholdsSet( sessionid, resourceid, sensornum, &senstbuff1); if (rv != SA_OK) return; /* Re-read threshold values */ rv = saHpiSensorThresholdsGet( sessionid, resourceid, sensornum, &senstbuff2); if (rv != SA_OK) return; /* Display reset thresholds */ if (rv == SA_OK) { printf( " Reset\n"); ShowThresh( &senstbuff2 ); } /* Unsubscribe to future events */ printf( "Unsubscribe\n"); rv = saHpiUnsubscribe( sessionid ); return; } /*end DoEvent*/
int main(int argc, char **argv) { int c, test_fail = 0, wait = 0; char *timeout_str= (char *)NULL; int do_discover_after_subscribe = 0; SaErrorT rv; SaHpiSessionIdT sessionid; SaHpiDomainInfoT domainInfo; SaHpiRptEntryT rptentry; SaHpiEntryIdT rptentryid; SaHpiEntryIdT nextrptentryid; SaHpiResourceIdT resourceid; SaHpiEventLogInfoT info; SaHpiRdrT rdr; SaHpiTimeoutT timeout; SaHpiEventT event; memset(&rptentry, 0, sizeof(rptentry)); printf("%s: version %s\n", argv[0], progver); while ( (c = getopt( argc, argv,"t:xd?")) != EOF ) { switch(c) { case 't': timeout_str = optarg; break; case 'd': do_discover_after_subscribe = 1; break; case 'x': fdebug = 1; break; default: Usage(argv); exit(1); } } if (timeout_str != (char *)NULL) { if ((strcmp(timeout_str, "SAHPI_TIMEOUT_BLOCK") == 0) || (strcmp(timeout_str, "BLOCK") == 0)) { timeout = SAHPI_TIMEOUT_BLOCK; } else { wait = atoi(timeout_str); timeout = (SaHpiTimeoutT)(wait * HPI_NSEC_PER_SEC); } } else timeout = (SaHpiTimeoutT) SAHPI_TIMEOUT_IMMEDIATE; printf("************** timeout:[%lld] ****************\n", timeout); rv = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sessionid, NULL); if (rv != SA_OK) { if (rv == SA_ERR_HPI_ERROR) printf("saHpiSessionOpen: error %d, SpiLibd not running\n", rv); else printf("saHpiSessionOpen: %s\n", oh_lookup_error(rv)); exit(-1); } if (fdebug) printf("saHpiDiscover\n"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover: %s\n", oh_lookup_error(rv)); exit(-1); } if (fdebug) printf( "Subscribe to events\n"); rv = saHpiSubscribe( sessionid ); if (rv != SA_OK) { printf("saHpiSubscribe: %s\n", oh_lookup_error(rv)); exit(-1); } if (do_discover_after_subscribe) { if (fdebug) printf("saHpiDiscover after saHpiSubscribe\n"); rv = saHpiDiscover(sessionid); if (rv != SA_OK) { printf("saHpiDiscover after saHpiSubscribe: %s\n", oh_lookup_error(rv)); exit(-1); } } rv = saHpiDomainInfoGet(sessionid, &domainInfo); if (fdebug) printf("saHpiDomainInfoGet %s\n", oh_lookup_error(rv)); printf("DomainInfo: UpdateCount = %d, UpdateTime = %lx\n", domainInfo.RptUpdateCount, (unsigned long)domainInfo.RptUpdateTimestamp); /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { printf("**********************************************\n"); rv = saHpiRptEntryGet(sessionid, rptentryid, &nextrptentryid, &rptentry); if (fdebug) printf("saHpiRptEntryGet %s\n", oh_lookup_error(rv)); if (rv == SA_OK) { resourceid = rptentry.ResourceId; if (fdebug) printf("RPT %x capabilities = %x\n", resourceid, rptentry.ResourceCapabilities); if ( (rptentry.ResourceCapabilities & SAHPI_CAPABILITY_EVENT_LOG)) { /* Using EventLogInfo to build up event queue - for now */ rv = saHpiEventLogInfoGet(sessionid, resourceid, &info); if (fdebug) printf("saHpiEventLogInfoGet %s\n", oh_lookup_error(rv)); if (rv == SA_OK) oh_print_eventloginfo(&info, 4); } else { if (fdebug) printf("RPT doesn't have SEL\n"); } rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; printf("rptentry[%d] tag: %s\n", resourceid, rptentry.ResourceTag.Data); rptentryid = nextrptentryid; } printf("**********************************************\n"); } printf( "Go and get the event\n"); while (1) { rdr.RdrType = SAHPI_NO_RECORD; rv = saHpiEventGet( sessionid, timeout, &event, &rdr, &rptentry, NULL); if (rv != SA_OK) { if (rv != SA_ERR_HPI_TIMEOUT) { printf("ERROR during EventGet : %s\n", oh_lookup_error(rv)); test_fail = 1; } else { if (timeout == SAHPI_TIMEOUT_BLOCK) { printf("ERROR: Timeout while infinite wait\n"); test_fail = 1; } else if (timeout != SAHPI_TIMEOUT_IMMEDIATE) { printf("ERROR: Time, %d seconds, expired waiting" " for event\n", wait); test_fail = 1; } } break; } else { oh_print_event(&event, 4); } } if (test_fail == 0) printf(" Test PASS.\n"); else printf(" Test FAILED.\n"); /* Unsubscribe to future events */ if (fdebug) printf( "Unsubscribe\n"); rv = saHpiUnsubscribe( sessionid ); rv = saHpiSessionClose(sessionid); return(0); }
int main(int argc, char **argv) { int c, wait = 0; SaErrorT rv; SaHpiVersionT hpiVer; SaHpiSessionIdT sessionid; SaHpiRptInfoT rptinfo; SaHpiRptEntryT rptentry; SaHpiEntryIdT rptentryid; SaHpiEntryIdT nextrptentryid; SaHpiResourceIdT resourceid; SaHpiSelInfoT info; SaHpiRdrT rdr; SaHpiTimeoutT timeout; SaHpiEventT event; printf("%s: version %s\n",argv[0],progver); while ( (c = getopt( argc, argv,"t:x?")) != EOF ) switch(c) { case 't': ftimer = 1; wait = atoi(optarg); break; case 'x': fdebug = 1; break; default: printf("Usage %s [-tx]\n",argv[0]); printf(" -t <value>:wait <value> seconds for event\n"); printf(" -x :displays eXtra debug messages\n"); exit(1); } if (ftimer) timeout = (SaHpiInt64T)(wait * HPI_NSEC_PER_SEC); else timeout = (SaHpiInt64T) SAHPI_TIMEOUT_IMMEDIATE; rv = saHpiInitialize(&hpiVer); if (rv != SA_OK) { printf("saHpiInitialize: %s\n",decode_error(rv)); exit(-1); } rv = saHpiSessionOpen(SAHPI_DEFAULT_DOMAIN_ID,&sessionid,NULL); if (rv != SA_OK) { if (rv == SA_ERR_HPI_ERROR) printf("saHpiSessionOpen: error %d, SpiLibd not running\n",rv); else printf("saHpiSessionOpen: %s\n",decode_error(rv)); exit(-1); } rv = saHpiResourcesDiscover(sessionid); if (fdebug) printf("saHpiResourcesDiscover %s\n",decode_error(rv)); rv = saHpiRptInfoGet(sessionid,&rptinfo); if (fdebug) printf("saHpiRptInfoGet %s\n",decode_error(rv)); printf("RptInfo: UpdateCount = %d, UpdateTime = %lx\n", rptinfo.UpdateCount, (unsigned long)rptinfo.UpdateTimestamp); printf( "Subscribe to events\n"); rv = saHpiSubscribe( sessionid, (SaHpiBoolT)0 ); if (rv != SA_OK) return rv; /* walk the RPT list */ rptentryid = SAHPI_FIRST_ENTRY; while ((rv == SA_OK) && (rptentryid != SAHPI_LAST_ENTRY)) { rv = saHpiRptEntryGet(sessionid,rptentryid,&nextrptentryid,&rptentry); if (fdebug) printf("saHpiRptEntryGet %s\n",decode_error(rv)); if (rv == SA_OK) { resourceid = rptentry.ResourceId; if (fdebug) printf("RPT %x capabilities = %x\n", resourceid, rptentry.ResourceCapabilities); if (!(rptentry.ResourceCapabilities & SAHPI_CAPABILITY_SEL)) { if (fdebug) printf("RPT doesn't have SEL\n"); rptentryid = nextrptentryid; continue; /* no SEL here, try next RPT */ } rptentry.ResourceTag.Data[rptentry.ResourceTag.DataLength] = 0; printf("rptentry[%d] tag: %s\n", resourceid,rptentry.ResourceTag.Data); /* Using EventLogInfo to build up event queue - for now */ rv = saHpiEventLogInfoGet(sessionid,resourceid,&info); if (fdebug) printf("saHpiEventLogInfoGet %s\n",decode_error(rv)); if (rv == SA_OK) { break; } rptentryid = nextrptentryid; } } printf( "Go and get the event\n"); while (1) { rv = saHpiEventGet( sessionid, timeout, &event, &rdr, &rptentry ); if (rv != SA_OK) { if (rv != SA_ERR_HPI_TIMEOUT) { printf( "Error during EventGet - Test FAILED\n"); break; } else { printf( "\n\n****** Time, %d seconds, expired waiting for event.\n", wait); break; } } else { print_event(&event); } } /* Unsubscribe to future events */ printf( "Unsubscribe\n"); rv = saHpiUnsubscribe( sessionid ); rv = saHpiSessionClose(sessionid); rv = saHpiFinalize(); exit(0); return(0); }
cOpenHpiDaemon::tResult cOpenHpiDaemon::HandleMsg( cConnection *c, const cMessageHeader &header, const void *data, cMessageHeader &rh, void *&rd ) { cHpiMarshal *hm = HpiMarshalFind( header.m_id ); // check for function and data length if ( !hm || hm->m_request_len < header.m_len ) { //MessageHeaderInit( &rh, eMhError, header.m_seq, 0, 0 ); //rd = 0; fprintf( stderr, "wrong message length: id %d !\n", header.m_id ); return eResultError; } assert( hm->m_reply_len ); // init reply header MessageHeaderInit( &rh, eMhReply, header.m_seq, header.m_id, hm->m_reply_len ); // alloc reply buffer rd = calloc( 1, hm->m_reply_len ); SaErrorT ret; switch( header.m_id ) { case eFsaHpiSessionOpen: { SaHpiDomainIdT domain_id; SaHpiSessionIdT session_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, (void *)&domain_id ); ret = saHpiSessionOpen( domain_id, &session_id, 0 ); DbgFunc( "saHpiSessionOpen( %x, %x ) = %d\n", domain_id, session_id, ret ); if ( ret == SA_OK ) c->AddSession( session_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &session_id ); } break; case eFsaHpiSessionClose: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiSessionClose( session_id ); DbgFunc( "saHpiSessionClose( %x ) = %d\n", session_id, ret ); if ( ret == SA_OK ) c->RemSession( session_id ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourcesDiscover: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiResourcesDiscover( session_id ); DbgFunc( "saHpiResourcesDiscover( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiRptInfoGet: { SaHpiSessionIdT session_id; SaHpiRptInfoT rpt_info; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiRptInfoGet( session_id, &rpt_info ); DbgFunc( "saHpiRptInfoGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &rpt_info ); } break; case eFsaHpiRptEntryGet: { SaHpiSessionIdT session_id; SaHpiEntryIdT entry_id; SaHpiEntryIdT next_entry_id; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &entry_id ); ret = saHpiRptEntryGet( session_id, entry_id, &next_entry_id, &rpt_entry ); DbgFunc( "saHpiRptEntryGet( %x, %x, %x ) = %d\n", session_id, entry_id, next_entry_id, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &next_entry_id, &rpt_entry ); } break; case eFsaHpiRptEntryGetByResourceId: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiRptEntryGetByResourceId( session_id, resource_id, &rpt_entry ); DbgFunc( "saHpiRptEntryGetByResourceId( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &rpt_entry ); } break; case eFsaHpiResourceSeveritySet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSeverityT severity; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &severity ); ret = saHpiResourceSeveritySet( session_id, resource_id, severity ); DbgFunc( "saHpiResourceSeveritySet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceTagSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTextBufferT resource_tag; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &resource_tag ); ret = saHpiResourceTagSet( session_id, resource_id, &resource_tag ); DbgFunc( "saHpiResourceTagSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceIdGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiResourceIdGet( session_id, &resource_id ); DbgFunc( "saHpiResourceIdGet( %x ) = %d, %x\n", session_id, ret, resource_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &resource_id ); } break; case eFsaHpiEntitySchemaGet: { SaHpiSessionIdT session_id; SaHpiUint32T schema_id = 0; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiEntitySchemaGet( session_id, &schema_id ); DbgFunc( "saHpiEntitySchemaGet( %x ) = %d, %x\n", session_id, ret, schema_id ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &schema_id ); } break; case eFsaHpiEventLogInfoGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelInfoT info; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogInfoGet( session_id, resource_id, &info ); DbgFunc( "saHpiEventLogInfoGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &info ); } break; case eFsaHpiEventLogEntryGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryIdT entry_id; SaHpiSelEntryIdT prev_entry_id = 0; SaHpiSelEntryIdT next_entry_id = 0; SaHpiSelEntryT event_log_entry; SaHpiRdrT rdr; SaHpiRptEntryT rpt_entry; memset( &rdr, 0, sizeof( SaHpiRdrT ) ); memset( &rpt_entry, 0, sizeof( SaHpiRptEntryT ) ); HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiEventLogEntryGet( session_id, resource_id, entry_id, &prev_entry_id, &next_entry_id, &event_log_entry, &rdr, &rpt_entry ); DbgFunc( "saHpiEventLogEntryGet( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply5( hm, rd, &ret, &prev_entry_id, &next_entry_id, &event_log_entry, &rdr, &rpt_entry ); } break; case eFsaHpiEventLogEntryAdd: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryT evt_entry; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &evt_entry ); ret = saHpiEventLogEntryAdd( session_id, resource_id, &evt_entry ); DbgFunc( "saHpiEventLogEntryAdd( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogEntryDelete: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSelEntryIdT entry_id; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiEventLogEntryDelete( session_id, resource_id, entry_id ); DbgFunc( "saHpiEventLogEntryDelete( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogClear: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogClear( session_id, resource_id ); DbgFunc( "saHpiEventLogClear( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogTimeGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeT ti; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogTimeGet( session_id, resource_id, &ti ); DbgFunc( "saHpiEventLogTimeGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &ti ); } break; case eFsaHpiEventLogTimeSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeT ti; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id , &ti ); ret = saHpiEventLogTimeSet( session_id, resource_id, ti ); DbgFunc( "saHpiEventLogTimeSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventLogStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiBoolT enable; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiEventLogStateGet( session_id, resource_id, &enable ); DbgFunc( "saHpiEventLogStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &enable ); } break; case eFsaHpiEventLogStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiBoolT enable; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &enable ); ret = saHpiEventLogStateSet( session_id, resource_id, enable ); DbgFunc( "saHpiEventLogStateSet( %x, %x, %s ) = %d\n", session_id, resource_id, enable ? "true" : "false", ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiSubscribe: { SaHpiSessionIdT session_id; SaHpiBoolT provide_active_alarms; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &provide_active_alarms ); ret = saHpiSubscribe( session_id, provide_active_alarms ); DbgFunc( "saHpiSubscribe( %x, %s ) = %d\n", session_id, provide_active_alarms ? "true" : "false", ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiUnsubscribe: { SaHpiSessionIdT session_id; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiUnsubscribe( session_id ); DbgFunc( "saHpiUnsubscribe( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEventGet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; SaHpiEventT event; SaHpiRdrT rdr; SaHpiRptEntryT rpt_entry; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &timeout ); if ( timeout == 0 ) { ret = saHpiEventGet( session_id, timeout, &event, &rdr, &rpt_entry ); DbgFunc( "saHpiEventGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply3( hm, rd, &ret, &event, &rdr, &rpt_entry ); } else { cSession *s = c->FindSession( session_id ); if ( s && !s->IsEventGet() ) { s->EventGet( true ); SaHpiTimeT end; gettimeofday1( &end ); if ( timeout == SAHPI_TIMEOUT_BLOCK ) end += (SaHpiTimeT)10000*1000000000; //set a long time else end += timeout; s->Timeout() = end; s->Seq() = header.m_seq; DbgEvent( "saHpiEventGet( %x ): add to event listener.\n", s->SessionId() ); return eResultOk; } // error ret = SA_ERR_HPI_BUSY; rh.m_len = HpiMarshalReply3( hm, rd, &ret, &event, &rdr, &rpt_entry ); } } break; case eFsaHpiRdrGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEntryIdT entry_id; SaHpiEntryIdT next_entry_id; SaHpiRdrT rdr; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &entry_id ); ret = saHpiRdrGet( session_id, resource_id, entry_id, &next_entry_id, &rdr ); DbgFunc( "saHpiRdrGet( %x, %x, %x ) = %d\n", session_id, resource_id, entry_id, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &next_entry_id, &rdr ); } break; case eFsaHpiSensorReadingGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorReadingT reading; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorReadingGet( session_id, resource_id, sensor_num, &reading ); DbgFunc( "saHpiSensorReadingGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &reading ); } break; case eFsaHpiSensorReadingConvert: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorReadingT reading_input; SaHpiSensorReadingT converted_reading; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &reading_input ); ret = saHpiSensorReadingConvert( session_id, resource_id, sensor_num, &reading_input, &converted_reading ); DbgFunc( "saHpiSensorReadingConvert( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &converted_reading ); } break; case eFsaHpiSensorThresholdsGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorThresholdsT sensor_thresholds; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorThresholdsGet( session_id, resource_id, sensor_num, &sensor_thresholds); DbgFunc( "saHpiSensorThresholdsGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &sensor_thresholds ); } break; case eFsaHpiSensorThresholdsSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorThresholdsT sensor_thresholds; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &sensor_thresholds ); ret = saHpiSensorThresholdsSet( session_id, resource_id, sensor_num, &sensor_thresholds ); DbgFunc( "saHpiSensorThresholdsSet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiSensorTypeGet: { SaHpiResourceIdT resource_id; SaHpiSessionIdT session_id; SaHpiSensorNumT sensor_num; SaHpiSensorTypeT type; SaHpiEventCategoryT category; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorTypeGet( session_id, resource_id, sensor_num, &type, &category ); DbgFunc( "saHpiSensorTypeGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply2( hm, rd, &ret, &type, &category ); } break; case eFsaHpiSensorEventEnablesGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorEvtEnablesT enables; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num ); ret = saHpiSensorEventEnablesGet( session_id, resource_id, sensor_num, &enables ); DbgFunc( "saHpiSensorEventEnablesGet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &enables ); } break; case eFsaHpiSensorEventEnablesSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiSensorNumT sensor_num; SaHpiSensorEvtEnablesT enables; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &sensor_num, &enables ); ret = saHpiSensorEventEnablesSet( session_id, resource_id, sensor_num, &enables ); DbgFunc( "saHpiSensorEventEnablesSet( %x, %x, %x ) = %d\n", session_id, resource_id, sensor_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiControlTypeGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlTypeT type; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num ); ret = saHpiControlTypeGet( session_id, resource_id, ctrl_num, &type ); DbgFunc( "saHpiControlTypeGet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &type ); } break; case eFsaHpiControlStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlStateT ctrl_state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num ); ret = saHpiControlStateGet( session_id, resource_id, ctrl_num, &ctrl_state ); DbgFunc( "saHpiControlStateGet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &ctrl_state ); } break; case eFsaHpiControlStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiCtrlNumT ctrl_num; SaHpiCtrlStateT ctrl_state; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &ctrl_num, &ctrl_state ); ret = saHpiControlStateSet( session_id, resource_id, ctrl_num, &ctrl_state ); DbgFunc( "saHpiControlStateSet( %x, %x, %x ) = %d\n", session_id, resource_id, ctrl_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiEntityInventoryDataRead: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEirIdT eir_id; SaHpiUint32T buffer_size; unsigned char *buffer = 0; SaHpiUint32T actual_size; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &eir_id, &buffer_size ); if ( buffer_size ) buffer = new unsigned char [buffer_size]; ret = saHpiEntityInventoryDataRead( session_id, resource_id, eir_id, buffer_size, (SaHpiInventoryDataT *)(void *)buffer, &actual_size ); DbgFunc( "saHpintityInventoryDataRead( %x, %x, %x, %d ) = %d\n", session_id, resource_id, eir_id, buffer_size, ret ); const cMarshalType *reply[4]; reply[0] = &SaErrorType; // SA_OK reply[1] = &SaHpiUint32Type; // actual size const void *params[3]; params[0] = &ret; params[1] = &actual_size; if ( ret != SA_OK || buffer == 0 ) reply[2] = 0; else { reply[2] = &SaHpiInventoryDataType, // inventory data reply[3] = 0; params[2] = buffer; } rh.m_len = MarshalArray( reply, params, rd ); if ( buffer ) delete [] buffer; } break; case eFsaHpiEntityInventoryDataWrite: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiEirIdT eir_id; unsigned char buffer[10240]; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &eir_id, buffer ); ret = saHpiEntityInventoryDataWrite( session_id, resource_id, eir_id, (SaHpiInventoryDataT *)(void *)buffer ); DbgFunc( "saHpintityInventoryDataWrite( %x, %x, %x ) = %d\n", session_id, resource_id, eir_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiWatchdogTimerGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; SaHpiWatchdogT watchdog; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num ); ret = saHpiWatchdogTimerGet( session_id, resource_id, watchdog_num, &watchdog ); DbgFunc( "saHpiWatchdogTimerGet( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &watchdog ); } break; case eFsaHpiWatchdogTimerSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; SaHpiWatchdogT watchdog; HpiDemarshalRequest4( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num, &watchdog ); ret = saHpiWatchdogTimerSet( session_id, resource_id, watchdog_num, &watchdog ); DbgFunc( "saHpiWatchdogTimerSet( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiWatchdogTimerReset: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiWatchdogNumT watchdog_num; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &watchdog_num ); ret = saHpiWatchdogTimerReset( session_id, resource_id, watchdog_num ); DbgFunc( "eFsaHpiWatchdogTimerReset( %x, %x, %x ) = %d\n", session_id, resource_id, watchdog_num, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapControlRequest: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapControlRequest( session_id, resource_id ); DbgFunc( "saHpiHotSwapControlRequest( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceActiveSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceActiveSet( session_id, resource_id ); DbgFunc( "saHpiResourceActiveSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceInactiveSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceInactiveSet( session_id, resource_id ); DbgFunc( "saHpiResourceInactiveSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiAutoInsertTimeoutGet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; HpiDemarshalRequest1( header.m_flags & dMhEndianBit, hm, data, &session_id ); ret = saHpiAutoInsertTimeoutGet( session_id, &timeout ); DbgFunc( "saHpiAutoInsertTimeoutGet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &timeout ); } break; case eFsaHpiAutoInsertTimeoutSet: { SaHpiSessionIdT session_id; SaHpiTimeoutT timeout; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &timeout ); ret = saHpiAutoInsertTimeoutSet( session_id, timeout ); DbgFunc( "saHpiAutoInsertTimeoutSet( %x ) = %d\n", session_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiAutoExtractTimeoutGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeoutT timeout; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiAutoExtractTimeoutGet( session_id, resource_id, &timeout ); DbgFunc( "saHpiAutoExtractTimeoutGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &timeout ); } break; case eFsaHpiAutoExtractTimeoutSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiTimeoutT timeout; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &timeout ); ret = saHpiAutoExtractTimeoutSet( session_id, resource_id, timeout ); DbgFunc( "saHpiAutoExtractTimeoutSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiHotSwapStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiHotSwapActionRequest: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsActionT action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &action ); ret = saHpiHotSwapActionRequest( session_id, resource_id, action ); DbgFunc( "saHpiHotSwapActionRequest( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourcePowerStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsPowerStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourcePowerStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiResourcePowerStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiResourcePowerStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsPowerStateT state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &state ); ret = saHpiResourcePowerStateSet( session_id, resource_id, state ); DbgFunc( "(saHpiResourcePowerStateSet %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiHotSwapIndicatorStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsIndicatorStateT state; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiHotSwapIndicatorStateGet( session_id, resource_id, &state ); DbgFunc( "saHpiHotSwapIndicatorStateGet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &state ); } break; case eFsaHpiHotSwapIndicatorStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiHsIndicatorStateT state; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &state ); ret = saHpiHotSwapIndicatorStateSet( session_id, resource_id, state ); DbgFunc( "saHpiHotSwapIndicatorStateSet( %x, %x ) = %d\n", session_id, resource_id , ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiParmControl: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiParmActionT action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &action ); ret = saHpiParmControl( session_id, resource_id, action ); DbgFunc( "saHpiParmControl( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; case eFsaHpiResourceResetStateGet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiResetActionT reset_action; HpiDemarshalRequest2( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id ); ret = saHpiResourceResetStateGet( session_id, resource_id, &reset_action ); DbgFunc( "saHpiResourceResetStateGet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply1( hm, rd, &ret, &reset_action ); } break; case eFsaHpiResourceResetStateSet: { SaHpiSessionIdT session_id; SaHpiResourceIdT resource_id; SaHpiResetActionT reset_action; HpiDemarshalRequest3( header.m_flags & dMhEndianBit, hm, data, &session_id, &resource_id, &reset_action ); ret = saHpiResourceResetStateSet( session_id, resource_id, reset_action ); DbgFunc( "saHpiResourceResetStateSet( %x, %x ) = %d\n", session_id, resource_id, ret ); rh.m_len = HpiMarshalReply0( hm, rd, &ret ); } break; default: assert( 0 ); break; } assert( rh.m_len <= hm->m_reply_len ); return eResultReply; }
bool cOpenHpiDaemon::Initialize() { if ( m_daemon ) { DbgInit( "become a daemon.\n" ); pid_t pid = fork(); if ( pid < 0 ) { fprintf( stderr, "cannot fork: %s !\n", strerror( errno ) ); return false; } // parent process if ( pid != 0 ) exit( 0 ); // become the session leader setsid(); // second fork to become a real daemon pid = fork(); if ( pid < 0 ) { fprintf( stderr, "cannot fork: %s !\n", strerror( errno ) ); return false; } // parent process if ( pid != 0 ) exit( 0 ); chdir( "/" ); umask( 0 ); } // use config file given by the command line if ( m_config ) setenv( "OPENHPI_CONF", m_config, 1 ); // initialize openhpi DbgInit( "initialize openhpi.\n" ); SaErrorT rv = saHpiInitialize( &m_version ); if ( rv != SA_OK ) { fprintf( stderr, "cannot initialize openhpi: %s !\n", decode_error( rv ) ); return false; } // create a session rv = saHpiSessionOpen( SAHPI_DEFAULT_DOMAIN_ID, &m_session, 0 ); if ( rv != SA_OK ) { fprintf( stderr, "cannot create session: %s !\n", decode_error( rv ) ); saHpiFinalize(); return false; } // subscribe rv = saHpiSubscribe( m_session, SAHPI_TRUE ); if ( rv != SA_OK ) { fprintf( stderr, "cannot subscribe: %s !\n", decode_error( rv ) ); saHpiSessionClose( m_session ); saHpiFinalize(); return false; } // open daemon socket DbgInit( "create daemon connection port %d.\n", m_daemon_port ); m_main_socket = ServerConnectionMainOpen( m_daemon_port ); if ( !m_main_socket ) { fprintf( stderr, "cannot create daemon socket: %d, %s !\n", errno, strerror( errno ) ); saHpiUnsubscribe( m_session ); saHpiSessionClose( m_session ); saHpiFinalize(); return false; } if ( m_interactive ) DbgInit( "interactive\n" ); DbgInit( "daemon is up.\n" ); return true; }
int TestDomain(SaHpiSessionIdT sessionId) { int i; int retval = SAF_TEST_NOTSUPPORT; int response; SaErrorT error; SaHpiEntryIdT nextEntryId; SaHpiEntryIdT entryId; SaHpiRptEntryT rptEntry; SaHpiBoolT pass = SAHPI_FALSE; sensorCount = 0; error = saHpiSubscribe(sessionId); if (error != SA_OK) { e_print(saHpiSubscribe, SA_OK, error); retval = SAF_TEST_UNRESOLVED; } else { nextEntryId = SAHPI_FIRST_ENTRY; while (nextEntryId != SAHPI_LAST_ENTRY && retval == SAF_TEST_NOTSUPPORT) { entryId = nextEntryId; error = saHpiRptEntryGet(sessionId, entryId, &nextEntryId, &rptEntry); if (error == SA_ERR_HPI_NOT_PRESENT) { break; } else if (error != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiRptEntryGet, SA_OK, error); } else if (rptEntry.ResourceCapabilities & SAHPI_CAPABILITY_SENSOR) { response = testResource(sessionId, rptEntry.ResourceId); if (response == SAF_TEST_PASS) { pass = SAHPI_TRUE; } else { retval = response; } } } if (retval == SAF_TEST_NOTSUPPORT && pass) { retval = SAF_TEST_PASS; // Check for any remaining events that may have been generated. // We will pause for 5 seconds to give the last sensor time to // generate an event. for (i = 0; i < 2 && retval == SAF_TEST_PASS; i++) { sleep(5); retval = checkForEvents(sessionId); } if (retval == SAF_TEST_PASS) { retval = verifyEvents(); } } restoreSensors(sessionId); error = saHpiUnsubscribe(sessionId); if (error != SA_OK) { e_print(saHpiUnsubscribe, SA_OK, error); } } return retval; }
int main() { SaHpiSessionIdT sid; SaHpiEventT event; SaHpiRptEntryT rpt_entry; SaHpiResourceIdT rid; SaHpiSeverityT severity_old, severity_new; int i; SaErrorT status; int ret = SAF_TEST_UNKNOWN; printf("\n*****************Domain func begin***************\n"); status = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sid, NULL); if (status != SA_OK) { e_print(saHpiSessionOpen, SA_OK, status); ret = SAF_TEST_UNRESOLVED; } else { status = saHpiSubscribe(sid); if (status != SA_OK) { e_print(saHpiSubscribe, SA_OK, status); ret = SAF_TEST_UNRESOLVED; } else { /* User inserts a FRU manually */ read_prompt("Now pls. insert a FRU in the domain ...\n" "Then press Enter key to continue ...\n"); for (i = 0;;) { status = saHpiEventGet(sid, TIMEOUT, &event, NULL, &rpt_entry, NULL); if (status == SA_ERR_HPI_TIMEOUT && ++i == TIMES) { m_print ("The timeout value has been reached, but the user did not enter an FRU."); ret = SAF_TEST_UNRESOLVED; break; } else if (status != SA_OK) { e_print(saHpiEventGet, SA_OK, status); ret = SAF_TEST_UNRESOLVED; break; } else if ((event.EventType == SAHPI_ET_HOTSWAP) && ((event.EventDataUnion.HotSwapEvent.HotSwapState == SAHPI_HS_STATE_ACTIVE) || (event.EventDataUnion.HotSwapEvent.HotSwapState == SAHPI_HS_STATE_INSERTION_PENDING))) { rid = rpt_entry.ResourceId; severity_old = rpt_entry.ResourceSeverity; break; } } if (ret == SAF_TEST_UNKNOWN) { if (severity_old != SAHPI_CRITICAL) severity_new = SAHPI_CRITICAL; else severity_new = SAHPI_MAJOR; status = saHpiResourceSeveritySet(sid, rid, severity_new); if (status != SA_OK) { e_print(saHpiResourceSeveritySet, SA_OK, status); ret = SAF_TEST_UNRESOLVED; } else { read_prompt ("Now please create a \"surprise extraction\" by removing the\n" "the same FRU you just inserted to identify its ResourceId ...\n" "Then press the Enter key to continue ...\n"); for (i = 0;;) { status = saHpiEventGet(sid, TIMEOUT, &event, NULL, &rpt_entry, NULL); if (status == SA_ERR_HPI_TIMEOUT) { if (++i == TIMES) { m_print ("The timeout value has been reached, but the user did not plug out an FRU."); ret = SAF_TEST_UNRESOLVED; break; } } else if (status != SA_OK) { e_print(saHpiEventGet, SA_OK, status); ret = SAF_TEST_UNRESOLVED; break; } else if (event.EventType == SAHPI_ET_HOTSWAP && event.EventDataUnion.HotSwapEvent.HotSwapState == SAHPI_HS_STATE_NOT_PRESENT && rpt_entry.ResourceId == rid && event.Severity == severity_new) { ret = SAF_TEST_PASS; break; } } } if (ret == SAF_TEST_UNKNOWN) { ret = SAF_TEST_FAIL; } saHpiResourceSeveritySet(sid, rid, severity_old); } status = saHpiUnsubscribe(sid); } status = saHpiSessionClose(sid); } printf("\n return=%s\n",get_test_result(ret)); printf("\n*****************Domain func end*****************\n"); return ret; }