Use IFA_LOCAL instead of IFA_ADDRESS over IPv4 network on ANDROID

IFA_ADDRESS gives DESTINATION address in case of point-to-point
connection, which is not able to create ports for candidate gathering.
Use IFA_LOCAL to avoid this problem.

Bug: webrtc:9189
Change-Id: Ifcb1955b1b4011dc69c93d99b4e223b370dc16eb
Reviewed-on: https://webrtc-review.googlesource.com/69620
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23055}
This commit is contained in:
Yongje Lee 2018-04-27 09:47:07 +09:00 committed by Commit Bot
parent ad3971f40f
commit ebd9abc1a2
2 changed files with 18 additions and 17 deletions

View file

@ -68,6 +68,7 @@ ARM Holdings <*@arm.com>
BroadSoft Inc. <*@broadsoft.com> BroadSoft Inc. <*@broadsoft.com>
Facebook Inc. <*@fb.com> Facebook Inc. <*@fb.com>
Google Inc. <*@google.com> Google Inc. <*@google.com>
HyperConnect Inc. <*@hpcnt.com>
Life On Air Inc. <*@lifeonair.com> Life On Air Inc. <*@lifeonair.com>
Intel Corporation <*@intel.com> Intel Corporation <*@intel.com>
MIPS Technologies <*@mips.com> MIPS Technologies <*@mips.com>

View file

@ -174,24 +174,24 @@ int getifaddrs(struct ifaddrs** result) {
rtattr* rta = IFA_RTA(address_msg); rtattr* rta = IFA_RTA(address_msg);
ssize_t payload_len = IFA_PAYLOAD(header); ssize_t payload_len = IFA_PAYLOAD(header);
while (RTA_OK(rta, payload_len)) { while (RTA_OK(rta, payload_len)) {
if (rta->rta_type == IFA_ADDRESS) { if ((address_msg->ifa_family == AF_INET &&
int family = address_msg->ifa_family; rta->rta_type == IFA_LOCAL) ||
if (family == AF_INET || family == AF_INET6) { (address_msg->ifa_family == AF_INET6 &&
ifaddrs* newest = new ifaddrs; rta->rta_type == IFA_ADDRESS)) {
memset(newest, 0, sizeof(ifaddrs)); ifaddrs* newest = new ifaddrs;
if (current) { memset(newest, 0, sizeof(ifaddrs));
current->ifa_next = newest; if (current) {
} else { current->ifa_next = newest;
start = newest; } else {
} start = newest;
if (populate_ifaddrs(newest, address_msg, RTA_DATA(rta),
RTA_PAYLOAD(rta)) != 0) {
freeifaddrs(start);
*result = nullptr;
return -1;
}
current = newest;
} }
if (populate_ifaddrs(newest, address_msg, RTA_DATA(rta),
RTA_PAYLOAD(rta)) != 0) {
freeifaddrs(start);
*result = nullptr;
return -1;
}
current = newest;
} }
rta = RTA_NEXT(rta, payload_len); rta = RTA_NEXT(rta, payload_len);
} }