Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
fix(Endpoint): Move endpoint used only source code
Browse files Browse the repository at this point in the history
The "cipher","connectivity", "https", and the "text_serializer" are
only serving for endpoint. Moving these files under endpoint may make
more sense.

Close #638
  • Loading branch information
splasky committed Jul 17, 2020
1 parent c548a46 commit b375312
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 70 deletions.
54 changes: 48 additions & 6 deletions endpoint/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "endpoint_core",
srcs = ["endpoint_core.c"],
Expand All @@ -11,9 +13,9 @@ cc_library(
deps = [
"//common:ta_errors",
"//common:ta_logger",
"//utils:cipher",
"//utils:https",
"//utils:text_serializer",
"//endpoint:cipher",
"//endpoint:https",
"//endpoint:text_serializer",
"//utils:tryte_byte_conv",
],
)
Expand All @@ -33,9 +35,9 @@ cc_binary(
deps = [
"//common:ta_errors",
"//common:ta_logger",
"//utils:cipher",
"//utils:https",
"//utils:text_serializer",
"//endpoint:cipher",
"//endpoint:https",
"//endpoint:text_serializer",
"//utils:tryte_byte_conv",
],
)
Expand All @@ -49,3 +51,43 @@ platform(
"@platforms//cpu:arm",
],
)

cc_library(
name = "cipher",
srcs = ["cipher.c"],
hdrs = ["cipher.h"],
deps = [
"//common:ta_errors",
"//common:ta_logger",
"@mbedtls_2_16_6",
],
)

cc_library(
name = "https",
srcs = ["https.c"],
hdrs = ["https.h"],
defines = select({
":https_enable": ["ENDPOINT_HTTPS"],
"//conditions:default": [],
}),
deps = [
"//common:ta_errors",
"//endpoint/connectivity:conn_http",
],
)

config_setting(
name = "https_enable",
values = {"define": "https=enable"},
)

