404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.22.27.222: ~ $
.lf 1 stdin
.TH LBER_DECODE 3 "2018/03/22" "OpenLDAP 2.4.46"
.\" $OpenLDAP$
.\" Copyright 1998-2018 The OpenLDAP Foundation All Rights Reserved.
.\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
.SH NAME
ber_get_next, ber_skip_tag, ber_peek_tag, ber_scanf, ber_get_int, ber_get_enum, ber_get_stringb, ber_get_stringa, ber_get_stringal, ber_get_stringbv, ber_get_null, ber_get_boolean, ber_get_bitstring, ber_first_element, ber_next_element \- OpenLDAP LBER simplified Basic Encoding Rules library routines for decoding
.SH LIBRARY
OpenLDAP LBER (liblber, \-llber)
.SH SYNOPSIS
.B #include <lber.h>
.LP
.BI "ber_tag_t ber_get_next(Sockbuf *" sb ", ber_len_t *" len ", BerElement *" ber ");"
.LP
.BI "ber_tag_t ber_skip_tag(BerElement *" ber ", ber_len_t *" len ");"
.LP
.BI "ber_tag_t ber_peek_tag(BerElement *" ber ", ber_len_t *" len ");"
.LP
.BI "ber_tag_t ber_scanf(BerElement *" ber ", const char *" fmt ", ...);"
.LP
.BI "ber_tag_t ber_get_int(BerElement *" ber ", ber_int_t *" num ");"
.LP
.BI "ber_tag_t ber_get_enum(BerElement *" ber ", ber_int_t *" num ");"
.LP
.BI "ber_tag_t ber_get_stringb(BerElement *" ber ", char *" buf ", ber_len_t *" len ");"
.LP
.BI "ber_tag_t ber_get_stringa(BerElement *" ber ", char **" buf ");"
.LP
.BI "ber_tag_t ber_get_stringal(BerElement *" ber ", struct berval **" bv ");"
.LP
.BI "ber_tag_t ber_get_stringbv(BerElement *" ber ", struct berval *" bv ", int " alloc ");"
.LP
.BI "ber_tag_t ber_get_null(BerElement *" ber ");"
.LP
.BI "ber_tag_t ber_get_boolean(BerElement *" ber ", ber_int_t *" bool ");"
.LP
.BI "ber_tag_t ber_get_bitstringa(BerElement *" ber ", char **" buf ", ber_len_t *" blen ");"
.LP
.BI "ber_tag_t ber_first_element(BerElement *" ber ", ber_len_t *" len ", char **" cookie ");"
.LP
.BI "ber_tag_t ber_next_element(BerElement *" ber ", ber_len_t *" len ", const char *" cookie ");"
.SH DESCRIPTION
.LP
These routines provide a subroutine interface to a simplified
implementation of the Basic Encoding Rules of ASN.1.  The version
of BER these routines support is the one defined for the LDAP
protocol.  The encoding rules are the same as BER, except that 
only definite form lengths are used, and bitstrings and octet strings
are always encoded in primitive form.  This man page
describes the decoding routines in the lber library.  See
.BR lber-encode (3)
for details on the corresponding encoding routines.
Consult
.BR lber-types (3)
for information about types, allocators, and deallocators.
.LP
Normally, the only routines that need to be called by an application
are
.BR ber_get_next ()
to get the next BER element and
.BR ber_scanf ()
to do the actual decoding.  In some cases,
.BR ber_peek_tag ()
may also need to be called in normal usage.  The other routines are
provided for those applications that need more control than
.BR ber_scanf ()
provides.  In
general, these routines return the tag of the element decoded, or
LBER_ERROR if an error occurred.
.LP
The
.BR ber_get_next ()
routine is used to read the next BER element from the given Sockbuf,
\fIsb\fP.  It strips off and returns the leading tag, strips off and
returns the length of the entire element in \fIlen\fP, and sets up
\fIber\fP for subsequent calls to 
.BR ber_scanf ()
et al to decode the element. See
.BR lber-sockbuf (3)
for details of the Sockbuf implementation of the \fIsb\fP parameter.
.LP
The
.BR ber_scanf ()
routine is used to decode a BER element in much the same way that
.BR scanf (3)
works.  It reads from \fIber\fP, a pointer to a BerElement
such as returned by
.BR ber_get_next (),
interprets the bytes according to the format string \fIfmt\fP, and stores the
results in its additional arguments.  The format string contains
conversion specifications which are used to direct the interpretation
of the BER element.  The format string can contain the following
characters.
.RS
.LP
.TP 3
.B a
Octet string.  A char ** should be supplied.  Memory is allocated,
filled with the contents of the octet string, null-terminated, and
returned in the parameter.  The caller should free the returned
string using
.BR ber_memfree ().
.TP
.B A
Octet string.  A variant of "\fBa\fP".  A char ** should be supplied.
Memory is allocated, filled with the contents of the octet string, 
null-terminated, and returned in the parameter, unless a zero-length
string would result; in that case, the arg is set to NULL.
The caller should free the returned string using
.BR ber_memfree ().
.TP
.B s
Octet string.  A char * buffer should be supplied, followed by a pointer to a
ber_len_t initialized to the size of the buffer.  Upon return, the
null-terminated octet string is put into the buffer, and the
ber_len_t is set to the actual size of the octet string.
.TP
.B O
Octet string.  A struct ber_val ** should be supplied, which upon
return points to a dynamically allocated struct berval
containing the octet string and its length.
The caller should free the returned structure using
.BR ber_bvfree ().
.TP
.B o
Octet string.  A struct ber_val * should be supplied, which upon
return contains the dynamically allocated
octet string and its length.  The caller should free the returned octet
string using
.BR ber_memfree ().
.TP
.B m
Octet string.  A struct ber_val * should be supplied, which upon return
contains the octet string and its length.  The string resides in memory
assigned to the BerElement, and must not be freed by the caller.
.TP
.B b
Boolean.  A pointer to a ber_int_t should be supplied.
.TP
.B e
Enumeration.  A pointer to a ber_int_t should be supplied.
.TP
.B i
Integer.  A pointer to a ber_int_t should be supplied.
.TP
.B B
Bitstring.  A char ** should be supplied which will point to the
dynamically allocated
bits, followed by a ber_len_t *, which will point to the length
(in bits) of the bitstring returned.
.TP
.B n
Null.  No parameter is required.  The element is simply skipped if
it is recognized.
.TP
.B v
Sequence of octet strings.  A char *** should be supplied, which upon
return points to a dynamically allocated null-terminated array of char *'s
containing the octet strings.  NULL is returned if the sequence is empty.
The caller should free the returned array and octet strings using
.BR ber_memvfree ().
.TP
.B V
Sequence of octet strings with lengths.
A struct berval *** should be supplied, which upon
return points to a dynamically allocated null-terminated array of
struct berval *'s
containing the octet strings and their lengths.
NULL is returned if the sequence is empty.  
The caller should free the returned structures using
.BR ber_bvecfree ().
.TP
.B W
Sequence of octet strings with lengths.
A BerVarray * should be supplied, which upon
return points to a dynamically allocated array of
struct berval's
containing the octet strings and their lengths. The array is terminated
by a struct berval with a NULL bv_val string pointer.
NULL is returned if the sequence is empty.  
The caller should free the returned structures using
.BR ber_bvarray_free ().
.TP
.B M
Sequence of octet strings with lengths.  This is a generalized form
of the previous three formats.
A void ** (ptr) should be supplied, followed by a ber_len_t * (len)
and a ber_len_t (off).
Upon return (ptr) will point to a dynamically allocated array
whose elements are all of size (*len).  A struct berval will be filled
starting at offset (off) in each element.  The strings in each struct
berval reside in memory assigned to the BerElement and must not be
freed by the caller.  The array is terminated by a struct berval
with a NULL bv_val string pointer.  NULL is returned if the sequence
is empty.  The number of elements in the array is also stored
in (*len) on return.  The caller should free the returned array using
.BR ber_memfree ().
.TP
.B l
Length of the next element.  A pointer to a ber_len_t should be supplied.
.TP
.B t
Tag of the next element.  A pointer to a ber_tag_t should be supplied.
.TP
.B T
Skip element and return its tag.  A pointer to a ber_tag_t should be supplied.
.TP
.B x
Skip element.  The next element is skipped.
.TP
.B {
Begin sequence.  No parameter is required.  The initial sequence tag
and length are skipped.
.TP
.B }
End sequence.  No parameter is required and no action is taken.
.TP
.B [
Begin set.  No parameter is required.  The initial set tag
and length are skipped.
.TP
.B ]
End set.  No parameter is required and no action is taken.
.RE
.LP
The
.BR ber_get_int ()
routine tries to interpret the next element as an integer,
returning the result in \fInum\fP.  The tag of whatever it finds is returned
on success, LBER_ERROR (\-1) on failure.
.LP
The
.BR ber_get_stringb ()
routine is used to read an octet string into a
preallocated buffer.  The \fIlen\fP parameter should be initialized to
the size of the buffer, and will contain the length of the octet string
read upon return.  The buffer should be big enough to take the octet
string value plus a terminating NULL byte.
.LP
The
.BR ber_get_stringa ()
routine is used to dynamically allocate space into
which an octet string is read.
The caller should free the returned string using
.BR ber_memfree().
.LP
The
.BR ber_get_stringal ()
routine is used to dynamically allocate space
into which an octet string and its length are read.  It takes a
struct berval **, and returns the result in this parameter.
The caller should free the returned structure using
.BR ber_bvfree().
.LP
The
.BR ber_get_stringbv ()
routine is used to read an octet string and its length into the 
provided struct berval *. If the \fIalloc\fP parameter is zero, the string
will reside in memory assigned to the BerElement, and must not be freed
by the caller. If the \fIalloc\fP parameter is non-zero, the string will be
copied into dynamically allocated space which should be returned using
.BR ber_memfree ().
.LP
The
.BR ber_get_null ()
routine is used to read a NULL element.  It returns
the tag of the element it skips over.
.LP
The
.BR ber_get_boolean ()
routine is used to read a boolean value.  It is called the same way that
.BR ber_get_int ()
is called.
.LP
The
.BR ber_get_enum ()
routine is used to read a enumeration value.  It is called the same way that
.BR ber_get_int ()
is called.
.LP
The
.BR ber_get_bitstringa ()
routine is used to read a bitstring value.  It
takes a char ** which will hold the dynamically allocated bits, followed by an
ber_len_t *, which will point to the length (in bits) of the bitstring returned.
The caller should free the returned string using
.BR ber_memfree ().
.LP
The
.BR ber_first_element ()
routine is used to return the tag and length
of the first element in a set or sequence.  It also returns in \fIcookie\fP
a magic cookie parameter that should be passed to subsequent calls to
ber_next_element(), which returns similar information.
.SH EXAMPLES
Assume the variable \fIber\fP contains a lightweight BER encoding of
the following ASN.1 object:
.LP
.nf
      AlmostASearchRequest := SEQUENCE {
          baseObject      DistinguishedName,
          scope           ENUMERATED {
              baseObject    (0),
              singleLevel   (1),
              wholeSubtree  (2)
          },
          derefAliases    ENUMERATED {
              neverDerefaliases   (0),
              derefInSearching    (1),
              derefFindingBaseObj (2),
              alwaysDerefAliases  (3)
          },
          sizelimit       INTEGER (0 .. 65535),
          timelimit       INTEGER (0 .. 65535),
          attrsOnly       BOOLEAN,
          attributes      SEQUENCE OF AttributeType
      }
