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

NAME

6       snmp_pdu_add_var,        snmp_varlist_add_var,       snmp_add_null_var,
7       snmp_clone_varbind, snmp_free_varbind,  snmp_free_var,  print_variable,
8       fprint_variable,     snprint_variable,    print_value,    fprint_value,
9       snprint_value - varbind_api functions
10

SYNOPSIS

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

DESCRIPTION

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

SEE ALSO

133       pdu_api(3) mib_api(3)
134
135
136
1374.2 Berkeley Distribution         20 Apr 2009                   VARBIND_API(3)
Impressum