clsync
Loading...
Searching...
No Matches
socket.h File Reference
#include <pthread.h>
#include <stdint.h>
#include "port-hacks.h"
#include "clsync.h"
#include "ctx.h"
Include dependency graph for socket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  clsynccbqueue
 
struct  clsyncsock
 
struct  clsyncthread
 
struct  sockcmd_dat_negotiation
 
struct  sockcmd_dat_ack
 
struct  sockcmd_dat_invalidcmd
 
struct  sockcmd_dat_version
 
struct  sockcmd_dat_info
 
struct  sockcmd_dat_dump
 
struct  sockcmd_dat_eexist
 
struct  sockcmd_dat_eperm
 
struct  sockcmd_dat_set
 
struct  sockcmd
 
struct  socket_sockthreaddata
 

Macros

#define SOCKET_DEFAULT_PROT   0
 
#define SOCKET_DEFAULT_SUBPROT   SUBPROT0_TEXT
 
#define SOCKET_BUFSIZ   (1<<12)
 
#define SOCKET_PROVIDER_CLSYNC
 
#define SOCKET_MAX   SOCKET_MAX_CLSYNC
 
#define sockcmd_dat_einval   sockcmd_dat_ack
 
#define sockcmd_dat_einval_t   sockcmd_dat_ack_t
 
#define sockcmd_dat_unknowncmd   sockcmd_dat_ack
 
#define sockcmd_dat_unknowncmd_t   sockcmd_dat_ack_t
 

Typedefs

typedef int(* clsyncsock_cb_funct_t) (struct socket_sockthreaddata *thread, struct sockcmd *sockcmd_p, void *arg)
 
typedef struct clsynccbqueue clsynccbqueue_t
 
typedef struct clsyncsock clsyncsock_t
 
typedef struct clsyncthread clsyncthread_t
 
typedef enum subprot0 subprot0_t
 
typedef enum clsyncsock_state clsyncsock_state_t
 
typedef enum sockcmd_id sockcmd_id_t
 
typedef struct sockcmd_dat_negotiation sockcmd_dat_negotiation_t
 
typedef struct sockcmd_dat_ack sockcmd_dat_ack_t
 
typedef struct sockcmd_dat_invalidcmd sockcmd_dat_invalidcmd_t
 
typedef struct sockcmd_dat_version sockcmd_dat_version_t
 
typedef struct sockcmd_dat_info sockcmd_dat_info_t
 
typedef struct sockcmd_dat_dump sockcmd_dat_dump_t
 
typedef struct sockcmd_dat_eexist sockcmd_dat_eexist_t
 
typedef struct sockcmd_dat_eperm sockcmd_dat_eperm_t
 
typedef struct sockcmd_dat_set sockcmd_dat_set_t
 
typedef struct sockcmd sockcmd_t
 
typedef enum sockprocflags sockprocflags_t
 
typedef enum sockauth_id sockauth_id_t
 
typedef int(* clsyncsock_procfunct_t) (struct socket_sockthreaddata *, sockcmd_t *)
 
typedef void(* freefunct_t) (void *)
 
typedef struct socket_sockthreaddata socket_sockthreaddata_t
 

Enumerations

enum  subprot0 { SUBPROT0_TEXT , SUBPROT0_BINARY }
 
enum  clsyncsock_state {
  CLSTATE_NONE = 0 , CLSTATE_AUTH , CLSTATE_MAIN , CLSTATE_DYING ,
  CLSTATE_DIED
}
 
