2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2009
6 ** NOTE! The following LGPL license applies to the tsocket
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/>.
24 #ifndef _TSOCKET_INTERNAL_H
25 #define _TSOCKET_INTERNAL_H
30 struct tsocket_address_ops
{
33 char *(*string
)(const struct tsocket_address
*addr
,
36 struct tsocket_address
*(*copy
)(const struct tsocket_address
*addr
,
38 const char *location
);
41 struct tsocket_address
{
43 const struct tsocket_address_ops
*ops
;
48 struct tsocket_address
*_tsocket_address_create(TALLOC_CTX
*mem_ctx
,
49 const struct tsocket_address_ops
*ops
,
53 const char *location
);
54 #define tsocket_address_create(mem_ctx, ops, state, type, location) \
55 _tsocket_address_create(mem_ctx, ops, state, sizeof(type), \
58 struct tdgram_context_ops
{
61 struct tevent_req
*(*recvfrom_send
)(TALLOC_CTX
*mem_ctx
,
62 struct tevent_context
*ev
,
63 struct tdgram_context
*dgram
);
64 ssize_t (*recvfrom_recv
)(struct tevent_req
*req
,
68 struct tsocket_address
**src
);
70 struct tevent_req
*(*sendto_send
)(TALLOC_CTX
*mem_ctx
,
71 struct tevent_context
*ev
,
72 struct tdgram_context
*dgram
,
73 const uint8_t *buf
, size_t len
,
74 const struct tsocket_address
*dst
);
75 ssize_t (*sendto_recv
)(struct tevent_req
*req
,
78 struct tevent_req
*(*disconnect_send
)(TALLOC_CTX
*mem_ctx
,
79 struct tevent_context
*ev
,
80 struct tdgram_context
*dgram
);
81 int (*disconnect_recv
)(struct tevent_req
*req
,
85 struct tdgram_context
*_tdgram_context_create(TALLOC_CTX
*mem_ctx
,
86 const struct tdgram_context_ops
*ops
,
90 const char *location
);
91 #define tdgram_context_create(mem_ctx, ops, state, type, location) \
92 _tdgram_context_create(mem_ctx, ops, state, sizeof(type), \
95 void *_tdgram_context_data(struct tdgram_context
*dgram
);
96 #define tdgram_context_data(_req, _type) \
97 talloc_get_type_abort(_tdgram_context_data(_req), _type)
99 struct tstream_context_ops
{
102 ssize_t (*pending_bytes
)(struct tstream_context
*stream
);
104 struct tevent_req
*(*readv_send
)(TALLOC_CTX
*mem_ctx
,
105 struct tevent_context
*ev
,
106 struct tstream_context
*stream
,
107 struct iovec
*vector
,
109 int (*readv_recv
)(struct tevent_req
*req
,
112 struct tevent_req
*(*writev_send
)(TALLOC_CTX
*mem_ctx
,
113 struct tevent_context
*ev
,
114 struct tstream_context
*stream
,
115 const struct iovec
*vector
,
117 int (*writev_recv
)(struct tevent_req
*req
,
120 struct tevent_req
*(*disconnect_send
)(TALLOC_CTX
*mem_ctx
,
121 struct tevent_context
*ev
,
122 struct tstream_context
*stream
);
123 int (*disconnect_recv
)(struct tevent_req
*req
,
127 struct tstream_context
*_tstream_context_create(TALLOC_CTX
*mem_ctx
,
128 const struct tstream_context_ops
*ops
,
132 const char *location
);
133 #define tstream_context_create(mem_ctx, ops, state, type, location) \
134 _tstream_context_create(mem_ctx, ops, state, sizeof(type), \
137 void *_tstream_context_data(struct tstream_context
*stream
);
138 #define tstream_context_data(_req, _type) \
139 talloc_get_type_abort(_tstream_context_data(_req), _type)
141 int tsocket_simple_int_recv(struct tevent_req
*req
, int *perrno
);
143 #endif /* _TSOCKET_H */