/** * the *_extract_index routine * * This routine is called when a set request is received for an index * that was not found in the table container. Here, we parse the oid * in the the individual index components and copy those indexes to the * context. Then we make sure the indexes for the new row are valid. */ int saHpiAutoInsertTimeoutTable_extract_index( saHpiAutoInsertTimeoutTable_context * ctx, netsnmp_index * hdr ) { /* * temporary local storage for extracting oid index * * extract index uses varbinds (netsnmp_variable_list) to parse * the index OID into the individual components for each index part. */ /** TODO: add storage for external index(s)! */ netsnmp_variable_list var_saHpiDomainId; int err; /* * copy index, if provided */ if(hdr) { netsnmp_assert(ctx->index.oids == NULL); if(snmp_clone_mem( (void*)&ctx->index.oids, hdr->oids, hdr->len * sizeof(oid) )) { return -1; } ctx->index.len = hdr->len; } /* * initialize variable that will hold each component of the index. * If there are multiple indexes for the table, the variable_lists * need to be linked together, in order. */ /** TODO: add code for external index(s)! */ memset( &var_saHpiDomainId, 0x00, sizeof(var_saHpiDomainId) ); var_saHpiDomainId.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */ /** TODO: link this index to the next, or NULL for the last one */ var_saHpiDomainId.next_variable = NULL; /* * parse the oid into the individual index components */ err = parse_oid_indexes( hdr->oids, hdr->len, &var_saHpiDomainId ); if (err == SNMP_ERR_NOERROR) { /* * copy index components into the context structure */ /** skipping external index saHpiDomainId */ /** skipping external index saHpiResourceId */ /** skipping external index saHpiResourceIsHistorical */ err = saHpiDomainId_check_index(*var_saHpiDomainId.val.integer); } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_saHpiDomainId ); return err; }
/* * the *_extract_index routine. (Mostly auto-generated) * * This routine is called when a set request is received for an index * that was not found in the table container. Here, we parse the oid * in the individual index components and copy those indexes to the * context. Then we make sure the indexes for the new row are valid. * * It has been modified from its original form in that if the indexes are * invalid, then they aren't returned. An index is invalid if: * * 1) It is < 1 * 2) It doesn't match the global userLookupIndex. (As per MIB specs) * */ int openserSIPRegUserLookupTable_extract_index( openserSIPRegUserLookupTable_context * ctx, netsnmp_index * hdr) { /* * temporary local storage for extracting oid index * * extract index uses varbinds (netsnmp_variable_list) to parse * the index OID into the individual components for each index part. */ netsnmp_variable_list var_openserSIPRegUserLookupIndex; int err; /* copy index, if provided */ if(hdr) { netsnmp_assert(ctx->index.oids == NULL); if((hdr->len > MAX_OID_LEN) || snmp_clone_mem( (void*)&ctx->index.oids, hdr->oids, hdr->len * sizeof(oid) )) { return -1; } ctx->index.len = hdr->len; } /* Set up the index */ memset(&var_openserSIPRegUserLookupIndex, 0x00, sizeof(var_openserSIPRegUserLookupIndex)); var_openserSIPRegUserLookupIndex.type = ASN_UNSIGNED; var_openserSIPRegUserLookupIndex.next_variable = NULL; /* parse the oid into the individual index components */ err = parse_oid_indexes( hdr->oids, hdr->len, &var_openserSIPRegUserLookupIndex ); if (err == SNMP_ERR_NOERROR) { /* copy index components into the context structure */ ctx->openserSIPRegUserLookupIndex = *var_openserSIPRegUserLookupIndex.val.integer; /* * Check to make sure that the index corresponds to the * global_userLookupCounter, as per the MIB specifications. */ if (*var_openserSIPRegUserLookupIndex.val.integer != global_UserLookupCounter || *var_openserSIPRegUserLookupIndex.val.integer < 1) { err = -1; } } /* parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_openserSIPRegUserLookupIndex ); return err; }
/* * the *_extract_index routine */ int saHpiSensorTable_extract_index (saHpiSensorTable_context * ctx, netsnmp_index * hdr) { /* * temporary local storage for extracting oid index */ netsnmp_variable_list var_saHpiDomainID; netsnmp_variable_list var_saHpiResourceID; netsnmp_variable_list var_saHpiSensorIndex; int err; /* * copy index, if provided */ if (hdr) { netsnmp_assert (ctx->index.oids == NULL); if (snmp_clone_mem ((void *) &ctx->index.oids, hdr->oids, hdr->len * sizeof (oid))) { return -1; } ctx->index.len = hdr->len; } /** * Create variable to hold each component of the index */ memset (&var_saHpiDomainID, 0x00, sizeof (var_saHpiDomainID)); var_saHpiDomainID.type = ASN_UNSIGNED; var_saHpiDomainID.next_variable = &var_saHpiResourceID; memset (&var_saHpiResourceID, 0x00, sizeof (var_saHpiResourceID)); var_saHpiResourceID.type = ASN_UNSIGNED; var_saHpiResourceID.next_variable = &var_saHpiSensorIndex; memset (&var_saHpiSensorIndex, 0x00, sizeof (var_saHpiSensorIndex)); var_saHpiSensorIndex.type = ASN_UNSIGNED; var_saHpiSensorIndex.next_variable = NULL; /* * parse the oid into the individual components */ err = parse_oid_indexes (hdr->oids, hdr->len, &var_saHpiDomainID); if (err == SNMP_ERR_NOERROR) { ctx->saHpiSensorIndex = *var_saHpiSensorIndex.val.integer; } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers (&var_saHpiDomainID); return err; }
/** * extract dot11WtpDataPktsTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int dot11WtpDataPktsTable_index_from_oid(netsnmp_index *oid_idx, dot11WtpDataPktsTable_mib_index *mib_idx) { int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * wtpMacAddr(1)/Dot11BaseWtpIdTC/ASN_OCTET_STR/char(char)//L/A/w/e/r/d/h */ netsnmp_variable_list var_wtpMacAddr; /* * set up varbinds */ memset( &var_wtpMacAddr, 0x00, sizeof(var_wtpMacAddr) ); var_wtpMacAddr.type = ASN_OCTET_STR; /* * chain temp index varbinds together */ var_wtpMacAddr.next_variable = NULL; DEBUGMSGTL(("verbose:dot11WtpDataPktsTable:dot11WtpDataPktsTable_index_from_oid","called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes( oid_idx->oids, oid_idx->len, &var_wtpMacAddr ); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ /* * NOTE: val_len is in bytes, wtpMacAddr_len might not be */ if(var_wtpMacAddr.val_len > sizeof(mib_idx->wtpMacAddr)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->wtpMacAddr, var_wtpMacAddr.val.string, var_wtpMacAddr.val_len); mib_idx->wtpMacAddr_len = var_wtpMacAddr.val_len / sizeof(mib_idx->wtpMacAddr[0]); } } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_wtpMacAddr ); return err; } /* dot11WtpDataPktsTable_index_from_oid */
/** * extract ipv6ScopeZoneIndexTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int ipv6ScopeZoneIndexTable_index_from_oid(netsnmp_index * oid_idx, ipv6ScopeZoneIndexTable_mib_index * mib_idx) { int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * ipv6ScopeZoneIndexIfIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H */ netsnmp_variable_list var_ipv6ScopeZoneIndexIfIndex; /* * set up varbinds */ memset(&var_ipv6ScopeZoneIndexIfIndex, 0x00, sizeof(var_ipv6ScopeZoneIndexIfIndex)); var_ipv6ScopeZoneIndexIfIndex.type = ASN_INTEGER; /* * chain temp index varbinds together */ var_ipv6ScopeZoneIndexIfIndex.next_variable = NULL; DEBUGMSGTL(("verbose:ipv6ScopeZoneIndexTable:ipv6ScopeZoneIndexTable_index_from_oid", "called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes(oid_idx->oids, oid_idx->len, &var_ipv6ScopeZoneIndexIfIndex); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ mib_idx->ipv6ScopeZoneIndexIfIndex = *((long *) var_ipv6ScopeZoneIndexIfIndex.val.string); } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_ipv6ScopeZoneIndexIfIndex); return err; } /* ipv6ScopeZoneIndexTable_index_from_oid */
/** * extract dot11SsidTeminalTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int dot11SsidTeminalTable_index_from_oid(netsnmp_index *oid_idx, dot11SsidTeminalTable_mib_index *mib_idx) { int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * wlanCurrID(1)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ netsnmp_variable_list var_wlanCurrID; /* * set up varbinds */ memset( &var_wlanCurrID, 0x00, sizeof(var_wlanCurrID) ); var_wlanCurrID.type = ASN_INTEGER; /* * chain temp index varbinds together */ var_wlanCurrID.next_variable = NULL; DEBUGMSGTL(("verbose:dot11SsidTeminalTable:dot11SsidTeminalTable_index_from_oid","called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes( oid_idx->oids, oid_idx->len, &var_wlanCurrID ); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ mib_idx->wlanCurrID = *((long *)var_wlanCurrID.val.string); } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_wlanCurrID ); return err; } /* dot11SsidTeminalTable_index_from_oid */
/** * the *_extract_index routine * * This routine is called when a set request is received for an index * that was not found in the table container. Here, we parse the oid * in the the individual index components and copy those indexes to the * context. Then we make sure the indexes for the new row are valid. */ int saHpiHotSwapTable_extract_index( saHpiHotSwapTable_context * ctx, netsnmp_index * hdr ) { /* * temporary local storage for extracting oid index * * extract index uses varbinds (netsnmp_variable_list) to parse * the index OID into the individual components for each index part. */ /** TODO: add storage for external index(s)! */ netsnmp_variable_list var_saHpiDomainId; netsnmp_variable_list var_saHpiResourceId; netsnmp_variable_list var_saHpiResourceIsHistorical; int err; /* * copy index, if provided */ if(hdr) { netsnmp_assert(ctx->index.oids == NULL); if(snmp_clone_mem( (void*)&ctx->index.oids, hdr->oids, hdr->len * sizeof(oid) )) { return -1; } ctx->index.len = hdr->len; } /* * initialize variable that will hold each component of the index. * If there are multiple indexes for the table, the variable_lists * need to be linked together, in order. */ /** TODO: add code for external index(s)! */ memset( &var_saHpiDomainId, 0x00, sizeof(var_saHpiDomainId) ); var_saHpiDomainId.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */ /** TODO: link this index to the next, or NULL for the last one */ #ifdef TABLE_CONTAINER_TODO snmp_log(LOG_ERR, "saHpiHotSwapTable_extract_index index list not implemented!\n" ); return 0; #else var_saHpiDomainId.next_variable = &var_XX; #endif memset( &var_saHpiResourceId, 0x00, sizeof(var_saHpiResourceId) ); var_saHpiResourceId.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */ /** TODO: link this index to the next, or NULL for the last one */ #ifdef TABLE_CONTAINER_TODO snmp_log(LOG_ERR, "saHpiHotSwapTable_extract_index index list not implemented!\n" ); return 0; #else var_saHpiResourceId.next_variable = &var_XX; #endif memset( &var_saHpiResourceIsHistorical, 0x00, sizeof(var_saHpiResourceIsHistorical) ); var_saHpiResourceIsHistorical.type = ASN_INTEGER; /* type hint for parse_oid_indexes */ /** TODO: link this index to the next, or NULL for the last one */ #ifdef TABLE_CONTAINER_TODO snmp_log(LOG_ERR, "saHpiHotSwapTable_extract_index index list not implemented!\n" ); return 0; #else var_saHpiResourceIsHistorical.next_variable = &var_XX; #endif /* * parse the oid into the individual index components */ err = parse_oid_indexes( hdr->oids, hdr->len, &var_saHpiDomainId ); if (err == SNMP_ERR_NOERROR) { /* * copy index components into the context structure */ /** skipping external index saHpiDomainId */ /** skipping external index saHpiResourceId */ /** skipping external index saHpiResourceIsHistorical */ /* * TODO: check index for valid values. For EXAMPLE: * * if ( *var_saHpiDomainId.val.integer != XXX ) { * err = -1; * } */ /* * TODO: check index for valid values. For EXAMPLE: * * if ( *var_saHpiResourceId.val.integer != XXX ) { * err = -1; * } */ /* * TODO: check index for valid values. For EXAMPLE: * * if ( *var_saHpiResourceIsHistorical.val.integer != XXX ) { * err = -1; * } */ } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_saHpiDomainId ); return err; }
/** * extract ipDefaultRouterTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int ipDefaultRouterTable_index_from_oid(netsnmp_index * oid_idx, ipDefaultRouterTable_mib_index * mib_idx) { int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * ipDefaultRouterAddressType(1)/InetAddressType/ASN_INTEGER/long(u_long)//l/a/w/E/r/d/h */ netsnmp_variable_list var_ipDefaultRouterAddressType; /* * ipDefaultRouterAddress(2)/InetAddress/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ netsnmp_variable_list var_ipDefaultRouterAddress; /* * ipDefaultRouterIfIndex(3)/InterfaceIndex/ASN_INTEGER/long(long)//l/a/w/e/R/d/H */ netsnmp_variable_list var_ipDefaultRouterIfIndex; /* * set up varbinds */ memset(&var_ipDefaultRouterAddressType, 0x00, sizeof(var_ipDefaultRouterAddressType)); var_ipDefaultRouterAddressType.type = ASN_INTEGER; memset(&var_ipDefaultRouterAddress, 0x00, sizeof(var_ipDefaultRouterAddress)); var_ipDefaultRouterAddress.type = ASN_OCTET_STR; memset(&var_ipDefaultRouterIfIndex, 0x00, sizeof(var_ipDefaultRouterIfIndex)); var_ipDefaultRouterIfIndex.type = ASN_INTEGER; /* * chain temp index varbinds together */ var_ipDefaultRouterAddressType.next_variable = &var_ipDefaultRouterAddress; var_ipDefaultRouterAddress.next_variable = &var_ipDefaultRouterIfIndex; var_ipDefaultRouterIfIndex.next_variable = NULL; DEBUGMSGTL(("verbose:ipDefaultRouterTable:ipDefaultRouterTable_index_from_oid", "called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes(oid_idx->oids, oid_idx->len, &var_ipDefaultRouterAddressType); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ mib_idx->ipDefaultRouterAddressType = *((u_long *) var_ipDefaultRouterAddressType.val.string); /* * NOTE: val_len is in bytes, ipDefaultRouterAddress_len might not be */ if (var_ipDefaultRouterAddress.val_len > sizeof(mib_idx->ipDefaultRouterAddress)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->ipDefaultRouterAddress, var_ipDefaultRouterAddress.val.string, var_ipDefaultRouterAddress.val_len); mib_idx->ipDefaultRouterAddress_len = var_ipDefaultRouterAddress.val_len / sizeof(mib_idx->ipDefaultRouterAddress[0]); } mib_idx->ipDefaultRouterIfIndex = *((long *) var_ipDefaultRouterIfIndex.val.string); } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_ipDefaultRouterAddressType); return err; } /* ipDefaultRouterTable_index_from_oid */
/* * the *_extract_index routine (Mostly auto-generated) * * This routine is called when a set request is received for an index that * was not found in the table container. Here, we parse the oid in the * individual index components and copy those indexes to the context. Then * we make sure the indexes for the new row are valid. * * It has been modified from its original form in that the indexes aren't * returned if they are invalid. An index is invalid if it is not between * 100 and 699 (Inclusive). */ int openserSIPStatusCodesTable_extract_index( openserSIPStatusCodesTable_context * ctx, netsnmp_index * hdr) { /* * temporary local storage for extracting oid index * * extract index uses varbinds (netsnmp_variable_list) to parse * the index OID into the individual components for each index part. */ netsnmp_variable_list var_openserSIPStatusCodeMethod; netsnmp_variable_list var_openserSIPStatusCodeValue; int err; /* * copy index, if provided */ if(hdr) { netsnmp_assert(ctx->index.oids == NULL); if((hdr->len > MAX_OID_LEN) || snmp_clone_mem( (void*)&ctx->index.oids, hdr->oids, hdr->len * sizeof(oid))) { return -1; } ctx->index.len = hdr->len; } /* Initialize the two variables responsible for holding our two indices. */ memset(&var_openserSIPStatusCodeMethod, 0x00, sizeof(var_openserSIPStatusCodeMethod)); memset( &var_openserSIPStatusCodeValue, 0x00, sizeof(var_openserSIPStatusCodeValue) ); var_openserSIPStatusCodeMethod.type = ASN_UNSIGNED; var_openserSIPStatusCodeValue.type = ASN_UNSIGNED; var_openserSIPStatusCodeMethod.next_variable = &var_openserSIPStatusCodeValue; var_openserSIPStatusCodeValue.next_variable = NULL; /* parse the oid into the individual index components */ err = parse_oid_indexes( hdr->oids, hdr->len, &var_openserSIPStatusCodeMethod ); if (err == SNMP_ERR_NOERROR) { /* copy index components into the context structure */ ctx->openserSIPStatusCodeMethod = *var_openserSIPStatusCodeMethod.val.integer; ctx->openserSIPStatusCodeValue = *var_openserSIPStatusCodeValue.val.integer; if (*var_openserSIPStatusCodeMethod.val.integer < 1) { err = -1; } if (*var_openserSIPStatusCodeValue.val.integer < 100 || *var_openserSIPStatusCodeValue.val.integer > 699) { err = -1; } } /* parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_openserSIPStatusCodeMethod ); return err; }
/** * extract usmDHUserKeyTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int usmDHUserKeyTable_index_from_oid(netsnmp_index * oid_idx, usmDHUserKeyTable_mib_index * mib_idx) { int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * usmUserEngineID(1)/SnmpEngineID/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/h */ netsnmp_variable_list var_usmUserEngineID; /* * usmUserName(2)/SnmpAdminString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ netsnmp_variable_list var_usmUserName; /* * set up varbinds */ memset(&var_usmUserEngineID, 0x00, sizeof(var_usmUserEngineID)); var_usmUserEngineID.type = ASN_OCTET_STR; memset(&var_usmUserName, 0x00, sizeof(var_usmUserName)); var_usmUserName.type = ASN_OCTET_STR; /* * chain temp index varbinds together */ var_usmUserEngineID.next_variable = &var_usmUserName; var_usmUserName.next_variable = NULL; DEBUGMSGTL(("verbose:usmDHUserKeyTable:usmDHUserKeyTable_index_from_oid", "called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes(oid_idx->oids, oid_idx->len, &var_usmUserEngineID); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ /* * NOTE: val_len is in bytes, usmUserEngineID_len might not be */ if (var_usmUserEngineID.val_len > sizeof(mib_idx->usmUserEngineID)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->usmUserEngineID, var_usmUserEngineID.val.string, var_usmUserEngineID.val_len); mib_idx->usmUserEngineID_len = var_usmUserEngineID.val_len / sizeof(mib_idx->usmUserEngineID[0]); } /* * NOTE: val_len is in bytes, usmUserName_len might not be */ if (var_usmUserName.val_len > sizeof(mib_idx->usmUserName)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->usmUserName, var_usmUserName.val.string, var_usmUserName.val_len); mib_idx->usmUserName_len = var_usmUserName.val_len / sizeof(mib_idx->usmUserName[0]); } } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_usmUserEngineID); return err; } /* usmDHUserKeyTable_index_from_oid */
/** * extract dot11NewNeighborAPTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int dot11NewNeighborAPTable_index_from_oid(netsnmp_index *oid_idx, dot11NewNeighborAPTable_mib_index *mib_idx) { int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * wtpMacAddr(1)/DisplayString/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/H */ netsnmp_variable_list var_wtpMacAddr; /* * wtpWirelessIfIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ netsnmp_variable_list var_wtpWirelessIfIndex; /* * neighborAPIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ netsnmp_variable_list var_neighborAPIndex; /* * set up varbinds */ memset( &var_wtpMacAddr, 0x00, sizeof(var_wtpMacAddr) ); var_wtpMacAddr.type = ASN_OCTET_STR; memset( &var_wtpWirelessIfIndex, 0x00, sizeof(var_wtpWirelessIfIndex) ); var_wtpWirelessIfIndex.type = ASN_INTEGER; memset( &var_neighborAPIndex, 0x00, sizeof(var_neighborAPIndex) ); var_neighborAPIndex.type = ASN_INTEGER; /* * chain temp index varbinds together */ var_wtpMacAddr.next_variable = &var_wtpWirelessIfIndex; var_wtpWirelessIfIndex.next_variable = &var_neighborAPIndex; var_neighborAPIndex.next_variable = NULL; DEBUGMSGTL(("verbose:dot11NewNeighborAPTable:dot11NewNeighborAPTable_index_from_oid","called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes( oid_idx->oids, oid_idx->len, &var_wtpMacAddr ); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ /* * NOTE: val_len is in bytes, wtpMacAddr_len might not be */ if(var_wtpMacAddr.val_len > sizeof(mib_idx->wtpMacAddr)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->wtpMacAddr, var_wtpMacAddr.val.string, var_wtpMacAddr.val_len); mib_idx->wtpMacAddr_len = var_wtpMacAddr.val_len / sizeof(mib_idx->wtpMacAddr[0]); } mib_idx->wtpWirelessIfIndex = *((long *)var_wtpWirelessIfIndex.val.string); mib_idx->neighborAPIndex = *((long *)var_neighborAPIndex.val.string); } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_wtpMacAddr ); return err; } /* dot11NewNeighborAPTable_index_from_oid */
/** * the *_extract_index routine * * This routine is called when a set request is received for an index * that was not found in the table container. Here, we parse the oid * in the the individual index components and copy those indexes to the * context. Then we make sure the indexes for the new row are valid. */ int saHpiSensorThdPosHysteresisTable_extract_index (saHpiSensorThdPosHysteresisTable_context * ctx, netsnmp_index * hdr) { /* * temporary local storage for extracting oid index * * extract index uses varbinds (netsnmp_variable_list) to parse * the index OID into the individual components for each index part. */ netsnmp_variable_list var_saHpiDomainID; netsnmp_variable_list var_saHpiResourceID; netsnmp_variable_list var_saHpiSensorIndex; int err; /* * copy index, if provided */ if (hdr) { netsnmp_assert (ctx->index.oids == NULL); if (snmp_clone_mem ((void *) &ctx->index.oids, hdr->oids, hdr->len * sizeof (oid))) { return -1; } ctx->index.len = hdr->len; } /* * initialize variable that will hold each component of the index. * If there are multiple indexes for the table, the variable_lists * need to be linked together, in order. */ memset (&var_saHpiDomainID, 0x00, sizeof (var_saHpiDomainID)); var_saHpiDomainID.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */ var_saHpiDomainID.next_variable = &var_saHpiResourceID; memset (&var_saHpiResourceID, 0x00, sizeof (var_saHpiResourceID)); var_saHpiResourceID.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */ var_saHpiResourceID.next_variable = &var_saHpiSensorIndex; memset (&var_saHpiSensorIndex, 0x00, sizeof (var_saHpiSensorIndex)); var_saHpiSensorIndex.type = ASN_UNSIGNED; /* type hint for parse_oid_indexes */ var_saHpiSensorIndex.next_variable = NULL; /* * parse the oid into the individual index components */ err = parse_oid_indexes (hdr->oids, hdr->len, &var_saHpiDomainID); if (err == SNMP_ERR_NOERROR) { /* * copy index components into the context structure */ ctx->domain_id = *var_saHpiDomainID.val.integer; ctx->resource_id = *var_saHpiResourceID.val.integer; ctx->sensor_id = *var_saHpiSensorIndex.val.integer; } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers (&var_saHpiDomainID); return err; }
/** * the *_extract_index routine * * This routine is called when a set request is received for an index * that was not found in the table container. Here, we parse the oid * in the the individual index components and copy those indexes to the * context. Then we make sure the indexes for the new row are valid. */ int memTable_extract_index(memTable_context * ctx, netsnmp_index * hdr) { /* * temporary local storage for extracting oid index * * extract index uses varbinds (netsnmp_variable_list) to parse * the index OID into the individual components for each index part. */ netsnmp_variable_list var_memIndex; int err; /* * copy index, if provided */ if (hdr) { netsnmp_assert(ctx->index.oids == NULL); if (snmp_clone_mem((void *) &ctx->index.oids, hdr->oids, hdr->len * sizeof(oid))) { return -1; } ctx->index.len = hdr->len; } /* * initialize variable that will hold each component of the index. * If there are multiple indexes for the table, the variable_lists * need to be linked together, in order. */ memset(&var_memIndex, 0x00, sizeof(var_memIndex)); var_memIndex.type = ASN_INTEGER; /* type hint for parse_oid_indexes */ /** TODO: link this index to the next, or NULL for the last one */ #ifdef TABLE_CONTAINER_TODO log_print(LOGN_CRI, "memTable_extract_index index list not implemented!\n"); return 0; #else //var_memIndex.next_variable = &var_XX; var_memIndex.next_variable = NULL; #endif /* * parse the oid into the individual index components */ err = parse_oid_indexes(hdr->oids, hdr->len, &var_memIndex); if (err == SNMP_ERR_NOERROR) { /* * copy index components into the context structure */ ctx->memIndex = *var_memIndex.val.integer; /* * TODO: check index for valid values. For EXAMPLE: * * if ( *var_memIndex.val.integer != XXX ) { * err = -1; * } */ } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_memIndex); return err; }
/** * extract pgsqlPgAmTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int pgsqlPgAmTable_index_from_oid(netsnmp_index *oid_idx, pgsqlPgAmTable_mib_index *mib_idx) { int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * pgsnmpdConnID(1)/DisplayString/ASN_OCTET_STR/char(char)//L/a/w/e/R/d/H */ netsnmp_variable_list var_pgsnmpdConnID; /* * rdbmsDbIndex(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/R/d/h */ netsnmp_variable_list var_rdbmsDbIndex; /* * pgsqlPgAmEntryOID(1)/INTEGER/ASN_INTEGER/long(long)//l/a/w/e/r/d/h */ netsnmp_variable_list var_pgsqlPgAmEntryOID; /* * set up varbinds */ memset( &var_pgsnmpdConnID, 0x00, sizeof(var_pgsnmpdConnID) ); var_pgsnmpdConnID.type = ASN_OCTET_STR; memset( &var_rdbmsDbIndex, 0x00, sizeof(var_rdbmsDbIndex) ); var_rdbmsDbIndex.type = ASN_INTEGER; memset( &var_pgsqlPgAmEntryOID, 0x00, sizeof(var_pgsqlPgAmEntryOID) ); var_pgsqlPgAmEntryOID.type = ASN_INTEGER; /* * chain temp index varbinds together */ var_pgsnmpdConnID.next_variable = &var_rdbmsDbIndex; var_rdbmsDbIndex.next_variable = &var_pgsqlPgAmEntryOID; var_pgsqlPgAmEntryOID.next_variable = NULL; DEBUGMSGTL(("verbose:pgsqlPgAmTable:pgsqlPgAmTable_index_from_oid","called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes( oid_idx->oids, oid_idx->len, &var_pgsnmpdConnID ); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ /* * NOTE: val_len is in bytes, pgsnmpdConnID_len might not be */ if(var_pgsnmpdConnID.val_len > sizeof(mib_idx->pgsnmpdConnID)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->pgsnmpdConnID, var_pgsnmpdConnID.val.string, var_pgsnmpdConnID.val_len); mib_idx->pgsnmpdConnID_len = var_pgsnmpdConnID.val_len / sizeof(mib_idx->pgsnmpdConnID[0]); } mib_idx->rdbmsDbIndex = *((long *)var_rdbmsDbIndex.val.string); mib_idx->pgsqlPgAmEntryOID = *((long *)var_pgsqlPgAmEntryOID.val.string); } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_pgsnmpdConnID ); return err; } /* pgsqlPgAmTable_index_from_oid */
/* * the *_extract_index routine */ int netSnmpIETFWGTable_extract_index(netSnmpIETFWGTable_context * ctx, netsnmp_index * hdr) { DEBUGMSGTL((AGENT,"netSnmpIETFWGTable_extract_index")); /* * temporary local storage for extracting oid index */ netsnmp_variable_list var_nsIETFWGName; int err; oid tmp[MAX_OID_LEN]; int tmpl; /* * copy index, if provided */ if (hdr) { netsnmp_assert(ctx->index.oids == NULL); if (snmp_clone_mem((void *) &ctx->index.oids, hdr->oids, hdr->len * sizeof(oid))) { return -1; } ctx->index.len = hdr->len; } /** * Create variable to hold each component of the index */ memset(&var_nsIETFWGName, 0x00, sizeof(var_nsIETFWGName)); var_nsIETFWGName.type = ASN_OCTET_STR; var_nsIETFWGName.next_variable = NULL; /* var_nsIETFWGName.val.string = "ABC"; var_nsIETFWGName.val_len = 3; build_oid_noalloc(tmp, sizeof(tmp), &tmpl, my_oid, OID_LENGTH(my_oid), &var_nsIETFWGName); var_nsIETFWGName.name = tmp; var_nsIETFWGName.name_length = tmpl; DEBUGMSGTL((AGENT,"Build the OID: ")); build_oid_segment(&var_nsIETFWGName); DEBUGMSGOID((AGENT, var_nsIETFWGName.name, var_nsIETFWGName.name_length)); */ /* * parse the oid into the individual components */ err = parse_oid_indexes(hdr->oids, hdr->len, &var_nsIETFWGName); DEBUGMSGTL((AGENT,"parse_oid_indexs: %d = %d", err, SNMP_ERR_NOERROR)); if (err == SNMP_ERR_NOERROR) { /* * copy components into the context structure */ if (var_nsIETFWGName.val_len > sizeof(ctx->nsIETFWGName)) err = -1; else memcpy(ctx->nsIETFWGName, var_nsIETFWGName.val.string, var_nsIETFWGName.val_len); ctx->nsIETFWGName_len = var_nsIETFWGName.val_len; /* * TODO: check index for valid values. For EXAMPLE: * * if ( XXX_check_value( var_nsIETFWGName.val.string, XXX ) ) { * err = -1; * } */ } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers(&var_nsIETFWGName); return err; }
/** * extract jmfcNamespaceHttpServerTable indexes from a netsnmp_index * * @retval SNMP_ERR_NOERROR : no error * @retval SNMP_ERR_GENERR : error */ int jmfcNamespaceHttpServerTable_index_from_oid(netsnmp_index *oid_idx, jmfcNamespaceHttpServerTable_mib_index * mib_idx) { int err = SNMP_ERR_NOERROR; /* * temp storage for parsing indexes */ /* * jmfcNamespaceName(2)/OCTETSTR/ASN_OCTET_STR/char(char)//L/A/w/e/R/d/h */ netsnmp_variable_list var_jmfcNamespaceName; /* * set up varbinds */ memset( &var_jmfcNamespaceName, 0x00, sizeof(var_jmfcNamespaceName) ); var_jmfcNamespaceName.type = ASN_OCTET_STR; /* * chain temp index varbinds together */ var_jmfcNamespaceName.next_variable = NULL; DEBUGMSGTL(("verbose:jmfcNamespaceHttpServerTable:jmfcNamespaceHttpServerTable_index_from_oid","called\n")); /* * parse the oid into the individual index components */ err = parse_oid_indexes( oid_idx->oids, oid_idx->len, &var_jmfcNamespaceName ); if (err == SNMP_ERR_NOERROR) { /* * copy out values */ /* * NOTE: val_len is in bytes, jmfcNamespaceName_len might not be */ if (var_jmfcNamespaceName.val_len > sizeof(mib_idx->jmfcNamespaceName)) err = SNMP_ERR_GENERR; else { memcpy(mib_idx->jmfcNamespaceName, var_jmfcNamespaceName.val.string, var_jmfcNamespaceName.val_len); mib_idx->jmfcNamespaceName_len = var_jmfcNamespaceName.val_len / sizeof(mib_idx->jmfcNamespaceName[0]); } } /* * parsing may have allocated memory. free it. */ snmp_reset_var_buffers( &var_jmfcNamespaceName ); return err; } /* jmfcNamespaceHttpServerTable_index_from_oid */