iotivity: update to version 1.2.1lilik-openwrt-22.03
@ -1,38 +0,0 @@ | |||||
From 884e831ed07607097614276f6bbf192993228100 Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||||
Date: Tue, 2 Jun 2015 11:08:17 +0200 | |||||
Subject: [PATCH 3/4] 004-use-env.patch | |||||
--- | |||||
build_common/SConscript | 22 ++++++++++++++++++++++ | |||||
1 file changed, 22 insertions(+) | |||||
--- a/build_common/SConscript | |||||
+++ b/build_common/SConscript | |||||
@@ -151,6 +151,26 @@ tc_set_msg = ''' | |||||
* cause inexplicable errors. * | |||||
******************************************************************************* | |||||
''' | |||||
+env['ENV'] = os.environ | |||||
+if 'CC' in os.environ: | |||||
+ env['CC'] = Split(os.environ['CC']) | |||||
+ print "using CC from environment: %s" % env['CC'] | |||||
+if 'CXX' in os.environ: | |||||
+ env['CXX'] = Split(os.environ['CXX']) | |||||
+ print "using CXX from environment: %s" % env['CXX'] | |||||
+if 'CFLAGS' in os.environ: | |||||
+ env['CFLAGS'] = Split(os.environ['CFLAGS']) | |||||
+ print "using CFLAGS from environment: %s" % env['CFLAGS'] | |||||
+if 'CXXFLAGS' in os.environ: | |||||
+ env['CXXFLAGS'] = Split(os.environ['CXXFLAGS']) | |||||
+ print "using CXXFLAGS from environment: %s" % env['CXXFLAGS'] | |||||
+if 'CPPFLAGS' in os.environ: | |||||
+ env['CPPFLAGS'] = Split(os.environ['CPPFLAGS']) | |||||
+ print "using CPPFLAGS from environment: %s" % env['CPPFLAGS'] | |||||
+if 'LDFLAGS' in os.environ: | |||||
+ env['LINKFLAGS'] = Split(os.environ['LDFLAGS']) | |||||
+ print "using LDFLAGS/LINKFLAGS from environment: %s" % env['LINKFLAGS'] | |||||
+ | |||||
if env.get('VERBOSE') == False: | |||||
env['CCCOMSTR'] = "Compiling $TARGET" | |||||
env['SHCCCOMSTR'] = "Compiling $TARGET" |
@ -1,60 +0,0 @@ | |||||
From 980ef34a085f654e74c9896e8143e6f970049b6c Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Mon, 22 Jun 2015 19:39:58 +0200 | |||||
Subject: [PATCH 3/5] Do not set architecture specific flags | |||||
Setting architecture specific flags causes problems when you want to | |||||
build something which is not covered by these. | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
build_common/linux/SConscript | 20 -------------------- | |||||
resource/csdk/connectivity/build/linux/SConscript | 20 -------------------- | |||||
2 files changed, 40 deletions(-) | |||||
--- a/build_common/linux/SConscript | |||||
+++ b/build_common/linux/SConscript | |||||
@@ -24,20 +24,3 @@ env.AppendUnique(LINKFLAGS = ['-ldl', '- | |||||
# Set arch flags that match best TARGET_ARCH variable | |||||
target_arch = env.get('TARGET_ARCH') | |||||
-if target_arch in ['x86']: | |||||
- env.AppendUnique(CCFLAGS = ['-m32']) | |||||
- env.AppendUnique(LINKFLAGS = ['-m32']) | |||||
-elif target_arch in ['x86_64']: | |||||
- env.AppendUnique(CCFLAGS = ['-m64']) | |||||
- env.AppendUnique(LINKFLAGS = ['-m64']) | |||||
-elif target_arch in ['arm'] or target_arch.find('v5') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv5te']) | |||||
-elif target_arch.find('v7a-hard') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
- env.AppendUnique(CPPFLAGS = ['-mfloat-abi=hard']) | |||||
- env.AppendUnique(CCFLAGS = ['-mfloat-abi=hard']) | |||||
- env.AppendUnique(LINKFLAGS = ['-mfloat-abi=hard']) | |||||
-elif target_arch.find('v7a') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
-elif target_arch.find('arm64') >= 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv8-a']) | |||||
--- a/resource/csdk/connectivity/build/linux/SConscript | |||||
+++ b/resource/csdk/connectivity/build/linux/SConscript | |||||
@@ -22,20 +22,3 @@ env.AppendUnique(LINKFLAGS = ['-ldl', '- | |||||
# Set arch flags | |||||
target_arch = env.get('TARGET_ARCH') | |||||
-if target_arch in ['x86']: | |||||
- env.AppendUnique(CCFLAGS = ['-m32']) | |||||
- env.AppendUnique(LINKFLAGS = ['-m32']) | |||||
-elif target_arch in ['x86_64']: | |||||
- env.AppendUnique(CCFLAGS = ['-m64']) | |||||
- env.AppendUnique(LINKFLAGS = ['-m64']) | |||||
-elif target_arch.find('v7a-hard') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
- env.AppendUnique(CPPFLAGS = ['-mfloat-abi=hard']) | |||||
- env.AppendUnique(CCFLAGS = ['-mfloat-abi=hard']) | |||||
- env.AppendUnique(LINKFLAGS = ['-mfloat-abi=hard']) | |||||
-elif target_arch.find('v7a') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
-elif target_arch.find('arm64') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv8-a']) | |||||
-else: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv5te']) |
@ -0,0 +1,44 @@ | |||||
From dabd6597013e1df72b08621b466d136b8d25d110 Mon Sep 17 00:00:00 2001 | |||||
From: Philippe Coval <philippe.coval@osg.samsung.com> | |||||
Date: Thu, 29 Sep 2016 10:57:59 +0200 | |||||
Subject: [PATCH 20/23] linux: Add more architectures | |||||
This does not scale and this check should be removed. | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Author: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Change-Id: Ibb271701904745ee4f5dd689c197228239c37262 | |||||
Origin: https://github.com/openwrt/packages/blob/master/net/iotivity/patches/021-add-some-more-architectures.patch | |||||
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com> | |||||
Reviewed-on: https://gerrit.iotivity.org/gerrit/14575 | |||||
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org> | |||||
Reviewed-by: Nivedita Singhvi <niveditasinghvi@gmail.com> | |||||
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com> | |||||
Reviewed-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||||
--- | |||||
build_common/SConscript | 2 +- | |||||
resource/csdk/connectivity/build/SConscript | 2 +- | |||||
2 files changed, 2 insertions(+), 2 deletions(-) | |||||
--- a/build_common/SConscript | |||||
+++ b/build_common/SConscript | |||||
@@ -18,7 +18,7 @@ host_target_map = { | |||||
# Map of os and allowed archs (os: allowed archs) | |||||
os_arch_map = { | |||||
- 'linux': ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64'], | |||||
+ 'linux': ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64', 'mips', 'mipsel', 'mips64', 'mips64el', 'i386', 'powerpc', 'sparc', 'aarch64'], | |||||
'tizen': ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64'], | |||||
'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'], | |||||
'windows': ['x86', 'amd64', 'arm'], | |||||
--- a/resource/csdk/connectivity/build/SConscript | |||||
+++ b/resource/csdk/connectivity/build/SConscript | |||||
@@ -14,7 +14,7 @@ host_target_map = { | |||||
# Map of os and allowed archs (os: allowed archs) | |||||
os_arch_map = { | |||||
- 'linux': ['x86', 'x86_64', 'arm', 'arm64'], | |||||
+ 'linux': ['x86', 'x86_64', 'arm', 'arm64', 'mips', 'mipsel', 'mips64', 'mips64el', 'i386', 'powerpc', 'sparc', 'aarch64'], | |||||
'tizen': ['x86', 'x86_64', 'arm', 'arm64'], | |||||
'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'], | |||||
'windows': ['x86', 'amd64', 'arm'], |
@ -1,35 +0,0 @@ | |||||
From f78ba209b14908bf2b6197293e1f9e3458ddba8e Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Mon, 22 Jun 2015 19:59:47 +0200 | |||||
Subject: [PATCH 4/5] add some more architectures | |||||
This does not scale and this check should be removed. | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
build_common/SConscript | 2 +- | |||||
resource/csdk/connectivity/build/SConscript | 2 +- | |||||
2 files changed, 2 insertions(+), 2 deletions(-) | |||||
--- a/build_common/SConscript | |||||
+++ b/build_common/SConscript | |||||
@@ -14,7 +14,7 @@ host_target_map = { | |||||
# Map of os and allowed archs (os: allowed archs) | |||||
os_arch_map = { | |||||
- 'linux': ['x86', 'x86_64', 'arm', 'arm64'], | |||||
+ 'linux': ['x86', 'x86_64', 'arm', 'arm64', 'mips', 'mipsel', 'mips64', 'mips64el', 'i386', 'powerpc', 'sparc', 'aarch64'], | |||||
'tizen': ['x86', 'x86_64', 'arm', 'arm64', 'armeabi-v7a'], | |||||
'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'], | |||||
'windows': ['x86', 'amd64', 'arm'], | |||||
--- a/resource/csdk/connectivity/build/SConscript | |||||
+++ b/resource/csdk/connectivity/build/SConscript | |||||
@@ -14,7 +14,7 @@ host_target_map = { | |||||
# Map of os and allowed archs (os: allowed archs) | |||||
os_arch_map = { | |||||
- 'linux': ['x86', 'x86_64', 'arm', 'arm64'], | |||||
+ 'linux': ['x86', 'x86_64', 'arm', 'arm64', 'mips', 'mipsel', 'mips64', 'mips64el', 'i386', 'powerpc', 'sparc', 'aarch64'], | |||||
'tizen': ['x86', 'x86_64', 'arm', 'arm64'], | |||||
'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'], | |||||
'windows': ['x86', 'amd64', 'arm'], |
@ -0,0 +1,39 @@ | |||||
From 792f68219b3ab4ff5238e3abc7aa1c68bfa4a22b Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sat, 10 Dec 2016 18:15:32 +0100 | |||||
Subject: [PATCH 21/23] build: do not set TARGET_ARCH to default | |||||
This check is useless, scons already checks this and returns such an | |||||
error message: | |||||
Invalid value for option TARGET_ARCH: mips. Valid values are: ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64'] | |||||
Change-Id: I3f7dd3b9fcae875ab20349203fb77537f24be763 | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
build_common/SConscript | 3 --- | |||||
resource/csdk/connectivity/build/SConscript | 2 -- | |||||
2 files changed, 5 deletions(-) | |||||
--- a/build_common/SConscript | |||||
+++ b/build_common/SConscript | |||||
@@ -54,9 +54,6 @@ if target_os == 'android': | |||||
else: | |||||
default_arch = platform.machine() | |||||
-if default_arch not in os_arch_map[target_os]: | |||||
- default_arch = os_arch_map[target_os][0].lower() | |||||
- | |||||
target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch | |||||
# True if binary needs to be installed on board. (Might need root permissions) | |||||
--- a/resource/csdk/connectivity/build/SConscript | |||||
+++ b/resource/csdk/connectivity/build/SConscript | |||||
@@ -40,8 +40,6 @@ if target_os not in host_target_map[host | |||||
Exit(1) | |||||
default_arch = platform.machine() | |||||
-if default_arch not in os_arch_map[target_os]: | |||||
- default_arch = os_arch_map[target_os][0].lower() | |||||
target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch | |||||
@ -0,0 +1,57 @@ | |||||
From 39b0c436c77555849da1e68cc8733c67183c291f Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sat, 10 Dec 2016 18:35:04 +0100 | |||||
Subject: [PATCH 22/23] build: restrict compiler options to supported | |||||
architectures | |||||
For Linux we currently only support the following architectures: | |||||
'x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64' | |||||
explicitly check for those architectures and also remove ARM hard float. | |||||
Change-Id: I7078530bc2a89b88c7049cc53e8bb3fbe5d75ca8 | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
build_common/linux/SConscript | 11 +++-------- | |||||
resource/csdk/connectivity/build/linux/SConscript | 11 +++-------- | |||||
2 files changed, 6 insertions(+), 16 deletions(-) | |||||
--- a/build_common/linux/SConscript | |||||
+++ b/build_common/linux/SConscript | |||||
@@ -30,14 +30,9 @@ if target_arch in ['x86']: | |||||
elif target_arch in ['x86_64']: | |||||
env.AppendUnique(CCFLAGS = ['-m64']) | |||||
env.AppendUnique(LINKFLAGS = ['-m64']) | |||||
-elif target_arch in ['arm'] or target_arch.find('v5') > 0: | |||||
+elif target_arch in ['arm']: | |||||
env.AppendUnique(CPPFLAGS = ['-march=armv5te']) | |||||
-elif target_arch.find('v7a-hard') > 0: | |||||
+elif target_arch in ['arm-v7a', 'armeabi-v7a']: | |||||
env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
- env.AppendUnique(CPPFLAGS = ['-mfloat-abi=hard']) | |||||
- env.AppendUnique(CCFLAGS = ['-mfloat-abi=hard']) | |||||
- env.AppendUnique(LINKFLAGS = ['-mfloat-abi=hard']) | |||||
-elif target_arch.find('v7a') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
-elif target_arch.find('arm64') >= 0: | |||||
+elif target_arch.find('arm64') > 0: | |||||
env.AppendUnique(CPPFLAGS = ['-march=armv8-a']) | |||||
--- a/resource/csdk/connectivity/build/linux/SConscript | |||||
+++ b/resource/csdk/connectivity/build/linux/SConscript | |||||
@@ -29,14 +29,9 @@ if target_arch in ['x86']: | |||||
elif target_arch in ['x86_64']: | |||||
env.AppendUnique(CCFLAGS = ['-m64']) | |||||
env.AppendUnique(LINKFLAGS = ['-m64']) | |||||
-elif target_arch.find('v7a-hard') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
- env.AppendUnique(CPPFLAGS = ['-mfloat-abi=hard']) | |||||
- env.AppendUnique(CCFLAGS = ['-mfloat-abi=hard']) | |||||
- env.AppendUnique(LINKFLAGS = ['-mfloat-abi=hard']) | |||||
-elif target_arch.find('v7a') > 0: | |||||
+elif target_arch in ['arm']: | |||||
+ env.AppendUnique(CPPFLAGS = ['-march=armv5te']) | |||||
+elif target_arch in ['arm-v7a', 'armeabi-v7a']: | |||||
env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
elif target_arch.find('arm64') > 0: | |||||
env.AppendUnique(CPPFLAGS = ['-march=armv8-a']) | |||||
-else: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv5te']) |
@ -0,0 +1,126 @@ | |||||
From 5f9513eb341d520d10c48f8ba2bd145063405fdd Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sat, 10 Dec 2016 18:08:05 +0100 | |||||
Subject: [PATCH 23/23] build: take compiler options from environment | |||||
This makes it possible to compile IoTivity with custom compiler | |||||
options. This way someone can use optimized compiler settings for the | |||||
target CPU. I want to use this in OpenWrt / LEDE to build specific | |||||
IoTivity binaries for each CPU architecture, there the build system | |||||
provides the matching compiler options. | |||||
Change-Id: I86772f73b81c41d7e96e51b434fd9e3b4992753a | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
build_common/SConscript | 25 +++++++++++++++++++++ | |||||
build_common/linux/SConscript | 27 ++++++++++++----------- | |||||
resource/csdk/connectivity/build/linux/SConscript | 27 ++++++++++++----------- | |||||
3 files changed, 53 insertions(+), 26 deletions(-) | |||||
--- a/build_common/SConscript | |||||
+++ b/build_common/SConscript | |||||
@@ -120,6 +120,7 @@ help_vars.Add(PathVariable('ANDROID_NDK' | |||||
help_vars.Add(PathVariable('ANDROID_HOME', 'Android SDK path', None, PathVariable.PathAccept)) | |||||
help_vars.Add(PathVariable('ANDROID_GRADLE', 'Gradle binary file', None, PathVariable.PathIsFile)) | |||||
help_vars.Add(EnumVariable('WITH_UPSTREAM_LIBCOAP', 'Use latest stable version of LibCoAP downloaded from github', default_with_upstream_libcoap, allowed_values=('0','1'))) | |||||
+help_vars.Add(BoolVariable('WITH_ENV', 'Use compiler options from environment', False)) | |||||
AddOption('--prefix', | |||||
dest='prefix', | |||||
@@ -153,6 +154,30 @@ else: | |||||
) | |||||
Help(help_vars.GenerateHelpText(env)) | |||||
+if env.get('WITH_ENV'): | |||||
+ env['ENV'] = os.environ | |||||
+ if 'CC' in os.environ: | |||||
+ env['CC'] = Split(os.environ['CC']) | |||||
+ print "using CC from environment: %s" % env['CC'] | |||||
+ if 'CXX' in os.environ: | |||||
+ env['CXX'] = Split(os.environ['CXX']) | |||||
+ print "using CXX from environment: %s" % env['CXX'] | |||||
+ if 'CFLAGS' in os.environ: | |||||
+ env['CFLAGS'] = Split(os.environ['CFLAGS']) | |||||
+ print "using CFLAGS from environment: %s" % env['CFLAGS'] | |||||
+ if 'CXXFLAGS' in os.environ: | |||||
+ env['CXXFLAGS'] = Split(os.environ['CXXFLAGS']) | |||||
+ print "using CXXFLAGS from environment: %s" % env['CXXFLAGS'] | |||||
+ if 'CCFLAGS' in os.environ: | |||||
+ env['CCFLAGS'] = Split(os.environ['CCFLAGS']) | |||||
+ print "using CCFLAGS from environment: %s" % env['CCFLAGS'] | |||||
+ if 'CPPFLAGS' in os.environ: | |||||
+ env['CPPFLAGS'] = Split(os.environ['CPPFLAGS']) | |||||
+ print "using CPPFLAGS from environment: %s" % env['CPPFLAGS'] | |||||
+ if 'LDFLAGS' in os.environ: | |||||
+ env['LINKFLAGS'] = Split(os.environ['LDFLAGS']) | |||||
+ print "using LDFLAGS/LINKFLAGS from environment: %s" % env['LINKFLAGS'] | |||||
+ | |||||
tc_set_msg = ''' | |||||
************************************ Warning ********************************** | |||||
* Enviornment variable TC_PREFIX/TC_PATH is set. It will change the default * | |||||
--- a/build_common/linux/SConscript | |||||
+++ b/build_common/linux/SConscript | |||||
@@ -23,16 +23,17 @@ env.AppendUnique(CCFLAGS = ['-Wall', '-W | |||||
env.AppendUnique(LIBS = ['dl', 'pthread', 'uuid']) | |||||
# Set arch flags that match best TARGET_ARCH variable | |||||
-target_arch = env.get('TARGET_ARCH') | |||||
-if target_arch in ['x86']: | |||||
- env.AppendUnique(CCFLAGS = ['-m32']) | |||||
- env.AppendUnique(LINKFLAGS = ['-m32']) | |||||
-elif target_arch in ['x86_64']: | |||||
- env.AppendUnique(CCFLAGS = ['-m64']) | |||||
- env.AppendUnique(LINKFLAGS = ['-m64']) | |||||
-elif target_arch in ['arm']: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv5te']) | |||||
-elif target_arch in ['arm-v7a', 'armeabi-v7a']: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
-elif target_arch.find('arm64') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv8-a']) | |||||
+if not env.get('WITH_ENV'): | |||||
+ target_arch = env.get('TARGET_ARCH') | |||||
+ if target_arch in ['x86']: | |||||
+ env.AppendUnique(CCFLAGS = ['-m32']) | |||||
+ env.AppendUnique(LINKFLAGS = ['-m32']) | |||||
+ elif target_arch in ['x86_64']: | |||||
+ env.AppendUnique(CCFLAGS = ['-m64']) | |||||
+ env.AppendUnique(LINKFLAGS = ['-m64']) | |||||
+ elif target_arch in ['arm']: | |||||
+ env.AppendUnique(CPPFLAGS = ['-march=armv5te']) | |||||
+ elif target_arch in ['arm-v7a', 'armeabi-v7a']: | |||||
+ env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
+ elif target_arch.find('arm64') > 0: | |||||
+ env.AppendUnique(CPPFLAGS = ['-march=armv8-a']) | |||||
--- a/resource/csdk/connectivity/build/linux/SConscript | |||||
+++ b/resource/csdk/connectivity/build/linux/SConscript | |||||
@@ -22,16 +22,17 @@ env.AppendUnique(CCFLAGS = ['-Wall', '-f | |||||
env.AppendUnique(LIBS = ['dl', 'pthread']) | |||||
# Set arch flags | |||||
-target_arch = env.get('TARGET_ARCH') | |||||
-if target_arch in ['x86']: | |||||
- env.AppendUnique(CCFLAGS = ['-m32']) | |||||
- env.AppendUnique(LINKFLAGS = ['-m32']) | |||||
-elif target_arch in ['x86_64']: | |||||
- env.AppendUnique(CCFLAGS = ['-m64']) | |||||
- env.AppendUnique(LINKFLAGS = ['-m64']) | |||||
-elif target_arch in ['arm']: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv5te']) | |||||
-elif target_arch in ['arm-v7a', 'armeabi-v7a']: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
-elif target_arch.find('arm64') > 0: | |||||
- env.AppendUnique(CPPFLAGS = ['-march=armv8-a']) | |||||
+if not env.get('WITH_ENV'): | |||||
+ target_arch = env.get('TARGET_ARCH') | |||||
+ if target_arch in ['x86']: | |||||
+ env.AppendUnique(CCFLAGS = ['-m32']) | |||||
+ env.AppendUnique(LINKFLAGS = ['-m32']) | |||||
+ elif target_arch in ['x86_64']: | |||||
+ env.AppendUnique(CCFLAGS = ['-m64']) | |||||
+ env.AppendUnique(LINKFLAGS = ['-m64']) | |||||
+ elif target_arch in ['arm']: | |||||
+ env.AppendUnique(CPPFLAGS = ['-march=armv5te']) | |||||
+ elif target_arch in ['arm-v7a', 'armeabi-v7a']: | |||||
+ env.AppendUnique(CPPFLAGS = ['-march=armv7-a']) | |||||
+ elif target_arch.find('arm64') > 0: | |||||
+ env.AppendUnique(CPPFLAGS = ['-march=armv8-a']) |
@ -0,0 +1,27 @@ | |||||
From 08b403572985a70fe5d652378e1cfa2b72ac6a3d Mon Sep 17 00:00:00 2001 | |||||
From: Philippe Coval <philippe.coval@osg.samsung.com> | |||||
Date: Fri, 9 Dec 2016 02:12:04 +0100 | |||||
Subject: [PATCH] linux: Use system sqlite3 | |||||
Problem was discovered on yocto | |||||
Change-Id: I5274bed9e4b7ddcdc1b17a265a1886cd78cb631f | |||||
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com> | |||||
Reviewed-on: https://gerrit.iotivity.org/gerrit/15305 | |||||
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org> | |||||
Reviewed-by: Ziran Sun <ziran.sun@samsung.com> | |||||
--- | |||||
resource/csdk/SConscript | 2 +- | |||||
1 file changed, 1 insertion(+), 1 deletion(-) | |||||
--- a/resource/csdk/SConscript | |||||
+++ b/resource/csdk/SConscript | |||||
@@ -191,7 +191,7 @@ if with_tcp == True: | |||||
if 'SERVER' in rd_mode: | |||||
liboctbstack_src.append(OCTBSTACK_SRC + 'oicresourcedirectory.c') | |||||
- if target_os not in ['tizen']: | |||||
+ if target_os not in ['linux', 'tizen']: | |||||
liboctbstack_src.append('#extlibs/sqlite3/sqlite3.c') | |||||
if target_os in ['linux']: |
@ -1,24 +0,0 @@ | |||||
From 4488170af944163b62051b2afee60386a9973c72 Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||||
Date: Thu, 31 Mar 2016 10:23:48 +0200 | |||||
Subject: [PATCH] remove building of provisioning service | |||||
The provisioning service is not used in this build and depends on boost_thread | |||||
which would add an additional unused dependency. | |||||
Change-Id: Ic7edab3ae96d77339ea0f48fc76ab2534c49b6ba | |||||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||||
--- | |||||
resource/src/SConscript | 4 ++-- | |||||
1 file changed, 2 insertions(+), 2 deletions(-) | |||||
--- a/resource/src/SConscript | |||||
+++ b/resource/src/SConscript | |||||
@@ -116,5 +116,5 @@ oclib_env.UserInstallTargetHeader(header | |||||
oclib_env.UserInstallTargetHeader(header_dir + 'CAManager.h', 'resource', 'CAManager.h') | |||||
# Add Provisioning library | |||||
-if target_os in ['linux', 'android', 'tizen'] and env.get('SECURED') == '1': | |||||
- SConscript('../provisioning/SConscript') | |||||
+# if target_os in ['linux', 'android', 'tizen'] and env.get('SECURED') == '1': | |||||
+# SConscript('../provisioning/SConscript') |
@ -0,0 +1,54 @@ | |||||
From d8cf30cb0abd5fa8f6282b490618204d683b625c Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Mon, 3 Oct 2016 21:00:28 +0200 | |||||
Subject: [PATCH 1/3] csdk: move OCEntityHandlerResponse from stack to heap | |||||
OCEntityHandlerResponse is over 50KByte and I got a stack overflow on MIPS | |||||
running on LEDE without this patch. Instead of storing | |||||
OCEntityHandlerResponse on the program stack, allocate some memory on | |||||
the heap and free it afterwards again. | |||||
This fixes one part of this issue for me: | |||||
https://jira.iotivity.org/browse/IOT-1374 | |||||
Change-Id: I365a5c7a34dce2dfb0897a20b57a13ba566748ec | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
resource/csdk/stack/src/ocresource.c | 24 +++++++++++++++++------- | |||||
1 file changed, 17 insertions(+), 7 deletions(-) | |||||
--- a/resource/csdk/stack/src/ocresource.c | |||||
+++ b/resource/csdk/stack/src/ocresource.c | |||||
@@ -774,15 +774,25 @@ static bool includeThisResourceInRespons | |||||
OCStackResult SendNonPersistantDiscoveryResponse(OCServerRequest *request, OCResource *resource, | |||||
OCPayload *discoveryPayload, OCEntityHandlerResult ehResult) | |||||
{ | |||||
- OCEntityHandlerResponse response = {0}; | |||||
+ OCEntityHandlerResponse *response = NULL; | |||||
+ OCStackResult result = OC_STACK_ERROR; | |||||
- response.ehResult = ehResult; | |||||
- response.payload = discoveryPayload; | |||||
- response.persistentBufferFlag = 0; | |||||
- response.requestHandle = (OCRequestHandle) request->requestId; | |||||
- response.resourceHandle = (OCResourceHandle) resource; | |||||
+ response = (OCEntityHandlerResponse *)OICCalloc(1, sizeof(*response)); | |||||
+ VERIFY_PARAM_NON_NULL(TAG, response, "Failed allocating OCEntityHandlerResponse"); | |||||
- return OCDoResponse(&response); | |||||
+ response->ehResult = ehResult; | |||||
+ response->payload = discoveryPayload; | |||||
+ response->persistentBufferFlag = 0; | |||||
+ response->requestHandle = (OCRequestHandle) request->requestId; | |||||
+ response->resourceHandle = (OCResourceHandle) resource; | |||||
+ | |||||
+ result = OCDoResponse(response); | |||||
+ | |||||
+ OICFree(response); | |||||
+ return result; | |||||
+ | |||||
+exit: | |||||
+ return OC_STACK_NO_MEMORY; | |||||
} | |||||
static OCStackResult EHRequest(OCEntityHandlerRequest *ehRequest, OCPayloadType type, |
@ -0,0 +1,357 @@ | |||||
From e8971dd4914c9d42938c4c885b4ac6d784d7e0ff Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Mon, 3 Oct 2016 23:22:36 +0200 | |||||
Subject: [PATCH 2/3] csdk: move OCClientResponse from stack to heap | |||||
OCClientResponse is about 50KByte and should not be stored on the | |||||
stack. On LEDE with MIPS, musl libc this causes a segmentation fault. | |||||
Moving this structure to the heap is the simple solution for this | |||||
problem, but this structure should be shrined. | |||||
There are probably more places were this is stored on the stack and | |||||
will cause problems. This fixes the other issue I saw in | |||||
https://jira.iotivity.org/browse/IOT-1374 | |||||
Change-Id: I45d8aee4a8151fea51d3318acb1eea61ce579060 | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
resource/csdk/stack/src/ocstack.c | 163 ++++++++++++++++++++++++-------------- | |||||
1 file changed, 102 insertions(+), 61 deletions(-) | |||||
--- a/resource/csdk/stack/src/ocstack.c | |||||
+++ b/resource/csdk/stack/src/ocstack.c | |||||
@@ -1042,7 +1042,7 @@ OCStackResult HandlePresenceResponse(con | |||||
OCStackApplicationResult cbResult = OC_STACK_DELETE_TRANSACTION; | |||||
ClientCB * cbNode = NULL; | |||||
char *resourceTypeName = NULL; | |||||
- OCClientResponse response = {.devAddr = {.adapter = OC_DEFAULT_ADAPTER}}; | |||||
+ OCClientResponse *response = NULL; | |||||
OCStackResult result = OC_STACK_ERROR; | |||||
uint32_t maxAge = 0; | |||||
int uriLen; | |||||
@@ -1057,15 +1057,23 @@ OCStackResult HandlePresenceResponse(con | |||||
return OC_STACK_ERROR; | |||||
} | |||||
- response.payload = NULL; | |||||
- response.result = OC_STACK_OK; | |||||
+ response = (OCClientResponse *)OICCalloc(1, sizeof(*response)); | |||||
+ if (!response) | |||||
+ { | |||||
+ OIC_LOG(ERROR, TAG, "Allocating memory for response failed"); | |||||
+ return OC_STACK_ERROR; | |||||
+ } | |||||
+ response->devAddr.adapter = OC_DEFAULT_ADAPTER; | |||||
- CopyEndpointToDevAddr(endpoint, &response.devAddr); | |||||
- FixUpClientResponse(&response); | |||||
+ response->payload = NULL; | |||||
+ response->result = OC_STACK_OK; | |||||
+ | |||||
+ CopyEndpointToDevAddr(endpoint, &response->devAddr); | |||||
+ FixUpClientResponse(response); | |||||
if (responseInfo->info.payload) | |||||
{ | |||||
- result = OCParsePayload(&response.payload, | |||||
+ result = OCParsePayload(&response->payload, | |||||
PAYLOAD_TYPE_PRESENCE, | |||||
responseInfo->info.payload, | |||||
responseInfo->info.payloadSize); | |||||
@@ -1075,15 +1083,15 @@ OCStackResult HandlePresenceResponse(con | |||||
OIC_LOG(ERROR, TAG, "Presence parse failed"); | |||||
goto exit; | |||||
} | |||||
- if(!response.payload || response.payload->type != PAYLOAD_TYPE_PRESENCE) | |||||
+ if(!response->payload || response->payload->type != PAYLOAD_TYPE_PRESENCE) | |||||
{ | |||||
OIC_LOG(ERROR, TAG, "Presence payload was wrong type"); | |||||
result = OC_STACK_ERROR; | |||||
goto exit; | |||||
} | |||||
- response.sequenceNumber = ((OCPresencePayload*)response.payload)->sequenceNumber; | |||||
- resourceTypeName = ((OCPresencePayload*)response.payload)->resourceType; | |||||
- maxAge = ((OCPresencePayload*)response.payload)->maxAge; | |||||
+ response->sequenceNumber = ((OCPresencePayload*)response->payload)->sequenceNumber; | |||||
+ resourceTypeName = ((OCPresencePayload*)response->payload)->resourceType; | |||||
+ maxAge = ((OCPresencePayload*)response->payload)->maxAge; | |||||
} | |||||
// check for unicast presence | |||||
@@ -1091,6 +1099,7 @@ OCStackResult HandlePresenceResponse(con | |||||
responseInfo->isMulticast); | |||||
if (uriLen < 0 || (size_t)uriLen >= sizeof (presenceUri)) | |||||
{ | |||||
+ OICFree(response); | |||||
return OC_STACK_INVALID_URI; | |||||
} | |||||
OIC_LOG(ERROR, TAG, "check for unicast presence"); | |||||
@@ -1118,7 +1127,7 @@ OCStackResult HandlePresenceResponse(con | |||||
if (presenceSubscribe) | |||||
{ | |||||
- if(cbNode->sequenceNumber == response.sequenceNumber) | |||||
+ if(cbNode->sequenceNumber == response->sequenceNumber) | |||||
{ | |||||
OIC_LOG(INFO, TAG, "No presence change"); | |||||
ResetPresenceTTL(cbNode, maxAge); | |||||
@@ -1129,7 +1138,7 @@ OCStackResult HandlePresenceResponse(con | |||||
if(maxAge == 0) | |||||
{ | |||||
OIC_LOG(INFO, TAG, "Stopping presence"); | |||||
- response.result = OC_STACK_PRESENCE_STOPPED; | |||||
+ response->result = OC_STACK_PRESENCE_STOPPED; | |||||
if(cbNode->presence) | |||||
{ | |||||
OICFree(cbNode->presence->timeOut); | |||||
@@ -1165,7 +1174,7 @@ OCStackResult HandlePresenceResponse(con | |||||
ResetPresenceTTL(cbNode, maxAge); | |||||
- cbNode->sequenceNumber = response.sequenceNumber; | |||||
+ cbNode->sequenceNumber = response->sequenceNumber; | |||||
} | |||||
} | |||||
else | |||||
@@ -1175,7 +1184,7 @@ OCStackResult HandlePresenceResponse(con | |||||
if (0 == maxAge) | |||||
{ | |||||
OIC_LOG(INFO, TAG, "Stopping presence"); | |||||
- response.result = OC_STACK_PRESENCE_STOPPED; | |||||
+ response->result = OC_STACK_PRESENCE_STOPPED; | |||||
} | |||||
} | |||||
@@ -1191,7 +1200,7 @@ OCStackResult HandlePresenceResponse(con | |||||
OIC_LOG(INFO, TAG, "Callback for presence"); | |||||
- cbResult = cbNode->callBack(cbNode->context, cbNode->handle, &response); | |||||
+ cbResult = cbNode->callBack(cbNode->context, cbNode->handle, response); | |||||
if (cbResult == OC_STACK_DELETE_TRANSACTION) | |||||
{ | |||||
@@ -1199,7 +1208,8 @@ OCStackResult HandlePresenceResponse(con | |||||
} | |||||
exit: | |||||
- OCPayloadDestroy(response.payload); | |||||
+ OCPayloadDestroy(response->payload); | |||||
+ OICFree(response); | |||||
return result; | |||||
} | |||||
@@ -1240,36 +1250,53 @@ void OCHandleResponse(const CAEndpoint_t | |||||
OIC_LOG(INFO, TAG, "Receiving A Timeout for this token"); | |||||
OIC_LOG(INFO, TAG, "Calling into application address space"); | |||||
- OCClientResponse response = | |||||
- {.devAddr = {.adapter = OC_DEFAULT_ADAPTER}}; | |||||
- CopyEndpointToDevAddr(endPoint, &response.devAddr); | |||||
- FixUpClientResponse(&response); | |||||
- response.resourceUri = responseInfo->info.resourceUri; | |||||
- memcpy(response.identity.id, responseInfo->info.identity.id, | |||||
- sizeof (response.identity.id)); | |||||
- response.identity.id_length = responseInfo->info.identity.id_length; | |||||
+ OCClientResponse *response = NULL; | |||||
+ | |||||
+ response = (OCClientResponse *)OICCalloc(1, sizeof(*response)); | |||||
+ if (!response) | |||||
+ { | |||||
+ OIC_LOG(ERROR, TAG, "Allocating memory for response failed"); | |||||
+ return; | |||||
+ } | |||||
+ | |||||
+ response->devAddr.adapter = OC_DEFAULT_ADAPTER; | |||||
+ CopyEndpointToDevAddr(endPoint, &response->devAddr); | |||||
+ FixUpClientResponse(response); | |||||
+ response->resourceUri = responseInfo->info.resourceUri; | |||||
+ memcpy(response->identity.id, responseInfo->info.identity.id, | |||||
+ sizeof (response->identity.id)); | |||||
+ response->identity.id_length = responseInfo->info.identity.id_length; | |||||
- response.result = CAResponseToOCStackResult(responseInfo->result); | |||||
+ response->result = CAResponseToOCStackResult(responseInfo->result); | |||||
cbNode->callBack(cbNode->context, | |||||
- cbNode->handle, &response); | |||||
+ cbNode->handle, response); | |||||
FindAndDeleteClientCB(cbNode); | |||||
+ OICFree(response); | |||||
} | |||||
else | |||||
{ | |||||
OIC_LOG(INFO, TAG, "This is a regular response, A client call back is found"); | |||||
OIC_LOG(INFO, TAG, "Calling into application address space"); | |||||
- OCClientResponse response = | |||||
- {.devAddr = {.adapter = OC_DEFAULT_ADAPTER}}; | |||||
- response.sequenceNumber = MAX_SEQUENCE_NUMBER + 1; | |||||
- CopyEndpointToDevAddr(endPoint, &response.devAddr); | |||||
- FixUpClientResponse(&response); | |||||
- response.resourceUri = responseInfo->info.resourceUri; | |||||
- memcpy(response.identity.id, responseInfo->info.identity.id, | |||||
- sizeof (response.identity.id)); | |||||
- response.identity.id_length = responseInfo->info.identity.id_length; | |||||
+ OCClientResponse *response = NULL; | |||||
- response.result = CAResponseToOCStackResult(responseInfo->result); | |||||
+ response = (OCClientResponse *)OICCalloc(1, sizeof(*response)); | |||||
+ if (!response) | |||||
+ { | |||||
+ OIC_LOG(ERROR, TAG, "Allocating memory for response failed"); | |||||
+ return; | |||||
+ } | |||||
+ | |||||
+ response->devAddr.adapter = OC_DEFAULT_ADAPTER; | |||||
+ response->sequenceNumber = MAX_SEQUENCE_NUMBER + 1; | |||||
+ CopyEndpointToDevAddr(endPoint, &response->devAddr); | |||||
+ FixUpClientResponse(response); | |||||
+ response->resourceUri = responseInfo->info.resourceUri; | |||||
+ memcpy(response->identity.id, responseInfo->info.identity.id, | |||||
+ sizeof (response->identity.id)); | |||||
+ response->identity.id_length = responseInfo->info.identity.id_length; | |||||
+ | |||||
+ response->result = CAResponseToOCStackResult(responseInfo->result); | |||||
if(responseInfo->info.payload && | |||||
responseInfo->info.payloadSize) | |||||
@@ -1359,21 +1386,23 @@ void OCHandleResponse(const CAEndpoint_t | |||||
{ | |||||
OIC_LOG_V(ERROR, TAG, "Unknown Payload type: %d %s", | |||||
cbNode->method, cbNode->requestUri); | |||||
+ OICFree(response); | |||||
return; | |||||
} | |||||
- if(OC_STACK_OK != OCParsePayload(&response.payload, | |||||
+ if(OC_STACK_OK != OCParsePayload(&response->payload, | |||||
type, | |||||
responseInfo->info.payload, | |||||
responseInfo->info.payloadSize)) | |||||
{ | |||||
OIC_LOG(ERROR, TAG, "Error converting payload"); | |||||
- OCPayloadDestroy(response.payload); | |||||
+ OCPayloadDestroy(response->payload); | |||||
+ OICFree(response); | |||||
return; | |||||
} | |||||
} | |||||
- response.numRcvdVendorSpecificHeaderOptions = 0; | |||||
+ response->numRcvdVendorSpecificHeaderOptions = 0; | |||||
if(responseInfo->info.numOptions > 0) | |||||
{ | |||||
int start = 0; | |||||
@@ -1391,19 +1420,20 @@ void OCHandleResponse(const CAEndpoint_t | |||||
observationOption = | |||||
(observationOption << 8) | optionData[i]; | |||||
} | |||||
- response.sequenceNumber = observationOption; | |||||
- response.numRcvdVendorSpecificHeaderOptions = responseInfo->info.numOptions - 1; | |||||
+ response->sequenceNumber = observationOption; | |||||
+ response->numRcvdVendorSpecificHeaderOptions = responseInfo->info.numOptions - 1; | |||||
start = 1; | |||||
} | |||||
else | |||||
{ | |||||
- response.numRcvdVendorSpecificHeaderOptions = responseInfo->info.numOptions; | |||||
+ response->numRcvdVendorSpecificHeaderOptions = responseInfo->info.numOptions; | |||||
} | |||||
- if(response.numRcvdVendorSpecificHeaderOptions > MAX_HEADER_OPTIONS) | |||||
+ if(response->numRcvdVendorSpecificHeaderOptions > MAX_HEADER_OPTIONS) | |||||
{ | |||||
OIC_LOG(ERROR, TAG, "#header options are more than MAX_HEADER_OPTIONS"); | |||||
- OCPayloadDestroy(response.payload); | |||||
+ OCPayloadDestroy(response->payload); | |||||
+ OICFree(response); | |||||
return; | |||||
} | |||||
@@ -1411,19 +1441,19 @@ void OCHandleResponse(const CAEndpoint_t | |||||
{ | |||||
if(&(responseInfo->info.options[i])) | |||||
{ | |||||
- memcpy (&(response.rcvdVendorSpecificHeaderOptions[i-start]), | |||||
+ memcpy (&(response->rcvdVendorSpecificHeaderOptions[i-start]), | |||||
&(responseInfo->info.options[i]), sizeof(OCHeaderOption)); | |||||
} | |||||
} | |||||
} | |||||
if (cbNode->method == OC_REST_OBSERVE && | |||||
- response.sequenceNumber > OC_OFFSET_SEQUENCE_NUMBER && | |||||
+ response->sequenceNumber > OC_OFFSET_SEQUENCE_NUMBER && | |||||
cbNode->sequenceNumber <= MAX_SEQUENCE_NUMBER && | |||||
- response.sequenceNumber <= cbNode->sequenceNumber) | |||||
+ response->sequenceNumber <= cbNode->sequenceNumber) | |||||
{ | |||||
OIC_LOG_V(INFO, TAG, "Received stale notification. Number :%d", | |||||
- response.sequenceNumber); | |||||
+ response->sequenceNumber); | |||||
} | |||||
else | |||||
{ | |||||
@@ -1432,13 +1462,13 @@ void OCHandleResponse(const CAEndpoint_t | |||||
char *targetUri = strstr(cbNode->requestUri, OC_RSRVD_RD_URI); | |||||
if (targetUri) | |||||
{ | |||||
- OCUpdateResourceInsWithResponse(cbNode->requestUri, &response); | |||||
+ OCUpdateResourceInsWithResponse(cbNode->requestUri, response); | |||||
} | |||||
#endif | |||||
OCStackApplicationResult appFeedback = cbNode->callBack(cbNode->context, | |||||
cbNode->handle, | |||||
- &response); | |||||
- cbNode->sequenceNumber = response.sequenceNumber; | |||||
+ response); | |||||
+ cbNode->sequenceNumber = response->sequenceNumber; | |||||
if (appFeedback == OC_STACK_DELETE_TRANSACTION) | |||||
{ | |||||
@@ -1459,7 +1489,8 @@ void OCHandleResponse(const CAEndpoint_t | |||||
CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0, NULL, CA_RESPONSE_FOR_RES); | |||||
} | |||||
- OCPayloadDestroy(response.payload); | |||||
+ OCPayloadDestroy(response->payload); | |||||
+ OICFree(response); | |||||
} | |||||
return; | |||||
} | |||||
@@ -1585,16 +1616,26 @@ void HandleCAErrorResponse(const CAEndpo | |||||
errorInfo->info.tokenLength, NULL, NULL); | |||||
if (cbNode) | |||||
{ | |||||
- OCClientResponse response = { .devAddr = { .adapter = OC_DEFAULT_ADAPTER } }; | |||||
- CopyEndpointToDevAddr(endPoint, &response.devAddr); | |||||
- FixUpClientResponse(&response); | |||||
- response.resourceUri = errorInfo->info.resourceUri; | |||||
- memcpy(response.identity.id, errorInfo->info.identity.id, | |||||
- sizeof (response.identity.id)); | |||||
- response.identity.id_length = errorInfo->info.identity.id_length; | |||||
- response.result = CAResultToOCResult(errorInfo->result); | |||||
+ OCClientResponse *response = NULL; | |||||
+ | |||||
+ response = (OCClientResponse *)OICCalloc(1, sizeof(*response)); | |||||
+ if (!response) | |||||
+ { | |||||
+ OIC_LOG(ERROR, TAG, "Allocating memory for response failed"); | |||||
+ return; | |||||
+ } | |||||
+ | |||||
+ response->devAddr.adapter = OC_DEFAULT_ADAPTER; | |||||
+ CopyEndpointToDevAddr(endPoint, &response->devAddr); | |||||
+ FixUpClientResponse(response); | |||||
+ response->resourceUri = errorInfo->info.resourceUri; | |||||
+ memcpy(response->identity.id, errorInfo->info.identity.id, | |||||
+ sizeof (response->identity.id)); | |||||
+ response->identity.id_length = errorInfo->info.identity.id_length; | |||||
+ response->result = CAResultToOCResult(errorInfo->result); | |||||
- cbNode->callBack(cbNode->context, cbNode->handle, &response); | |||||
+ cbNode->callBack(cbNode->context, cbNode->handle, response); | |||||
+ OICFree(response); | |||||
} | |||||
ResourceObserver *observer = GetObserverUsingToken(errorInfo->info.token, |
@ -0,0 +1,103 @@ | |||||
From 7fb5b6a19b06dc5b0a7f32261551b206b1e6a563 Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sun, 8 Jan 2017 19:24:26 +0100 | |||||
Subject: [PATCH 3/3] src: move OCClientResponse from stack to heap | |||||
OCClientResponse is about 50KByte and should not be stored on the | |||||
stack. On LEDE with MIPS, musl libc this causes a segmentation fault. | |||||
Moving this structure to the heap is the simple solution for this | |||||
problem, but this structure should be shrinked. | |||||
Change-Id: I7887f93450f45b8031fcdfffb9ee2214fc3d5dd2 | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
resource/src/InProcServerWrapper.cpp | 44 +++++++++++++++++++++--------------- | |||||
1 file changed, 26 insertions(+), 18 deletions(-) | |||||
--- a/resource/src/InProcServerWrapper.cpp | |||||
+++ b/resource/src/InProcServerWrapper.cpp | |||||
@@ -568,51 +568,58 @@ namespace OC | |||||
} | |||||
else | |||||
{ | |||||
- OCEntityHandlerResponse response; | |||||
+ OCEntityHandlerResponse *response = NULL; | |||||
+ | |||||
+ response = (OCEntityHandlerResponse *)OICCalloc(1, sizeof(*response)); | |||||
+ if (!response) { | |||||
+ result = OC_STACK_MALFORMED_RESPONSE; | |||||
+ throw OCException(OC::Exception::STR_NULL_RESPONSE, OC_STACK_MALFORMED_RESPONSE); | |||||
+ } | |||||
+ | |||||
// OCRepPayload* payLoad = pResponse->getPayload(); | |||||
HeaderOptions serverHeaderOptions = pResponse->getHeaderOptions(); | |||||
- response.requestHandle = pResponse->getRequestHandle(); | |||||
- response.resourceHandle = pResponse->getResourceHandle(); | |||||
- response.ehResult = pResponse->getResponseResult(); | |||||
+ response->requestHandle = pResponse->getRequestHandle(); | |||||
+ response->resourceHandle = pResponse->getResourceHandle(); | |||||
+ response->ehResult = pResponse->getResponseResult(); | |||||
- response.payload = reinterpret_cast<OCPayload*>(pResponse->getPayload()); | |||||
+ response->payload = reinterpret_cast<OCPayload*>(pResponse->getPayload()); | |||||
- response.persistentBufferFlag = 0; | |||||
+ response->persistentBufferFlag = 0; | |||||
- response.numSendVendorSpecificHeaderOptions = serverHeaderOptions.size(); | |||||
+ response->numSendVendorSpecificHeaderOptions = serverHeaderOptions.size(); | |||||
int i = 0; | |||||
for (auto it=serverHeaderOptions.begin(); it != serverHeaderOptions.end(); ++it) | |||||
{ | |||||
- response.sendVendorSpecificHeaderOptions[i].protocolID = OC_COAP_ID; | |||||
- response.sendVendorSpecificHeaderOptions[i].optionID = | |||||
+ response->sendVendorSpecificHeaderOptions[i].protocolID = OC_COAP_ID; | |||||
+ response->sendVendorSpecificHeaderOptions[i].optionID = | |||||
static_cast<uint16_t>(it->getOptionID()); | |||||
- response.sendVendorSpecificHeaderOptions[i].optionLength = | |||||
+ response->sendVendorSpecificHeaderOptions[i].optionLength = | |||||
(it->getOptionData()).length() + 1; | |||||
std::string optionData = it->getOptionData(); | |||||
std::copy(optionData.begin(), | |||||
optionData.end(), | |||||
- response.sendVendorSpecificHeaderOptions[i].optionData); | |||||
- response.sendVendorSpecificHeaderOptions[i].optionData[it->getOptionData().length()] | |||||
+ response->sendVendorSpecificHeaderOptions[i].optionData); | |||||
+ response->sendVendorSpecificHeaderOptions[i].optionData[it->getOptionData().length()] | |||||
= '\0'; | |||||
i++; | |||||
} | |||||
- if(OC_EH_RESOURCE_CREATED == response.ehResult) | |||||
+ if(OC_EH_RESOURCE_CREATED == response->ehResult) | |||||
{ | |||||
- pResponse->getNewResourceUri().copy(response.resourceUri, | |||||
- sizeof (response.resourceUri) - 1); | |||||
- response.resourceUri[pResponse->getNewResourceUri().length()] = '\0'; | |||||
+ pResponse->getNewResourceUri().copy(response->resourceUri, | |||||
+ sizeof (response->resourceUri) - 1); | |||||
+ response->resourceUri[pResponse->getNewResourceUri().length()] = '\0'; | |||||
} | |||||
if(cLock) | |||||
{ | |||||
std::lock_guard<std::recursive_mutex> lock(*cLock); | |||||
- result = OCDoResponse(&response); | |||||
+ result = OCDoResponse(response); | |||||
} | |||||
else | |||||
{ | |||||
- OICFree(response.payload); | |||||
+ OICFree(response->payload); | |||||
result = OC_STACK_ERROR; | |||||
} | |||||
@@ -620,6 +627,7 @@ namespace OC | |||||
{ | |||||
oclog() << "Error sending response\n"; | |||||
} | |||||
+ OICFree(response); | |||||
return result; | |||||
} | |||||
} |
@ -1,38 +0,0 @@ | |||||
From 8a1a5562904c1bbdb2bcb332c0a74482d7cdea15 Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||||
Date: Wed, 11 Nov 2015 18:10:03 +0100 | |||||
Subject: [PATCH 5/5] resource-encapsulation: deactivate test covergae | |||||
Change-Id: I9c9b5853ee1521f5963c73c3025b1c0f10393a96 | |||||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com> | |||||
--- | |||||
.../resource-encapsulation/src/common/SConscript | 4 ---- | |||||
.../src/serverBuilder/SConscript | 4 ---- | |||||
2 files changed, 8 deletions(-) | |||||
--- a/service/resource-encapsulation/src/common/SConscript | |||||
+++ b/service/resource-encapsulation/src/common/SConscript | |||||
@@ -66,10 +66,6 @@ if target_os == 'android': | |||||
rcs_common_env.AppendUnique(LIBS = ['dl', 'oc']) | |||||
-if not release: | |||||
- rcs_common_env.AppendUnique(CXXFLAGS = ['--coverage']) | |||||
- rcs_common_env.PrependUnique(LIBS = ['gcov']) | |||||
- | |||||
###################################################################### | |||||
# Source files and Targets | |||||
###################################################################### | |||||
--- a/service/resource-encapsulation/src/serverBuilder/SConscript | |||||
+++ b/service/resource-encapsulation/src/serverBuilder/SConscript | |||||
@@ -67,10 +67,6 @@ server_builder_env.AppendUnique(LIBS = [ | |||||
if env.get('LOGGING'): | |||||
server_builder_env.AppendUnique(LIBS = ['octbstack']) | |||||
-if not release: | |||||
- server_builder_env.AppendUnique(CXXFLAGS = ['--coverage']) | |||||
- server_builder_env.PrependUnique(LIBS = ['gcov']) | |||||
- | |||||
###################################################################### | |||||
# Source files and Targets | |||||
###################################################################### |
@ -1,39 +0,0 @@ | |||||
From b1c29c35cba3eb39af18fb8db0ec676e3d658b1d Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||||
Date: Fri, 17 Jun 2016 17:38:35 +0200 | |||||
Subject: [PATCH] security: fix reading of permission attribute from | |||||
configuration | |||||
Casting the pointer to the permission attribute from uint16_t to uint64_t | |||||
causes problems on MIPS Big Endian systems and probably othrs as well. | |||||
When the calling method interprets it as uint64_t not the value is | |||||
converted but the pointer is interpreted as it would point to a 64 bit | |||||
integer, but it is only a 16 bit wide integer. On MIPS BE permission was | |||||
always 0 independent of which value between 0 and 32 the permission | |||||
attribute had, this was probably written to some padding area or into | |||||
some other member of the struct. | |||||
This patch fixes the memory corruption and makes the code work for me with | |||||
a MIPS BE CPU. | |||||
Change-Id: Ifa843e69980ad4309b1e3076b8e2c98c03324352 | |||||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||||
--- | |||||
resource/csdk/security/src/aclresource.c | 5 ++++- | |||||
1 file changed, 4 insertions(+), 1 deletion(-) | |||||
--- a/resource/csdk/security/src/aclresource.c | |||||
+++ b/resource/csdk/security/src/aclresource.c | |||||
@@ -602,8 +602,11 @@ OicSecAcl_t* CBORPayloadToAcl(const uint | |||||
// Permissions -- Mandatory | |||||
if (strcmp(name, OIC_JSON_PERMISSION_NAME) == 0) | |||||
{ | |||||
- cborFindResult = cbor_value_get_uint64(&aclMap, (uint64_t *) &acl->permission); | |||||
+ uint64_t tmp64; | |||||
+ | |||||
+ cborFindResult = cbor_value_get_uint64(&aclMap, &tmp64); | |||||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding a PERM Value."); | |||||
+ acl->permission = tmp64; | |||||
} | |||||
// Period -- Not mandatory |
@ -1,87 +0,0 @@ | |||||
From f182119e571a1b520b4e5ef4ee5e5b5cd243b931 Mon Sep 17 00:00:00 2001 | |||||
From: Chul Lee <chuls.lee@samsung.com> | |||||
Date: Wed, 22 Jun 2016 12:40:21 +0900 | |||||
Subject: [PATCH] Remove the endianness dependency in cbor conversion. | |||||
A similar bug reported from https://gerrit.iotivity.org/gerrit/#/c/8755/ | |||||
Change-Id: I631bab77f7486f1f45eaff96c67d39606e37c6b6 | |||||
Signed-off-by: Chul Lee <chuls.lee@samsung.com> | |||||
Reviewed-on: https://gerrit.iotivity.org/gerrit/8829 | |||||
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org> | |||||
Reviewed-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||||
Reviewed-by: Randeep Singh <randeep.s@samsung.com> | |||||
(cherry picked from commit 24474a8d2555229efb425b6cb63e19b3279ba810) | |||||
Reviewed-on: https://gerrit.iotivity.org/gerrit/9053 | |||||
--- | |||||
resource/csdk/security/src/credresource.c | 8 ++++++-- | |||||
resource/csdk/security/src/pconfresource.c | 5 +++-- | |||||
resource/csdk/stack/src/ocpayloadparse.c | 8 ++++++-- | |||||
3 files changed, 15 insertions(+), 6 deletions(-) | |||||
--- a/resource/csdk/security/src/credresource.c | |||||
+++ b/resource/csdk/security/src/credresource.c | |||||
@@ -435,8 +435,10 @@ OCStackResult CBORPayloadToCred(const ui | |||||
//credid | |||||
if (strcmp(name, OIC_JSON_CREDID_NAME) == 0) | |||||
{ | |||||
- cborFindResult = cbor_value_get_uint64(&credMap, (uint64_t *) &cred->credId); | |||||
+ uint64_t credId = 0; | |||||
+ cborFindResult = cbor_value_get_uint64(&credMap, &credId); | |||||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CredId."); | |||||
+ cred->credId = (uint16_t)credId; | |||||
} | |||||
// subjectid | |||||
if (strcmp(name, OIC_JSON_SUBJECTID_NAME) == 0) | |||||
@@ -451,8 +453,10 @@ OCStackResult CBORPayloadToCred(const ui | |||||
// credtype | |||||
if (strcmp(name, OIC_JSON_CREDTYPE_NAME) == 0) | |||||
{ | |||||
- cborFindResult = cbor_value_get_uint64(&credMap, (uint64_t *) &cred->credType); | |||||
+ uint64_t credType = 0; | |||||
+ cborFindResult = cbor_value_get_uint64(&credMap, &credType); | |||||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CredType."); | |||||
+ cred->credType = (OicSecCredType_t)credType; | |||||
} | |||||
// privatedata | |||||
if (strcmp(name, OIC_JSON_PRIVATEDATA_NAME) == 0) | |||||
--- a/resource/csdk/security/src/pconfresource.c | |||||
+++ b/resource/csdk/security/src/pconfresource.c | |||||
@@ -642,8 +642,9 @@ OCStackResult CBORPayloadToPconf(const u | |||||
// Permissions -- Mandatory | |||||
if (strcmp(name, OIC_JSON_PERMISSION_NAME) == 0) | |||||
{ | |||||
- cborFindResult = cbor_value_get_uint64(&pdAclMap, | |||||
- (uint64_t *) &pdacl->permission); | |||||
+ uint64_t permission = 0; | |||||
+ cborFindResult = cbor_value_get_uint64(&pdAclMap, &permission); | |||||
+ pdacl->permission = (uint16_t)permission; | |||||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value"); | |||||
} | |||||
--- a/resource/csdk/stack/src/ocpayloadparse.c | |||||
+++ b/resource/csdk/stack/src/ocpayloadparse.c | |||||
@@ -1169,17 +1169,21 @@ static OCStackResult OCParsePresencePayl | |||||
if (cbor_value_is_map(rootValue)) | |||||
{ | |||||
CborValue curVal; | |||||
+ uint64_t temp = 0; | |||||
// Sequence Number | |||||
CborError err = cbor_value_map_find_value(rootValue, OC_RSRVD_NONCE, &curVal); | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding nonce tag"); | |||||
- err = cbor_value_get_uint64(&curVal, (uint64_t *)&payload->sequenceNumber); | |||||
+ err = cbor_value_get_uint64(&curVal, &temp); | |||||
+ payload->sequenceNumber = (uint32_t)temp; | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding nonce value"); | |||||
// Max Age | |||||
err = cbor_value_map_find_value(rootValue, OC_RSRVD_TTL, &curVal); | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding ttl tag"); | |||||
- err = cbor_value_get_uint64(&curVal, (uint64_t *)&payload->maxAge); | |||||
+ temp = 0; | |||||
+ err = cbor_value_get_uint64(&curVal, &temp); | |||||
+ payload->maxAge = (uint32_t)temp; | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding ttl value"); | |||||
// Trigger |
@ -1,93 +0,0 @@ | |||||
From 7c99ef8bfa024f11452311c36329eeeeece4fd74 Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||||
Date: Wed, 22 Jun 2016 11:41:43 +0200 | |||||
Subject: [PATCH] Fix memory corruption when reading inetgers from cbor | |||||
When the cbor_value_get_*() function is called with a pointer to some int, it | |||||
should have the correct size. When we cast it to something else it is treated | |||||
as a pointer to an uint64_t in the function for example and them 64 bits gets | |||||
written to memory even with the real type is only 32 bit long. When the real | |||||
type is only 32 bit long some other memory gets overwritten. On Big endian | |||||
systems the least significant bits are cut of so in most cases 0 is read. | |||||
With this patch a value cast is used and the value is converted to the other size. | |||||
This is the same as in commit 0d64c7c95a5c11a9fb5201e729fd8c75da210c80 | |||||
"security: fix reading of permission attribute from configuration" | |||||
Change-Id: If5965491241e25ebf60a22dc45d37d74a33cb02f | |||||
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@intel.com> | |||||
--- | |||||
resource/csdk/security/src/pconfresource.c | 5 ++++- | |||||
resource/csdk/stack/src/ocpayloadparse.c | 19 +++++++++++++++---- | |||||
2 files changed, 19 insertions(+), 5 deletions(-) | |||||
--- a/resource/csdk/security/src/pconfresource.c | |||||
+++ b/resource/csdk/security/src/pconfresource.c | |||||
@@ -507,8 +507,11 @@ OCStackResult CBORPayloadToPconf(const u | |||||
while (cbor_value_is_valid(&prm)) | |||||
{ | |||||
- cborFindResult = cbor_value_get_int(&prm, (int *)&pconf->prm[i++]); | |||||
+ int prm_val; | |||||
+ | |||||
+ cborFindResult = cbor_value_get_int(&prm, &prm_val); | |||||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get value"); | |||||
+ pconf->prm[i++] = (OicSecPrm_t)prm_val; | |||||
cborFindResult = cbor_value_advance(&prm); | |||||
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to advance value"); | |||||
} | |||||
--- a/resource/csdk/stack/src/ocpayloadparse.c | |||||
+++ b/resource/csdk/stack/src/ocpayloadparse.c | |||||
@@ -287,6 +287,8 @@ static OCStackResult OCParseDiscoveryPay | |||||
while (cbor_value_is_map(&resourceMap)) | |||||
{ | |||||
+ int bitmap; | |||||
+ | |||||
resource = (OCResourcePayload *)OICCalloc(1, sizeof(OCResourcePayload)); | |||||
VERIFY_PARAM_NON_NULL(TAG, resource, "Failed allocating resource payload"); | |||||
@@ -319,8 +321,9 @@ static OCStackResult OCParseDiscoveryPay | |||||
// Bitmap | |||||
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_BITMAP, &curVal); | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "to find bitmap tag"); | |||||
- err = cbor_value_get_int(&curVal, (int *)&resource->bitmap); | |||||
+ err = cbor_value_get_int(&curVal, &bitmap); | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "to find bitmap value"); | |||||
+ resource->bitmap = (uint8_t)bitmap; | |||||
// Secure Flag | |||||
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_SECURE, &curVal); | |||||
@@ -336,8 +339,11 @@ static OCStackResult OCParseDiscoveryPay | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "to find port tag"); | |||||
if (cbor_value_is_valid(&curVal)) | |||||
{ | |||||
- err = cbor_value_get_int(&curVal, (int *)&resource->port); | |||||
+ int port; | |||||
+ | |||||
+ err = cbor_value_get_int(&curVal, &port); | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "to find port value"); | |||||
+ resource->port = (uint16_t)port; | |||||
} | |||||
err = cbor_value_advance(&resourceMap); | |||||
@@ -1170,6 +1176,7 @@ static OCStackResult OCParsePresencePayl | |||||
{ | |||||
CborValue curVal; | |||||
uint64_t temp = 0; | |||||
+ uint8_t trigger; | |||||
// Sequence Number | |||||
CborError err = cbor_value_map_find_value(rootValue, OC_RSRVD_NONCE, &curVal); | |||||
@@ -1189,8 +1196,9 @@ static OCStackResult OCParsePresencePayl | |||||
// Trigger | |||||
err = cbor_value_map_find_value(rootValue, OC_RSRVD_TRIGGER, &curVal); | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding trigger tag"); | |||||
- err = cbor_value_get_simple_type(&curVal, (uint8_t *)&payload->trigger); | |||||
+ err = cbor_value_get_simple_type(&curVal, &trigger); | |||||
VERIFY_CBOR_SUCCESS(TAG, err, "Failed finding trigger value"); | |||||
+ payload->trigger = (OCPresenceTrigger)trigger; | |||||
// Resource type name | |||||
err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &curVal); |
@ -1,36 +0,0 @@ | |||||
From e093390b2839f6039a6ff94ed4942fa45c53a418 Mon Sep 17 00:00:00 2001 | |||||
From: Philippe Coval <philippe.coval@osg.samsung.com> | |||||
Date: Tue, 26 Apr 2016 15:28:17 +0200 | |||||
Subject: [PATCH] [Resource-container] Backported init fix to 1.1-rel | |||||
[Resource-container] Fix member var initialization | |||||
Incorrect type was used causing build error. | |||||
Origin: 6a10062f1fe64ca75ac6d34541bbd295ef052dcb | |||||
Author: Inga Stotland <inga.stotland@intel.com> | |||||
Change-Id: I701096c3b6512546847cf4e120430f690e920453 | |||||
Signed-off-by: Inga Stotland <inga.stotland@intel.com> | |||||
Reviewed-on: https://gerrit.iotivity.org/gerrit/7759 | |||||
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org> | |||||
Reviewed-by: George Nash <george.nash@intel.com> | |||||
Reviewed-by: Markus Jung <markus.jung85@gmail.com> | |||||
Reviewed-by: Uze Choi <uzchoi@samsung.com> | |||||
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com> | |||||
Reviewed-on: https://gerrit.iotivity.org/gerrit/7929 | |||||
--- | |||||
service/resource-container/src/BundleInfoInternal.cpp | 2 +- | |||||
1 file changed, 1 insertion(+), 1 deletion(-) | |||||
--- a/service/resource-container/src/BundleInfoInternal.cpp | |||||
+++ b/service/resource-container/src/BundleInfoInternal.cpp | |||||
@@ -32,8 +32,8 @@ namespace OIC | |||||
m_resourceCreator = nullptr; | |||||
m_resourceDestroyer = nullptr; | |||||
m_bundleHandle = nullptr; | |||||
- m_so_bundle = nullptr; | |||||
+ m_so_bundle = false; | |||||
m_loaded = false; | |||||
m_activated = false; | |||||
m_java_bundle = false; |
@ -0,0 +1,27 @@ | |||||
From 261cf19bfa3dea10ed0f2ebbb2d945c19c9a2804 Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sun, 4 Dec 2016 00:18:37 +0100 | |||||
Subject: [PATCH 5/7] ssl: fix compilation against non debug mbedtls | |||||
The function mbedtls_debug_set_threshold() is only available when | |||||
MBEDTLS_DEBUG_C is set. make the call depend on this condition. | |||||
Change-Id: I8158bc4c55b428167e36084e7a46359c269c5fc7 | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | 2 ++ | |||||
1 file changed, 2 insertions(+) | |||||
--- a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | |||||
+++ b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | |||||
@@ -1278,8 +1278,10 @@ static int InitConfig(mbedtls_ssl_config | |||||
#if !defined(NDEBUG) || defined(TB_LOG) | |||||
mbedtls_ssl_conf_dbg(conf, DebugSsl, NULL); | |||||
+#if defined(MBEDTLS_DEBUG_C) | |||||
mbedtls_debug_set_threshold(MBED_TLS_DEBUG_LEVEL); | |||||
#endif | |||||
+#endif | |||||
OIC_LOG_V(DEBUG, NET_SSL_TAG, "Out %s", __func__); | |||||
return 0; | |||||
} |
@ -0,0 +1,35 @@ | |||||
From cee085e0e62214603b9ae035d63fabca23c491bd Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sun, 8 Jan 2017 01:39:35 +0100 | |||||
Subject: [PATCH 6/7] ssl: call mbedtls_version_get_string() only if available | |||||
The function mbedtls_version_get_string() is only available if | |||||
MBEDTLS_VERSION_C is set in the mbedtls configuration. Check this | |||||
before calling this function and print the mbedtls version this was | |||||
compiled against instead if mbedtls_version_get_string() is not | |||||
available. | |||||
This fixes a compile problem when MBEDTLS_VERSION_C is not set. | |||||
Change-Id: I54c2c2a3fc1f9d35afa475500e3db68420a1b54a | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | 4 ++++ | |||||
1 file changed, 4 insertions(+) | |||||
--- a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | |||||
+++ b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | |||||
@@ -1376,9 +1376,13 @@ CAResult_t CAinitSslAdapter() | |||||
/* Initialize TLS library | |||||
*/ | |||||
#if !defined(NDEBUG) || defined(TB_LOG) | |||||
+#ifdef MBEDTLS_VERSION_C | |||||
char version[MBED_TLS_VERSION_LEN]; | |||||
mbedtls_version_get_string(version); | |||||
OIC_LOG_V(INFO, NET_SSL_TAG, "mbed TLS version: %s", version); | |||||
+#else | |||||
+ OIC_LOG_V(INFO, NET_SSL_TAG, "mbed TLS version: %s", MBEDTLS_VERSION_STRING); | |||||
+#endif | |||||
#endif | |||||
/* Entropy settings |
@ -0,0 +1,30 @@ | |||||
From 3684ac3720f91dc131c1c61689395a69ae1865f9 Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sun, 8 Jan 2017 20:31:18 +0100 | |||||
Subject: [PATCH 7/7] ssl: call mbedtls_ssl_conf_renegotiation() only if | |||||
available | |||||
The function mbedtls_ssl_conf_renegotiation() is only available if | |||||
MBEDTLS_SSL_RENEGOTIATION is set in the mbedtls configuration. Check this | |||||
before calling this function. | |||||
This fixes a compile problem when MBEDTLS_SSL_RENEGOTIATION is not set. | |||||
Change-Id: I69f15359d2dcaed1e4fe56fc7799737e38d6c2e7 | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | 2 ++ | |||||
1 file changed, 2 insertions(+) | |||||
--- a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | |||||
+++ b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | |||||
@@ -1273,7 +1273,9 @@ static int InitConfig(mbedtls_ssl_config | |||||
mbedtls_ssl_conf_rng(conf, mbedtls_ctr_drbg_random, &g_caSslContext->rnd); | |||||
mbedtls_ssl_conf_curves(conf, curve[ADAPTER_CURVE_SECP256R1]); | |||||
mbedtls_ssl_conf_min_version(conf, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3); | |||||
+#ifdef MBEDTLS_SSL_RENEGOTIATION | |||||
mbedtls_ssl_conf_renegotiation(conf, MBEDTLS_SSL_RENEGOTIATION_DISABLED); | |||||
+#endif | |||||
mbedtls_ssl_conf_authmode(conf, MBEDTLS_SSL_VERIFY_REQUIRED); | |||||
#if !defined(NDEBUG) || defined(TB_LOG) |
@ -0,0 +1,44 @@ | |||||
From 01796db0b166e720860eff200acabff410ba6979 Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sun, 4 Dec 2016 00:15:21 +0100 | |||||
Subject: [PATCH 4/7] ssl: enable usage of patched mbed functions conditionally | |||||
Only activate support for the MBEDTLS_KEY_EXCHANGE_ECDH_ANON_ENABLED | |||||
cipher suite when this is actually available in mbedtls. | |||||
This makes it possible to compile IoTivity against a unpatched mbedtls | |||||
version. | |||||
Change-Id: Ic56d7faf7597cc5dc08f9d55be29dde898949609 | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | 4 ++++ | |||||
1 file changed, 4 insertions(+) | |||||
--- a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | |||||
+++ b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | |||||
@@ -237,7 +237,9 @@ int tlsCipher[ADAPTER_CIPHER_MAX][2] = | |||||
{ | |||||
{MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA, 0}, | |||||
{MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, 0}, | |||||
+#ifdef MBEDTLS_TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256 | |||||
{MBEDTLS_TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256, 0}, | |||||
+#endif | |||||
{MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256, 0}, | |||||
{MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM, 0}, | |||||
{MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, 0} | |||||
@@ -1943,6 +1945,7 @@ CAResult_t CAsetTlsCipherSuite(const uin | |||||
g_caSslContext->cipher = ADAPTER_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8; | |||||
break; | |||||
} | |||||
+#ifdef MBEDTLS_TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256 | |||||
case MBEDTLS_TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256: | |||||
{ | |||||
#ifdef __WITH_TLS__ | |||||
@@ -1960,6 +1963,7 @@ CAResult_t CAsetTlsCipherSuite(const uin | |||||
g_caSslContext->cipher = ADAPTER_TLS_ECDH_ANON_WITH_AES_128_CBC_SHA_256; | |||||
break; | |||||
} | |||||
+#endif | |||||
case MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256: | |||||
{ | |||||
#if 0 // PIN OTM |
@ -0,0 +1,22 @@ | |||||
Make it possible to use system mbedtls version | |||||
--- a/resource/csdk/connectivity/src/SConscript | |||||
+++ b/resource/csdk/connectivity/src/SConscript | |||||
@@ -73,16 +73,7 @@ if env.get('SECURED') == '1': | |||||
env.AppendUnique(CPPPATH = [src_dir + '/resource/csdk/security/include']) | |||||
env.AppendUnique(CPPDEFINES = ['__WITH_DTLS__']) | |||||
env.AppendUnique(CPPPATH = [os.path.join(root_dir, 'external/inc')]) | |||||
- tls_path = 'extlibs/mbedtls'; | |||||
- tls_headers_path = 'mbedtls/include'; | |||||
- if ca_os == 'tizen' and os.path.exists(root_dir + '/' + tls_path): | |||||
- env.SConscript(os.path.join(root_dir, tls_path + '/SConscript')) | |||||
- env.AppendUnique(CPPPATH = [os.path.join(root_dir, tls_path + '/' + tls_headers_path)]) | |||||
- else: | |||||
- if ca_os != 'android': | |||||
- env.SConscript('#' + tls_path + '/SConscript') | |||||
- env.AppendUnique(CPPPATH = ['#' + tls_path + '/' + tls_headers_path]) | |||||
- env.AppendUnique(CA_SRC = [os.path.join(ca_path, 'adapter_util/ca_adapter_net_ssl.c')]) | |||||
+ env.AppendUnique(CA_SRC = [os.path.join(ca_path, 'adapter_util/ca_adapter_net_ssl.c')]) | |||||
if ((secured == '1') and (with_tcp == True)): | |||||
env.AppendUnique(CPPDEFINES = ['__WITH_TLS__']) |
@ -0,0 +1,31 @@ | |||||
From df8360447163762c63994dcb07f9e69a5a365a1c Mon Sep 17 00:00:00 2001 | |||||
From: Hauke Mehrtens <hauke@hauke-m.de> | |||||
Date: Sun, 8 Jan 2017 22:01:57 +0100 | |||||
Subject: [PATCH 8/8] zigbee_wrapper: do not check for floating point | |||||
This makes the compile fail for soft float builds. In such builds the | |||||
double is still 64 bit long. | |||||
Change-Id: I45d3f19b49f5d23d2b65307738a362765c5ea1c2 | |||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> | |||||
--- | |||||
plugins/zigbee_wrapper/src/zigbee_wrapper.c | 8 -------- | |||||
1 file changed, 8 deletions(-) | |||||
--- a/plugins/zigbee_wrapper/src/zigbee_wrapper.c | |||||
+++ b/plugins/zigbee_wrapper/src/zigbee_wrapper.c | |||||
@@ -37,14 +37,6 @@ | |||||
#include <math.h> | |||||
#include <errno.h> | |||||
-// The following #define must be here under "math.h". | |||||
-// This ifdef ensures that "__STDC_IEC_559__" is defined. If it is defined, | |||||
-// then we are guaranteed that the 'double' type is 64-bit. Otherwise, the | |||||
-// compilation of this file should fail because we are no longer guaranteed. | |||||
-#ifndef __STDC_IEC_559__ | |||||
-#error "Requires IEEE 754 floating point!" | |||||
-#endif | |||||
- | |||||
#include "zigbee_wrapper.h" | |||||
#include "telegesis_wrapper.h" | |||||
#include "pluginlist.h" |
@ -1,35 +1,32 @@ | |||||
--- a/resource/csdk/connectivity/src/bt_le_adapter/linux/SConscript | --- a/resource/csdk/connectivity/src/bt_le_adapter/linux/SConscript | ||||
+++ b/resource/csdk/connectivity/src/bt_le_adapter/linux/SConscript | +++ b/resource/csdk/connectivity/src/bt_le_adapter/linux/SConscript | ||||
@@ -73,7 +73,7 @@ env.AppendUnique( | |||||
@@ -73,7 +73,6 @@ env.AppendUnique( | |||||
# The Linux BLE adapter implementation uses GDBus to make D-Bus based | # The Linux BLE adapter implementation uses GDBus to make D-Bus based | ||||
# method calls to BlueZ. Pull in the necessary dependencies. | # method calls to BlueZ. Pull in the necessary dependencies. | ||||
-env.ParseConfig("pkg-config gio-unix-2.0 --cflags --libs") | -env.ParseConfig("pkg-config gio-unix-2.0 --cflags --libs") | ||||
+# env.ParseConfig("pkg-config gio-unix-2.0 --cflags --libs") | |||||
# Set up commands to generate GDBus code from the D-Bus introspection | # Set up commands to generate GDBus code from the D-Bus introspection | ||||
# XML. | # XML. | ||||
--- a/resource/csdk/security/provisioning/sample/SConscript | --- a/resource/csdk/security/provisioning/sample/SConscript | ||||
+++ b/resource/csdk/security/provisioning/sample/SConscript | +++ b/resource/csdk/security/provisioning/sample/SConscript | ||||
@@ -58,7 +58,7 @@ if env.get('SECURED') == '1': | |||||
if env.get('DTLS_WITH_X509') == '1': | |||||
provisioning_env.AppendUnique(LIBS = ['CKManager']) | |||||
provisioning_env.AppendUnique(LIBS = ['asn1']) | |||||
-provisioning_env.ParseConfig('pkg-config --libs glib-2.0'); | |||||
+# provisioning_env.ParseConfig('pkg-config --libs glib-2.0'); | |||||
provisioning_env.AppendUnique(CPPDEFINES = ['TB_LOG']) | |||||
@@ -70,7 +70,6 @@ if target_os not in ['windows']: | |||||
if target_os not in ['msys_nt', 'windows']: | |||||
provisioning_env.AppendUnique(LIBS = ['dl', 'm']) | |||||
- provisioning_env.ParseConfig('pkg-config --libs glib-2.0'); | |||||
provisioning_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) | |||||
else: | |||||
provisioning_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'csdk')]) | |||||
--- a/resource/csdk/security/provisioning/SConscript | --- a/resource/csdk/security/provisioning/SConscript | ||||
+++ b/resource/csdk/security/provisioning/SConscript | +++ b/resource/csdk/security/provisioning/SConscript | ||||
@@ -76,8 +76,8 @@ provisioning_env.AppendUnique(LIBS = ['t | |||||
if env.get('DTLS_WITH_X509') == '1': | |||||
provisioning_env.AppendUnique(LIBS = ['CKManager', 'asn1']) | |||||
@@ -73,9 +73,6 @@ provisioning_env.PrependUnique(LIBS = [' | |||||
provisioning_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto']) | |||||
-if target_os != 'android': | |||||
-if target_os not in ['msys_nt', 'windows', 'android', 'ios']: | |||||
- provisioning_env.ParseConfig('pkg-config --libs glib-2.0') | - provisioning_env.ParseConfig('pkg-config --libs glib-2.0') | ||||
+# if target_os != 'android': | |||||
+# provisioning_env.ParseConfig('pkg-config --libs glib-2.0') | |||||
- | |||||
if target_os in ['windows', 'msys_nt']: | |||||
provisioning_env.AppendUnique(LIBS = ['ws2_32', 'advapi32', 'iphlpapi']) | |||||
if target_os == 'tizen': | |||||
provisioning_env.ParseConfig('pkg-config --cflags --libs sqlite3') |