headers under rebranding;

v0.5.xx
Alexander Vdolainen 9 years ago
parent 880b56bad3
commit b76c84478a

@ -1 +1 @@
nobase_include_HEADERS = sntl/sntllv2.h sntl/errno.h sntl/limits.h
nobase_include_HEADERS = sxmp/sxmp.h sxmp/errno.h sxmp/limits.h

@ -1,54 +0,0 @@
/*
* Secure Network Transport Layer Library v2 implementation.
* (sntllv2) it superseed all versions before due to the:
* - memory consumption
* - new features such as pulse emitting
* - performance optimization
*
* This is a proprietary software. See COPYING for further details.
*
* (c) Askele Group 2013-2015 <http://askele.com>
*
*/
#ifndef __SNTL_ERRNO_H__
#define __SNTL_ERRNO_H__
#define __SNTL_EPREFIX 200
#define SNE_SUCCESS 200
#define SNE_FAILED 201
#define SNE_ENOMEM 202
#define SNE_BADPROTO 203
#define SNE_ENORPC 204
#define SNE_EPERM 205
#define SNE_TOOLONG 206
#define SNE_EBUSY 207
#define SNE_WOULDBLOCK 208
#define SNE_LINKERROR 209
#define SNE_NOSUCHMSG 210
#define SNE_NOSUCHCHAN 211
#define SNE_ETIMEDOUT 212
#define SNE_IGNORED 213
#define SNE_REPLYREQ 214
#define SNE_RAPIDMSG 215
#define SNE_ESSL 216
#define SNE_NOCHANNELS 217
#define SNE_MCHANNELS 218
#define SNE_MMESSAGES 219
#define SNE_LINKBROKEN 220
#define SNE_INVALINDEX 221
/* some old errors for compatibility */
#define ESXOREPLYREQ SNE_REPLYREQ /* protocol require reply with expression,
* or expression return for the request */
#define ESXOTIMEDOUT SNE_ETIMEDOUT /* timedout */
#define ESXRCBADPROT SNE_BADPROTO /* invalid protocol */
#define ESXNOCONNECT SNE_LINKERROR /* connection is lost */
#define ESXNOCHANSUP SNE_NOSUCHCHAN
#define ESXRAPIDREPLY SNE_RAPIDMSG
const char *sntll_errno2cstr(int);
#endif /* __SNTL_ERRNO_H__ */

@ -1,24 +0,0 @@
/*
* Secure Network Transport Layer Library v2 implementation.
* (sntllv2) it superseed all versions before due to the:
* - memory consumption
* - new features such as pulse emitting
* - performance optimization
*
* This is a proprietary software. See COPYING for further details.
*
* (c) Askele Group 2013-2015 <http://askele.com>
*
*/
#ifndef __SNTL_LIMITS_H__
#define __SNTL_LIMITS_H__
#define MAX_RPC_LIST 512
#define MAX_SNTLLBUFSIZE 65536
#define MAX_RBBUF_LEN (MAX_SNTLLBUFSIZE - sizeof(sntllv2_head_t))
#define MAX_SNTLLTHREADS 8
#endif /* __SNTL_LIMITS_H__ */

@ -0,0 +1,45 @@
/*
* Secure X Message Passing Library v2 implementation.
* (sxmplv2) it superseed all versions before due to the:
* - memory consumption
* - new features such as pulse emitting
* - performance optimization
*
* This is a proprietary software. See COPYING for further details.
*
* (c) Askele Group 2013-2015 <http://askele.com>
*
*/
#ifndef __SXMP_ERRNO_H__
#define __SXMP_ERRNO_H__
#define __SXMP_EPREFIX 200
#define SXE_SUCCESS 200
#define SXE_FAILED 201
#define SXE_ENOMEM 202
#define SXE_BADPROTO 203
#define SXE_ENORPC 204
#define SXE_EPERM 205
#define SXE_TOOLONG 206
#define SXE_EBUSY 207
#define SXE_WOULDBLOCK 208
#define SXE_LINKERROR 209
#define SXE_NOSUCHMSG 210
#define SXE_NOSUCHCHAN 211
#define SXE_ETIMEDOUT 212
#define SXE_IGNORED 213
#define SXE_REPLYREQ 214
#define SXE_RAPIDMSG 215
#define SXE_ESSL 216
#define SXE_NOCHANNELS 217
#define SXE_MCHANNELS 218
#define SXE_MMESSAGES 219
#define SXE_LINKBROKEN 220
#define SXE_INVALINDEX 221
const char *sxmpl_errno2cstr(int);
#endif /* __SXMP_ERRNO_H__ */

