X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Flber.h;h=df73e6328cbbb29841b526e60f5be6fcb0284c33;hb=d87732558a414d05d92b7e5936f6624da32caaab;hp=77a32fa8915bd3893a4a85d4550089016cdf4e3b;hpb=92b33668023cfea14e5510d9c150ceb4e8319b85;p=openldap diff --git a/include/lber.h b/include/lber.h index 77a32fa891..df73e6328c 100644 --- a/include/lber.h +++ b/include/lber.h @@ -1,16 +1,18 @@ /* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, Redwood City, California, USA +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2010 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP - * Public License. A copy of this license is available at - * http://www.OpenLDAP.org/license.html or in file LICENSE in the - * top-level directory of the distribution. + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . */ -/* Portions - * Copyright (c) 1990 Regents of the University of Michigan. +/* Portions Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -29,9 +31,13 @@ LDAP_BEGIN_DECL -/* Overview of LBER tag construction +/* + * ber_tag_t represents the identifier octets at the beginning of BER + * elements. OpenLDAP treats them as mere big-endian unsigned integers. + * + * Actually the BER identifier octets look like this: * - * Bits + * Bits of 1st octet: * ______ * 8 7 | CLASS * 0 0 = UNIVERSAL @@ -44,16 +50,20 @@ LDAP_BEGIN_DECL * 1 = CONSTRUCTED * ___________ * | 5 ... 1 | TAG-NUMBER + * + * For ASN.1 tag numbers >= 0x1F, TAG-NUMBER above is 0x1F and the next + * BER octets contain the actual ASN.1 tag number: Big-endian, base + * 128, 8.bit = 1 in all but the last octet, minimum number of octets. */ -/* BER classes and mask */ +/* BER classes and mask (in 1st identifier octet) */ #define LBER_CLASS_UNIVERSAL ((ber_tag_t) 0x00U) #define LBER_CLASS_APPLICATION ((ber_tag_t) 0x40U) #define LBER_CLASS_CONTEXT ((ber_tag_t) 0x80U) #define LBER_CLASS_PRIVATE ((ber_tag_t) 0xc0U) #define LBER_CLASS_MASK ((ber_tag_t) 0xc0U) -/* BER encoding type and mask */ +/* BER encoding type and mask (in 1st identifier octet) */ #define LBER_PRIMITIVE ((ber_tag_t) 0x00U) #define LBER_CONSTRUCTED ((ber_tag_t) 0x20U) #define LBER_ENCODING_MASK ((ber_tag_t) 0x20U) @@ -62,13 +72,10 @@ LDAP_BEGIN_DECL #define LBER_MORE_TAG_MASK ((ber_tag_t) 0x80U) /* - * Note that LBER_ERROR and LBER_DEFAULT are values that can never appear - * as valid BER tags, and so it is safe to use them to report errors. In - * fact, any tag for which the following is true is invalid: + * LBER_ERROR and LBER_DEFAULT are values that can never appear + * as valid BER tags, so it is safe to use them to report errors. + * Valid tags have (tag & (ber_tag_t) 0xFF) != 0xFF. */ -#define LBER_INVALID(t) (((t) & (ber_tag_t) 0x080UL) \ - && (((t) & (ber_tag_t) ~ 0x0FF)) - #define LBER_ERROR ((ber_tag_t) -1) #define LBER_DEFAULT ((ber_tag_t) -1) @@ -136,8 +143,12 @@ typedef struct lber_memory_fns { #define LBER_SB_OPT_NEEDS_WRITE 12 #define LBER_SB_OPT_GET_MAX_INCOMING 13 #define LBER_SB_OPT_SET_MAX_INCOMING 14 + +/* Only meaningful ifdef LDAP_PF_LOCAL_SENDMSG */ +#define LBER_SB_OPT_UNGET_BUF 15 + /* Largest option used by the library */ -#define LBER_SB_OPT_OPT_MAX 14 +#define LBER_SB_OPT_OPT_MAX 15 /* LBER IO operations stacking levels */ #define LBER_SBIOD_LEVEL_PROVIDER 10 @@ -150,17 +161,15 @@ typedef struct lber_memory_fns { #define LBER_OPT_SOCKBUF_DEBUG 0x1002 /* on/off values */ -extern char ber_pvt_opt_on; +LBER_V( char ) ber_pvt_opt_on; #define LBER_OPT_ON ((void *) &ber_pvt_opt_on) #define LBER_OPT_OFF ((void *) 0) #define LBER_OPT_SUCCESS (0) #define LBER_OPT_ERROR (-1) -#define LBER_ELEMENT_SIZEOF (256) /* must be >= sizeof(BerElement) */ typedef struct berelement BerElement; typedef struct sockbuf Sockbuf; -typedef struct seqorset Seqorset; typedef struct sockbuf_io Sockbuf_IO; @@ -224,10 +233,6 @@ LBER_F( void ) ber_dump LDAP_P(( BerElement *ber, int inout )); -LBER_F( void ) -ber_sos_dump LDAP_P(( - Seqorset *sos )); - /* * in decode.c: */ @@ -250,6 +255,16 @@ ber_peek_tag LDAP_P(( BerElement *ber, ber_len_t *len )); +LBER_F( ber_tag_t ) +ber_skip_element LDAP_P(( + BerElement *ber, + struct berval *bv )); + +LBER_F( ber_tag_t ) +ber_peek_element LDAP_P(( + LDAP_CONST BerElement *ber, + struct berval *bv )); + LBER_F( ber_tag_t ) ber_get_int LDAP_P(( BerElement *ber, @@ -266,11 +281,18 @@ ber_get_stringb LDAP_P(( char *buf, ber_len_t *len )); +#define LBER_BV_ALLOC 0x01 /* allocate/copy result, otherwise in-place */ +#define LBER_BV_NOTERM 0x02 /* omit NUL-terminator if parsing in-place */ +#define LBER_BV_STRING 0x04 /* fail if berval contains embedded \0 */ +/* LBER_BV_STRING currently accepts a terminating \0 in the berval, because + * Active Directory sends that in at least the diagonsticMessage field. + */ + LBER_F( ber_tag_t ) ber_get_stringbv LDAP_P(( BerElement *ber, struct berval *bv, - int alloc )); + int options )); LBER_F( ber_tag_t ) ber_get_stringa LDAP_P(( @@ -315,9 +337,19 @@ ber_scanf LDAP_P(( LDAP_CONST char *fmt, ... )); +LBER_F( int ) +ber_decode_oid LDAP_P(( + struct berval *in, + struct berval *out )); + /* * in encode.c */ +LBER_F( int ) +ber_encode_oid LDAP_P(( + struct berval *in, + struct berval *out )); + typedef int (*BEREncodeCallback) LDAP_P(( BerElement *ber, void *data )); @@ -400,6 +432,11 @@ ber_printf LDAP_P(( * in io.c: */ +LBER_F( ber_slen_t ) +ber_skip_data LDAP_P(( + BerElement *ber, + ber_len_t len )); + LBER_F( ber_slen_t ) ber_read LDAP_P(( BerElement *ber, @@ -411,7 +448,7 @@ ber_write LDAP_P(( BerElement *ber, LDAP_CONST char *buf, ber_len_t len, - int nosos )); + int zero )); /* nonzero is unsupported from OpenLDAP 2.4.18 */ LBER_F( void ) ber_free LDAP_P(( @@ -422,10 +459,20 @@ LBER_F( void ) ber_free_buf LDAP_P(( BerElement *ber )); LBER_F( int ) -ber_flush LDAP_P(( +ber_flush2 LDAP_P(( Sockbuf *sb, BerElement *ber, int freeit )); +#define LBER_FLUSH_FREE_NEVER (0x0) /* traditional behavior */ +#define LBER_FLUSH_FREE_ON_SUCCESS (0x1) /* traditional behavior */ +#define LBER_FLUSH_FREE_ON_ERROR (0x2) +#define LBER_FLUSH_FREE_ALWAYS (LBER_FLUSH_FREE_ON_SUCCESS|LBER_FLUSH_FREE_ON_ERROR) + +LBER_F( int ) +ber_flush LDAP_P(( + Sockbuf *sb, + BerElement *ber, + int freeit )); /* DEPRECATED */ LBER_F( BerElement * ) ber_alloc LDAP_P(( void )); /* DEPRECATED */ @@ -582,20 +629,32 @@ ber_bvdup LDAP_P(( struct berval *src )); LBER_F( struct berval * ) -ber_str2bv LDAP_P(( - LDAP_CONST char *, ber_len_t len, int dup, struct berval *bv)); +ber_mem2bv LDAP_P(( + LDAP_CONST char *, ber_len_t len, int duplicate, struct berval *bv)); LBER_F( struct berval * ) -ber_mem2bv LDAP_P(( - LDAP_CONST char *, ber_len_t len, int dup, struct berval *bv)); +ber_str2bv LDAP_P(( + LDAP_CONST char *, ber_len_t len, int duplicate, struct berval *bv)); -#define ber_bvstr(a) ber_str2bv(a, 0, 0, NULL) -#define ber_bvstrdup(a) ber_str2bv(a, 0, 1, NULL) +#define ber_bvstr(a) ((ber_str2bv)((a), 0, 0, NULL)) +#define ber_bvstrdup(a) ((ber_str2bv)((a), 0, 1, NULL)) LBER_F( char * ) ber_strdup LDAP_P(( LDAP_CONST char * )); +LBER_F( ber_len_t ) +ber_strnlen LDAP_P(( + LDAP_CONST char *s, ber_len_t len )); + +LBER_F( char * ) +ber_strndup LDAP_P(( + LDAP_CONST char *s, ber_len_t l )); + +LBER_F( struct berval * ) +ber_bvreplace LDAP_P(( + struct berval *dst, LDAP_CONST struct berval *src )); + LBER_F( void ) ber_bvarray_free LDAP_P(( BerVarray p ));