enum  sockcmd_id {
  SOCKCMD_REQUEST_NEGOTIATION = 000 , SOCKCMD_REPLY_NEGOTIATION = 001 , SOCKCMD_REPLY_ACK = 150 , SOCKCMD_REPLY_UNKNOWNCMD = 160 ,
  SOCKCMD_REPLY_INVALIDCMDID = 161 , SOCKCMD_REPLY_EINVAL = 162 , SOCKCMD_REPLY_EEXIST = 163 , SOCKCMD_REPLY_EPERM = 164 ,
  SOCKCMD_REPLY_ECUSTOM = 199 , SOCKCMD_REQUEST_VERSION = 200 , SOCKCMD_REQUEST_INFO = 201 , SOCKCMD_REQUEST_DUMP = 202 ,
  SOCKCMD_REQUEST_LOGIN = 210 , SOCKCMD_REQUEST_SET = 211 , SOCKCMD_REQUEST_DIE = 240 , SOCKCMD_REQUEST_QUIT = 250 ,
  SOCKCMD_REPLY_VERSION = 300 , SOCKCMD_REPLY_INFO = 301 , SOCKCMD_REPLY_DUMP = 302 , SOCKCMD_REPLY_LOGIN = 310 ,
  SOCKCMD_REPLY_SET = 311 , SOCKCMD_REPLY_DIE = 340 , SOCKCMD_REPLY_BYE = 350 , SOCKCMD_REPLY_UNEXPECTEDEND = 351 ,
  SOCKCMD_MAXID
}
 
enum  sockprocflags { SOCKPROCFLAG_NONE = 0x00 }
 
enum  sockauth_id { SOCKAUTH_UNSET = 0 , SOCKAUTH_NULL , SOCKAUTH_PAM }
 

Functions

int socket_reply (clsyncsock_t *clsyncsock_p, sockcmd_t *sockcmd_p, sockcmd_id_t cmd_id,...)
 
int socket_send (clsyncsock_t *clsyncsock, sockcmd_id_t cmd_id,...)
 
int socket_send_cb (clsyncsock_t *clsyncsock_p, sockcmd_id_t cmd_id, clsyncsock_cb_funct_t cb, void *cb_arg,...)
 
int socket_sendinvalid (clsyncsock_t *clsyncsock_p, sockcmd_t *sockcmd_p)
 
int socket_recv (clsyncsock_t *clsyncsock, sockcmd_t *sockcmd)
 
int socket_check_bysock (int sock)
 
clsyncsock_tsocket_accept (int sock)
 
int socket_cleanup (clsyncsock_t *clsyncsock_p)
 
int socket_close (clsyncsock_t *clsyncsock_p)
 
int socket_init ()
 
int socket_deinit ()
 
int socket_procclsyncsock (socket_sockthreaddata_t *arg)
 
clsyncsock_tsocket_connect_unix (const char *const socket_path)
 
clsyncsock_tsocket_listen_unix (const char *const socket_path)
 
socket_sockthreaddata_tsocket_thread_attach (clsyncsock_t *clsyncsock_p)
 
int socket_thread_start (socket_sockthreaddata_t *threaddata_p)
 

Variables

int clsyncsocks_num
 
int clsyncsocks_count
 
int clsyncsocks_last
 
const char *const textmessage_args []
 
const char *const textmessage_descr []
 

Macro Definition Documentation

◆ sockcmd_dat_einval

#define sockcmd_dat_einval   sockcmd_dat_ack

Definition at line 140 of file socket.h.

◆ sockcmd_dat_einval_t

#define sockcmd_dat_einval_t   sockcmd_dat_ack_t

Definition at line 141 of file socket.h.

◆ sockcmd_dat_unknowncmd

#define sockcmd_dat_unknowncmd   sockcmd_dat_ack

Definition at line 142 of file socket.h.

◆ sockcmd_dat_unknowncmd_t

#define sockcmd_dat_unknowncmd_t   sockcmd_dat_ack_t

Definition at line 143 of file socket.h.

◆ SOCKET_BUFSIZ

#define SOCKET_BUFSIZ   (1<<12)

Definition at line 38 of file socket.h.

◆ SOCKET_DEFAULT_PROT

#define SOCKET_DEFAULT_PROT   0

Definition at line 34 of file socket.h.

◆ SOCKET_DEFAULT_SUBPROT

