Hi, everyone
I am a snmp newbie developer, and want to write some new OIDs.
And generate sample code from mib2c MY-DEFINE-MIB file.
But when i develop this part, i meet a big problem:
when set string, requests->requestvb->val.string always remain some old
data, i don't know how to empty it.

Ex:
snmpset -v 1 -c XXX localhost [A OID] s "ABCDEFGHIJ"
snmpset -v 1 -c XXX localhost [B OID] s "1234567"

snmpget -v 1 -c XXX localhost [B OID]
==> "1234567HIJ"

So i want to ask how to solve this problem?
Thanks.

This is my code:
==================================================
...
static  char   A[100];
static  char   B[30];
...

void
init_XXX(void)
{
    const oid       A_oid[] = { ... };
    const oid       B_oid[] = { ... };
...
}

int
handle_AOID(netsnmp_mib_handler *handler,
                       netsnmp_handler_registration *reginfo,
                       netsnmp_agent_request_info *reqinfo,
                       netsnmp_request_info *requests)
{
...

    switch (reqinfo->mode) {

    case MODE_GET:
        snmp_set_var_typed_value(requests->requestvb,
                                 ASN_OCTET_STR, A, sizeof(A));
        break;
    ...
        case MODE_SET_ACTION:
        strncpy(A, requests->requestvb->val.string,
                        sizeof(A));
        A[sizeof(A)-1]='\0';
        break;
        ...
    }
    ...
}


int
handle_BOID(netsnmp_mib_handler *handler,
                       netsnmp_handler_registration *reginfo,
                       netsnmp_agent_request_info *reqinfo,
                       netsnmp_request_info *requests)
{
...

    switch (reqinfo->mode) {

    case MODE_GET:
        snmp_set_var_typed_value(requests->requestvb,
                                 ASN_OCTET_STR, B, sizeof(B));
        break;
    ...
        case MODE_SET_ACTION:
        strncpy(B, requests->requestvb->val.string,
                        sizeof(B));
        B[sizeof(B)-1]='\0';
        break;
        ...
    }
    ...
}
===============================================
And other part codes, i almost not modified them, continue to use from
mib2c auto-generate.
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to