summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2017-06-18 20:24:04 -0400
committerCorey Farrell <git@cfware.com>2017-07-21 14:04:33 -0500
commiteea9da2f42c23fae72bb5b67c51dd38ab3a92a8d (patch)
treee0e69955214e682e2e4550cb8c6298c5adc147b3 /include/asterisk
parent7fcb730997a54fd58a2edf47489f464c34c6e156 (diff)
Core: Add support for systemd socket activation.
This change adds support for socket activation of certain SOCK_STREAM listeners in Asterisk: * AMI / AMI over TLS * CLI * HTTP / HTTPS Example systemd units are provided. This support extends to any socket which is initialized using ast_tcptls_server_start, so any unknown modules using this function will support socket activation. Asterisk continues to function as normal if socket activation is not enabled or if systemd development headers are not available during build. ASTERISK-27063 #close Change-Id: Id814ee6a892f4b80d018365c8ad8d89063474f4d
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/io.h24
-rw-r--r--include/asterisk/netsock2.h16
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