From 0b1a8bce125e4543e40c4b855a64384fe7ef5865 Mon Sep 17 00:00:00 2001 From: ChaJiWon Date: Wed, 12 Apr 2017 21:12:46 +0900 Subject: [PATCH] Modified getNetAddress() in SceneUtils If network have IPv4 address, it returns IPv4 address. Change-Id: Iba93339b6a980251194b02d6fa905006a88a0608 Signed-off-by: ChaJiWon Reviewed-on: https://gerrit.iotivity.org/gerrit/18675 Reviewed-by: Uze Choi Reviewed-by: JungYong KIM Tested-by: jenkins-iotivity --- service/scene-manager/src/SceneUtils.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/service/scene-manager/src/SceneUtils.cpp b/service/scene-manager/src/SceneUtils.cpp index 7face9f..0b244a0 100755 --- a/service/scene-manager/src/SceneUtils.cpp +++ b/service/scene-manager/src/SceneUtils.cpp @@ -93,7 +93,8 @@ namespace OIC { address_ipv4 = std::string(netInfo[i].addr) + ":" + std::to_string(netInfo[i].port); - } else if(netInfo[i].flags == CATransportFlags_t::CA_IPV6) + } + else if(netInfo[i].flags == CATransportFlags_t::CA_IPV6) { char addressEncoded[CA_MAX_URI_LENGTH] = {0}; @@ -111,12 +112,14 @@ namespace OIC } } } - - if(address_ipv4.length() > 0 && address_ipv6.length() == 0) + // currently ipv6 case doesn't work due to create remote resource object api fail on v6. + // Even if both ipv4 & ipv6 are in the netinfo, ipv4 address will be returned as below. + // if create remote resource object api work well on IPv6 later, below should be fixed. + if (!address_ipv4.empty()) { OICFree(netInfo); return address_ipv4; - } else if(address_ipv6.length() > 0) + } else if (!address_ipv6.empty()) { OICFree(netInfo); return address_ipv6; -- 2.7.4