---
name: "netsnmp_mib_utilities"
section: "3snmp"
platform: "linux"
package: "libsnmp-dev"
version: "5.4.3~dfsg-2.8+deb7u1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/netsnmp_mib_utilities"
---

# netsnmp\_mib\_utilities(3snmp)

the Net-SNMP mib parsing and datatype manipulation routines.

## NAME

netsnmp\_mib\_utilities - the Net-SNMP mib parsing and datatype manipulation routines.

### Data Structures

struct **\_PrefixList**\
 struct **parse\_hints**\

### Typedefs

typedef struct **\_PrefixList** \* **PrefixListPtr**\
 typedef struct **\_PrefixList** **PrefixList**\

### Enumerations

enum **inet\_address\_type** { **IPV4** =  1, **IPV6** =  2, **IPV4Z** =  3, **IPV6Z** =  4, **DNS** =  16 }\

### Functions

int **\_sprint\_hexstring\_line** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const u\_char \*cp, size\_t line\_len)\
 *Prints a hexadecimal string into a buffer.*  int **sprint\_realloc\_hexstring** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const u\_char \*cp, size\_t len)\
 int **sprint\_realloc\_asciistring** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const u\_char \*cp, size\_t len)\
 *Prints an ascii string into a buffer.*  int **sprint\_realloc\_octet\_string** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints an octet string into a buffer.*  int **sprint\_realloc\_counter64** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints a counter into a buffer.*  int **sprint\_realloc\_opaque** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints an object identifier into a buffer.*  int **sprint\_realloc\_object\_identifier** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints an object identifier into a buffer.*  int **sprint\_realloc\_timeticks** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints a timetick* **variable** *into a buffer.*  int **sprint\_realloc\_hinted\_integer** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, long val, const char decimaltype, const char \*hint, const char \*units)\
 *Prints an integer according to the hint into a buffer.*  int **sprint\_realloc\_integer** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints an integer into a buffer.*  int **sprint\_realloc\_uinteger** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints an unsigned integer into a buffer.*  int **sprint\_realloc\_gauge** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints a gauge value into a buffer.*  int **sprint\_realloc\_counter** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints a counter value into a buffer.*  int **sprint\_realloc\_networkaddress** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints a network address into a buffer.*  int **sprint\_realloc\_ipaddress** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints an ip-address into a buffer.*  int **sprint\_realloc\_null** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints a null value into a buffer.*  int **sprint\_realloc\_bitstring** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Prints a bit string into a buffer.*  int **sprint\_realloc\_nsapaddress** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **sprint\_realloc\_badtype** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Fallback routine for a bad type, prints 'Variable has bad type' into a buffer.*  int **sprint\_realloc\_by\_type** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 *Universal print routine, prints a* **variable** *into a buffer according to the* **variable** *type.*  struct **tree** \* **get\_tree\_head** (void)\
 *Retrieves the* **tree** *head.*  char \* **snmp\_out\_toggle\_options** (char \*options)\
 void **snmp\_out\_toggle\_options\_usage** (const char \*lead, FILE \*outf)\
 char \* **snmp\_in\_options** (char \*optarg, int argc, char \*const \*argv)\
 char \* **snmp\_in\_toggle\_options** (char \*options)\
 void **snmp\_in\_toggle\_options\_usage** (const char \*lead, FILE \*outf)\
 *Prints out a help usage for the in\* toggle options.*  void **register\_mib\_handlers** (void)\
 void **netsnmp\_set\_mib\_directory** (const char \*dir)\
 char \* **netsnmp\_get\_mib\_directory** (void)\
 void **netsnmp\_fixup\_mib\_directory** (void)\
 void **netsnmp\_init\_mib** (void)\
 *Initialises the mib reader.*  void **init\_mib** (void)\
 void **shutdown\_mib** (void)\
 *Unloads all mibs.*  void **print\_mib** (FILE \*fp)\
 *Prints the MIBs to the file fp.*  void **print\_ascii\_dump** (FILE \*fp)\
 void **set\_function** (struct **tree** \*subtree)\
 *Set's the printing function printomat in a subtree according it's type.*  int **read\_objid** (const char \*input, oid \*output, size\_t \*out\_len)\
 *Reads an object identifier from an input string into internal OID form.*  void **netsnmp\_sprint\_realloc\_objid** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, int \*buf\_overflow, const oid \*objid, size\_t objidlen)\
 struct **tree** \* **netsnmp\_sprint\_realloc\_objid\_tree** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, int \*buf\_overflow, const oid \*objid, size\_t objidlen)\
 int **sprint\_realloc\_objid** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const oid \*objid, size\_t objidlen)\
 int **snprint\_objid** (char \*buf, size\_t buf\_len, const oid \*objid, size\_t objidlen)\
 void **print\_objid** (const oid \*objid, size\_t objidlen)\
 *Prints an oid to stdout.*  void **fprint\_objid** (FILE \*f, const oid \*objid, size\_t objidlen)\
 *Prints an oid to a file descriptor.*  int **sprint\_realloc\_variable** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const oid \*objid, size\_t objidlen, const **netsnmp\_variable\_list** \***variable**)\
 int **snprint\_variable** (char \*buf, size\_t buf\_len, const oid \*objid, size\_t objidlen, const **netsnmp\_variable\_list** \***variable**)\
 void **print\_variable** (const oid \*objid, size\_t objidlen, const **netsnmp\_variable\_list** \***variable**)\
 *Prints a* **variable** *to stdout.*  void **fprint\_variable** (FILE \*f, const oid \*objid, size\_t objidlen, const **netsnmp\_variable\_list** \***variable**)\
 *Prints a* **variable** *to a file descriptor.*  int **sprint\_realloc\_value** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, const oid \*objid, size\_t objidlen, const **netsnmp\_variable\_list** \***variable**)\
 int **snprint\_value** (char \*buf, size\_t buf\_len, const oid \*objid, size\_t objidlen, const **netsnmp\_variable\_list** \***variable**)\
 void **print\_value** (const oid \*objid, size\_t objidlen, const **netsnmp\_variable\_list** \***variable**)\
 void **fprint\_value** (FILE \*f, const oid \*objid, size\_t objidlen, const **netsnmp\_variable\_list** \***variable**)\
 int **build\_oid\_segment** (**netsnmp\_variable\_list** \*var)\
 *Takes the value in VAR and turns it into an OID segment in var-\>name.*  int **build\_oid\_noalloc** (oid \*in, size\_t in\_len, size\_t \*out\_len, oid \*prefix, size\_t prefix\_len, **netsnmp\_variable\_list** \*indexes)\
 int **build\_oid** (oid \*\*out, size\_t \*out\_len, oid \*prefix, size\_t prefix\_len, **netsnmp\_variable\_list** \*indexes)\
 int **parse\_oid\_indexes** (oid \*oidIndex, size\_t oidLen, **netsnmp\_variable\_list** \*data)\
 int **parse\_one\_oid\_index** (oid \*\*oidStart, size\_t \*oidLen, **netsnmp\_variable\_list** \*data, int complete)\
 int **dump\_realloc\_oid\_to\_inetaddress** (const int addr\_type, const oid \*objid, size\_t objidlen, u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, char quotechar)\
 int **dump\_realloc\_oid\_to\_string** (const oid \*objid, size\_t objidlen, u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, char quotechar)\
 struct **tree** \* **get\_tree** (const oid \*objid, size\_t objidlen, struct **tree** \*subtree)\
 void **print\_description** (oid \*objid, size\_t objidlen, int width)\
 *Prints on oid description on stdout.*  void **fprint\_description** (FILE \*f, oid \*objid, size\_t objidlen, int width)\
 *Prints on oid description into a file descriptor.*  int **snprint\_description** (char \*buf, size\_t buf\_len, oid \*objid, size\_t objidlen, int width)\
 int **sprint\_realloc\_description** (u\_char \*\*buf, size\_t \*buf\_len, size\_t \*out\_len, int allow\_realloc, oid \*objid, size\_t objidlen, int width)\
 int **get\_module\_node** (const char \*fname, const char \***module**, oid \*objid, size\_t \*objidlen)\
 int **get\_wild\_node** (const char \*name, oid \*objid, size\_t \*objidlen)\
 int **get\_node** (const char \*name, oid \*objid, size\_t \*objidlen)\
 void **clear\_tree\_flags** (register struct **tree** \*tp)\
 void **print\_oid\_report** (FILE \*fp)\
 void **print\_oid\_report\_enable\_labeledoid** (void)\
 void **print\_oid\_report\_enable\_oid** (void)\
 void **print\_oid\_report\_enable\_suffix** (void)\
 void **print\_oid\_report\_enable\_symbolic** (void)\
 void **print\_oid\_report\_enable\_mibchildoid** (void)\
 char \* **uptime\_string** (u\_long timeticks, char \*buf)\
 *Converts timeticks to hours, minutes, seconds string.*  char \* **uptime\_string\_n** (u\_long timeticks, char \*buf, size\_t buflen)\
 oid \* **snmp\_parse\_oid** (const char \*argv, oid \*root, size\_t \*rootlen)\
 *Given a string, parses an oid out of it (if possible).*  const char \* **parse\_octet\_hint** (const char \*hint, const char \*value, unsigned char \*\*new\_val, int \*new\_val\_len)\
 u\_char **mib\_to\_asn\_type** (int mib\_type)\
 int **netsnmp\_str2oid** (const char \*S, oid \*O, int L)\
 *Converts a string to its OID form.*  int **netsnmp\_oid2chars** (char \*C, int L, const oid \*O)\
 *Converts an OID to its character form.*  int **netsnmp\_oid2str** (char \*S, int L, oid \*O)\
 *Converts an OID to its string form.*  int **snprint\_by\_type** (char \*buf, size\_t buf\_len, **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_hexstring** (char \*buf, size\_t buf\_len, const u\_char \*cp, size\_t len)\
 int **snprint\_asciistring** (char \*buf, size\_t buf\_len, const u\_char \*cp, size\_t len)\
 int **snprint\_octet\_string** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_opaque** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_object\_identifier** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_timeticks** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_hinted\_integer** (char \*buf, size\_t buf\_len, long val, const char \*hint, const char \*units)\
 int **snprint\_integer** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_uinteger** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_gauge** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_counter** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_networkaddress** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_ipaddress** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_null** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_bitstring** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_nsapaddress** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_counter64** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\
 int **snprint\_badtype** (char \*buf, size\_t buf\_len, const **netsnmp\_variable\_list** \*var, const struct **enum\_list** \*enums, const char \*hint, const char \*units)\

### Variables

struct **tree** \* **tree\_head**\
 struct **tree** \* **Mib**\
 oid **RFC1213\_MIB** \[\] = { 1, 3, 6, 1, 2, 1 }\
 **PrefixList** **mib\_prefixes** \[\]\

## Function Documentation

### int \_sprint\_hexstring\_line (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const u\_char \* cp, size\_t line\_len)

Prints a hexadecimal string into a buffer. The characters pointed by \*cp are encoded as hexadecimal string.

If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)

