Hi Dave, I changed the code as below, but now Get fails and Get next works. The below is the response.
Dev6-MgmtServer:/usr/sbin # 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 = No Such Instance currently exists at this OID Dev6-MgmtServer:/usr/sbin # 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 = Counter64: 0 The code snipprt is as below:: Any help is highly appreciated. 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; cout << "ipAddress" << ipAddress << endl; //vplexDirectorPrimaryIpAddr = htonl(inet_addr(ipAddress.c_str())); 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; cout << "in vplexDirectorFETable_createEntry" << endl; cout << "ipAddress--IDX" << entry->vplexDirectorPrimaryIpAddr << endl; entry->next = vplexDirectorFETable_head; vplexDirectorFETable_head = entry; return entry; } /* 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; struct vplexDirectorFETable_entry *entry = (struct vplexDirectorFETable_entry *)*my_loop_context; cout << "in vplexDirectorFETable_get_first_data_point" << endl; cout << "ipAddress" << entry->vplexDirectorPrimaryIpAddr << endl; netsnmp_variable_list *list = vplexDirectorFETable_get_next_data_point(my_loop_context, my_data_context, put_index_data, mydata ); cout << "put_index_data" << *list->val.integer << endl; return list; } 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 ) { cout << "iam in vplexDirectorFETable_get_next_data_point" << endl; cout << "idx" << idx << "ipAddress" << entry->vplexDirectorPrimaryIpAddr << endl; //snmp_set_var_typed_integer( idx, ASN_IPADDRESS, entry->vplexDirectorPrimaryIpAddr) ; snmp_set_var_typed_value( idx,ASN_IPADDRESS,(u_char *) &entry->vplexDirectorPrimaryIpAddr,\ sizeof(entry->vplexDirectorPrimaryIpAddr)); idx = idx->next_variable; *my_data_context = (void *)entry; *my_loop_context = (void *)entry->next; return put_index_data; } else { return NULL; } } Thx, Anup -----Original Message----- From: dave.shi...@googlemail.com [mailto:dave.shi...@googlemail.com] On Behalf Of Dave Shield Sent: Tuesday, August 24, 2010 8:04 PM To: Shankar, Anup Cc: net-snmp-users@lists.sourceforge.net Subject: Re: Fails:: SNMPGetNext and GetBulk has the IP Address Index reversed in the request. On 24 August 2010 13:48, <anup.shan...@emc.com> wrote: > snmp_set_var_typed_integer( idx, ASN_IPADDRESS, > ntohl(entry->vplexDirectorPrimaryIpAddr) ); The SMI type IpAddress is not an integer-based type. It is a (four-octet) binary string, which holds the address in network-byte order. See RFC 2758, section 7.1.5 You *might* be able to get away with treating it as an integer in this way, but I certainly don't think you should be returning it in host order. Dave ------------------------------------------------------------------------------ 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