diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/io.h | 24 | ||||
-rw-r--r-- | include/asterisk/netsock2.h | 16 |
2 files changed, 40 insertions, 0 deletions
diff --git a/include/asterisk/io.h b/include/asterisk/io.h index 6ee8450bd..f103cf556 100644 --- a/include/asterisk/io.h +++ b/include/asterisk/io.h @@ -24,6 +24,7 @@ #define _ASTERISK_IO_H #include "asterisk/poll-compat.h" +#include "asterisk/netsock2.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { @@ -148,6 +149,29 @@ int ast_get_termcols(int fd); */ int ast_sd_notify(const char *state); +/*! + * \brief Find a listening file descriptor provided by socket activation. + * \param type SOCK_STREAM or SOCK_DGRAM + * \param addr The socket address of the bound listener. + * \retval <0 No match. + * \retval >0 File Descriptor matching sockaddr. + * + * \note This function returns -1 if systemd's development headers were not + * detected on the system. + */ +int ast_sd_get_fd(int type, const struct ast_sockaddr *addr); + +/*! + * \brief Find a listening AF_LOCAL file descriptor provided by socket activation. + * \param type SOCK_STREAM or SOCK_DGRAM + * \param path The path of the listener. + * \retval <0 No match. + * \retval >0 File Descriptor matching path. + * + * \note This function returns -1 if systemd's development headers were not + * detected on the system. + */ +int ast_sd_get_fd_un(int type, const char *path); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/include/asterisk/netsock2.h b/include/asterisk/netsock2.h index 3ede99087..6c0dd633b 100644 --- a/include/asterisk/netsock2.h +++ b/include/asterisk/netsock2.h @@ -129,6 +129,22 @@ static inline void ast_sockaddr_setnull(struct ast_sockaddr *addr) } /*! + * \brief + * Copies the data from a sockaddr to an ast_sockaddr + * + * \param dst The destination ast_sockaddr + * \param src The source sockaddr + * \param len Length of the value stored in sockaddr + * \retval void + */ +static inline void ast_sockaddr_copy_sockaddr(struct ast_sockaddr *dst, + struct sockaddr *src, socklen_t len) +{ + memcpy(dst, src, len); + dst->len = len; +} + +/*! * \since 1.8 * * \brief |