**Parameters:**

*buf* address of the buffer to print to. \
 *buf\_len* address to an integer containing the size of buf. \
 *out\_len* incremented by the number of characters printed. \
 *allow\_realloc* if not zero reallocate the buffer to fit the needed size. \
 *cp* the array of characters to encode. \
 *line\_len* the array length of cp.

**Returns:**

1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)

Definition at line 271 of file mib.c.

### int build\_oid (oid \*\* out, size\_t \* out\_len, oid \* prefix, size\_t prefix\_len, netsnmp\_variable\_list \* indexes)

xxx-rks: should free previous value?

Definition at line 3581 of file mib.c.

### int build\_oid\_segment (netsnmp\_variable\_list \* var)

Takes the value in VAR and turns it into an OID segment in var-\>name. **Parameters:**

*var* The **variable**.

**Returns:**

SNMPERR\_SUCCESS or SNMPERR\_GENERR

Definition at line 3445 of file mib.c.

### void fprint\_description (FILE \* f, oid \* objid, size\_t objidlen, int width)

Prints on oid description into a file descriptor. **Parameters:**

*f* The file descriptor to print to. \
 *objid* The object identifier. \
 *objidlen* The object id length. \
 *width* Number of subidentifiers.

Definition at line 4451 of file mib.c.

