2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * Update types: single-index and all are mutually exclusive; a count 2N/A * update is optional. 2N/A * If fmri is the fmri of a resource we have previously seen and indexed, return 2N/A * data for it. Otherwise, return NULL. Note that the resource may not be 2N/A * valid; that is, it may have been removed from the fault manager since its 2N/A * information was last updated. 2N/A * If index corresponds to a resource we have previously seen and indexed, 2N/A * return data for it. Otherwise, return NULL. Note that the resource may 2N/A * not be valid; that is, it may have been expired from the fault manager 2N/A * since its information was last updated. 2N/A * If index corresponds to a valid (that is, extant as of latest information 2N/A * from the fault manager) resource, return the data for that resource. 2N/A * Otherwise, return the data for the valid resource whose index is as close as 2N/A * possible to index but not lower. This preserves the lexicographical 2N/A * ordering required for GETNEXT processing. 2N/A * Possible update the contents of a single resource within the cache. This 2N/A * is our callback from fmd_rsrc_iter. 2N/A * A resource we haven't seen before. We're obligated to index 2N/A * it and link it into our cache so that we can find it, but we're 2N/A * not obligated to fill it in completely unless we're doing a 2N/A * full update or this is the resource we were asked for. This 2N/A * avoids unnecessary iteration and memory manipulation for data 2N/A * we're not going to return for this request. 2N/A * We allocate indices sequentially and never reuse them. 2N/A * This ensures we can always return valid GETNEXT responses 2N/A * without having to reindex, and it provides the user a 2N/A * more consistent view of the fault manager. 2N/A * Update some or all resource data from fmd. If type includes UCT_ALL, all 2N/A * resources will be indexed and their data cached. If type includes 2N/A * UCT_INDEX, updates will stop once the resource matching index has been 2N/A * updated. If UCT_COUNT is set, the number of faulted resources will be 2N/A * Returns appropriate SNMP error codes. 2N/A * The current rsrcinfo_update implementation offers minimal savings 2N/A * for the use of index-only updates; therefore we always do a full 2N/A * update. If it becomes advantageous to limit updates to a single 2N/A * index, the contexts can be queued by the handler instead. 2N/A * The Net-SNMP template uses add_indexes here, but that 2N/A * function is unsafe because it does not check for failure. 2N/A * There's no way to unregister the table handler, so we 2N/A * can't free any of the data, either. 2N/A * only kind we do). They perform two functions: 2N/A * - First, frob the request to set all the index variables to correspond 2N/A * to the value that's going to be returned. For GET, this is a nop; 2N/A * - Second, find and return the fmd resource information corresponding to 2N/A * the (possibly updated) indices. 2N/A * These should be as fast as possible; they run in the agent thread. 2N/A * If we have no index, we must make one. 2N/A "index %lu; trying next column\n",
index));
2N/A * table_info->colnum contains the column number requested. 2N/A * table_info->indexes contains a linked list of snmp variable 2N/A * bindings for the indexes of the table. Values in the list 2N/A * have been set corresponding to the indexes of the 2N/A * request. We have other guarantees as well: 2N/A * - The column number is always within range. 2N/A * - If we have no index data, table_info->index_oid_len is 0. 2N/A * - We will never receive requests outside our table nor 2N/A * those with the first subid anything other than 1 (Entry) 2N/A * nor those without a column number. This is true even 2N/A * for GETNEXT requests. 2N/A * According to the documentation, it's not possible for us ever to 2N/A * be called with MODE_GETNEXT. However, Net-SNMP does the following: 2N/A * - set reqinfo->mode to MODE_GET 2N/A * - invoke the handler 2N/A * - set reqinfo->mode to MODE_GETNEXT (even if the request was not 2N/A * actually processed; i.e. it's been delegated) 2N/A * Since we're called back later with the same reqinfo, we see 2N/A * GETNEXT. Therefore this case is needed to work around the 2N/A * We are never called for a GETNEXT when registered as an 2N/A * instance; it's handled for us and converted to a GET. 2N/A * Also, an instance handler is given only one request at a time, so 2N/A * we don't need to loop over a list of requests.