You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/01/12 17:30:40 UTC

[GitHub] mkiiskila closed pull request #726: Allow transport implementations to be registered from outside net/oic package

mkiiskila closed pull request #726: Allow transport implementations to be registered from outside net/oic package
URL: https://github.com/apache/mynewt-core/pull/726
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/net/oic/include/oic/messaging/coap/transactions.h b/net/oic/include/oic/messaging/coap/transactions.h
index ba3119ccc..bc9beda7a 100644
--- a/net/oic/include/oic/messaging/coap/transactions.h
+++ b/net/oic/include/oic/messaging/coap/transactions.h
@@ -67,7 +67,7 @@ typedef struct coap_transaction {
 
 void coap_register_as_transaction_handler(void);
 
-coap_transaction_t *coap_new_transaction(uint16_t mid, oc_endpoint_t *endpoint);
+coap_transaction_t *coap_new_transaction(uint16_t mid, oc_endpoint_t *);
 
 void coap_send_transaction(coap_transaction_t *t);
 void coap_clear_transaction(coap_transaction_t *t);
diff --git a/net/oic/include/oic/oc_client_state.h b/net/oic/include/oic/oc_client_state.h
index aa6b16e22..8623ffcd8 100644
--- a/net/oic/include/oic/oc_client_state.h
+++ b/net/oic/include/oic/oc_client_state.h
@@ -71,7 +71,7 @@ typedef struct oc_client_cb {
 } oc_client_cb_t;
 
 bool oc_ri_invoke_client_cb(struct coap_packet_rx *response,
-                            oc_endpoint_t *endpoint);
+                            oc_endpoint_t *);
 
 oc_client_cb_t *oc_ri_alloc_client_cb(const char *uri,
                                       oc_server_handle_t *server,
@@ -85,10 +85,10 @@ void oc_ri_remove_client_cb_by_mid(uint16_t mid);
 
 oc_discovery_flags_t oc_ri_process_discovery_payload(struct coap_packet_rx *rsp,
                                                      oc_discovery_cb_t *handler,
-                                                     oc_endpoint_t *endpoint);
+                                                     oc_endpoint_t *);
 
-bool oc_ri_send_rst(oc_endpoint_t *endpoint, uint8_t *token, uint8_t token_len,
-                    uint16_t mid);
+bool oc_ri_send_rst(oc_endpoint_t *endpoint, uint8_t *token,
+                    uint8_t token_len, uint16_t mid);
 #endif
 
 #ifdef __cplusplus
diff --git a/net/oic/include/oic/oc_ri.h b/net/oic/include/oic/oc_ri.h
index 60359784d..5cb9b4883 100644
--- a/net/oic/include/oic/oc_ri.h
+++ b/net/oic/include/oic/oc_ri.h
@@ -18,9 +18,9 @@
 #define OC_RI_H
 
 #include "oic/port/mynewt/config.h"
+#include "oic/port/oc_connectivity.h"
 #include "oic/oc_rep.h"
 #include "oic/oc_uuid.h"
-#include "oic/port/oc_connectivity.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -155,7 +155,7 @@ struct coap_packet;
 bool oc_ri_invoke_coap_entity_handler(struct coap_packet_rx *request,
                                       struct coap_packet *response,
                                       int32_t *offset,
-                                      oc_endpoint_t *endpoint);
+                                      struct oc_endpoint *endpoint);
 
 #ifdef __cplusplus
 }
