Ziti C SDK
Loading...
Searching...
No Matches
zitilib.h
Go to the documentation of this file.
1// Copyright (c) 2022. NetFoundry Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15
16#ifndef ZITI_SDK_ZITILIB_H
17#define ZITI_SDK_ZITILIB_H
18
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include "externs.h"
25#include "errors.h"
26#include "enums.h"
27
28#include <stdint.h>
29
30typedef uint32_t ziti_handle_t;
31#define ZITI_INVALID_HANDLE ((ziti_handle_t)-1)
32
33#if _WIN32
34#include <WinSock2.h>
35typedef SOCKET ziti_socket_t;
36#else
37#include <netinet/in.h>
38
39typedef int ziti_socket_t;
40#endif
41
48void Ziti_lib_init(void);
49
57
68int Ziti_enroll_identity(const char *jwt, const char *key, const char *cert,
69 char **id_json, unsigned long *id_json_len);
70
102int Ziti_enroll_controller(const char *url, const char *jwt, ziti_enroll_mode mode,
103 const char *signer_name,
104 char **id_json, unsigned long *id_json_len);
129int Ziti_load_context(ziti_handle_t *h, const char *identity);
130
157int Ziti_load_context_with_timeout(ziti_handle_t *h, const char *identity, int timeout_ms);
158
159
166const char * const * Ziti_get_ext_signers(ziti_handle_t ztx);
167
181char* Ziti_login_external(ziti_handle_t ztx, const char *signer_name);
182
194int Ziti_login_totp(ziti_handle_t ztx, const char *code);
195
207int Ziti_wait_for_auth(ziti_handle_t ztx, int timeout_ms);
208
216
225
233
243int Ziti_connect(ziti_socket_t socket, ziti_handle_t ztx, const char *service, const char *terminator);
244
253int Ziti_connect_addr(ziti_socket_t socket, const char *host, unsigned int port);
254
264int Ziti_connect_sockaddr(ziti_socket_t socket, const struct sockaddr *addr, int addrlen);
265
275int Ziti_bind(ziti_socket_t socket, ziti_handle_t ztx, const char *service, const char *terminator);
276
284int Ziti_listen(ziti_socket_t socket, int backlog);
285
301ziti_socket_t Ziti_accept(ziti_socket_t socket, char *caller, int caller_len);
302
303
305int Ziti_resolve(const char *host, const char *port, const struct addrinfo *hints, struct addrinfo **addrlist);
306
314
315
316#ifdef __cplusplus
317}
318#endif
319
320#endif //ZITI_SDK_ZITILIB_H
ziti_enroll_mode
Definition enums.h:34
Defines the macros, functions, typedefs and constants pertaining to errors observed when using a Ziti...
#define ZITI_FUNC
Definition externs.h:38
int Ziti_connect(ziti_socket_t socket, ziti_handle_t ztx, const char *service, const char *terminator)
Connect socket to a Ziti service.
uint32_t ziti_handle_t
Definition zitilib.h:30
ziti_socket_t Ziti_socket(int type)
creates a socket handle(Windows) or file descriptor(*nix) suitable for connecting to a Ziti service
int Ziti_enroll_controller(const char *url, const char *jwt, ziti_enroll_mode mode, const char *signer_name, char **id_json, unsigned long *id_json_len)
Enroll or authenticate a Ziti identity via a controller URL.
int Ziti_resolve(const char *host, const char *port, const struct addrinfo *hints, struct addrinfo **addrlist)
const char *const * Ziti_get_ext_signers(ziti_handle_t ztx)
Get the names of external signers available for authentication.
int Ziti_connect_sockaddr(ziti_socket_t socket, const struct sockaddr *addr, int addrlen)
Connect socket to a Ziti service with the given intercept sockaddr.
int Ziti_load_context_with_timeout(ziti_handle_t *h, const char *identity, int timeout_ms)
Load Ziti identity with timeout control.
int Ziti_last_error(void)
return Ziti error code for last failed operation.
int Ziti_wait_for_auth(ziti_handle_t ztx, int timeout_ms)
Wait for authentication to complete.
ziti_socket_t Ziti_accept(ziti_socket_t socket, char *caller, int caller_len)
accept a client Ziti connection as a socket
int Ziti_load_context(ziti_handle_t *h, const char *identity)
Load Ziti identity.
int Ziti_connect_addr(ziti_socket_t socket, const char *host, unsigned int port)
Connect socket to a Ziti service with the given intercept address.
int ziti_socket_t
Definition zitilib.h:39
char * Ziti_login_external(ziti_handle_t ztx, const char *signer_name)
Start external login process.
void Ziti_lib_init(void)
Initialize Ziti library.
int Ziti_enroll_identity(const char *jwt, const char *key, const char *cert, char **id_json, unsigned long *id_json_len)
enroll a new Ziti identity
void Ziti_lib_shutdown(void)
Shutdown Ziti library.
int Ziti_listen(ziti_socket_t socket, int backlog)
marks the [socket] as a socket able to accept incoming connections
int Ziti_bind(ziti_socket_t socket, ziti_handle_t ztx, const char *service, const char *terminator)
Bind socket to a Ziti service.
int Ziti_check_socket(ziti_socket_t socket)
Check if the given socket handle/fd is attached to a Ziti connection via Ziti_connect()/Ziti_bind()
int Ziti_close(ziti_socket_t socket)
close the given socket handle/file descriptor.
int Ziti_login_totp(ziti_handle_t ztx, const char *code)
Login with TOTP code.