Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iotivity-lite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
41
Issues
41
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IoTivity
iotivity-lite
Commits
62c29f82
Commit
62c29f82
authored
Jan 28, 2020
by
Kishen Maloor
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into fargo
Signed-off-by:
Kishen Maloor
<
kishen.maloor@intel.com
>
parents
8a659eef
21fe3cb6
Pipeline
#222
passed with stage
in 49 seconds
Changes
52
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
885 additions
and
428 deletions
+885
-428
api/cloud/oc_cloud_store.c
api/cloud/oc_cloud_store.c
+6
-29
api/oc_endpoint.c
api/oc_endpoint.c
+46
-0
api/oc_introspection.c
api/oc_introspection.c
+7
-10
api/oc_ri.c
api/oc_ri.c
+1
-3
api/oc_swupdate.c
api/oc_swupdate.c
+5
-0
api/unittest/eptest.cpp
api/unittest/eptest.cpp
+213
-50
apps/client_block_linux.c
apps/client_block_linux.c
+2
-2
apps/client_collections_linux.c
apps/client_collections_linux.c
+2
-2
apps/client_linux.c
apps/client_linux.c
+2
-2
apps/client_multithread_linux.c
apps/client_multithread_linux.c
+2
-2
apps/cloud_certification_tests.c
apps/cloud_certification_tests.c
+2
-0
apps/cloud_server.c
apps/cloud_server.c
+2
-0
apps/multi_device_client_linux.c
apps/multi_device_client_linux.c
+2
-2
apps/multi_device_server_linux.c
apps/multi_device_server_linux.c
+2
-2
apps/server_block_linux.c
apps/server_block_linux.c
+2
-2
apps/server_collections_linux.c
apps/server_collections_linux.c
+2
-2
apps/server_linux.c
apps/server_linux.c
+2
-2
apps/server_multithread_linux.c
apps/server_multithread_linux.c
+2
-2
apps/simpleclient.c
apps/simpleclient.c
+2
-2
apps/simpleclient_windows.c
apps/simpleclient_windows.c
+2
-2
apps/simpleserver.c
apps/simpleserver.c
+2
-2
apps/simpleserver_pki.c
apps/simpleserver_pki.c
+2
-2
apps/simpleserver_windows.c
apps/simpleserver_windows.c
+3
-3
apps/smart_home_server_linux.c
apps/smart_home_server_linux.c
+2
-2
apps/smart_home_server_with_mock_swupdate.cpp
apps/smart_home_server_with_mock_swupdate.cpp
+2
-2
apps/smart_lock_linux.c
apps/smart_lock_linux.c
+2
-2
apps/temp_sensor_client_linux.c
apps/temp_sensor_client_linux.c
+2
-2
include/oc_api.h
include/oc_api.h
+182
-8
include/oc_client_state.h
include/oc_client_state.h
+1
-1
include/oc_endpoint.h
include/oc_endpoint.h
+1
-0
messaging/coap/engine.c
messaging/coap/engine.c
+10
-3
onboarding_tool/obtmain.c
onboarding_tool/obtmain.c
+2
-0
port/android/oc_config.h
port/android/oc_config.h
+14
-0
port/android/random.c
port/android/random.c
+1
-0
port/android/storage.c
port/android/storage.c
+3
-2
port/linux/oc_config.h
port/linux/oc_config.h
+14
-0
port/linux/storage.c
port/linux/storage.c
+3
-2
port/openthread/oc_config.h
port/openthread/oc_config.h
+14
-0
port/openthread/storage.c
port/openthread/storage.c
+3
-2
port/windows/oc_config.h
port/windows/oc_config.h
+14
-0
port/windows/storage.c
port/windows/storage.c
+3
-2
port/zephyr/src/oc_config.h
port/zephyr/src/oc_config.h
+14
-0
port/zephyr/src/storage.c
port/zephyr/src/storage.c
+4
-2
security/oc_obt.c
security/oc_obt.c
+6
-0
swig/apps/java_lite_simple_client/run-simple-client-lite.cmd
swig/apps/java_lite_simple_client/run-simple-client-lite.cmd
+1
-1
swig/apps/java_lite_simple_server/run-simple-server-lite.cmd
swig/apps/java_lite_simple_server/run-simple-server-lite.cmd
+1
-1
swig/apps/java_onboarding_tool/run-onboarding-tool-lite.cmd
swig/apps/java_onboarding_tool/run-onboarding-tool-lite.cmd
+1
-1
swig/apps/oc/android_on_boarding_tool/OnBoardingTool/gradlew.bat
...ps/oc/android_on_boarding_tool/OnBoardingTool/gradlew.bat
+90
-90
swig/apps/oc/android_simple_client/SimpleClient/gradlew.bat
swig/apps/oc/android_simple_client/SimpleClient/gradlew.bat
+90
-90
swig/apps/oc/android_simple_server/SimpleServer/gradlew.bat
swig/apps/oc/android_simple_server/SimpleServer/gradlew.bat
+90
-90
swig/apps/oc/java_oc_onboarding_tool/run-onboarding-tool-lite.cmd
...s/oc/java_oc_onboarding_tool/run-onboarding-tool-lite.cmd
+1
-1
swig/apps/oc/java_oc_simple_client/run-simple-client-lite.cmd
.../apps/oc/java_oc_simple_client/run-simple-client-lite.cmd
+1
-1
No files found.
api/cloud/oc_cloud_store.c
View file @
62c29f82
...
...
@@ -21,43 +21,20 @@
#include "oc_api.h"
#include "oc_cloud_internal.h"
#include "oc_rep.h"
#include "oc_config.h"
#ifdef OC_DYNAMIC_ALLOCATION
#include <stdlib.h>
#endif
/* OC_DYNAMIC_ALLOCATION */
#ifndef OC_STORAGE
#error Preprocessor macro OC_CLOUD is defined but OC_STORAGE is not defined \
check oc_config.h and make sure OC_STORAGE is defined if OC_CLOUD is defined.
#endif
#define CLOUD_STORE_NAME "cloud"
#define CLOUD_TAG_MAX (32)
#ifndef OC_SECURITY
// dummy storage
int
oc_storage_config
(
const
char
*
store
)
{
(
void
)
store
;
return
0
;
}
long
oc_storage_read
(
const
char
*
store
,
uint8_t
*
buf
,
size_t
size
)
{
(
void
)
store
;
(
void
)
buf
;
(
void
)
size
;
return
-
1
;
}
long
oc_storage_write
(
const
char
*
store
,
uint8_t
*
buf
,
size_t
size
)
{
(
void
)
store
;
(
void
)
buf
;
(
void
)
size
;
return
-
1
;
}
#endif
static
int
cloud_store_load_internal
(
const
char
*
store_name
,
oc_cloud_store_t
*
store
);
static
void
gen_cloud_tag
(
const
char
*
name
,
size_t
device
,
char
*
cloud_tag
);
...
...
api/oc_endpoint.c
View file @
62c29f82
...
...
@@ -496,6 +496,52 @@ oc_string_to_endpoint(oc_string_t *endpoint_str, oc_endpoint_t *endpoint,
return
-
1
;
}
int
oc_endpoint_string_parse_path
(
oc_string_t
*
endpoint_str
,
oc_string_t
*
path
)
{
if
(
!
endpoint_str
)
{
return
-
1
;
}
if
(
!
path
)
{
return
-
1
;
}
const
char
*
address
=
NULL
;
address
=
strstr
(
oc_string
(
*
endpoint_str
),
"://"
);
if
(
!
address
)
{
return
-
1
;
}
// 3 is string length of "://"
address
+=
3
;
size_t
len
=
oc_string_len
(
*
endpoint_str
)
-
(
address
-
oc_string
(
*
endpoint_str
));
// the smallest possible address is '0' anything smaller is invalid.
if
(
len
<
1
)
{
return
-
1
;
}
/* Extract a uri path if available */
const
char
*
path_start
=
NULL
;
const
char
*
query_start
=
NULL
;
path_start
=
memchr
(
address
,
'/'
,
len
);
if
(
!
path_start
)
{
// no path found return error
return
-
1
;
}
query_start
=
memchr
((
address
+
(
path_start
-
address
)),
'?'
,
(
len
-
(
path_start
-
address
)));
if
(
query_start
)
{
oc_new_string
(
path
,
path_start
,
(
query_start
-
path_start
));
}
else
{
oc_new_string
(
path
,
path_start
,
(
len
-
(
path_start
-
address
)));
}
return
0
;
}
int
oc_ipv6_endpoint_is_link_local
(
oc_endpoint_t
*
endpoint
)
{
...
...
api/oc_introspection.c
View file @
62c29f82
...
...
@@ -22,14 +22,19 @@
#include "oc_introspection_internal.h"
#include <inttypes.h>
#include <stdio.h>
#include "oc_config.h"
#ifndef OC_IDD_API
#include "server_introspection.dat.h"
#else
/* OC_IDD_API */
#if !defined(OC_STORAGE) && defined(OC_IDD_API)
#error Preprocessor macro OC_IDD_API is defined but OC_STORAGE is not defined \
check oc_config.h and make sure OC_STORAGE is defined if OC_IDD_API is defined.
#endif
#define MAX_TAG_LENGTH 20
#ifdef OC_SECURITY
static
void
gen_idd_tag
(
const
char
*
name
,
size_t
device_index
,
char
*
idd_tag
)
{
...
...
@@ -39,19 +44,13 @@ gen_idd_tag(const char *name, size_t device_index, char *idd_tag)
(
idd_tag_len
<
MAX_TAG_LENGTH
)
?
idd_tag_len
+
1
:
MAX_TAG_LENGTH
;
idd_tag
[
idd_tag_len
]
=
'\0'
;
}
#endif
/* OC_SECURITY */
void
oc_set_introspection_data
(
size_t
device
,
uint8_t
*
IDD
,
size_t
IDD_size
)
{
(
void
)
device
;
(
void
)
IDD
;
(
void
)
IDD_size
;
#ifdef OC_SECURITY
char
idd_tag
[
MAX_TAG_LENGTH
];
gen_idd_tag
(
"IDD"
,
device
,
idd_tag
);
oc_storage_write
(
idd_tag
,
IDD
,
IDD_size
);
#endif
/* OC_SECURITY */
}
#endif
/*OC_IDD_API*/
...
...
@@ -73,13 +72,11 @@ oc_core_introspection_data_handler(oc_request_t *request,
}
else
{
IDD_size
=
-
1
;
}
#else
/* OC_IDD_API */
#ifdef OC_SECURITY
#else
/* OC_IDD_API */
char
idd_tag
[
MAX_TAG_LENGTH
];
gen_idd_tag
(
"IDD"
,
request
->
resource
->
device
,
idd_tag
);
IDD_size
=
oc_storage_read
(
idd_tag
,
request
->
response
->
response_buffer
->
buffer
,
OC_MAX_APP_DATA_SIZE
);
#endif
/* OC_SECURITY */
#endif
/* OC_IDD_API */
if
(
IDD_size
>=
0
&&
IDD_size
<
OC_MAX_APP_DATA_SIZE
)
{
...
...
api/oc_ri.c
View file @
62c29f82
...
...
@@ -1229,7 +1229,7 @@ oc_ri_find_client_cb_by_token(uint8_t *token, uint8_t token_len)
return
cb
;
}
static
bool
bool
oc_ri_is_client_cb_valid
(
oc_client_cb_t
*
client_cb
)
{
oc_client_cb_t
*
cb
=
oc_list_head
(
client_cbs
);
...
...
@@ -1316,7 +1316,6 @@ oc_ri_invoke_client_cb(void *response, oc_client_cb_t *cb,
struct
oc_memb
rep_objects
=
{
sizeof
(
oc_rep_t
),
0
,
0
,
0
,
0
};
#endif
/* OC_DYNAMIC_ALLOCATION */
oc_rep_set_pool
(
&
rep_objects
);
if
(
payload_len
)
{
if
(
cb
->
discovery
)
{
if
(
oc_ri_process_discovery_payload
(
payload
,
payload_len
,
cb
->
handler
,
...
...
@@ -1401,7 +1400,6 @@ oc_ri_invoke_client_cb(void *response, oc_client_cb_t *cb,
}
}
}
return
true
;
}
...
...
api/oc_swupdate.c
View file @
62c29f82
...
...
@@ -22,6 +22,11 @@
#include "oc_swupdate_internal.h"
#include "security/oc_pstat.h"
#ifndef OC_STORAGE
#error Preprocessor macro OC_SOFTWARE_UPDATE is defined but OC_STORAGE is not defined \
check oc_config.h and make sure OC_STORAGE is defined if OC_SOFTWARE_UPDATE is defined.
#endif
#ifdef OC_DYNAMIC_ALLOCATION
#include "port/oc_assert.h"
#include <stdlib.h>
...
...
api/unittest/eptest.cpp
View file @
62c29f82
...
...
@@ -18,49 +18,70 @@
#include <cstdlib>
#include "oc_endpoint.h"
#include "oc_helpers.h"
TEST
(
OCEndpoints
,
StringToEndpoint
)
{
const
char
*
spu
[
4
]
=
{
"coaps://10.211.55.3:56789/a/light"
,
"coap://openconnectivity.org"
,
"coap://openconnectivity.org/alpha"
,
"coaps://openconnectivity.org:3456/alpha"
};
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
#ifdef OC_IPV4
const
char
*
spu0
[
1
]
=
{
"coaps://10.211.55.3:56789/a/light"
};
for
(
int
i
=
0
;
i
<
1
;
i
++
)
{
oc_string_t
s
;
oc_new_string
(
&
s
,
spu0
[
i
],
strlen
(
spu0
[
i
]));
oc_endpoint_t
ep
;
memset
(
&
ep
,
0
,
sizeof
(
oc_endpoint_t
));
oc_string_t
uri
;
memset
(
&
uri
,
0
,
sizeof
(
oc_string_t
));
int
ret
=
oc_string_to_endpoint
(
&
s
,
&
ep
,
&
uri
);
EXPECT_EQ
(
ret
,
0
)
<<
"spu0["
<<
i
<<
"] "
<<
spu0
[
i
];
switch
(
i
)
{
case
0
:
{
EXPECT_TRUE
(
ep
.
flags
&
IPV4
);
EXPECT_TRUE
(
ep
.
flags
&
SECURED
);
EXPECT_FALSE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
56789
);
EXPECT_STREQ
(
oc_string
(
uri
),
"/a/light"
);
uint8_t
addr
[
4
]
=
{
10
,
211
,
55
,
3
};
EXPECT_EQ
(
0
,
memcmp
(
ep
.
addr
.
ipv4
.
address
,
addr
,
4
));
}
break
;
default:
break
;
}
oc_free_string
(
&
s
);
oc_free_string
(
&
uri
);
}
#endif
/* OC_IPV4 */
const
char
*
spu1
[
3
]
=
{
"coap://openconnectivity.org"
,
"coap://openconnectivity.org/alpha"
,
"coaps://openconnectivity.org:3456/alpha"
};
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
oc_string_t
s
;
oc_new_string
(
&
s
,
spu
[
i
],
strlen
(
spu
[
i
]));
oc_new_string
(
&
s
,
spu
1
[
i
],
strlen
(
spu1
[
i
]));
oc_endpoint_t
ep
;
memset
(
&
ep
,
0
,
sizeof
(
oc_endpoint_t
));
oc_string_t
uri
;
memset
(
&
uri
,
0
,
sizeof
(
oc_string_t
));
int
ret
=
oc_string_to_endpoint
(
&
s
,
&
ep
,
&
uri
);
EXPECT_EQ
(
ret
,
0
)
<<
"spu
["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_EQ
(
ret
,
0
)
<<
"spu
1["
<<
i
<<
"] "
<<
spu1
[
i
];
switch
(
i
)
{
case
0
:
{
EXPECT_TRUE
(
ep
.
flags
&
IPV4
);
EXPECT_TRUE
(
ep
.
flags
&
SECURED
);
EXPECT_FALSE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
56789
);
EXPECT_STREQ
(
oc_string
(
uri
),
"/a/light"
);
uint8_t
addr
[
4
]
=
{
10
,
211
,
55
,
3
};
EXPECT_EQ
(
0
,
memcmp
(
ep
.
addr
.
ipv4
.
address
,
addr
,
4
));
}
break
;
case
1
:
case
0
:
ASSERT_TRUE
((
ep
.
flags
&
IPV4
)
||
(
ep
.
flags
&
IPV6
));
ASSERT_FALSE
(
ep
.
flags
&
SECURED
);
ASSERT_FALSE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
5683
);
EXPECT_EQ
(
oc_string_len
(
uri
),
0
);
break
;
case
2
:
case
1
:
ASSERT_TRUE
((
ep
.
flags
&
IPV4
)
||
(
ep
.
flags
&
IPV6
));
ASSERT_FALSE
(
ep
.
flags
&
SECURED
);
ASSERT_FALSE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
5683
);
EXPECT_STREQ
(
oc_string
(
uri
),
"/alpha"
);
break
;
case
3
:
case
2
:
ASSERT_TRUE
((
ep
.
flags
&
IPV4
)
||
(
ep
.
flags
&
IPV6
));
ASSERT_TRUE
(
ep
.
flags
&
SECURED
);
ASSERT_FALSE
(
ep
.
flags
&
TCP
);
...
...
@@ -75,50 +96,70 @@ TEST(OCEndpoints, StringToEndpoint)
}
#ifdef OC_TCP
const
char
*
spu2
[
6
]
=
{
"coaps+tcp://10.211.55.3/a/light"
,
"coap+tcp://1.2.3.4:2568"
,
"coaps+tcp://openconnectivity.org:3456"
,
#ifdef OC_IPV4
const
char
*
spu2
[
2
]
=
{
"coaps+tcp://10.211.55.3/a/light"
,
"coap+tcp://1.2.3.4:2568"
};
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
oc_string_t
s
;
oc_new_string
(
&
s
,
spu2
[
i
],
strlen
(
spu2
[
i
]));
oc_endpoint_t
ep
;
memset
(
&
ep
,
0
,
sizeof
(
oc_endpoint_t
));
oc_string_t
uri
;
memset
(
&
uri
,
0
,
sizeof
(
oc_string_t
));
int
ret
=
oc_string_to_endpoint
(
&
s
,
&
ep
,
&
uri
);
EXPECT_EQ
(
ret
,
0
)
<<
"spu2["
<<
i
<<
"] "
<<
spu2
[
i
];
switch
(
i
)
{
case
0
:
{
EXPECT_TRUE
(
ep
.
flags
&
IPV4
);
EXPECT_TRUE
(
ep
.
flags
&
SECURED
);
EXPECT_TRUE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
5684
);
EXPECT_STREQ
(
oc_string
(
uri
),
"/a/light"
);
uint8_t
addr
[
4
]
=
{
10
,
211
,
55
,
3
};
EXPECT_EQ
(
0
,
memcmp
(
ep
.
addr
.
ipv4
.
address
,
addr
,
4
));
}
break
;
case
1
:
{
EXPECT_TRUE
(
ep
.
flags
&
IPV4
);
EXPECT_FALSE
(
ep
.
flags
&
SECURED
);
EXPECT_TRUE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
2568
);
EXPECT_EQ
(
oc_string_len
(
uri
),
0
);
uint8_t
addr
[
4
]
=
{
1
,
2
,
3
,
4
};
EXPECT_EQ
(
0
,
memcmp
(
ep
.
addr
.
ipv4
.
address
,
addr
,
4
));
}
break
;
default:
break
;
}
oc_free_string
(
&
s
);
oc_free_string
(
&
uri
);
}
#endif
/* OC_IPV4 */
const
char
*
spu3
[
4
]
=
{
"coaps+tcp://openconnectivity.org:3456"
,
"coap+tcp://[ff02::158]"
,
"coaps+tcp://[ff02::158]/a/light"
,
"coaps+tcp://[fe80::12]:2439/a/light"
};
for
(
int
i
=
0
;
i
<
6
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
oc_string_t
s
;
oc_new_string
(
&
s
,
spu
2
[
i
],
strlen
(
spu2
[
i
]));
oc_new_string
(
&
s
,
spu
3
[
i
],
strlen
(
spu3
[
i
]));
oc_endpoint_t
ep
;
memset
(
&
ep
,
0
,
sizeof
(
oc_endpoint_t
));
oc_string_t
uri
;
memset
(
&
uri
,
0
,
sizeof
(
oc_string_t
));
int
ret
=
oc_string_to_endpoint
(
&
s
,
&
ep
,
&
uri
);
EXPECT_EQ
(
ret
,
0
)
<<
"spu
2["
<<
i
<<
"] "
<<
spu2
[
i
];
EXPECT_EQ
(
ret
,
0
)
<<
"spu
3["
<<
i
<<
"] "
<<
spu3
[
i
];
switch
(
i
)
{
case
0
:
{
EXPECT_TRUE
(
ep
.
flags
&
IPV4
);
EXPECT_TRUE
(
ep
.
flags
&
SECURED
);
EXPECT_TRUE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
5684
);
EXPECT_STREQ
(
oc_string
(
uri
),
"/a/light"
);
uint8_t
addr
[
4
]
=
{
10
,
211
,
55
,
3
};
EXPECT_EQ
(
0
,
memcmp
(
ep
.
addr
.
ipv4
.
address
,
addr
,
4
));
}
break
;
case
1
:
{
EXPECT_TRUE
(
ep
.
flags
&
IPV4
);
EXPECT_FALSE
(
ep
.
flags
&
SECURED
);
EXPECT_TRUE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
2568
);
EXPECT_EQ
(
oc_string_len
(
uri
),
0
);
uint8_t
addr
[
4
]
=
{
1
,
2
,
3
,
4
};
EXPECT_EQ
(
0
,
memcmp
(
ep
.
addr
.
ipv4
.
address
,
addr
,
4
));
}
break
;
case
2
:
case
0
:
ASSERT_TRUE
((
ep
.
flags
&
IPV4
)
||
(
ep
.
flags
&
IPV6
));
ASSERT_TRUE
(
ep
.
flags
&
SECURED
);
ASSERT_TRUE
(
ep
.
flags
&
TCP
);
EXPECT_EQ
(
ep
.
addr
.
ipv4
.
port
,
3456
);
EXPECT_EQ
(
oc_string_len
(
uri
),
0
);
break
;
case
3
:
{
case
1
:
{
ASSERT_TRUE
(
ep
.
flags
&
IPV6
);
ASSERT_FALSE
(
ep
.
flags
&
SECURED
);
ASSERT_TRUE
(
ep
.
flags
&
TCP
);
...
...
@@ -128,7 +169,7 @@ TEST(OCEndpoints, StringToEndpoint)
0
,
0
,
0
,
0
,
0
,
0
,
0x01
,
0x58
};
EXPECT_EQ
(
0
,
memcmp
(
ep
.
addr
.
ipv6
.
address
,
addr
,
16
));
}
break
;
case
4
:
{
case
2
:
{
ASSERT_TRUE
(
ep
.
flags
&
IPV6
);
ASSERT_TRUE
(
ep
.
flags
&
SECURED
);
ASSERT_TRUE
(
ep
.
flags
&
TCP
);
...
...
@@ -138,7 +179,7 @@ TEST(OCEndpoints, StringToEndpoint)
EXPECT_EQ
(
0
,
memcmp
(
ep
.
addr
.
ipv6
.
address
,
addr
,
16
));
EXPECT_STREQ
(
oc_string
(
uri
),
"/a/light"
);
}
break
;
case
5
:
{
case
3
:
{
ASSERT_TRUE
(
ep
.
flags
&
IPV6
);
ASSERT_TRUE
(
ep
.
flags
&
SECURED
);
ASSERT_TRUE
(
ep
.
flags
&
TCP
);
...
...
@@ -156,19 +197,141 @@ TEST(OCEndpoints, StringToEndpoint)
}
// test dns lookup when uri is NULL
const
char
*
spu
3
[
4
]
=
{
"coap://10.211.55.3:56789/a/light"
,
const
char
*
spu
4
[
4
]
=
{
"coap://10.211.55.3:56789/a/light"
,
"coaps+tcp://10.211.55.3/a/light"
,
"coap://openconnectivity.org/alpha"
,
"coaps://openconnectivity.org:3456/alpha"
};
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
oc_string_t
s
;
oc_new_string
(
&
s
,
spu
3
[
i
],
strlen
(
spu
[
i
]));
oc_new_string
(
&
s
,
spu
4
[
i
],
strlen
(
spu4
[
i
]));
oc_endpoint_t
ep
;
memset
(
&
ep
,
0
,
sizeof
(
oc_endpoint_t
));
int
ret
=
oc_string_to_endpoint
(
&
s
,
&
ep
,
NULL
);
EXPECT_EQ
(
ret
,
0
)
<<
"spu
3["
<<
i
<<
"] "
<<
spu3
[
i
];
EXPECT_EQ
(
ret
,
0
)
<<
"spu
4["
<<
i
<<
"] "
<<
spu4
[
i
];
}
#endif
}
TEST
(
OCEndpoints
,
EndpointStringParsePath
)
{
const
char
*
spu
[
12
]
=
{
"coaps://10.211.55.3:56789/a/light"
,
"coap://openconnectivity.org"
,
"coap://openconnectivity.org/alpha"
,
"coaps://openconnectivity.org:3456/alpha"
,
"coaps+tcp://10.211.55.3/a/light"
,
"coap+tcp://1.2.3.4:2568"
,
"coaps+tcp://openconnectivity.org:3456"
,
"coap+tcp://[ff02::158]"
,
"coaps+tcp://[ff02::158]/a/light"
,
"coaps+tcp://[fe80::12]:2439/a/light"
,
"coaps+tcp://[fe80::12]:2439/a/light?s=100"
,
"coap://0/foo"
};
for
(
int
i
=
0
;
i
<
12
;
i
++
)
{
oc_string_t
s
;
oc_string_t
path
;
int
ret
=
-
1
;
oc_new_string
(
&
s
,
spu
[
i
],
strlen
(
spu
[
i
]));
memset
(
&
path
,
0
,
sizeof
(
oc_string_t
));
switch
(
i
)
{
case
0
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
0
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_STREQ
(
oc_string
(
path
),
"/a/light"
);
break
;
case
1
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
-
1
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_EQ
(
path
.
ptr
,
NULL
);
break
;
case
2
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
0
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_STREQ
(
oc_string
(
path
),
"/alpha"
);
break
;
case
3
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
0
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_STREQ
(
oc_string
(
path
),
"/alpha"
);
break
;
case
4
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
0
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_STREQ
(
oc_string
(
path
),
"/a/light"
);
break
;
case
5
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
-
1
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_EQ
(
path
.
ptr
,
NULL
);
break
;
case
6
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
-
1
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_EQ
(
path
.
ptr
,
NULL
);
break
;
case
7
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
-
1
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_EQ
(
path
.
ptr
,
NULL
);
break
;
case
8
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
0
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_STREQ
(
oc_string
(
path
),
"/a/light"
);
break
;
case
9
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
0
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_STREQ
(
oc_string
(
path
),
"/a/light"
);
break
;
case
10
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
0
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_STREQ
(
oc_string
(
path
),
"/a/light"
);
break
;
case
11
:
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
0
,
ret
)
<<
"spu["
<<
i
<<
"] "
<<
spu
[
i
];
EXPECT_STREQ
(
oc_string
(
path
),
"/foo"
);
break
;
default:
break
;
}
}
// paths with expected errors
const
char
*
spu2
[
2
]
=
{
"coaps://"
,
// no address
"coaps:/10.211.55.3:56789/a/light"
// missing ://
};
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
oc_string_t
s
;
oc_new_string
(
&
s
,
spu2
[
i
],
strlen
(
spu2
[
i
]));
oc_string_t
path
;
memset
(
&
path
,
0
,
sizeof
(
oc_string_t
));
int
ret
=
oc_endpoint_string_parse_path
(
&
s
,
&
path
);
EXPECT_EQ
(
-
1
,
ret
)
<<
"spu2["
<<
i
<<
"] "
<<
spu2
[
i
];
oc_free_string
(
&
s
);
oc_free_string
(
&
path
);
}
{
oc_string_t
path
;
int
ret
=
oc_endpoint_string_parse_path
(
NULL
,
&
path
);
EXPECT_EQ
(
-
1
,
ret
);
if
(
-
1
!=
ret
)
{
// If code is working as expected this should never run.
oc_free_string
(
&
path
);
}
}
{
oc_string_t
s
;
oc_new_string
(
&
s
,
"coap://0/p"
,
strlen
(
"coap://0/p"
));
EXPECT_EQ
(
-
1
,
oc_endpoint_string_parse_path
(
&
s
,
NULL
));
oc_free_string
(
&
s
);
}
}
apps/client_block_linux.c
View file @
62c29f82
...
...
@@ -176,9 +176,9 @@ main(void)
oc_clock_time_t
next_event
;
#ifdef OC_S
ECURITY
#ifdef OC_S
TORAGE
oc_storage_config
(
"./client_block_linux_creds"
);
#endif
/* OC_S
ECURITY
*/
#endif
/* OC_S
TORAGE
*/
oc_set_mtu_size
(
300
);
oc_set_max_app_data_size
(
2048
);
...
...
apps/client_collections_linux.c
View file @
62c29f82
...
...
@@ -427,9 +427,9 @@ main(void)
oc_clock_time_t
next_event
;
#ifdef OC_S
ECURITY
#ifdef OC_S
TORAGE
oc_storage_config
(
"./client_collections_linux_creds"
);
#endif
/* OC_S
ECURITY
*/
#endif
/* OC_S
TORAGE
*/
init
=
oc_main_init
(
&
handler
);
if
(
init
<
0
)
...
...
apps/client_linux.c
View file @
62c29f82
...
...
@@ -163,9 +163,9 @@ main(void)
oc_clock_time_t
next_event
;
#ifdef OC_S
ECURITY
#ifdef OC_S
TORAGE
oc_storage_config
(
"./client_creds"
);
#endif
/* OC_S
ECURITY
*/
#endif
/* OC_S
TORAGE
*/
oc_set_con_res_announced
(
false
);
init
=
oc_main_init
(
&
handler
);
...
...
apps/client_multithread_linux.c
View file @
62c29f82
...
...
@@ -394,9 +394,9 @@ main(void)
.
signal_event_loop
=
signal_event_loop
};
#ifdef OC_S
ECURITY
#ifdef OC_S
TORAGE
oc_storage_config
(
"./client_multithread_linux_creds"
);
#endif
/* OC_S
ECURITY
*/
#endif
/* OC_S
TORAGE
*/
if
(
pthread_mutex_init
(
&
mutex
,
NULL
)
<
0
)
{
printf
(
"pthread_mutex_init failed!
\n
"
);
...
...
apps/cloud_certification_tests.c
View file @
62c29f82
...
...
@@ -565,7 +565,9 @@ ocf_event_thread(void *data)
.
register_resources
=
register_resources
};
#ifdef OC_STORAGE
oc_storage_config
(
"./cloud_tests_creds"
);
#endif
/* OC_STORAGE */
if
(
pthread_mutex_init
(
&
mutex
,
NULL
)
<
0
)
{
printf
(
"pthread_mutex_init failed!
\n
"
);
...
...
apps/cloud_server.c
View file @
62c29f82
...
...
@@ -296,7 +296,9 @@ main(void)
.
signal_event_loop
=
signal_event_loop
,
.
register_resources
=
register_resources
};
#ifdef OC_STORAGE
oc_storage_config
(
"./cloud_server_creds/"
);
#endif
/* OC_STORAGE */