#define SOCKET_DEFAULT_SUBPROT   SUBPROT0_TEXT

Definition at line 35 of file socket.h.

◆ SOCKET_MAX

#define SOCKET_MAX   SOCKET_MAX_CLSYNC

Definition at line 50 of file socket.h.

◆ SOCKET_PROVIDER_CLSYNC

#define SOCKET_PROVIDER_CLSYNC

Definition at line 43 of file socket.h.

Typedef Documentation

◆ clsynccbqueue_t

Definition at line 63 of file socket.h.

◆ clsyncsock_cb_funct_t

typedef int(* clsyncsock_cb_funct_t) (struct socket_sockthreaddata *thread, struct sockcmd *sockcmd_p, void *arg)

Definition at line 56 of file socket.h.

◆ clsyncsock_procfunct_t

typedef int(* clsyncsock_procfunct_t) (struct socket_sockthreaddata *, sockcmd_t *)

Definition at line 207 of file socket.h.

◆ clsyncsock_state_t

Definition at line 98 of file socket.h.

◆ clsyncsock_t

typedef struct clsyncsock clsyncsock_t

Definition at line 76 of file socket.h.

◆ clsyncthread_t

typedef struct clsyncthread clsyncthread_t

Definition at line 83 of file socket.h.

◆ freefunct_t

typedef void(* freefunct_t) (void *)

Definition at line 208 of file socket.h.

◆ sockauth_id_t

typedef enum sockauth_id sockauth_id_t

Definition at line 204 of file socket.h.

◆ sockcmd_dat_ack_t

Definition at line 139 of file socket.h.

◆ sockcmd_dat_dump_t

Definition at line 168 of file socket.h.

◆ sockcmd_dat_eexist_t

Definition at line 173 of file socket.h.

◆ sockcmd_dat_eperm_t

Definition at line 178 of file socket.h.

◆ sockcmd_dat_info_t

Definition at line 163 of file socket.h.

◆ sockcmd_dat_invalidcmd_t

Definition at line 148 of file socket.h.

◆ sockcmd_dat_negotiation_t

Definition at line 133 of file socket.h.

◆ sockcmd_dat_set_t

Definition at line 184 of file socket.h.

◆ sockcmd_dat_version_t

Definition at line 155 of file socket.h.

◆ sockcmd_id_t

typedef enum sockcmd_id sockcmd_id_t

Definition at line 127 of file socket.h.

◆ sockcmd_t

typedef struct sockcmd sockcmd_t

Definition at line 192 of file socket.h.

◆ socket_sockthreaddata_t

Definition at line 221 of file socket.h.

◆ sockprocflags_t

Definition at line 197 of file socket.h.

◆ subprot0_t

typedef enum subprot0 subprot0_t

Definition at line 89 of file socket.h.

Enumeration Type Documentation

◆ clsyncsock_state

Enumerator
CLSTATE_NONE 
CLSTATE_AUTH 
CLSTATE_MAIN 
CLSTATE_DYING 
CLSTATE_DIED 

Definition at line 91 of file socket.h.

◆ sockauth_id

Enumerator
SOCKAUTH_UNSET 
SOCKAUTH_NULL 
SOCKAUTH_PAM 

Definition at line 199 of file socket.h.

◆ sockcmd_id

