Hi All, We are using NET-SNMP code for building an SNMP agent for servicing our MIB file. The MIB file reports performance metrics for the hardware. The Table entries in the MIB use IP Address as index.
The setup is as below: ----------------------------- NET-SNMP : net-snmp-5.3.0.1-25.25 OS: SLES 10 -- 32bit. The problem iam facing is when I use the SNMPGet to retrieve the table entry it Works. However the GetNext and GetBulk calls fail. I have used the mib2c.iterate.conf to generate the code. snmpget -v 2c -c public 127.0.0.1 1.3.6.1.4.1.1139.21.2.2.5.1.1.128.221.252.35 SNMPv2-SMI::enterprises.1139.21.2.2.5.1.1.128.221.252.35 = Counter64: 0 snmpgetnext -v 2c -c public 127.0.0.1 1.3.6.1.4.1.1139.21.2.2.5.1.1.128.221.252.35 SNMPv2-SMI::enterprises.1139.21.2.2.5.1.2.35.252.221.128 = No Such Instance The below is the code snippet.. -------------------------------------- void initialize_table_vplexDirectorFETable(void) { const oid vplexDirectorFETable_oid[] = {1,3,6,1,4,1,1139,21,2,2,5}; const size_t vplexDirectorFETable_oid_len = OID_LENGTH(vplexDirectorFETable_oid); netsnmp_handler_registration *reg; netsnmp_iterator_info *iinfo; netsnmp_table_registration_info *table_info; DEBUGMSGTL(("vplexStats:init", "initializing table vplexDirectorFETable\n")); reg = netsnmp_create_handler_registration( "vplexDirectorFETable", vplexDirectorFETable_handler, vplexDirectorFETable_oid, vplexDirectorFETable_oid_len, HANDLER_CAN_RONLY ); table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info ); netsnmp_table_helper_add_indexes(table_info, ASN_IPADDRESS, /* index: vplexDirectorPrimaryIpAddr */ 0); table_info->min_column = COLUMN_VPLEXDIRECTORFEOPSREAD; table_info->max_column = COLUMN_VPLEXDIRECTORFEBYTESWRITE; iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info ); iinfo->get_first_data_point = vplexDirectorFETable_get_first_data_point; iinfo->get_next_data_point = vplexDirectorFETable_get_next_data_point; iinfo->table_reginfo = table_info; netsnmp_register_table_iterator( reg, iinfo ); /* Initialise the contents of the table here */ struct vplexDirectorFETable_entry *entry; in_addr_t vplexDirectorPrimaryIpAddr; cout << "initialize_table_vplexDirectorFETable" << endl; Stringvector idxList; std::vector<DirectorInfo> dirList = VPLEXConfigurator::getInstance()->getDirectorsInfo(); VPLEXStatsManager* statsMgr = VPLEXStatsManager::getInstance(); DirectorInfo dir; String ipAddress; for(std::vector<DirectorInfo>::iterator i = dirList.begin(); i != dirList.end(); i++) { dir = *i; ipAddress = dir.primaryIpAddress; vplexDirectorPrimaryIpAddr = inet_addr(ipAddress.c_str()); cout << "Entry IP" << vplexDirectorPrimaryIpAddr << endl; entry = vplexDirectorFETable_createEntry(vplexDirectorPrimaryIpAddr); entry->valid = 1; } } /* create a new row in the (unsorted) table */ struct vplexDirectorFETable_entry * vplexDirectorFETable_createEntry( in_addr_t vplexDirectorPrimaryIpAddr ) { struct vplexDirectorFETable_entry *entry; entry = SNMP_MALLOC_TYPEDEF(struct vplexDirectorFETable_entry); if (!entry) return NULL; entry->vplexDirectorPrimaryIpAddr = vplexDirectorPrimaryIpAddr; entry->next = vplexDirectorFETable_head; vplexDirectorFETable_head = entry; return entry; } /* remove a row from the table */ void vplexDirectorFETable_removeEntry( struct vplexDirectorFETable_entry *entry ) { struct vplexDirectorFETable_entry *ptr, *prev; if (!entry) return; /* Nothing to remove */ for ( ptr = vplexDirectorFETable_head, prev = NULL; ptr != NULL; prev = ptr, ptr = ptr->next ) { if ( ptr == entry ) break; } if ( !ptr ) return; /* Can't find it */ if ( prev == NULL ) vplexDirectorFETable_head = ptr->next; else prev->next = ptr->next; SNMP_FREE( entry ); /* XXX - release any other internal resources */ } /* Example iterator hook routines - using 'get_next' to do most of the work */ netsnmp_variable_list * vplexDirectorFETable_get_first_data_point(void **my_loop_context, void **my_data_context, netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata) { *my_loop_context = vplexDirectorFETable_head; return vplexDirectorFETable_get_next_data_point(my_loop_context, my_data_context, put_index_data, mydata ); } netsnmp_variable_list * vplexDirectorFETable_get_next_data_point(void **my_loop_context, void **my_data_context, netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata) { struct vplexDirectorFETable_entry *entry = (struct vplexDirectorFETable_entry *)*my_loop_context; netsnmp_variable_list *idx = put_index_data; if ( entry ) { snmp_set_var_typed_integer( idx, ASN_IPADDRESS, ntohl(entry->vplexDirectorPrimaryIpAddr) ); idx = idx->next_variable; *my_data_context = (void *)entry; *my_loop_context = (void *)entry->next; return put_index_data; } else { return NULL; } } /** handles requests for the vplexDirectorFETable table */ int vplexDirectorFETable_handler( netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { netsnmp_request_info *request; netsnmp_table_request_info *table_info; struct vplexDirectorFETable_entry *table_entry; DEBUGMSGTL(("vplexStats:handler", "Processing request (%d)\n", reqinfo->mode)); switch (reqinfo->mode) { /* * Read-support (also covers GetNext requests) */ case MODE_GET: for (request=requests; request; request=request->next) { table_entry = (struct vplexDirectorFETable_entry *) netsnmp_extract_iterator_context(request); table_info = netsnmp_extract_table_info( request); switch (table_info->colnum) { case COLUMN_VPLEXDIRECTORFEOPSREAD: if ( !table_entry ) { netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHINSTANCE); continue; } ------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ Net-snmp-users mailing list Net-snmp-users@lists.sourceforge.net Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users