Ziti C SDK
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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
27typedef struct ziti_ctx *ziti_context;
28
29#if _WIN32
30#include <WinSock2.h>
31typedef SOCKET ziti_socket_t;
32#else
33#include <netinet/in.h>
34
35typedef int ziti_socket_t;
36#endif
37
44void Ziti_lib_init(void);
45
53
64int Ziti_enroll_identity(const char *jwt, const char *key, const char *cert,
65 char **id_json, unsigned long *id_json_len);
77ziti_context Ziti_load_context(const char *identity);
78
86
95
103
113int Ziti_connect(ziti_socket_t socket, ziti_context ztx, const char *service, const char *terminator);
114
123int Ziti_connect_addr(ziti_socket_t socket, const char *host, unsigned int port);
124
134int Ziti_bind(ziti_socket_t socket, ziti_context ztx, const char *service, const char *terminator);
135
143int Ziti_listen(ziti_socket_t socket, int backlog);
144
160ziti_socket_t Ziti_accept(ziti_socket_t socket, char *caller, int caller_len);
161
169
170
171#ifdef __cplusplus
172}
173#endif
174
175#endif //ZITI_SDK_ZITILIB_H
Defines the macros, functions, typedefs and constants pertaining to errors observed when using a Ziti...
#define ZITI_FUNC
Definition externs.h:38
struct ziti_ctx * ziti_context
Represents the Ziti Edge identity context.
Definition ziti.h:67
int Ziti_connect(ziti_socket_t socket, ziti_context ztx, const char *service, const char *terminator)
Connect socket to a Ziti service.
ziti_socket_t Ziti_socket(int type)
creates a socket handle(Windows) or file descriptor(*nix) suitable for connecting to a Ziti service
struct ziti_ctx * ziti_context
Definition zitilib.h:27
int Ziti_bind(ziti_socket_t socket, ziti_context ztx, const char *service, const char *terminator)
Bind socket to a Ziti service.
int Ziti_last_error(void)
return Ziti error code for last failed operation.
ziti_socket_t Ziti_accept(ziti_socket_t socket, char *caller, int caller_len)
accept a client Ziti connection as a socket
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:35
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_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.
ziti_context Ziti_load_context(const char *identity)
Load Ziti identity.