1NETSNMP_VARBIND_API(3)             Net-SNMP             NETSNMP_VARBIND_API(3)
2
3
4

NAME

6       snmp_pdu_add_variable,   snmp_varlist_add_variable,  snmp_add_null_var,
7       snmp_clone_varbind,       snmp_set_var_objid,       snmp_set_var_value,
8       snmp_set_var_typed_value,  snmp_set_var_typed_integer,  print_variable,
9       fprint_variable,    snprint_variable,    print_value,     fprint_value,
10       snprint_value,  snmp_free_var,  snmp_free_varbind - netsnmp_varbind_api
11       functions
12

SYNOPSIS

14       #include <net-snmp/varbind_api.h>
15
16   Creation
17       netsnmp_variable_list *snmp_pdu_add_variable(
18                            netsnmp_pdu *pdu,
19                            const oid *objid, size_t objidlen,
20                            u_char type, const void *value, size_t len);
21       netsnmp_variable_list *snmp_varlist_add_variable(
22                            netsnmp_variable_list *varlist,
23                            const oid *objid, size_t objidlen,
24                            u_char type, const void *value, size_t len);
25       netsnmp_variable_list *snmp_add_null_var(
26                            netsnmp_pdu *pdu,
27                            const oid *objid, size_t objidlen);
28
29       netsnmp_variable_list *snmp_clone_varbind(
30                            netsnmp_variable_list *varlist);
31
32   Setting Values
33       int  snmp_set_var_objid( netsnmp_variable_list* variable,
34                            const oid * objid, size_t objidlen);
35       int  snmp_set_var_value( netsnmp_variable_list* variable,
36                            const void * value, size_t vallen);
37       int  snmp_set_var_typed_value( netsnmp_variable_list* variable,
38                            u_char type,
39                            const void * value, size_t vallen);
40       int  snmp_set_var_typed_integer( netsnmp_variable_list* variable,
41                            u_char type, long value);
42
43   Output
44       void  print_variable(const oid *objid, size_t objidlen,
45                            const netsnmp_variable_list *variable);
46       void fprint_variable(FILE *fp,
47                            const oid *objid, size_t objidlen,
48                            const netsnmp_variable_list *variable);
49       int snprint_variable(char *buf, size_t len,
50                            const oid *objid, size_t objidlen,
51                            const netsnmp_variable_list *variable);
52
53       void  print_value(const oid *objid, size_t objidlen,
54                            const netsnmp_variable_list *variable);
55       void fprint_value(FILE *fp,
56                            const oid *objid, size_t objidlen,
57                            const netsnmp_variable_list *variable);
58       int snprint_value(char *buf, size_t len,
59                            const oid *objid, size_t objidlen,
60                            const netsnmp_variable_list *variable);
61
62   Deletion
63       void snmp_free_var(       netsnmp_variable_list *variable);
64       void snmp_free_varbind( netsnmp_variable_list *variables);
65

DESCRIPTION

67       The functions dealing with variable bindings fall into  four  groups  -
68       dealing  with  the  creation, setting of values, output and deletion of
69       varbinds.
70
71   Creation
72       snmp_pdu_add_variable will create a new varbind structure,  initialised
73       with  the name ( objid, objidlen ), syntax ( type ) and value ( value ,
74       len ) provided.  This varbind is then added to the end of  the  varbind
75       list in the given PDU.
76
77       snmp_varlist_add_variable  is  similar,  but appends the new varbind to
78       the end of the varbind list provided.  When adding the first varbind to
79       an empty list, simply pass the address of the head of the list:
80
81                netsnmp_variable_list *vl = NULL;
82                snmp_varlist_add_variable(
83                          &vl, name1, name1_len,
84                          ASN_TYPE, &val1, val1_len);
85                snmp_varlist_add_variable(
86                          &vl, name2, name2_len,
87                          ASN_TYPE, &val2, val2_len);
88
89       In  both  cases,  the  routine will return a pointer to the new varbind
90       structure (or NULL if the varbind creation fails).
91
92       snmp_add_null_var is a convenience function to add an empty varbind  to
93       the  PDU.   without needing to specify the NULL value explicitly.  This
94       is the normal mechanism for constructing a GET (or similar) information
95       retrieval request.
96       Again, this returns a pointer to the new varbind, or NULL.
97
98       snmp_clone_varbind  creates  a  copy  of  each varbind in the specified
99       list, returning a pointer to the head of the new list (or NULL  if  the
100       cloning fails).
101
102   Setting of values
103       snmp_set_var_objid sets the name of the varbind structure to the speci‐
104       fied OID.
105       snmp_set_var_typed_value sets the syntax type and value of the  varbind
106       structure.
107       snmp_set_var_value sets the value of the varbind structure, leaving the
108       syntax type unchanged.
109       snmp_set_var_typed_integer is a convenience function to set the  syntax
110       type and value for a 32-bit integer-based varbind.
111
112       All  four of these return 0 if the assignment is successful, or 1 if it
113       is not.
114
115   Output
116       print_variable will take an object identifier (as returned by  read_ob‐
117       jid, snmp_parse_oid or get_module_node) and an instance of such a vari‐
118       able, and prints to the standard output the textual form of the  object
119       identifier together with the value of the variable.
120
121       fprint_variable does the same, but prints to the FILE pointer specified
122       by the initial parameter.
123
124       snprint_variable prints the same information into the buffer pointed to
125       by  buf  which  is  of length len.  It returns the number of characters
126       printed, or -1 if the buffer was not large enough.  In the latter case,
127       buf  will  typically  contained  a truncated version of the information
128       (but this behaviour is not guaranteed).  This function replaces the ob‐
129       solete function sprint_variable.
130
131       print_value, fprint_value, and snprint_value do the same as the equiva‐
132       lent print_variable routines, but only  displaying  the  value  of  the
133       variable, without the corresponding object identifier.
134
135       For displaying the OID of a varbind, see netsnmp_mib_api(3).
136
137   Deletion
138       snmp_free_var releases all memory used by the given varbind structure.
139       snmp_free_varbind releases all memory used by each varbind structure in
140       the varbind list provided.
141

SEE ALSO

143       netsnmp_pdu_api(3) netsnmp_mib_api(3)
144
145
146
147V5.9.1                            13 Aug 2010           NETSNMP_VARBIND_API(3)
Impressum