smbtorture: Make cracksname easier to debug by outputing the offered format
[Samba.git] / lib / tsocket / tsocket_internal.h
blob154b2ce6f890c66b0cdc6643f1bdabfdd5447dbe
1 /*
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
8 ** under the LGPL
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
27 #include <unistd.h>
28 #include <sys/uio.h>
30 struct tsocket_address_ops {
31 const char *name;
33 char *(*string)(const struct tsocket_address *addr,
34 TALLOC_CTX *mem_ctx);
36 struct tsocket_address *(*copy)(const struct tsocket_address *addr,
37 TALLOC_CTX *mem_ctx,
38 const char *location);
41 struct tsocket_address {
42 const char *location;
43 const struct tsocket_address_ops *ops;
45 void *private_data;
48 struct tsocket_address *_tsocket_address_create(TALLOC_CTX *mem_ctx,
49 const struct tsocket_address_ops *ops,
50 void *pstate,
51 size_t psize,
52 const char *type,
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), \
56 #type, location)
58 struct tdgram_context_ops {
59 const char *name;
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,
65 int *perrno,
66 TALLOC_CTX *mem_ctx,
67 uint8_t **buf,
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,
76 int *perrno);
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,
82 int *perrno);
85 struct tdgram_context *_tdgram_context_create(TALLOC_CTX *mem_ctx,
86 const struct tdgram_context_ops *ops,
87 void *pstate,
88 size_t psize,
89 const char *type,
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), \
93 #type, location)
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 {
100 const char *name;
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,
108 size_t count);
109 int (*readv_recv)(struct tevent_req *req,
110 int *perrno);
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,
116 size_t count);
117 int (*writev_recv)(struct tevent_req *req,
118 int *perrno);
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,
124 int *perrno);
127 struct tstream_context *_tstream_context_create(TALLOC_CTX *mem_ctx,
128 const struct tstream_context_ops *ops,
129 void *pstate,
130 size_t psize,
131 const char *type,
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), \
135 #type, location)
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 */