Commit 79fda973 authored by sy01.youn's avatar sy01.youn Committed by Uze Choi

Fix a faulty logic in parsing a received query and in setting a URI string

When the request is sent with an empty query string, ehRequest->query is
empty string, which is interpreted as a default interface. This patch adds
a conditional statement to handle this case.
Additionally, due to https://gerrit.iotivity.org/gerrit/#/c/9111/ patch,
OCRepPayloadSetUri API is going not to be used in a simple resource like
wifi, cloudserver, and devConf resource. So, OCRepPayloadSetPropString
is used to write an URI of the resource.

Change-Id: Ie815e752007767881cef51018453e52c1a0e5863
Signed-off-by: default avatarJihun Ha <jihun.ha@samsung.com>
Signed-off-by: default avatarsy01.youn <sy01.youn@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11045Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
parent c7fe3e6a
......@@ -69,6 +69,9 @@ bool CompareResourceInterface(char *from, char *iface)
char *str = OICStrdup(from);
char *ptr = strtok(str, ";");
if(ptr == NULL)
return false;
do
{
if(strstr(ptr, ".if."))
......@@ -282,7 +285,9 @@ void updateProvResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
void updateWiFiResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
{
if(ehRequest && !CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
if(ehRequest &&
strcmp(ehRequest->query, "") &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
{
// In case of link list, batch interface
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
......@@ -360,7 +365,9 @@ void updateWiFiResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
void updateCloudResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
{
if(ehRequest && !CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
if(ehRequest &&
strcmp(ehRequest->query, "") &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
{
// In case of link list, batch interface
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
......@@ -429,7 +436,9 @@ void updateCloudResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
void updateDevConfResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* input)
{
if(ehRequest && !CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
if(ehRequest &&
strcmp(ehRequest->query, "") &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
{
// In case of link list, batch interface
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
......@@ -496,7 +505,9 @@ void updateDevConfResource(OCEntityHandlerRequest* ehRequest, OCRepPayload* inpu
OCRepPayload* constructResponseOfWiFi(OCEntityHandlerRequest *ehRequest)
{
if(ehRequest && !CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
if(ehRequest &&
strcmp(ehRequest->query, "") &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
{
// In case of link list, batch interface
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
......@@ -511,7 +522,7 @@ OCRepPayload* constructResponseOfWiFi(OCEntityHandlerRequest *ehRequest)
}
OIC_LOG(INFO, ES_RH_TAG, "constructResponse wifi res");
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_WIFI);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_HREF, OC_RSRVD_ES_URI_WIFI);
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {gWiFiResource.numMode, 0, 0};
int64_t *modes_64 = (int64_t *)OICMalloc(gWiFiResource.numMode * sizeof(int64_t));
......@@ -537,7 +548,9 @@ OCRepPayload* constructResponseOfWiFi(OCEntityHandlerRequest *ehRequest)
OCRepPayload* constructResponseOfCloud(OCEntityHandlerRequest *ehRequest)
{
if(ehRequest && !CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
if(ehRequest &&
strcmp(ehRequest->query, "") &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
{
// In case of link list, batch interface
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
......@@ -552,7 +565,7 @@ OCRepPayload* constructResponseOfCloud(OCEntityHandlerRequest *ehRequest)
}
OIC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_CLOUDSERVER);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_HREF, OC_RSRVD_ES_URI_CLOUDSERVER);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHCODE, gCloudResource.authCode);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_AUTHPROVIDER, gCloudResource.authProvider);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_CISERVER, gCloudResource.ciServer);
......@@ -567,7 +580,9 @@ OCRepPayload* constructResponseOfCloud(OCEntityHandlerRequest *ehRequest)
OCRepPayload* constructResponseOfDevConf(OCEntityHandlerRequest *ehRequest)
{
if(ehRequest && !CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
if(ehRequest &&
strcmp(ehRequest->query, "") &&
!CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT))
{
// In case of link list, batch interface
OIC_LOG(ERROR, ES_RH_TAG, "Not supported Interface");
......@@ -582,7 +597,7 @@ OCRepPayload* constructResponseOfDevConf(OCEntityHandlerRequest *ehRequest)
}
OIC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_DEVCONF);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_HREF, OC_RSRVD_ES_URI_DEVCONF);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_DEVNAME, gDevConfResource.devName);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_MODELNUMBER, gDevConfResource.modelNumber);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LOCATION, gDevConfResource.location);
......@@ -724,7 +739,7 @@ OCRepPayload* constructResponseOfProv(OCEntityHandlerRequest *ehRequest)
(ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT)))
{
OIC_LOG(INFO, ES_RH_TAG, "constructResponse prov res");
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_PROV);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_HREF, OC_RSRVD_ES_URI_PROV);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_PROVSTATUS, gProvResource.status);
OCRepPayloadSetPropInt(payload, OC_RSRVD_ES_LAST_ERRORCODE, gProvResource.lastErrCode);
OCRepPayloadSetPropString(payload, OC_RSRVD_ES_LINKS, gProvResource.ocfWebLinks);
......
......@@ -265,6 +265,12 @@ private:
void discoverRemoteEnrolleeCbToGetWifiRsrc(std::shared_ptr<OC::OCResource> resource)
{
if(!isValidResourceToTest(resource))
{
return ;
}
if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_WIFI) && m_getWifiCb)
{
QueryParamsMap test;
......@@ -303,6 +309,11 @@ private:
void discoverRemoteEnrolleeCbToGetCloudRsrc(std::shared_ptr<OC::OCResource> resource)
{
if(!isValidResourceToTest(resource))
{
return ;
}
if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_CLOUDSERVER) && m_getCloudCb)
{
QueryParamsMap test;
......@@ -340,6 +351,11 @@ private:
void discoverRemoteEnrolleeCbToGetDevConf(std::shared_ptr<OC::OCResource> resource)
{
if(!isValidResourceToTest(resource))
{
return ;
}
if(!resource->getResourceTypes().at(0).compare(OC_RSRVD_ES_RES_TYPE_DEVCONF) && m_getDevConfCb)
{
QueryParamsMap test;
......
......@@ -55,6 +55,7 @@ extern "C"
#define OC_RSRVD_ES_COUNTRY "ctry"
#define OC_RSRVD_ES_MODELNUMBER "mnmo"
#define OC_RSRVD_ES_LOCATION "loc"
#define OC_RSRVD_ES_HREF "href"
/**
* Easysetup defined resoruce types and uris.
......
......@@ -13,6 +13,8 @@ secured = env.get('SECURED')
logging = env.get('LOGGING')
routing = env.get('ROUTING')
es_target_enrollee = env.get('ES_TARGET_ENROLLEE')
with_tcp = env.get('WITH_TCP')
with_cloud = env.get('WITH_CLOUD')
print "Given Transport is %s" % transport
print "Given OS is %s" % target_os
......@@ -20,7 +22,7 @@ print "Given es_target_enrollee is %s" % es_target_enrollee
if target_os == 'tizen':
command = "sh service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh %s %s %s %s %s %s" % (transport, secured, routing, release_mode, logging, es_target_enrollee)
command = "sh service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/gbsbuild.sh %s %s %s %s %s %s %s %s" % (transport, secured, routing, release_mode, logging, es_target_enrollee, with_tcp, with_cloud)
print "Created Command is %s" % command
gbs_script = env.Command('gbs_build', None, command)
AlwaysBuild ('gbs_script')
\ No newline at end of file
......@@ -16,6 +16,7 @@ sourcedir=`pwd`
echo `pwd`
# Clean tmp directory.
rm -rf ./tmp
# Create directory structure for GBS Build
......@@ -32,9 +33,10 @@ cp -LR ./extlibs/tinycbor $sourcedir/tmp/extlibs
rm -rf $sourcedir/tmp/extlibs/tinycbor/tinycbor/.git
cp -R ./extlibs/cjson $sourcedir/tmp/extlibs
cp -R ./extlibs/mbedtls $sourcedir/tmp/extlibs
cp -R ./extlibs/gtest $sourcedir/tmp/extlibs
cp -R ./extlibs/tinydtls $sourcedir/tmp/extlibs
cp -R ./extlibs/sqlite3 $sourcedir/tmp/extlibs
cp -LR ./extlibs/sqlite3 $sourcedir/tmp/extlibs
cp -R ./extlibs/timer $sourcedir/tmp/extlibs
cp -R ./extlibs/rapidxml $sourcedir/tmp/extlibs
cp -R ./resource $sourcedir/tmp
......@@ -50,14 +52,29 @@ cp ./tools/tizen/*.rpm ./tmp
cp ./tools/tizen/.gbs.conf ./tmp
cp ./tools/tizen/*.rpm $sourcedir/tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
cp ./tools/tizen/.gbs.conf ./tmp/service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample
cp -R $sourcedir/iotivity.pc.in $sourcedir/tmp
cd $sourcedir/tmp
echo `pwd`
if [ -d ./extlibs/mbedtls/mbedtls ];then
cd ./extlibs/mbedtls/mbedtls
git reset --hard ad249f509fd62a3bbea7ccd1fef605dbd482a7bd ; git apply ../ocf.patch
cd -
rm -rf ./extlibs/mbedtls/mbedtls/.git*
else
echo ""
echo "*********************************** Error: ****************************************"
echo "* Please download mbedtls using the following command: *"
echo "* $ git clone https://github.com/ARMmbed/mbedtls.git extlibs/mbedtls/mbedtls *"
echo "***********************************************************************************"
echo ""
exit
fi
rm -rf ./extlibs/tinycbor/tinycbor/.git*
whoami
# Build IoTivity
# Initialize Git repository
......@@ -69,7 +86,7 @@ if [ ! -d .git ]; then
git commit -m "Initial commit"
fi
buildoption="--define 'TARGET_TRANSPORT '$1 --define 'SECURED '$2 --define 'ROUTING '$3 --define 'RELEASE '$4 --define 'LOGGING '$5 --define 'ES_TARGET_ENROLLEE '$6"
buildoption="--define 'TARGET_TRANSPORT '$1 --define 'SECURED '$2 --define 'ROUTING '$3 --define 'RELEASE '$4 --define 'LOGGING '$5 --define 'ES_TARGET_ENROLLEE '$6 --define 'WITH_TCP '$7 --define 'WITH_CLOUD '$8"
echo "Calling core gbs build command"
gbscommand="gbs build -A armv7l -B ~/GBS-ROOT-OIC $buildoption --include-all --repository ./"
echo $gbscommand
......
......@@ -29,7 +29,7 @@ Build Procedure
3) Execute following command(s) to start build based on some build flags required :
# scons -f service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP ROUTING=EP RELEASE=0 LOGGING=true ES_TARGET_ENROLLEE=tizen
# scons -f service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/build/tizen/SConscript TARGET_OS=tizen TARGET_TRANSPORT=IP ROUTING=EP RELEASE=0 LOGGING=true ES_TARGET_ENROLLEE=tizen SECURED=1 WITH_TCP=false WITH_CLOUD=false
4) If built for security mode:
After installing sample RPM on device, copy required .dat files and other applications to the same path where enrollee_wifi(executable) is available
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment