Commit 95769f61 authored by Marek Szkowron's avatar Marek Szkowron

Merge remote-tracking branch 'origin/ipanema' into ipanema_fix_version

parents a04d01ce e0a7e7d3
Pipeline #1095 passed with stage
in 3 minutes and 28 seconds
......@@ -31,26 +31,13 @@ Android_build:
variables:
GIT_SUBMODULE_STRATEGY: normal
stage: build
image: openjdk:8-jdk
before_script:
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 make autoconf swig patch
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
- unzip -d android-sdk-linux android-sdk.zip
- echo y | android-sdk-linux/tools/bin/sdkmanager "ndk-bundle" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-28" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
- echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;28.0.2" >/dev/null
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
# temporarily disable checking for EPIPE error and use yes to accept all licenses
- set +o pipefail
- yes | android-sdk-linux/tools/bin/sdkmanager --licenses
- set -o pipefail
- ./android-sdk-linux/ndk-bundle/build/tools/make_standalone_toolchain.py --arch arm --api 23 --install-dir ~/android-arm-23
image: gitlab.iotivity.org:5050/iotivity/iotivity-lite
script:
- cd port/android
- make DYNAMIC=1 TCP=1 IPV4=1 SECURE=1 PKI=1 CLOUD=1 JAVA=1 DEBUG=0
retry:
max: 2
when: runner_system_failure
doxygen:
variables:
......@@ -62,3 +49,4 @@ doxygen:
- doxygen --version
- cd tools
- ./build_doc.sh
......@@ -992,7 +992,7 @@ oc_handle_collection_request(oc_method_t method, oc_request_t *request,
break;
}
}
request->response->content_format = APPLICATION_VND_OCF_CBOR;
request->response->response_buffer->content_format = APPLICATION_VND_OCF_CBOR;
request->response->response_buffer->response_length = (uint16_t)size;
request->response->response_buffer->code = code;
......
......@@ -511,7 +511,7 @@ oc_core_1_1_discovery_handler(oc_request_t *request,
}
int response_length = oc_rep_get_encoded_payload_size();
request->response->content_format = APPLICATION_CBOR;
request->response->response_buffer->content_format = APPLICATION_CBOR;
if (matches && response_length) {
request->response->response_buffer->response_length =
(uint16_t)response_length;
......@@ -706,7 +706,7 @@ oc_core_discovery_handler(oc_request_t *request, oc_interface_mask_t iface_mask,
break;
}
int response_length = oc_rep_get_encoded_payload_size();
request->response->content_format = APPLICATION_VND_OCF_CBOR;
request->response->response_buffer->content_format = APPLICATION_VND_OCF_CBOR;
if (matches && response_length > 0) {
request->response->response_buffer->response_length =
(uint16_t)response_length;
......
......@@ -78,7 +78,7 @@ oc_core_introspection_data_handler(oc_request_t *request,
IDD_size = oc_storage_read(
idd_tag, request->response->response_buffer->buffer, OC_MAX_APP_DATA_SIZE);
#endif /* OC_IDD_API */
request->response->content_format = APPLICATION_VND_OCF_CBOR;
request->response->response_buffer->content_format = APPLICATION_VND_OCF_CBOR;
if (IDD_size >= 0 && IDD_size < OC_MAX_APP_DATA_SIZE) {
request->response->response_buffer->response_length = (uint16_t)IDD_size;
request->response->response_buffer->code = oc_status_code(OC_STATUS_OK);
......
......@@ -275,6 +275,8 @@ stop_processes(void)
oc_resource_t *
oc_ri_get_app_resource_by_uri(const char *uri, size_t uri_len, size_t device)
{
if (!uri || uri_len == 0)
return NULL;
int skip = 0;
if (uri[0] != '/')
skip = 1;
......@@ -729,10 +731,10 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
*/
response_buffer.code = 0;
response_buffer.response_length = 0;
response_buffer.content_format = 0;
response_obj.separate_response = NULL;
response_obj.response_buffer = &response_buffer;
response_obj.content_format = 0;
request_obj.response = &response_obj;
request_obj.request_payload = NULL;
......@@ -747,7 +749,7 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
oc_interface_mask_t iface_query = 0, iface_mask = 0;
/* Obtain request uri from the CoAP packet. */
const char *uri_path;
const char *uri_path = NULL;
size_t uri_path_len = coap_get_header_uri_path(request, &uri_path);
/* Obtain query string from CoAP packet. */
......@@ -1172,8 +1174,9 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
coap_set_payload(response, response_buffer.buffer,
response_buffer.response_length);
#endif /* !OC_BLOCK_WISE */
if (response_obj.content_format > 0) {
coap_set_header_content_format(response, response_obj.content_format);
if (response_buffer.content_format > 0) {
coap_set_header_content_format(response,
response_buffer.content_format);
}
}
......
......@@ -75,11 +75,12 @@ oc_send_response(oc_request_t *request, oc_status_t response_code)
{
#ifdef OC_SPEC_VER_OIC
if (request->origin && request->origin->version == OIC_VER_1_1_0) {
request->response->content_format = APPLICATION_CBOR;
request->response->response_buffer->content_format = APPLICATION_CBOR;
} else
#endif /* OC_SPEC_VER_OIC */
{
request->response->content_format = APPLICATION_VND_OCF_CBOR;
request->response->response_buffer->content_format =
APPLICATION_VND_OCF_CBOR;
}
request->response->response_buffer->response_length =
(uint16_t)response_length();
......@@ -237,7 +238,7 @@ oc_send_response_raw(oc_request_t *request, const uint8_t *payload, size_t size,
oc_content_format_t content_format,
oc_status_t response_code)
{
request->response->content_format = content_format;
request->response->response_buffer->content_format = content_format;
memcpy(request->response->response_buffer->buffer, payload, size);
request->response->response_buffer->response_length = (uint16_t)size;
request->response->response_buffer->code = oc_status_code(response_code);
......@@ -410,8 +411,10 @@ oc_resource_set_request_handler(oc_resource_t *resource, oc_method_t method,
break;
}
handler->cb = callback;
handler->user_data = user_data;
if (handler) {
handler->cb = callback;
handler->user_data = user_data;
}
}
void
......@@ -464,26 +467,21 @@ oc_send_separate_response(oc_separate_response_t *handle,
response_buffer.buffer = handle->buffer;
response_buffer.response_length = (uint16_t)response_length();
response_buffer.code = oc_status_code(response_code);
response_buffer.content_format = APPLICATION_VND_OCF_CBOR;
coap_separate_t *cur = oc_list_head(handle->requests), *next = NULL;
coap_packet_t response[1];
while (cur != NULL) {
next = cur->next;
if (cur->observe > 0) {
if (cur->observe < 3) {
coap_transaction_t *t =
coap_new_transaction(coap_get_mid(), &cur->endpoint);
if (t) {
coap_separate_resume(response, cur,
(uint8_t)oc_status_code(response_code), t->mid);
#ifdef OC_SPEC_VER_OIC
if (cur->endpoint.version == OIC_VER_1_1_0) {
coap_set_header_content_format(response, APPLICATION_CBOR);
} else
#endif /* OC_SPEC_VER_OIC */
{
coap_set_header_content_format(response, APPLICATION_VND_OCF_CBOR);
}
coap_set_header_content_format(response,
response_buffer.content_format);
#ifdef OC_BLOCK_WISE
oc_blockwise_state_t *response_state = NULL;
......
......@@ -90,12 +90,25 @@ display_menu(void)
} \
} while (0)
static void set_device_custom_property(void *data)
{
(void)data;
oc_rep_set_array(root, dmn);
oc_rep_object_array_begin_item(dmn);
oc_rep_set_text_string(dmn, language, "en");
oc_rep_set_text_string(dmn, value, manufacturer);
oc_rep_object_array_end_item(dmn);
oc_rep_close_array(root, dmn);
}
static int
app_init(void)
{
int ret = oc_init_platform(manufacturer, NULL, NULL);
ret |= oc_add_device("/oic/d", device_rt, device_name, spec_version,
data_model_version, NULL, NULL);
data_model_version, set_device_custom_property, NULL);
if (ret || !deviceid) {
return ret;
}
......
......@@ -101,7 +101,6 @@ typedef struct oc_response_t
{
oc_separate_response_t *separate_response;
oc_response_buffer_t *response_buffer;
oc_content_format_t content_format;
} oc_response_t;
typedef enum {
......
......@@ -247,8 +247,9 @@ coap_receive(oc_message_t *msg)
#endif /* OC_TCP */
{
transaction = coap_get_transaction_by_mid(message->mid);
if (transaction)
if (transaction) {
coap_clear_transaction(transaction);
}
transaction = NULL;
}
......@@ -844,13 +845,13 @@ send_message:
}
}
#endif /* OC_CLIENT && OC_BLOCK_WISE */
transaction->message->length =
coap_serialize_message(response, transaction->message->data);
if (transaction->message->length > 0) {
coap_send_transaction(transaction);
} else {
coap_clear_transaction(transaction);
}
}
transaction->message->length =
coap_serialize_message(response, transaction->message->data);
if (transaction->message->length > 0) {
coap_send_transaction(transaction);
} else {
coap_clear_transaction(transaction);
}
}
......
......@@ -94,9 +94,7 @@ coap_remove_observer_handle_by_uri(oc_endpoint_t *endpoint, const char *uri,
(oc_string_len(obs->url) == (size_t)uri_len &&
memcmp(oc_string(obs->url), uri, uri_len) == 0) &&
obs->iface_mask == iface_mask) {
obs->resource->num_observers--;
oc_list_remove(observers_list, obs);
oc_memb_free(&observers_memb, obs);
coap_remove_observer(obs);
removed++;
break;
}
......@@ -730,10 +728,11 @@ coap_notify_observers(oc_resource_t *resource,
"notification");
#ifdef OC_BLOCK_WISE
if (coap_separate_accept(req, response.separate_response,
&obs->endpoint, 0, obs->block2_size) == 1)
&obs->endpoint, obs->obs_counter,
obs->block2_size) == 1)
#else /* OC_BLOCK_WISE */
if (coap_separate_accept(req, response.separate_response,
&obs->endpoint, 0) == 1)
&obs->endpoint, obs->obs_counter) == 1)
#endif /* !OC_BLOCK_WISE */
response.separate_response->active = 1;
} // separate response
......@@ -823,9 +822,9 @@ coap_notify_observers(oc_resource_t *resource,
} else {
coap_set_header_observe(notification, 1);
}
if (response.content_format > 0) {
if (response_buf->content_format > 0) {
coap_set_header_content_format(notification,
response.content_format);
response_buf->content_format);
}
coap_set_token(notification, obs->token, obs->token_len);
transaction = coap_new_transaction(coap_get_mid(), &obs->endpoint);
......
......@@ -19,10 +19,10 @@
#include "separate.h"
#include "util/oc_list.h"
#include "oc_ri.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
struct oc_separate_response_s
......@@ -42,6 +42,7 @@ struct oc_response_buffer_s
uint16_t buffer_size;
uint16_t response_length;
int code;
oc_content_format_t content_format;
};
#ifdef __cplusplus
......
......@@ -98,7 +98,8 @@ coap_separate_accept(void *request, oc_separate_response_t *separate_response,
separate_store != NULL; separate_store = separate_store->next) {
if (separate_store->token_len == coap_req->token_len &&
memcmp(separate_store->token, coap_req->token,
separate_store->token_len) == 0) {
separate_store->token_len) == 0 &&
separate_store->observe == observe) {
break;
}
}
......@@ -113,8 +114,6 @@ coap_separate_accept(void *request, oc_separate_response_t *separate_response,
oc_list_add(separate_response->requests, separate_store);
memcpy(&separate_store->endpoint, endpoint, sizeof(oc_endpoint_t));
/* store correct response type */
separate_store->type = COAP_TYPE_NON;
......@@ -131,6 +130,8 @@ coap_separate_accept(void *request, oc_separate_response_t *separate_response,
#endif /* OC_BLOCK_WISE */
}
memcpy(&separate_store->endpoint, endpoint, sizeof(oc_endpoint_t));
separate_store->observe = observe;
/* send separate ACK for CON */
......@@ -179,6 +180,9 @@ coap_separate_resume(void *response, coap_separate_t *separate_store,
if (separate_store->token_len) {
coap_set_token(response, separate_store->token, separate_store->token_len);
}
if (separate_store->observe == 0) {
coap_set_header_observe(response, 0);
}
}
/*---------------------------------------------------------------------------*/
void
......
......@@ -54,8 +54,7 @@
#include "transactions.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
typedef struct coap_separate
......
......@@ -645,9 +645,6 @@ process_interface_change_event(void)
}
if (if_state_changed) {
#ifdef OC_SECURITY
oc_close_all_tls_sessions();
#endif /* OC_SECURITY */
for (i = 0; i < num_devices; i++) {
ip_context_t *dev = get_ip_context_for_device(i);
oc_network_event_handler_mutex_lock();
......
......@@ -1046,6 +1046,8 @@ device1_RFPRO(int status, void *data)
if (!p->switch_dos) {
free_credprov_ctx(p, -1);
}
} else {
free_credprov_ctx(p, -1);
}
}
......
......@@ -108,8 +108,10 @@ oc_sec_decode_sdi(oc_rep_t *rep, bool from_storage, size_t device)
if (oc_string_len(s->name) > 0) {
oc_free_string(&s->name);
}
oc_new_string(&s->name, oc_string(rep->value.string),
oc_string_len(rep->value.string));
if (oc_string_len(rep->value.string) > 0) {
oc_new_string(&s->name, oc_string(rep->value.string),
oc_string_len(rep->value.string));
}
suc = true;
} else {
OC_ERR("oc_sdi: Unknown property %s", oc_string(rep->name));
......
......@@ -39,6 +39,7 @@
#include "api/oc_main.h"
#include "api/oc_session_events_internal.h"
#include "messaging/coap/observe.h"
#include "messaging/coap/engine.h"
#include "oc_acl_internal.h"
#include "oc_api.h"
#include "oc_buffer.h"
......@@ -262,6 +263,35 @@ is_peer_active(oc_tls_peer_t *peer)
static oc_event_callback_retval_t oc_tls_inactive(void *data);
#ifdef OC_CLIENT
static void
oc_tls_free_invalid_peer(oc_tls_peer_t *peer)
{
OC_DBG("\noc_tls: removing invalid peer");
oc_list_remove(tls_peers, peer);
oc_ri_remove_timed_event_callback(peer, oc_tls_inactive);
mbedtls_ssl_free(&peer->ssl_ctx);
oc_message_t *message = (oc_message_t *)oc_list_pop(peer->send_q);
while (message != NULL) {
oc_message_unref(message);
message = (oc_message_t *)oc_list_pop(peer->send_q);
}
message = (oc_message_t *)oc_list_pop(peer->recv_q);
while (message != NULL) {
oc_message_unref(message);
message = (oc_message_t *)oc_list_pop(peer->recv_q);
}
#ifdef OC_PKI
oc_free_string(&peer->public_key);
#endif /* OC_PKI */
mbedtls_ssl_config_free(&peer->ssl_conf);
oc_etimer_stop(&peer->timer.fin_timer);
oc_memb_free(&tls_peers_s, peer);
}
#endif /* OC_CLIENT */
static void
oc_tls_free_peer(oc_tls_peer_t *peer, bool inactivity_cb)
{
......@@ -534,10 +564,14 @@ oc_tls_audit_log(const char *aeid, const char *message, uint8_t category,
uint8_t priority, oc_tls_peer_t *peer)
{
char buff[IPADDR_BUFF_SIZE];
SNPRINTFipaddr(buff, IPADDR_BUFF_SIZE, peer->endpoint);
if (peer) {
SNPRINTFipaddr(buff, IPADDR_BUFF_SIZE, peer->endpoint);
} else {
buff[0] = '\0';
}
char *aux[] = { buff };
oc_audit_log(peer->endpoint.device, aeid, message, category, priority,
(const char **)aux, 1);
oc_audit_log((peer) ? peer->endpoint.device : 0, aeid, message, category,
priority, (const char **)aux, 1);
}
static int
......@@ -1649,8 +1683,23 @@ write_application_data(oc_tls_peer_t *peer)
static void
oc_tls_init_connection(oc_message_t *message)
{
oc_tls_peer_t *peer =
oc_tls_add_peer(&message->endpoint, MBEDTLS_SSL_IS_CLIENT);
oc_sec_pstat_t *pstat = oc_sec_get_pstat(message->endpoint.device);
if (pstat->s != OC_DOS_RFNOP) {
oc_message_unref(message);
return;
}
oc_tls_peer_t *peer = oc_tls_get_peer(&message->endpoint);
if (peer && peer->role != MBEDTLS_SSL_IS_CLIENT) {
oc_tls_free_invalid_peer(peer);
peer = NULL;
}
if (!peer) {
peer = oc_tls_add_peer(&message->endpoint, MBEDTLS_SSL_IS_CLIENT);
}
if (peer) {
oc_message_t *duplicate = oc_list_head(peer->send_q);
while (duplicate != NULL) {
......@@ -1833,7 +1882,10 @@ read_application_data(oc_tls_peer_t *peer)
}
message->length = ret;
message->encrypted = 0;
oc_recv_message(message);
if (oc_process_post(&coap_engine, oc_events[INBOUND_RI_EVENT], message) ==
OC_PROCESS_ERR_FULL) {
oc_message_unref(message);
}
OC_DBG("oc_tls: Decrypted incoming message");
}
}
......@@ -1855,6 +1907,8 @@ oc_tls_recv_message(oc_message_t *message)
oc_list_add(peer->recv_q, message);
peer->timestamp = oc_clock_time();
oc_tls_handler_schedule_read(peer);
} else {
oc_message_unref(message);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment