2 * Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Copyright (c) 1990 Regents of the University of Michigan.
9 * Redistribution and use in source and binary forms are permitted
10 * provided that this notice is preserved and that due credit is given
11 * to the University of Michigan at Ann Arbor. The name of the University
12 * may not be used to endorse or promote products derived from this
13 * software without specific prior written permission. This software
14 * is provided ``as is'' without express or implied warranty.
26 extern BER_MEMORY_FN ber_int_realloc;
30 #define LBER_UNINITIALIZED 0x0
31 #define LBER_INITIALIZED 0x1
32 #define LBER_VALID_BERELEMENT 0x2
33 #define LBER_VALID_SOCKBUF 0x3
35 unsigned short lbo_options;
39 extern struct lber_options ber_int_options;
40 #define ber_int_debug ber_int_options.lbo_debug
43 struct lber_options ber_opts;
44 #define ber_valid ber_opts.lbo_valid
45 #define ber_options ber_opts.lbo_options
46 #define ber_debug ber_opts.lbo_debug
50 unsigned long ber_tag;
51 unsigned long ber_len;
57 struct seqorset *ber_sos;
59 BERTranslateProc ber_encode_translate_proc;
60 BERTranslateProc ber_decode_translate_proc;
62 #define BER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT)
63 #define NULLBER ((BerElement *) 0)
65 #define ber_pvt_ber_bytes(ber) ((ber)->ber_ptr - (ber)->ber_buf)
66 #define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr)
71 int (*sbi_setup)( struct sockbuf * sb, void *arg );
72 int (*sbi_remove)( struct sockbuf *sb );
74 long (*sbi_read)( struct sockbuf *sb, void *buf, long len );
75 long (*sbi_write)( struct sockbuf *sb, void *buf, long len );
76 int (*sbi_close)( struct sockbuf *sb );
80 int (*sbs_setup)( struct sockbuf * sb, void *arg );
81 int (*sbs_remove)( struct sockbuf *sb );
83 long (*sbs_protect)( struct sockbuf *sb, char *in, long *ilen,
84 char *out, long olen );
85 long (*sbs_release)( struct sockbuf *sb, char *in, long ilen,
86 char *out0, long olen0, char *out1, long olen1 );
96 typedef struct sockbuf_io Sockbuf_IO;
97 typedef struct sockbuf_sec Sockbuf_Sec;
98 typedef struct sockbuf_buf Sockbuf_Buf;
100 extern Sockbuf_IO ber_pvt_sb_io_tcp;
101 extern Sockbuf_IO ber_pvt_sb_io_udp;
105 struct lber_options sb_opts;
106 #define sb_valid sb_opts.lbo_valid
107 #define sb_options sb_opts.lbo_options
108 #define sb_debug sb_opts.lbo_debug
114 int sb_trans_ready:1;
119 void *sb_iodata; /* transport-layer data pointer */
120 Sockbuf_IO *sb_io; /* I/O functions */
123 void *sb_sdata; /* security-layer data pointer */
133 long sb_max_incoming;
137 Sockbuf_Buf sb_sec_buf_in;
138 Sockbuf_Buf sb_sec_buf_out;
139 long sb_sec_prev_len;
142 #define SOCKBUF_VALID(ber) ((sb)->sb_valid==LBER_VALID_SOCKBUF)
144 /* these should be internal ie: ber_int_* */
145 #define ber_pvt_sb_get_desc( sb ) ((sb)->sb_sd)
146 #define ber_pvt_sb_set_desc( sb, val ) ((sb)->sb_sd =(val))
148 #define ber_pvt_sb_in_use( sb ) ((sb)->sb_sd!=-1)
151 #define ber_pvt_sb_data_ready( sb ) \
152 (((sb)->sb_buf_ready) || ((sb)->sb_trans_ready) || ((sb)->sb_sec_ready))
154 #define ber_pvt_sb_data_ready( sb ) \
155 (((sb)->sb_buf_ready) || ((sb)->sb_trans_ready))
158 #define READBUFSIZ 8192
162 unsigned long sos_clen;
163 unsigned long sos_tag;
166 struct seqorset *sos_next;
168 #define NULLSEQORSET ((Seqorset *) 0)
173 #define ber_log_printf ber_pvt_log_printf
176 ber_log_bprint LDAP_P((
183 ber_log_dump LDAP_P((
186 const BerElement *ber,
190 ber_log_sos_dump LDAP_P((
193 const Seqorset *sos ));
197 /* simple macros to realloc for now */
198 #define LBER_MALLOC(s) \
200 ? (*ber_int_realloc)(NULL,(s)) \
203 #define LBER_CALLOC(n,s) \
205 ? ber_int_calloc((n),(s)) \
208 #define LBER_REALLOC(p,s) \
210 ? (*ber_int_realloc)((p),(s)) \
213 #define LBER_FREE(p) \
215 ? (*ber_int_realloc)((p),(size_t)0) \
216 : realloc((p),(size_t)0))
219 ber_int_calloc LDAP_P((
226 /* these should be ber_int*() functions */
229 ber_pvt_sb_init LDAP_P(( Sockbuf *sb ));
232 ber_pvt_sb_destroy LDAP_P(( Sockbuf *sb ));
236 ber_pvt_sb_set_sec LDAP_P(( Sockbuf *sb, Sockbuf_Sec *sec, void *arg ));
239 ber_pvt_sb_clear_sec LDAP_P(( Sockbuf *sb ));
243 ber_pvt_sb_set_io LDAP_P(( Sockbuf *sb, Sockbuf_IO *layer, void *arg ));
246 ber_pvt_sb_clear_io LDAP_P(( Sockbuf *sb ));
249 ber_pvt_sb_close LDAP_P((Sockbuf *sb ));
252 ber_pvt_sb_set_nonblock LDAP_P(( Sockbuf *sb, int nb ));
255 ber_pvt_sb_set_readahead LDAP_P(( Sockbuf *sb, int rh ));
258 ber_pvt_sb_read LDAP_P(( Sockbuf *sb, void *buf, long len ));
261 ber_pvt_sb_write LDAP_P(( Sockbuf *sb, void *buf, long len ));
264 ber_pvt_sb_udp_set_dst LDAP_P((Sockbuf *sb, void *addr ));
267 ber_pvt_sb_udp_get_src LDAP_P((Sockbuf *sb ));
270 #endif /* _LBER_INT_H */