MIBs for Dummies - row context initialization question - SNMP

This is a discussion on MIBs for Dummies - row context initialization question - SNMP ; I'm trying to get used to the generated code from mib2c using the MIBs for Dummies config file, and I think I'm missing something that should be obvious. In the main table header (eg. myTable.h) it defines a row context ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: MIBs for Dummies - row context initialization question

  1. MIBs for Dummies - row context initialization question

    I'm trying to get used to the generated code from mib2c using the MIBs
    for Dummies config file, and I think I'm missing something that should
    be obvious. In the main table header (eg. myTable.h) it defines a row
    context structure, which contains among other things a table data
    structure called data. That structure contains fields of appropriate
    types for each of the non-index columns in the table, as well as
    size_t fields to contain the length of each data field. For each table
    row, the generated template code (myTable_data_access.c) generates a
    new row context struct with myTable_allocate_rowreq_ctx(), calls
    myTable_indexes_set() on the new context structure, and then in turn
    sets each data member. The code looks like this:

    if ((NULL == rowreq_ctx->data.myEntryName) ||
    (rowreq_ctx->data.myEntryName_len < (myEntryName_len *
    sizeof(rowreq_ctx->data.myEntryName[0])))) {
    snmp_log(LOG_ERR,"not enough space for value\n");
    return MFD_ERROR;
    }

    When I run this, I always get the "not enough space for value" error,
    because, if I read this correctly, nothing has ever initialized the
    rowreq_ctx->data.myEntryName_len value. Does that initialization
    happen somewhere in the template code, and I just missed it? Do I have
    to do it manually somewhere, and if so, where? Am I just reading it
    completely wrong? Many thanks for any light you can shed on this for
    me.

    -Josh

    -------------------------------------------------------------------------
    Take Surveys. Earn Cash. Influence the Future of IT
    Join SourceForge.net's Techsay panel and you'll get the chance to share your
    opinions on IT & business topics through brief surveys-and earn cash
    http://www.techsay.com/default.php?p...rge&CID=DEVDEV
    _______________________________________________
    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/...net-snmp-users

  2. Thumbs up Re: MIBs for Dummies - row context initialization question

    HIii
    U are yourself very much close to solution. NOw i will show you what you have use and why

    rowreq_ctx->data.myEntryName_len =sizeof(rowreq_ctx->data.myEntryName);//this is //reqrd

    if ((NULL == rowreq_ctx->data.myEntryName) ||
    (rowreq_ctx->data.myEntryName_len < (myEntryName_len *
    sizeof(rowreq_ctx->data.myEntryName[0])))) {
    snmp_log(LOG_ERR,"not enough space for value\n");
    return MFD_ERROR;
    }


    as data.myEntryName_len is never initialized and contains garbage value so its required
    the same problem i had also faced in my initial days of net snmp
    Happy Coding

+ Reply to Thread