Commit 8edc9d03 authored by George Nash's avatar George Nash Committed by Kishen Maloor

Add tcpadapter to Android/update Makefile

This updates the Android makefile so it is able to build again.
Notable changes:
 - add x509x source files to DTLS code
 - changed default value for ANDROID_API from 19 to 23
 - added default values for DYNAMIC, SECURE, and PKI build options
 - updated starting CFLAGS value
   - -fPIE -pie changed to -fPIC
   - -fno-reorder-functions and -fno-defer-pop were removed
     due to warnings about them being unknown tags
 - add misc. security files to the build.

The tcpadapter code is a straight copy/paste of the tcpadapter.c/.h
from the Linux port. No modifications were made to tcpadapter.
Only changes made were:
 - added the adapter_receive_state_t to ipcontext.h needed by
   tcpadapter.

Most Makefile changes were obtained by referencing the Makefile
found in the `swig` branch.

Change-Id: Ifddcac31ad60a42c363206e397760a57466a551a
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
parent 28ae13db
......@@ -51,7 +51,7 @@
# or invoke like this: make NDK_HOME=/opt/android-ndk ANDROID_API=24
# Location of the installation directory and the API level.
ANDROID_API := 19
ANDROID_API := 23
ifeq (${NDK_HOME},)
ANDROID_BASE := "${HOME}/android-arm-${ANDROID_API}"
else
......@@ -70,11 +70,17 @@ endif
RM ?= rm
MKDIR ?= mkdir
DYNAMIC ?= 1
SECURE ?= 1
PKI ?= 1
ROOT_DIR = ../..
OBJDIR ?= ./${ANDROID_HOST}obj
MBEDTLS_DIR := $(ROOT_DIR)/deps/mbedtls
DTLS= aes.c aesni.c arc4.c asn1parse.c asn1write.c base64.c \
DTLS= \
aes.c aesni.c arc4.c asn1parse.c asn1write.c base64.c \
bignum.c blowfish.c camellia.c ccm.c cipher.c cipher_wrap.c \
cmac.c ctr_drbg.c des.c dhm.c ecdh.c ecdsa.c \
ecjpake.c ecp.c ecp_curves.c entropy.c entropy_poll.c error.c \
......@@ -85,7 +91,9 @@ DTLS= aes.c aesni.c arc4.c asn1parse.c asn1write.c base64.c \
sha512.c threading.c timing.c version.c version_features.c \
xtea.c pkcs11.c x509.c x509_crt.c debug.c net_sockets.c \
ssl_cache.c ssl_ciphersuites.c ssl_cli.c ssl_cookie.c \
ssl_srv.c ssl_ticket.c ssl_tls.c rsa_internal.c
ssl_srv.c ssl_ticket.c ssl_tls.c rsa_internal.c \
x509write_csr.c x509write_crt.c x509_create.c
DTLSFLAGS=-I../../deps/mbedtls/include -D__OC_RANDOM
CBOR=../../deps/tinycbor/src/cborencoder.c ../../deps/tinycbor/src/cborencoder_close_container_checked.c ../../deps/tinycbor/src/cborparser.c# ../../deps/tinycbor/src/cbortojson.c ../../deps/tinycbor/src/cborpretty.c ../../deps/tinycbor/src/cborparser_dup_string.c
......@@ -109,13 +117,13 @@ HEADERS_UTIL_PT = $(wildcard ../../util/pt/*.h)
HEADERS_PORT = $(wildcard ../../port/*.h)
HEADERS_TINYCBOR = $(wildcard ../../deps/tinycbor/src/*.h)
CFLAGS?=-fPIE -pie -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I./ -I../../include/ -I../../ -std=gnu99 -Wall -D__ANDROID_API__=${ANDROID_API}
CFLAGS?=-fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-strict-overflow -I./ -I../../include/ -I../../ -std=gnu99 -Wall -DLONG_BIT=64 -D__ANDROID_API__=${ANDROID_API}
OBJ_COMMON=$(addprefix ${OBJDIR}/,$(notdir $(SRC_COMMON:.c=.o)))
OBJ_CLIENT=$(addprefix ${OBJDIR}/client/,$(notdir $(SRC:.c=.o)))
OBJ_SERVER=$(addprefix ${OBJDIR}/server/,$(filter-out oc_obt.o,$(notdir $(SRC:.c=.o))))
OBJ_SERVER=$(addprefix ${OBJDIR}/server/,$(filter-out oc_obt.o oc_obt_otm_justworks.o oc_obt_otm_randompin.o,$(notdir $(SRC:.c=.o))))
OBJ_CLIENT_SERVER=$(addprefix ${OBJDIR}/client_server/,$(notdir $(SRC:.c=.o)))
VPATH=../../messaging/coap/:../../util/:../../api/:../../deps/tinycbor/src/:../../deps/mbedtls/library:../../api/c-timestamp:
LIBS?= -lm
LIBS?= -lm -llog
SAMPLES := server client temp_sensor simpleserver simpleclient client_collections_linux \
server_collections_linux server_block_linux client_block_linux smart_home_server_linux multi_device_server multi_device_client \
......@@ -129,16 +137,24 @@ else
CFLAGS += -Wl,--gc-sections
endif
ifeq ($(PKI),1)
CFLAGS += -DOC_PKI
endif
ifeq ($(DYNAMIC),1)
CFLAGS += -DOC_DYNAMIC_ALLOCATION
endif
ifneq ($(SECURE),0)
SRC += $(addprefix ../../security/,oc_acl.c oc_cred.c oc_doxm.c oc_pstat.c oc_tls.c oc_svr.c oc_store.c)
SRC += $(addprefix ../../security/,oc_acl.c oc_cred.c oc_doxm.c oc_pstat.c \
oc_tls.c oc_svr.c oc_store.c oc_pki.c oc_certs.c oc_sp.c oc_keypair.c \
oc_csr.c oc_roles.c)
SRC_COMMON += $(addprefix $(MBEDTLS_DIR)/library/,${DTLS})
MBEDTLS_PATCH_FILE := $(MBEDTLS_DIR)/patched.txt
ifeq ($(DYNAMIC),1)
SRC += ../../security/oc_obt.c
SRC += ../../security/oc_obt.c \
../../security/oc_obt_otm_justworks.c \
../../security/oc_obt_otm_randompin.c
SAMPLES += ${OBT}
else
SRC_COMMON += $(MBEDTLS_DIR)/library/memory_buffer_alloc.c
......
......@@ -925,10 +925,9 @@ network_event_thread(void *data)
#endif /* OC_SECURITY */
#ifdef OC_TCP
tcp_receive_state_t tcp_status = oc_tcp_receive_message(dev,
&setfds,
message);
if (tcp_status == TCP_STATUS_RECEIVE) {
adapter_receive_state_t tcp_status =
oc_tcp_receive_message(dev, &setfds, message);
if (tcp_status == ADAPTER_STATUS_RECEIVE) {
goto common;
} else {
oc_message_unref(message);
......
......@@ -30,6 +30,13 @@ extern "C"
{
#endif
typedef enum {
ADAPTER_STATUS_NONE = 0, /* Nothing happens */
ADAPTER_STATUS_ACCEPT, /* Receiving no meaningful data */
ADAPTER_STATUS_RECEIVE, /* Receiving meaningful data */
ADAPTER_STATUS_ERROR /* Error */
} adapter_receive_state_t;
#ifdef OC_TCP
typedef struct tcp_context_t {
struct sockaddr_storage server;
......
This diff is collapsed.
/****************************************************************************
*
* Copyright 2018 Samsung Electronics All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************/
#ifndef TCP_ADAPTER_H
#define TCP_ADAPTER_H
#include "ipcontext.h"
#include "port/oc_connectivity.h"
#include <sys/select.h>
#ifdef __cplusplus
extern "C"
{
#endif
int oc_tcp_connectivity_init(ip_context_t *dev);
void oc_tcp_connectivity_shutdown(ip_context_t *dev);
int oc_tcp_send_buffer(ip_context_t *dev, oc_message_t *message,
const struct sockaddr_storage *receiver);
void oc_tcp_add_socks_to_fd_set(ip_context_t *dev);
void oc_tcp_set_session_fds(fd_set *fds);
adapter_receive_state_t oc_tcp_receive_message(ip_context_t *dev, fd_set *fds,
oc_message_t *message);
void oc_tcp_end_session(ip_context_t *dev, oc_endpoint_t *endpoint);
#ifdef __cplusplus
}
#endif
#endif /* TCP_ADAPTER_H */
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