On 06/07/07, Need Help <[EMAIL PROTECTED]> wrote:

> typedef struct MIB_OCTET_STRING_s {
>    u_long  length;
>    u_char  textStr[50];
>
> } MIB_OCTET_STRING;

Note that  'textStr' is effective a "char *", pointing to the start
of the string value.



>       snmp_set_var_typed_value(requests->requestvb,
>                                ASN_OCTET_STR,
>                                (u_char *)&serialNumber.textStr,
>                                serialNumber.length);
>   }


Not quite.   serialNumber.textStr is already a pointer to the
string value, so you don't need to take the address of it.
Try

    snmp_set_var_typed_value(requests->requestvb,
                                ASN_OCTET_STR,
                                (u_char *)serialNumber.textStr,
                                serialNumber.length);
   }

> Now, in the "handle_ocStbHostCapabilities()" routine (not shown), I noticed
> I need to supply the scalar value via the same exact
> "snmp_set_var_typed_value" routine interface using a pointer/length
> combination.

That will work, yes.

>      Since the "HostCapabilities" value is defined as an "Integer"
> value in the MIB file, I was expecting to call a new routine which had an
> interface allowing me to provide "u_int" value instead of a pointer/length
> combination.

You can do that as well - see snmp_set_var_typed_integer()
(though we don't currently have an unsigned version of this routine)


>        Are all scalar values treated the same in that I will need to
> provide a pointer and byte length for each?

Fundamentally, yes.  This is how *all* values are handled internally,
for both scalar and table objects.   There are various higher-level
convenience routines that accept values in a more "natural" format,
but they are then converted to this pointer/length format behind
the scenes.

>                                           If so, then I guess NetSNMP
> figures out the byte is really not a character, but is in fact an Integer

Don't think of this as a character pointer.  It would be more appropriate
to regard it as "void*" - as an arbitrary (opaque) pointer that needs to
be cast to the appropriate form before using.
   The reason for using "char*" rather than "void*" is historical.



> Also, what is the "maximum length" of a scalar value which can be passed
> into the "snmp_set_var_typed_value" routine?

For integer-based values, either 32-bit or 64-bit, depending on the syntax.
For character-based values (including opaque), the theoretical maximum
is 65K (although particular MIB objects may have a smaller maximum size).
For OID-based values, the maximum length is 128 subidentifiers  (each of
which is up to 32-bits).

Dave

-------------------------------------------------------------------------
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-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to