static void broadcast_changes(datamap *map, HWND dialog, windows_options *opts, datamap_entry *entry, const char *option_name) { HWND other_control; const char *that_option_name; int i; for (i = 0; i < map->entry_count; i++) { // search for an entry with the same option_name, but is not the exact // same entry that_option_name = map->entries[i].option_name; if (map->entries[i].option_name && (&map->entries[i] != entry) && !strcmp(that_option_name, option_name)) { // we've found a control sharing the same option; populate it other_control = GetDlgItem(dialog, map->entries[i].dlgitem); if (other_control != NULL) populate_control(map, other_control, opts, &map->entries[i], that_option_name); } } }
/* * Populates up to FIVE different rows: * - RDR * - Sensor * - Inventory * - Control * - Watchdog */ int populate_rdr (SaHpiRptEntryT * rpt_entry, oid * rpt_oid, size_t rpt_oid_len, oid * resource_oid, size_t resource_oid_len) { SaErrorT err; SaHpiEntryIdT current_rdr; SaHpiEntryIdT next_rdr; SaHpiRdrT rdr_entry; SaHpiSessionIdT session_id; long backup_count = rdr_count; int rc = AGENT_ERR_NOERROR; oid rdr_oid[RDR_INDEX_NR]; oid full_oid[MAX_OID_LEN]; oid child_oid[MAX_OID_LEN]; size_t child_oid_len; oid column[2]; int column_len = 2; int full_oid_len; unsigned long child_id = 0xDEADBEEF; netsnmp_index rdr_index; saHpiRdrTable_context *rdr_context; oid *trap_oid; trap_vars *trap = NULL; size_t trap_len; netsnmp_variable_list *trap_var; DEBUGMSGTL ((AGENT, "\n\t--- populate_rdr: Entry.\n")); if ((rc = getSaHpiSession (&session_id)) == AGENT_ERR_NOERROR) { rdr_index.len = RDR_INDEX_NR; next_rdr = SAHPI_FIRST_ENTRY; do { current_rdr = next_rdr; memset (&rdr_entry, 0x00, sizeof (SaHpiRdrT)); err = saHpiRdrGet (session_id, rpt_entry->ResourceId, current_rdr, &next_rdr, &rdr_entry); if (err == SA_OK) { rdr_mutex = AGENT_TRUE; // Look at the MIB to find out what the indexs are rdr_oid[0] = rpt_entry->DomainId; rdr_oid[1] = rpt_entry->ResourceId; rdr_oid[2] = rdr_entry.RecordId; // The type is +1 from the SAF HPI SA spec rdr_oid[3] = rdr_entry.RdrType+1; rdr_index.oids = (oid *) & rdr_oid; if (backup_count == 0) { rdr_context = saHpiRdrTable_create_row (&rdr_index); rdr_new_entry_count++; } else { // See if it exists. rdr_context = NULL; rdr_context = CONTAINER_FIND (cb.container, &rdr_index); // If we don't find it - we create it. if (!rdr_context) { // New entry. Add it rdr_context = saHpiRdrTable_create_row (&rdr_index); rdr_new_entry_count++; } if (!rdr_context) { snmp_log (LOG_ERR, "Not enough memory for a RDR row!"); return AGENT_ERR_INTERNAL_ERROR; } } column[0] = 1; column[1] = COLUMN_SAHPIRDRRESOURCEID; build_full_oid (saHpiRdrTable_oid, saHpiRdrTable_oid_len, column, column_len, &rdr_index, full_oid, MAX_OID_LEN, &full_oid_len); child_oid_len = 0; if (rdr_entry.RdrType == SAHPI_SENSOR_RDR) { child_id = rdr_entry.RdrTypeUnion.SensorRec.Num; DEBUGMSGTL ((AGENT, "Calling populate_sensor; RPT: %d, RDR: %d, SensorRec.Num: %d\n", rpt_entry->ResourceId, rdr_entry.RecordId, child_id)); rc = populate_sensor (rdr_entry.RecordId, &rdr_entry.RdrTypeUnion.SensorRec, rpt_entry, full_oid, full_oid_len, child_oid, &child_oid_len); DEBUGMSGTL ((AGENT, "Called populate_sensor(); rc: %d\n", rc)); } if (rdr_entry.RdrType == SAHPI_CTRL_RDR) { child_id = rdr_entry.RdrTypeUnion.CtrlRec.Num; DEBUGMSGTL ((AGENT, "Calling populate_control; RPT: %d, RDR: %d, CtrlRec.Num: %d\n", rpt_entry->ResourceId, rdr_entry.RecordId, child_id)); rc = populate_control (rdr_entry.RecordId,&rdr_entry.RdrTypeUnion.CtrlRec, rpt_entry, full_oid, full_oid_len, child_oid, &child_oid_len); DEBUGMSGTL ((AGENT, "Called populate_control(); rc: %d\n", rc)); } if (rdr_entry.RdrType == SAHPI_INVENTORY_RDR) { child_id = rdr_entry.RdrTypeUnion.InventoryRec.EirId; DEBUGMSGTL ((AGENT, "Calling populate_inventory; RPT: %d, RDR: %d, InventoryRec.EirId: %d\n", rpt_entry->ResourceId, rdr_entry.RecordId, child_id)); rc = populate_inventory (rdr_entry.RecordId,&rdr_entry.RdrTypeUnion.InventoryRec, rpt_entry, full_oid, full_oid_len, child_oid, &child_oid_len); DEBUGMSGTL ((AGENT, "Called populate_inventory(); rc: %d\n", rc)); } if (rdr_entry.RdrType == SAHPI_WATCHDOG_RDR) { child_id = rdr_entry.RdrTypeUnion.WatchdogRec.WatchdogNum; DEBUGMSGTL ((AGENT, "Calling populate_watchdog; RPT: %d, RDR: %d, CtrlRec.Num: %d\n", rpt_entry->ResourceId, rdr_entry.RecordId, child_id)); rc = populate_watchdog (rdr_entry.RecordId,&rdr_entry.RdrTypeUnion.WatchdogRec, rpt_entry, full_oid, full_oid_len, child_oid, &child_oid_len); DEBUGMSGTL ((AGENT, "Called populate_watchdog(); rc: %d\n", rc)); } // Mark this ctx as touched, or cleaned rdr_context->dirty_bit = AGENT_FALSE; // By this stage, rdr_context surely has something in it. // '*_modify_context' does a checksum check to see if // the record needs to be altered, and if so populates with // information from RDR and the OIDs passed. if (saHpiRdrTable_modify_context (rpt_entry, &rdr_entry, rdr_context, rpt_oid, rpt_oid_len, child_oid, child_oid_len, child_id, &trap, &trap_len, &trap_oid) == AGENT_NEW_ENTRY) { CONTAINER_INSERT (cb.container, rdr_context); rdr_count = CONTAINER_SIZE (cb.container); if (send_traps == AGENT_TRUE) { if (trap != NULL) { trap_var = build_notification (&rdr_index, trap, trap_len, saHpiResourceDataRecordNotification_oid, OID_LENGTH (saHpiResourceDataRecordNotification_oid), saHpiRdrTable_oid, saHpiRdrTable_oid_len, rpt_entry->DomainId, rpt_oid, rpt_oid_len, rpt_entry-> ResourceId, resource_oid, resource_oid_len); if (trap_var != NULL) { // Add some more (entryCount, and entryUpdate) snmp_varlist_add_variable (&trap_var, saHpiRdrCount_oid, OID_LENGTH (saHpiRdrCount_oid), ASN_COUNTER, (u_char *) & rdr_count, sizeof (rdr_count)); DEBUGMSGTL ((AGENT, "Sending RDR TRAP/EVENT\n")); send_v2trap (trap_var); snmp_free_varbind (trap_var); } else { snmp_log (LOG_WARNING, "Could not build a RDR TRAP/EVENT message.\n"); rc = AGENT_ERR_BUILD_TRAP; } } } } } else { // Bail out. // This can happend if there are no entries for that Resource rc = AGENT_ERR_OPERATION; break; } } while (next_rdr != SAHPI_LAST_ENTRY); } DEBUGMSGTL ((AGENT, "\n\t--- populate_rdr. Exit\n")); return rc; }