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 /* these have to match lber types settings */
27 #define LBER_INT_HTON(i) AC_HTONL(i)
28 #define LBER_INT_NTOH(i) AC_NTOHL(i)
29 #define LBER_LEN_HTON(l) AC_HTONL(l)
30 #define LBER_LEN_NTOH(l) AC_NTOHL(l)
31 #define LBER_TAG_HTON(t) AC_HTONL(t)
32 #define LBER_TAG_NTOH(t) AC_NTOHL(t)
37 #define LBER_UNINITIALIZED 0x0
38 #define LBER_INITIALIZED 0x1
39 #define LBER_VALID_BERELEMENT 0x2
40 #define LBER_VALID_SOCKBUF 0x3
42 unsigned short lbo_options;
46 extern struct lber_options ber_int_options;
47 #define ber_int_debug ber_int_options.lbo_debug
50 struct lber_options ber_opts;
51 #define ber_valid ber_opts.lbo_valid
52 #define ber_options ber_opts.lbo_options
53 #define ber_debug ber_opts.lbo_debug
55 ber_tag_t ber_usertag;
64 struct seqorset *ber_sos;
66 BERTranslateProc ber_encode_translate_proc;
67 BERTranslateProc ber_decode_translate_proc;
69 #define BER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT)
72 #define ber_pvt_ber_bytes(ber) ((ber)->ber_ptr - (ber)->ber_buf)
73 #define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr)
78 int (*sbi_setup)( struct sockbuf * sb, void *arg );
79 int (*sbi_remove)( struct sockbuf *sb );
81 ber_slen_t (*sbi_read)( struct sockbuf *sb, void *buf, ber_len_t len );
82 ber_slen_t (*sbi_write)( struct sockbuf *sb, void *buf, ber_len_t len );
83 int (*sbi_close)( struct sockbuf *sb );
87 int (*sbs_setup)( struct sockbuf * sb, void *arg );
88 int (*sbs_remove)( struct sockbuf *sb );
90 long (*sbs_protect)( struct sockbuf *sb, char *in, long *ilen,
91 char *out, long olen );
92 long (*sbs_release)( struct sockbuf *sb, char *in, long ilen,
93 char *out0, long olen0, char *out1, long olen1 );
103 typedef struct sockbuf_io Sockbuf_IO;
104 typedef struct sockbuf_sec Sockbuf_Sec;
105 typedef struct sockbuf_buf Sockbuf_Buf;
107 extern Sockbuf_IO ber_pvt_sb_io_tcp;
108 extern Sockbuf_IO ber_pvt_sb_io_udp;
112 struct lber_options sb_opts;
113 #define sb_valid sb_opts.lbo_valid
114 #define sb_options sb_opts.lbo_options
115 #define sb_debug sb_opts.lbo_debug
121 int sb_trans_ready:1;
126 void *sb_iodata; /* transport-layer data pointer */
127 Sockbuf_IO *sb_io; /* I/O functions */
130 void *sb_sdata; /* security-layer data pointer */
137 long sb_max_incoming;
141 Sockbuf_Buf sb_sec_buf_in;
142 Sockbuf_Buf sb_sec_buf_out;
143 ber_len_t sb_sec_prev_len;
146 #define SOCKBUF_VALID(ber) ((sb)->sb_valid==LBER_VALID_SOCKBUF)
148 /* these should be internal ie: ber_int_* */
149 #define ber_pvt_sb_get_desc( sb ) ((sb)->sb_sd)
150 #define ber_pvt_sb_set_desc( sb, val ) ((sb)->sb_sd =(val))
152 #define ber_pvt_sb_in_use( sb ) ((sb)->sb_sd != AC_SOCKET_INVALID)
155 #define ber_pvt_sb_data_ready( sb ) \
156 (((sb)->sb_buf_ready) || ((sb)->sb_trans_ready) || ((sb)->sb_sec_ready))
158 #define ber_pvt_sb_data_ready( sb ) \
159 (((sb)->sb_buf_ready) || ((sb)->sb_trans_ready))
162 #define READBUFSIZ 8192
170 struct seqorset *sos_next;
177 #define ber_log_printf ber_pvt_log_printf
180 ber_log_bprint LDAP_P((
187 ber_log_dump LDAP_P((
190 const BerElement *ber,
194 ber_log_sos_dump LDAP_P((
197 const Seqorset *sos ));
201 /* simple macros to realloc for now */
202 extern BerMemoryFunctions* ber_int_memory_fns;
204 #define LBER_INT_MALLOC(s) ber_memalloc((s))
205 #define LBER_INT_CALLOC(n,s) ber_memcalloc((n),(s))
206 #define LBER_INT_REALLOC(p,s) ber_memrealloc((p),(s))
207 #define LBER_INT_FREE(p) ber_memfree((p))
208 #define LBER_INT_VFREE(v) ber_memvfree((void**)(v))
209 #define LBER_INT_STRDUP(s) ber_strdup((s))
211 #define LBER_MALLOC(s) ber_memalloc((s))
212 #define LBER_CALLOC(n,s) ber_memcalloc((n),(s))
213 #define LBER_REALLOC(p,s) ber_memrealloc((p),(s))
214 #define LBER_FREE(p) ber_memfree((p))
215 #define LBER_VFREE(v) ber_memvfree((void**)(v))
216 #define LBER_STRDUP(s) ber_strdup((s))
220 /* these should be ber_int*() functions */
223 ber_pvt_sb_init LDAP_P(( Sockbuf *sb ));
226 ber_pvt_sb_destroy LDAP_P(( Sockbuf *sb ));
230 ber_pvt_sb_set_sec LDAP_P(( Sockbuf *sb, Sockbuf_Sec *sec, void *arg ));
233 ber_pvt_sb_clear_sec LDAP_P(( Sockbuf *sb ));
237 ber_pvt_sb_set_io LDAP_P(( Sockbuf *sb, Sockbuf_IO *layer, void *arg ));
240 ber_pvt_sb_clear_io LDAP_P(( Sockbuf *sb ));
243 ber_pvt_sb_close LDAP_P((Sockbuf *sb ));
246 ber_pvt_sb_set_nonblock LDAP_P(( Sockbuf *sb, int nb ));
249 ber_pvt_sb_set_readahead LDAP_P(( Sockbuf *sb, int rh ));
252 ber_pvt_sb_read LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
255 ber_pvt_sb_write LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
258 ber_pvt_sb_udp_set_dst LDAP_P((Sockbuf *sb, void *addr ));
261 ber_pvt_sb_udp_get_src LDAP_P((Sockbuf *sb ));
264 #endif /* _LBER_INT_H */