diff --git a/net/oic/include/oic/port/mynewt/ble.h b/net/oic/include/oic/port/mynewt/ble.h
new file mode 100644
index 000000000..63841aeca
--- /dev/null
+++ b/net/oic/include/oic/port/mynewt/ble.h
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 __OIC_MYNEWT_BLE_H_
+#define __OIC_MYNEWT_BLE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * oc_endpoint for BLE source.
+ */
+struct oc_endpoint_ble {
+    struct oc_ep_hdr ep;
+    uint8_t srv_idx;
+    uint16_t conn_handle;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OIC_MYNEWT_BLE_H_ */
diff --git a/net/oic/include/oic/port/mynewt/ip.h b/net/oic/include/oic/port/mynewt/ip.h
new file mode 100644
index 000000000..4c55c88d9
--- /dev/null
+++ b/net/oic/include/oic/port/mynewt/ip.h
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 __OIC_MYNEWT_IP_H_
+#define __OIC_MYNEWT_IP_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+    uint8_t address[16];
+    uint8_t scope;
+} oc_ipv6_addr_t;
+
+typedef struct {
+    uint8_t address[4];
+} oc_ipv4_addr_t;
+
+/*
+ * oc_endpoint for IPv4/IPv6
+ */
+struct oc_endpoint_ip {
+    struct oc_ep_hdr ep;
+    uint16_t port;
+    union {
+        oc_ipv6_addr_t v6;
+        oc_ipv4_addr_t v4;
+    };
+};
+
+extern uint8_t oc_ip6_transport_id;
+extern uint8_t oc_ip4_transport_id;
+
+static inline int
+oc_endpoint_is_ip(struct oc_endpoint *oe)
+{
+    return oe->ep.oe_type == oc_ip6_transport_id ||
+      oe->ep.oe_type == oc_ip4_transport_id;
+}
+
+#define oc_make_ip6_endpoint(__name__, __flags__, __port__, ...)        \
+    struct oc_endpoint_ip __name__ = {.ep = {.oe_type = oc_ip6_transport_id, \
+                                             .oe_flags = __flags__ },   \
+                                      .port = __port__,                 \
+                                      .v6 = {.scope = 0,                \
+                                             .address = { __VA_ARGS__ } } }
+#define oc_make_ip4_endpoint(__name__, __flags__, __port__, ...)        \
+    struct oc_endpoint_ip __name__ = {.ep = {.oe_type = oc_ip4_transport_id, \
+                                             .oe_flags = __flags__},    \
+                                      .port = __port__,                 \
+                                      .v4 = {.address = { __VA_ARGS__ } } }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OIC_MYNEWT_IP_H_ */
diff --git a/net/oic/include/oic/port/mynewt/lora.h b/net/oic/include/oic/port/mynewt/lora.h
new file mode 100644
index 000000000..797b63b9d
--- /dev/null
+++ b/net/oic/include/oic/port/mynewt/lora.h
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 __OIC_MYNEWT_LORA_H_
+#define __OIC_MYNEWT_LORA_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * oc_endpoint for LORA.
+ */
+struct oc_endpoint_lora {
+    struct oc_ep_hdr ep;
+    uint8_t port;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OIC_MYNEWT_LORA_H_ */
diff --git a/net/oic/include/oic/port/mynewt/transport.h b/net/oic/include/oic/port/mynewt/transport.h
new file mode 100644
index 000000000..dcd80a0fa
--- /dev/null
+++ b/net/oic/include/oic/port/mynewt/transport.h
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 __MYNEWT_TRANSPORT_H_
+#define __MYNEWT_TRANSPORT_H_
+
+#include <os/queue.h>
+
+#include "oic/oc_ri.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define OC_TRANSPORT_MAX 8
+
+#define OC_TRANSPORT_USE_TCP (1 << 0)
+
+struct oc_endpoint;
+enum oc_resource_properties;
+
+struct oc_transport {
+    uint8_t ot_ep_size;
+    uint8_t ot_flags;
+    void (*ot_tx_ucast)(struct os_mbuf *);
+    void (*ot_tx_mcast)(struct os_mbuf *);
+    enum oc_resource_properties
+         (*ot_get_trans_security)(const struct oc_endpoint *);
+    char *(*ot_ep_str)(char *ptr, int maxlen, const struct oc_endpoint *);
+    int (*ot_init)(void);
+    void (*ot_shutdown)(void);
+};
+
+extern const struct oc_transport *oc_transports[OC_TRANSPORT_MAX];
+
+int8_t oc_transport_register(const struct oc_transport *);
+int8_t oc_transport_lookup(const struct oc_transport *);
+void oc_transport_unregister(const struct oc_transport *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MYNEWT_TRANSPORT_H_ */
diff --git a/net/oic/include/oic/port/oc_connectivity.h b/net/oic/include/oic/port/oc_connectivity.h
index e4fddb76a..57c101ffa 100644
--- a/net/oic/include/oic/port/oc_connectivity.h
+++ b/net/oic/include/oic/port/oc_connectivity.h
@@ -20,130 +20,63 @@
 #include <stdint.h>
 
 #include "oic/port/mynewt/config.h"
+#include "oic/port/mynewt/transport.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef struct {
-    uint16_t port;
-    uint8_t address[16];
-    uint8_t scope;
-} oc_ipv6_addr_t;
-
-typedef struct {
-    uint16_t port;
-    uint8_t address[4];
-} oc_ipv4_addr_t;
-
-enum oc_transport_flags {
-    IP = 1 << 0,
-    GATT = 1 << 1,
-    IPSP = 1 << 2,
-    MULTICAST = 1 << 3,
-    SECURED = 1 << 4,
-    SERIAL = 1 << 5,
-    IP4 = 1 << 6,
-    LORA = 1 << 7,
-};
-
 /*
  * OC endpoint data structure comes in different variations,
- * depending on flags field.
- */
-/*
- * oc_endpoint for IPv6 source
+ * depending on type of transport.
  */
-struct oc_endpoint_ip {
-    enum oc_transport_flags flags;
-    union {
-        oc_ipv6_addr_t v6;
-        oc_ipv4_addr_t v4;
-    };
+struct oc_ep_hdr {
+    uint8_t oe_type:3;          /* index to oc_transports array */
+    uint8_t oe_flags:5;         /* OC_ENDPOINT flags */
 };
 
-/*
- * oc_endpoint for BLE source.
- */
-struct oc_endpoint_ble {
-    enum oc_transport_flags flags;
-    uint8_t srv_idx;
-    uint16_t conn_handle;
-};
+#define OC_ENDPOINT_MULTICAST   1 << 0
+#define OC_ENDPOINT_SECURED     1 << 1
 
 /*
- * oc_endpoint for LORA.
+ * Use this when reserving memory for oc_endpoint of unknown type.
  */
-struct oc_endpoint_lora {
-    enum oc_transport_flags flags;
-    uint8_t port;
-};
+typedef struct oc_endpoint {
+    struct oc_ep_hdr ep;
+    uint8_t _res[23];          /* based on size of oc_endpoint_ip6 */
+} oc_endpoint_t;
 
 /*
- * oc_endpoint for multicast target and serial port.
+ * Plain oc_endpoint for multicast target.
  */
 struct oc_endpoint_plain {
-    enum oc_transport_flags flags;
+    struct oc_ep_hdr ep;
 };
 
-typedef struct oc_endpoint {
-    union {
-        struct oc_endpoint_ip oe_ip;
-        struct oc_endpoint_ble oe_ble;
-        struct oc_endpoint_lora oe_lora;
-        struct oc_endpoint_plain oe;
-    };
-} oc_endpoint_t;
-
 static inline int
 oc_endpoint_size(struct oc_endpoint *oe)
 {
-    if (oe->oe.flags & (IP | IP4)) {
-        return sizeof (struct oc_endpoint_ip);
-    } else if (oe->oe.flags & GATT) {
-        return sizeof (struct oc_endpoint_ble);
-    } else if (oe->oe.flags & LORA) {
-        return sizeof (struct oc_endpoint_lora);
-    } else if (oe->oe.flags & SERIAL) {
-        return sizeof (struct oc_endpoint_plain);
-    } else {
-        return sizeof (struct oc_endpoint);
-    }
+    return oc_transports[oe->ep.oe_type]->ot_ep_size;
+}
+
+static inline int
+oc_endpoint_use_tcp(struct oc_endpoint *oe)
+{
+    return oc_transports[oe->ep.oe_type]->ot_flags & OC_TRANSPORT_USE_TCP;
 }
 
 #define OC_MBUF_ENDPOINT(m)                                            \
     ((struct oc_endpoint *)((uint8_t *)m + sizeof(struct os_mbuf) +    \
                             sizeof(struct os_mbuf_pkthdr)))
 
-
-#define oc_make_ip_endpoint(__name__, __flags__, __port__, ...)         \
-    oc_endpoint_t __name__ = {.oe_ip = {.flags = __flags__,             \
-                                        .v6 = {.port = __port__,        \
-                                               .address = { __VA_ARGS__ } } } }
-#define oc_make_ip4_endpoint(__name__, __flags__, __port__, ...)        \
-    oc_endpoint_t __name__ = {.oe_ip = {.flags = __flags__,             \
-                                        .v4 = {.port = __port__,        \
-                                               .address = { __VA_ARGS__ } } } }
-
 #ifdef OC_SECURITY
 uint16_t oc_connectivity_get_dtls_port(void);
 #endif /* OC_SECURITY */
 
-enum oc_resource_properties
-oc_get_trans_security(const struct oc_endpoint *oe);
+enum oc_resource_properties oc_get_trans_security(const struct oc_endpoint *oe);
 int oc_connectivity_init(void);
 void oc_connectivity_shutdown(void);
 
-static inline int
-oc_endpoint_use_tcp(struct oc_endpoint *oe)
-{
-    if (oe->oe.flags & GATT) {
-        return 1;
-    }
-    return 0;
-}
-
-
 void oc_send_buffer(struct os_mbuf *);
 void oc_send_multicast_message(struct os_mbuf *);
 
diff --git a/net/oic/pkg.yml b/net/oic/pkg.yml
index 52c3673ac..2e9400698 100644
--- a/net/oic/pkg.yml
+++ b/net/oic/pkg.yml
@@ -54,3 +54,8 @@ pkg.cflags:
 
 pkg.init:
     oc_init: 300
+    oc_register_ip6: 301
+    oc_register_ip4: 301
+    oc_register_serial: 301
+    oc_register_gatt: 301
+    oc_register_lora: 301
diff --git a/net/oic/src/api/oc_buffer.c b/net/oic/src/api/oc_buffer.c
index 065db1814..d40c3ddfe 100644
--- a/net/oic/src/api/oc_buffer.c
+++ b/net/oic/src/api/oc_buffer.c
@@ -32,6 +32,7 @@
 #include "api/oc_buffer.h"
 
 #include "port/mynewt/adaptor.h"
+#include "port/mynewt/transport.h"
 
 static struct os_mqueue oc_inq;
 static struct os_mqueue oc_outq;
@@ -40,13 +41,16 @@ struct os_mbuf *
 oc_allocate_mbuf(struct oc_endpoint *oe)
 {
     struct os_mbuf *m;
+    int ep_size;
+
+    ep_size = oc_endpoint_size(oe);
 
     /* get a packet header */
-    m = os_msys_get_pkthdr(0, sizeof(struct oc_endpoint));
+    m = os_msys_get_pkthdr(0, ep_size);
     if (!m) {
         return NULL;
     }
-    memcpy(OC_MBUF_ENDPOINT(m), oe, sizeof(struct oc_endpoint));
+    memcpy(OC_MBUF_ENDPOINT(m), oe, ep_size);
     return m;
 }
 
@@ -78,7 +82,7 @@ oc_buffer_tx(struct os_event *ev)
         OC_LOG_DEBUG("oc_buffer_tx: ");
         OC_LOG_ENDPOINT(LOG_LEVEL_DEBUG, OC_MBUF_ENDPOINT(m));
 #ifdef OC_CLIENT
-        if (OC_MBUF_ENDPOINT(m)->oe.flags & MULTICAST) {
+        if (OC_MBUF_ENDPOINT(m)->ep.oe_flags & OC_ENDPOINT_MULTICAST) {
             oc_send_multicast_message(m);
         } else {
 #endif
diff --git a/net/oic/src/api/oc_client_api.c b/net/oic/src/api/oc_client_api.c
index 84d38704a..80b62e0ac 100644
--- a/net/oic/src/api/oc_client_api.c
+++ b/net/oic/src/api/oc_client_api.c
@@ -21,6 +21,9 @@
 #include "oic/messaging/coap/transactions.h"
 #include "oic/oc_api.h"
 #include "api/oc_buffer.h"
+#if MYNEWT_VAL(OC_TRANSPORT_IPV6) || MYNEWT_VAL(OC_TRANSPORT_IPV4)
+#include "oic/port/mynewt/ip.h"
+#endif
 
 #ifdef OC_CLIENT
 #define OC_CLIENT_CB_TIMEOUT_SECS COAP_RESPONSE_TIMEOUT
@@ -301,10 +304,9 @@ oc_do_ip6_discovery(const char *rt, oc_discovery_cb_t handler)
 {
     oc_server_handle_t handle;
 
-    oc_make_ip_endpoint(mcast, IP | MULTICAST, 5683,
+    oc_make_ip6_endpoint(mcast, OC_ENDPOINT_MULTICAST, 5683,
                        0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xfd);
-    mcast.oe_ip.v6.scope = 0;
-    memcpy(&handle.endpoint, &mcast, sizeof(oc_endpoint_t));
+    memcpy(&handle.endpoint, &mcast, sizeof(mcast));
 
     return oc_send_ip_discovery(&handle, rt, handler);
 
@@ -317,8 +319,9 @@ oc_do_ip4_discovery(const char *rt, oc_discovery_cb_t handler)
 {
     oc_server_handle_t handle;
 
-    oc_make_ip4_endpoint(mcast, IP4 | MULTICAST, 5683, 0xe0, 0, 0x01, 0xbb);
-    memcpy(&handle.endpoint, &mcast, sizeof(oc_endpoint_t));
+    oc_make_ip4_endpoint(mcast, OC_ENDPOINT_MULTICAST, 5683,
+                         0xe0, 0, 0x01, 0xbb);
+    memcpy(&handle.endpoint, &mcast, sizeof(mcast));
 
     return oc_send_ip_discovery(&handle, rt, handler);
 }
diff --git a/net/oic/src/api/oc_discovery.c b/net/oic/src/api/oc_discovery.c
index 35ed973db..fafb63db7 100644
--- a/net/oic/src/api/oc_discovery.c
+++ b/net/oic/src/api/oc_discovery.c
@@ -24,6 +24,7 @@
 #include "oic/messaging/coap/oc_coap.h"
 #include "oic/oc_api.h"
 #include "oic/oc_core_res.h"
+#include "oic/port/mynewt/ip.h"
 
 static bool
 filter_resource(oc_resource_t *resource, const char *rt, int rt_len,
@@ -193,15 +194,19 @@ oc_ri_process_discovery_payload(struct coap_packet_rx *rsp,
       .os_str = NULL
   };
   bool secure = false;
-  uint16_t dtls_port = 0, default_port = endpoint->oe_ip.v6.port;
+  uint16_t dtls_port = 0, default_port = 0;
   oc_string_array_t types = {};
   oc_interface_mask_t interfaces = 0;
   oc_server_handle_t handle;
   uint16_t data_off;
   struct os_mbuf *m;
   int len;
+  struct oc_endpoint_ip *ip;
 
-  memcpy(&handle.endpoint, endpoint, sizeof(oc_endpoint_t));
+  memcpy(&handle.endpoint, endpoint, oc_endpoint_size(endpoint));
+  if (oc_endpoint_is_ip(endpoint)) {
+      default_port = ((struct oc_endpoint_ip *)endpoint)->port;
+  }
 
   oc_rep_t *array = 0, *rep;
 
@@ -276,14 +281,16 @@ oc_ri_process_discovery_payload(struct coap_packet_rx *rsp,
               }
               resource_info = resource_info->next;
             }
-            if (secure) {
-              handle.endpoint.oe_ip.v6.port = dtls_port;
-              handle.endpoint.oe_ip.flags |= SECURED;
-            } else {
-              handle.endpoint.oe_ip.v6.port = default_port;
-              handle.endpoint.oe_ip.flags &= ~SECURED;
+            if (default_port) {
+                ip = (struct oc_endpoint_ip *)&handle.endpoint;
+                if (secure) {
+                    ip->port = dtls_port;
+                    ip->ep.oe_flags |= OC_ENDPOINT_SECURED;
+                } else {
+                    ip->port = default_port;
+                    ip->ep.oe_flags &= ~OC_ENDPOINT_SECURED;
+                }
             }
-
             if (handler(oc_string(di), oc_string(uri), types, interfaces,
                         &handle) == OC_STOP_DISCOVERY) {
               ret = OC_STOP_DISCOVERY;
diff --git a/net/oic/src/api/oc_ri.c b/net/oic/src/api/oc_ri.c
index 3f336a906..c081b72fa 100644
--- a/net/oic/src/api/oc_ri.c
+++ b/net/oic/src/api/oc_ri.c
@@ -375,7 +375,8 @@ does_interface_support_method(oc_resource_t *resource,
  *                              false if the security requirements are not met.
  */
 static bool
-oc_ri_check_trans_security(const oc_endpoint_t *oe, const oc_resource_t *res)
+oc_ri_check_trans_security(const oc_endpoint_t *oe,
+                           const oc_resource_t *res)
 {
 #if MYNEWT_VAL(OC_TRANS_SECURITY)
   oc_resource_properties_t res_sec_flags;
diff --git a/net/oic/src/messaging/coap/engine.c b/net/oic/src/messaging/coap/engine.c
index 6a36e7496..416eccf0a 100644
--- a/net/oic/src/messaging/coap/engine.c
+++ b/net/oic/src/messaging/coap/engine.c
@@ -60,13 +60,14 @@ coap_receive(struct os_mbuf **mp)
     static struct coap_packet response[1];
     static coap_transaction_t *transaction = NULL;
     struct os_mbuf *rsp;
-    oc_endpoint_t endpoint; /* XXX */
+    struct oc_endpoint endpoint; /* XXX */
 
     erbium_status_code = NO_ERROR;
 
     OC_LOG_INFO("CoAP: received datalen=%u\n", OS_MBUF_PKTLEN(*mp));
 
-    memcpy(&endpoint, OC_MBUF_ENDPOINT(*mp), sizeof(endpoint)); /* XXXXX */
+    memcpy(&endpoint, OC_MBUF_ENDPOINT(*mp),
+           oc_endpoint_size(OC_MBUF_ENDPOINT(*mp)));
     erbium_status_code = coap_parse_message(message, mp);
     if (erbium_status_code != NO_ERROR) {
         goto out;
diff --git a/net/oic/src/messaging/coap/observe.c b/net/oic/src/messaging/coap/observe.c
index 9623b0014..b14eb8c41 100644
--- a/net/oic/src/messaging/coap/observe.c
+++ b/net/oic/src/messaging/coap/observe.c
@@ -77,7 +77,7 @@ add_observer(oc_resource_t *resource, oc_endpoint_t *endpoint,
         }
         memcpy(o->url, uri, max);
         o->url[max] = 0;
-        memcpy(&o->endpoint, endpoint, sizeof(oc_endpoint_t));
+        memcpy(&o->endpoint, endpoint, oc_endpoint_size(endpoint));
         o->token_len = token_len;
         memcpy(o->token, token, token_len);
         o->last_mid = 0;
diff --git a/net/oic/src/port/mynewt/adaptor.c b/net/oic/src/port/mynewt/adaptor.c
index 87f52f9f6..fbe853b30 100644
--- a/net/oic/src/port/mynewt/adaptor.c
+++ b/net/oic/src/port/mynewt/adaptor.c
@@ -28,10 +28,11 @@
 #include "api/oc_priv.h"
 #include "port/oc_connectivity.h"
 #include "adaptor.h"
+#include "port/mynewt/transport.h"
 
 static struct os_eventq *oc_evq;
-
 struct log oc_log;
+const struct oc_transport *oc_transports[OC_TRANSPORT_MAX];
 
 struct os_eventq *
 oc_evq_get(void)
@@ -45,83 +46,95 @@ oc_evq_set(struct os_eventq *evq)
     oc_evq = evq;
 }
 
+int8_t
+oc_transport_register(const struct oc_transport *ot)
+{
+    int i;
+    int first = -1;
+
+    for (i = 0; i < OC_TRANSPORT_MAX; i++) {
+        if (oc_transports[i] == ot) {
+            return -1;
+        }
+        if (oc_transports[i] == NULL && first < 0) {
+            oc_transports[i] = ot;
+            first = i;
+        }
+    }
+    return first;
+}
+
+int8_t
+oc_transport_lookup(const struct oc_transport *ot)
+{
+    int i;
+
+    for (i = 0; i < OC_TRANSPORT_MAX; i++) {
+        if (oc_transports[i] == ot) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+void
+oc_transport_unregister(const struct oc_transport *ot)
+{
+    int i;
+
+    i = oc_transport_lookup(ot);
+    if (i >= 0) {
+        oc_transports[i] = NULL;
+    }
+}
+
 void
 oc_send_buffer(struct os_mbuf *m)
 {
     struct oc_endpoint *oe;
+    const struct oc_transport *ot;
 
     oe = OC_MBUF_ENDPOINT(m);
 
-    switch (oe->oe.flags) {
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
-    case IP:
-        oc_send_buffer_ip6(m);
-        break;
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
-    case IP4:
-        oc_send_buffer_ip4(m);
-        break;
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-    case GATT:
-        oc_send_buffer_gatt(m);
-        break;
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_LORA) == 1)
-    case LORA:
-        oc_send_buffer_lora(m);
-        break;
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
-    case SERIAL:
-        oc_send_buffer_serial(m);
-        break;
-#endif
-    default:
-        OC_LOG_ERROR("Unknown transport option %u\n", oe->oe.flags);
+    ot = oc_transports[oe->ep.oe_type];
+    if (ot) {
+        ot->ot_tx_ucast(m);
+    } else {
+        OC_LOG_ERROR("Unknown transport option %u\n", oe->ep.oe_type);
         os_mbuf_free_chain(m);
     }
 }
 
+/*
+ * Send on all the transports.
+ */
 void
 oc_send_multicast_message(struct os_mbuf *m)
 {
-    /*
-     * Send on all the transports.
-     */
-    void (*funcs[])(struct os_mbuf *) = {
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
-        oc_send_buffer_ip6_mcast,
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
-        oc_send_buffer_ip4_mcast,
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-        /* no multicast for GATT, just send unicast */
-        oc_send_buffer_gatt,
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_LORA) == 1)
-        /* no multi-cast for serial.  just send unicast */
-        oc_send_buffer_lora,
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
-        /* no multi-cast for serial.  just send unicast */
-        oc_send_buffer_serial,
-#endif
-    };
+    const struct oc_transport *ot;
+    const struct oc_transport *prev = NULL;
     struct os_mbuf *n;
     int i;
 
-    for (i = 0; i < (sizeof(funcs) / sizeof(funcs[0])) - 1; i++) {
-        n = os_mbuf_dup(m);
-        funcs[i](m);
-        if (!n) {
-            return;
+    for (i = 0; i < OC_TRANSPORT_MAX; i++) {
+        if (!oc_transports[i]) {
+            continue;
+        }
+
+        ot = oc_transports[i];
+        if (prev) {
+            n = os_mbuf_dup(m);
+            prev->ot_tx_mcast(m);
+            if (!n) {
+                return;
+            }
+            m = n;
         }
-        m = n;
+        prev = ot;
+    }
+    if (prev) {
+        prev->ot_tx_mcast(m);
     }
-    funcs[(sizeof(funcs) / sizeof(funcs[0])) - 1](m);
 }
 
 /**
@@ -130,90 +143,52 @@ oc_send_multicast_message(struct os_mbuf *m)
 oc_resource_properties_t
 oc_get_trans_security(const struct oc_endpoint *oe)
 {
-    switch (oe->oe.flags) {
-#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-    case GATT:
-        return oc_get_trans_security_gatt(&oe->oe_ble);
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
-    case IP:
-        return 0;
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
-    case IP4:
-        return 0;
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_LORA) == 1)
-    case LORA:
-        return 0;
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
-    case SERIAL:
-        return 0;
-#endif
-    default:
-        OC_LOG_ERROR("Unknown transport option %u\n", oe->oe.flags);
-        return 0;
+    const struct oc_transport *ot;
+
+    ot = oc_transports[oe->ep.oe_type];
+    if (ot) {
+        if (ot->ot_get_trans_security) {
+            return ot->ot_get_trans_security(oe);
+        } else {
+            return 0;
+        }
     }
+    OC_LOG_ERROR("Unknown transport option %u\n", oe->ep.oe_type);
+    return 0;
 }
 
 void
 oc_connectivity_shutdown(void)
 {
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
-    oc_connectivity_shutdown_ip6();
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
-    oc_connectivity_shutdown_ip4();
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
-    oc_connectivity_shutdown_serial();
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_LORA) == 1)
-    oc_connectivity_shutdown_lora();
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-    oc_connectivity_shutdown_gatt();
-#endif
+    int i;
+    const struct oc_transport *ot;
+
+    for (i = 0; i < OC_TRANSPORT_MAX; i++) {
+        if (!oc_transports[i]) {
+            continue;
+        }
+        ot = oc_transports[i];
+        ot->ot_shutdown();
+    }
 }
 
 int
 oc_connectivity_init(void)
 {
     int rc = -1;
+    int i;
+    const struct oc_transport *ot;
 
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
-    if (oc_connectivity_init_ip6() == 0) {
-        rc = 0;
-    }
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
-    if (oc_connectivity_init_ip4() == 0) {
-        rc = 0;
-    }
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
-    if (oc_connectivity_init_serial() == 0) {
-        rc = 0;
-    }
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-    if (oc_connectivity_init_gatt() == 0) {
-        rc = 0;
-    }
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_LORA) == 1)
-    if (oc_connectivity_init_lora() == 0) {
-        rc = 0;
-    }
-#endif
-
-    if (rc != 0) {
-        oc_connectivity_shutdown();
-        return rc;
+    for (i = 0; i < OC_TRANSPORT_MAX; i++) {
+        if (!oc_transports[i]) {
+            continue;
+        }
+        ot = oc_transports[i];
+        if (ot->ot_init() == 0) {
+            rc = 0;
+        }
     }
-
-    return 0;
+    return rc;
 }
 
 void
diff --git a/net/oic/src/port/mynewt/adaptor.h b/net/oic/src/port/mynewt/adaptor.h
index cfc2a0a9f..175df16d3 100644
--- a/net/oic/src/port/mynewt/adaptor.h
+++ b/net/oic/src/port/mynewt/adaptor.h
@@ -24,43 +24,8 @@
 extern "C" {
 #endif
 
-enum oc_resource_properties;
-
 struct os_eventq *oc_evq_get(void);
 
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
-int oc_connectivity_init_ip6(void);
-void oc_connectivity_shutdown_ip6(void);
-void oc_send_buffer_ip6(struct os_mbuf *);
-void oc_send_buffer_ip6_mcast(struct os_mbuf *);
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
-int oc_connectivity_init_ip4(void);
-void oc_connectivity_shutdown_ip4(void);
-void oc_send_buffer_ip4(struct os_mbuf *);
-void oc_send_buffer_ip4_mcast(struct os_mbuf *);
-#endif
-
-#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-int oc_connectivity_init_gatt(void);
-void oc_connectivity_shutdown_gatt(void);
-void oc_send_buffer_gatt(struct os_mbuf *);
-enum oc_resource_properties
-oc_get_trans_security_gatt(const struct oc_endpoint_ble *oe_ble);
-#endif
-
-#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
-int oc_connectivity_init_serial(void);
-void oc_connectivity_shutdown_serial(void);
-void oc_send_buffer_serial(struct os_mbuf *);
-#endif
-
-#if (MYNEWT_VAL(OC_TRANSPORT_LORA) == 1)
-int oc_connectivity_init_lora(void);
-void oc_connectivity_shutdown_lora(void);
-void oc_send_buffer_lora(struct os_mbuf *);
-#endif
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/net/oic/src/port/mynewt/ble_adaptor.c b/net/oic/src/port/mynewt/ble_adaptor.c
index 3feffbe63..16503d5b7 100644
--- a/net/oic/src/port/mynewt/ble_adaptor.c
+++ b/net/oic/src/port/mynewt/ble_adaptor.c
@@ -17,11 +17,13 @@
  * under the License.
  */
 
+#include <assert.h>
+#include <string.h>
+#include <stdint.h>
+
 #include <syscfg/syscfg.h>
 #if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-#include <assert.h>
 #include <os/os.h>
-#include <string.h>
 
 #include <stats/stats.h>
 #include "oic/oc_gatt.h"
@@ -29,12 +31,33 @@
 #include "oic/oc_ri.h"
 #include "messaging/coap/coap.h"
 #include "api/oc_buffer.h"
-#include "port/oc_connectivity.h"
+#include "oic/port/oc_connectivity.h"
 #include "adaptor.h"
+#include "oic/port/mynewt/ble.h"
 #include "host/ble_hs.h"
 #include "services/gap/ble_svc_gap.h"
 #include "services/gatt/ble_svc_gatt.h"
 
+static void oc_send_buffer_gatt(struct os_mbuf *m);
+static char *oc_log_ep_gatt(char *ptr, int maxlen, const struct oc_endpoint *);
+enum oc_resource_properties
+oc_get_trans_security_gatt(const struct oc_endpoint *oe_ble);
+static int oc_connectivity_init_gatt(void);
+void oc_connectivity_shutdown_gatt(void);
+
+static const struct oc_transport oc_gatt_transport = {
+    .ot_ep_size = sizeof(struct oc_endpoint_ble),
+    .ot_flags = 0,
+    .ot_tx_ucast = oc_send_buffer_gatt,
+    .ot_tx_mcast = oc_send_buffer_gatt,
+    .ot_get_trans_security = oc_get_trans_security_gatt,
+    .ot_ep_str = oc_log_ep_gatt,
+    .ot_init = oc_connectivity_init_gatt,
+    .ot_shutdown = oc_connectivity_shutdown_gatt
+};
+
+static uint8_t oc_gatt_transport_id;
+
 /* OIC Transport Profile GATT */
 
 /* unsecure service UUID */
@@ -168,6 +191,15 @@ oc_ble_req_attr_to_idx(uint16_t attr_handle)
     return -1;
 }
 
+static char *
+oc_log_ep_gatt(char *ptr, int maxlen, const struct oc_endpoint *oe)
+{
+    struct oc_endpoint_ble *oe_ble = (struct oc_endpoint_ble *)oe;
+
+    snprintf(ptr, maxlen, "ble %u", oe_ble->conn_handle);
+    return ptr;
+}
+
 int
 oc_ble_reass(struct os_mbuf *om1, uint16_t conn_handle, uint8_t srv_idx)
 {
@@ -224,7 +256,8 @@ oc_ble_reass(struct os_mbuf *om1, uint16_t conn_handle, uint8_t srv_idx)
             om2 = om1;
         }
         oe_ble = (struct oc_endpoint_ble *)OC_MBUF_ENDPOINT(om2);
-        oe_ble->flags = GATT;
+        oe_ble->ep.oe_type = oc_gatt_transport_id;
+        oe_ble->ep.oe_flags = 0;
         oe_ble->srv_idx = srv_idx;
         oe_ble->conn_handle = conn_handle;
         pkt2 = OS_MBUF_PKTHDR(om2);
@@ -376,7 +409,7 @@ void
 oc_send_buffer_gatt(struct os_mbuf *m)
 {
 #if (MYNEWT_VAL(OC_SERVER) == 1)
-    struct oc_endpoint *oe;
+    struct oc_endpoint_ble *oe_ble;
     struct os_mbuf_pkthdr *pkt;
     uint16_t mtu;
     uint16_t conn_handle;
@@ -390,16 +423,16 @@ oc_send_buffer_gatt(struct os_mbuf *m)
 #if (MYNEWT_VAL(OC_SERVER) == 1)
 
     assert(OS_MBUF_USRHDR_LEN(m) >= sizeof(struct oc_endpoint_ble));
-    oe = OC_MBUF_ENDPOINT(m);
-    conn_handle = oe->oe_ble.conn_handle;
+    oe_ble = (struct oc_endpoint_ble *)OC_MBUF_ENDPOINT(m);
+    conn_handle = oe_ble->conn_handle;
 
     STATS_INC(oc_ble_stats, oframe);
     STATS_INCN(oc_ble_stats, obytes, OS_MBUF_PKTLEN(m));
 
-    if (oe->oe_ble.srv_idx >= OC_BLE_SRV_CNT) {
+    if (oe_ble->srv_idx >= OC_BLE_SRV_CNT) {
         goto err;
     }
-    attr_handle = oc_ble_srv_handles[oe->oe_ble.srv_idx].rsp;
+    attr_handle = oc_ble_srv_handles[oe_ble->srv_idx].rsp;
 
     mtu = ble_att_mtu(conn_handle);
     if (mtu < 4) {
@@ -435,12 +468,14 @@ oc_send_buffer_gatt(struct os_mbuf *m)
  * Retrieves the specified BLE endpoint's transport layer security properties.
  */
 oc_resource_properties_t
-oc_get_trans_security_gatt(const struct oc_endpoint_ble *oe_ble)
+oc_get_trans_security_gatt(const struct oc_endpoint *oe)
 {
+    const struct oc_endpoint_ble *oe_ble;
     oc_resource_properties_t props;
     struct ble_gap_conn_desc desc;
     int rc;
 
+    oe_ble = (const struct oc_endpoint_ble *)oe;
     rc = ble_gap_conn_find(oe_ble->conn_handle, &desc);
     if (rc != 0) {
         return 0;
@@ -458,3 +493,11 @@ oc_get_trans_security_gatt(const struct oc_endpoint_ble *oe_ble)
 }
 
 #endif
+
+void
+oc_register_gatt(void)
+{
+#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
+    oc_gatt_transport_id = oc_transport_register(&oc_gatt_transport);
+#endif
+}
diff --git a/net/oic/src/port/mynewt/ip4_adaptor.c b/net/oic/src/port/mynewt/ip4_adaptor.c
index d72c72f80..91d20c96f 100644
--- a/net/oic/src/port/mynewt/ip4_adaptor.c
+++ b/net/oic/src/port/mynewt/ip4_adaptor.c
@@ -17,11 +17,13 @@
  * under the License.
  */
 
-#include <syscfg/syscfg.h>
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
 #include <assert.h>
 #include <string.h>
+#include <stdint.h>
+
+#include <syscfg/syscfg.h>
 
+#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
 #include <os/os.h>
 #include <os/endian.h>
 
@@ -29,21 +31,35 @@
 #include <mn_socket/mn_socket.h>
 #include <stats/stats.h>
 
-#include "port/oc_connectivity.h"
+#include "oic/port/oc_connectivity.h"
 #include "oic/oc_log.h"
 #include "api/oc_buffer.h"
 #include "adaptor.h"
-
+#include "oic/port/mynewt/transport.h"
+#include "oic/port/mynewt/ip.h"
+
+static void oc_send_buffer_ip4(struct os_mbuf *m);
+static void oc_send_buffer_ip4_mcast(struct os_mbuf *m);
+static char *oc_log_ep_ip4(char *ptr, int maxlen, const struct oc_endpoint *);
+static int oc_connectivity_init_ip4(void);
+void oc_connectivity_shutdown_ip4(void);
 static void oc_event_ip4(struct os_event *ev);
 
+static const struct oc_transport oc_ip4_transport = {
+    .ot_ep_size = sizeof(struct oc_endpoint_ip),
+    .ot_flags = 0,
+    .ot_tx_ucast = oc_send_buffer_ip4,
+    .ot_tx_mcast = oc_send_buffer_ip4_mcast,
+    .ot_get_trans_security = NULL,
+    .ot_ep_str = oc_log_ep_ip4,
+    .ot_init = oc_connectivity_init_ip4,
+    .ot_shutdown = oc_connectivity_shutdown_ip4
+};
+
 static struct os_event oc_sock4_read_event = {
     .ev_cb = oc_event_ip4,
 };
 
-#ifdef OC_SECURITY
-#error This implementation does not yet support security
-#endif
-
 #define COAP_PORT_UNSECURED (5683)
 
 /* 224.0.1.187 */
@@ -78,26 +94,38 @@ static struct mn_socket *oc_ucast4;
 static struct mn_socket *oc_mcast4;
 #endif
 
+#ifdef OC_SECURITY
+#error This implementation does not yet support security
+#endif
+
+static char *
+oc_log_ep_ip4(char *ptr, int maxlen, const struct oc_endpoint *oe)
+{
+    const struct oc_endpoint_ip *oe_ip = (const struct oc_endpoint_ip *)oe;
+    int len;
+
+    mn_inet_ntop(MN_PF_INET, oe_ip->v4.address, ptr, maxlen);
+    len = strlen(ptr);
+    snprintf(ptr + len, maxlen - len, "-%u", oe_ip->port);
+    return ptr;
+}
+
 static void
 oc_send_buffer_ip4_int(struct os_mbuf *m, int is_mcast)
 {
     struct mn_sockaddr_in to;
-    struct oc_endpoint *oe;
+    struct oc_endpoint_ip *oe_ip;
     struct mn_itf itf;
     uint32_t if2_idx;
     struct os_mbuf *n;
     int rc;
 
     assert(OS_MBUF_USRHDR_LEN(m) >= sizeof(struct oc_endpoint_ip));
-    oe = OC_MBUF_ENDPOINT(m);
-    if ((oe->oe_ip.flags & IP4) == 0) {
-        os_mbuf_free_chain(m);
-        return;
-    }
+    oe_ip = (struct oc_endpoint_ip *)OC_MBUF_ENDPOINT(m);
     to.msin_len = sizeof(to);
     to.msin_family = MN_AF_INET;
-    to.msin_port = htons(oe->oe_ip.v4.port);
-    memcpy(&to.msin_addr, oe->oe_ip.v4.address, sizeof(to.msin_addr));
+    to.msin_port = htons(oe_ip->port);
+    memcpy(&to.msin_addr, oe_ip->v4.address, sizeof(to.msin_addr));
 
     STATS_INCN(oc_ip4_stats, obytes, OS_MBUF_PKTLEN(m));
     if (is_mcast) {
@@ -186,7 +214,7 @@ oc_attempt_rx_ip4_sock(struct mn_socket *rxsock)
     int rc;
     struct os_mbuf *m;
     struct os_mbuf *n;
-    struct oc_endpoint *oe;
+    struct oc_endpoint_ip *oe_ip;
     struct mn_sockaddr_in from;
 
     rc = mn_recvfrom(rxsock, &n, (struct mn_sockaddr *) &from);
@@ -205,12 +233,12 @@ oc_attempt_rx_ip4_sock(struct mn_socket *rxsock)
     OS_MBUF_PKTHDR(m)->omp_len = OS_MBUF_PKTHDR(n)->omp_len;
     SLIST_NEXT(m, om_next) = n;
 
-    oe = OC_MBUF_ENDPOINT(m);
+    oe_ip = (struct oc_endpoint_ip *)OC_MBUF_ENDPOINT(m);
 
-    oe->oe_ip.flags = IP4;
-    memcpy(&oe->oe_ip.v4.address, &from.msin_addr,
-           sizeof(oe->oe_ip.v4.address));
-    oe->oe_ip.v4.port = ntohs(from.msin_port);
+    oe_ip->ep.oe_type = oc_ip4_transport_id;
+    oe_ip->ep.oe_flags = 0;
+    memcpy(&oe_ip->v4.address, &from.msin_addr, sizeof(oe_ip->v4.address));
+    oe_ip->port = ntohs(from.msin_port);
 
     return m;
 
@@ -352,3 +380,13 @@ oc_connectivity_init_ip4(void)
 }
 
 #endif
+
+uint8_t oc_ip4_transport_id = -1;
+
+void
+oc_register_ip4(void)
+{
+#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV4) == 1)
+    oc_ip4_transport_id = oc_transport_register(&oc_ip4_transport);
+#endif
+}
diff --git a/net/oic/src/port/mynewt/ip_adaptor.c b/net/oic/src/port/mynewt/ip_adaptor.c
index 7f806cb3e..90cc83ab6 100644
--- a/net/oic/src/port/mynewt/ip_adaptor.c
+++ b/net/oic/src/port/mynewt/ip_adaptor.c
@@ -17,10 +17,13 @@
  * under the License.
  */
 
-#include <syscfg/syscfg.h>
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
 #include <assert.h>
 #include <string.h>
+#include <stdint.h>
+
+#include <syscfg/syscfg.h>
+
+#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
 
 #include <os/os.h>
 #include <os/endian.h>
@@ -29,22 +32,35 @@
 #include <mn_socket/mn_socket.h>
 #include <stats/stats.h>
 
-#include "port/oc_connectivity.h"
+#include "oic/port/oc_connectivity.h"
 #include "oic/oc_log.h"
 #include "api/oc_buffer.h"
 #include "adaptor.h"
-
+#include "oic/port/mynewt/transport.h"
+#include "oic/port/mynewt/ip.h"
+
+static void oc_send_buffer_ip6(struct os_mbuf *m);
+static void oc_send_buffer_ip6_mcast(struct os_mbuf *m);
+static char *oc_log_ep_ip6(char *ptr, int maxlen, const struct oc_endpoint *);
+static int oc_connectivity_init_ip6(void);
+void oc_connectivity_shutdown_ip6(void);
 static void oc_event_ip6(struct os_event *ev);
 
+static const struct oc_transport oc_ip6_transport = {
+    .ot_ep_size = sizeof(struct oc_endpoint_ip),
+    .ot_flags = 0,
+    .ot_tx_ucast = oc_send_buffer_ip6,
+    .ot_tx_mcast = oc_send_buffer_ip6_mcast,
+    .ot_get_trans_security = NULL,
+    .ot_ep_str = oc_log_ep_ip6,
+    .ot_init = oc_connectivity_init_ip6,
+    .ot_shutdown = oc_connectivity_shutdown_ip6
+};
+
 static struct os_event oc_sock6_read_event = {
     .ev_cb = oc_event_ip6,
 };
 
-#ifdef OC_SECURITY
-#error This implementation does not yet support security
-#endif
-
-
 #define COAP_PORT_UNSECURED (5683)
 
 /* link-local scoped address ff02::fd */
@@ -82,28 +98,40 @@ static struct mn_socket *oc_ucast6;
 static struct mn_socket *oc_mcast6;
 #endif
 
+#ifdef OC_SECURITY
+#error This implementation does not yet support security
+#endif
+
+static char *
+oc_log_ep_ip6(char *ptr, int maxlen, const struct oc_endpoint *oe)
+{
+    const struct oc_endpoint_ip *oe_ip = (const struct oc_endpoint_ip *)oe;
+    int len;
+
+    mn_inet_ntop(MN_PF_INET6, oe_ip->v6.address, ptr, maxlen);
+    len = strlen(ptr);
+    snprintf(ptr + len, maxlen - len, "-%u", oe_ip->port);
+    return ptr;
+}
+
 static void
 oc_send_buffer_ip6_int(struct os_mbuf *m, int is_mcast)
 {
     struct mn_sockaddr_in6 to;
-    struct oc_endpoint *oe;
+    struct oc_endpoint_ip *oe_ip;
     struct mn_itf itf;
     struct mn_itf itf2;
     struct os_mbuf *n;
     int rc;
 
     assert(OS_MBUF_USRHDR_LEN(m) >= sizeof(struct oc_endpoint_ip));
-    oe = OC_MBUF_ENDPOINT(m);
-    if ((oe->oe_ip.flags & IP) == 0) {
-        os_mbuf_free_chain(m);
-        return;
-    }
+    oe_ip = (struct oc_endpoint_ip *)OC_MBUF_ENDPOINT(m);
     to.msin6_len = sizeof(to);
     to.msin6_family = MN_AF_INET6;
-    to.msin6_port = htons(oe->oe_ip.v6.port);
+    to.msin6_port = htons(oe_ip->port);
     to.msin6_flowinfo = 0;
-    to.msin6_scope_id = oe->oe_ip.v6.scope;
-    memcpy(&to.msin6_addr, oe->oe_ip.v6.address, sizeof(to.msin6_addr));
+    to.msin6_scope_id = oe_ip->v6.scope;
+    memcpy(&to.msin6_addr, oe_ip->v6.address, sizeof(to.msin6_addr));
 
     STATS_INCN(oc_ip_stats, obytes, OS_MBUF_PKTLEN(m));
     if (is_mcast) {
@@ -164,13 +192,14 @@ oc_send_buffer_ip6_int(struct os_mbuf *m, int is_mcast)
     }
 }
 
-void
+static void
 oc_send_buffer_ip6(struct os_mbuf *m)
 {
     STATS_INC(oc_ip_stats, oucast);
     oc_send_buffer_ip6_int(m, 0);
 }
-void
+
+static void
 oc_send_buffer_ip6_mcast(struct os_mbuf *m)
 {
     STATS_INC(oc_ip_stats, omcast);
@@ -183,7 +212,7 @@ oc_attempt_rx_ip6_sock(struct mn_socket *rxsock)
     int rc;
     struct os_mbuf *m;
     struct os_mbuf *n;
-    struct oc_endpoint *oe;
+    struct oc_endpoint_ip *oe_ip;
     struct mn_sockaddr_in6 from;
 
     rc = mn_recvfrom(rxsock, &n, (struct mn_sockaddr *) &from);
@@ -202,13 +231,13 @@ oc_attempt_rx_ip6_sock(struct mn_socket *rxsock)
     OS_MBUF_PKTHDR(m)->omp_len = OS_MBUF_PKTHDR(n)->omp_len;
     SLIST_NEXT(m, om_next) = n;
 
-    oe = OC_MBUF_ENDPOINT(m);
+    oe_ip = (struct oc_endpoint_ip *)OC_MBUF_ENDPOINT(m);
 
-    oe->oe_ip.flags = IP;
-    memcpy(&oe->oe_ip.v6.address, &from.msin6_addr,
-           sizeof(oe->oe_ip.v6.address));
-    oe->oe_ip.v6.scope = from.msin6_scope_id;
-    oe->oe_ip.v6.port = ntohs(from.msin6_port);
+    oe_ip->ep.oe_type = oc_ip6_transport_id;
+    oe_ip->ep.oe_flags = 0;
+    memcpy(&oe_ip->v6.address, &from.msin6_addr, sizeof(oe_ip->v6.address));
+    oe_ip->v6.scope = from.msin6_scope_id;
+    oe_ip->port = ntohs(from.msin6_port);
 
     return m;
 
@@ -353,3 +382,14 @@ oc_connectivity_init_ip6(void)
 }
 
 #endif
+
+uint8_t oc_ip6_transport_id = -1;
+
+void
+oc_register_ip6(void)
+{
+#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1) && (MYNEWT_VAL(OC_TRANSPORT_IPV6) == 1)
+    oc_ip6_transport_id = oc_transport_register(&oc_ip6_transport);
+#endif
+}
+
diff --git a/net/oic/src/port/mynewt/log.c b/net/oic/src/port/mynewt/log.c
index f09684996..bcf877208 100644
--- a/net/oic/src/port/mynewt/log.c
+++ b/net/oic/src/port/mynewt/log.c
@@ -25,45 +25,27 @@
 #endif
 #include "oic/oc_log.h"
 #include "port/oc_connectivity.h"
+#include "oic/port/mynewt/transport.h"
 
 void
 oc_log_endpoint(uint16_t lvl, struct oc_endpoint *oe)
 {
     char *str;
     char tmp[46 + 6];
+    const struct oc_transport *ot;
 
     (void)tmp;
     (void)str;
 
-    switch (oe->oe.flags) {
-#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1)
-    case IP: {
-        int len;
-
-        mn_inet_ntop(MN_PF_INET6, oe->oe_ip.v6.address, tmp, sizeof(tmp));
-        len = strlen(tmp);
-        snprintf(tmp + len, sizeof(tmp) - len, "-%u\n", oe->oe_ip.v6.port);
-        str = tmp;
-        break;
-    }
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
-    case GATT:
-        snprintf(tmp, sizeof(tmp), "ble %u\n", oe->oe_ble.conn_handle);
-        str = tmp;
-        break;
-#endif
-#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
-    case SERIAL:
-        str = "serial\n";
-        break;
-#endif
-    case MULTICAST:
-        str = "multicast\n";
-        break;
-    default:
-        str = "<unkwn>\n";
-        break;
+    if (oe->ep.oe_flags & OC_ENDPOINT_MULTICAST) {
+        str = "multicast";
+    } else {
+        ot = oc_transports[oe->ep.oe_type];
+        if (ot) {
+            str = ot->ot_ep_str(tmp, sizeof(tmp), oe);
+        } else {
+            str = "<unkwn>";
+        }
     }
     log_printf(&oc_log, LOG_MODULE_IOTIVITY, lvl, str);
 }
diff --git a/net/oic/src/port/mynewt/lora_adaptor.c b/net/oic/src/port/mynewt/lora_adaptor.c
index a5f1fd06c..f96197c68 100644
--- a/net/oic/src/port/mynewt/lora_adaptor.c
+++ b/net/oic/src/port/mynewt/lora_adaptor.c
@@ -17,10 +17,12 @@
  * under the License.
  */
 
-#include <syscfg/syscfg.h>
-#if MYNEWT_VAL(OC_TRANSPORT_LORA)
 #include <assert.h>
 #include <string.h>
+#include <stdint.h>
+
+#include <syscfg/syscfg.h>
+#if MYNEWT_VAL(OC_TRANSPORT_LORA)
 
 #include <os/os.h>
 #include <os/endian.h>
@@ -31,15 +33,35 @@
 
 #include <node/lora.h>
 
-#include "port/oc_connectivity.h"
+#include "oic/port/oc_connectivity.h"
 #include "oic/oc_log.h"
 #include "api/oc_buffer.h"
 #include "adaptor.h"
+#include "oic/port/mynewt/transport.h"
+#include "oic/port/mynewt/lora.h"
 
 #ifdef OC_SECURITY
 #error This implementation does not yet support security
 #endif
 
+static void oc_send_buffer_lora(struct os_mbuf *m);
+static char *oc_log_ep_lora(char *ptr, int maxlen, const struct oc_endpoint *);
+static int oc_connectivity_init_lora(void);
+void oc_connectivity_shutdown_lora(void);
+
+static const struct oc_transport oc_lora_transport = {
+    .ot_ep_size = sizeof(struct oc_endpoint_lora),
+    .ot_flags = 0,
+    .ot_tx_ucast = oc_send_buffer_lora,
+    .ot_tx_mcast = oc_send_buffer_lora,
+    .ot_get_trans_security = NULL,
+    .ot_ep_str = oc_log_ep_lora,
+    .ot_init = oc_connectivity_init_lora,
+    .ot_shutdown = oc_connectivity_shutdown_lora
+};
+
+static uint8_t oc_lora_transport_id;
+
 STATS_SECT_START(oc_lora_stats)
     STATS_SECT_ENTRY(iframe)
     STATS_SECT_ENTRY(ibytes)
@@ -93,6 +115,15 @@ struct coap_lora_frag {
     uint8_t frag_num;	/* which fragment within packet */
 };
 
+static char *
+oc_log_ep_lora(char *ptr, int maxlen, const struct oc_endpoint *oe)
+{
+    struct oc_endpoint_lora *oe_lora = (struct oc_endpoint_lora *)oe;
+
+    snprintf(ptr, maxlen, "lora %u", oe_lora->port);
+    return ptr;
+}
+
 void
 oc_send_frag_lora(struct oc_lora_state *os)
 {
@@ -260,7 +291,8 @@ oc_lora_deliver(struct oc_lora_state *os)
         m = n;
     }
     oe = (struct oc_endpoint_lora *)OC_MBUF_ENDPOINT(m);
-    oe->flags = LORA;
+    oe->ep.oe_type = oc_lora_transport_id;
+    oe->ep.oe_flags = 0;
     oe->port = os->rx_port;
 
     /*
@@ -384,5 +416,12 @@ oc_connectivity_init_lora(void)
     }
     return 0;
 }
+#endif
 
+void
+oc_register_lora(void)
+{
+#if (MYNEWT_VAL(OC_TRANSPORT_LORA) == 1)
+    oc_lora_transport_id = oc_transport_register(&oc_lora_transport);
 #endif
+}
diff --git a/net/oic/src/port/mynewt/serial_adaptor.c b/net/oic/src/port/mynewt/serial_adaptor.c
index 6e6450b49..4cc4d1f44 100644
--- a/net/oic/src/port/mynewt/serial_adaptor.c
+++ b/net/oic/src/port/mynewt/serial_adaptor.c
@@ -17,11 +17,12 @@
  * under the License.
  */
 
+#include <assert.h>
+#include <stdint.h>
+
 #include <syscfg/syscfg.h>
 #if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
 
-#include <assert.h>
-
 #include <os/os.h>
 
 #include <shell/shell.h>
@@ -30,11 +31,34 @@
 #include "port/oc_connectivity.h"
 #include "oic/oc_log.h"
 #include "adaptor.h"
-
-struct os_mqueue oc_serial_mqueue;
-
+#include "oic/port/mynewt/transport.h"
+
+static void oc_send_buffer_serial(struct os_mbuf *m);
+static char *oc_log_ep_serial(char *ptr, int max, const struct oc_endpoint *);
+static int oc_connectivity_init_serial(void);
+void oc_connectivity_shutdown_serial(void);
+
+static const struct oc_transport oc_serial_transport = {
+    .ot_ep_size = sizeof(struct oc_endpoint_plain),
+    .ot_flags = 0,
+    .ot_tx_ucast = oc_send_buffer_serial,
+    .ot_tx_mcast = oc_send_buffer_serial,
+    .ot_get_trans_security = NULL,
+    .ot_ep_str = oc_log_ep_serial,
+    .ot_init = oc_connectivity_init_serial,
+    .ot_shutdown = oc_connectivity_shutdown_serial
+};
+
+static uint8_t oc_serial_transport_id;
+static struct os_mqueue oc_serial_mqueue;
 static struct os_mbuf *oc_attempt_rx_serial(void);
 
+static char *
+oc_log_ep_serial(char *ptr, int max, const struct oc_endpoint *oe)
+{
+    return "serial";
+}
+
 static int
 oc_serial_in(struct os_mbuf *m, void *arg)
 {
@@ -94,7 +118,7 @@ oc_attempt_rx_serial(void)
 {
     struct os_mbuf *m;
     struct os_mbuf *n;
-    struct oc_endpoint *oe;
+    struct oc_endpoint_plain *oe_plain;
 
     /* get an mbuf from the queue */
     n = os_mqueue_get(&oc_serial_mqueue);
@@ -110,8 +134,9 @@ oc_attempt_rx_serial(void)
     OS_MBUF_PKTHDR(m)->omp_len = OS_MBUF_PKTHDR(n)->omp_len;
     SLIST_NEXT(m, om_next) = n;
 
-    oe = OC_MBUF_ENDPOINT(m);
-    oe->oe.flags = SERIAL;
+    oe_plain = (struct oc_endpoint_plain *)OC_MBUF_ENDPOINT(m);
+    oe_plain->ep.oe_type = oc_serial_transport_id;
+    oe_plain->ep.oe_flags = 0;
 
     return m;
 
@@ -119,4 +144,13 @@ oc_attempt_rx_serial(void)
     os_mbuf_free_chain(n);
     return NULL;
 }
+
+#endif
+
+void
+oc_register_serial(void)
+{
+#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
+    oc_serial_transport_id = oc_transport_register(&oc_serial_transport);
 #endif
+}
diff --git a/net/oic/src/security/oc_acl.c b/net/oic/src/security/oc_acl.c
index 173873b00..93769d0ff 100644
--- a/net/oic/src/security/oc_acl.c
+++ b/net/oic/src/security/oc_acl.c
@@ -36,348 +36,377 @@ static oc_sec_acl_t ac_list = { 0 };
 static void
 get_sub_perm_groups(oc_sec_ace_t *ace, uint16_t *groups, int *n)
 {
-  int i = 0, j;
-  oc_sec_acl_res_t *res = oc_list_head(ace->resources);
-  while (res != NULL) {
-    groups[i++] = res->permissions;
-    res = res->next;
-  }
-  for (i = 0; i < (*n - 1); i++) {
-    for (j = (i + 1); j < *n; j++) {
-      if (groups[i] > groups[j]) {
-        uint16_t t = groups[i];
-        groups[i] = groups[j];
-        groups[j] = t;
-      }
+    int i = 0, j;
+    oc_sec_acl_res_t *res = oc_list_head(ace->resources);
+
+    while (res != NULL) {
+        groups[i++] = res->permissions;
+        res = res->next;
     }
-  }
-  j = 0;
-  for (i = 1; i < *n; i++) {
-    if (groups[j] != groups[i])
-      groups[++j] = groups[i];
-  }
-  *n = j + 1;
+    for (i = 0; i < (*n - 1); i++) {
+        for (j = (i + 1); j < *n; j++) {
+            if (groups[i] > groups[j]) {
+                uint16_t t = groups[i];
+                groups[i] = groups[j];
+                groups[j] = t;
+            }
+        }
+    }
+    j = 0;
+    for (i = 1; i < *n; i++) {
+        if (groups[j] != groups[i])
+            groups[++j] = groups[i];
+    }
+    *n = j + 1;
 }
 
 void
 oc_sec_encode_acl(void)
 {
-  int i, n;
-  char uuid[37];
-  oc_rep_start_root_object();
-  oc_process_baseline_interface(oc_core_get_resource_by_index(OCF_SEC_ACL));
-  oc_rep_set_object(root, aclist);
-  oc_rep_set_array(aclist, aces);
-  oc_sec_ace_t *sub = oc_list_head(ac_list.subjects);
-  while (sub != NULL) {
-    if (strncmp(sub->subjectuuid.id, WILDCARD.id, 16) == 0) {
-      uuid[0] = '*';
-      uuid[1] = '\0';
-    } else {
-      oc_uuid_to_str(&sub->subjectuuid, uuid, 37);
-    }
-    LOG("oc_sec_acl_encode: subject %s\n", uuid);
-    n = oc_list_length(sub->resources);
-    uint16_t groups[n];
-    get_sub_perm_groups(sub, groups, &n);
-    for (i = 0; i < n; i++) {
-      oc_rep_object_array_start_item(aces);
-      oc_rep_set_text_string(aces, subjectuuid, uuid);
-      oc_rep_set_uint(aces, permission, groups[i]);
-      oc_rep_set_array(aces, resources);
-      oc_sec_acl_res_t *res = oc_list_head(sub->resources);
-      while (res != NULL) {
-        if (res->permissions == groups[i]) {
-          LOG("oc_sec_acl_encode: adding resource %s\n",
-              oc_string(res->resource->uri));
-          oc_rep_object_array_start_item(resources);
-          oc_rep_set_text_string(resources, href,
-                                 oc_string(res->resource->uri));
-          oc_rep_set_text_string(resources, rel, "");
-          oc_rep_set_text_string(resources, rt, "");
-          oc_rep_set_text_string(resources, if, "");
-          oc_rep_object_array_end_item(resources);
+    int i, n;
+    char uuid[37];
+
+    oc_rep_start_root_object();
+    oc_process_baseline_interface(oc_core_get_resource_by_index(OCF_SEC_ACL));
+    oc_rep_set_object(root, aclist);
+    oc_rep_set_array(aclist, aces);
+    oc_sec_ace_t *sub = oc_list_head(ac_list.subjects);
+    while (sub != NULL) {
+        if (strncmp(sub->subjectuuid.id, WILDCARD.id, 16) == 0) {
+            uuid[0] = '*';
+            uuid[1] = '\0';
+        } else {
+            oc_uuid_to_str(&sub->subjectuuid, uuid, 37);
         }
-        res = res->next;
-      }
-      oc_rep_close_array(aces, resources);
-      oc_rep_object_array_end_item(aces);
+        LOG("oc_sec_acl_encode: subject %s\n", uuid);
+        n = oc_list_length(sub->resources);
+        uint16_t groups[n];
+        get_sub_perm_groups(sub, groups, &n);
+        for (i = 0; i < n; i++) {
+            oc_rep_object_array_start_item(aces);
+            oc_rep_set_text_string(aces, subjectuuid, uuid);
+            oc_rep_set_uint(aces, permission, groups[i]);
+            oc_rep_set_array(aces, resources);
+            oc_sec_acl_res_t *res = oc_list_head(sub->resources);
+            while (res != NULL) {
+                if (res->permissions == groups[i]) {
+                    LOG("oc_sec_acl_encode: adding resource %s\n",
+                      oc_string(res->resource->uri));
+                    oc_rep_object_array_start_item(resources);
+                    oc_rep_set_text_string(resources, href,
+                                           oc_string(res->resource->uri));
+                    oc_rep_set_text_string(resources, rel, "");
+                    oc_rep_set_text_string(resources, rt, "");
+                    oc_rep_set_text_string(resources, if, "");
+                    oc_rep_object_array_end_item(resources);
+                }
+                res = res->next;
+            }
+            oc_rep_close_array(aces, resources);
+            oc_rep_object_array_end_item(aces);
+        }
+        sub = sub->next;
     }
-    sub = sub->next;
-  }
-  oc_rep_close_array(aclist, aces);
-  oc_rep_close_object(root, aclist);
-  oc_uuid_to_str(&ac_list.rowneruuid, uuid, 37);
-  oc_rep_set_text_string(root, rowneruuid, uuid);
-  oc_rep_end_root_object();
+    oc_rep_close_array(aclist, aces);
+    oc_rep_close_object(root, aclist);
+    oc_uuid_to_str(&ac_list.rowneruuid, uuid, 37);
+    oc_rep_set_text_string(root, rowneruuid, uuid);
+    oc_rep_end_root_object();
 }
 
 static oc_sec_acl_res_t *
 oc_sec_acl_get_ace(oc_uuid_t *subjectuuid, oc_resource_t *resource, bool create)
 {
-  oc_sec_ace_t *ace = (oc_sec_ace_t *)oc_list_head(ac_list.subjects);
-  oc_sec_acl_res_t *res = NULL;
-
+    oc_sec_ace_t *ace = (oc_sec_ace_t *)oc_list_head(ac_list.subjects);
+    oc_sec_acl_res_t *res = NULL;
 #ifdef DEBUG
-  char uuid[37];
-  oc_uuid_to_str(subjectuuid, uuid, 37);
-#endif
+    char uuid[37];
 
-  while (ace != NULL) {
-    if (strncmp(ace->subjectuuid.id, subjectuuid->id, 16) == 0)
-      goto got_ace;
-    ace = oc_list_item_next(ace);
-  }
+    oc_uuid_to_str(subjectuuid, uuid, 37);
+#endif
 
-  if (create)
-    goto new_ace;
+    while (ace != NULL) {
+        if (strncmp(ace->subjectuuid.id, subjectuuid->id, 16) == 0) {
+            goto got_ace;
+        }
+        ace = oc_list_item_next(ace);
+    }
 
-  LOG("Could not find ACE for subject %s\n", uuid);
+    if (create) {
+        goto new_ace;
+    }
+    LOG("Could not find ACE for subject %s\n", uuid);
 
-  goto done;
+    goto done;
 
 got_ace:
-  LOG("Found ACE for subject %s\n", uuid);
-  res = (oc_sec_acl_res_t *)oc_list_head(ace->resources);
-
-  while (res != NULL) {
-    if (res->resource == resource) {
-      LOG("Found permissions mask for resource %s in ACE\n",
-          oc_string(res->resource->uri));
-      goto done;
+    LOG("Found ACE for subject %s\n", uuid);
+    res = (oc_sec_acl_res_t *)oc_list_head(ace->resources);
+
+    while (res != NULL) {
+        if (res->resource == resource) {
+            LOG("Found permissions mask for resource %s in ACE\n",
+                oc_string(res->resource->uri));
+            goto done;
+        }
+        res = oc_list_item_next(res);
     }
-    res = oc_list_item_next(res);
-  }
 
-  if (create)
-    goto new_res;
+    if (create) {
+        goto new_res;
+    }
 
-  goto done;
+    goto done;
 
 new_ace:
-  ace = oc_memb_alloc(&ace_l);
+    ace = oc_memb_alloc(&ace_l);
 
-  if (!ace)
-    goto done;
+    if (!ace) {
+        goto done;
+    }
 
-  LOG("Created new ACE for subject %s\n", uuid);
+    LOG("Created new ACE for subject %s\n", uuid);
 
-  OC_LIST_STRUCT_INIT(ace, resources);
-  strncpy(ace->subjectuuid.id, subjectuuid->id, 16);
-  oc_list_add(ac_list.subjects, ace);
+    OC_LIST_STRUCT_INIT(ace, resources);
+    strncpy(ace->subjectuuid.id, subjectuuid->id, 16);
+    oc_list_add(ac_list.subjects, ace);
 
 new_res:
-  res = oc_memb_alloc(&res_l);
-  if (res) {
-    res->resource = resource;
-    LOG("Adding new resource %s to ACE\n", oc_string(res->resource->uri));
-    oc_list_add(ace->resources, res);
-  }
+    res = oc_memb_alloc(&res_l);
+    if (res) {
+        res->resource = resource;
+        LOG("Adding new resource %s to ACE\n", oc_string(res->resource->uri));
+        oc_list_add(ace->resources, res);
+    }
 
 done:
-  return res;
+    return res;
 }
 
 static bool
 oc_sec_update_acl(oc_uuid_t *subjectuuid, oc_resource_t *resource,
                   uint16_t permissions)
 {
-  oc_sec_acl_res_t *res = oc_sec_acl_get_ace(subjectuuid, resource, true);
+    oc_sec_acl_res_t *res = oc_sec_acl_get_ace(subjectuuid, resource, true);
 
-  if (!res)
-    return false;
+    if (!res) {
+        return false;
+    }
 
-  res->permissions = permissions;
+    res->permissions = permissions;
 
-  LOG("Added resource with permissions: %d\n", res->permissions);
+    LOG("Added resource with permissions: %d\n", res->permissions);
 
-  return true;
+    return true;
 }
 
 void
 oc_sec_acl_init(void)
 {
-  OC_LIST_STRUCT_INIT(&ac_list, subjects);
+    OC_LIST_STRUCT_INIT(&ac_list, subjects);
 }
 
 void
 oc_sec_acl_default(void)
 {
-  bool success = true;
-  int i;
-  oc_resource_t *resource;
-  for (i = 0; i < NUM_OC_CORE_RESOURCES; i++) {
-    resource = oc_core_get_resource_by_index(i);
-    if (i < OCF_SEC_DOXM || i > OCF_SEC_CRED)
-      success &= oc_sec_update_acl(&WILDCARD, resource, 2);
-    else
-      success &= oc_sec_update_acl(&WILDCARD, resource, 6);
-  }
-  LOG("ACL for core resources initialized %d\n", success);
-  oc_uuid_t *device = oc_core_get_device_id(0);
-  memcpy(&ac_list.rowneruuid, device, sizeof(oc_uuid_t));
+    bool success = true;
+    int i;
+    oc_resource_t *resource;
+    oc_uuid_t *device;
+
+    for (i = 0; i < NUM_OC_CORE_RESOURCES; i++) {
+        resource = oc_core_get_resource_by_index(i);
+        if (i < OCF_SEC_DOXM || i > OCF_SEC_CRED) {
+            success &= oc_sec_update_acl(&WILDCARD, resource, 2);
+        } else {
+            success &= oc_sec_update_acl(&WILDCARD, resource, 6);
+        }
+    }
+    LOG("ACL for core resources initialized %d\n", success);
+    device = oc_core_get_device_id(0);
+    memcpy(&ac_list.rowneruuid, device, sizeof(oc_uuid_t));
 }
 
 bool
 oc_sec_check_acl(oc_method_t method, oc_resource_t *resource,
                  oc_endpoint_t *endpoint)
 {
-  bool granted = false;
-  oc_sec_acl_res_t *res = NULL;
-  oc_uuid_t *identity = (oc_uuid_t *)oc_sec_dtls_get_peer_uuid(endpoint);
-
-  if (identity) {
-    res = oc_sec_acl_get_ace(identity, resource, false);
-  }
-
-  if (!res) { // Try Anonymous
-    res = oc_sec_acl_get_ace(&WILDCARD, resource, false);
-  }
+    bool granted = false;
+    oc_sec_acl_res_t *res = NULL;
+    oc_uuid_t *identity = (oc_uuid_t *)oc_sec_dtls_get_peer_uuid(endpoint);
 
-  if (!res)
-    return granted;
+    if (identity) {
+        res = oc_sec_acl_get_ace(identity, resource, false);
+    }
 
-  LOG("Got permissions mask %d\n", res->permissions);
+    if (!res) { // Try Anonymous
+        res = oc_sec_acl_get_ace(&WILDCARD, resource, false);
+    }
 
-  if (res->permissions & OC_PERM_CREATE || res->permissions & OC_PERM_UPDATE) {
-    switch (method) {
-    case OC_PUT:
-    case OC_POST:
-      granted = true;
-      break;
-    default:
-      break;
+    if (!res) {
+        return granted;
+    }
+    LOG("Got permissions mask %d\n", res->permissions);
+
+    if (res->permissions & OC_PERM_CREATE ||
+        res->permissions & OC_PERM_UPDATE) {
+        switch (method) {
+        case OC_PUT:
+        case OC_POST:
+            granted = true;
+            break;
+        default:
+            break;
+        }
     }
-  }
 
-  if (res->permissions & OC_PERM_RETRIEVE ||
-      res->permissions & OC_PERM_NOTIFY) {
-    switch (method) {
-    case OC_GET:
-      granted = true;
-      break;
-    default:
-      break;
+    if (res->permissions & OC_PERM_RETRIEVE ||
+        res->permissions & OC_PERM_NOTIFY) {
+        switch (method) {
+        case OC_GET:
+            granted = true;
+            break;
+        default:
+            break;
+        }
     }
-  }
 
-  if (res->permissions & OC_PERM_DELETE) {
-    switch (method) {
-    case OC_DELETE:
-      granted = true;
-      break;
-    default:
-      break;
+    if (res->permissions & OC_PERM_DELETE) {
+        switch (method) {
+        case OC_DELETE:
+            granted = true;
+            break;
+        default:
+            break;
+        }
     }
-  }
 
-  return granted;
+    return granted;
 }
 
 bool
 oc_sec_decode_acl(oc_rep_t *rep)
 {
-  uint16_t permissions = 0;
-  oc_uuid_t subjectuuid;
-  oc_rep_t *resources = 0;
-  int len = 0;
-  while (rep != NULL) {
-    len = oc_string_len(rep->name);
-    switch (rep->type) {
-    case STRING:
-      if (len == 10 && strncmp(oc_string(rep->name), "rowneruuid", 10) == 0) {
-        oc_str_to_uuid(oc_string(rep->value_string), &ac_list.rowneruuid);
-      }
-      break;
-    case OBJECT: {
-      oc_rep_t *aclist = rep->value_object;
-      while (aclist != NULL) {
-        switch (aclist->type) {
-        case OBJECT_ARRAY: {
-          oc_rep_t *aces = aclist->value_object_array;
-          while (aces != NULL) {
-            oc_rep_t *ace = aces->value_object;
-            while (ace != NULL) {
-              len = oc_string_len(ace->name);
-              switch (ace->type) {
-              case STRING:
-                if (len == 11 &&
-                    strncmp(oc_string(ace->name), "subjectuuid", 11) == 0) {
-                  if (strncmp(oc_string(ace->value_string), "*", 1) == 0)
-                    strncpy(subjectuuid.id, WILDCARD.id, 16);
-                  else
-                    oc_str_to_uuid(oc_string(ace->value_string), &subjectuuid);
-                }
-                break;
-              case INT:
-                if (len == 10 &&
-                    strncmp(oc_string(ace->name), "permission", 10) == 0)
-                  permissions = ace->value_int;
-                break;
-              case OBJECT_ARRAY:
-                if (len == 9 &&
-                    strncmp(oc_string(ace->name), "resources", 9) == 0)
-                  resources = ace->value_object_array;
-                break;
-              default:
-                break;
-              }
-              ace = ace->next;
+    uint16_t permissions = 0;
+    oc_uuid_t subjectuuid;
+    oc_rep_t *resources = 0;
+    int len = 0;
+
+    while (rep != NULL) {
+        len = oc_string_len(rep->name);
+        switch (rep->type) {
+        case STRING:
+            if (len == 10 &&
+                strncmp(oc_string(rep->name), "rowneruuid", 10) == 0) {
+                oc_str_to_uuid(oc_string(rep->value_string),
+                               &ac_list.rowneruuid);
             }
-
-            while (resources != NULL) {
-              oc_rep_t *resource = resources->value_object;
-              while (resource != NULL) {
-                switch (resource->type) {
-                case STRING:
-                  if (oc_string_len(resource->name) == 4 &&
-                      strncasecmp(oc_string(resource->name), "href", 4) == 0) {
-                    oc_resource_t *res = oc_core_get_resource_by_uri(
-                      oc_string(resource->value_string));
+            break;
+        case OBJECT: {
+            oc_rep_t *aclist = rep->value_object;
+
+            while (aclist != NULL) {
+                switch (aclist->type) {
+                case OBJECT_ARRAY: {
+                    oc_rep_t *aces = aclist->value_object_array;
+                    while (aces != NULL) {
+                        oc_rep_t *ace = aces->value_object;
+                        while (ace != NULL) {
+                            len = oc_string_len(ace->name);
+                            switch (ace->type) {
+                            case STRING:
+                                if (len == 11 &&
+                                    strncmp(oc_string(ace->name), "subjectuuid",
+                                          11) == 0) {
+                                    if (strncmp(oc_string(ace->value_string),
+                                                "*", 1) == 0) {
+                                        strncpy(subjectuuid.id, WILDCARD.id,
+                                                16);
+                                    } else {
+                                        oc_str_to_uuid(oc_string(
+                                            ace->value_string), &subjectuuid);
+                                    }
+                                }
+                                break;
+                            case INT:
+                                if (len == 10 &&
+                                    strncmp(oc_string(ace->name), "permission",
+                                          10) == 0) {
+                                    permissions = ace->value_int;
+                                }
+                                break;
+                            case OBJECT_ARRAY:
+                                if (len == 9 &&
+                                    strncmp(oc_string(ace->name), "resources",
+                                          9) == 0) {
+                                    resources = ace->value_object_array;
+                                }
+                                break;
+                            default:
+                                break;
+                            }
+                            ace = ace->next;
+                        }
+
+                        while (resources != NULL) {
+                            oc_rep_t *resource = resources->value_object;
+                            while (resource != NULL) {
+                                switch (resource->type) {
+                                case STRING:
+                                    if (oc_string_len(resource->name) == 4 &&
+                                        strncasecmp(oc_string(resource->name),
+                                                    "href", 4) == 0) {
+                                        oc_resource_t *res;
+                                        res = oc_core_get_resource_by_uri(
+                                          oc_string(resource->value_string));
 
 #ifdef OC_SERVER
-                    if (!res)
-                      res = oc_ri_get_app_resource_by_uri(
-                        oc_string(resource->value_string));
+                                        if (!res) {
+                                            res = oc_ri_get_app_resource_by_uri(
+                                             oc_string(resource->value_string));
+                                        }
 #endif /* OC_SERVER */
-
-                    if (!res) {
-                      LOG(
-                        "\n\noc_sec_acl_decode: could not find resource %s\n\n",
-                        oc_string(resource->value_string));
-                      return false;
-                    }
-
-                    if (!oc_sec_update_acl(&subjectuuid, res, permissions)) {
-                      LOG("\n\noc_sec_acl_decode: could not update ACE with "
-                          "resource %s permissions\n\n",
-                          oc_string(res->uri));
-                      return false;
+                                        if (!res) {
+                                            LOG("\n\noc_sec_acl_decode: could "
+                                                "not find resource %s\n\n",
+                                             oc_string(resource->value_string));
+                                            return false;
+                                        }
+
+                                        if (!oc_sec_update_acl(&subjectuuid,
+                                                               res,
+                                                               permissions)) {
+                                            LOG("\n\noc_sec_acl_decode: could "
+                                                "not update ACE with "
+                                                "resource %s permissions\n\n",
+                                              oc_string(res->uri));
+                                            return false;
+                                        }
+                                    }
+                                    break;
+                                default:
+                                    break;
+                                }
+                                resource = resource->next;
+                            }
+                            resources = resources->next;
+                        }
+                        aces = aces->next;
                     }
-                  }
-                  break;
+                } break;
                 default:
-                  break;
+                    break;
                 }
-                resource = resource->next;
-              }
-              resources = resources->next;
+                aclist = aclist->next;
             }
-            aces = aces->next;
-          }
-        } break;
+        }
+            break;
         default:
-          break;
+            break;
         }
-        aclist = aclist->next;
-      }
-    } break;
-    default:
-      break;
+        rep = rep->next;
     }
-    rep = rep->next;
-  }
-  return true;
+    return true;
 }
 
 /*
@@ -403,10 +432,11 @@ oc_sec_decode_acl(oc_rep_t *rep)
 void
 post_acl(oc_request_t *request, oc_interface_mask_t interface)
 {
-  if (oc_sec_decode_acl(request->request_payload))
-    oc_send_response(request, OC_STATUS_CREATED);
-  else
-    oc_send_response(request, OC_STATUS_INTERNAL_SERVER_ERROR);
+    if (oc_sec_decode_acl(request->request_payload)) {
+        oc_send_response(request, OC_STATUS_CREATED);
+    } else {
+        oc_send_response(request, OC_STATUS_INTERNAL_SERVER_ERROR);
+    }
 }
 
 #endif /* OC_SECURITY */
diff --git a/net/oic/src/security/oc_acl.h b/net/oic/src/security/oc_acl.h
index 17f556013..f6140a06d 100644
--- a/net/oic/src/security/oc_acl.h
+++ b/net/oic/src/security/oc_acl.h
@@ -28,32 +28,29 @@
 extern "C" {
 #endif
 
-typedef enum {
-  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)
+typedef enum oc_sec_acl_permissions_mask {
+    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_sec_acl_permissions_mask_t;
 
-typedef struct
-{
-  OC_LIST_STRUCT(subjects);
-  oc_uuid_t rowneruuid;
+typedef struct oc_sec_acl {
+    OC_LIST_STRUCT(subjects);
+    oc_uuid_t rowneruuid;
 } oc_sec_acl_t;
 
-typedef struct oc_sec_acl_res_s
-{
-  struct oc_sec_acl_res_s *next;
-  oc_resource_t *resource;
-  uint16_t permissions;
+typedef struct oc_sec_acl_res {
+    struct oc_sec_acl_res_s *next;
+    oc_resource_t *resource;
+    uint16_t permissions;
 } oc_sec_acl_res_t;
 
-typedef struct oc_sec_ace_s
-{
-  struct oc_sec_ace_s *next;
-  OC_LIST_STRUCT(resources);
-  oc_uuid_t subjectuuid;
+typedef struct oc_sec_ace {
+    struct oc_sec_ace_s *next;
+    OC_LIST_STRUCT(resources);
+    oc_uuid_t subjectuuid;
 } oc_sec_ace_t;
 
 void oc_sec_acl_default(void);
diff --git a/net/oic/src/security/oc_cred.c b/net/oic/src/security/oc_cred.c
index 2cccf7115..3fef4d82c 100644
--- a/net/oic/src/security/oc_cred.c
+++ b/net/oic/src/security/oc_cred.c
@@ -33,168 +33,184 @@ OC_MEMB(creds, oc_sec_cred_t, MAX_NUM_SUBJECTS + 1);
 oc_sec_cred_t *
 oc_sec_find_cred(oc_uuid_t *subjectuuid)
 {
-  oc_sec_cred_t *cred = oc_list_head(creds_l);
-  while (cred != NULL) {
-    if (strncmp(cred->subjectuuid.id, subjectuuid->id, 16) == 0) {
-      return cred;
+    oc_sec_cred_t *cred = oc_list_head(creds_l);
+
+    while (cred != NULL) {
+        if (strncmp(cred->subjectuuid.id, subjectuuid->id, 16) == 0) {
+            return cred;
+        }
+        cred = cred->next;
     }
-    cred = cred->next;
-  }
-  return NULL;
+    return NULL;
 }
 
 oc_sec_cred_t *
 oc_sec_get_cred(oc_uuid_t *subjectuuid)
 {
-  oc_sec_cred_t *cred = oc_sec_find_cred(subjectuuid);
-  if (cred == NULL) {
-    cred = oc_memb_alloc(&creds);
-    strncpy(cred->subjectuuid.id, subjectuuid->id, 16);
-    oc_list_add(creds_l, cred);
-  }
-  return cred;
+    oc_sec_cred_t *cred = oc_sec_find_cred(subjectuuid);
+
+    if (cred == NULL) {
+        cred = oc_memb_alloc(&creds);
+        strncpy(cred->subjectuuid.id, subjectuuid->id, 16);
+        oc_list_add(creds_l, cred);
+    }
+    return cred;
 }
 
 void
 oc_sec_encode_cred(void)
 {
-  oc_sec_cred_t *creds = oc_list_head(creds_l);
-  char uuid[37];
-  oc_rep_start_root_object();
-  oc_process_baseline_interface(oc_core_get_resource_by_index(OCF_SEC_CRED));
-  oc_rep_set_array(root, creds);
-  if (creds == NULL) {
-    oc_rep_object_array_start_item(creds);
-    oc_rep_object_array_end_item(creds);
-  }
-  while (creds != NULL) {
-    oc_rep_object_array_start_item(creds);
-    oc_rep_set_int(creds, credid, creds->credid);
-    oc_rep_set_int(creds, credtype, creds->credtype);
-    oc_uuid_to_str(&creds->subjectuuid, uuid, 37);
-    oc_rep_set_text_string(creds, subjectuuid, uuid);
-    oc_rep_set_object(creds, privatedata);
-    oc_rep_set_byte_string(privatedata, data, creds->key);
-    oc_rep_set_text_string(privatedata, encoding, "oic.sec.encoding.raw");
-    oc_rep_close_object(creds, privatedata);
-    oc_rep_object_array_end_item(creds);
-    creds = creds->next;
-  }
-  oc_rep_close_array(root, creds);
-  oc_rep_end_root_object();
+    oc_sec_cred_t *creds = oc_list_head(creds_l);
+    char uuid[37];
+
+    oc_rep_start_root_object();
+    oc_process_baseline_interface(oc_core_get_resource_by_index(OCF_SEC_CRED));
+    oc_rep_set_array(root, creds);
+    if (creds == NULL) {
+        oc_rep_object_array_start_item(creds);
+        oc_rep_object_array_end_item(creds);
+    }
+    while (creds != NULL) {
+        oc_rep_object_array_start_item(creds);
+        oc_rep_set_int(creds, credid, creds->credid);
+        oc_rep_set_int(creds, credtype, creds->credtype);
+        oc_uuid_to_str(&creds->subjectuuid, uuid, 37);
+        oc_rep_set_text_string(creds, subjectuuid, uuid);
+        oc_rep_set_object(creds, privatedata);
+        oc_rep_set_byte_string(privatedata, data, creds->key);
+        oc_rep_set_text_string(privatedata, encoding, "oic.sec.encoding.raw");
+        oc_rep_close_object(creds, privatedata);
+        oc_rep_object_array_end_item(creds);
+        creds = creds->next;
+    }
+    oc_rep_close_array(root, creds);
+    oc_rep_end_root_object();
 }
 
 bool
 oc_sec_decode_cred(oc_rep_t *rep, oc_sec_cred_t **owner)
 {
-  oc_sec_doxm_t *doxm = oc_sec_get_doxm();
-  int credid = 0, credtype = 0;
-  char subjectuuid[37] = { 0 };
-  oc_uuid_t subject;
-  oc_sec_cred_t *credobj;
-  bool got_key = false;
-  int len = 0;
-  uint8_t key[16];
-  while (rep != NULL) {
-    len = oc_string_len(rep->name);
-    switch (rep->type) {
-    case STRING:
-      if (len == 10 && strncmp(oc_string(rep->name), "rowneruuid", 10) == 0) {
-        oc_str_to_uuid(oc_string(rep->value_string), &doxm->rowneruuid);
-      }
-      break;
-    case OBJECT_ARRAY: {
-      oc_rep_t *creds_array = rep->value_object_array;
-      while (creds_array != NULL) {
-        oc_rep_t *cred = creds_array->value_object;
-        bool valid_cred = false;
-        while (cred != NULL) {
-          len = oc_string_len(cred->name);
-          valid_cred = true;
-          switch (cred->type) {
-          case INT:
-            if (len == 6 && strncmp(oc_string(cred->name), "credid", 6) == 0)
-              credid = cred->value_int;
-            else if (len == 8 &&
-                     strncmp(oc_string(cred->name), "credtype", 8) == 0)
-              credtype = cred->value_int;
-            break;
-          case STRING:
-            if (len == 11 &&
-                strncmp(oc_string(cred->name), "subjectuuid", 11) == 0) {
-              strncpy(subjectuuid, oc_string(cred->value_string),
-                      oc_string_len(cred->value_string) + 1);
+    oc_sec_doxm_t *doxm = oc_sec_get_doxm();
+    int credid = 0, credtype = 0;
+    char subjectuuid[37] = { 0 };
+    oc_uuid_t subject;
+    oc_sec_cred_t *credobj;
+    bool got_key = false;
+    int len = 0;
+    uint8_t key[16];
+
+    while (rep != NULL) {
+        len = oc_string_len(rep->name);
+        switch (rep->type) {
+        case STRING:
+            if (len == 10 &&
+                strncmp(oc_string(rep->name), "rowneruuid", 10) == 0) {
+                oc_str_to_uuid(oc_string(rep->value_string), &doxm->rowneruuid);
             }
             break;
-          case OBJECT: {
-            oc_rep_t *data = cred->value_object;
-            while (data != NULL) {
-              switch (data->type) {
-              case BYTE_STRING: {
-                got_key = true;
-                int psk = 0;
-                uint8_t *p = oc_cast(data->value_string, uint8_t);
-                size_t size = oc_string_len(data->value_string);
-                if (size != 16) {
-                  return false;
+        case OBJECT_ARRAY: {
+            oc_rep_t *creds_array = rep->value_object_array;
+            while (creds_array != NULL) {
+                oc_rep_t *cred = creds_array->value_object;
+                bool valid_cred = false;
+                while (cred != NULL) {
+                    len = oc_string_len(cred->name);
+                    valid_cred = true;
+                    switch (cred->type) {
+                    case INT:
+                        if (len == 6 &&
+                          strncmp(oc_string(cred->name), "credid", 6) == 0) {
+                            credid = cred->value_int;
+                        } else if (len == 8 &&
+                          strncmp(oc_string(cred->name), "credtype", 8) == 0) {
+                            credtype = cred->value_int;
+                        }
+                        break;
+                    case STRING:
+                        if (len == 11 &&
+                            strncmp(oc_string(cred->name), "subjectuuid",
+                                    11) == 0) {
+                            strncpy(subjectuuid, oc_string(cred->value_string),
+                                    oc_string_len(cred->value_string) + 1);
+                        }
+                        break;
+                    case OBJECT: {
+                        oc_rep_t *data = cred->value_object;
+
+                        while (data != NULL) {
+                            switch (data->type) {
+                            case BYTE_STRING: {
+                                got_key = true;
+                                int psk = 0;
+                                uint8_t *p = oc_cast(data->value_string,
+                                                     uint8_t);
+                                size_t size = oc_string_len(data->value_string);
+                                if (size != 16) {
+                                    return false;
+                                }
+                                while (psk < size) {
+                                    key[psk] = p[psk];
+                                    psk++;
+                                }
+                            }
+                                break;
+                            default:
+                                break;
+                            }
+                            data = data->next;
+                        }
+                    }
+                        break;
+                    default:
+                        break;
+                    }
+                    cred = cred->next;
                 }
-                while (psk < size) {
-                  key[psk] = p[psk];
-                  psk++;
+                if (valid_cred) {
+                    oc_str_to_uuid(subjectuuid, &subject);
+                    credobj = oc_sec_get_cred(&subject);
+                    credobj->credid = credid;
+                    credobj->credtype = credtype;
+
+                    if (got_key) {
+                        memcpy(credobj->key, key, 16);
+                    } else {
+                        if (owner) {
+                            *owner = credobj;
+                        }
+                    }
                 }
-              } break;
-              default:
-                break;
-              }
-              data = data->next;
+                creds_array = creds_array->next;
             }
-          } break;
-          default:
-            break;
-          }
-          cred = cred->next;
         }
-        if (valid_cred) {
-          oc_str_to_uuid(subjectuuid, &subject);
-          credobj = oc_sec_get_cred(&subject);
-          credobj->credid = credid;
-          credobj->credtype = credtype;
-
-          if (got_key) {
-            memcpy(credobj->key, key, 16);
-          } else {
-            if (owner)
-              *owner = credobj;
-          }
+            break;
+        default:
+            break;
         }
-        creds_array = creds_array->next;
-      }
-    } break;
-    default:
-      break;
+        rep = rep->next;
     }
-    rep = rep->next;
-  }
-  return true;
+    return true;
 }
 
 void
 post_cred(oc_request_t *request, oc_interface_mask_t interface)
 {
-  oc_sec_doxm_t *doxm = oc_sec_get_doxm();
-  oc_sec_cred_t *owner = NULL;
-  bool success = oc_sec_decode_cred(request->request_payload, &owner);
-  if (owner && strncmp(owner->subjectuuid.id, doxm->rowneruuid.id, 16) == 0) {
-    oc_uuid_t *dev = oc_core_get_device_id(0);
-    oc_sec_derive_owner_psk(request->origin, OXM_JUST_WORKS,
-                            strlen(OXM_JUST_WORKS), owner->subjectuuid.id, 16,
-                            dev->id, 16, owner->key, 16);
-  }
-  if (!success) {
-    oc_send_response(request, OC_STATUS_BAD_REQUEST);
-  } else {
-    oc_send_response(request, OC_STATUS_CHANGED);
-  }
+    oc_sec_doxm_t *doxm = oc_sec_get_doxm();
+    oc_sec_cred_t *owner = NULL;
+    bool success = oc_sec_decode_cred(request->request_payload, &owner);
+
+    if (owner && strncmp(owner->subjectuuid.id, doxm->rowneruuid.id, 16) == 0) {
+        oc_uuid_t *dev = oc_core_get_device_id(0);
+        oc_sec_derive_owner_psk(request->origin, OXM_JUST_WORKS,
+                                strlen(OXM_JUST_WORKS), owner->subjectuuid.id,
+                                       16,
+                                dev->id, 16, owner->key, 16);
+    }
+    if (!success) {
+        oc_send_response(request, OC_STATUS_BAD_REQUEST);
+    } else {
+        oc_send_response(request, OC_STATUS_CHANGED);
+    }
 }
 
 #endif /* OC_SECURITY */
diff --git a/net/oic/src/security/oc_cred.h b/net/oic/src/security/oc_cred.h
index 106f18ac1..e9c6776d4 100644
--- a/net/oic/src/security/oc_cred.h
+++ b/net/oic/src/security/oc_cred.h
@@ -25,13 +25,12 @@
 extern "C" {
 #endif
 
-typedef struct oc_sec_cred_s
-{
-  struct oc_sec_cred_s *next;
-  int credid;
-  int credtype;
-  oc_uuid_t subjectuuid;
-  uint8_t key[16]; // Supports only 128-bit keys
+typedef struct oc_sec_cred {
+    struct oc_sec_cred_s *next;
+    int credid;
+    int credtype;
+    oc_uuid_t subjectuuid;
+    uint8_t key[16]; // Supports only 128-bit keys
 } oc_sec_cred_t;
 
 void oc_sec_encode_cred(void);
diff --git a/net/oic/src/security/oc_doxm.c b/net/oic/src/security/oc_doxm.c
index ceb604582..925446ff6 100644
--- a/net/oic/src/security/oc_doxm.c
+++ b/net/oic/src/security/oc_doxm.c
@@ -29,100 +29,109 @@ static oc_sec_doxm_t doxm;
 void
 oc_sec_doxm_default(void)
 {
-  doxm.oxmsel = 0;
-  doxm.sct = 1;
-  doxm.owned = false;
-  doxm.dpc = false;
-  oc_uuid_t *deviceuuid = oc_core_get_device_id(0);
-  oc_gen_uuid(deviceuuid);
-  memcpy(&doxm.deviceuuid, deviceuuid, sizeof(oc_uuid_t));
-  memset(doxm.devowneruuid.id, 0, 16);
-  memset(doxm.rowneruuid.id, 0, 16);
+    oc_uuid_t *deviceuuid;
+
+    doxm.oxmsel = 0;
+    doxm.sct = 1;
+    doxm.owned = false;
+    doxm.dpc = false;
+    deviceuuid = oc_core_get_device_id(0);
+    oc_gen_uuid(deviceuuid);
+    memcpy(&doxm.deviceuuid, deviceuuid, sizeof(oc_uuid_t));
+    memset(doxm.devowneruuid.id, 0, 16);
+    memset(doxm.rowneruuid.id, 0, 16);
 }
 
 void
 oc_sec_encode_doxm(void)
 {
-  int oxms[1] = { 0 };
-  char uuid[37];
-  oc_rep_start_root_object();
-  oc_process_baseline_interface(oc_core_get_resource_by_index(OCF_SEC_DOXM));
-  oc_rep_set_int_array(root, oxms, oxms, 1);
-  oc_rep_set_int(root, oxmsel, doxm.oxmsel);
-  oc_rep_set_int(root, sct, doxm.sct);
-  oc_rep_set_boolean(root, owned, doxm.owned);
-  oc_uuid_to_str(&doxm.deviceuuid, uuid, 37);
-  oc_rep_set_text_string(root, deviceuuid, uuid);
-  oc_uuid_to_str(&doxm.devowneruuid, uuid, 37);
-  oc_rep_set_text_string(root, devowneruuid, uuid);
-  oc_uuid_to_str(&doxm.rowneruuid, uuid, 37);
-  oc_rep_set_text_string(root, rowneruuid, uuid);
-  oc_rep_end_root_object();
+    int oxms[1] = { 0 };
+    char uuid[37];
+
+    oc_rep_start_root_object();
+    oc_process_baseline_interface(oc_core_get_resource_by_index(OCF_SEC_DOXM));
+    oc_rep_set_int_array(root, oxms, oxms, 1);
+    oc_rep_set_int(root, oxmsel, doxm.oxmsel);
+    oc_rep_set_int(root, sct, doxm.sct);
+    oc_rep_set_boolean(root, owned, doxm.owned);
+    oc_uuid_to_str(&doxm.deviceuuid, uuid, 37);
+    oc_rep_set_text_string(root, deviceuuid, uuid);
+    oc_uuid_to_str(&doxm.devowneruuid, uuid, 37);
+    oc_rep_set_text_string(root, devowneruuid, uuid);
+    oc_uuid_to_str(&doxm.rowneruuid, uuid, 37);
+    oc_rep_set_text_string(root, rowneruuid, uuid);
+    oc_rep_end_root_object();
 }
 
 oc_sec_doxm_t *
 oc_sec_get_doxm(void)
 {
-  return &doxm;
+    return &doxm;
 }
 
 void
 get_doxm(oc_request_t *request, oc_interface_mask_t interface)
 {
-  switch (interface) {
-  case OC_IF_BASELINE: {
-    char *q;
-    int ql = oc_get_query_value(request, "owned", &q);
-    if (ql && ((doxm.owned == 1 && strncasecmp(q, "false", 5) == 0) ||
-               (doxm.owned == 0 && strncasecmp(q, "true", 4) == 0))) {
-      oc_ignore_request(request);
-    } else {
-      oc_sec_encode_doxm();
-      oc_send_response(request, OC_STATUS_OK);
+    switch (interface) {
+    case OC_IF_BASELINE: {
+        char *q;
+        int ql = oc_get_query_value(request, "owned", &q);
+
+        if (ql && ((doxm.owned == 1 && strncasecmp(q, "false", 5) == 0) ||
+                   (doxm.owned == 0 && strncasecmp(q, "true", 4) == 0))) {
+            oc_ignore_request(request);
+        } else {
+            oc_sec_encode_doxm();
+            oc_send_response(request, OC_STATUS_OK);
+        }
+    }
+        break;
+    default:
+        break;
     }
-  } break;
-  default:
-    break;
-  }
 }
 
 void
 oc_sec_decode_doxm(oc_rep_t *rep)
 {
-  while (rep != NULL) {
-    switch (rep->type) {
-    case BOOL:
-      if (strncmp(oc_string(rep->name), "owned", 5) == 0)
-        doxm.owned = rep->value_boolean;
-      else if (strncmp(oc_string(rep->name), "dpc", 3) == 0)
-        doxm.dpc = rep->value_boolean;
-      break;
-    case INT:
-      if (strncmp(oc_string(rep->name), "oxmsel", 6) == 0)
-        doxm.oxmsel = rep->value_int;
-      else if (strncmp(oc_string(rep->name), "sct", 3) == 0)
-        doxm.sct = rep->value_int;
-      break;
-    case STRING:
-      if (strncmp(oc_string(rep->name), "deviceuuid", 10) == 0)
-        oc_str_to_uuid(oc_string(rep->value_string), &doxm.deviceuuid);
-      else if (strncmp(oc_string(rep->name), "devowneruuid", 12) == 0)
-        oc_str_to_uuid(oc_string(rep->value_string), &doxm.devowneruuid);
-      else if (strncmp(oc_string(rep->name), "rowneruuid", 10) == 0)
-        oc_str_to_uuid(oc_string(rep->value_string), &doxm.rowneruuid);
-      break;
-    default:
-      break;
+    while (rep != NULL) {
+        switch (rep->type) {
+        case BOOL:
+            if (strncmp(oc_string(rep->name), "owned", 5) == 0) {
+                doxm.owned = rep->value_boolean;
+            } else if (strncmp(oc_string(rep->name), "dpc", 3) == 0) {
+                doxm.dpc = rep->value_boolean;
+            }
+            break;
+        case INT:
+            if (strncmp(oc_string(rep->name), "oxmsel", 6) == 0) {
+                doxm.oxmsel = rep->value_int;
+            } else if (strncmp(oc_string(rep->name), "sct", 3) == 0) {
+                doxm.sct = rep->value_int;
+            }
+            break;
+        case STRING:
+            if (strncmp(oc_string(rep->name), "deviceuuid", 10) == 0) {
+                oc_str_to_uuid(oc_string(rep->value_string), &doxm.deviceuuid);
+            } else if (strncmp(oc_string(rep->name), "devowneruuid", 12) == 0) {
+                oc_str_to_uuid(oc_string(rep->value_string),
+                               &doxm.devowneruuid);
+            } else if (strncmp(oc_string(rep->name), "rowneruuid", 10) == 0) {
+                oc_str_to_uuid(oc_string(rep->value_string), &doxm.rowneruuid);
+            }
+            break;
+        default:
+            break;
+        }
+        rep = rep->next;
     }
-    rep = rep->next;
-  }
 }
 
 void
 post_doxm(oc_request_t *request, oc_interface_mask_t interface)
 {
-  oc_sec_decode_doxm(request->request_payload);
-  oc_send_response(request, OC_STATUS_CHANGED);
+    oc_sec_decode_doxm(request->request_payload);
+    oc_send_response(request, OC_STATUS_CHANGED);
 }
 
 #endif /* OC_SECURITY */
diff --git a/net/oic/src/security/oc_doxm.h b/net/oic/src/security/oc_doxm.h
index 7c7586dcb..88e1061ba 100644
--- a/net/oic/src/security/oc_doxm.h
+++ b/net/oic/src/security/oc_doxm.h
@@ -29,15 +29,14 @@
 extern "C" {
 #endif
 
-typedef struct
-{
-  int oxmsel;
-  int sct;
-  bool owned;
-  bool dpc;
-  oc_uuid_t deviceuuid;
-  oc_uuid_t devowneruuid;
-  oc_uuid_t rowneruuid;
+typedef struct oc_sec_doxm {
+    int oxmsel;
+    int sct;
+    bool owned;
+    bool dpc;
+    oc_uuid_t deviceuuid;
+    oc_uuid_t devowneruuid;
+    oc_uuid_t rowneruuid;
 } oc_sec_doxm_t;
 
 void oc_sec_decode_doxm(oc_rep_t *rep);
diff --git a/net/oic/src/security/oc_dtls.c b/net/oic/src/security/oc_dtls.c
index a904d79a4..1bb2f5020 100644
--- a/net/oic/src/security/oc_dtls.c
+++ b/net/oic/src/security/oc_dtls.c
@@ -35,91 +35,98 @@ static dtls_context_t *ocf_dtls_context;
 oc_sec_dtls_peer_t *
 oc_sec_dtls_get_peer(oc_endpoint_t *endpoint)
 {
-  oc_sec_dtls_peer_t *peer = oc_list_head(dtls_peers);
-  while (peer != NULL) {
-    if (memcmp(&peer->session.addr, endpoint, oc_endpoint_size(endpoint)) == 0)
-      break;
-    peer = oc_list_item_next(peer);
-  }
-  return peer;
+    oc_sec_dtls_peer_t *peer = oc_list_head(dtls_peers);
+
+    while (peer != NULL) {
+        if (memcmp(&peer->session.addr, endpoint,
+            oc_endpoint_size(endpoint)) == 0)
+            break;
+        peer = oc_list_item_next(peer);
+    }
+    return peer;
 }
 
 void
 oc_sec_dtls_remove_peer(oc_endpoint_t *endpoint)
 {
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
-  if (peer) {
-    LOG("\n\noc_sec_dtls: removed peer\n\n");
-    oc_list_remove(dtls_peers, peer);
-    oc_memb_free(&dtls_peers_s, peer);
-  }
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
+
+    if (peer) {
+        LOG("\n\noc_sec_dtls: removed peer\n\n");
+        oc_list_remove(dtls_peers, peer);
+        oc_memb_free(&dtls_peers_s, peer);
+    }
 }
 
 oc_event_callback_retval_t
 oc_sec_dtls_inactive(void *data)
 {
-  LOG("\n\noc_sec_dtls: DTLS inactivity callback\n\n");
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(data);
-  if (peer) {
-    oc_clock_time_t time = oc_clock_time();
-    time -= peer->timestamp;
-    if (time < DTLS_INACTIVITY_TIMEOUT * OC_CLOCK_SECOND) {
-      LOG("\n\noc_sec_dtls: Resetting DTLS inactivity callback\n\n");
-      return CONTINUE;
-    } else if (time < 2 * DTLS_INACTIVITY_TIMEOUT * OC_CLOCK_SECOND) {
-      LOG("\n\noc_sec_dtls: Initiating connection close\n\n");
-      oc_sec_dtls_close_init(data);
-      return CONTINUE;
+    LOG("\n\noc_sec_dtls: DTLS inactivity callback\n\n");
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(data);
+    if (peer) {
+        oc_clock_time_t time = oc_clock_time();
+        time -= peer->timestamp;
+        if (time < DTLS_INACTIVITY_TIMEOUT * OC_CLOCK_SECOND) {
+            LOG("\n\noc_sec_dtls: Resetting DTLS inactivity callback\n\n");
+            return CONTINUE;
+        } else if (time < 2 * DTLS_INACTIVITY_TIMEOUT * OC_CLOCK_SECOND) {
+            LOG("\n\noc_sec_dtls: Initiating connection close\n\n");
+            oc_sec_dtls_close_init(data);
+            return CONTINUE;
+        } else {
+            LOG("\n\noc_sec_dtls: Completing connection close\n\n");
+            oc_sec_dtls_close_finish(data);
+        }
     } else {
-      LOG("\n\noc_sec_dtls: Completing connection close\n\n");
-      oc_sec_dtls_close_finish(data);
+        LOG("\n\noc_sec_dtls: Could not find peer\n\n");
+        LOG("oc_sec_dtls: Num active peers %d\n", oc_list_length(dtls_peers));
     }
-  } else {
-    LOG("\n\noc_sec_dtls: Could not find peer\n\n");
-    LOG("oc_sec_dtls: Num active peers %d\n", oc_list_length(dtls_peers));
-  }
-  LOG("\n\noc_sec_dtls: Terminating DTLS inactivity callback\n\n");
-  return DONE;
+    LOG("\n\noc_sec_dtls: Terminating DTLS inactivity callback\n\n");
+    return DONE;
 }
 
 oc_sec_dtls_peer_t *
 oc_sec_dtls_add_peer(oc_endpoint_t *endpoint)
 {
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
-  if (!peer) {
-    peer = oc_memb_alloc(&dtls_peers_s);
-    if (peer) {
-      LOG("\n\noc_sec_dtls: Allocating new DTLS peer\n\n");
-      memcpy(&peer->session.addr, endpoint, sizeof(oc_endpoint_t));
-      peer->session.size = sizeof(oc_endpoint_t);
-      OC_LIST_STRUCT_INIT(peer, send_queue);
-      peer->connected = false;
-      oc_list_add(dtls_peers, peer);
-
-      oc_ri_add_timed_event_callback_seconds(
-        &peer->session.addr, oc_sec_dtls_inactive, DTLS_INACTIVITY_TIMEOUT);
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
+
+    if (!peer) {
+        peer = oc_memb_alloc(&dtls_peers_s);
+        if (peer) {
+            LOG("\n\noc_sec_dtls: Allocating new DTLS peer\n\n");
+            memcpy(&peer->session.addr, endpoint, sizeof(oc_endpoint_t));
+            peer->session.size = sizeof(oc_endpoint_t);
+            OC_LIST_STRUCT_INIT(peer, send_queue);
+            peer->connected = false;
+            oc_list_add(dtls_peers, peer);
+
+            oc_ri_add_timed_event_callback_seconds(&peer->session.addr,
+                         oc_sec_dtls_inactive, DTLS_INACTIVITY_TIMEOUT);
+        }
     }
-  }
-  return peer;
+    return peer;
 }
 
 bool
 oc_sec_dtls_connected(oc_endpoint_t *endpoint)
 {
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
-  if (peer)
-    return peer->connected;
-  return false;
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
+
+    if (peer) {
+        return peer->connected;
+    }
+    return false;
 }
 
 oc_uuid_t *
 oc_sec_dtls_get_peer_uuid(oc_endpoint_t *endpoint)
 {
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
-  if (peer) {
-    return &peer->uuid;
-  }
-  return NULL;
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
+
+    if (peer) {
+        return &peer->uuid;
+    }
+    return NULL;
 }
 
 /*
@@ -132,26 +139,28 @@ static int
 oc_sec_dtls_get_decrypted_message(struct dtls_context_t *ctx,
                                   session_t *session, uint8_t *buf, size_t len)
 {
-  oc_message_t *message = oc_allocate_message();
-  if (message) {
-    memcpy(&message->endpoint, &session->addr, sizeof(oc_endpoint_t));
-    memcpy(message->data, buf, len);
-    message->length = len;
-    oc_recv_message(message);
-  }
-  return 0;
+    oc_message_t *message = oc_allocate_message();
+    if (message) {
+        memcpy(&message->endpoint, &session->addr, sizeof(oc_endpoint_t));
+        memcpy(message->data, buf, len);
+        message->length = len;
+        oc_recv_message(message);
+    }
+    return 0;
 }
 
 void
 oc_sec_dtls_init_connection(oc_message_t *message)
 {
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_add_peer(&message->endpoint);
-  if (peer) {
-    LOG("\n\noc_dtls: Initializing DTLS connection\n\n");
-    dtls_connect(ocf_dtls_context, &peer->session);
-    oc_list_add(peer->send_queue, message);
-  } else
-    oc_message_unref(message);
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_add_peer(&message->endpoint);
+
+    if (peer) {
+        LOG("\n\noc_dtls: Initializing DTLS connection\n\n");
+        dtls_connect(ocf_dtls_context, &peer->session);
+        oc_list_add(peer->send_queue, message);
+    } else {
+        oc_message_unref(message);
+    }
 }
 
 /*
@@ -168,14 +177,15 @@ oc_sec_dtls_init_connection(oc_message_t *message)
 int
 oc_sec_dtls_send_message(oc_message_t *message)
 {
-  int ret = 0;
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(&message->endpoint);
-  if (peer) {
-    ret = dtls_write(ocf_dtls_context, &peer->session, message->data,
-                     message->length);
-  }
-  oc_message_unref(message);
-  return ret;
+    int ret = 0;
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(&message->endpoint);
+
+    if (peer) {
+        ret = dtls_write(ocf_dtls_context, &peer->session, message->data,
+                         message->length);
+    }
+    oc_message_unref(message);
+    return ret;
 }
 
 /*
@@ -188,12 +198,12 @@ static int
 oc_sec_dtls_send_encrypted_message(struct dtls_context_t *ctx,
                                    session_t *session, uint8_t *buf, size_t len)
 {
-  oc_message_t message;
-  memcpy(&message.endpoint, &session->addr, sizeof(oc_endpoint_t));
-  memcpy(message.data, buf, len);
-  message.length = len;
-  oc_send_buffer(&message);
-  return len;
+    oc_message_t message;
+    memcpy(&message.endpoint, &session->addr, sizeof(oc_endpoint_t));
+    memcpy(message.data, buf, len);
+    message.length = len;
+    oc_send_buffer(&message);
+    return len;
 }
 
 /*
@@ -207,48 +217,51 @@ oc_sec_dtls_get_owner_psk(struct dtls_context_t *ctx, const session_t *session,
                           const unsigned char *desc, size_t desc_len,
                           unsigned char *result, size_t result_length)
 {
-  switch (type) {
-  case DTLS_PSK_IDENTITY:
-  case DTLS_PSK_HINT: {
-    LOG("Identity\n");
-    oc_uuid_t *uuid = oc_core_get_device_id(0);
-    memcpy(result, uuid->id, 16);
-    return 16;
-  } break;
-  case DTLS_PSK_KEY: {
-    LOG("key\n");
-    oc_sec_cred_t *cred = oc_sec_find_cred((oc_uuid_t *)desc);
-    oc_sec_dtls_peer_t *peer =
-      oc_sec_dtls_get_peer((oc_endpoint_t *)&session->addr);
-    if (cred != NULL && peer != NULL) {
-      memcpy(&peer->uuid, (oc_uuid_t *)desc, 16);
-      memcpy(result, cred->key, 16);
-      return 16;
+    switch (type) {
+    case DTLS_PSK_IDENTITY:
+    case DTLS_PSK_HINT: {
+        LOG("Identity\n");
+        oc_uuid_t *uuid = oc_core_get_device_id(0);
+        memcpy(result, uuid->id, 16);
+        return 16;
+    }
+        break;
+    case DTLS_PSK_KEY: {
+        LOG("key\n");
+        oc_sec_cred_t *cred = oc_sec_find_cred((oc_uuid_t *)desc);
+        oc_sec_dtls_peer_t *peer =
+          oc_sec_dtls_get_peer((oc_endpoint_t *)&session->addr);
+        if (cred != NULL && peer != NULL) {
+            memcpy(&peer->uuid, (oc_uuid_t *)desc, 16);
+            memcpy(result, cred->key, 16);
+            return 16;
+        }
+        return 0;
+    }
+        break;
+    default:
+        break;
     }
     return 0;
-  } break;
-  default:
-    break;
-  }
-  return 0;
 }
 
 int
 oc_sec_dtls_events(struct dtls_context_t *ctx, session_t *session,
                    dtls_alert_level_t level, unsigned short code)
 {
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(&session->addr);
-  if (peer && level == 0 && code == DTLS_EVENT_CONNECTED) {
-    peer->connected = true;
-    oc_message_t *m = oc_list_pop(peer->send_queue);
-    while (m != NULL) {
-      oc_sec_dtls_send_message(m);
-      m = oc_list_pop(peer->send_queue);
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(&session->addr);
+
+    if (peer && level == 0 && code == DTLS_EVENT_CONNECTED) {
+        peer->connected = true;
+        oc_message_t *m = oc_list_pop(peer->send_queue);
+        while (m != NULL) {
+            oc_sec_dtls_send_message(m);
+            m = oc_list_pop(peer->send_queue);
+        }
+    } else if (level == 2) {
+        oc_sec_dtls_close_finish(&session->addr);
     }
-  } else if (level == 2) {
-    oc_sec_dtls_close_finish(&session->addr);
-  }
-  return 0;
+    return 0;
 }
 
 static dtls_handler_t dtls_cb = {.write = oc_sec_dtls_send_encrypted_message,
@@ -263,12 +276,13 @@ oc_sec_derive_owner_psk(oc_endpoint_t *endpoint, const char *oxm,
                         const size_t obt_uuid_len, uint8_t *key,
                         const size_t key_len)
 {
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
-  if (peer) {
-    dtls_prf_with_current_keyblock(
-      ocf_dtls_context, &peer->session, oxm, oxm_len, server_uuid,
-      server_uuid_len, obt_uuid, obt_uuid_len, (uint8_t *)key, key_len);
-  }
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_get_peer(endpoint);
+
+    if (peer) {
+        dtls_prf_with_current_keyblock(
+          ocf_dtls_context, &peer->session, oxm, oxm_len, server_uuid,
+            server_uuid_len, obt_uuid, obt_uuid_len, (uint8_t *)key, key_len);
+    }
 }
 
 /*
@@ -279,17 +293,18 @@ oc_sec_derive_owner_psk(oc_endpoint_t *endpoint, const char *oxm,
 static void
 oc_sec_dtls_recv_message(oc_message_t *message)
 {
-  oc_sec_dtls_peer_t *peer = oc_sec_dtls_add_peer(&message->endpoint);
-  if (peer) {
-    int ret = dtls_handle_message(ocf_dtls_context, &peer->session,
+    oc_sec_dtls_peer_t *peer = oc_sec_dtls_add_peer(&message->endpoint);
+
+    if (peer) {
+        int ret = dtls_handle_message(ocf_dtls_context, &peer->session,
                                   message->data, message->length);
-    if (ret != 0) {
-      oc_sec_dtls_close_finish(&message->endpoint);
-    } else {
-      peer->timestamp = oc_clock_time();
+        if (ret != 0) {
+            oc_sec_dtls_close_finish(&message->endpoint);
+        } else {
+            peer->timestamp = oc_clock_time();
+        }
     }
-  }
-  oc_message_unref(message);
+    oc_message_unref(message);
 }
 
 /* If not owned, select anon_ECDH cipher and enter ready for OTM state */
@@ -299,74 +314,74 @@ oc_sec_dtls_recv_message(oc_message_t *message)
 void
 oc_sec_dtls_init_context(void)
 {
-  dtls_init();
-  ocf_dtls_context = dtls_new_context(NULL);
-
-  if (oc_sec_provisioned()) {
-    LOG("\n\noc_sec_dtls: Device in normal operation state\n\n");
-    dtls_select_cipher(ocf_dtls_context, TLS_PSK_WITH_AES_128_CCM_8);
-  } else {
-    LOG("\n\noc_sec_dtls: Device in ready for OTM state\n\n");
-    dtls_enables_anon_ecdh(ocf_dtls_context, DTLS_CIPHER_ENABLE);
-  }
-  dtls_set_handler(ocf_dtls_context, &dtls_cb);
+    dtls_init();
+    ocf_dtls_context = dtls_new_context(NULL);
+
+    if (oc_sec_provisioned()) {
+        LOG("\n\noc_sec_dtls: Device in normal operation state\n\n");
+        dtls_select_cipher(ocf_dtls_context, TLS_PSK_WITH_AES_128_CCM_8);
+    } else {
+        LOG("\n\noc_sec_dtls: Device in ready for OTM state\n\n");
+        dtls_enables_anon_ecdh(ocf_dtls_context, DTLS_CIPHER_ENABLE);
+    }
+    dtls_set_handler(ocf_dtls_context, &dtls_cb);
 }
 
 void
 oc_sec_dtls_close_init(oc_endpoint_t *endpoint)
 {
-  oc_sec_dtls_peer_t *p = oc_sec_dtls_get_peer(endpoint);
-  if (p) {
-    dtls_peer_t *peer = dtls_get_peer(ocf_dtls_context, &p->session);
-    if (peer) {
-      dtls_close(ocf_dtls_context, &p->session);
-      oc_message_t *m = oc_list_pop(p->send_queue);
-      while (m != NULL) {
-        LOG("\n\noc_sec_dtls: Freeing DTLS Peer send queue\n\n");
-        oc_message_unref(m);
-        m = oc_list_pop(p->send_queue);
-      }
+    oc_sec_dtls_peer_t *p = oc_sec_dtls_get_peer(endpoint);
+    if (p) {
+        dtls_peer_t *peer = dtls_get_peer(ocf_dtls_context, &p->session);
+        if (peer) {
+            dtls_close(ocf_dtls_context, &p->session);
+            oc_message_t *m = oc_list_pop(p->send_queue);
+            while (m != NULL) {
+                LOG("\n\noc_sec_dtls: Freeing DTLS Peer send queue\n\n");
+                oc_message_unref(m);
+                m = oc_list_pop(p->send_queue);
+            }
+        }
     }
-  }
 }
 
 void
 oc_sec_dtls_close_finish(oc_endpoint_t *endpoint)
 {
-  oc_sec_dtls_peer_t *p = oc_sec_dtls_get_peer(endpoint);
-  if (p) {
-    dtls_peer_t *peer = dtls_get_peer(ocf_dtls_context, &p->session);
-    if (peer) {
-      oc_list_remove(ocf_dtls_context->peers, peer);
-      dtls_free_peer(peer);
-    }
-    oc_message_t *m = oc_list_pop(p->send_queue);
-    while (m != NULL) {
-      LOG("\n\noc_sec_dtls: Freeing DTLS Peer send queue\n\n");
-      oc_message_unref(m);
-      m = oc_list_pop(p->send_queue);
+    oc_sec_dtls_peer_t *p = oc_sec_dtls_get_peer(endpoint);
+    if (p) {
+        dtls_peer_t *peer = dtls_get_peer(ocf_dtls_context, &p->session);
+        if (peer) {
+            oc_list_remove(ocf_dtls_context->peers, peer);
+            dtls_free_peer(peer);
+        }
+        oc_message_t *m = oc_list_pop(p->send_queue);
+        while (m != NULL) {
+            LOG("\n\noc_sec_dtls: Freeing DTLS Peer send queue\n\n");
+            oc_message_unref(m);
+            m = oc_list_pop(p->send_queue);
+        }
+        oc_sec_dtls_remove_peer(endpoint);
     }
-    oc_sec_dtls_remove_peer(endpoint);
-  }
 }
 
 OC_PROCESS_THREAD(oc_dtls_handler, ev, data)
 {
-  OC_PROCESS_BEGIN();
+    OC_PROCESS_BEGIN();
 
-  while (1) {
-    OC_PROCESS_YIELD();
+    while (1) {
+        OC_PROCESS_YIELD();
 
-    if (ev == oc_events[UDP_TO_DTLS_EVENT]) {
-      oc_sec_dtls_recv_message(data);
-    } else if (ev == oc_events[INIT_DTLS_CONN_EVENT]) {
-      oc_sec_dtls_init_connection(data);
-    } else if (ev == oc_events[RI_TO_DTLS_EVENT]) {
-      oc_sec_dtls_send_message(data);
+        if (ev == oc_events[UDP_TO_DTLS_EVENT]) {
+            oc_sec_dtls_recv_message(data);
+        } else if (ev == oc_events[INIT_DTLS_CONN_EVENT]) {
+            oc_sec_dtls_init_connection(data);
+        } else if (ev == oc_events[RI_TO_DTLS_EVENT]) {
+            oc_sec_dtls_send_message(data);
+        }
     }
-  }
 
-  OC_PROCESS_END();
+    OC_PROCESS_END();
 }
 
 #endif /* OC_SECURITY */
diff --git a/net/oic/src/security/oc_dtls.h b/net/oic/src/security/oc_dtls.h
index 21885c06f..82c10bc05 100644
--- a/net/oic/src/security/oc_dtls.h
+++ b/net/oic/src/security/oc_dtls.h
@@ -41,14 +41,13 @@ int oc_sec_dtls_send_message(oc_message_t *message);
 oc_uuid_t *oc_sec_dtls_get_peer_uuid(oc_endpoint_t *endpoint);
 bool oc_sec_dtls_connected(oc_endpoint_t *endpoint);
 
-typedef struct oc_sec_dtls_peer_s
-{
-  struct oc_sec_dtls_peer_s *next;
-  OC_LIST_STRUCT(send_queue);
-  session_t session;
-  oc_uuid_t uuid;
-  bool connected;
-  oc_clock_time_t timestamp;
+typedef struct oc_sec_dtls_peer {
+    struct oc_sec_dtls_peer_s *next;
+    OC_LIST_STRUCT(send_queue);
+    session_t session;
+    oc_uuid_t uuid;
+    bool connected;
+    oc_clock_time_t timestamp;
 } oc_sec_dtls_peer_t;
 
 #ifdef __cplusplus
diff --git a/net/oic/src/security/oc_pstat.c b/net/oic/src/security/oc_pstat.c
index 7e8a86d1a..afd10e052 100644
--- a/net/oic/src/security/oc_pstat.c
+++ b/net/oic/src/security/oc_pstat.c
@@ -26,94 +26,98 @@ static oc_sec_pstat_t pstat;
 oc_sec_pstat_t *
 oc_sec_get_pstat(void)
 {
-  return &pstat;
+    return &pstat;
 }
 
 bool
 oc_sec_provisioned(void)
 {
-  return pstat.isop;
+    return pstat.isop;
 }
 
 void
 oc_sec_pstat_default(void)
 {
-  pstat.isop = false;
-  pstat.cm = 2;
-  pstat.tm = 0;
-  pstat.om = 3;
-  pstat.sm = 3;
+    pstat.isop = false;
+    pstat.cm = 2;
+    pstat.tm = 0;
+    pstat.om = 3;
+    pstat.sm = 3;
 }
 
 void
 oc_sec_encode_pstat(void)
 {
-  char uuid[37];
-  oc_sec_doxm_t *doxm = oc_sec_get_doxm();
-  oc_rep_start_root_object();
-  oc_process_baseline_interface(oc_core_get_resource_by_index(OCF_SEC_PSTAT));
-  oc_rep_set_uint(root, cm, pstat.cm);
-  oc_rep_set_uint(root, tm, pstat.tm);
-  oc_rep_set_int(root, om, pstat.om);
-  oc_rep_set_int(root, sm, pstat.sm);
-  oc_rep_set_boolean(root, isop, pstat.isop);
-  oc_uuid_to_str(&doxm->deviceuuid, uuid, 37);
-  oc_rep_set_text_string(root, deviceuuid, uuid);
-  oc_uuid_to_str(&doxm->rowneruuid, uuid, 37);
-  oc_rep_set_text_string(root, rowneruuid, uuid);
-  oc_rep_end_root_object();
+    char uuid[37];
+    oc_sec_doxm_t *doxm = oc_sec_get_doxm();
+
+    oc_rep_start_root_object();
+    oc_process_baseline_interface(oc_core_get_resource_by_index(OCF_SEC_PSTAT));
+    oc_rep_set_uint(root, cm, pstat.cm);
+    oc_rep_set_uint(root, tm, pstat.tm);
+    oc_rep_set_int(root, om, pstat.om);
+    oc_rep_set_int(root, sm, pstat.sm);
+    oc_rep_set_boolean(root, isop, pstat.isop);
+    oc_uuid_to_str(&doxm->deviceuuid, uuid, 37);
+    oc_rep_set_text_string(root, deviceuuid, uuid);
+    oc_uuid_to_str(&doxm->rowneruuid, uuid, 37);
+    oc_rep_set_text_string(root, rowneruuid, uuid);
+    oc_rep_end_root_object();
 }
 
 void
 oc_sec_decode_pstat(oc_rep_t *rep)
 {
-  oc_sec_doxm_t *doxm = oc_sec_get_doxm();
-  while (rep != NULL) {
-    switch (rep->type) {
-    case BOOL:
-      pstat.isop = rep->value_boolean;
-      break;
-    case INT:
-      if (strncmp(oc_string(rep->name), "cm", 2) == 0)
-        pstat.cm = rep->value_int;
-      else if (strncmp(oc_string(rep->name), "tm", 2) == 0)
-        pstat.tm = rep->value_int;
-      else if (strncmp(oc_string(rep->name), "om", 2) == 0)
-        pstat.om = rep->value_int;
-      else if (strncmp(oc_string(rep->name), "sm", 2) == 0)
-        pstat.sm = rep->value_int;
-      break;
-    case STRING:
-      if (strncmp(oc_string(rep->name), "deviceuuid", 10) == 0)
-        oc_str_to_uuid(oc_string(rep->value_string), &doxm->deviceuuid);
-      else if (strncmp(oc_string(rep->name), "rowneruuid", 10) == 0)
-        oc_str_to_uuid(oc_string(rep->value_string), &doxm->rowneruuid);
-      break;
-    default:
-      break;
+    oc_sec_doxm_t *doxm = oc_sec_get_doxm();
+
+    while (rep != NULL) {
+        switch (rep->type) {
+        case BOOL:
+            pstat.isop = rep->value_boolean;
+            break;
+        case INT:
+            if (strncmp(oc_string(rep->name), "cm", 2) == 0) {
+                pstat.cm = rep->value_int;
+            } else if (strncmp(oc_string(rep->name), "tm", 2) == 0) {
+                pstat.tm = rep->value_int;
+            } else if (strncmp(oc_string(rep->name), "om", 2) == 0) {
+                pstat.om = rep->value_int;
+            } else if (strncmp(oc_string(rep->name), "sm", 2) == 0) {
+                pstat.sm = rep->value_int;
+            }
+            break;
+        case STRING:
+            if (strncmp(oc_string(rep->name), "deviceuuid", 10) == 0) {
+                oc_str_to_uuid(oc_string(rep->value_string), &doxm->deviceuuid);
+            } else if (strncmp(oc_string(rep->name), "rowneruuid", 10) == 0) {
+                oc_str_to_uuid(oc_string(rep->value_string), &doxm->rowneruuid);
+            }
+            break;
+        default:
+            break;
+        }
+        rep = rep->next;
     }
-    rep = rep->next;
-  }
 }
 
 void
 get_pstat(oc_request_t *request, oc_interface_mask_t interface)
 {
-  switch (interface) {
-  case OC_IF_BASELINE: {
-    oc_sec_encode_pstat();
-    oc_send_response(request, OC_STATUS_OK);
-  } break;
-  default:
-    break;
-  }
+    switch (interface) {
+    case OC_IF_BASELINE: {
+        oc_sec_encode_pstat();
+        oc_send_response(request, OC_STATUS_OK);
+    } break;
+    default:
+        break;
+    }
 }
 
 void
 post_pstat(oc_request_t *request, oc_interface_mask_t interface)
 {
-  oc_sec_decode_pstat(request->request_payload);
-  oc_send_response(request, OC_STATUS_CHANGED);
+    oc_sec_decode_pstat(request->request_payload);
+    oc_send_response(request, OC_STATUS_CHANGED);
 }
 
 #endif /* OC_SECURITY */
diff --git a/net/oic/src/security/oc_pstat.h b/net/oic/src/security/oc_pstat.h
index 7189d52b7..b69675355 100644
--- a/net/oic/src/security/oc_pstat.h
+++ b/net/oic/src/security/oc_pstat.h
@@ -23,13 +23,12 @@
 extern "C" {
 #endif
 
-typedef struct
-{
-  bool isop;
-  int cm;
-  int tm;
-  int om;
-  int sm;
+typedef struct oc_sec_pstat {
+    bool isop;
+    int cm;
+    int tm;
+    int om;
+    int sm;
 } oc_sec_pstat_t;
 
 bool oc_sec_provisioned(void);
diff --git a/net/oic/src/security/oc_store.c b/net/oic/src/security/oc_store.c
index 15f8cca0a..e40f4c651 100644
--- a/net/oic/src/security/oc_store.c
+++ b/net/oic/src/security/oc_store.c
@@ -26,133 +26,133 @@
 void
 oc_sec_load_doxm(void)
 {
-  long ret = 0;
-  size_t size = 512;
-  uint8_t buf[size];
-  oc_rep_t *rep;
-
-  if (oc_sec_provisioned()) {
-    ret = oc_storage_read("/doxm", buf, size);
-    if (ret > 0) {
-      oc_parse_rep(buf, ret, &rep);
-      oc_sec_decode_doxm(rep);
-      oc_free_rep(rep);
+    long ret = 0;
+    size_t size = 512;
+    uint8_t buf[size];
+    oc_rep_t *rep;
+
+    if (oc_sec_provisioned()) {
+        ret = oc_storage_read("/doxm", buf, size);
+        if (ret > 0) {
+            oc_parse_rep(buf, ret, &rep);
+            oc_sec_decode_doxm(rep);
+            oc_free_rep(rep);
+        }
     }
-  }
 
-  if (ret <= 0) {
-    oc_sec_doxm_default();
-  }
+    if (ret <= 0) {
+        oc_sec_doxm_default();
+    }
 
-  oc_uuid_t *deviceuuid = oc_core_get_device_id(0);
-  oc_sec_doxm_t *doxm = oc_sec_get_doxm();
-  memcpy(deviceuuid, &doxm->deviceuuid, sizeof(oc_uuid_t));
+    oc_uuid_t *deviceuuid = oc_core_get_device_id(0);
+    oc_sec_doxm_t *doxm = oc_sec_get_doxm();
+    memcpy(deviceuuid, &doxm->deviceuuid, sizeof(oc_uuid_t));
 }
 
 void
 oc_sec_load_pstat(void)
 {
-  long ret = 0;
-  size_t size = 512;
-  uint8_t buf[size];
-  oc_rep_t *rep;
-
-  ret = oc_storage_read("/pstat", buf, size);
-  if (ret > 0) {
-    oc_parse_rep(buf, ret, &rep);
-    oc_sec_decode_pstat(rep);
-    oc_free_rep(rep);
-  }
-
-  if (ret <= 0) {
-    oc_sec_pstat_default();
-  }
+    long ret = 0;
+    size_t size = 512;
+    uint8_t buf[size];
+    oc_rep_t *rep;
+
+    ret = oc_storage_read("/pstat", buf, size);
+    if (ret > 0) {
+        oc_parse_rep(buf, ret, &rep);
+        oc_sec_decode_pstat(rep);
+        oc_free_rep(rep);
+    }
+
+    if (ret <= 0) {
+        oc_sec_pstat_default();
+    }
 }
 
 void
 oc_sec_load_cred(void)
 {
-  long ret = 0;
-  size_t size = 1024;
-  uint8_t buf[size];
-  oc_rep_t *rep;
-
-  if (oc_sec_provisioned()) {
-    ret = oc_storage_read("/cred", buf, size);
-
-    if (ret <= 0)
-      return;
-
-    oc_parse_rep(buf, ret, &rep);
-    oc_sec_decode_cred(rep, NULL);
-    oc_free_rep(rep);
-  }
+    long ret = 0;
+    size_t size = 1024;
+    uint8_t buf[size];
+    oc_rep_t *rep;
+
+    if (oc_sec_provisioned()) {
+        ret = oc_storage_read("/cred", buf, size);
+
+        if (ret <= 0) {
+            return;
+        }
+        oc_parse_rep(buf, ret, &rep);
+        oc_sec_decode_cred(rep, NULL);
+        oc_free_rep(rep);
+    }
 }
 
 void
 oc_sec_load_acl(void)
 {
-  size_t size = 1024;
-  long ret = 0;
-  uint8_t buf[size];
-  oc_rep_t *rep;
-
-  oc_sec_acl_init();
-
-  if (oc_sec_provisioned()) {
-    ret = oc_storage_read("/acl", buf, size);
-    if (ret > 0) {
-      oc_parse_rep(buf, ret, &rep);
-      oc_sec_decode_acl(rep);
-      oc_free_rep(rep);
+    size_t size = 1024;
+    long ret = 0;
+    uint8_t buf[size];
+    oc_rep_t *rep;
+
+    oc_sec_acl_init();
+
+    if (oc_sec_provisioned()) {
+        ret = oc_storage_read("/acl", buf, size);
+        if (ret > 0) {
+            oc_parse_rep(buf, ret, &rep);
+            oc_sec_decode_acl(rep);
+            oc_free_rep(rep);
+        }
     }
-  }
 
-  if (ret <= 0) {
-    oc_sec_acl_default();
-  }
+    if (ret <= 0) {
+        oc_sec_acl_default();
+    }
 }
 
 void
 oc_sec_dump_state(void)
 {
-  uint8_t buf[1024];
-
-  /* pstat */
-  oc_rep_new(buf, 1024);
-  oc_sec_encode_pstat();
-  int size = oc_rep_finalize();
-  if (size > 0) {
-    LOG("oc_store: encoded pstat size %d\n", size);
-    oc_storage_write("/pstat", buf, size);
-  }
-
-  /* cred */
-  oc_rep_new(buf, 1024);
-  oc_sec_encode_cred();
-  size = oc_rep_finalize();
-  if (size > 0) {
-    LOG("oc_store: encoded cred size %d\n", size);
-    oc_storage_write("/cred", buf, size);
-  }
-
-  /* doxm */
-  oc_rep_new(buf, 1024);
-  oc_sec_encode_doxm();
-  size = oc_rep_finalize();
-  if (size > 0) {
-    LOG("oc_store: encoded doxm size %d\n", size);
-    oc_storage_write("/doxm", buf, size);
-  }
-
-  /* acl */
-  oc_rep_new(buf, 1024);
-  oc_sec_encode_acl();
-  size = oc_rep_finalize();
-  if (size > 0) {
-    LOG("oc_store: encoded ACL size %d\n", size);
-    oc_storage_write("/acl", buf, size);
-  }
+    uint8_t buf[1024];
+
+    /* pstat */
+    oc_rep_new(buf, 1024);
+    oc_sec_encode_pstat();
+    int size = oc_rep_finalize();
+    if (size > 0) {
+        LOG("oc_store: encoded pstat size %d\n", size);
+        oc_storage_write("/pstat", buf, size);
+    }
+
+    /* cred */
+    oc_rep_new(buf, 1024);
+    oc_sec_encode_cred();
+    size = oc_rep_finalize();
+    if (size > 0) {
+        LOG("oc_store: encoded cred size %d\n", size);
+        oc_storage_write("/cred", buf, size);
+    }
+
+    /* doxm */
+    oc_rep_new(buf, 1024);
+    oc_sec_encode_doxm();
+    size = oc_rep_finalize();
+    if (size > 0) {
+        LOG("oc_store: encoded doxm size %d\n", size);
+        oc_storage_write("/doxm", buf, size);
+    }
+
+    /* acl */
+    oc_rep_new(buf, 1024);
+    oc_sec_encode_acl();
+    size = oc_rep_finalize();
+    if (size > 0) {
+        LOG("oc_store: encoded ACL size %d\n", size);
+        oc_storage_write("/acl", buf, size);
+    }
 }
 
 #endif /* OC_SECURITY */
diff --git a/net/oic/src/security/oc_svr.c b/net/oic/src/security/oc_svr.c
index 8e44425e6..52d96cb80 100644
--- a/net/oic/src/security/oc_svr.c
+++ b/net/oic/src/security/oc_svr.c
@@ -33,19 +33,20 @@
 void
 oc_sec_create_svr(void)
 {
-  oc_core_populate_resource(OCF_SEC_DOXM, "/oic/sec/doxm", "oic.sec.doxm",
-                            OC_IF_BASELINE, OC_IF_BASELINE,
-                            OC_ACTIVE | OC_SECURE | OC_DISCOVERABLE, get_doxm,
-                            0, post_doxm, 0, 0);
-  oc_core_populate_resource(
-    OCF_SEC_PSTAT, "/oic/sec/pstat", "oic.sec.pstat", OC_IF_BASELINE,
-    OC_IF_BASELINE, OC_ACTIVE | OC_SECURE, get_pstat, 0, post_pstat, 0, 0);
-  oc_core_populate_resource(OCF_SEC_ACL, "/oic/sec/acl", "oic.sec.acl",
-                            OC_IF_BASELINE, OC_IF_BASELINE,
-                            OC_ACTIVE | OC_SECURE, 0, 0, post_acl, 0, 0);
-  oc_core_populate_resource(OCF_SEC_CRED, "/oic/sec/cred", "oic.sec.cred",
-                            OC_IF_BASELINE, OC_IF_BASELINE,
-                            OC_ACTIVE | OC_SECURE, 0, 0, post_cred, 0, 0);
+    oc_core_populate_resource(OCF_SEC_DOXM, "/oic/sec/doxm", "oic.sec.doxm",
+                              OC_IF_BASELINE, OC_IF_BASELINE,
+                              OC_ACTIVE | OC_SECURE | OC_DISCOVERABLE, get_doxm,
+                              0, post_doxm, 0, 0);
+    oc_core_populate_resource(OCF_SEC_PSTAT, "/oic/sec/pstat", "oic.sec.pstat",
+                              OC_IF_BASELINE, OC_IF_BASELINE,
+                              OC_ACTIVE | OC_SECURE, get_pstat, 0,
+                              post_pstat, 0, 0);
+    oc_core_populate_resource(OCF_SEC_ACL, "/oic/sec/acl", "oic.sec.acl",
+                              OC_IF_BASELINE, OC_IF_BASELINE,
+                              OC_ACTIVE | OC_SECURE, 0, 0, post_acl, 0, 0);
+    oc_core_populate_resource(OCF_SEC_CRED, "/oic/sec/cred", "oic.sec.cred",
+                              OC_IF_BASELINE, OC_IF_BASELINE,
+                              OC_ACTIVE | OC_SECURE, 0, 0, post_cred, 0, 0);
 }
 
 #endif /* OC_SECURITY */
diff --git a/net/oic/syscfg.yml b/net/oic/syscfg.yml
index 2f6987c5a..4add9865f 100644
--- a/net/oic/syscfg.yml
+++ b/net/oic/syscfg.yml
@@ -23,33 +23,43 @@ syscfg.defs:
     OC_TRANSPORT_SERIAL:
         description: 'Enables OIC transport over nlip serial'
         value: '0'
+
     OC_TRANSPORT_GATT:
         description: 'Enables OIC transport over BLE GATT'
         value: '0'
+
     OC_TRANSPORT_IP:
         description: 'Enables OIC transport over IP UDP'
         value: '0'
+
     OC_TRANSPORT_IPV6:
         description: 'Support IPv6'
         value: '1'
+
     OC_TRANSPORT_IPV4:
         description: 'Support IPv4'
         value: '0'
+
     OC_TRANSPORT_LORA:
         description: 'Support Lora'
         value: '0'
+
     OC_LORA_PORT:
         description: 'Which LORA port to use'
         value: 0xbb
+
     OC_CLIENT:
         description: 'Enables OIC client support'
         value: '0'
+
     OC_SERVER:
         description: 'Enables OIC server support'
         value: '0'
+
     OC_DEBUG:
         description: 'Enables OIC debug logs'
         value: '0'
+
     OC_NUM_REP_OBJECTS:
         description: 'Estimated number of nodes in payload tree structure'
         value: 32
@@ -86,3 +96,4 @@ syscfg.defs:
         description: >
             Enables per-resource transport layer security requirements.
         value: 1
+
diff --git a/net/oic/test/src/test_discovery.c b/net/oic/test/src/test_discovery.c
index c9e1cfd83..3923b8e30 100644
--- a/net/oic/test/src/test_discovery.c
+++ b/net/oic/test/src/test_discovery.c
@@ -20,6 +20,7 @@
 
 #include <os/os.h>
 #include <oic/oc_api.h>
+#include <oic/port/mynewt/ip.h>
 
 static int test_discovery_state;
 static volatile int test_discovery_done;
@@ -38,7 +39,7 @@ test_discovery_cb(const char *di, const char *uri, oc_string_array_t types,
                   oc_interface_mask_t interfaces,
                   struct oc_server_handle *server)
 {
-    if ((server->endpoint.oe.flags & IP) == 0) {
+    if (server->endpoint.ep.oe_type != oc_ip6_transport_id) {
         return 0;
     }
     oic_test_set_endpoint(server);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services