cc_library(
name = "text_serializer",
srcs = ["text_serializer.c"],
hdrs = ["text_serializer.h"],
deps = [
":cipher",
"//common:ta_errors",
],
)
File renamed without changes.
2 changes: 1 addition & 1 deletion utils/cipher.h → endpoint/cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern "C" {
#endif

/**
* @file utils/cipher.h
* @file endpoint/cipher.h
*/

#define AES_BLOCK_SIZE 16
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions endpoint/endpointComp/Component.cdef
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ sources:
${CURDIR}/../../output_base/external/mbedtls_2_16_6/library/x509.c
${CURDIR}/../../output_base/external/mbedtls_2_16_6/library/x509_crt.c

${CURDIR}/../../utils/cipher.c
${CURDIR}/../../utils/connectivity/conn_http.c
${CURDIR}/../../utils/https.c
${CURDIR}/../../utils/text_serializer.c
${CURDIR}/../../endpoint/cipher.c
${CURDIR}/../../endpoint/connectivity/conn_http.c
${CURDIR}/../../endpoint/https.c
${CURDIR}/../../endpoint/text_serializer.c
${CURDIR}/../../utils/tryte_byte_conv.c

endpoint.c
Expand Down
2 changes: 1 addition & 1 deletion endpoint/endpointComp/endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include "hal/device.h"

#include "common/ta_errors.h"
#include "endpoint/cipher.h"
#include "endpoint/endpoint_core.h"
#include "le_test.h"
#include "legato.h"
#include "utils/cipher.h"

#include "le_log.h"

Expand Down
8 changes: 4 additions & 4 deletions endpoint/endpoint_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include <string.h>
#include <time.h>
#include "common/logger.h"
#include "endpoint/cipher.h"
#include "endpoint/connectivity/conn_http.h"
#include "endpoint/https.h"
#include "endpoint/text_serializer.h"
#include "http_parser.h"
#include "utils/cipher.h"
#include "utils/connectivity/conn_http.h"
#include "utils/https.h"
#include "utils/text_serializer.h"
#include "utils/tryte_byte_conv.h"

#include <netdb.h>
Expand Down
2 changes: 1 addition & 1 deletion utils/https.c → endpoint/https.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <string.h>
#include "common/logger.h"
#include "common/ta_errors.h"
#include "endpoint/connectivity/conn_http.h"
#include "http_parser.h"
#include "utils/connectivity/conn_http.h"

static http_parser parser;

Expand Down
2 changes: 1 addition & 1 deletion utils/https.h → endpoint/https.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern "C" {
#endif

/**
* @file utils/https.h
* @file endpoint/https.h
*/

/**
Expand Down
1 change: 0 additions & 1 deletion utils/text_serializer.c → endpoint/text_serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils/cipher.h"

#define IV_LEN 16
#define UINT32_LEN 10
Expand Down
4 changes: 2 additions & 2 deletions utils/text_serializer.h → endpoint/text_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
#include <stddef.h>
#include <stdint.h>
#include "common/ta_errors.h"
#include "utils/cipher.h"
#include "endpoint/cipher.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @file utils/text_serializer.h
* @file endpoint/text_serializer.h
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion endpoint/unit-test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ cc_test(
"test_http.c",
],
deps = [
"//endpoint/connectivity:conn_http",
"//tests:test_define",
"//utils/connectivity:conn_http",
],
)

Expand Down
2 changes: 1 addition & 1 deletion endpoint/unit-test/test_endpoint_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include <stdlib.h>
#include <time.h>
#include "common/ta_errors.h"
#include "endpoint/cipher.h"
#include "endpoint/endpoint_core.h"
#include "tests/test_define.h"
#include "utils/cipher.h"

#define TEST_VALUE 0
#define TEST_MESSAGE "THISISMSG9THISISMSG9THISISMSG"
Expand Down
2 changes: 1 addition & 1 deletion endpoint/unit-test/test_http.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <stdlib.h>
#include <string.h>
#include "common/ta_errors.h"
#include "endpoint/connectivity/conn_http.h"
#include "http_parser.h"
#include "tests/test_define.h"
#include "utils/connectivity/conn_http.h"

#define TEST_PORT "8000"
#define TEST_HOST "localhost"
Expand Down
6 changes: 3 additions & 3 deletions tests/unit-test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ cc_test(
"test_text_serializer.c",
],
deps = [
"//endpoint:cipher",
"//endpoint:text_serializer",
"//tests:test_define",
"//utils:cipher",
"//utils:text_serializer",
],
)

Expand All @@ -72,8 +72,8 @@ cc_test(
"test_cipher.c",
],
deps = [
"//endpoint:cipher",
"//tests:test_define",
"//utils:cipher",
],
)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit-test/test_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "endpoint/cipher.h"
#include "tests/test_define.h"
#include "utils/cipher.h"

#define MAXLINE 1024

Expand Down
4 changes: 2 additions & 2 deletions tests/unit-test/test_text_serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "endpoint/cipher.h"
#include "endpoint/text_serializer.h"
#include "tests/test_define.h"
#include "utils/cipher.h"
#include "utils/text_serializer.h"

const uint8_t iv[AES_BLOCK_SIZE] = {164, 3, 98, 193, 52, 162, 107, 252, 184, 42, 74, 225, 157, 26, 88, 72};
const uint8_t payload[] = {
Expand Down
40 changes: 0 additions & 40 deletions utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,6 @@ cc_library(
deps = ["@org_iota_common//utils:char_buffer"],
)

cc_library(
name = "cipher",
srcs = ["cipher.c"],
hdrs = ["cipher.h"],
deps = [
"//common:ta_errors",
"//common:ta_logger",
"@mbedtls_2_16_6",
],
)

cc_library(
name = "https",
srcs = ["https.c"],
hdrs = ["https.h"],
defines = select({
":https_enable": ["ENDPOINT_HTTPS"],
"//conditions:default": [],
}),
deps = [
"//common:ta_errors",
"//utils/connectivity:conn_http",
],
)

config_setting(
name = "https_enable",
values = {"define": "https=enable"},
)

cc_library(
name = "text_serializer",
srcs = ["text_serializer.c"],
hdrs = ["text_serializer.h"],
deps = [
":cipher",
"//common:ta_errors",
],
)

cc_library(
name = "tryte_byte_conv",
srcs = ["tryte_byte_conv.c"],
Expand Down

0 comments on commit b375312

Please sign in to comment.