5.3. Getting values

The mechanism by which the NetSNMP library retrieves the correct row is by calling the function defined in the callback mechanism. Please refer to Section 5.1.3 for more details.

   cb.get_value = netSnmpIETFWGTable_get_value;

The netSnmpIETFWGTable_get_value is similar to the ACTION, RESERVE1, and RESERVE2 routines by the mechanism of looping through the requests for columns and performing some operation on the correct column. In this case, instead of checking the value, or writing, it is setting a pointer to the appropiate data and the data's length (in bytes).

  switch(table_info->colnum) {

        case COLUMN_NSIETFWGNAME:
            /** OCTETSTR = ASN_OCTET_STR */
            snmp_set_var_typed_value(var, ASN_OCTET_STR,
                         (char*)& context->nsIETFWGName,
                         context->nsIETFWGName_len );
        break;
        ...
Note

If one of your columnar nodes is of type write-only. Then just return NULL for that specified column.

The snmp_set_var_typed_value function sets the correct type of the data, a pointer to the location of the data, and the length of the data in bytes. There is no need for host to network byte swapping - the NetSNMP library performs these functions internally if needed.