static int sip_addheader(struct ast_channel *chan, const char *data);
static int sip_do_reload(enum channelreloadreason reason);
static char *sip_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
-static int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,
- const char *name, int flag, int family);
static int ast_sockaddr_resolve_first(struct ast_sockaddr *addr,
const char *name, int flag);
static int ast_sockaddr_resolve_first_transport(struct ast_sockaddr *addr,
return AST_MODULE_LOAD_SUCCESS;
}
-/*! \brief Return the first entry from ast_sockaddr_resolve filtered by address family
- *
- * \warning Using this function probably means you have a faulty design.
- */
-static int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,
- const char* name, int flag, int family)
-{
- struct ast_sockaddr *addrs;
- int addrs_cnt;
-
- addrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);
- if (addrs_cnt <= 0) {
- return 1;
- }
- if (addrs_cnt > 1) {
- ast_debug(1, "Multiple addresses, using the first one only\n");
- }
-
- ast_sockaddr_copy(addr, &addrs[0]);
-
- ast_free(addrs);
- return 0;
-}
-
/*! \brief Return the first entry from ast_sockaddr_resolve filtered by family of binddaddr
*
* \warning Using this function probably means you have a faulty design.
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str,
int flags, int family);
+/*!
+ * \since 16.0
+ *
+ * \brief
+ * Return the first entry from ast_sockaddr_resolve filtered by address family
+ *
+ * \details
+ * Parses a string containing a host name or an IPv4 or IPv6 address followed
+ * by an optional port (separated by a colon). This function only returns the
+ * first address into the ast_sockaddr. Allowed formats for name are the following:
+ *
+ * hostname:port
+ * host.example.com:port
+ * a.b.c.d
+ * a.b.c.d:port
+ * a:b:c:...:d
+ * [a:b:c:...:d]
+ * [a:b:c:...:d]:port
+ *
+ * \param[out] addr The resulting ast_sockaddr
+ * \param name The string to parse
+ * \param flags If set to zero, a port MAY be present. If set to
+ * PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to
+ * PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a
+ * port MUST NOT be present.
+ *
+ * \param family Only addresses of the given family will be returned. Use 0 or
+ * AST_AF_UNSPEC to specify any address family. Behavior is ultimately determined
+ * by getaddrinfo in how it orders return results. First result is selected to
+ * be returned.
+ *
+ * \retval 0 Success
+ * \retval non-zero Failure
+ * \warning Using this function potentially means you have a faulty design.
+ */
+int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,
+ const char* name, int flag, int family);
+
/*!
* \brief
* Apply a netmask to an address and store the result in a separate structure.
return res_cnt;
}
+/*! \brief Pulls first resolved address and returns it */
+int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,
+ const char* name, int flag, int family)
+{
+ struct ast_sockaddr *addrs;
+ int addrs_cnt;
+
+ addrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);
+ if (addrs_cnt <= 0) {
+ return 1;
+ }
+ if (addrs_cnt > 1) {
+ ast_debug(1, "Multiple addresses resolving %s, using the first one only\n", name);
+ }
+
+ ast_sockaddr_copy(addr, &addrs[0]);
+
+ ast_free(addrs);
+ return 0;
+}
+
int ast_sockaddr_apply_netmask(const struct ast_sockaddr *addr, const struct ast_sockaddr *netmask,
struct ast_sockaddr *result)
{
}
}
-/*! \brief Pulls first resolved address and returns it */
-static int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,
- const char* name, int flag, int family)
-{
- struct ast_sockaddr *addrs;
- int addrs_cnt;
-
- addrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);
- if (addrs_cnt <= 0) {
- return 1;
- }
- if (addrs_cnt > 1) {
- ast_debug(1, "Multiple addresses resolving %s, using the first one only\n", name);
- }
-
- ast_sockaddr_copy(addr, &addrs[0]);
-
- ast_free(addrs);
- return 0;
-}
-
/*! \brief Allocate the HEPv3 run-time data */
static struct hepv3_runtime_data *hepv3_data_alloc(struct hepv3_global_config *config)
{
static enum pjsip_logging_mode logging_mode;
static struct ast_sockaddr log_addr;
-/*! \brief Return the first entry from ast_sockaddr_resolve filtered by address family
- *
- * \warning Using this function probably means you have a faulty design.
- * \note This function was taken from the function of the same name in chan_sip.c
- */
-static int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr,
- const char* name, int flag, int family)
-{
- struct ast_sockaddr *addrs;
- int addrs_cnt;
-
- addrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);
- if (addrs_cnt <= 0) {
- return 1;
- }
- if (addrs_cnt > 1) {
- ast_debug(1, "Multiple addresses, using the first one only\n");
- }
-
- ast_sockaddr_copy(addr, &addrs[0]);
-
- ast_free(addrs);
- return 0;
-}
-
/*! \brief See if we pass debug IP filter */
static inline int pjsip_log_test_addr(const char *address, int port)
{