### void fprint\_objid (FILE \* f, const oid \* objid, size\_t objidlen)

Prints an oid to a file descriptor. **Parameters:**

*f* The file descriptor to print to. \
 *objid* The oid to print \
 *objidlen* The length of oidid.

Definition at line 3164 of file mib.c.

### void fprint\_variable (FILE \* f, const oid \* objid, size\_t objidlen, const netsnmp\_variable\_list \* variable)

Prints a **variable** to a file descriptor. **Parameters:**

*f* The file descriptor to print to. \
 *objid* The object id. \
 *objidlen* The length of teh object id. \
 **variable The variable to print.**

**Definition at line 3318 of file mib.c.**

### struct tree\* get\_tree\_head (void)` [read]`

**Retrieves the tree head. Returns:**

**the tree head.**

**Definition at line 2017 of file mib.c.**

### int get\_wild\_node (const char \* name, oid \* objid, size\_t \* objidlen) See also:

**comments on find\_best\_tree\_node for usage after first time.**

**Definition at line 5490 of file mib.c.**

### void netsnmp\_fixup\_mib\_directory (void)

**swap in the new value and repeat**

**Definition at line 2480 of file mib.c.**

### char\* netsnmp\_get\_mib\_directory (void)

**Check if the environment variable is set**

**Not set use hard coded path**

