mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-11 07:22:22 +00:00
Align patches with the fix submitted upstream.
Obtained from: https://issues.asterisk.org/jira/browse/ASTERISK-26617
This commit is contained in:
parent
3985e8599c
commit
42a62fcabe
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=427462
@ -2,6 +2,7 @@
|
||||
|
||||
PORTNAME= asterisk
|
||||
PORTVERSION= 13.13.0
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= net
|
||||
MASTER_SITES= http://downloads.asterisk.org/pub/telephony/%SUBDIR%/:DEFAULT,g729
|
||||
MASTER_SITE_SUBDIR= asterisk/ \
|
||||
|
16
net/asterisk13/files/patch-include_asterisk_utils.h
Normal file
16
net/asterisk13/files/patch-include_asterisk_utils.h
Normal file
@ -0,0 +1,16 @@
|
||||
--- include/asterisk/utils.h.orig 2016-11-23 15:26:01 UTC
|
||||
+++ include/asterisk/utils.h
|
||||
@@ -1127,4 +1127,13 @@ int ast_file_is_readable(const char *fil
|
||||
*/
|
||||
int ast_compare_versions(const char *version1, const char *version2);
|
||||
|
||||
+/*
|
||||
+ * \brief Test that an OS supports IPv6 Networking.
|
||||
+ * \since 13.14.0
|
||||
+ *
|
||||
+ * \return True (non-zero) if the IPv6 supported.
|
||||
+ * \return False (zero) if the OS doesn't support IPv6.
|
||||
+ */
|
||||
+int ast_check_ipv6(void);
|
||||
+
|
||||
#endif /* _ASTERISK_UTILS_H */
|
@ -1,65 +0,0 @@
|
||||
--- main/udptl.c.orig 2016-11-23 15:26:01 UTC
|
||||
+++ main/udptl.c
|
||||
@@ -1016,6 +1016,9 @@ struct ast_udptl *ast_udptl_new_with_bin
|
||||
int i;
|
||||
long int flags;
|
||||
RAII_VAR(struct udptl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
|
||||
+#if defined(__FreeBSD__)
|
||||
+ int portretryipv4 = 1;
|
||||
+#endif
|
||||
|
||||
if (!cfg || !cfg->general) {
|
||||
ast_log(LOG_ERROR, "Could not access global udptl options!\n");
|
||||
@@ -1039,8 +1042,18 @@ struct ast_udptl *ast_udptl_new_with_bin
|
||||
udptl->tx[i].buf_len = -1;
|
||||
}
|
||||
|
||||
- if ((udptl->fd = socket(ast_sockaddr_is_ipv6(addr) ?
|
||||
- AF_INET6 : AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
+#if defined(__FreeBSD__)
|
||||
+ udptl->fd = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
+ if (udptl->fd < 0) {
|
||||
+ ast_sockaddr_parse(addr, "0.0.0.0", 0);
|
||||
+ udptl->fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ portretryipv4 = 0;
|
||||
+ }
|
||||
+#else
|
||||
+ udptl->fd = socket(ast_sockaddr_is_ipv6(addr) ?
|
||||
+ AF_INET6 : AF_INET, SOCK_DGRAM, 0);
|
||||
+#endif
|
||||
+ if (udptl->fd < 0) {
|
||||
ast_free(udptl);
|
||||
ast_log(LOG_WARNING, "Unable to allocate socket: %s\n", strerror(errno));
|
||||
return NULL;
|
||||
@@ -1079,8 +1092,30 @@ struct ast_udptl *ast_udptl_new_with_bin
|
||||
if (x > cfg->general->end)
|
||||
x = cfg->general->start;
|
||||
if (x == startplace) {
|
||||
+#if defined(__FreeBSD__)
|
||||
+ /* Try again with IPv4 if not IPv6 port could be found */
|
||||
+ if (portretryipv4 == 1) {
|
||||
+ close(udptl->fd);
|
||||
+ ast_sockaddr_parse(addr, "0.0.0.0", 0);
|
||||
+ udptl->fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ if (udptl->fd >= 0) {
|
||||
+ flags = fcntl(udptl->fd, F_GETFL);
|
||||
+ fcntl(udptl->fd, F_SETFL, flags | O_NONBLOCK);
|
||||
+ /* Reset the RTP port search parameters */
|
||||
+ x = (cfg->general->start == cfg->general->end) ? cfg->general->start : (ast_random() % (cfg->general->end - cfg->general->start)) + cfg->general->start;
|
||||
+ if (cfg->general->use_even_ports && (x & 1)) {
|
||||
+ ++x;
|
||||
+ }
|
||||
+ startplace = x;
|
||||
+ portretryipv4 = 0;
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
ast_log(LOG_WARNING, "No UDPTL ports remaining\n");
|
||||
- close(udptl->fd);
|
||||
+ if (udptl->fd >= 0) {
|
||||
+ close(udptl->fd);
|
||||
+ }
|
||||
ast_free(udptl);
|
||||
return NULL;
|
||||
}
|
21
net/asterisk13/files/patch-main_utils.c
Normal file
21
net/asterisk13/files/patch-main_utils.c
Normal file
@ -0,0 +1,21 @@
|
||||
--- main/utils.c.orig 2016-11-23 15:26:01 UTC
|
||||
+++ main/utils.c
|
||||
@@ -2425,6 +2425,18 @@ char *ast_utils_which(const char *binary
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+int ast_check_ipv6(void)
|
||||
+{
|
||||
+ int udp6_socket = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
+
|
||||
+ if (udp6_socket < 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ close(udp6_socket);
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
void DO_CRASH_NORETURN ast_do_crash(void)
|
||||
{
|
||||
#if defined(DO_CRASH)
|
23
net/asterisk13/files/patch-res_res__pjsip__sdp__rtp.c
Normal file
23
net/asterisk13/files/patch-res_res__pjsip__sdp__rtp.c
Normal file
@ -0,0 +1,23 @@
|
||||
--- res/res_pjsip_sdp_rtp.c.orig 2016-11-23 15:26:01 UTC
|
||||
+++ res/res_pjsip_sdp_rtp.c
|
||||
@@ -51,6 +51,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revisi
|
||||
#include "asterisk/acl.h"
|
||||
#include "asterisk/sdp_srtp.h"
|
||||
#include "asterisk/dsp.h"
|
||||
+#include "asterisk/utils.h"
|
||||
|
||||
#include "asterisk/res_pjsip.h"
|
||||
#include "asterisk/res_pjsip_session.h"
|
||||
@@ -1493,7 +1494,11 @@ static int load_module(void)
|
||||
{
|
||||
CHECK_PJSIP_SESSION_MODULE_LOADED();
|
||||
|
||||
- ast_sockaddr_parse(&address_rtp, "::", 0);
|
||||
+ if (ast_check_ipv6()) {
|
||||
+ ast_sockaddr_parse(&address_rtp, "::", 0);
|
||||
+ } else {
|
||||
+ ast_sockaddr_parse(&address_rtp, "0.0.0.0", 0);
|
||||
+ }
|
||||
|
||||
if (!(sched = ast_sched_context_create())) {
|
||||
ast_log(LOG_ERROR, "Unable to create scheduler context.\n");
|
23
net/asterisk13/files/patch-res_res__pjsip__t38.c
Normal file
23
net/asterisk13/files/patch-res_res__pjsip__t38.c
Normal file
@ -0,0 +1,23 @@
|
||||
--- res/res_pjsip_t38.c.orig 2016-11-23 15:26:01 UTC
|
||||
+++ res/res_pjsip_t38.c
|
||||
@@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revisi
|
||||
#include "asterisk/netsock2.h"
|
||||
#include "asterisk/channel.h"
|
||||
#include "asterisk/acl.h"
|
||||
+#include "asterisk/utils.h"
|
||||
|
||||
#include "asterisk/res_pjsip.h"
|
||||
#include "asterisk/res_pjsip_session.h"
|
||||
@@ -918,7 +919,11 @@ static int load_module(void)
|
||||
{
|
||||
CHECK_PJSIP_SESSION_MODULE_LOADED();
|
||||
|
||||
- ast_sockaddr_parse(&address, "::", 0);
|
||||
+ if (ast_check_ipv6()) {
|
||||
+ ast_sockaddr_parse(&address, "::", 0);
|
||||
+ } else {
|
||||
+ ast_sockaddr_parse(&address, "0.0.0.0", 0);
|
||||
+ }
|
||||
|
||||
if (ast_sip_session_register_supplement(&t38_supplement)) {
|
||||
ast_log(LOG_ERROR, "Unable to register T.38 session supplement\n");
|
@ -1,65 +0,0 @@
|
||||
--- res/res_rtp_asterisk.c.orig 2016-11-23 15:26:01 UTC
|
||||
+++ res/res_rtp_asterisk.c
|
||||
@@ -2638,6 +2638,9 @@ static int ast_rtp_new(struct ast_rtp_in
|
||||
{
|
||||
struct ast_rtp *rtp = NULL;
|
||||
int x, startplace;
|
||||
+#if defined(__FreeBSD__)
|
||||
+ int portretryipv4 = 1;
|
||||
+#endif
|
||||
|
||||
/* Create a new RTP structure to hold all of our data */
|
||||
if (!(rtp = ast_calloc(1, sizeof(*rtp)))) {
|
||||
@@ -2658,10 +2661,20 @@ static int ast_rtp_new(struct ast_rtp_in
|
||||
}
|
||||
|
||||
/* Create a new socket for us to listen on and use */
|
||||
- if ((rtp->s =
|
||||
- create_new_socket("RTP",
|
||||
- ast_sockaddr_is_ipv4(addr) ? AF_INET :
|
||||
- ast_sockaddr_is_ipv6(addr) ? AF_INET6 : -1)) < 0) {
|
||||
+#if defined(__FreeBSD__)
|
||||
+ rtp->s = create_new_socket("RTP", AF_INET6);
|
||||
+ if (rtp->s < 0) {
|
||||
+ /* create correct addr structure for AF_INET */
|
||||
+ ast_sockaddr_parse(addr, "0.0.0.0", 0);
|
||||
+ rtp->s = create_new_socket("RTP", AF_INET);
|
||||
+ portretryipv4 = 0;
|
||||
+ }
|
||||
+#else
|
||||
+ rtp->s = create_new_socket("RTP",
|
||||
+ ast_sockaddr_is_ipv4(addr) ? AF_INET :
|
||||
+ ast_sockaddr_is_ipv6(addr) ? AF_INET6 : -1);
|
||||
+#endif
|
||||
+ if (rtp->s < 0) {
|
||||
ast_log(LOG_WARNING, "Failed to create a new socket for RTP instance '%p'\n", instance);
|
||||
ast_free(rtp);
|
||||
return -1;
|
||||
@@ -2688,8 +2701,26 @@ static int ast_rtp_new(struct ast_rtp_in
|
||||
|
||||
/* See if we ran out of ports or if the bind actually failed because of something other than the address being in use */
|
||||
if (x == startplace || (errno != EADDRINUSE && errno != EACCES)) {
|
||||
+#if defined(__FreeBSD__)
|
||||
+ /* Try again with IPv4 if not IPv6 port could be found */
|
||||
+ if (portretryipv4 == 1) {
|
||||
+ close(rtp->s);
|
||||
+ ast_sockaddr_parse(addr, "0.0.0.0", 0);
|
||||
+ rtp->s = create_new_socket("RTP", AF_INET);
|
||||
+ if (rtp->s >= 0) {
|
||||
+ /* Reset the RTP port search parameters */
|
||||
+ x = (rtpend == rtpstart) ? rtpstart : (ast_random() % (rtpend - rtpstart)) + rtpstart;
|
||||
+ x = x & ~1;
|
||||
+ startplace = x;
|
||||
+ portretryipv4 = 0;
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
ast_log(LOG_ERROR, "Oh dear... we couldn't allocate a port for RTP instance '%p'\n", instance);
|
||||
- close(rtp->s);
|
||||
+ if (rtp->s >= 0) {
|
||||
+ close(rtp->s);
|
||||
+ }
|
||||
ast_free(rtp);
|
||||
return -1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user