summaryrefslogtreecommitdiff
path: root/pjlib/src/pj/addr_resolv_symbian.cpp
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-12-31 11:26:21 +0000
committerBenny Prijono <bennylp@teluu.com>2007-12-31 11:26:21 +0000
commitbaa2f7d1c0e83897cc89fd8a02846af9f1eca4e6 (patch)
tree1e2618ba0671369ca7b701e4c97ad5f189d28b83 /pjlib/src/pj/addr_resolv_symbian.cpp
parentd378a0cda4735265cce253e38d636cb416ff8ad5 (diff)
Fixed IPv6/IPv4 address issue in Symbian: Symbian, at least 9.1, seems to have dual stack IP, so IPv4 address can be returned as a mapped IPv6 address
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1647 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/addr_resolv_symbian.cpp')
-rw-r--r--pjlib/src/pj/addr_resolv_symbian.cpp76
1 files changed, 53 insertions, 23 deletions
diff --git a/pjlib/src/pj/addr_resolv_symbian.cpp b/pjlib/src/pj/addr_resolv_symbian.cpp
index d3698b51..9a28cbb9 100644
--- a/pjlib/src/pj/addr_resolv_symbian.cpp
+++ b/pjlib/src/pj/addr_resolv_symbian.cpp
@@ -20,12 +20,15 @@
#include <pj/assert.h>
#include <pj/errno.h>
#include <pj/ip_helper.h>
+#include <pj/log.h>
#include <pj/sock.h>
#include <pj/string.h>
#include <pj/unicode.h>
#include "os_symbian.h"
+#define THIS_FILE "addr_resolv_symbian.cpp"
+#define TRACE_ME 0
// PJLIB API: resolve hostname
@@ -86,32 +89,59 @@ static pj_status_t getaddrinfo_by_af(int af, const pj_str_t *name,
i = 0;
while (reqStatus == KErrNone && i < *count) {
- // Get the resolved TInetAddr
- TInetAddr inetAddr(nameEntry().iAddr);
- int addrlen;
+ // Get the resolved TInetAddr
+ TInetAddr inetAddr(nameEntry().iAddr);
+ int addrlen;
- // Ignore if this is not the same address family
- if (inetAddr.Family() != (unsigned)af) {
- resv.Next(nameEntry, reqStatus);
- User::WaitForRequest(reqStatus);
- continue;
- }
-
- // Convert the official address to ANSI.
- pj_unicode_to_ansi((const wchar_t*)nameEntry().iName.Ptr(),
- nameEntry().iName.Length(),
- ai[i].ai_canonname, sizeof(ai[i].ai_canonname));
+#if TRACE_ME
+ if (1) {
+ pj_sockaddr a;
+ char ipaddr[PJ_INET6_ADDRSTRLEN+2];
+ int namelen;
+
+ namelen = sizeof(pj_sockaddr);
+ if (PjSymbianOS::Addr2pj(inetAddr, a, &namelen,
+ PJ_FALSE) == PJ_SUCCESS)
+ {
+ PJ_LOG(5,(THIS_FILE, "resolve %.*s: %s",
+ (int)name->slen, name->ptr,
+ pj_sockaddr_print(&a, ipaddr, sizeof(ipaddr), 2)));
+ }
+ }
+#endif
+
+ // Ignore if this is not the same address family
+ // Not a good idea, as Symbian mapps IPv4 to IPv6.
+ //fam = inetAddr.Family();
+ //if (fam != af) {
+ // resv.Next(nameEntry, reqStatus);
+ // User::WaitForRequest(reqStatus);
+ // continue;
+ //}
+
+ // Convert IP address first to get IPv4 mapped address
+ addrlen = sizeof(ai[i].ai_addr);
+ status = PjSymbianOS::Addr2pj(inetAddr, ai[i].ai_addr,
+ &addrlen, PJ_TRUE);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ // Ignore if address family doesn't match
+ if (ai[i].ai_addr.addr.sa_family != af) {
+ resv.Next(nameEntry, reqStatus);
+ User::WaitForRequest(reqStatus);
+ continue;
+ }
- // Convert IP address
- addrlen = sizeof(ai[i].ai_addr);
- status = PjSymbianOS::Addr2pj(inetAddr, ai[i].ai_addr, &addrlen);
- if (status != PJ_SUCCESS)
- return status;
+ // Convert the official address to ANSI.
+ pj_unicode_to_ansi((const wchar_t*)nameEntry().iName.Ptr(),
+ nameEntry().iName.Length(),
+ ai[i].ai_canonname, sizeof(ai[i].ai_canonname));
- // Next
- ++i;
- resv.Next(nameEntry, reqStatus);
- User::WaitForRequest(reqStatus);
+ // Next
+ ++i;
+ resv.Next(nameEntry, reqStatus);
+ User::WaitForRequest(reqStatus);
}
*count = i;