snmp_authentication(3N) snmp_authentication(3N)
NAME
snmp_authentication - SNMP authentication operations.
SYNOPSIS
#include <snmp/snmp.h>
short build_authentication(auth_ptr, pdu_ptr); AuthHeader
*auth_ptr; /* pointer to Authentication header
returned by make_authentication */
PDU *pdu_ptr; /* pointer to PDU structure
returned by by make_pdu */
void free_authentication(auth_ptr); AuthHeader *auth_ptr;
AuthHeader *make_authentication(community_ptr); OctetString
*community_ptr; /* usually made by
make_octet_from_text */
AuthHeader *parse_authentication(packet, packet_len); unsigned
char *packet; /* pointer to inbound SNMP packet */ long
packet_len; /* length of packet */
#include <snmp/snmp.h> #include <snmp/snmpuser.h>
void print_packet_out(packet, length) unsigned char
*packet; /* buffer to be displayed */ long
length; /* length of buffer */
DESCRIPTION
build_authentication takes the PDU and the authentication
information and from them builds the actual SNMP packet in the
authentication data structure's packlet octet string area.
auth_ptr->packlet->octet_ptr points to the packet and
auth_ptr->packlet->length contains the packet's length. This
packlet is freed when free_authentication(3) is called, so it
should be copied (using bcopy; see bstring(3)) to a holding
area; alternatively, the authentication should not be freed
until the packet is actually sent. Once this has been done,
the authentication can be freed with a call to
free_authentication(3).
free_authentication frees all memory associated with a trivial
authentication header data structure, including the actual
SNMP packet that build_authentication(3) creates and the octet
string associated with make_authentication(3). The PDU
structure pointed to by the pdu_ptr passed to make-
Copyright 1994 Novell, Inc. Page 1
snmp_authentication(3N) snmp_authentication(3N)
authentication(3) is NOT touched.
make_authentication is used to create a library format
authentication header data structure for use by
build_authentication(3). This particular implementation of
the library creates an authentication header based on the
trivial authentication put forth by RFC 1098, which calls for
a community octet string usually based on text. The header
and the octet string associated with the header are freed when
free_authentication(3) is called with the authentication
pointer.
parse_authentication is used to create a library format
authentication header data structure from an incoming SNMP
packet. If parsing errors occur, a message is output to
standard error and the routine returns NULL. Otherwise, the
community_ptr part of the structure should be checked for
authentication and the pointer passed on to parse_pdu(3) for
further ASN.1 parsing. It should be noted that the state of
the authentication header created during the building phase
after a call to build_authentication(3) is nearly symmetrical
to the state of the authentication header after this call on
the parsing side.
print_packet_out prints out the contents of a buffer, in hex
at 20 bytes per line. It is called with a pointer to the
buffer to be displayed and the number of buffer bytes to be
displayed. This call is frequently used in debugging code to
display the actual SNMP message that has been received; this
allows hand parsing of the message. It is generally
unsuitable for a production user interface.
SEE ALSO
octetstring(3N), varbind(3N), snmp_pdu(3N).
Copyright 1994 Novell, Inc. Page 2