**Definition at line 2433 of file mib.c.**

### void netsnmp\_init\_mib (void)

**Initialises the mib reader. Reads in all settings from the environment.**

**Definition at line 2527 of file mib.c.**

### int netsnmp\_oid2chars (char \* C, int L, const oid \* O)

**Converts an OID to its character form. in example 5 . 1 . 2 . 3 . 4 . 5 = 12345**

**Parameters:**

*C* **The character buffer.** \
 *L* **The length of the buffer.** \
 *O* **The oid.**

**Returns:**

**0 on Sucess, 1 on failure.**

**length**

**Definition at line 6277 of file mib.c.**

### int netsnmp\_oid2str (char \* S, int L, oid \* O)

**Converts an OID to its string form. in example 5 . 'h' . 'e' . 'l' . 'l' . 'o' = 'hello\\0' (null terminated)**

**Parameters:**

*S* **The character string buffer.** \
 *L* **The length of the string buffer.** \
 *O* **The oid.**

**Returns:**

**0 on Sucess, 1 on failure.**

**Definition at line 6305 of file mib.c.**

### void netsnmp\_set\_mib\_directory (const char \* dir)

**New dir starts with '+', thus we add it.**

**If dir starts with '+' skip '+' it.**

**set\_string calls strdup, so if we allocated memory, free it**

**Definition at line 2378 of file mib.c.**

### int netsnmp\_str2oid (const char \* S, oid \* O, int L)

**Converts a string to its OID form. in example 'hello' = 5 . 'h' . 'e' . 'l' . 'l' . 'o'**

**Parameters:**

*S* **The string.** \
 *O* **The oid.** \
 *L* **The length of the oid.**

**Returns:**

**0 on Sucess, 1 on failure.**

**Definition at line 6242 of file mib.c.**

### void print\_description (oid \* objid, size\_t objidlen, int width)

**Prints on oid description on stdout. See also:**

**fprint\_description**

**Definition at line 4435 of file mib.c.**

### void print\_mib (FILE \* fp)

**Prints the MIBs to the file fp. Parameters:**

*fp* **The file descriptor to print to.**

**Definition at line 2742 of file mib.c.**

### void print\_objid (const oid \* objid, size\_t objidlen)

**Prints an oid to stdout. Parameters:**

*objid* **The oid to print** \
 *objidlen* **The length of oidid.**

**Definition at line 3150 of file mib.c.**

### void print\_variable (const oid \* objid, size\_t objidlen, const netsnmp\_variable\_list \* variable)

**Prints a variable to stdout. Parameters:**

*objid* **The object id.** \
 *objidlen* **The length of teh object id.** \
 **variable The variable to print.**

**Definition at line 3302 of file mib.c.**

### int read\_objid (const char \* input, oid \* output, size\_t \* out\_len)

**Reads an object identifier from an input string into internal OID form. When called, out\_len must hold the maximum length of the output array.**

**Parameters:**

*input* **the input string.** \
 *output* **the oid wirte.** \
 *out\_len* **number of subid's in output.**

**Returns:**

**1 if successful.**

**If an error occurs, this function returns 0 and MAY set snmp\_errno. snmp\_errno is NOT set if SET\_SNMP\_ERROR evaluates to nothing. This can make multi-threaded use a tiny bit more robust.**

**Definition at line 2840 of file mib.c.**

### void set\_function (struct tree \* subtree)

**Set's the printing function printomat in a subtree according it's type. Parameters:**

*subtree* **The subtree to set.**

**Definition at line 2763 of file mib.c.**

### void shutdown\_mib (void)

**Unloads all mibs.**

**Definition at line 2717 of file mib.c.**

### void snmp\_in\_toggle\_options\_usage (const char \* lead, FILE \* outf)

**Prints out a help usage for the in\* toggle options. Parameters:**

*lead* **The lead to print for every line.** \
 *outf* **The file descriptor to write to.**

**Definition at line 2290 of file mib.c.**

### oid\* snmp\_parse\_oid (const char \* argv, oid \* root, size\_t \* rootlen)

**Given a string, parses an oid out of it (if possible). It will try to parse it based on predetermined configuration if present or by every method possible otherwise. If a suffix has been registered using NETSNMP\_DS\_LIB\_OIDSUFFIX, it will be appended to the input string before processing.**

**Parameters:**

*argv* **The OID to string parse** \
 *root* **An OID array where the results are stored.** \
 *rootlen* **The max length of the array going in and the data length coming out.**

