[Asterisk-code-review] pjproject bundled: Fix for Solaris builds. Do not undef s addr. (asterisk[master])

Alexander Traud asteriskteam at digium.com
Mon Jul 30 07:46:32 CDT 2018


Alexander Traud has uploaded this change for review. ( https://gerrit.asterisk.org/9778


Change subject: pjproject_bundled: Fix for Solaris builds. Do not undef s_addr.
......................................................................

pjproject_bundled: Fix for Solaris builds. Do not undef s_addr.

The authors of PJProject undef s_addr because of some issue in Microsoft
Windows. However in Oracle Solaris, s_addr is not a structure member, but
defined to map to the real structure member.

ASTERISK-27997

Change-Id: I8223026d4d54e2a46521085fcc94bfa6ebe35b11
---
M res/res_pjsip/pjsip_resolver.c
A third-party/pjproject/patches/0120-solaris.patch
2 files changed, 121 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/78/9778/1

diff --git a/res/res_pjsip/pjsip_resolver.c b/res/res_pjsip/pjsip_resolver.c
index bc53990..5aa0582 100644
--- a/res/res_pjsip/pjsip_resolver.c
+++ b/res/res_pjsip/pjsip_resolver.c
@@ -327,7 +327,7 @@
 					resolve->addresses.entry[address_count].addr_len = sizeof(pj_sockaddr_in);
 					pj_sockaddr_init(pj_AF_INET(), &resolve->addresses.entry[address_count].addr, NULL,
 						target->port);
-					resolve->addresses.entry[address_count].addr.ipv4.sin_addr = *(struct pj_in_addr*)ast_dns_record_get_data(record);
+					resolve->addresses.entry[address_count].addr.ipv4.sin_addr = *(pj_in_addr*)ast_dns_record_get_data(record);
 				} else {
 					ast_debug(2, "[%p] AAAA record received on target '%s'\n", resolve, ast_dns_query_get_name(query));
 					resolve->addresses.entry[address_count].addr_len = sizeof(pj_sockaddr_in6);
diff --git a/third-party/pjproject/patches/0120-solaris.patch b/third-party/pjproject/patches/0120-solaris.patch
new file mode 100644
index 0000000..399beee
--- /dev/null
+++ b/third-party/pjproject/patches/0120-solaris.patch
@@ -0,0 +1,120 @@
+From e98e9e5323acc8af811c70a0d5bab1decf068ec9 Mon Sep 17 00:00:00 2001
+From: Shaun Ruffell <sruffell at digium.com>
+Date: Fri, 7 Sep 2012 14:31:19 -0500
+Subject: [PATCH 1/2] [RFC] pjproject: Fix for Solaris builds. Do not undef
+ s_addr.
+
+pjproject, in order to solve build problems on Windows [1], undefines s_addr in
+one of it's headers that is included in res_rtp_asterisk.c. On Solaris s_addr is
+not a structure member, but defined to map to the real strucuture member,
+therefore when building on Solaris it's possible to get build errors like:
+
+    [CC] res_rtp_asterisk.c -> res_rtp_asterisk.o
+    In file included from /export/home/admin/asterisk-11-svn/include/asterisk/stun.h:29,
+                     from res_rtp_asterisk.c:51:
+    /export/home/admin/asterisk-11-svn/include/asterisk/network.h: In function `inaddrcmp':
+    /export/home/admin/asterisk-11-svn/include/asterisk/network.h:92: error: structure has no member named `s_addr'
+    /export/home/admin/asterisk-11-svn/include/asterisk/network.h:92: error: structure has no member named `s_addr'
+    res_rtp_asterisk.c: In function `ast_rtp_on_ice_tx_pkt':
+    res_rtp_asterisk.c:706: warning: dereferencing type-punned pointer will break strict-aliasing rules
+    res_rtp_asterisk.c:710: warning: dereferencing type-punned pointer will break strict-aliasing rules
+    res_rtp_asterisk.c: In function `rtp_add_candidates_to_ice':
+    res_rtp_asterisk.c:1085: error: structure has no member named `s_addr'
+    make[2]: *** [res_rtp_asterisk.o] Error 1
+    make[1]: *** [res] Error 2
+    make[1]: Leaving directory `/export/home/admin/asterisk-11-svn'
+    gmake: *** [_cleantest_all] Error 2
+
+Unfortunately, in order to make this work, I also had to make sure pjproject
+only used the typdef pj_in_addr and not the struct pj_in_addr so that when
+building Asterisk I could "typedef struct in_addr pj_in_addr". It's possible
+then that the library and users of those interfaces in Asterisk have a different
+idea about the type of the argument. While on the surface it looks like they are
+all 32 bit big endian values.
+
+[1] http://trac.pjsip.org/repos/changeset/484
+
+Reported-by: Ben Klang
+(issues ASTERISK-20366)
+---
+ res/pjproject/pjlib/include/pj/sock.h          | 8 +++++++-
+ res/pjproject/pjlib/src/pj/sock_bsd.c          | 2 +-
+ res/pjproject/pjlib/src/pj/sock_linux_kernel.c | 2 +-
+ res/pjproject/pjlib/src/pj/sock_symbian.cpp    | 2 +-
+ 4 files changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h
+index 83d35db..0f8850d 100644
+--- a/pjlib/include/pj/sock.h
++++ b/pjlib/include/pj/sock.h
+@@ -471,6 +471,7 @@ typedef enum pj_socket_sd_type
+  */
+ #define PJ_INVALID_SOCKET   (-1)
+ 
++#ifndef _ASTERISK_H
+ /* Must undefine s_addr because of pj_in_addr below */
+ #undef s_addr
+ 
+@@ -482,6 +483,11 @@ typedef struct pj_in_addr
+     pj_uint32_t	s_addr;		/**< The 32bit IP address.	    */
+ } pj_in_addr;
+ 
++#else
++#include <sys/types.h>
++#include <netinet/in.h>
++typedef struct in_addr pj_in_addr;
++#endif
+ 
+ /**
+  * Maximum length of text representation of an IPv4 address.
+@@ -675,7 +681,7 @@ PJ_DECL(char*) pj_inet_ntoa(pj_in_addr inaddr);
+  *
+  * @return	nonzero if the address is valid, zero if not.
+  */
+-PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp);
++PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp);
+ 
+ /**
+  * This function converts an address in its standard text presentation form
+diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c
+index 9bd0356..3bd7121 100644
+--- a/pjlib/src/pj/sock_bsd.c
++++ b/pjlib/src/pj/sock_bsd.c
+@@ -232,7 +232,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
+  * numbers-and-dots notation into binary data and stores it in the structure
+  * that inp points to. 
+  */
+-PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
++PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
+ {
+     char tempaddr[PJ_INET_ADDRSTRLEN];
+ 
+diff --git a/pjlib/src/pj/sock_linux_kernel.c b/pjlib/src/pj/sock_linux_kernel.c
+index 89c2f0e..c7a8097 100644
+--- a/pjlib/src/pj/sock_linux_kernel.c
++++ b/pjlib/src/pj/sock_linux_kernel.c
+@@ -147,7 +147,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr in)
+  * numbers-and-dots notation into binary data and stores it in the structure
+  * that inp points to. 
+  */
+-PJ_DEF(int) pj_inet_aton(const pj_str_t *ccp, struct pj_in_addr *addr)
++PJ_DEF(int) pj_inet_aton(const pj_str_t *ccp, pj_in_addr *addr)
+ {
+     pj_uint32_t val;
+     int base, n;
+diff --git a/pjlib/src/pj/sock_symbian.cpp b/pjlib/src/pj/sock_symbian.cpp
+index 09239b0..e72bbda 100644
+--- a/pjlib/src/pj/sock_symbian.cpp
++++ b/pjlib/src/pj/sock_symbian.cpp
+@@ -299,7 +299,7 @@ PJ_DEF(char*) pj_inet_ntoa(pj_in_addr inaddr)
+  * numbers-and-dots notation into binary data and stores it in the structure
+  * that inp points to. 
+  */
+-PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp)
++PJ_DEF(int) pj_inet_aton(const pj_str_t *cp, pj_in_addr *inp)
+ {
+     enum { MAXIPLEN = PJ_INET_ADDRSTRLEN };
+ 
+-- 
+1.7.12
+

-- 
To view, visit https://gerrit.asterisk.org/9778
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8223026d4d54e2a46521085fcc94bfa6ebe35b11
Gerrit-Change-Number: 9778
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180730/d9209e2c/attachment-0001.html>


More information about the asterisk-code-review mailing list