---------- Forwarded message ----------
From: pavithra s <[EMAIL PROTECTED]>
Date: Jul 13, 2007 6:28 PM
Subject: Re: SNMPTable - Multilple Instances
To: net-snmp-users@lists.sourceforge.net

Can anyone say what i m doing is right or not...........

On 7/13/07, pavithra s <[EMAIL PROTECTED]> wrote:

Hi All,

I trying to do multiple instances using Table code generated from mib2c
tool.I m able to walk,bulkget,etc., but the problem is the agent is not
recognising the end of the instance.For  example if i have created 2
instances using createEntry funtion,when i request for the third instance as
XXX.3,i shoould get Msg like "No such Instance available"

But i m error like
netsnmp_assert pss->s_snmp_errno != (-11) failed snmp_api.c:3124
snmp_build()
send response: Error building ASN.1 representation (build int size 0: s/b
4)
XXX.2

I m attaching what i ve done to generated code:

void
initialize_table_voltTable(void)
{

struct voltTable_entry *data=NULL;

........../* same as generated*/
..........

data = GetVoltData();
     if(data==NULL)
         return NULL;
}
struct voltTable_entry *GetVoltData()
{

    struct voltTable_entry
*entry=NULL,*tmp=NULL,*tmp_ptr=NULL,*tmp3=NULL,*tmp4=NULL;

    tmp = SNMP_MALLOC_TYPEDEF(struct voltTable_entry);
    if (!tmp)
        return NULL;

    tmp_ptr = SNMP_MALLOC_TYPEDEF(struct voltTable_entry);
    if (!tmp_ptr)
        return NULL;

/

    tmp = voltTable_createEntry(0);


        tmp->valid =1;

        strncpy(tmp->voltDescr,"Voltage",strlen("Voltage")+1);
        tmp->voltReading = 18;//voltReading;
        tmp->voltNominalReading =17;// voltNominalReading;
        tmp->voltNonRecovLimitHigh =16 ;//voltNonRecovLimitHigh;

//     tmp->next=NULL;

        tmp_ptr = tmp->next;

        tmp_ptr = voltTable_createEntry(1);
        tmp_ptr->valid =1;


strncpy(tmp_ptr->voltDescr,"Voltage2",strlen("Voltage22222222222")+1);
        tmp_ptr->voltReading = 10;//voltReading;
        tmp_ptr->voltNominalReading =22;// voltNominalReading;
        tmp_ptr->voltNonRecovLimitHigh =21 ;//voltNonRecovLimitHigh;


        tmp_ptr->next=NULL;

}

netsnmp_variable_list *
voltTable_get_first_data_point(void **my_loop_context,
                               void **my_data_context,
                               netsnmp_variable_list * put_index_data,
                               netsnmp_iterator_info *mydata)
{


    voltTable_head = GetVoltData();

    if(voltTable_head!=NULL){
        *my_loop_context = voltTable_head;
        printf("\n\n index==========in gte_first
%d",put_index_data->index);
        return voltTable_get_next_data_point(my_loop_context,
my_data_context,
                                         put_index_data, mydata);
    }
    else{
        return NULL;
    }
}

netsnmp_variable_list *
voltTable_get_next_data_point(void **my_loop_context,
                              void **my_data_context,
                              netsnmp_variable_list * put_index_data,
                              netsnmp_iterator_info *mydata)
{

    struct voltTable_entry *entry =
                (struct voltTable_entry *) *my_loop_context;

                netsnmp_variable_list *idx = put_index_data;

    if (entry)
     {
//         printf("\n----innnndex ==---%d",*put_index_data->val.integer);
        if(*put_index_data->val.integer<2)
            {
//             printf("\n in set_value\n\n");
            snmp_set_var_value(idx,(u_char *)&entry->voltIndex,
sizeof(entry->voltIndex));
            idx = idx->next_variable;
            *my_data_context = (void *)entry;
            *my_loop_context = (void *)entry->next;
            return put_index_data;
            }
        else{
            printf("\n I M HERE in else \n\n");
            return NULL;
        }

    }

    else {
        printf("\n I m here-------------in entry=NULL---\n\n");
//         SET_SNMP_ERROR(SNMPERR_UNKNOWN_OBJID);
        return NULL;
    }

}



This is wht i ve done to the generated template....I tried for very long
time but i m not able to resolve....  Any help will be of great help....its
urgent ....


Cab anyone shed some light on this......


Thanks &Regards,
Pavithra S




-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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

Reply via email to