res_pjproject: Fix sockaddr conversion routines for non-bundled PJSIP
authorSean Bright <sean.bright@gmail.com>
Wed, 12 Sep 2018 12:18:07 +0000 (08:18 -0400)
committerSean Bright <sean.bright@gmail.com>
Wed, 12 Sep 2018 12:26:33 +0000 (07:26 -0500)
The bundled version of pjproject has a patch for Solaris compatability
that changes the definition of various socket structures which we need
to account for when compiling against a non-bundled version.

ASTERISK-28049 #close

Change-Id: Ia1ea47c433fc2d915115193ee889a752373925f0

res/res_pjproject.c

index 5b133ec..2bb5d3b 100644 (file)
@@ -478,7 +478,11 @@ int ast_sockaddr_to_pj_sockaddr(const struct ast_sockaddr *addr, pj_sockaddr *pj
        if (addr->ss.ss_family == AF_INET) {
                struct sockaddr_in *sin = (struct sockaddr_in *) &addr->ss;
                pjaddr->ipv4.sin_family = pj_AF_INET();
-               pjaddr->ipv4.sin_addr   = sin->sin_addr;
+#ifdef HAVE_PJPROJECT_BUNDLED
+               pjaddr->ipv4.sin_addr = sin->sin_addr;
+#else
+               pjaddr->ipv4.sin_addr.s_addr = sin->sin_addr.s_addr;
+#endif
                pjaddr->ipv4.sin_port   = sin->sin_port;
        } else if (addr->ss.ss_family == AF_INET6) {
                struct sockaddr_in6 *sin = (struct sockaddr_in6 *) &addr->ss;
@@ -499,7 +503,11 @@ int ast_sockaddr_from_pj_sockaddr(struct ast_sockaddr *addr, const pj_sockaddr *
        if (pjaddr->addr.sa_family == pj_AF_INET()) {
                struct sockaddr_in *sin = (struct sockaddr_in *) &addr->ss;
                sin->sin_family = AF_INET;
-               sin->sin_addr   = pjaddr->ipv4.sin_addr;
+#ifdef HAVE_PJPROJECT_BUNDLED
+               sin->sin_addr = pjaddr->ipv4.sin_addr;
+#else
+               sin->sin_addr.s_addr = pjaddr->ipv4.sin_addr.s_addr;
+#endif
                sin->sin_port   = pjaddr->ipv4.sin_port;
                addr->len = sizeof(struct sockaddr_in);
        } else if (pjaddr->addr.sa_family == pj_AF_INET6()) {