Commit 75c52365 authored by George Nash's avatar George Nash

Merge remote branch 'origin/master' into swig

Due to changes in include paths of oc_obt.h and oc_pki.h
some of the SWIG interface files have been modified to
handle those changes for this merge

- oc_acl.i is no longer needed an has been deleted
- oc_acl.i has been removed from build_swig.sh script
  the line of code has already been commented out.
- no longer need to include oc_acl.i in oc_obt.i
- handle OCSecurityAce, OCAceResource, OCAceConnectionType,
  OCAceWildcard, and oc_acepermissions_t in oc_obt.i
- No longer need to declare oc_sp_types_t in oc_pki.i

Change-Id: I0ffa44f582aafb6667e07bca097d7963552bfbc2
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
parents 5b660fd0 197f479e
......@@ -18,6 +18,8 @@
#include "c-timestamp/timestamp.h"
#include "port/oc_log.h"
#define OC_NSEC_PER_SEC 1000000000
size_t
oc_clock_time_rfc3339(char *out_buf, size_t out_buf_len)
{
......@@ -31,7 +33,7 @@ oc_clock_encode_time_rfc3339(oc_clock_time_t time, char *out_buf,
timestamp_t now_t = { 0 };
now_t.sec = (int64_t)(time / OC_CLOCK_SECOND);
now_t.nsec = (int32_t)((time % OC_CLOCK_SECOND) * (1.e09 / OC_CLOCK_SECOND));
now_t.nsec = (int32_t)((time % OC_CLOCK_SECOND) * (OC_NSEC_PER_SEC / OC_CLOCK_SECOND));
return timestamp_format(out_buf, out_buf_len, &now_t);
}
......@@ -49,7 +51,7 @@ oc_clock_parse_time_rfc3339(const char *in_buf, size_t in_buf_len)
}
oc_clock_time_t t =
((in_time.sec * 1.e09) + in_time.nsec) * OC_CLOCK_SECOND / 1.e09;
((in_time.sec * OC_NSEC_PER_SEC) + in_time.nsec) * OC_CLOCK_SECOND / OC_NSEC_PER_SEC;
return t;
}
......@@ -21,13 +21,36 @@
#include "oc_api.h"
#include "oc_uuid.h"
#include "security/oc_acl.h"
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct oc_ace_res_s oc_ace_res_t;
typedef struct oc_sec_ace_s oc_sec_ace_t;
typedef enum {
OC_CONN_AUTH_CRYPT = 0,
OC_CONN_ANON_CLEAR
} oc_ace_connection_type_t;
typedef enum {
OC_ACE_NO_WC = -1,
OC_ACE_WC_ALL = 0x111,
OC_ACE_WC_ALL_SECURED = 0x01,
OC_ACE_WC_ALL_PUBLIC = 0x10,
} oc_ace_wildcard_t;
typedef enum {
OC_PERM_NONE = 0,
OC_PERM_CREATE = (1 << 0),
OC_PERM_RETRIEVE = (1 << 1),
OC_PERM_UPDATE = (1 << 2),
OC_PERM_DELETE = (1 << 3),
OC_PERM_NOTIFY = (1 << 4)
} oc_ace_permissions_t;
typedef void (*oc_obt_discovery_cb_t)(oc_uuid_t *, oc_endpoint_t *, void *);
typedef void (*oc_obt_device_status_cb_t)(oc_uuid_t *, int, void *);
typedef void (*oc_obt_status_cb_t)(int, void *);
......
......@@ -17,12 +17,17 @@
#ifndef OC_PKI_H
#define OC_PKI_H
#include "security/oc_sp.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
OC_SP_BASELINE = 1 << 1,
OC_SP_BLACK = 1 << 2,
OC_SP_BLUE = 1 << 3,
OC_SP_PURPLE = 1 << 4
} oc_sp_types_t;
int oc_pki_add_mfg_cert(size_t device, const unsigned char *cert,
size_t cert_size, const unsigned char *key,
size_t key_size);
......
......@@ -415,7 +415,7 @@ otm_just_works_cb(oc_uuid_t *uuid, int status, void *data)
if (status >= 0) {
PRINT("\nSuccessfully performed OTM on device %s\n", di);
add_device_to_list(uuid, unowned_devices);
add_device_to_list(uuid, owned_devices);
} else {
PRINT("\nERROR performing ownership transfer on device %s\n", di);
}
......
......@@ -20,24 +20,32 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static LARGE_INTEGER frequency = { 0 };
void
oc_clock_init(void)
{
QueryPerformanceFrequency(&frequency);
}
oc_clock_time_t
oc_clock_time(void)
{
LARGE_INTEGER count = { 0 };
if (frequency.QuadPart && QueryPerformanceCounter(&count)) {
oc_clock_time_t t =
1000 * count.QuadPart / frequency.QuadPart; // milliseconds
return t;
}
// fall back if no QueryPerformanceCounter available
return GetTickCount64();
oc_clock_time_t time = 0;
// This magic number is the number of 100 nanosecond intervals since January
// 1, 1601 (UTC)
// until 00:00:00 January 1, 1970
static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL);
SYSTEMTIME system_time;
FILETIME file_time;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
time = ((uint64_t)file_time.dwLowDateTime);
time += ((uint64_t)file_time.dwHighDateTime) << 32;
time = (oc_clock_time_t)((time - EPOCH) / 10000L);
return time;
}
unsigned long
......
......@@ -211,7 +211,9 @@
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\..\api\c-timestamp\timestamp.h" />
<ClInclude Include="..\..\..\api\oc_events.h" />
<ClInclude Include="..\..\..\api\oc_main.h" />
<ClInclude Include="..\..\..\deps\tinycbor\src\cbor.h" />
<ClInclude Include="..\..\..\deps\tinycbor\src\cborjson.h" />
<ClInclude Include="..\..\..\include\oc_api.h" />
......@@ -279,10 +281,16 @@
<ClInclude Include="..\oc_config.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_compare.c" />
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_format.c" />
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_parse.c" />
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_tm.c" />
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_valid.c" />
<ClCompile Include="..\..\..\api\oc_base64.c" />
<ClCompile Include="..\..\..\api\oc_blockwise.c" />
<ClCompile Include="..\..\..\api\oc_buffer.c" />
<ClCompile Include="..\..\..\api\oc_client_api.c" />
<ClCompile Include="..\..\..\api\oc_clock.c" />
<ClCompile Include="..\..\..\api\oc_collection.c" />
<ClCompile Include="..\..\..\api\oc_core_res.c" />
<ClCompile Include="..\..\..\api\oc_discovery.c" />
......
......@@ -364,6 +364,24 @@
<ClCompile Include="..\..\..\security\oc_obt_otm_randompin.c">
<Filter>Security</Filter>
</ClCompile>
<ClCompile Include="..\..\..\api\oc_clock.c">
<Filter>Core</Filter>
</ClCompile>
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_compare.c">
<Filter>Core\c-timestamp</Filter>
</ClCompile>
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_format.c">
<Filter>Core\c-timestamp</Filter>
</ClCompile>
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_parse.c">
<Filter>Core\c-timestamp</Filter>
</ClCompile>
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_tm.c">
<Filter>Core\c-timestamp</Filter>
</ClCompile>
<ClCompile Include="..\..\..\api\c-timestamp\timestamp_valid.c">
<Filter>Core\c-timestamp</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\deps\tinycbor\src\cbor.h">
......@@ -555,6 +573,9 @@
<ClInclude Include="..\..\..\security\oc_csr.h">
<Filter>Security</Filter>
</ClInclude>
<ClInclude Include="..\..\..\api\oc_main.h">
<Filter>Core</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\oc_clock_util.h">
<Filter>Headers</Filter>
</ClInclude>
......@@ -564,6 +585,9 @@
<ClInclude Include="..\..\..\include\oc_signal_event_loop.h">
<Filter>Headers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\api\c-timestamp\timestamp.h">
<Filter>Core\c-timestamp</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="mbedTLS">
......@@ -584,6 +608,9 @@
<Filter Include="Security">
<UniqueIdentifier>{c6a27107-4b6c-4673-be9e-c0d8641f0a90}</UniqueIdentifier>
</Filter>
<Filter Include="Core\c-timestamp">
<UniqueIdentifier>{d83c9727-1931-4e51-9774-da03809c6325}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\security\oc_pstat.c.diff">
......
......@@ -17,6 +17,7 @@
#ifndef OC_ACL_H
#define OC_ACL_H
#include "oc_obt.h"
#include "oc_ri.h"
#include "oc_uuid.h"
#include "port/oc_log.h"
......@@ -29,41 +30,21 @@ extern "C"
{
#endif
typedef enum {
OC_PERM_NONE = 0,
OC_PERM_CREATE = (1 << 0),
OC_PERM_RETRIEVE = (1 << 1),
OC_PERM_UPDATE = (1 << 2),
OC_PERM_DELETE = (1 << 3),
OC_PERM_NOTIFY = (1 << 4)
} oc_ace_permissions_t;
typedef enum {
OC_ACE_NO_WC = -1,
OC_ACE_WC_ALL = 0x111,
OC_ACE_WC_ALL_SECURED = 0x01,
OC_ACE_WC_ALL_PUBLIC = 0x10,
} oc_ace_wildcard_t;
typedef enum {
OC_SUBJECT_UUID = 0,
OC_SUBJECT_ROLE,
OC_SUBJECT_CONN
} oc_ace_subject_type_t;
typedef enum {
OC_CONN_AUTH_CRYPT = 0,
OC_CONN_ANON_CLEAR
} oc_ace_connection_type_t;
typedef struct oc_ace_res_s
struct oc_ace_res_s
{
struct oc_ace_res_s *next;
oc_string_t href;
oc_interface_mask_t interfaces;
oc_string_array_t types;
oc_ace_wildcard_t wildcard;
} oc_ace_res_t;
};
typedef union
{
......@@ -76,7 +57,7 @@ typedef union
oc_ace_connection_type_t conn;
} oc_ace_subject_t;
typedef struct oc_sec_ace_s
struct oc_sec_ace_s
{
struct oc_sec_ace_s *next;
OC_LIST_STRUCT(resources);
......@@ -85,7 +66,7 @@ typedef struct oc_sec_ace_s
int aceid;
oc_ace_permissions_t permission;
// TODO: Add "validity" for ACE. It is currently not a mandatory property
} oc_sec_ace_t;
};
typedef struct
{
......
......@@ -429,8 +429,6 @@ get_endpoints(oc_client_response_t *data)
return;
}
cb->cb(&device->uuid, device->endpoint, cb->data);
oc_remove_delayed_callback(cb, free_discovery_cb);
free_discovery_cb(cb);
}
static void
......@@ -1286,7 +1284,9 @@ oc_obt_init(void)
memcpy(doxm->devowneruuid.id, uuid->id, 16);
memcpy(doxm->deviceuuid.id, uuid->id, 16);
memcpy(doxm->rowneruuid.id, uuid->id, 16);
doxm->owned = true;
doxm->oxmsel = 0;
memcpy(creds->rowneruuid.id, uuid->id, 16);
......
......@@ -18,18 +18,12 @@
#define OC_SP_H
#include "oc_ri.h"
#include "oc_pki.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
OC_SP_BASELINE = 1 << 1,
OC_SP_BLACK = 1 << 2,
OC_SP_BLUE = 1 << 3,
OC_SP_PURPLE = 1 << 4
} oc_sp_types_t;
typedef struct
{
oc_sp_types_t supported_profiles;
......
......@@ -38,8 +38,6 @@ fi
#swig -java -package org.iotivity -outdir ../iotivity-lite-java/src/org/iotivity/ -o ../iotivity-lite-java/jni/oc_ri_wrap.c ../swig_interfaces/oc_ri.i
swig -java -package org.iotivity -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../port/ -o ../iotivity-lite-java/jni/oc_storage_wrap.c ../swig_interfaces/oc_storage.i
#swig -java -package org.iotivity -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../security/ -o ../iotivity-lite-java/jni/oc_acl_wrap.c ../swig_interfaces/oc_acl.i
cp *.h ../iotivity-lite-java/jni/
cp ../oc_java/*.java ../iotivity-lite-java/src/org/iotivity/
mkdir -p ../iotivity-lite-java/src/org/iotivity/oc/
......
/* File oc_acl.i */
%module OCAcl
%{
#include "security/oc_acl.h"
%}
%ignore oc_ace_permissions_t;
%rename(OCAceWildcard) oc_ace_wildcard_t;
%ignore oc_ace_subject_type_t;
%rename(OCAceConnectionType) oc_ace_connection_type_t;
%rename(OCAceResource) oc_ace_res_s;
%ignore oc_ace_subject_t;
%ignore oc_ace_subject_t_role;
%ignore oc_sec_ace_s::OC_LIST_STRUCT(resources);
%ignore oc_sec_ace_s::subject_type;
%ignore oc_sec_ace_s::subject;
%ignore oc_sec_ace_s::permission;
%rename(OCSecurityAce) oc_sec_ace_s;
%ignore oc_sec_acl_t;
%ignore oc_sec_acl_init;
%ignore oc_sec_acl_free;
%ignore oc_sec_get_acl;
%ignore oc_sec_acl_default;
%ignore oc_sec_encode_acl;
%ignore oc_sec_decode_acl;
%ignore oc_sec_acl_init;
%ignore post_acl;
%ignore get_acl;
%ignore delete_acl;
%ignore oc_sec_check_acl;
%ignore oc_sec_set_post_otm_acl;
// TODO solve why the -I is not working for oc_acl.h here
%include "../../security/oc_acl.h"
......@@ -4,8 +4,6 @@
%include "iotivity.swg"
%import "oc_uuid.i"
// include not importe oc_acl.i it only exposes structs and enums so no need to build it separate.
%include "oc_acl.i"
%pragma(java) jniclasscode=%{
static {
......@@ -30,6 +28,24 @@
JCALL1(GetJavaVM, jenv, &jvm);
}
%rename(OCSecurityAce) oc_sec_ace_s;
/* We are relying on the iotivity-lite library to create and destry instances of oc_sec_ace_s */
%nodefaultctor oc_sec_ace_s;
%nodefaultdtor oc_sec_ace_s;
/* This will cause SWIG to wrap oc_sec_ace_s, even though oc_obt does not know anything about what is inside it */
struct oc_sec_ace_s{ };
%rename(OCAceResource) oc_ace_res_s;
/* We are relying on the iotivity-lite library to create and destry instances of oc_ace_res_s */
%nodefaultctor oc_ace_res_s;
%nodefaultdtor oc_ace_res_s;
/* This will cause SWIG to wrap oc_ace_res_s, even though oc_obt does not know anything about what is inside it */
struct oc_ace_res_s{ };
%rename(OCAceConnectionType) oc_ace_connection_type_t;
%rename(OCAceWildcard) oc_ace_wildcard_t;
%ignore oc_ace_permissions_t;
%ignore oc_obt_init;
%rename(init) jni_obt_init;
%inline %{
......
......@@ -23,12 +23,6 @@
%}
%rename (OCSpTypesMask) oc_sp_types_t;
typedef enum {
OC_SP_BASELINE = 1 << 1,
OC_SP_BLACK = 1 << 2,
OC_SP_BLUE = 1 << 3,
OC_SP_PURPLE = 1 << 4
} oc_sp_types_t;
%apply (const unsigned char * BYTE, size_t LENGTH) { (const unsigned char *cert, size_t cert_size) };
%apply (const unsigned char * BYTE, size_t LENGTH) { (const unsigned char *key, size_t key_size) };
......
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