From 36b97d0bb9fe004f3d8a500f3af83dff34f86d7b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 May 2015 11:39:38 +0200 Subject: lib/tsocket: add tdgram_inet_udp_broadcast_socket() This is similar to tdgram_inet_udp_socket(), but it allows the use of ipv4 broadcast traffic. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke Reviewed-by: Jeremy Allison --- lib/tsocket/tsocket.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'lib/tsocket/tsocket.h') diff --git a/lib/tsocket/tsocket.h b/lib/tsocket/tsocket.h index 296c7c555ae..f52b7466dfb 100644 --- a/lib/tsocket/tsocket.h +++ b/lib/tsocket/tsocket.h @@ -705,6 +705,8 @@ bool tdgram_bsd_optimize_recvfrom(struct tdgram_context *dgram, * communication. The function will allocate the memory. * * @return 0 on success, -1 on error with errno set. + * + * @see tdgram_inet_udp_broadcast_socket() */ int tdgram_inet_udp_socket(const struct tsocket_address *local, const struct tsocket_address *remote, @@ -720,6 +722,33 @@ int _tdgram_inet_udp_socket(const struct tsocket_address *local, _tdgram_inet_udp_socket(local, remote, mem_ctx, dgram, __location__) #endif +#ifdef DOXYGEN +/** + * @brief Create a tdgram_context for a ipv4 UDP broadcast (and unicast) communication. + * + * @param[in] local An 'inet' (ipv4 only) tsocket_address for the local endpoint. + * + * @param[in] mem_ctx The talloc memory context to use. + * + * @param[in] dgram The tdgram_context pointer to setup the udp + * communication. The function will allocate the memory. + * + * @return 0 on success, -1 on error with errno set. + * + * @see tdgram_inet_udp_socket() + */ +int tdgram_inet_udp_broadcast_socket(const struct tsocket_address *local, + TALLOC_CTX *mem_ctx, + struct tdgram_context **dgram); +#else +int _tdgram_inet_udp_broadcast_socket(const struct tsocket_address *local, + TALLOC_CTX *mem_ctx, + struct tdgram_context **dgram, + const char *location); +#define tdgram_inet_udp_broadcast_socket(local, mem_ctx, dgram) \ + _tdgram_inet_udp_broadcast_socket(local, mem_ctx, dgram, __location__) +#endif + #ifdef DOXYGEN /** * @brief Create a tdgram_context for unix domain datagram communication. -- cgit v1.2.1