@ -0,0 +1,26 @@
/*
* Secure X Message Passing Library v2 implementation.
* (sxmplv2) it superseed all versions before due to the:
* - memory consumption
* - new features such as pulse emitting
* - performance optimization
*
* This is a proprietary software. See COPYING for further details.
*
* (c) Askele Group 2013-2015 <http://askele.com>
*
*/
#ifndef __SXMP_LIMITS_H__
#define __SXMP_LIMITS_H__
#define MAX_RPC_LIST 512
#define MAX_SXMPLBUFSIZE 65536
#define MAX_RBBUF_LEN (MAX_SXMPLBUFSIZE - sizeof(sntllv2_head_t))
#define MAX_SXMPLTHREADS 8
#define MAX_LINKS 32768
#endif /* __SXMP_LIMITS_H__ */

@ -1,6 +1,6 @@
/*
* Secure Network Transport Layer Library v2 implementation.
* (sntllv2) it superseed all versions before due to the:
* Secure X Message Passing Library v2 implementation.
* (sxmplv2) it superseed all versions before due to the:
* - memory consumption
* - new features such as pulse emitting
* - performance optimization
@ -11,8 +11,8 @@
*
*/
#ifndef __SNTL_SNTLLV2_H__
#define __SNTL_SNTLLV2_H__
#ifndef __SXMP_SXMPLV2_H__
#define __SXMP_SXMPLV2_H__
#include <stdint.h>
#include <time.h>
@ -27,50 +27,50 @@
#include <sexpr/sexp.h>
#include <sexpr/faststack.h>
#include <sntl/errno.h>
#include <sxmp/errno.h>
#define VERIFY_DEPTH 1 /* FIXME: */
typedef struct __perm_context_type {
typedef struct __session_context_type {
char *login;
char *passwd;
uint64_t certid;
struct in_addr *addr;
void *priv;
} perm_ctx_t;
} sxsession_ctx_t;
/* 8 byte header */
typedef struct __sntllv2_head_type {
typedef struct __sxmplv2_head_type {
uint16_t msgid;
uint16_t payload_length;
uint8_t attr;
uint8_t opcode;
uint16_t reserve;
}__attribute__((packed)) sntllv2_head_t;
}__attribute__((packed)) sxmplv2_head_t;
struct __connections_subsys_type;
struct __channel_t;
struct __message_t;
struct __sxhub_type;
struct __sxchannel_t;
struct __sxmsg_t;
/* flags for the connection link */
#define SNSX_BATCHMODE (1 << 1)
#define SNSX_MESSAGINGMODE (1 << 2)
#define SNSX_ALIVE (1 << 3)
#define SNSX_CLOSED (1 << 4)
#define SXMP_BATCHMODE (1 << 1)
#define SXMP_MESSAGINGMODE (1 << 2)
#define SXMP_ALIVE (1 << 3)
#define SXMP_CLOSED (1 << 4)
/*
* älä jätä kommentteja omalla kielellä! yksinkertaisia englanti sijaan!
* i found somebody who write comments and messages in non-english,
* it's a fucking practice - forget it.
*/
typedef struct __connection_t {
typedef struct __sxlink_t {
/* General section */
struct __connections_subsys_type *ssys; /* < connections subsystem */
char *uuid; /** < uuid of the connection */
struct __sxhub_type *ssys; /* < hub subsystem */
char *uuid; /** < uuid of the link */
/* Channels section */
idx_allocator_t idx_ch; /** < index allocation for channels */
pthread_mutex_t idx_ch_lock; /** < mutex for allocating and deallocating channels */
struct __channel_t **channels; /** < channels O(1) storage */
struct __sxchannel_t **channels; /** < channels O(1) storage */
/* RPC section */
usrtc_t *rpc_list; /** < search tree of possible RPC typed lists */
/* SSL related section */
@ -78,9 +78,9 @@ typedef struct __connection_t {
int ssl_data_index; /** < SSL index for the custom data */
pthread_mutex_t sslinout[2]; /** < SSL related locks for in and out */
/* Security section */
perm_ctx_t *pctx; /** < higher layer authentification context */
sxsession_ctx_t *pctx; /** < higher layer authentification and session context */
/* Messages section */
struct __message_t **messages; /** < messages O(1) storage */
struct __sxmsg_t **messages; /** < messages O(1) storage */
idx_allocator_t idx_msg;
pthread_mutex_t idx_msg_lock;
list_head_t write_pending; /** < list of messages waiting for write */
@ -90,27 +90,26 @@ typedef struct __connection_t {
pthread_t thrd_poll[8];
volatile uint8_t flags; /** < flags of the connection */
volatile uint8_t usecount; /** < use count for the connection link */
usrtc_node_t csnode; /** < node to store the connection within list */
} conn_t;
usrtc_node_t csnode; /** < node to store the link within list */
} sxlink_t;
#define connection_getpctx(c) (c)->pctx
#define connection_getpriv(c) (c)->pctx->priv
#define connection_setpriv(c, p) (c)->pctx->priv = (void *)(p)
#define sxlink_getpctx(c) (c)->pctx
#define sxlink_getpriv(c) (c)->pctx->priv
#define sxlink_setpriv(c, p) (c)->pctx->priv = (void *)(p)
struct __connection_rpc_list_type;
struct __message_t;
struct __link_rpc_list_type;
typedef struct __pp_msg_type {
struct __message_t *msg;
typedef struct __pp_msg_type { /* postponed message entry */
struct __sxmsg_t *msg;
list_node_t node;
} ppmsg_t;
} sxppmsg_t;
typedef struct __channel_t {
typedef struct __sxchannel_t {
uint16_t cid; /** < ID of the channel */
conn_t *connection; /** < pointer to the parent connection */
struct __connection_rpc_list_type *rpc_list; /** < rpc functions list */
sxlink_t *link; /** < pointer to the underlying link */
struct __link_rpc_list_type *rpc_list; /** < rpc functions list */
int flags; /** < flags of the channel */
} chnl_t;
} sxchnl_t;
/* message flags */
#define SXMSG_OPEN (1 << 1)
@ -122,15 +121,15 @@ typedef struct __channel_t {
#define SXMSG_TIMEDOUT (1 << 7)
/**
* \brief Message used in sntl message passing
* \brief Message used in sxmp message passing
*
* This structure used to manage a message within a channel
* of the sntl structure stack.
* of the sxmp structure stack.
*/
typedef struct __message_t {
chnl_t *pch; /** < channel of the message(if applicable) */
typedef struct __sxmsg_t {
sxchnl_t *pch; /** < channel of the message(if applicable) */
pthread_mutex_t wait; /** < special wait mutex, used for pending list and sync */
sntllv2_head_t mhead; /** < last actual head of the message */
sxmplv2_head_t mhead; /** < last actual head of the message */
void *payload; /** < payload */
} sxmsg_t;
@ -141,53 +140,51 @@ typedef struct __message_t {
#define sxmsg_waitlock(m) pthread_mutex_lock(&((m)->wait))
#define sxmsg_waitunlock(m) pthread_mutex_unlock(&((m)->wait))
typedef struct __connection_rpc_entry_type {
typedef struct __link_rpc_entry_type {
char *name;
int (*rpcf)(void *, sexp_t *);
usrtc_node_t node;
} cx_rpc_t;
} sxl_rpc_t;
typedef struct __connection_rpc_list_type {
typedef struct __link_rpc_list_type {
usrtc_t *rpc_tree; /** < search tree for the rpc lookup */
char *opt_version; /** < reserved for future implementations */
} cx_rpc_list_t;
#define MAX_CONNECTIONS 32768
} sxl_rpclist_t;
/**
* \brief Connection subsystem structure.
* \brief Hub subsystem structure.
*
* This structure used for management and control a set of a
* determined connections with the same RPC lists and the same
* determined links with the same RPC lists and the same
* mode (server, client).
*
*/
typedef struct __connections_subsys_type {
usrtc_t *connections;
typedef struct __sxhub_type {
usrtc_t *links;
pthread_rwlock_t rwlock;
char *rootca, *certpem, *certkey; /* path name to the certificates */
cx_rpc_list_t *system_rpc;
/* special functions pointers */
int (*validate_sslpem)(conn_t *); /** < this function used to validate SSL certificate while SSL handshake */
int (*secure_check)(conn_t *); /** < this function authorize user to login,
int (*validate_sslpem)(sxlink_t *); /** < this function used to validate SSL certificate while SSL handshake */
int (*secure_check)(sxlink_t *); /** < this function authorize user to login,
* and also should check SSL cert and user, and already made sessions */
usrtc_t* (*get_rpc_typed_list_tree)(conn_t *); /** < this function is used to set RPC list of the functions */
int (*set_typed_list_callback)(conn_t *, int, char *); /** < this function is a callback
usrtc_t* (*get_rpc_typed_list_tree)(sxlink_t *); /** < this function is used to set RPC list of the functions */
int (*set_typed_list_callback)(sxlink_t *, int, char *); /** < this function is a callback
* during setting up a typed channel */
void (*on_destroy)(conn_t *); /** < callback on connection destroy */
void (*on_pulse)(conn_t *, sexp_t *); /** < callback on pulse emit */
void (*on_destroy)(sxlink_t *); /** < callback on connection destroy */
void (*on_pulse)(sxlink_t *, sexp_t *); /** < callback on pulse emit */
SSL_CTX *ctx; /** < SSL context */
void *priv;
} conn_sys_t;
} sxhub_t;
#define connections_set_sslvalidate(c, f) (c)->validate_sslpem = (f)
#define connections_set_authcheck(c, f) (c)->secure_check = (f)
#define connections_set_rpcvalidator(c, f) (c)->get_rpc_typed_list_tree = (f)
#define connections_set_channelcall(c, f) (c)->set_typed_list_callback = (f)
#define connections_set_ondestroy(c, f) (c)->on_destroy = (f)
#define connections_set_onpulse(c, f) (c)->on_pulse = (f)
#define connections_set_priv(c, p) (c)->priv = (p)
#define connections_get_priv(c) (c)->priv
#define sxhub_set_sslvalidate(c, f) (c)->validate_sslpem = (f)
#define sxhub_set_authcheck(c, f) (c)->secure_check = (f)
#define sxhub_set_rpcvalidator(c, f) (c)->get_rpc_typed_list_tree = (f)
#define sxhub_set_channelcall(c, f) (c)->set_typed_list_callback = (f)
#define sxhub_set_ondestroy(c, f) (c)->on_destroy = (f)
#define sxhub_set_onpulse(c, f) (c)->on_pulse = (f)
#define sxhub_set_priv(c, p) (c)->priv = (p)
#define sxhub_get_priv(c) (c)->priv
typedef struct __rpc_typed_list_type {
int type_id;
@ -201,42 +198,42 @@ extern "C" {
#endif
/* API */
int sntl_init(void);
int sxmp_init(void);
void sntl_finalize(void);
void sxmp_finalize(void);
int connections_init(conn_sys_t *ssys);
int sxhub_init(sxhub_t *ssys);
conn_sys_t *connections_create(void);
sxhub_t *sxhub_create(void);
int connections_destroy(conn_sys_t *ssys);
int sxhub_destroy(sxhub_t *ssys);
int connections_free(conn_sys_t *ssys);
int sxhub_free(sxhub_t *ssys);
int connections_setsslserts(conn_sys_t *ssys, const char *rootca,
const char *certpem, const char *certkey);
int sxhub_setsslserts(sxhub_t *ssys, const char *rootca,
const char *certpem, const char *certkey);
/* create links */
conn_t *connection_master_link(conn_sys_t *ssys, int sck, struct in_addr *addr);
conn_t *connection_link(conn_sys_t *ssys, const char *host,
int port, const char *SSL_cert, const char *login,
const char *passwd);
int connection_close(conn_t *co);
sxlink_t *sxlink_master_accept(sxhub_t *ssys, int sck, struct in_addr *addr);
sxlink_t *sxlink_connect(sxhub_t *ssys, const char *host,
int port, const char *SSL_cert, const char *login,
const char *passwd);
int sxlink_close(sxlink_t *co);
/* channels */
chnl_t *sxchannel_open(conn_t *co, int type);
int sxchannel_close(chnl_t *channel);
sxchnl_t *sxchannel_open(sxlink_t *co, int type);
int sxchannel_close(sxchnl_t *channel);
/* messages */
/*
* creates a message with a payload.
* Will return a error code, and, if applicable, pointer to message
*/
int sxmsg_send(chnl_t *channel, const char *data, size_t datalen, sxmsg_t **msg);
int sxmsg_send(sxchnl_t *channel, const char *data, size_t datalen, sxmsg_t **msg);
/* the same - postponed message i.e. will be written to the queue - not to write immendatly */
int sxmsg_send_pp(chnl_t *channel, const char *data, size_t datalen, sxmsg_t **msg);
int sxmsg_send_pp(sxchnl_t *channel, const char *data, size_t datalen, sxmsg_t **msg);
/* send a pulse message */
int sxmsg_pulse(conn_t *co, const char *data, size_t datalen);
int sxmsg_pulse(sxlink_t *co, const char *data, size_t datalen);
int sxmsg_reply(sxmsg_t *msg, const char *data, size_t datalen);
int sxmsg_reply_pp(sxmsg_t *msg, const char *data, size_t datalen);
int sxmsg_rreply(sxmsg_t *msg, size_t datalen);
@ -249,23 +246,23 @@ void sxmsg_clean(sxmsg_t *msg);
#endif
/* RPC List API */
#define SNTL_FILTER_INC 0xa
#define SNTL_FILTER_EXC 0xb
#define SNTL_FILTER_END -1
#define SXMP_FILTER_INC 0xa
#define SXMP_FILTER_EXC 0xb
#define SXMP_FILTER_END -1
#ifdef __cplusplus
extern "C" {
#endif
int sntl_rpclist_init(usrtc_t *tree);
int sxmp_rpclist_init(usrtc_t *tree);
int sntl_rpclist_add(usrtc_t *tree, int type, const char *description,
int sxmp_rpclist_add(usrtc_t *tree, int type, const char *description,
const char *version);
int sntl_rpclist_add_function(usrtc_t *tree, int type, const char *fu_name,
int sxmp_rpclist_add_function(usrtc_t *tree, int type, const char *fu_name,
int (*rpcf)(void *, sexp_t *));
int sntl_rpclist_filter(usrtc_t *source, usrtc_t **dest, int flag, int *filter);
int sxmp_rpclist_filter(usrtc_t *source, usrtc_t **dest, int flag, int *filter);
#ifdef __cplusplus
}
@ -275,6 +272,6 @@ int sntl_rpclist_filter(usrtc_t *source, usrtc_t **dest, int flag, int *filter);
#define dumphead(head) fprintf(stderr, "id: %d, opcode: %d, attr: %d, len = %d\n", head->msgid, head->opcode, head->attr, head->payload_length)
#endif /* __SNTL_SNTLLV2_H__ */
#endif /* __SXMP_SXMPLV2_H__ */
Loading…
Cancel
Save