From 8d98070a9f0a1a17d05e381b8e4c5a8f7a7e8233 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 26 Mar 2009 14:27:45 +0100 Subject: tsocket: split out a smaller tdgram_context abstraction The idea is to have a tdgram and a tstream abstraction which only provide tevent_req based io functions. metze --- lib/tsocket/tsocket.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'lib/tsocket/tsocket.h') diff --git a/lib/tsocket/tsocket.h b/lib/tsocket/tsocket.h index 9bcfb5cb7e..077fd1ef35 100644 --- a/lib/tsocket/tsocket.h +++ b/lib/tsocket/tsocket.h @@ -29,6 +29,7 @@ struct tsocket_context; struct tsocket_address; +struct tdgram_context; struct iovec; enum tsocket_type { @@ -120,6 +121,32 @@ int _tsocket_address_create_socket(const struct tsocket_address *addr, _tsocket_address_create_socket(addr, type, mem_ctx, sock,\ __location__) +/* + * tdgram_context related functions + */ +struct tevent_req *tdgram_recvfrom_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct tdgram_context *dgram); +ssize_t tdgram_recvfrom_recv(struct tevent_req *req, + int *perrno, + TALLOC_CTX *mem_ctx, + uint8_t **buf, + struct tsocket_address **src); + +struct tevent_req *tdgram_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 tdgram_sendto_recv(struct tevent_req *req, + int *perrno); + +struct tevent_req *tdgram_disconnect_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct tdgram_context *dgram); +int tdgram_disconnect_recv(struct tevent_req *req, + int *perrno); + /* * BSD sockets: inet, inet6 and unix */ @@ -160,6 +187,22 @@ int _tsocket_context_bsd_wrap_existing(TALLOC_CTX *mem_ctx, _tsocket_context_bsd_wrap_existing(mem_ctx, fd, cod, _sock, \ __location__) +int _tdgram_inet_udp_socket(const struct tsocket_address *local, + const struct tsocket_address *remote, + TALLOC_CTX *mem_ctx, + struct tdgram_context **dgram, + const char *location); +#define tdgram_inet_udp_socket(local, remote, mem_ctx, dgram) \ + _tdgram_inet_udp_socket(local, remote, mem_ctx, dgram, __location__) + +int _tdgram_unix_dgram_socket(const struct tsocket_address *local, + const struct tsocket_address *remote, + TALLOC_CTX *mem_ctx, + struct tdgram_context **dgram, + const char *location); +#define tdgram_unix_dgram_socket(local, remote, mem_ctx, dgram) \ + _tdgram_unix_dgram_socket(local, remote, mem_ctx, dgram, __location__) + /* * Async helpers */ -- cgit