Asterisk - The Open Source Telephony Project  21.4.1
res_pjproject.h
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2016, Fairview 5 Engineering, LLC
5  *
6  * George Joseph <george.joseph@fairview5.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 #ifndef _RES_PJPROJECT_H
20 #define _RES_PJPROJECT_H
21 
22 #include <pj/types.h>
23 #include <pj/pool.h>
24 
25 struct ast_sockaddr;
26 
27 /*!
28  * \brief Retrieve a pjproject build option
29  *
30  * \param option The build option requested
31  * \param format_string A scanf-style format string to parse the option value into
32  * \param ... Pointers to variables to receive the values parsed
33  *
34  * \retval The number of values parsed
35  *
36  * \since 13.8.0
37  *
38  * \note The option requested must be from those returned by pj_dump_config()
39  * which can be displayed with the 'pjsip show buildopts' CLI command.
40  *
41  * <b>Sample Usage:</b>
42  * \code
43  *
44  * int max_hostname;
45  *
46  * ast_sip_get_pjproject_buildopt("PJ_MAX_HOSTNAME", "%d", &max_hostname);
47  *
48  * \endcode
49  *
50  */
51 int ast_pjproject_get_buildopt(char *option, char *format_string, ...) __attribute__((format(scanf, 2, 3)));
52 
53 /*!
54  * \brief Begin PJPROJECT log interception for CLI output.
55  * \since 13.8.0
56  *
57  * \param fd CLI file descriptior to send intercepted output.
58  *
59  * \note ast_pjproject_log_intercept_begin() and
60  * ast_pjproject_log_intercept_end() must always be called
61  * in pairs.
62  */
64 
65 /*!
66  * \brief End PJPROJECT log interception for CLI output.
67  * \since 13.8.0
68  *
69  * \note ast_pjproject_log_intercept_begin() and
70  * ast_pjproject_log_intercept_end() must always be called
71  * in pairs.
72  */
74 
75 /*!
76  * \brief Initialize the caching pool factory.
77  * \since 13.21.0
78  *
79  * \param cp Caching pool factory to initialize
80  * \param policy Pool factory policy
81  * \param max_capacity Total capacity to be retained in the cache. Zero disables caching.
82  */
83 void ast_pjproject_caching_pool_init(pj_caching_pool *cp,
84  const pj_pool_factory_policy *policy, pj_size_t max_capacity);
85 
86 /*!
87  * \brief Destroy caching pool factory and all cached pools.
88  * \since 13.21.0
89  *
90  * \param cp Caching pool factory to destroy
91  */
92 void ast_pjproject_caching_pool_destroy(pj_caching_pool *cp);
93 
94 /*!
95  * \brief Fill a pj_sockaddr from an ast_sockaddr
96  * \since 13.24.0
97  *
98  * \param addr The source address to copy
99  * \param pjaddr The target address to receive the copied address
100  *
101  * \retval 0 Success
102  * \retval -1 Failure
103  */
104 int ast_sockaddr_to_pj_sockaddr(const struct ast_sockaddr *addr, pj_sockaddr *pjaddr);
105 
106 /*!
107  * \brief Fill an ast_sockaddr from a pj_sockaddr
108  * \since 13.24.0
109  *
110  * \param addr The target address to receive the copied address
111  * \param pjaddr The source address to copy
112  *
113  * \retval 0 Success
114  * \retval -1 Failure
115  */
116 int ast_sockaddr_from_pj_sockaddr(struct ast_sockaddr *addr, const pj_sockaddr *pjaddr);
117 
118 /*!
119  * \brief Compare an ast_sockaddr to a pj_sockaddr
120  *
121  * \param addr pointer to ast_sockaddr structure
122  * \param pjaddr pointer to pj_sockaddr structure
123  *
124  * \retval -1 \a addr is lexicographically smaller than \a pjaddr
125  * \retval 0 \a addr is equal to \a pjaddr
126  * \retval 1 \a pjaddr is lexicographically smaller than \a addr
127 */
128 int ast_sockaddr_pj_sockaddr_cmp(const struct ast_sockaddr *addr,
129  const pj_sockaddr *pjaddr);
130 
131 #endif /* _RES_PJPROJECT_H */
void ast_pjproject_caching_pool_init(pj_caching_pool *cp, const pj_pool_factory_policy *policy, pj_size_t max_capacity)
Initialize the caching pool factory.
Socket address structure.
Definition: netsock2.h:97
void ast_pjproject_log_intercept_end(void)
End PJPROJECT log interception for CLI output.
void ast_pjproject_log_intercept_begin(int fd)
Begin PJPROJECT log interception for CLI output.
int ast_pjproject_get_buildopt(char *option, char *format_string,...)
Retrieve a pjproject build option.
void ast_pjproject_caching_pool_destroy(pj_caching_pool *cp)
Destroy caching pool factory and all cached pools.
int ast_sockaddr_from_pj_sockaddr(struct ast_sockaddr *addr, const pj_sockaddr *pjaddr)
Fill an ast_sockaddr from a pj_sockaddr.
int ast_sockaddr_pj_sockaddr_cmp(const struct ast_sockaddr *addr, const pj_sockaddr *pjaddr)
Compare an ast_sockaddr to a pj_sockaddr.
int ast_sockaddr_to_pj_sockaddr(const struct ast_sockaddr *addr, pj_sockaddr *pjaddr)
Fill a pj_sockaddr from an ast_sockaddr.