2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2009
6 ** NOTE! The following LGPL license applies to the tevent
7 ** library. This does NOT imply that all of Samba is released
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 3 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, see <http://www.gnu.org/licenses/>.
30 struct tsocket_context;
31 struct tsocket_address;
35 TSOCKET_TYPE_STREAM = 1,
40 typedef void (*tsocket_event_handler_t)(struct tsocket_context *, void *);
41 int tsocket_set_event_context(struct tsocket_context *sock,
42 struct tevent_context *ev);
43 int tsocket_set_readable_handler(struct tsocket_context *sock,
44 tsocket_event_handler_t handler,
46 int tsocket_set_writeable_handler(struct tsocket_context *sock,
47 tsocket_event_handler_t handler,
50 int tsocket_connect(struct tsocket_context *sock,
51 const struct tsocket_address *remote_addr);
53 int tsocket_listen(struct tsocket_context *sock,
56 int _tsocket_accept(struct tsocket_context *sock,
58 struct tsocket_context **new_sock,
59 const char *location);
60 #define tsocket_accept(sock, mem_ctx, new_sock) \
61 _tsocket_accept(sock, mem_ctx, new_sock, __location__)
63 ssize_t tsocket_pending(struct tsocket_context *sock);
65 int tsocket_readv(struct tsocket_context *sock,
66 const struct iovec *vector, size_t count);
67 int tsocket_writev(struct tsocket_context *sock,
68 const struct iovec *vector, size_t count);
70 ssize_t tsocket_recvfrom(struct tsocket_context *sock,
71 uint8_t *data, size_t len,
73 struct tsocket_address **src_addr);
74 ssize_t tsocket_sendto(struct tsocket_context *sock,
75 const uint8_t *data, size_t len,
76 const struct tsocket_address *dest_addr);
78 int tsocket_get_status(const struct tsocket_context *sock);
80 int _tsocket_get_local_address(const struct tsocket_context *sock,
82 struct tsocket_address **local_addr,
83 const char *location);
84 #define tsocket_get_local_address(sock, mem_ctx, local_addr) \
85 _tsocket_get_local_address(sock, mem_ctx, local_addr, __location__)
86 int _tsocket_get_remote_address(const struct tsocket_context *sock,
88 struct tsocket_address **remote_addr,
89 const char *location);
90 #define tsocket_get_remote_address(sock, mem_ctx, remote_addr) \
91 _tsocket_get_remote_address(sock, mem_ctx, remote_addr, __location__)
93 int tsocket_get_option(const struct tsocket_context *sock,
97 int tsocket_set_option(const struct tsocket_context *sock,
102 void tsocket_disconnect(struct tsocket_context *sock);
104 char *tsocket_address_string(const struct tsocket_address *addr,
105 TALLOC_CTX *mem_ctx);
107 struct tsocket_address *_tsocket_address_copy(const struct tsocket_address *addr,
109 const char *location);
111 #define tsocket_address_copy(addr, mem_ctx) \
112 _tsocket_address_copy(addr, mem_ctx, __location__)
114 int _tsocket_address_create_socket(const struct tsocket_address *addr,
115 enum tsocket_type type,
117 struct tsocket_context **sock,
118 const char *location);
119 #define tsocket_address_create_socket(addr, type, mem_ctx, sock) \
120 _tsocket_address_create_socket(addr, type, mem_ctx, sock,\
123 #endif /* _TSOCKET_H */