-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36cd9cf
commit 0cc9780
Showing
8 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
|
||
/.idea/ | ||
|
||
build-*/ | ||
build/ | ||
/cmake-build-debug/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Submodule ziti-sdk-c
added at
4ff5b7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.0 |