summaryrefslogtreecommitdiff
path: root/lib/tsocket/tsocket_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tsocket/tsocket_internal.h')
-rw-r--r--lib/tsocket/tsocket_internal.h49
1 files changed, 41 insertions, 8 deletions
diff --git a/lib/tsocket/tsocket_internal.h b/lib/tsocket/tsocket_internal.h
index e4a4908f3e..893394405f 100644
--- a/lib/tsocket/tsocket_internal.h
+++ b/lib/tsocket/tsocket_internal.h
@@ -57,14 +57,6 @@ struct tsocket_context_ops {
int (*writev_data)(struct tsocket_context *sock,
const struct iovec *vector, size_t count);
- ssize_t (*recvfrom_data)(struct tsocket_context *sock,
- uint8_t *data, size_t len,
- TALLOC_CTX *addr_ctx,
- struct tsocket_address **remote_addr);
- ssize_t (*sendto_data)(struct tsocket_context *sock,
- const uint8_t *data, size_t len,
- const struct tsocket_address *remote_addr);
-
/* info */
int (*get_status)(const struct tsocket_context *sock);
int (*get_local_address)(const struct tsocket_context *sock,
@@ -149,6 +141,47 @@ struct tsocket_address *_tsocket_address_create(TALLOC_CTX *mem_ctx,
_tsocket_address_create(mem_ctx, ops, state, sizeof(type), \
#type, location)
+struct tdgram_context_ops {
+ const char *name;
+
+ struct tevent_req *(*recvfrom_send)(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct tdgram_context *dgram);
+ ssize_t (*recvfrom_recv)(struct tevent_req *req,
+ int *perrno,
+ TALLOC_CTX *mem_ctx,
+ uint8_t **buf,
+ struct tsocket_address **src);
+
+ struct tevent_req *(*sendto_send)(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct tdgram_context *dgram,
+ const uint8_t *buf, size_t len,
+ const struct tsocket_address *dst);
+ ssize_t (*sendto_recv)(struct tevent_req *req,
+ int *perrno);
+
+ struct tevent_req *(*disconnect_send)(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct tdgram_context *dgram);
+ int (*disconnect_recv)(struct tevent_req *req,
+ int *perrno);
+};
+
+struct tdgram_context *_tdgram_context_create(TALLOC_CTX *mem_ctx,
+ const struct tdgram_context_ops *ops,
+ void *pstate,
+ size_t psize,
+ const char *type,
+ const char *location);
+#define tdgram_context_create(mem_ctx, ops, state, type, location) \
+ _tdgram_context_create(mem_ctx, ops, state, sizeof(type), \
+ #type, location)
+
+void *_tdgram_context_data(struct tdgram_context *dgram);
+#define tdgram_context_data(_req, _type) \
+ talloc_get_type_abort(_tdgram_context_data(_req), _type)
+
int tsocket_error_from_errno(int ret, int sys_errno, bool *retry);
int tsocket_simple_int_recv(struct tevent_req *req, int *perrno);
int tsocket_common_prepare_fd(int fd, bool high_fd);