octetstring(3snmp)


octetstring: free_octetstring, make_octet_from_hex, make_octetstring, make_octet_from_text, print_ascii, print_octet_string_out -- operations on OctetStrings

Synopsis

#include <snmp/snmp.h>

void free_octetstring(OctetString *os_ptr);

OctetString *make_octet_from_hex(char *hex_string);

OctetString *make_octetstring(char *in_string, long length);

#include <snmp/snmp.h> #include <snmp/snmpuser.h>

OctetString *make_octet_from_text(char *text_string);

short print_ascii(OctetString *octet_ptr);

void print_octet_string_out(OctetString *octet_ptr, long wrap);

Description

free_octetstring frees all memory associated with an OctetString data structure, including the memory allocated to the individual octets.

make_octet_from_hex converts a hex text string into a library format OctetString data structure for use by calls to make_varbind(3snmp) and make_authentication(3snmp). The format of these strings is a hex value (1 or more hex digits, upper or lower case) followed by a space, with more hex values and spaces to complete the string. For example, to create an OctetString of length two with a hex 15 in the first octet and a hex 3D in the second octet, the text string could be ``15 3d'' or ``0x15 0x3D''. The OctetString construct returned by this call can be freed by a call to free_octetstring. Usually, this is unnecessary as the construct is most often passed to another library routine for inclusion in a larger ASN.1 construct, and that library's free counterpart will perform the memory recovery.

make_octetstring produces a library OctetString construct from an input byte string and length. This construct is usually passed to other library calls, such as make_varbind or make_authentication, and linked into a larger library construct of an ASN.1 entity. free_octetstring recovers all memory malloc'ed by make_octetstring, but should not be used if the OctetString is is passed to another library routine. The free_* counterparts to those routines free up all memory that has been linked to the higher level ASN.1 structure.

make_octet_from_text is used to create a library format OctetString data structure for use by calls to make_varbind and make_authentication from text strings.

If an OctetString's value contains only printable characters, print_ascii prints out the value's contents as an ASCII string. It is called with a pointer to the OctetString construct and checks if the string is printable. If it isn't printable, print_ascii returns a -1 value; otherwise it returns 1.

print_octet_string_out prints out the contents of an OctetString's value in hex. It is called with a pointer to the OctetString construct and the number of bytes to display on one line (the variable wrap). This call is used by the print_varbind_list(3snmp) routine to actually print out OctetString values.

References

smux_util(3snmp), snmp_authentication(3snmp), snmp_pdu(3snmp), varbind(3snmp)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004