mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
lib:tsocket: New function to build a tsocket_context from samba_address
Signed-off-by: Samuel Cabrero <scabrero@suse.de> Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
0a65fa8a9a
commit
8cb921d255
@ -26,6 +26,7 @@
|
||||
|
||||
#include <tevent.h>
|
||||
|
||||
struct samba_sockaddr;
|
||||
struct tsocket_address;
|
||||
struct tdgram_context;
|
||||
struct tstream_context;
|
||||
@ -982,6 +983,32 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx,
|
||||
__location__)
|
||||
#endif
|
||||
|
||||
#ifdef DOXYGEN
|
||||
/**
|
||||
* @brief Convert a samba address to a tsocket address.
|
||||
*
|
||||
* @param[in] mem_ctx The talloc memory context to use.
|
||||
*
|
||||
* @param[in] s_addr The samba address structure to convert.
|
||||
*
|
||||
* @param[out] t_addr The tsocket pointer to allocate and fill.
|
||||
*
|
||||
* @return 0 on success, -1 on error with errno set.
|
||||
*/
|
||||
int tsocket_address_bsd_from_samba_sockaddr(TALLOC_CTX *mem_ctx,
|
||||
const struct samba_sockaddr *s_addr,
|
||||
struct tsocket_address **t_addr);
|
||||
#else
|
||||
int _tsocket_address_bsd_from_samba_sockaddr(TALLOC_CTX *mem_ctx,
|
||||
const struct samba_sockaddr *s_addr,
|
||||
struct tsocket_address **t_addr,
|
||||
const char *location);
|
||||
|
||||
#define tsocket_address_bsd_from_samba_sockaddr(mem_ctx, s_addr, t_addr) \
|
||||
_tsocket_address_bsd_from_samba_sockaddr(mem_ctx, s_addr, t_addr, \
|
||||
__location__)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Fill a bsd sockaddr structure.
|
||||
*
|
||||
|
@ -281,6 +281,18 @@ int _tsocket_address_bsd_from_sockaddr(TALLOC_CTX *mem_ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _tsocket_address_bsd_from_samba_sockaddr(TALLOC_CTX *mem_ctx,
|
||||
const struct samba_sockaddr *s_addr,
|
||||
struct tsocket_address **t_addr,
|
||||
const char *location)
|
||||
{
|
||||
return _tsocket_address_bsd_from_sockaddr(mem_ctx,
|
||||
&s_addr->u.sa,
|
||||
s_addr->sa_socklen,
|
||||
t_addr,
|
||||
location);
|
||||
}
|
||||
|
||||
ssize_t tsocket_address_bsd_sockaddr(const struct tsocket_address *addr,
|
||||
struct sockaddr *sa,
|
||||
size_t sa_socklen)
|
||||
|
Loading…
x
Reference in New Issue
Block a user