/* $OpenLDAP$ */
/*
- * Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* Portions
LDAP_BEGIN_DECL
-LIBLBER_F (BER_ERRNO_FN) ber_int_errno_fn;
+LBER_F (BER_ERRNO_FN) ber_int_errno_fn;
struct lber_options {
short lbo_valid;
+ unsigned short lbo_options;
+ int lbo_debug;
+ long lbo_meminuse;
+};
+
+#ifdef NEW_LOGGING
+# ifdef LDAP_DEBUG
+# ifdef LDAP_LOG
+# undef LDAP_LOG
+# endif
+# define LDAP_LOG(a) ber_pvt_log_output a
+# define BER_DUMP(a) ber_output_dump a
+# else
+# define LDAP_LOG(a)
+# define BER_DUMP(a)
+# endif
+#endif
+
#define LBER_UNINITIALIZED 0x0
#define LBER_INITIALIZED 0x1
#define LBER_VALID_BERELEMENT 0x2
#define LBER_VALID_SOCKBUF 0x3
- unsigned short lbo_options;
- int lbo_debug;
-};
-
-LIBLBER_F (struct lber_options) ber_int_options;
+LBER_F (struct lber_options) ber_int_options;
#define ber_int_debug ber_int_options.lbo_debug
struct berelement {
struct seqorset *ber_sos;
char *ber_rwptr;
- BERTranslateProc ber_encode_translate_proc;
- BERTranslateProc ber_decode_translate_proc;
};
#define BER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT)
-
-#define ber_pvt_ber_bytes(ber) ((ber)->ber_ptr - (ber)->ber_buf)
#define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr)
-
-struct sockbuf;
-
-struct sockbuf_io {
- int (*sbi_setup)( struct sockbuf * sb, void *arg );
- int (*sbi_remove)( struct sockbuf *sb );
-
- ber_slen_t (*sbi_read)( struct sockbuf *sb, void *buf, ber_len_t len );
- ber_slen_t (*sbi_write)( struct sockbuf *sb, void *buf, ber_len_t len );
- int (*sbi_close)( struct sockbuf *sb );
-};
-
-struct sockbuf_sec {
- int (*sbs_setup)( struct sockbuf * sb, void *arg );
- int (*sbs_remove)( struct sockbuf *sb );
-
- long (*sbs_protect)( struct sockbuf *sb, char *in, long *ilen,
- char *out, long olen );
- long (*sbs_release)( struct sockbuf *sb, char *in, long ilen,
- char *out0, long olen0, char *out1, long olen1 );
-};
-
-struct sockbuf_buf {
- ber_len_t buf_size;
- ber_len_t buf_ptr;
- ber_len_t buf_end;
- char *buf_base;
-};
-
-typedef struct sockbuf_io Sockbuf_IO;
-typedef struct sockbuf_sec Sockbuf_Sec;
-typedef struct sockbuf_buf Sockbuf_Buf;
-
-LIBLBER_F( Sockbuf_IO ) ber_pvt_sb_io_tcp;
-LIBLBER_F( Sockbuf_IO ) ber_pvt_sb_io_udp;
-
+#define ber_pvt_ber_total(ber) ((ber)->ber_end - (ber)->ber_buf)
+#define ber_pvt_ber_write(ber) ((ber)->ber_ptr - (ber)->ber_buf)
struct sockbuf {
struct lber_options sb_opts;
+ Sockbuf_IO_Desc *sb_iod; /* I/O functions */
#define sb_valid sb_opts.lbo_valid
#define sb_options sb_opts.lbo_options
#define sb_debug sb_opts.lbo_debug
-
- int sb_non_block:1;
- int sb_read_ahead:1;
-
- int sb_buf_ready:1;
- int sb_trans_ready:1;
- int sb_sec_ready:1;
-
- /* these bits indicate if the transport layer
- * needs to read or write
- */
- int sb_trans_needs_read:1;
- int sb_trans_needs_write:1;
-
- int sb_fd;
-
- void *sb_iodata; /* transport-layer data pointer */
- Sockbuf_IO *sb_io; /* I/O functions */
-
-#ifdef LDAP_SASL
- void *sb_sdata; /* security-layer data pointer */
- Sockbuf_Sec *sb_sec;
-#endif
-
- ber_socket_t sb_sd;
-
-#ifdef DEADWOOD
- long sb_max_incoming;
-#endif
- Sockbuf_Buf sb_buf;
-#ifdef LDAP_SASL
- Sockbuf_Buf sb_sec_buf_in;
- Sockbuf_Buf sb_sec_buf_out;
- ber_len_t sb_sec_prev_len;
-#endif
+ ber_socket_t sb_fd;
+ unsigned int sb_trans_needs_read:1;
+ unsigned int sb_trans_needs_write:1;
};
-#define SOCKBUF_VALID(ber) ((sb)->sb_valid==LBER_VALID_SOCKBUF)
-
-/* these should be internal ie: ber_int_* */
-#define ber_pvt_sb_get_desc( sb ) ((sb)->sb_sd)
-#define ber_pvt_sb_set_desc( sb, val ) ((sb)->sb_sd =(val))
-#define ber_pvt_sb_in_use( sb ) ((sb)->sb_sd != AC_SOCKET_INVALID)
-
-#ifdef USE_SASL
-#define ber_pvt_sb_data_ready( sb ) \
-(((sb)->sb_buf_ready) || ((sb)->sb_trans_ready) || ((sb)->sb_sec_ready))
-#else
-#define ber_pvt_sb_data_ready( sb ) \
-(((sb)->sb_buf_ready) || ((sb)->sb_trans_ready))
-#endif
-#define ber_pvt_sb_needs_read( sb ) \
-((sb)->sb_trans_needs_read)
-#define ber_pvt_sb_needs_write( sb ) \
-((sb)->sb_trans_needs_write)
+#define SOCKBUF_VALID( sb ) ( (sb)->sb_valid == LBER_VALID_SOCKBUF )
#define READBUFSIZ 8192
};
+/*
+ * io.c
+ */
+int ber_realloc LDAP_P((
+ BerElement *ber,
+ ber_len_t len ));
+
/*
* bprint.c
*/
#define ber_log_printf ber_pvt_log_printf
-LIBLBER_F( int )
+#ifdef NEW_LOGGING
+LBER_F( int )
+ber_output_dump LDAP_P((
+ char *subsys,
+ int level,
+ BerElement *ber,
+ int inout ));
+#endif
+
+LBER_F( int )
ber_log_bprint LDAP_P((
int errlvl,
int loglvl,
const char *data,
ber_len_t len ));
-LIBLBER_F( int )
+LBER_F( int )
ber_log_dump LDAP_P((
int errlvl,
int loglvl,
BerElement *ber,
int inout ));
-LIBLBER_F( int )
+LBER_F( int )
ber_log_sos_dump LDAP_P((
int errlvl,
int loglvl,
/* memory.c */
/* simple macros to realloc for now */
-LIBLBER_F (BerMemoryFunctions *) ber_int_memory_fns;
+LBER_F (BerMemoryFunctions *) ber_int_memory_fns;
#ifdef CSRIMALLOC
#define LBER_INT_MALLOC malloc
/* sockbuf.c */
-/* these should be ber_int*() functions */
-
-LIBLBER_F( int )
-ber_pvt_sb_init LDAP_P(( Sockbuf *sb ));
-
-LIBLBER_F( int )
-ber_pvt_sb_destroy LDAP_P(( Sockbuf *sb ));
-
-#ifdef USE_SASL
-LIBLBER_F( int )
-ber_pvt_sb_set_sec LDAP_P(( Sockbuf *sb, Sockbuf_Sec *sec, void *arg ));
-
-LIBLBER_F( int )
-ber_pvt_sb_clear_sec LDAP_P(( Sockbuf *sb ));
-#endif
-
-LIBLBER_F( int )
-ber_pvt_sb_set_io LDAP_P(( Sockbuf *sb, Sockbuf_IO *layer, void *arg ));
-
-LIBLBER_F( int )
-ber_pvt_sb_clear_io LDAP_P(( Sockbuf *sb ));
-
-LIBLBER_F( int )
-ber_pvt_sb_close LDAP_P((Sockbuf *sb ));
-
-LIBLBER_F( int )
-ber_pvt_sb_set_nonblock LDAP_P(( Sockbuf *sb, int nb ));
-
-LIBLBER_F( int )
-ber_pvt_sb_set_readahead LDAP_P(( Sockbuf *sb, int rh ));
+LBER_F( int )
+ber_int_sb_init LDAP_P(( Sockbuf *sb ));
-LIBLBER_F( ber_slen_t )
-ber_pvt_sb_read LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
+LBER_F( int )
+ber_int_sb_close LDAP_P(( Sockbuf *sb ));
-LIBLBER_F( ber_slen_t )
-ber_pvt_sb_write LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
+LBER_F( int )
+ber_int_sb_destroy LDAP_P(( Sockbuf *sb ));
-LIBLBER_F( int )
-ber_pvt_sb_udp_set_dst LDAP_P((Sockbuf *sb, void *addr ));
+LBER_F( ber_slen_t )
+ber_int_sb_read LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
-LIBLBER_F( void * )
-ber_pvt_sb_udp_get_src LDAP_P((Sockbuf *sb ));
+LBER_F( ber_slen_t )
+ber_int_sb_write LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
-LIBLBER_F( int )
-ber_pvt_socket_set_nonblock LDAP_P(( ber_socket_t sd, int nb ));
+LDAP_END_DECL
#endif /* _LBER_INT_H */