SNMPSET illusion? - SNMP

This is a discussion on SNMPSET illusion? - SNMP ; Hi all, I have the following MIB node in my MIB cdsprAlcActivity OBJECT-TYPE SYNTAX INTEGER { alc-on ( 1 ), alc-off ( 2 ) } ACCESS read-write STATUS mandatory DESCRIPTION "Use regulated or fixed output power 1 - ALC on ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: SNMPSET illusion?

  1. SNMPSET illusion?

    Hi all,

    I have the following MIB node in my MIB

    cdsprAlcActivity OBJECT-TYPE
    SYNTAX INTEGER
    {

    alc-on ( 1 ),
    alc-off ( 2 )
    }
    ACCESS read-write
    STATUS mandatory
    DESCRIPTION
    "Use regulated or fixed output power
    1 - ALC on
    2 - ALC off"
    ::= { alc 1}


    The agent should accept only the following two snmpset requests
    snmpset -c private -v2c localhost REPEATER-MIB::cdsprAlcActivity.0 i 1
    snmpset -c private -v2c localhost REPEATER-MIB::cdsprAlcActivity.0 i 2

    But I have a peculiar problem, when I set values to other than 0 and
    1, it responds this way. For example:
    snmpset -c private -v2c localhost REPEATER-MIB::cdsprAlcActivity.0 i 100
    REPEATER-MIB::cdsprAlcActivity.0 = INTEGER: 100

    Interestingly when I do snmpget it gives me the correct value(which
    was originally set to value 2 before the above snmpset)
    snmpget -c private -v2c localhost XM-RADIO-REPEATER-MIB::cdsprAlcActivity.0
    REPEATER-MIB::cdsprAlcActivity.0 = INTEGER: alc-off(2)

    For invalid snmpset values instead of complaining that the value is
    out of bounds - it shows as if the value has been set even for out of
    bounds value - although in reality the value has not been changed/set
    creating an illusion - instead of complaining - why???

    Ofcourse snmpset works fine for values 1 and 0, which was validated
    with snmpget requests.

    With regards,

    Raghavendra

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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. Re: SNMPSET illusion?

    2008/7/23 Raghavendra Prasad :


    > For invalid snmpset values instead of complaining that the value is
    > out of bounds - it shows as if the value has been set even for out of
    > bounds value - although in reality the value has not been changed/set
    > creating an illusion - instead of complaining - why???
    >


    In the code used to handle your mib there are two ways of checking for
    a valid integer in the SET_RESERVE# blocks generated by mib2c:

    One is a simple check to see if the value passed is an integer, the
    other is a range check.

    Usually mib2c uses the former call rather an range check.

    At the moment I've not got my development machine with me to check
    exact syntax but if you look in your agent code (assuming you used
    mib2c to generate it) for the column in question in the SET_RESERVE1
    block there is a comment refering to the option to use a check range
    rather than the simple check type call (check range will validate the
    type as well so its a straight swap - I believe from memory the
    parameter list is the same with the addition of the upper and lower
    bounds).





    --
    Richard Horton
    Users are like a virus: Each causing a thousand tiny crises until the
    host finally dies.
    http://www.solstans.co.uk - Solstans Japanese Bobtails and Norwegian Forest Cats
    http://www.pbase.com/arimus - My online photogallery

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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


  3. Re: SNMPSET illusion?

    Thanks for reply

    Did you both mean the function
    ret = netsnmp_check_vb_type_and_size(requests->requestvb,
    ASN_INTEGER, requests->requestvb->val_len);

    Which I am using in my code

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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


  4. Re: SNMPSET illusion?

    I use the following code still the problem persists, any help??

    case MODE_SET_RESERVE1:
    ret = netsnmp_check_vb_type_and_size(requests->requestvb,
    ASN_INTEGER, i requests->requestvb->val_len);

    if ( ret != SNMP_ERR_NOERROR ) {
    netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGVALUE);
    }
    break;

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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


  5. Re: SNMPSET illusion?

    2008/7/23 Raghavendra Prasad :
    > I use the following code still the problem persists, any help??
    >
    > case MODE_SET_RESERVE1:
    > ret = netsnmp_check_vb_type_and_size(...)


    You are still only checking the type of the assigned value.
    As Richard said earlier, you need to check the *range*
    of this value as well.

    Try
    ret = netsnmp_check_vb_int_range( requests->requestvb, 1, 2);

    Dave

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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


  6. Re: SNMPSET illusion?

    2008/7/23 Raghavendra Prasad :
    >>Try
    >> ret = netsnmp_check_vb_int_range( requests->requestvb, 1, 2);

    >
    > I may sound stupid, sometime ago I remember that this range check for
    > enumeration types was done automatically - I am fairly confident, which I
    > thought was due to parsing of MIB by snmpd ???


    No - the SNMP agent does *not* use the MIB file for processing SET
    (or GET*) requests. It''s up to your code to handle any validation that
    might be required. Hence the suggestion above.

    The "snmpset" command does do range validation, and will simply not
    send requests that it knows will fail. But if you want the agent to
    reject invalid values, then *your* code must check for these.

    Dave

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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


  7. Re: SNMPSET illusion?

    >No - the SNMP agent does *not* use the MIB file for processing SET
    > (or GET*) requests. It''s up to your code to handle any validation that
    > might be required. Hence the suggestion above.
    >
    > The "snmpset" command does do range validation, and will simply not
    > send requests that it knows will fail. But if you want the agent to
    > reject invalid values, then *your* code must check for these.
    >
    > Dave
    >

    That dispelled my wrong notion - many thanks for the clarification.

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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


  8. Re: SNMPSET illusion?

    Here is my code

    ret = netsnmp_check_vb_int_range( requests->requestvb, 1, 2);
    if ( ret != SNMP_ERR_NOERROR )
    netsnmp_request_set_error(requests, SNMP_ERR_WRONGVALUE);


    Is SNMP_ERR_WRONGVALUE a proper error code for range violation???, I
    tried searching explanations for net-snmp error codes but failed to
    get explanation for these error codes. Is there a source for this on
    web??

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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


  9. Re: SNMPSET illusion?

    2008/7/24 Raghavendra Prasad :
    > Here is my code
    >
    > ret = netsnmp_check_vb_int_range( requests->requestvb, 1, 2);
    > if ( ret != SNMP_ERR_NOERROR )
    > netsnmp_request_set_error(requests, SNMP_ERR_WRONGVALUE);


    netsnmp_check_vb_int_range() will return the appropriate error
    value for any given assignment. Just use that:

    ret = netsnmp_check_vb_int_range( requests->requestvb, 1, 2);
    if ( ret != SNMP_ERR_NOERROR )
    netsnmp_request_set_error(requests, ret);

    That will handle wrongType, wrongSize and wrongValue errors.

    Dave

    -------------------------------------------------------------------------
    This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
    Build the coolest Linux based applications with Moblin SDK & win great prizes
    Grand prize is a trip for two to an Open Source event anywhere in the world
    http://moblin-contest.org/redirect.p...r_id=100&url=/
    _______________________________________________
    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


+ Reply to Thread