.fi
.LP
The element can be decoded using
.BR ber_scanf ()
as follows.
.LP
.nf
      ber_int_t    scope, deref, size, time, attrsonly;
      char   *dn, **attrs;
      ber_tag_t tag;

      tag = ber_scanf( ber, "{aeeiib{v}}",
          &dn, &scope, &deref,
          &size, &time, &attrsonly, &attrs );

      if( tag == LBER_ERROR ) {
              /* error */
      } else {
              /* success */
      }

      ber_memfree( dn );
      ber_memvfree( attrs );
.fi
.SH ERRORS
If an error occurs during decoding, generally these routines return
LBER_ERROR ((ber_tag_t)\-1).
.LP
.SH NOTES
.LP
The return values for all of these functions are declared in the
.B <lber.h>
header file.  Some routines may dynamically allocate memory
which must be freed by the caller using supplied deallocation routines.
.SH SEE ALSO
.BR lber-encode (3),
.BR lber-memory (3),
.BR lber-sockbuf (3),
.BR lber-types (3)
.SH ACKNOWLEDGEMENTS
.lf 1 ./../Project
.\" Shared Project Acknowledgement Text
.B "OpenLDAP Software"
is developed and maintained by The OpenLDAP Project <http://www.openldap.org/>.
.B "OpenLDAP Software"
is derived from the University of Michigan LDAP 3.3 Release.  
.lf 358 stdin

