1LBER_SOCKBUF(3) Library Functions Manual LBER_SOCKBUF(3)
2
3
4
6 ber_sockbuf_alloc, ber_sockbuf_free, ber_sockbuf_ctrl, ber_sock‐
7 buf_add_io, ber_sockbuf_remove_io, Sockbuf_IO - OpenLDAP LBER I/O in‐
8 frastructure
9
11 OpenLDAP LBER (liblber, -llber)
12
14 #include <lber.h>
15
16 Sockbuf *ber_sockbuf_alloc( void );
17
18 void ber_sockbuf_free(Sockbuf *sb);
19
20 int ber_sockbuf_ctrl(Sockbuf *sb, int opt, void *arg);
21
22 int ber_sockbuf_add_io(Sockbuf *sb, Sockbuf_IO *sbio, int layer, void
23 *arg);
24
25 int ber_sockbuf_remove_io(Sockbuf *sb, Sockbuf_IO *sbio, int layer);
26
27 typedef struct sockbuf_io_desc {
28 int sbiod_level;
29 Sockbuf *sbiod_sb;
30 Sockbuf_IO *sbiod_io;
31 void *sbiod_pvt;
32 struct sockbuf_io_desc *sbiod_next;
33 } Sockbuf_IO_Desc;
34
35 typedef struct sockbuf_io {
36 int (*sbi_setup)(Sockbuf_IO_Desc *sbiod, void *arg);
37 int (*sbi_remove)(Sockbuf_IO_Desc *sbiod);
38 int (*sbi_ctrl)(Sockbuf_IO_Desc *sbiod, int opt, void *arg);
39 ber_slen_t (*sbi_read)(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len);
40 ber_slen_t (*sbi_write)(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len);
41 int (*sbi_close)(Sockbuf_IO_Desc *sbiod);
42 } Sockbuf_IO;
43
44
46 These routines are used to manage the low level I/O operations per‐
47 formed by the Lightweight BER library. They are called implicitly by
48 the other libraries and usually do not need to be called directly from
49 applications. The I/O framework is modularized and new transport lay‐
50 ers can be supported by appropriately defining a Sockbuf_IO structure
51 and installing it onto an existing Sockbuf. Sockbuf structures are
52 allocated and freed by ber_sockbuf_alloc() and ber_sockbuf_free(),
53 respectively. The ber_sockbuf_ctrl() function is used to get and set
54 options related to a Sockbuf or to a specific I/O layer of the Sockbuf.
55 The ber_sockbuf_add_io() and ber_sockbuf_remove_io() functions are used
56 to add and remove specific I/O layers on a Sockbuf.
57
58 Options for ber_sockbuf_ctrl() include:
59
60 LBER_SB_OPT_HAS_IO
61 Takes a Sockbuf_IO * argument and returns 1 if the given handler
62 is installed on the Sockbuf, otherwise returns 0.
63
64 LBER_SB_OPT_GET_FD
65 Retrieves the file descriptor associated to the Sockbuf; arg
66 must be a ber_socket_t *. The return value will be 1 if a valid
67 descriptor was present, -1 otherwise.
68
69 LBER_SB_OPT_SET_FD
70 Sets the file descriptor of the Sockbuf to the descriptor
71 pointed to by arg; arg must be a ber_socket_t *. The return
72 value will always be 1.
73
74 LBER_SB_OPT_SET_NONBLOCK
75 Toggles the non-blocking state of the file descriptor associated
76 to the Sockbuf. arg should be NULL to disable and non-NULL to
77 enable the non-blocking state. The return value will be 1 for
78 success, -1 otherwise.
79
80 LBER_SB_OPT_DRAIN
81 Flush (read and discard) all available input on the Sockbuf.
82 The return value will be 1.
83
84 LBER_SB_OPT_NEEDS_READ
85 Returns non-zero if input is waiting to be read.
86
87 LBER_SB_OPT_NEEDS_WRITE
88 Returns non-zero if the Sockbuf is ready to be written.
89
90 LBER_SB_OPT_GET_MAX_INCOMING
91 Returns the maximum allowed size of an incoming message; arg
92 must be a ber_len_t *. The return value will be 1.
93
94 LBER_SB_OPT_SET_MAX_INCOMING
95 Sets the maximum allowed size of an incoming message; arg must
96 be a ber_len_t *. The return value will be 1.
97
98
99 Options not in this list will be passed down to each Sockbuf_IO handler
100 in turn until one of them processes it. If the option is not handled
101 ber_sockbuf_ctrl() will return 0.
102
103
104 Multiple Sockbuf_IO handlers can be stacked in multiple layers to pro‐
105 vide various functionality. Currently defined layers include
106
107 LBER_SBIOD_LEVEL_PROVIDER
108 the lowest layer, talking directly to a network
109
110 LBER_SBIOD_LEVEL_TRANSPORT
111 an intermediate layer
112
113 LBER_SBIOD_LEVEL_APPLICATION
114 a higher layer
115
116 Currently defined Sockbuf_IO handlers in liblber include
117
118 ber_sockbuf_io_tcp
119 The default stream-oriented provider
120
121 ber_sockbuf_io_fd
122 A stream-oriented provider for local IPC sockets
123
124 ber_sockbuf_io_dgram
125 A datagram-oriented provider. This handler is only present if
126 the liblber library was built with LDAP_CONNECTIONLESS defined.
127
128 ber_sockbuf_io_readahead
129 A buffering layer, usually used with a datagram provider to hide
130 the datagram semantics from upper layers.
131
132 ber_sockbuf_io_debug
133 A generic handler that outputs hex dumps of all traffic. This
134 handler may be inserted multiple times at arbitrary layers to
135 show the flow of data between other handlers.
136
137 Additional handlers may be present in libldap if support for them was
138 enabled:
139
140 ldap_pvt_sockbuf_io_sasl
141 An application layer handler for SASL encoding/decoding.
142
143 sb_tls_sbio
144 A transport layer handler for SSL/TLS encoding/decoding. Note
145 that this handler is private to the library and is not exposed
146 in the API.
147
148 The provided handlers are all instantiated implicitly by libldap, and
149 applications generally will not need to directly manipulate them.
150
151
153 lber-decode(3), lber-encode(3), lber-types(3), ldap_get_option(3)
154
155
157 OpenLDAP Software is developed and maintained by The OpenLDAP Project
158 <http://www.openldap.org/>. OpenLDAP Software is derived from the Uni‐
159 versity of Michigan LDAP 3.3 Release.
160
161
162
163OpenLDAP 2.4.46 2018/03/22 LBER_SOCKBUF(3)