Blame man/netsnmp_varbind_api.3.def

Packit Service b38f0b
.TH NETSNMP_VARBIND_API 3 "13 Aug 2010" VVERSIONINFO "Net-SNMP"
Packit Service b38f0b
.SH NAME
Packit Service b38f0b
snmp_pdu_add_variable,
Packit Service b38f0b
snmp_varlist_add_variable,
Packit Service b38f0b
snmp_add_null_var,
Packit Service b38f0b
snmp_clone_varbind,
Packit Service b38f0b
snmp_set_var_objid,
Packit Service b38f0b
snmp_set_var_value,
Packit Service b38f0b
snmp_set_var_typed_value,
Packit Service b38f0b
snmp_set_var_typed_integer,
Packit Service b38f0b
print_variable,
Packit Service b38f0b
fprint_variable,
Packit Service b38f0b
snprint_variable,
Packit Service b38f0b
print_value,
Packit Service b38f0b
fprint_value,
Packit Service b38f0b
snprint_value,
Packit Service b38f0b
snmp_free_var,
Packit Service b38f0b
snmp_free_varbind - netsnmp_varbind_api functions
Packit Service b38f0b
.SH SYNOPSIS
Packit Service b38f0b
.B #include <net-snmp/varbind_api.h>
Packit Service b38f0b
.SS Creation
Packit Service b38f0b
.PP
Packit Service b38f0b
.B "netsnmp_variable_list *snmp_pdu_add_variable("
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     netsnmp_pdu *" pdu ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const oid *" objid ", size_t " objidlen ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     u_char " type ", const void *" value ", size_t " len ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.B "netsnmp_variable_list *snmp_varlist_add_variable("
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     netsnmp_variable_list *" varlist ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const oid *" objid ", size_t " objidlen ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     u_char " type ", const void *" value ", size_t " len ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.B "netsnmp_variable_list *snmp_add_null_var("
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     netsnmp_pdu *" pdu ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const oid *" objid ", size_t " objidlen ");"
Packit Service b38f0b
.PP
Packit Service b38f0b
.B "netsnmp_variable_list *snmp_clone_varbind("
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     netsnmp_variable_list *" varlist ");"
Packit Service b38f0b
.SS Setting Values
Packit Service b38f0b
.PP
Packit Service b38f0b
.BI "int  snmp_set_var_objid( netsnmp_variable_list* " variable ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const oid * " objid ", size_t " objidlen ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "int  snmp_set_var_value( netsnmp_variable_list* " variable ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const void * " value ", size_t " vallen ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "int  snmp_set_var_typed_value( netsnmp_variable_list* " variable ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     u_char " type ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const void * " value ", size_t " vallen ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "int  snmp_set_var_typed_integer( netsnmp_variable_list* " variable ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     u_char " type ", long " value ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.SS Output
Packit Service b38f0b
.PP
Packit Service b38f0b
.BI "void  print_variable(const oid *" "objid" ", size_t " "objidlen" ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const netsnmp_variable_list *" variable ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "void fprint_variable(FILE *" fp ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const oid *" objid ", size_t " objidlen ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const netsnmp_variable_list *" variable ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "int snprint_variable(char *" "buf" ", size_t " "len" ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const oid *" objid ", size_t " objidlen ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const netsnmp_variable_list *" variable ");"
Packit Service b38f0b
.PP
Packit Service b38f0b
.BI "void  print_value(const oid *" objid ", size_t " objidlen ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const netsnmp_variable_list *" variable ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "void fprint_value(FILE *" fp ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const oid *" objid ", size_t " objidlen ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const netsnmp_variable_list *" variable ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "int snprint_value(char *" buf ", size_t " "len" ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const oid *" objid ", size_t " objidlen ","
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "                     const netsnmp_variable_list *" variable ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.br
Packit Service b38f0b
.SS Deletion
Packit Service b38f0b
.PP
Packit Service b38f0b
.BI "void snmp_free_var(       netsnmp_variable_list *" variable ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.BI "void snmp_free_varbind( netsnmp_variable_list *" variables ");"
Packit Service b38f0b
.br
Packit Service b38f0b
.PP
Packit Service b38f0b
.SH DESCRIPTION
Packit Service b38f0b
The functions dealing with variable bindings fall into four groups - 
Packit Service b38f0b
dealing with the creation, setting of values, output and deletion of varbinds.
Packit Service b38f0b
.SS Creation
Packit Service b38f0b
.B snmp_pdu_add_variable
Packit Service b38f0b
will create a new varbind structure, initialised with the name (
Packit Service b38f0b
.IR objid ", " objidlen
Packit Service b38f0b
), syntax (
Packit Service b38f0b
.I type
Packit Service b38f0b
) and value (
Packit Service b38f0b
.I value ", " len
Packit Service b38f0b
) provided.
Packit Service b38f0b
This varbind is then added to the end of the varbind list in
Packit Service b38f0b
the given PDU.
Packit Service b38f0b
.PP
Packit Service b38f0b
.B snmp_varlist_add_variable
Packit Service b38f0b
is similar, but appends the new varbind to the end of the
Packit Service b38f0b
varbind list provided.
Packit Service b38f0b
When adding the first varbind to an empty list, simply
Packit Service b38f0b
pass the address of the head of the list:
Packit Service b38f0b
.IP
Packit Service b38f0b
  netsnmp_variable_list *vl = NULL;
Packit Service b38f0b
  snmp_varlist_add_variable(
Packit Service b38f0b
            &vl, name1, name1_len,
Packit Service b38f0b
            ASN_\fITYPE\fP, &val1, val1_len);
Packit Service b38f0b
  snmp_varlist_add_variable(
Packit Service b38f0b
            &vl, name2, name2_len,
Packit Service b38f0b
            ASN_\fITYPE\fP, &val2, val2_len);
Packit Service b38f0b
.PP
Packit Service b38f0b
In both cases, the routine will return a pointer to the new
Packit Service b38f0b
varbind structure (or NULL if the varbind creation fails).
Packit Service b38f0b
.PP
Packit Service b38f0b
.B snmp_add_null_var
Packit Service b38f0b
is a convenience function to add an empty varbind to the PDU.
Packit Service b38f0b
without needing to specify the NULL value explicitly.
Packit Service b38f0b
This is the normal mechanism for constructing a GET (or similar)
Packit Service b38f0b
information retrieval request.
Packit Service b38f0b
.br
Packit Service b38f0b
Again, this returns a pointer to the new varbind, or NULL.
Packit Service b38f0b
.PP
Packit Service b38f0b
.B snmp_clone_varbind
Packit Service b38f0b
creates a copy of each varbind in the specified list,
Packit Service b38f0b
returning a pointer to the head of the new list
Packit Service b38f0b
(or NULL if the cloning fails).
Packit Service b38f0b
.br
Packit Service b38f0b
.SS Setting of values
Packit Service b38f0b
.B snmp_set_var_objid
Packit Service b38f0b
sets the name of the varbind structure to the specified OID.
Packit Service b38f0b
.br
Packit Service b38f0b
.B snmp_set_var_typed_value
Packit Service b38f0b
sets the syntax type and value of the varbind structure.
Packit Service b38f0b
.br
Packit Service b38f0b
.B snmp_set_var_value
Packit Service b38f0b
sets the value of the varbind structure, leaving the syntax type unchanged.
Packit Service b38f0b
.br
Packit Service b38f0b
.B snmp_set_var_typed_integer
Packit Service b38f0b
is a convenience function to set the syntax type and value for
Packit Service b38f0b
a 32-bit integer-based varbind.
Packit Service b38f0b
.PP
Packit Service b38f0b
All four of these return 0 if the assignment is successful,
Packit Service b38f0b
or 1 if it is not.
Packit Service b38f0b
.SS Output
Packit Service b38f0b
.B print_variable
Packit Service b38f0b
will take an object identifier (as returned by
Packit Service b38f0b
.BR read_objid ", " snmp_parse_oid " or " get_module_node )
Packit Service b38f0b
and an instance of such a variable, and prints to the standard output
Packit Service b38f0b
the textual form of the object identifier together with the value
Packit Service b38f0b
of the variable.
Packit Service b38f0b
.PP
Packit Service b38f0b
.B fprint_variable
Packit Service b38f0b
does the same, but prints to the FILE pointer specified by the initial
Packit Service b38f0b
parameter.
Packit Service b38f0b
.PP
Packit Service b38f0b
.B snprint_variable
Packit Service b38f0b
prints the same information into the buffer pointed to by
Packit Service b38f0b
.I buf
Packit Service b38f0b
which is of length
Packit Service b38f0b
.IR len .
Packit Service b38f0b
It returns the number of characters printed, or -1 if the
Packit Service b38f0b
buffer was not large enough.  In the latter case,
Packit Service b38f0b
.I buf
Packit Service b38f0b
will typically contained a truncated version of the information (but
Packit Service b38f0b
this behaviour is not guaranteed).  This function replaces the
Packit Service b38f0b
obsolete function
Packit Service b38f0b
.BR sprint_variable .
Packit Service b38f0b
.PP
Packit Service b38f0b
.BR print_value ,
Packit Service b38f0b
.BR fprint_value ,
Packit Service b38f0b
and
Packit Service b38f0b
.B snprint_value
Packit Service b38f0b
do the same as the equivalent
Packit Service b38f0b
.B print_variable
Packit Service b38f0b
routines, but only displaying the value of the variable, without the
Packit Service b38f0b
corresponding object identifier.
Packit Service b38f0b
.PP
Packit Service b38f0b
For displaying the OID of a varbind, see \fBnetsnmp_mib_api\fP(3).
Packit Service b38f0b
.br
Packit Service b38f0b
.SS Deletion
Packit Service b38f0b
.B snmp_free_var
Packit Service b38f0b
releases all memory used by the given varbind structure.
Packit Service b38f0b
.br
Packit Service b38f0b
.B snmp_free_varbind
Packit Service b38f0b
releases all memory used by each varbind structure in the varbind list provided.
Packit Service b38f0b
.br
Packit Service b38f0b
.SH "SEE ALSO"
Packit Service b38f0b
.BR netsnmp_pdu_api "(3)"
Packit Service b38f0b
.BR netsnmp_mib_api "(3)"