FW: Iterate option is unable to retreive the first index column v alues.
Rohini V <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Sorry,
Forgot to mention that Column No. 1 is missing in output.
Even a get or getnext request doesn't work.
Thanks
Rohini
> -----Original Message-----
> From: Rohini V
> Sent: Friday, September 30, 2005 1:19 PM
> To: Sourceforgenet (E-mail)
> Subject: Iterate option is unable to retreive the first index column
> values.
>
>
> Hi
>
> There exists a table with 2 indices. Totally the table posseses 5 columns,
> out of which first 2 columns are indexes.
>
> I am using a structure to retrieve these 2 indexes.
>
> The structure is declared as :
> /*
> * This structure has a specific purpose.
> * Used only with tables which have 2 indexes.
> */
> struct indexData{
> int min1; // min value for index 1
> int min2; // min value for index 2
> int max1; // max value for index 1
> int max2; // max value for index 2
> int start1; // start point of min value for index 1
> int start2; // start point of min value for index 2
> int size; // overall size of container
> };
>
> typedef struct indexData otherData;
>
>
> The get_first and get_next hooks are like this :
>
> netsnmp_variable_list *
> exampleTable_get_first_data_point(void **my_loop_context,
> void **my_data_context,
> netsnmp_variable_list *
> put_index_data,
> netsnmp_iterator_info *mydata)
> {
> otherData* rest = exampleTable_other;
>
> printf("Inside Function %s\n", __FUNCTION__);
>
> if ( rest->start1 <= 0 || rest->start2 <= 0 )
> return NULL;
>
> rest->min1 = rest->start1;
> rest->min2 = rest->start2;
>
> *my_loop_context = (void *) rest;
> *my_data_context = (void *) rest;
>
> return exampleTable_get_next_data_point(my_loop_context,
> my_data_context,
> put_index_data,
> mydata);
> }
>
>
> netsnmp_variable_list *
> exampleTable_get_next_data_point(void **my_loop_context,
> void **my_data_context,
> netsnmp_variable_list *
> put_index_data,
> netsnmp_iterator_info *mydata)
> {
> otherData* rest;
> netsnmp_variable_list *idx = put_index_data;
>
> printf("Inside Function %s\n", __FUNCTION__);
>
> rest = ( otherData * ) *my_loop_context ;
>
> if ( rest->min1 > rest->max1 || rest->min2 > rest->max2 )
> return NULL;
>
> snmp_set_var_value(idx, (u_char *) &rest->min1,
> sizeof(rest->min1));
> idx = idx->next_variable;
>
> snmp_set_var_value(idx,(u_char *) &rest->min2,
> sizeof(rest->min2));
> idx = idx->next_variable;
>
> *my_loop_context = (void *) rest;
> *my_data_context = (void *) rest;
>
> rest->min1++;
> rest->min2++;
>
> return put_index_data;
> }
>
> And the handler is :
>
> int
> exampleTable_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;
> netsnmp_variable_list * var;
> otherData *rest;
>
> static oid exampleTableEntry_oid[] =
> { 1, 3, 6, 1, 4, 1, 1872, 2, 5, 6, 2, 4, 1 };
>
> unsigned int column_oid_len =
> OID_LENGTH(exampleTableEntry_oid) + 3;
> oid column_oid[column_oid_len];
> int iteridx1, iteridx2, rc = 0, foundit = 0;
> char *str, *temp;
> unsigned int hashVal = -1, value = 0;
> Data* ip;
>
> printf("Inside Function %s\n", __FUNCTION__);
> switch (reqinfo->mode) {
> /*
> * Read-support (also covers GetNext requests)
> */
> case MODE_GET:
> for (request = requests; request; request = request->next) {
> var = request->requestvb;
> printf("req oid = ");
> print_oid( var->name, var->name_length );
>
> rest = (otherData *)
> netsnmp_extract_iterator_context(request);
> if( rest == NULL )
> {
> printf("table_entry is NULL\n");
> return SNMP_NOSUCHINSTANCE;
> }
>
> table_info = netsnmp_extract_table_info(request);
> if ( table_info == NULL )
> continue;
>
> rc = append_to_oid_sec( column_oid,
> bwmStatPortTcrTableEntry_oid,
> column_oid_len-3,
> table_info->colnum,
> var->name[var->name_length-2],
> var->name[var->name_length-1] );
> hashVal = APHash( column_oid, column_oid_len );
> ip = traverse_table_container( bwmStatPortTcrTable_container,
> rest->size,
> hashVal );
> foundit = HASH_EQUALS( ip->key, hashVal );
> if ( foundit )
> {
> temp = (char*) ip->value;
> printf("temp val = %s\n", temp);
> iteridx1 = *table_info->indexes->val.integer ;
> iteridx2 =
> *table_info->indexes->next_variable->val.integer ;
> printf("iteridx1, 2 = %d, %d\n", iteridx1, iteridx2);
> }
> else
> {
> printf("Unable to trace the req oid\n");
> return;
> }
>
> printf("colnum = %d\n", table_info->colnum);
> switch (table_info->colnum) {
> case COLUMN_EXAMPLEPORTINDEX:
> printf("col1->indx\n");
> snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
> (u_char*) &iteridx1,
> sizeof(iteridx1));
> break;
>
> case COLUMN_EXAMPLECONTRACTINDEX:
> printf("col2->indx\n");
> snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
> (u_char*) &iteridx2,
> sizeof(iteridx2));
> break;
>
> case COLUMN_EXAMPLENAME:
> snmp_set_var_typed_value(request->requestvb,
> ASN_OCTET_STR,
> temp, strlen(temp) );
> break;
>
> case COLUMN_EXAMPLERATE:
> value = atoi(temp);
> snmp_set_var_typed_value(request->requestvb, ASN_INTEGER,
> (u_char*) &value,
> sizeof(value));
> break;
>
> case COLUMN_EXAMPLEOUTOCT:
> value = atoi(temp);
> snmp_set_var_typed_value(request->requestvb, ASN_COUNTER,
> (u_char*) &value,
> sizeof(value));
> break;
> }
> }
> break;
> }
> return SNMP_ERR_NOERROR;
> }
>
> Now, when I perform a snmp walk, or snmp get next , or snmp get ,
> I can only see the values from column 2. The column is always missing.
>
> The data are all displayed correctly.
> I dont understand what's going wrong.
>
> Please help.......
>
> Thanx in advance.
>
> Regards,
> Rohini
>
>
>
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users