enum sockcmd_id
Enumerator
SOCKCMD_REQUEST_NEGOTIATION 
SOCKCMD_REPLY_NEGOTIATION 
SOCKCMD_REPLY_ACK 
SOCKCMD_REPLY_UNKNOWNCMD 
SOCKCMD_REPLY_INVALIDCMDID 
SOCKCMD_REPLY_EINVAL 
SOCKCMD_REPLY_EEXIST 
SOCKCMD_REPLY_EPERM 
SOCKCMD_REPLY_ECUSTOM 
SOCKCMD_REQUEST_VERSION 
SOCKCMD_REQUEST_INFO 
SOCKCMD_REQUEST_DUMP 
SOCKCMD_REQUEST_LOGIN 
SOCKCMD_REQUEST_SET 
SOCKCMD_REQUEST_DIE 
SOCKCMD_REQUEST_QUIT 
SOCKCMD_REPLY_VERSION 
SOCKCMD_REPLY_INFO 
SOCKCMD_REPLY_DUMP 
SOCKCMD_REPLY_LOGIN 
SOCKCMD_REPLY_SET 
SOCKCMD_REPLY_DIE 
SOCKCMD_REPLY_BYE 
SOCKCMD_REPLY_UNEXPECTEDEND 
SOCKCMD_MAXID 

Definition at line 100 of file socket.h.

◆ sockprocflags

Enumerator
SOCKPROCFLAG_NONE 

Definition at line 194 of file socket.h.

◆ subprot0

enum subprot0
Enumerator
SUBPROT0_TEXT 
SUBPROT0_BINARY 

Definition at line 85 of file socket.h.

Function Documentation

◆ socket_accept()

clsyncsock_t * socket_accept ( int sock)
extern

Definition at line 177 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_check_bysock()

int socket_check_bysock ( int sock)
extern

Definition at line 108 of file socket.c.

Here is the caller graph for this function:

◆ socket_cleanup()

int socket_cleanup ( clsyncsock_t * clsyncsock_p)
extern

Definition at line 140 of file socket.c.

Here is the caller graph for this function:

◆ socket_close()

int socket_close ( clsyncsock_t * clsyncsock_p)
extern

Definition at line 150 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_connect_unix()

clsyncsock_t * socket_connect_unix ( const char *const socket_path)
extern
Here is the caller graph for this function:

◆ socket_deinit()

int socket_deinit ( )
extern

Definition at line 823 of file socket.c.

Here is the caller graph for this function:

◆ socket_init()

int socket_init ( )
extern

Definition at line 818 of file socket.c.

Here is the caller graph for this function:

◆ socket_listen_unix()

clsyncsock_t * socket_listen_unix ( const char *const socket_path)
extern

Definition at line 192 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_procclsyncsock()

int socket_procclsyncsock ( socket_sockthreaddata_t * arg)
extern

Definition at line 629 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_recv()

int socket_recv ( clsyncsock_t * clsyncsock,
sockcmd_t * sockcmd )
extern

Definition at line 501 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_reply()

int socket_reply ( clsyncsock_t * clsyncsock_p,
sockcmd_t * sockcmd_p,
sockcmd_id_t cmd_id,
... )
extern

Definition at line 331 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_send()

int socket_send ( clsyncsock_t * clsyncsock,
sockcmd_id_t cmd_id,
... )
extern

Definition at line 342 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_send_cb()

int socket_send_cb ( clsyncsock_t * clsyncsock_p,
sockcmd_id_t cmd_id,
clsyncsock_cb_funct_t cb,
void * cb_arg,
... )
extern

Definition at line 352 of file socket.c.

Here is the call graph for this function:

◆ socket_sendinvalid()

int socket_sendinvalid ( clsyncsock_t * clsyncsock_p,
sockcmd_t * sockcmd_p )
extern

Definition at line 621 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_thread_attach()

socket_sockthreaddata_t * socket_thread_attach ( clsyncsock_t * clsyncsock_p)
extern

Definition at line 797 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ socket_thread_start()

int socket_thread_start ( socket_sockthreaddata_t * threaddata_p)
extern

Definition at line 808 of file socket.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ clsyncsocks_count

int clsyncsocks_count
extern

◆ clsyncsocks_last

int clsyncsocks_last
extern

◆ clsyncsocks_num

int clsyncsocks_num
extern

◆ textmessage_args

const char* const textmessage_args[]
extern

Definition at line 72 of file socket.c.

◆ textmessage_descr

const char* const textmessage_descr[]
extern

Definition at line 88 of file socket.c.