Filemanager

Name Type Size Permission Actions
ber_alloc_t.3 File 9.07 KB 0644
ber_bvarray_add.3 File 6.38 KB 0644
ber_bvarray_free.3 File 6.38 KB 0644
ber_bvdup.3 File 6.38 KB 0644
ber_bvecadd.3 File 6.38 KB 0644
ber_bvecfree.3 File 6.38 KB 0644
ber_bvfree.3 File 6.38 KB 0644
ber_bvstr.3 File 6.38 KB 0644
ber_bvstrdup.3 File 6.38 KB 0644
ber_dupbv.3 File 6.38 KB 0644
ber_first_element.3 File 12.37 KB 0644
ber_flush.3 File 9.07 KB 0644
ber_free.3 File 6.38 KB 0644
ber_get_bitstring.3 File 12.37 KB 0644
ber_get_boolean.3 File 12.37 KB 0644
ber_get_enum.3 File 12.37 KB 0644
ber_get_int.3 File 12.37 KB 0644
ber_get_next.3 File 12.37 KB 0644
ber_get_null.3 File 12.37 KB 0644
ber_get_stringa.3 File 12.37 KB 0644
ber_get_stringb.3 File 12.37 KB 0644
ber_next_element.3 File 12.37 KB 0644
ber_peek_tag.3 File 12.37 KB 0644
ber_printf.3 File 9.07 KB 0644
ber_put_enum.3 File 9.07 KB 0644
ber_put_int.3 File 9.07 KB 0644
ber_put_null.3 File 9.07 KB 0644
ber_put_ostring.3 File 9.07 KB 0644
ber_put_seq.3 File 9.07 KB 0644
ber_put_set.3 File 9.07 KB 0644
ber_put_string.3 File 9.07 KB 0644
ber_scanf.3 File 12.37 KB 0644
ber_skip_tag.3 File 12.37 KB 0644
ber_start_set.3 File 9.07 KB 0644
ber_str2bv.3 File 6.38 KB 0644
lber-decode.3 File 12.37 KB 0644
lber-encode.3 File 9.07 KB 0644
lber-memory.3 File 1.53 KB 0644
lber-sockbuf.3 File 5.72 KB 0644
lber-types.3 File 6.38 KB 0644
ld_errno.3 File 6.54 KB 0644
ldap.3 File 8.83 KB 0644
ldap_abandon.3 File 2.29 KB 0644
ldap_abandon_ext.3 File 2.29 KB 0644
ldap_add.3 File 2.65 KB 0644
ldap_add_ext.3 File 2.65 KB 0644
ldap_add_ext_s.3 File 2.65 KB 0644
ldap_add_s.3 File 2.65 KB 0644
ldap_attributetype2name.3 File 8.78 KB 0644
ldap_attributetype2str.3 File 8.78 KB 0644
ldap_attributetype_free.3 File 8.78 KB 0644
ldap_bind.3 File 11.75 KB 0644
ldap_bind_s.3 File 11.75 KB 0644
ldap_compare.3 File 2.72 KB 0644
ldap_compare_ext.3 File 2.72 KB 0644
ldap_compare_ext_s.3 File 2.72 KB 0644
ldap_compare_s.3 File 2.72 KB 0644
ldap_control_create.3 File 2.93 KB 0644
ldap_control_dup.3 File 2.93 KB 0644
ldap_control_find.3 File 2.93 KB 0644
ldap_control_free.3 File 2.93 KB 0644
ldap_controls.3 File 2.93 KB 0644
ldap_controls_dup.3 File 2.93 KB 0644
ldap_controls_free.3 File 2.93 KB 0644
ldap_count_entries.3 File 2.35 KB 0644
ldap_count_messages.3 File 2.58 KB 0644
ldap_count_references.3 File 2.29 KB 0644
ldap_count_values.3 File 2.73 KB 0644
ldap_count_values_len.3 File 2.73 KB 0644
ldap_dcedn2dn.3 File 6.61 KB 0644
ldap_delete.3 File 2.49 KB 0644
ldap_delete_ext.3 File 2.49 KB 0644
ldap_delete_ext_s.3 File 2.49 KB 0644
ldap_delete_s.3 File 2.49 KB 0644
ldap_destroy.3 File 3.54 KB 0644
ldap_dn2ad_canonical.3 File 6.61 KB 0644
ldap_dn2dcedn.3 File 6.61 KB 0644
ldap_dn2str.3 File 6.61 KB 0644
ldap_dn2ufn.3 File 6.61 KB 0644
ldap_dnfree.3 File 6.61 KB 0644
ldap_dup.3 File 3.54 KB 0644
ldap_err2string.3 File 6.54 KB 0644
ldap_errlist.3 File 6.54 KB 0644
ldap_error.3 File 6.54 KB 0644
ldap_explode_dn.3 File 6.61 KB 0644
ldap_explode_rdn.3 File 6.61 KB 0644
ldap_extended_operation.3 File 2.47 KB 0644
ldap_extended_operation_s.3 File 2.47 KB 0644
ldap_first_attribute.3 File 2.3 KB 0644
ldap_first_entry.3 File 2.35 KB 0644
ldap_first_message.3 File 2.58 KB 0644
ldap_first_reference.3 File 2.29 KB 0644
ldap_free_urldesc.3 File 3.02 KB 0644
ldap_get_dn.3 File 6.61 KB 0644
ldap_get_option.3 File 19.06 KB 0644
ldap_get_values.3 File 2.73 KB 0644
ldap_get_values_len.3 File 2.73 KB 0644
ldap_init.3 File 5.96 KB 0644
ldap_init_fd.3 File 5.96 KB 0644
ldap_initialize.3 File 5.96 KB 0644
ldap_install_tls.3 File 1.66 KB 0644
ldap_is_ldap_url.3 File 3.02 KB 0644
ldap_matchingrule2name.3 File 8.78 KB 0644
ldap_matchingrule2str.3 File 8.78 KB 0644
ldap_matchingrule_free.3 File 8.78 KB 0644
ldap_memalloc.3 File 1.55 KB 0644
ldap_memcalloc.3 File 1.55 KB 0644
ldap_memfree.3 File 1.55 KB 0644
ldap_memory.3 File 1.55 KB 0644
ldap_memrealloc.3 File 1.55 KB 0644
ldap_memvfree.3 File 1.55 KB 0644
ldap_modify.3 File 4.45 KB 0644
ldap_modify_ext.3 File 4.45 KB 0644
ldap_modify_ext_s.3 File 4.45 KB 0644
ldap_modify_s.3 File 4.45 KB 0644
ldap_modrdn.3 File 2.27 KB 0644
ldap_modrdn2.3 File 2.27 KB 0644
ldap_modrdn2_s.3 File 2.27 KB 0644
ldap_modrdn_s.3 File 2.27 KB 0644
ldap_mods_free.3 File 4.45 KB 0644
ldap_msgfree.3 File 4.41 KB 0644
ldap_msgid.3 File 4.41 KB 0644
ldap_msgtype.3 File 4.41 KB 0644
ldap_next_attribute.3 File 2.3 KB 0644
ldap_next_entry.3 File 2.35 KB 0644
ldap_next_message.3 File 2.58 KB 0644
ldap_next_reference.3 File 2.29 KB 0644
ldap_objectclass2name.3 File 8.78 KB 0644
ldap_objectclass2str.3 File 8.78 KB 0644
ldap_objectclass_free.3 File 8.78 KB 0644
ldap_open.3 File 5.96 KB 0644
ldap_parse_extended_result.3 File 3.94 KB 0644
ldap_parse_reference.3 File 2.3 KB 0644
ldap_parse_result.3 File 3.94 KB 0644
ldap_parse_sasl_bind_result.3 File 3.94 KB 0644
ldap_parse_sort_control.3 File 1.64 KB 0644
ldap_parse_vlv_control.3 File 2.29 KB 0644
ldap_perror.3 File 6.54 KB 0644
ldap_rename.3 File 2.63 KB 0644
ldap_rename_s.3 File 2.63 KB 0644
ldap_result.3 File 4.41 KB 0644
ldap_result2error.3 File 6.54 KB 0644
ldap_sasl_bind.3 File 11.75 KB 0644
ldap_sasl_bind_s.3 File 11.75 KB 0644
ldap_schema.3 File 8.78 KB 0644
ldap_scherr2str.3 File 8.78 KB 0644
ldap_search.3 File 5.11 KB 0644
ldap_search_ext.3 File 5.11 KB 0644
ldap_search_ext_s.3 File 5.11 KB 0644
ldap_search_s.3 File 5.11 KB 0644
ldap_search_st.3 File 5.11 KB 0644
ldap_set_option.3 File 19.06 KB 0644
ldap_set_rebind_proc.3 File 11.75 KB 0644
ldap_set_urllist_proc.3 File 5.96 KB 0644
ldap_simple_bind.3 File 11.75 KB 0644
ldap_simple_bind_s.3 File 11.75 KB 0644
ldap_sort.3 File 1.23 KB 0644
ldap_sort_entries.3 File 1.23 KB 0644
ldap_sort_strcasecmp.3 File 1.23 KB 0644
ldap_sort_values.3 File 1.23 KB 0644
ldap_start_tls.3 File 1.66 KB 0644
ldap_start_tls_s.3 File 1.66 KB 0644
ldap_str2attributetype.3 File 8.78 KB 0644
ldap_str2dn.3 File 6.61 KB 0644
ldap_str2matchingrule.3 File 8.78 KB 0644
ldap_str2objectclass.3 File 8.78 KB 0644
ldap_str2syntax.3 File 8.78 KB 0644
ldap_strdup.3 File 1.55 KB 0644
ldap_sync.3 File 9.51 KB 0644
ldap_syntax2name.3 File 8.78 KB 0644
ldap_syntax2str.3 File 8.78 KB 0644
ldap_syntax_free.3 File 8.78 KB 0644
ldap_tls.3 File 1.66 KB 0644
ldap_tls_inplace.3 File 1.66 KB 0644
ldap_unbind.3 File 11.75 KB 0644
ldap_unbind_ext.3 File 11.75 KB 0644
ldap_unbind_ext_s.3 File 11.75 KB 0644
ldap_unbind_s.3 File 11.75 KB 0644
ldap_url.3 File 3.02 KB 0644
ldap_url_parse.3 File 3.02 KB 0644
ldap_value_free.3 File 2.73 KB 0644
ldap_value_free_len.3 File 2.73 KB 0644