**Returns:**

**The root oid pointer if successful, or NULL otherwise.**

**Definition at line 5848 of file mib.c.**

### int sprint\_realloc\_asciistring (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const u\_char \* cp, size\_t len)

**Prints an ascii string into a buffer. The characters pointed by \*cp are encoded as an ascii string.**

**If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **address of the buffer to print to.** \
 *buf\_len* **address to an integer containing the size of buf.** \
 *out\_len* **incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *cp* **the array of characters to encode.** \
 *len* **the array length of cp.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 367 of file mib.c.**

### int sprint\_realloc\_badtype (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Fallback routine for a bad type, prints 'Variable has bad type' into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1902 of file mib.c.**

### int sprint\_realloc\_bitstring (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints a bit string into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1763 of file mib.c.**

### int sprint\_realloc\_by\_type (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Universal print routine, prints a variable into a buffer according to the variable type. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1937 of file mib.c.**

### int sprint\_realloc\_counter (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints a counter value into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1530 of file mib.c.**

### int sprint\_realloc\_counter64 (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints a counter into a buffer. The variable var is encoded as a counter value.**

**If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 846 of file mib.c.**

### int sprint\_realloc\_gauge (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints a gauge value into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1457 of file mib.c.**

### int sprint\_realloc\_hinted\_integer (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, long val, const char decimaltype, const char \* hint, const char \* units)

**Prints an integer according to the hint into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *val* **The variable to encode.** \
 *decimaltype* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may \_NOT\_ be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1183 of file mib.c.**

### int sprint\_realloc\_integer (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints an integer into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1257 of file mib.c.**

### int sprint\_realloc\_ipaddress (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints an ip-address into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1659 of file mib.c.**

### int sprint\_realloc\_networkaddress (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints a network address into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1593 of file mib.c.**

### int sprint\_realloc\_null (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints a null value into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1719 of file mib.c.**

### int sprint\_realloc\_object\_identifier (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints an object identifier into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1039 of file mib.c.**

### int sprint\_realloc\_octet\_string (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints an octet string into a buffer. The variable var is encoded as octet string.**

**If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 427 of file mib.c.**

### int sprint\_realloc\_opaque (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints an object identifier into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 949 of file mib.c.**

### int sprint\_realloc\_timeticks (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints a timetick variable into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1109 of file mib.c.**

### int sprint\_realloc\_uinteger (u\_char \*\* buf, size\_t \* buf\_len, size\_t \* out\_len, int allow\_realloc, const netsnmp\_variable\_list \* var, const struct enum\_list \* enums, const char \* hint, const char \* units)

**Prints an unsigned integer into a buffer. If allow\_realloc is true the buffer will be (re)allocated to fit in the needed size. (Note: \*buf may change due to this.)**

**Parameters:**

*buf* **Address of the buffer to print to.** \
 *buf\_len* **Address to an integer containing the size of buf.** \
 *out\_len* **Incremented by the number of characters printed.** \
 *allow\_realloc* **if not zero reallocate the buffer to fit the needed size.** \
 *var* **The variable to encode.** \
 *enums* **The enumeration ff this variable is enumerated. may be NULL.** \
 *hint* **Contents of the DISPLAY-HINT clause of the MIB. See RFC 1903 Section 3.1 for details. may be NULL.** \
 *units* **Contents of the UNITS clause of the MIB. may be NULL.**

**Returns:**

**1 on success, or 0 on failure (out of memory, or buffer to small when not allowed to realloc.)**

**Definition at line 1360 of file mib.c.**

### char\* uptime\_string (u\_long timeticks, char \* buf)

**Converts timeticks to hours, minutes, seconds string. CMU compatible does not show centiseconds.**

**Parameters:**

*timeticks* **The timeticks to convert.** \
 *buf* **Buffer to write to, has to be at least 40 Bytes large.**

**Returns:**

**The buffer**

**See also:**

**uptimeString**

**Definition at line 5813 of file mib.c.**

## Variable Documentation

### PrefixList mib\_prefixes\[\] Initial value:

```
 {
    {&Standard_Prefix[0]},
    {'.iso.org.dod.internet.mgmt.mib-2'},
    {'.iso.org.dod.internet.experimental'},
    {'.iso.org.dod.internet.private'},
    {'.iso.org.dod.internet.snmpParties'},
    {'.iso.org.dod.internet.snmpSecrets'},
    {NULL, 0}
}
```

**Definition at line 160 of file mib.c.**

## Author

**Generated automatically by Doxygen for net-snmp from the source code.**
