Skip to content

Commit

Permalink
Merge pull request #2 from named-data-iot/refactor
Browse files Browse the repository at this point in the history
Refactor forwarder
  • Loading branch information
zjkmxy authored Mar 19, 2019
2 parents 9c003e0 + 9b97009 commit 4b31168
Show file tree
Hide file tree
Showing 24 changed files with 1,437 additions and 24 deletions.
8 changes: 8 additions & 0 deletions CMakeInputs/adaptation.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
target_sources(ndn-lite PUBLIC
${DIR_ADAPTATION}/adapt-consts.h
${DIR_ADAPTATION}/udp/udp-face.h
)
target_sources(ndn-lite PRIVATE
${DIR_ADAPTATION}/uniform-time.c
${DIR_ADAPTATION}/udp/udp-face.c
)
13 changes: 13 additions & 0 deletions CMakeInputs/encode.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(DIR_ENCODE "${DIR_NDN_LITE}/encode")
set(DIR_TRUST_SCHEMA "${DIR_ENCODE}/trust-schema")
target_sources(ndn-lite PUBLIC
${DIR_ENCODE}/data.h
${DIR_ENCODE}/decoder.h
Expand All @@ -12,6 +13,12 @@ target_sources(ndn-lite PUBLIC
${DIR_ENCODE}/signature.h
${DIR_ENCODE}/signed-interest.h
${DIR_ENCODE}/tlv.h
${DIR_ENCODE}/forwarder-helper.h
${DIR_ENCODE}/ndn-rule-storage.h
${DIR_TRUST_SCHEMA}/ndn-trust-schema-common.h
${DIR_TRUST_SCHEMA}/ndn-trust-schema-pattern-component.h
${DIR_TRUST_SCHEMA}/ndn-trust-schema-pattern.h
${DIR_TRUST_SCHEMA}/ndn-trust-schema-rule.h
)
target_sources(ndn-lite PRIVATE
${DIR_ENCODE}/data.c
Expand All @@ -22,5 +29,11 @@ target_sources(ndn-lite PRIVATE
${DIR_ENCODE}/name.c
${DIR_ENCODE}/signature.c
${DIR_ENCODE}/signed-interest.c
${DIR_ENCODE}/forwarder-helper.c
${DIR_ENCODE}/ndn-rule-storage.c
${DIR_TRUST_SCHEMA}/ndn-trust-schema-pattern-component.c
${DIR_TRUST_SCHEMA}/ndn-trust-schema-pattern.c
${DIR_TRUST_SCHEMA}/ndn-trust-schema-rule.c
)
unset(DIR_TRUST_SCHEMA)
unset(DIR_ENCODE)
20 changes: 20 additions & 0 deletions CMakeInputs/examples.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(DIR_EXAMPLES_OUTPUT "${PROJECT_BINARY_DIR}/examples")

# Single-file examples
set(LIST_EXAMPLES
"udp-basic-producer"
"udp-basic-consumer"
# "udp-group-producer"
# "udp-group-consumer"
# "access-control-producer"
# "access-control-consumer"
# "access-control-controller"
)
foreach(EXAM_NAME IN LISTS LIST_EXAMPLES)
add_executable(${EXAM_NAME} "${DIR_EXAMPLES}/${EXAM_NAME}.c")
target_link_libraries(${EXAM_NAME} ndn-lite)
set_target_properties(${EXAM_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${DIR_EXAMPLES_OUTPUT})
endforeach()
unset(LIST_EXAMPLES)

unset(DIR_EXAMPLES_OUTPUT)
2 changes: 0 additions & 2 deletions CMakeInputs/face.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
set(DIR_FACE "${DIR_NDN_LITE}/face")
target_sources(ndn-lite PUBLIC
${DIR_FACE}/direct-face.h
${DIR_FACE}/dummy-face.h
)
target_sources(ndn-lite PRIVATE
${DIR_FACE}/direct-face.c
${DIR_FACE}/dummy-face.c
)
unset(DIR_FACE)
7 changes: 6 additions & 1 deletion CMakeInputs/forwarder.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
set(DIR_FORWARDER "${DIR_NDN_LITE}/forwarder")
target_sources(ndn-lite PUBLIC
${DIR_FORWARDER}/callback-funcs.h
${DIR_FORWARDER}/face-table.h
${DIR_FORWARDER}/face.h
${DIR_FORWARDER}/fib.h
${DIR_FORWARDER}/forwarder.h
${DIR_FORWARDER}/name-tree.h
${DIR_FORWARDER}/pit.h
)
target_sources(ndn-lite PRIVATE
${DIR_FORWARDER}/face.c
${DIR_FORWARDER}/face-table.c
${DIR_FORWARDER}/fib.c
${DIR_FORWARDER}/forwarder.c
${DIR_FORWARDER}/name-tree.c
${DIR_FORWARDER}/pit.c
)
unset(DIR_FORWARDER)
1 change: 1 addition & 0 deletions CMakeInputs/ndnlite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ target_sources(ndn-lite PUBLIC
${DIR_NDN_LITE}/ndn-enums.h
${DIR_NDN_LITE}/ndn-error-code.h
${DIR_NDN_LITE}/ndn-services.h
${PROJECT_SOURCE_DIR}/ndn-lite.h
)
include(${DIR_CMAKEFILES}/app-support.cmake)
include(${DIR_CMAKEFILES}/encode.cmake)
Expand Down
2 changes: 2 additions & 0 deletions CMakeInputs/security.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target_sources(ndn-lite PUBLIC
${DIR_SECURITY}/ndn-lite-sec-config.h
${DIR_SECURITY}/ndn-lite-sec-utils.h
${DIR_SECURITY}/ndn-lite-sha.h
${DIR_SECURITY}/ndn-trust-schema.h
)
target_sources(ndn-lite PRIVATE
${DIR_SECURITY}/ndn-lite-aes.c
Expand All @@ -20,6 +21,7 @@ target_sources(ndn-lite PRIVATE
${DIR_SECURITY}/ndn-lite-sec-config.c
${DIR_SECURITY}/ndn-lite-sec-utils.c
${DIR_SECURITY}/ndn-lite-sha.c
${DIR_SECURITY}/ndn-trust-schema.c
${DIR_DEFAULT_BACKEND}/ndn-lite-default-aes-impl.h
${DIR_DEFAULT_BACKEND}/ndn-lite-default-aes-impl.c
${DIR_DEFAULT_BACKEND}/ndn-lite-default-ecc-impl.h
Expand Down
12 changes: 6 additions & 6 deletions CMakeInputs/unittest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ target_sources(unittest PRIVATE
"${DIR_UNITTESTS}/sign-verify/ecdsa-sign-verify-tests/test-secp256k1-def.c"
)

#target_sources(unittest PRIVATE
# "${DIR_UNITTESTS}/schematized-trust/trust-schema-tests.h"
# "${DIR_UNITTESTS}/schematized-trust/trust-schema-tests.c"
# "${DIR_UNITTESTS}/schematized-trust/trust-schema-tests-def.h"
# "${DIR_UNITTESTS}/schematized-trust/trust-schema-tests-def.c"
#)
target_sources(unittest PRIVATE
"${DIR_UNITTESTS}/schematized-trust/trust-schema-tests.h"
"${DIR_UNITTESTS}/schematized-trust/trust-schema-tests.c"
"${DIR_UNITTESTS}/schematized-trust/trust-schema-tests-def.h"
"${DIR_UNITTESTS}/schematized-trust/trust-schema-tests-def.c"
)
4 changes: 4 additions & 0 deletions CMakeInputs/util.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ set(DIR_UTIL "${DIR_NDN_LITE}/util")
target_sources(ndn-lite PUBLIC
${DIR_UTIL}/memory-pool.h
${DIR_UTIL}/msg-queue.h
${DIR_UTIL}/uniform-time.h
${DIR_UTIL}/bit-operations.h
${DIR_UTIL}/re.h
)
target_sources(ndn-lite PRIVATE
${DIR_UTIL}/memory-pool.c
${DIR_UTIL}/msg-queue.c
${DIR_UTIL}/re.c
)
unset(DIR_UTIL)
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,32 @@
cmake_minimum_required (VERSION 3.11)
project(ndn-lite)

add_definitions(-D_GNU_SOURCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -O0 -ggdb")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
set(CMAKE_C_FLAGS_RELEASE "-O3")

set(DIR_CMAKEFILES "${PROJECT_SOURCE_DIR}/CMakeInputs")
set(DIR_NDN_LITE "${PROJECT_SOURCE_DIR}/ndn-lite")
set(DIR_ADAPTATION "${PROJECT_SOURCE_DIR}/adaptation")
set(DIR_EXAMPLES "${PROJECT_SOURCE_DIR}/examples")
include_directories(${PROJECT_SOURCE_DIR})

# NDN-Lite static library
add_library(ndn-lite STATIC)
include(${DIR_CMAKEFILES}/ndnlite.cmake)

# Adaptation
include(${DIR_CMAKEFILES}/adaptation.cmake)

# Unit test program
add_executable(unittest)
target_link_libraries(unittest ndn-lite)
include(${DIR_CMAKEFILES}/unittest.cmake)

# Examples
include(${DIR_CMAKEFILES}/examples.cmake)

# Doxygen
# first we can indicate the documentation build as an option and set it to ON by default
option(BUILD_DOCS "Build documentation" OFF)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
* General Public License v3.0. See the file LICENSE in the top level
* directory for more details.
*/
#ifndef NDN_ADAPT_CONSTS_H
#define NDN_ADAPT_CONSTS_H

#ifndef NDN_UDP_UNICAST_FACE_H_
#define NDN_UDP_UNICAST_FACE_H_
#define NDN_UDP_FACE_SOCKET_ERROR 1

#ifdef __cplusplus
extern "C" {
#endif



#ifdef __cplusplus
}
#endif

#endif
#endif // NDN_ADAPT_CONSTS_H
Loading

0 comments on commit 4b31168

Please sign in to comment.