Commit dd5280a2 authored by Kishen Maloor's avatar Kishen Maloor

Removing incomplete and unused ports

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
parent aa0fad2b
Pipeline #111 passed with stage
in 50 seconds
#Set CONTIKI appropriately below to point to the root of your Contiki source.
CONTIKI = ${HOME}/contiki
ifeq ($(CLIENT),1)
CONTIKI_PROJECT = client_contiki
else
CONTIKI_PROJECT = server_contiki
SERVER=1
endif
all: $(CONTIKI_PROJECT)
PROJECTDIRS += ./ ../../include ../../ ../../api ../../messaging/coap ../../apps ../../deps/tinycbor/src ../../util
PROJECT_SOURCEFILES += oc_buffer.c oc_discovery.c oc_main.c oc_ri.c oc_client_api.c oc_network_events.c oc_server_api.c oc_core_res.c oc_helpers.c oc_rep.c oc_uuid.c cborencoder.c cborencoder_close_container_checked.c cborparser.c oc_etimer.c oc_memb.c oc_process.c oc_list.c oc_mmem.c oc_timer.c coap.c separate.c engine.c transactions.c observe.c ipadapter.c oc_clock.c oc_random.c abort.c storage.c oc_blockwise.c oc_base64.c oc_endpoint.c oc_introspection.c
CONTIKI_WITH_RPL = 1
CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include
CFLAGS += -std=gnu99 -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 -Wl,--gc-sections
ifeq ($(CLIENT),1)
CFLAGS += -DOC_CLIENT
endif
ifeq ($(SERVER),1)
CFLAGS += -DOC_SERVER
endif
ifeq ($(DEBUG),1)
CFLAGS += -DOC_DEBUG -g
endif
1) Set CONTIKI path in the Makefile.
2) Perform the build:
make SERVER=1 <additional options you normally pass; eg. TARGET=...)
This selects the apps/server_contiki sample.
Specify CLIENT=1 instead to select the apps/client_contiki sample.
Add DEBUG=1 to include debug output from IoTivity-Lite.
#include "port/oc_assert.h"
// TODO:
void abort_impl() {}
/*
// Copyright (c) 2016 Intel Corporation
//
// 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.
*/
#include "contiki.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "net/rpl/rpl.h"
#include "oc_buffer.h"
#include "oc_endpoint.h"
#include "port/oc_connectivity.h"
#include "simple-udp.h"
#define OCF_MCAST_PORT_UNSECURED (5683)
#define OCF_SERVER_PORT_UNSECURED (56789)
static struct simple_udp_connection server, mcast;
PROCESS(ip_adapter_process, "IP Adapter");
static uip_ipaddr_t ipaddr, mcastaddr;
static oc_endpoint_t *eps;
static void
free_endpoints(void)
{
oc_endpoint_t *ep = eps, *next;
while (ep != NULL) {
next = ep->next;
oc_free_endpoint(ep);
ep = next;
}
}
void
handle_incoming_message(uint8_t *buffer, int size, uint8_t *addr, uint16_t port)
{
oc_message_t *message = oc_allocate_message();
if (message) {
size_t bytes_read = size;
bytes_read = (bytes_read < OC_PDU_SIZE) ? bytes_read : OC_PDU_SIZE;
memcpy(message->data, buffer, bytes_read);
message->length = bytes_read;
message->endpoint.flags = IPV6;
memcpy(message->endpoint.addr.ipv6.address, addr, 16);
message->endpoint.addr.ipv6.port = port;
#ifdef OC_DEBUG
PRINT("Incoming message from ");
PRINTipaddr(message->endpoint);
PRINT("\n\n");
#endif /* OC_DEBUG */
oc_network_event(message);
return;
}
OC_WRN("ipadapter: No free RX/TX buffers to handle incoming message");
}
static void
receive(struct simple_udp_connection *c, const uip_ipaddr_t *sender_addr,
uint16_t sender_port, const uip_ipaddr_t *receiver_addr,
uint16_t receiver_port, const uint8_t *data, uint16_t datalen)
{
OC_DBG(
"ipadapter: Incoming message from network...dispatch for processing");
handle_incoming_message((uint8_t *)data, datalen, (uint8_t *)sender_addr,
sender_port);
}
oc_endpoint_t *
oc_connectivity_get_endpoints(size_t device)
{
(void)device;
if (!eps) {
oc_endpoint_t *ep = oc_new_endpoint();
if (!ep) {
return NULL;
}
memset(ep, 0, sizeof(oc_endpoint_t));
ep->flags = IPV6;
memcpy(ep->addr.ipv6.address, ipaddr.u8, 16);
ep->addr.ipv6.port = OCF_SERVER_PORT_UNSECURED;
ep->device = 0;
eps = ep;
}
return eps;
}
static uip_ipaddr_t *
set_global_address(void)
{
uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
/*
* Joining the OCF multicast group at ff0x::158
*/
uip_ip6addr(&mcastaddr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0158);
uip_ds6_maddr_t *rv = uip_ds6_maddr_add(&mcastaddr);
if (rv)
OC_DBG("Joined OCF multicast group");
else
OC_WRN("Failed to join OCF multicast group");
return &ipaddr;
}
static void
create_rpl_dag(uip_ipaddr_t *ipaddr)
{
struct uip_ds6_addr *root_if;
root_if = uip_ds6_addr_lookup(ipaddr);
if (root_if != NULL) {
rpl_dag_t *dag;
uip_ipaddr_t prefix;
rpl_set_root(RPL_DEFAULT_INSTANCE, ipaddr);
dag = rpl_get_any_dag();
uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0);
rpl_set_prefix(dag, &prefix, 64);
OC_DBG("Created new RPL DAG");
} else {
OC_WRN("Failed to create new RPL DAG");
}
}
PROCESS_THREAD(ip_adapter_process, ev, data)
{
static uip_ipaddr_t *ipaddr;
PROCESS_BEGIN();
ipaddr = set_global_address();
create_rpl_dag(ipaddr);
simple_udp_register(&mcast, OCF_MCAST_PORT_UNSECURED, NULL, 0, receive);
simple_udp_register(&server, OCF_SERVER_PORT_UNSECURED, NULL, 0, receive);
OC_DBG("ipadapter: Initialized ip_adapter_process");
while (ev != PROCESS_EVENT_EXIT) {
PROCESS_WAIT_EVENT();
}
PROCESS_END();
}
int
oc_send_buffer(oc_message_t *message)
{
#ifdef OC_DEBUG
PRINT("Outgoing message to ");
PRINTipaddr(message->endpoint);
PRINT("\n\n");
#endif /* OC_DEBUG */
simple_udp_sendto_port(
&server, message->data, message->length,
(const uip_ipaddr_t *)message->endpoint.addr.ipv6.address,
message->endpoint.addr.ipv6.port);
return message->length;
}
int
oc_connectivity_init(size_t device)
{
(void)device;
process_start(&ip_adapter_process, NULL);
return 0;
}
void
oc_connectivity_shutdown(size_t device)
{
(void)device;
free_endpoints();
process_exit(&ip_adapter_process);
}
#ifdef OC_CLIENT
void
oc_send_discovery_request(oc_message_t *message)
{
oc_send_buffer(message);
}
#endif /* OC_CLIENT */
/*
* oc_network_event_handler_mutex_* are defined only to comply with the
* connectivity interface, but are not used since the adapter process does
* not preempt the process running the event loop.
*/
void
oc_network_event_handler_mutex_init(void)
{
}
void
oc_network_event_handler_mutex_lock(void)
{
}
void oc_network_event_handler_mutex_unlock(void) {}
void oc_network_event_handler_mutex_destroy(void) {}
/*
// Copyright (c) 2016 Intel Corporation
//
// 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.
*/
#include "port/oc_clock.h"
#include "clock.h"
void
oc_clock_init(void)
{
}
oc_clock_time_t
oc_clock_time(void)
{
return clock_time();
}
unsigned long
oc_clock_seconds(void)
{
return clock_seconds();
}
void
oc_clock_wait(oc_clock_time_t t)
{
clock_delay(t);
}
/*
// Copyright (c) 2016 Intel Corporation
//
// 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 OC_CONFIG_H
#define OC_CONFIG_H
#include <contiki-conf.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Time resolution */
#include <stdint.h>
typedef uint64_t oc_clock_time_t;
#define OC_CLOCK_CONF_TICKS_PER_SECOND CLOCK_CONF_SECOND
#define OC_BYTES_POOL_SIZE (900)
#define OC_INTS_POOL_SIZE (4)
#define OC_DOUBLES_POOL_SIZE (4)
/* Server-side parameters */
/* Maximum number of server resources */
#define OC_MAX_APP_RESOURCES (1)
/* Common paramters */
/* Maximum size of request/response PDUs */
#define OC_MAX_APP_DATA_SIZE (600)
/* Maximum number of concurrent requests */
#define OC_MAX_NUM_CONCURRENT_REQUESTS (2)
/* Maximum number of nodes in a payload tree structure */
#define OC_MAX_NUM_REP_OBJECTS (70)
/* Number of devices on the OCF platform */
#define OC_MAX_NUM_DEVICES (1)
#define OC_MAX_NUM_ENDPOINTS (4)
/* Security layer */
/* Maximum number of authorized clients */
#define OC_MAX_NUM_SUBJECTS (1)
/* Maximum number of concurrent DTLS sessions */
#define OC_MAX_DTLS_PEERS (1)
/* Max inactivity timeout before tearing down DTLS connection */
#define OC_DTLS_INACTIVITY_TIMEOUT (10)
#ifdef __cplusplus
}
#endif
#endif /* OC_CONFIG_H */
/*
// Copyright (c) 2016 Intel Corporation
//
// 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.
*/
#include "port/oc_random.h"
#include "random.h"
// FIXME: Employ an appropriate seeding strategy here for the PRNG.
void
oc_random_init(void)
{
random_init(0);
}
unsigned int
oc_random_value(void)
{
return random_rand();
}
void
oc_random_destroy(void)
{
}
/*
// Copyright (c) 2016 Intel Corporation
//
// 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.
*/
#ifdef OC_SECURITY
#include "port/oc_storage.h"
#include <errno.h>
#include <stdbool.h>
#include <string.h>
#include <cfs/cfs.h>
#define STORE_PATH_SIZE 64
static char store_path[STORE_PATH_SIZE];
static int store_path_len;
static bool path_set = false;
int
oc_storage_config(const char *store)
{
store_path_len = strlen(store);
if (store_path_len >= STORE_PATH_SIZE)
return -ENOENT;
strncpy(store_path, store, store_path_len);
path_set = true;
return 0;
}
long
oc_storage_read(const char *store, uint8_t *buf, size_t size)
{
int fd;
size_t store_len = strlen(store);
if (!path_set || (store_len + store_path_len >= STORE_PATH_SIZE))
return -ENOENT;
strncpy(store_path + store_path_len, store, store_len);
store_path[store_path_len + store_len] = '\0';
fd = cfs_open(store_path, CFS_READ);
if (!fd)
return -EINVAL;
size = cfs_read(fd, buf, size);
cfs_close(fd);
return size;
}
long
oc_storage_write(const char *store, uint8_t *buf, size_t size)
{
int fd;
size_t store_len = strlen(store);
if (!path_set || (store_len + store_path_len >= STORE_PATH_SIZE))
return -ENOENT;
strncpy(store_path + store_path_len, store, store_len);
store_path[store_path_len + store_len] = '\0';
fd = cfs_open(store_path, CFS_WRITE);
if (!fd)
return -EINVAL;
size = cfs_write(fd, buf, size);
cfs_close(fd);
return size;
}
#endif /* OC_SECURITY */
#!/usr/bin/make -f
# -*- makefile -*-
# ex: set tabstop=4 noexpandtab:
#{
# Copyright 2018 Samsung Electronics France SAS
#
# 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.
#}
port?=$(shell basename -- "${CURDIR}")
DESTDIR ?=
extradir?=${DESTDIR}/${libdir}/iotivity-constrained/
prefix ?= /usr
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
libdir ?= $(exec_prefix)/lib
includedir ?= $(prefix)/include
pkgconfigdir ?= $(libdir)/pkgconfig
topdir?=../..
portdir?=${topdir}/port/${port}
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 \
gcm.c havege.c hmac_drbg.c md.c md2.c md4.c \
md5.c md_wrap.c oid.c padlock.c \
pem.c pk.c pk_wrap.c pkcs12.c pkcs5.c pkparse.c \
pkwrite.c platform.c ripemd160.c rsa.c sha1.c sha256.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
DTLSFLAGS=-I${topdir}/deps/mbedtls/include -D__OC_RANDOM
CBOR=${topdir}/deps/tinycbor/src/cborencoder.c ${topdir}/deps/tinycbor/src/cborencoder_close_container_checked.c ${topdir}/deps/tinycbor/src/cborparser.c
MBEDTLS_DIR := ${topdir}/deps/mbedtls
SRC_COMMON=$(wildcard ${topdir}/util/*.c) ${CBOR}
SRC=$(wildcard ${topdir}/messaging/coap/*.c ${topdir}/api/*.c ${portdir}/*.c)
HEADERS = $(wildcard ${topdir}/include/*.h)
HEADERS += ${portdir}/oc_config.h
HEADERS_COAP = $(wildcard ${topdir}/messaging/coap/*.h)
HEADERS_UTIL = $(wildcard ${topdir}/util/*.h)
HEADERS_UTIL_PT = $(wildcard ${topdir}/util/pt/*.h)
HEADERS_PORT = $(wildcard ${topdir}/port/*.h)
HEADERS_TINYCBOR = $(wildcard ${topdir}/deps/tinycbor/*.h)
CFLAGS=-fPIC -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 -std=gnu99
topdir?=${topdir}/
OBJ_COMMON=$(addprefix obj/,$(notdir $(SRC_COMMON:.c=.o)))
OBJ_CLIENT=$(addprefix obj/client/,$(notdir $(SRC:.c=.o)))
OBJ_SERVER=$(addprefix obj/server/,$(filter-out oc_obt.o,$(notdir $(SRC:.c=.o))))
OBJ_CLIENT_SERVER=$(addprefix obj/client_server/,$(notdir $(SRC:.c=.o)))
VPATH=${topdir}/messaging/coap/:${topdir}/util/:${topdir}/api/:${topdir}/deps/tinycbor/src/:${topdir}/deps/mbedtls/library:
LIBS?=
SAMPLES?=
ifeq ($(DEBUG),1)
CFLAGS += -DOC_DEBUG -g -O0
else
CFLAGS += -Wl,--gc-sections
endif
ifeq ($(DYNAMIC),1)
CFLAGS += -DOC_DYNAMIC_ALLOCATION
endif
ifeq ($(SECURE),1)
SRC += oc_acl.c oc_cred.c oc_doxm.c oc_pstat.c oc_dtls.c oc_svr.c oc_store.c
MBEDTLS_PATCH_FILE := $(MBEDTLS_DIR)/patched.txt
ifeq ($(DYNAMIC),1)
SRC_COMMON += ${DTLS}
SRC += oc_obt.c
else
SRC_COMMON += ${DTLS} memory_buffer_alloc.c
endif
CFLAGS += ${DTLSFLAGS} -DOC_SECURITY
VPATH += ${topdir}/security/:${topdir}/deps/mbedtls/library:
endif
CFLAGS+=-I${topdir}/include/ -I${topdir}
CFLAGS+=-I.
ifeq ($(IPV4),1)
CFLAGS += -DOC_IPV4
endif
ifeq ($(TCP),1)
CFLAGS += -DOC_TCP
endif
SAMPLES_CREDS = $(addsuffix _creds, ${SAMPLES}
CONSTRAINED_LIBS = libiotivity-constrained-server.a libiotivity-constrained-client.a \
libiotivity-constrained-client-server.a
all: $(MBEDTLS_PATCH_FILE) $(CONSTRAINED_LIBS) $(SAMPLES)
.PHONY: clean
obj/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS}
obj/server/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_SERVER
obj/client/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT
obj/client_server/%.o: %.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -DOC_CLIENT -DOC_SERVER
libiotivity-constrained-server.a: $(OBJ_COMMON) $(OBJ_SERVER)
$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_SERVER)
libiotivity-constrained-client.a: $(OBJ_COMMON) $(OBJ_CLIENT)
$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLIENT)
libiotivity-constrained-client-server.a: $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
$(AR) -rcs $@ $(OBJ_COMMON) $(OBJ_CLIENT_SERVER)
ifeq ($(SECURE),1)