tsocket: remove tsocket_context related stuff
[ira/wip.git] / lib / tsocket / tsocket_internal.h
1 /*
2    Unix SMB/CIFS implementation.
3
4    Copyright (C) Stefan Metzmacher 2009
5
6      ** NOTE! The following LGPL license applies to the tevent
7      ** library. This does NOT imply that all of Samba is released
8      ** under the LGPL
9
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.
14
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.
19
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/>.
22 */
23
24 #ifndef _TSOCKET_INTERNAL_H
25 #define _TSOCKET_INTERNAL_H
26
27 struct tsocket_address_ops {
28         const char *name;
29
30         char *(*string)(const struct tsocket_address *addr,
31                         TALLOC_CTX *mem_ctx);
32
33         struct tsocket_address *(*copy)(const struct tsocket_address *addr,
34                                         TALLOC_CTX *mem_ctx,
35                                         const char *location);
36 };
37
38 struct tsocket_address {
39         const char *location;
40         const struct tsocket_address_ops *ops;
41
42         void *private_data;
43 };
44
45 struct tsocket_address *_tsocket_address_create(TALLOC_CTX *mem_ctx,
46                                         const struct tsocket_address_ops *ops,
47                                         void *pstate,
48                                         size_t psize,
49                                         const char *type,
50                                         const char *location);
51 #define tsocket_address_create(mem_ctx, ops, state, type, location) \
52         _tsocket_address_create(mem_ctx, ops, state, sizeof(type), \
53                                 #type, location)
54
55 struct tdgram_context_ops {
56         const char *name;
57
58         struct tevent_req *(*recvfrom_send)(TALLOC_CTX *mem_ctx,
59                                             struct tevent_context *ev,
60                                             struct tdgram_context *dgram);
61         ssize_t (*recvfrom_recv)(struct tevent_req *req,
62                                  int *perrno,
63                                  TALLOC_CTX *mem_ctx,
64                                  uint8_t **buf,
65                                  struct tsocket_address **src);
66
67         struct tevent_req *(*sendto_send)(TALLOC_CTX *mem_ctx,
68                                           struct tevent_context *ev,
69                                           struct tdgram_context *dgram,
70                                           const uint8_t *buf, size_t len,
71                                           const struct tsocket_address *dst);
72         ssize_t (*sendto_recv)(struct tevent_req *req,
73                                int *perrno);
74
75         struct tevent_req *(*disconnect_send)(TALLOC_CTX *mem_ctx,
76                                               struct tevent_context *ev,
77                                               struct tdgram_context *dgram);
78         int (*disconnect_recv)(struct tevent_req *req,
79                                int *perrno);
80 };
81
82 struct tdgram_context *_tdgram_context_create(TALLOC_CTX *mem_ctx,
83                                         const struct tdgram_context_ops *ops,
84                                         void *pstate,
85                                         size_t psize,
86                                         const char *type,
87                                         const char *location);
88 #define tdgram_context_create(mem_ctx, ops, state, type, location) \
89         _tdgram_context_create(mem_ctx, ops, state, sizeof(type), \
90                                 #type, location)
91
92 void *_tdgram_context_data(struct tdgram_context *dgram);
93 #define tdgram_context_data(_req, _type) \
94         talloc_get_type_abort(_tdgram_context_data(_req), _type)
95
96 int tsocket_simple_int_recv(struct tevent_req *req, int *perrno);
97
98 #endif /* _TSOCKET_H */
99