Skip to content

Commit

Permalink
build deps
Browse files Browse the repository at this point in the history
  • Loading branch information
scareything committed Jan 27, 2020
1 parent 36cd9cf commit 0cc9780
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store

/.idea/

build-*/
build/
/cmake-build-debug/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "deps/lwip"]
path = deps/lwip
url = https://git.savannah.nongnu.org/git/lwip.git
[submodule "deps/ziti-sdk-c"]
path = deps/ziti-sdk-c
url = [email protected]:netfoundry/ziti-sdk-c.git
65 changes: 65 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 3.12)
file(READ version ver)

project(ziti-tunneler-sdk
VERSION ${ver}
LANGUAGES C CXX)

message("project version: ${PROJECT_VERSION}")

if (WIN32)
message("WIN32 build. Creating: ${CMAKE_BINARY_DIR}/cmake_install")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/cmake_install)
message("WIN32 build. Creating: ${CMAKE_BINARY_DIR}/cmake_install/ziti-sdk-${PROJECT_VERSION}")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/cmake_install/ziti-sdk-${PROJECT_VERSION})
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/cmake_install/ziti-sdk-${PROJECT_VERSION})
else()
set(CMAKE_INSTALL_PREFIX /opt/netfoundry/${PROJECT_NAME}-${PROJECT_VERSION})
endif()

message("cross-compiling ${CMAKE_CROSSCOMPILING}")

# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# capture build date
execute_process(
COMMAND date +%a-%m/%d/%Y-%H:%M:%S-%Z
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE BUILD_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

message("git info:")
message(" branch : ${GIT_BRANCH}")
message(" hash : ${GIT_COMMIT_HASH}")
message(" date : ${BUILD_DATE}")

if(DEFINED ENV{BITBUCKET_BUILD_NUMBER})
set(ZITI_BUILDNUM $ENV{BITBUCKET_BUILD_NUMBER})
else()
set(ZITI_BUILDNUM local)
endif()

set(ZITI_VERSION ${PROJECT_VERSION}-${ZITI_BUILDNUM})

link_directories(${CMAKE_BINARY_DIR}/lib)

add_subdirectory(deps)

if(WIN32)
add_subdirectory(windows)
endif()
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
# ziti-tunneler-sdk
# API Notes

The ziti tunneler SDK dispatches layer 3 packets to ziti service connections.
Using the SDK, a tunneler application only needs to proxy layer 3
packets from a virtual NIC (typically a tun interface)

typedef void (*to_client_cb)(uint8_t *packet, size_t len)

- `NF_tunnel_init(to_client_cb)`


implement the following callbacks:

- `on_service_add(const char *, intercept_address)`
`on_service_del(const char *, intercept_address)`

These functions are called when a service is added to an appwan.
Implementing applications should establish routes to the virtual
NIC for the intercept address of the added service.



- `to_ziti(uint8_t *packet, size_t len)`

Implementing applications must call this function when a packet is
read from the virtual NIC.


- `to_client(uint8_t *packet, size_t len)`

This function is called by the SDK when data is received from a
connected ziti service. The implementing application should write
the packet to the virtual NIC.


# Design Notes

## Packet Flow

The tunneler application adds a handle to the same uv loop that drives events
for the Ziti SDK. The handle will most likely be a `poll` handle that reads
the packet device. Packet devices are OS-specific (e.g. file descriptor
on Linux (darwin?), stream socket on Windows)
5 changes: 5 additions & 0 deletions deps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project(ziti-tunneler-sdk-deps)

include(ExternalProject)

add_subdirectory(ziti-sdk-c)
1 change: 1 addition & 0 deletions deps/lwip
Submodule lwip added at dae8eb
1 change: 1 addition & 0 deletions deps/ziti-sdk-c
Submodule ziti-sdk-c added at 4ff5b7
1 change: 1 addition & 0 deletions version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0

0 comments on commit 0cc9780

Please sign in to comment.