/// Insert or update an entry into the map. bool insert_update(const value_t& value) { if (mutexs_ == NULL) return false; size_t bucket_seat = calculate_hash_value(value.first) % num_buckets_; bucket_t& bucket = buckets_[bucket_seat]; // Use write lock for exclusive write. write_lock_t lock(mutexs_[bucket_seat % num_mutexs_]); size_t bucket_size = bucket.size(); for (size_t i = 0; i < bucket_size; ++i) { if (bucket[i].first == value.first) { bucket[i].second = value.second; return true; } } bucket.push_back(value); return true; }
/// Erase an entry from the map. bool erase(const K& k) { if (mutexs_ == NULL) return false; size_t bucket_seat = calculate_hash_value(k) % num_buckets_; bucket_t& bucket = buckets_[bucket_seat]; // Use write lock for exclusive write. write_lock_t lock(mutexs_[bucket_seat % num_mutexs_]); size_t bucket_size = bucket.size(); for (size_t i = 0; i < bucket_size; ++i) { if (bucket[i].first == k) { if (i != bucket_size - 1) bucket[i] = bucket[bucket_size - 1]; bucket.pop_back(); return true; } } return false; }
// Re-initialise the hash from the values already contained in the list. void rehash(std::size_t num_buckets) { if (num_buckets == num_buckets_) return; num_buckets_ = num_buckets; iterator end = values_.end(); // Update number of buckets and initialise all buckets to empty. bucket_type* tmp = new bucket_type[num_buckets_]; delete[] buckets_; buckets_ = tmp; for (std::size_t i = 0; i < num_buckets_; ++i) buckets_[i].first = buckets_[i].last = end; // Put all values back into the hash. iterator iter = values_.begin(); while (iter != end) { std::size_t bucket = calculate_hash_value(iter->first) % num_buckets_; if (buckets_[bucket].last == end) { buckets_[bucket].first = buckets_[bucket].last = iter++; } else if (++buckets_[bucket].last == iter) { ++iter; } else { values_.splice(buckets_[bucket].last, values_, iter++); --buckets_[bucket].last; } } }
// Insert a new entry into the map. std::pair<iterator, bool> insert(const value_type& v) { if (size_ + 1 >= num_buckets_) rehash(hash_size(size_ + 1)); size_t bucket = calculate_hash_value(v.first) % num_buckets_; iterator it = buckets_[bucket].first; if (it == values_.end()) { buckets_[bucket].first = buckets_[bucket].last = values_insert(values_.end(), v); ++size_; return std::pair<iterator, bool>(buckets_[bucket].last, true); } iterator end = buckets_[bucket].last; ++end; while (it != end) { if (it->first == v.first) return std::pair<iterator, bool>(it, false); ++it; } buckets_[bucket].last = values_insert(end, v); ++size_; return std::pair<iterator, bool>(buckets_[bucket].last, true); }
int saHpiWatchdogTable_modify_context( SaHpiWatchdogRecT *entry, SaHpiResourceIdT resource_id, SaHpiWatchdogT *wdog, oid *rdr_entry, size_t rdr_entry_oid_len, saHpiWatchdogTable_context *ctx) { long hash; // Make sure they are valid. if (entry && ctx) { // We are subtracting SaHpiTextBufferT b/c the underlaying HPI // library is not zeroing out the memory for not used entries - // thus garbage in SaHpiTextBufferT exist, hash = calculate_hash_value(entry, sizeof(SaHpiWatchdogRecT)); DEBUGMSGTL((AGENT," Hash value: %d, in ctx: %d\n", hash, ctx->hash)); if (ctx->hash != 0) { // Only do the check if the hash value is something else than zero. // 'zero' value is only for newly created records, and in some // rare instances when the hash has rolled to zero - in which // case we will just consider the worst-case scenario and update // the record and not trust the hash value. if (hash == ctx->hash) { // The same data. No need to change. return AGENT_ENTRY_EXIST; } } ctx->hash = hash; DEBUGMSGTL((AGENT,"Creating columns for: %d\n", entry->WatchdogNum)); ctx->saHpiWatchdogRDR_len = rdr_entry_oid_len * sizeof(oid); memcpy(ctx->saHpiWatchdogRDR, rdr_entry, ctx->saHpiWatchdogRDR_len); ctx->resource_id = resource_id; ctx->saHpiWatchdogNum = entry->WatchdogNum; ctx->saHpiWatchdogOem = entry->Oem; if (wdog) { ctx->saHpiWatchdogLog = (wdog->Log == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiWatchdogRunning = (wdog->Running == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiWatchdogTimerUse = wdog->TimerUse; ctx->saHpiWatchdogTimerAction = wdog->TimerAction; ctx->saHpiWatchdogPretimerInterrupt = wdog->PretimerInterrupt; ctx->saHpiWatchdogPreTimeoutInterval = wdog->PreTimeoutInterval; ctx->saHpiWatchdogTimerUseExpFlags = wdog->TimerUseExpFlags; ctx->saHpiWatchdogTimerInitialCount = wdog->InitialCount; ctx->saHpiWatchdogTimerPresentCount = wdog->PresentCount; } return AGENT_NEW_ENTRY; } return AGENT_ERR_NULL_DATA; }
// Find an entry in the map. iterator find(const K& k) { size_t bucket = calculate_hash_value(k) % num_buckets; iterator it = buckets_[bucket].first; if (it == values_.end()) return values_.end(); iterator end = buckets_[bucket].last; ++end; while (it != end) { if (it->first == k) return it; ++it; } return values_.end(); }
// Erase an entry from the map. void erase(iterator it) { assert(it != values_.end()); size_t bucket = calculate_hash_value(it->first) % num_buckets; bool is_first = (it == buckets_[bucket].first); bool is_last = (it == buckets_[bucket].last); if (is_first && is_last) buckets_[bucket].first = buckets_[bucket].last = values_.end(); else if (is_first) ++buckets_[bucket].first; else if (is_last) --buckets_[bucket].last; values_.erase(it); }
// Erase an entry from the map. void erase(iterator it) { ASIO_ASSERT(it != values_.end()); ASIO_ASSERT(num_buckets_ != 0); size_t bucket = calculate_hash_value(it->first) % num_buckets_; bool is_first = (it == buckets_[bucket].first); bool is_last = (it == buckets_[bucket].last); if (is_first && is_last) buckets_[bucket].first = buckets_[bucket].last = values_.end(); else if (is_first) ++buckets_[bucket].first; else if (is_last) --buckets_[bucket].last; values_erase(it); --size_; }
/// Find an entry in the map. bool find(const K& k, V& v) { if (mutexs_ == NULL) return false; size_t bucket_seat = calculate_hash_value(k) % num_buckets_; bucket_t& bucket = buckets_[bucket_seat]; // Use read lock for share read. read_lock_t lock(mutexs_[bucket_seat % num_mutexs_]); size_t bucket_size = bucket.size(); for (size_t i = 0; i < bucket_size; ++i) { if (bucket[i].first == k) { v = bucket[i].second; return true; } } return false; }
static int saHpiHotSwapTable_modify_context (SaHpiRptEntryT * rpt_entry, oid * rpt_oid, size_t rpt_oid_len, saHpiHotSwapTable_context * ctx) { unsigned int update_entry = MIB_FALSE; long hash = 0; int rc; SaHpiSessionIdT session_id; SaHpiHsIndicatorStateT indication_state; SaHpiHsPowerStateT power_state; SaHpiResetActionT reset_action; SaHpiHsStateT state; // These are 64-bite SaHpiTimeoutT insert_t; SaHpiTimeoutT extract_t; if (rpt_entry) { hash = calculate_hash_value (rpt_entry, sizeof (SaHpiRptEntryT) - sizeof (SaHpiTextBufferT)); } if (ctx) { if (ctx->hash != 0) { DEBUGMSGTL ((AGENT, "Updating HotSwap entry [%d, %d]\n", ctx->domain_id, ctx->resource_id)); update_entry = MIB_TRUE; } if (hash == 0) hash = 1; ctx->hash = hash; if (rpt_entry) { ctx->resource_id = rpt_entry->ResourceId; ctx->domain_id = rpt_entry->DomainId; ctx->saHpiHotSwapEventSeverity = rpt_entry->ResourceSeverity + 1; } // Get the seesion_id rc = getSaHpiSession (&session_id); if (rc != AGENT_ERR_NOERROR) { DEBUGMSGTL ((AGENT, "Call to getSaHpiSession failed with rc: %d\n", rc)); return rc; } // Indicator DEBUGMSGTL ((AGENT, "Calling saHpiHotSwapIndicatorStateGet with %d\n", ctx->resource_id)); rc = saHpiHotSwapIndicatorStateGet (session_id, ctx->resource_id, &indication_state); if (rc != SA_OK) { DEBUGMSGTL ((AGENT, "Call to saHpiHotSwapIndicatorStateGet failed with rc: %s\n", get_error_string (rc))); } else ctx->saHpiHotSwapIndicator = indication_state + 1; // PowerState DEBUGMSGTL ((AGENT, "Calling saHpiResourcePowerStateGet with %d\n", ctx->resource_id)); rc = saHpiResourcePowerStateGet (session_id, ctx->resource_id, &power_state); if (rc != SA_OK) { DEBUGMSGTL ((AGENT, "Call to saHpiResourcePowerStateGet failed with %s\n", get_error_string (rc))); } else ctx->saHpiHotSwapPowerState = power_state + 1; // ResetState DEBUGMSGTL ((AGENT, "Calling saHpiResourceResetStateGet with %d\n", ctx->resource_id)); rc = saHpiResourceResetStateGet (session_id, ctx->resource_id, &reset_action); if (rc != SA_OK) { DEBUGMSGTL ((AGENT, "Call to saHpiResourceResetStateGet failed with %s\n", get_error_string (rc))); } else ctx->saHpiHotSwapResetState = reset_action + 1; // State DEBUGMSGTL ((AGENT, "Calling saHpiHotSwapStateGet with %d\n", ctx->resource_id)); rc = saHpiHotSwapStateGet (session_id, ctx->resource_id, &state); if (rc != SA_OK) { DEBUGMSGTL ((AGENT, "Call to saHpiHotSwapStateGet failed with %s\n", get_error_string (rc))); } else { ctx->saHpiHotSwapState = state + 1; // We don't know the previous state? ctx->saHpiHotSwapPreviousState = 0; } // InsertTimeout DEBUGMSGTL ((AGENT, "Calling saHpiAutoInsertTimeoutGet \n")); rc = saHpiAutoInsertTimeoutGet (session_id, &insert_t); if (rc != SA_OK) { DEBUGMSGTL ((AGENT, "Call to saHpiAutoInsertTimeoutGet failed with %s\n", get_error_string (rc))); } else // IBM-KR: TODO, saHpiTimeT is 64bit, long is 32bit- // Should we make it 64-bit? Endian ctx->saHpiHotSwapInsertTimeout = insert_t; // Extract timeout DEBUGMSGTL ((AGENT, "Calling saHpiAutoExtractTimeoutGet with %d\n", ctx->resource_id)); rc = saHpiAutoExtractTimeoutGet (session_id, ctx->resource_id, &extract_t); if (rc != SA_OK) { DEBUGMSGTL ((AGENT, "Call to saHpiAutoExtractTimeoutGet failed with %s\n", get_error_string (rc))); } else { // IBM-KR: TODO, saHpiTimeT is 64bit, long is 32bit- // Should we make it 64-bit? Endian // ctx->saHpiHotSwapExtractTimeout = extract_t; } ctx->saHpiHotSwapActionRequest = 0; // Copy the RPT OID. if (rpt_oid) { ctx->saHpiHotSwapRTP_len = rpt_oid_len * sizeof (oid); memcpy (ctx->saHpiHotSwapRTP, rpt_oid, ctx->saHpiHotSwapRTP_len); } if (update_entry == MIB_TRUE) return AGENT_ENTRY_EXIST; return AGENT_NEW_ENTRY; } return AGENT_ERR_NULL_DATA; }
int modify_saHpiSensorThdPosHysteresisTable_row (SaHpiDomainIdT domain_id, SaHpiResourceIdT resource_id, SaHpiSensorNumT sensor_num, SaHpiSensorThdDefnT *threshold_def, SaHpiSensorReadingT * reading, saHpiSensorThdPosHysteresisTable_context * ctx) { long hash = 0; unsigned int update_entry = MIB_FALSE; // char format[SENSOR_THD_INTER_MAX]; DEBUGMSGTL ((AGENT, "Modify saHpiSensorThdPosHysteresisTable_ctx: Entry.\n")); if (ctx) { hash = calculate_hash_value (reading, sizeof (SaHpiSensorReadingT)); DEBUGMSGTL ((AGENT, " Hash value: %d, in ctx: %d\n", hash, ctx->hash)); if (ctx->hash != 0) { /* Only do the check if the hash value is something else than zero. * 'zero' value is only for newly created records, and in some * rare instances when the hash has rolled to zero - in which * case we will just consider the worst-case scenario and update * the record and not trust the hash value. */ if (hash == ctx->hash) { /* The same data. No need to change. */ return AGENT_ENTRY_EXIST; } if ((ctx->domain_id == domain_id) && (ctx->resource_id == resource_id) && (ctx->sensor_id == sensor_num)) { update_entry = MIB_TRUE; DEBUGMSGTL ((AGENT, "Posdating ThdPosHysteresisTable row [%d, %d, %d]\n", domain_id, resource_id, sensor_num)); } } if (hash == 0) /* Might happend - roll-over */ hash = 1; /* Need this - we consider hash * values of '0' uninitialized */ ctx->hash = hash; ctx->resource_id = resource_id; ctx->domain_id = domain_id; ctx->sensor_id = sensor_num; build_reading_strings (reading, 0, &ctx->saHpiSensorThdPosHysteresisValuesPresent, &ctx->saHpiSensorThdPosHysteresisRaw, ctx->saHpiSensorThdPosHysteresisInterpreted, &ctx->saHpiSensorThdPosHysteresisInterpreted_len, SENSOR_THD_INTER_MAX, NULL, NULL, NULL, 0); ctx->saHpiSensorThdPosHysteresisIsReadable = ((threshold_def->ReadThold & SAHPI_STM_UP_HYSTERESIS) == SAHPI_STM_UP_HYSTERESIS) ? MIB_TRUE : MIB_FALSE; ctx->saHpiSensorThdPosHysteresisIsWritable = ((threshold_def->WriteThold & SAHPI_STM_UP_HYSTERESIS) == SAHPI_STM_UP_HYSTERESIS) ? MIB_TRUE : MIB_FALSE; ctx->saHpiSensorThdPosHysteresisIsFixed = ((threshold_def->FixedThold & SAHPI_STM_UP_HYSTERESIS) == SAHPI_STM_UP_HYSTERESIS) ? MIB_TRUE : MIB_FALSE; /* END */ DEBUGMSGTL ((AGENT, "Modify saHpiSensorThdPosHysteresisTable_ctx: Exit")); if (update_entry == MIB_TRUE) return AGENT_ENTRY_EXIST; return AGENT_NEW_ENTRY; } DEBUGMSGTL ((AGENT, "Modify saHpiSensorThdPosHysteresisTable_ctx: Exit (NULL DATA)")); return AGENT_ERR_NULL_DATA; }
int saHpiRdrTable_modify_context (SaHpiRptEntryT * rpt_entry, SaHpiRdrT * entry, saHpiRdrTable_context * ctx, oid * rpt_oid, size_t rpt_oid_len, oid * child_oid, size_t child_oid_len, unsigned long child_id, trap_vars ** var, size_t * var_len, oid ** var_trap_oid) { unsigned int update_entry = MIB_FALSE; long hash; int len; // Make sure they are valid. if (entry && ctx) { // We are subtracting SaHpiTextBufferT b/c the underlaying HPI // library is not zeroing out the memory for not used entries - // thus garbage in SaHpiTextBufferT exist, hash = calculate_hash_value (entry, sizeof (SaHpiRdrTypeT) + sizeof (SaHpiEntityPathT) + sizeof (SaHpiEntryIdT)); DEBUGMSGTL ((AGENT, " Hash value: %d, in ctx: %d\n", hash, ctx->hash)); if (ctx->hash != 0) { // Only do the check if the hash value is something else than zero. // 'zero' value is only for newly created records, and in some // rare instances when the hash has rolled to zero - in which // case we will just consider the worst-case scenario and update // the record and not trust the hash value. if (hash == ctx->hash) { // The same data. No need to change. return AGENT_ENTRY_EXIST; } if ((ctx->domain_id == rpt_entry->DomainId) && (ctx->saHpiResourceID == rpt_entry->ResourceId) && (ctx->saHpiRdrRecordId == entry->RecordId) && (ctx->saHpiRdrType == entry->RdrType+1)) { update_entry = MIB_TRUE; DEBUGMSGTL((AGENT,"Updating RDR entry. [%d, %d, %d, %d]\n", rpt_entry->DomainId, rpt_entry->ResourceId, entry->RecordId, entry->RdrType+1)); } } if (hash == 0) hash = -1; ctx->hash = hash; ctx->domain_id = rpt_entry->DomainId; //ctx->child_id = child_id; ctx->saHpiResourceID = rpt_entry->ResourceId; ctx->saHpiRdrRecordId = entry->RecordId; ctx->saHpiRdrType = entry->RdrType+1; len = entitypath2string (&entry->Entity, ctx->saHpiRdrEntityPath, SNMP_MAX_MSG_SIZE); // Try to get it from rpt_entry. if (len == 0) { len = entitypath2string (&rpt_entry->ResourceEntity, ctx->saHpiRdrEntityPath, SNMP_MAX_MSG_SIZE); } if (len < 0) { // Bummer, EntityPath too long to fit in the SNMP_MAX_MSG_SIZE. len = 0; } DEBUGMSGTL ((AGENT, "EntityPath: %s\n", ctx->saHpiRdrEntityPath)); ctx->saHpiRdrEntityPath_len = len; ctx->saHpiRdr_len = child_oid_len * sizeof (oid); memcpy (ctx->saHpiRdr, child_oid, ctx->saHpiRdr_len); ctx->saHpiRdrRTP_len = rpt_oid_len * sizeof (oid); memcpy (ctx->saHpiRdrRTP, rpt_oid, ctx->saHpiRdrRTP_len); ctx->saHpiRdrId = child_id; // Fix the trap messages saHpiResourceDataRecordNotification[RDR_NOTIF_RDRRECORDID].value = (u_char *) & ctx->saHpiRdrRecordId; saHpiResourceDataRecordNotification[RDR_NOTIF_RDRRECORDID].value_len = sizeof (ctx->saHpiRdrRecordId); saHpiResourceDataRecordNotification[RDR_NOTIF_TYPE].value = (u_char *) & ctx->saHpiRdrType; saHpiResourceDataRecordNotification[RDR_NOTIF_TYPE].value_len = sizeof (ctx->saHpiRdrType); saHpiResourceDataRecordNotification[RDR_NOTIF_ENTITY_PATH].value = (u_char *) & ctx->saHpiRdrEntityPath; saHpiResourceDataRecordNotification[RDR_NOTIF_ENTITY_PATH].value_len = ctx->saHpiRdrEntityPath_len; saHpiResourceDataRecordNotification[RDR_NOTIF_RDR].value = (u_char *) & ctx->saHpiRdr; saHpiResourceDataRecordNotification[RDR_NOTIF_RDR].value_len = ctx->saHpiRdr_len; saHpiResourceDataRecordNotification[RDR_NOTIF_RDR_RTP].value = (u_char *) & ctx->saHpiRdrRTP; saHpiResourceDataRecordNotification[RDR_NOTIF_RDR_RTP].value_len = ctx->saHpiRdrRTP_len; // Point *var to this trap_vars. *var = (trap_vars *) & saHpiResourceDataRecordNotification; *var_len = RDR_NOTIF_COUNT; *var_trap_oid = (oid *) & saHpiResourceDataRecordNotification_oid; if (update_entry == MIB_TRUE) return AGENT_ENTRY_EXIST; return AGENT_NEW_ENTRY; } return AGENT_ERR_NULL_DATA; }
int modify_saHpiSensorReadingNominalTable_row (SaHpiDomainIdT domain_id, SaHpiResourceIdT resource_id, SaHpiSensorNumT sensor_num, SaHpiEventCategoryT sensor_category, SaHpiSensorReadingT * reading, saHpiSensorReadingNominalTable_context * ctx) { long hash = 0; unsigned int update_entry = MIB_FALSE; // char format[SENSOR_READING_INTER_MAX]; DEBUGMSGTL ((AGENT, "Modify saHpiSensorReadingNominalTable_ctx: Entry.\n")); if (ctx) { hash = calculate_hash_value (reading, sizeof (SaHpiSensorReadingT)); DEBUGMSGTL ((AGENT, " Hash value: %d, in ctx: %d\n", hash, ctx->hash)); if (ctx->hash != 0) { /* Only do the check if the hash value is something else than zero. * 'zero' value is only for newly created records, and in some * rare instances when the hash has rolled to zero - in which * case we will just consider the worst-case scenario and update * the record and not trust the hash value. */ if (hash == ctx->hash) { /* The same data. No need to change. */ return AGENT_ENTRY_EXIST; } if ((ctx->domain_id == domain_id) && (ctx->resource_id == resource_id) && (ctx->sensor_id == sensor_num)) { update_entry = MIB_TRUE; DEBUGMSGTL ((AGENT, "Updating ReadingNominalTable row [%d, %d, %d]\n", domain_id, resource_id, sensor_num)); } } if (hash == 0) /* Might happend - roll-over */ hash = 1; /* Need this - we consider hash * values of '0' uninitialized */ ctx->hash = hash; ctx->resource_id = resource_id; ctx->domain_id = domain_id; ctx->sensor_id = sensor_num; build_reading_strings (reading, sensor_category, &ctx->saHpiSensorReadingNominalValuesPresent, &ctx->saHpiSensorReadingNominalRaw, ctx->saHpiSensorReadingNominalInterpreted, &ctx->saHpiSensorReadingNominalInterpreted_len, SENSOR_READING_INTER_MAX, &ctx->saHpiSensorReadingNominalStatus, ctx->saHpiSensorReadingNominalEventStatus, &ctx->saHpiSensorReadingNominalEventStatus_len, SENSOR_READING_EVENT_MAX); /* END */ DEBUGMSGTL ((AGENT, "Modify saHpiSensorReadingNominalTable_ctx: Exit")); if (update_entry == MIB_TRUE) return AGENT_ENTRY_EXIST; return AGENT_NEW_ENTRY; } DEBUGMSGTL ((AGENT, "Modify saHpiSensorReadingNominalTable_ctx: Exit (NULL DATA)")); return AGENT_ERR_NULL_DATA; }
int saHpiSensorTable_modify_context (SaHpiEntryIdT rdr_id, SaHpiSensorRecT * entry, SaHpiSensorEvtEnablesT * enables, SaHpiRptEntryT * rpt_entry, oid * rdr_entry, size_t rdr_entry_oid_len, saHpiSensorTable_context * ctx) { unsigned int update_entry = MIB_FALSE; long hash; int i, len; SaHpiSensorDataFormatT data; // Make sure they are valid. if (entry && ctx) { hash = calculate_hash_value (entry, sizeof (SaHpiSensorRecT)); DEBUGMSGTL ((AGENT, " Hash value: %d, in ctx: %d\n", hash, ctx->hash)); if (ctx->hash != 0) { // Only do the check if the hash value is something else than zero. // 'zero' value is only for newly created records, and in some // rare instances when the hash has rolled to zero - in which // case we will just consider the worst-case scenario and update // the record and not trust the hash value. if (hash == ctx->hash) { // The same data. No need to change. return AGENT_ENTRY_EXIST; } if (((ctx->domain_id == rpt_entry->DomainId) && (ctx->resource_id == rpt_entry->ResourceId) && (ctx->saHpiSensorIndex == entry->Num)) || (ctx->rdr_id == rdr_id)) { update_entry = MIB_TRUE; DEBUGMSGTL ((AGENT, "Updating sensor entry. [%d, %d, %d]\n", rpt_entry->DomainId, rpt_entry->ResourceId, entry->Num)); } } if (hash == 0) // Might happend - roll-over hash = 1; // Need this - we consider hash values of '0' uninitialized ctx->hash = hash; data = entry->DataFormat; ctx->flags = data.Range.Flags; ctx->saHpiSensorRDR_len = rdr_entry_oid_len * sizeof (oid); memcpy (ctx->saHpiSensorRDR, rdr_entry, ctx->saHpiSensorRDR_len); ctx->saHpiSensorIndex = entry->Num; ctx->saHpiSensorType = entry->Type + 1; ctx->saHpiSensorCategory = entry->Category + 1; ctx->saHpiSensorHasThresholds = (entry->ThresholdDefn.IsThreshold == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiSensorThresholdCapabilities = entry->ThresholdDefn.TholdCapabilities + 1; // DOAMIN ctx->domain_id = rpt_entry->DomainId; ctx->resource_id = rpt_entry->ResourceId; ctx->rdr_id = rdr_id; // IBM-KR: Adding +1 ctx->saHpiSensorEventsCategoryControl = entry->EventCtrl + 1; /* * Generate a string representation of the state */ build_state_string (entry->Category, entry->Events, (char *) &ctx->saHpiSensorEventsSupported, &ctx->saHpiSensorEventsSupported_len, SENSOR_EVENTS_SUPPORTED_MAX); /* * No need to update a sensor that does not support * events. */ if (entry->EventCtrl != SAHPI_SEC_NO_EVENTS) { ctx->saHpiSensorStatus = enables->SensorStatus; build_state_string (entry->Category, enables->AssertEvents, (char *) &ctx->saHpiSensorAssertEvents, &ctx->saHpiSensorAssertEvents_len, SENSOR_EVENTS_SUPPORTED_MAX); build_state_string (entry->Category, enables->DeassertEvents, (char *) &ctx->saHpiSensorDeassertEvents, &ctx->saHpiSensorDeassertEvents_len, SENSOR_EVENTS_SUPPORTED_MAX); } ctx->saHpiSensorIgnore = (entry->Ignore == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiSensorReadingFormats = data.ReadingFormats; ctx->saHpiSensorIsNumeric = (data.IsNumeric == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiSensorSignFormat = data.SignFormat + 1; ctx->saHpiSensorBaseUnits = data.BaseUnits + 1; ctx->saHpiSensorModifierUnits = data.ModifierUnits + 1; ctx->saHpiSensorModifierUse = data.ModifierUse + 1; ctx->saHpiSensorFactorsStatic = (data.FactorsStatic == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; // Sensor factors. memset (ctx->saHpiSensorFactors, 0x00, SAHPISENSORFACTORS_MAX); // Normalize data. data.Factors.M_Factor = htons (data.Factors.M_Factor); data.Factors.B_Factor = htons (data.Factors.B_Factor); data.Factors.AccuracyFactor = htons (data.Factors.AccuracyFactor); memcpy (ctx->saHpiSensorFactors, &data.Factors.M_Factor, sizeof (SaHpiInt16T)); memcpy (ctx->saHpiSensorFactors + sizeof (SaHpiInt16T), &data.Factors.B_Factor, sizeof (SaHpiInt16T)); memcpy (ctx->saHpiSensorFactors + (sizeof (SaHpiInt16T) * 2), &data.Factors.AccuracyFactor, sizeof (SaHpiUint16T)); ctx->saHpiSensorFactors[6] = data.Factors.ToleranceFactor; ctx->saHpiSensorFactors[7] = data.Factors.ExpA; ctx->saHpiSensorFactors[8] = data.Factors.ExpR; ctx->saHpiSensorFactors[9] = data.Factors.ExpB; ctx->saHpiSensorFactors_len = SAHPISENSORFACTORS_MAX; ctx->saHpiSensorFactorsLinearization = data.Factors.Linearization + 1; ctx->saHpiSensorPercentage = (data.Percentage == SAHPI_TRUE) ? MIB_TRUE : MIB_FALSE; ctx->saHpiSensorOEM = entry->Oem; ctx->saHpiSensorRangeFlags_len = 0; for (i = 0; i < RANGE_FLAGS_LEN; i++) { if ((data.Range.Flags & range_flags[i].flag) == range_flags[i].flag) { len = strlen (range_flags[i].str); if (len + ctx->saHpiSensorRangeFlags_len > SENSOR_RANGE_FLAGS_MAX) break; memcpy (ctx->saHpiSensorRangeFlags + ctx->saHpiSensorRangeFlags_len, range_flags[i].str, len); ctx->saHpiSensorRangeFlags_len = ctx->saHpiSensorRangeFlags_len + len; } } ctx->saHpiSensorRangeFlags_len -= 2; if (update_entry == MIB_TRUE) return AGENT_ENTRY_EXIST; return AGENT_NEW_ENTRY; } return AGENT_ERR_NULL_DATA; }