Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
l0-server.h
Go to the documentation of this file.
1 
8 #ifndef L0_SERVER_H
9 #define L0_SERVER_H
10 
11 #include <ev.h>
12 #include <pbl.h>
13 #include "modules/cque.h"
14 #include "net_com.h"
15 #include "subscribe.h"
16 #include "teonet_l0_client.h"
17 
22 typedef struct ksnLNullData { // \TODO: will be renamed to teoL0Data
23  ev_io w;
24  char *name;
25  size_t name_length;
26  void *read_buffer;
27  size_t read_buffer_ptr;
29 
30  char *t_addr;
31  int t_port;
32  int t_channel;
33  double last_time;
34 
35  teoLNullEncryptionContext *server_crypt; // \TODO: will be renamed to teoL0EncryptionContext
36 } ksnLNullData;
37 
41 typedef struct ksnLNullClass { // \TODO: will be renamed to teoL0Class
42  void *ke;
43  PblMap *map;
44  PblMap *map_n;
45  int fd;
46  ksnLNullSStat stat;
47  int fd_trudp;
50 
51 #pragma pack(push)
52 #pragma pack(1)
53 
58 typedef struct ksnLNullSPacket { // \TODO: will be renamed to teoL0SPacket
59  uint8_t cmd;
61  uint16_t data_length;
62  char payload[];
64 
65 #pragma pack(pop)
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
73 int ksnLNullSendToL0(void *ke, char *addr, int port, char *cname,
74  size_t cname_length, uint8_t cmd, void *data, size_t data_len);
75 int ksnLNullSendEchoToL0(void *ke, char *addr, int port, char *cname,
76  size_t cname_length, void *data, size_t data_len);
77 int ksnLNullSendEchoToL0A(void *ke, char *addr, int port, char *cname,
78  size_t cname_length, void *data, size_t data_len);
79 int ksnLNullClientIsConnected(ksnLNullClass *kl, char *client_name);
80 teonet_client_data_ar *ksnLNullClientsList(ksnLNullClass *kl);
81 size_t ksnLNullClientsListLength(teonet_client_data_ar *clients_data);
82 ksnLNullSStat *ksnLNullStat(ksnLNullClass *kl);
84 ssize_t ksnLNullPacketSend(ksnLNullClass *kl, int fd, void *pkg, size_t pkg_length);
85 void ksnLNullClientDisconnect(ksnLNullClass *kl, int fd, int remove_f);
86 
87 teoLNullEncryptionContext *ksnLNullClientGetCrypto(ksnLNullClass *kl, int fd);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif /* L0_SERVER_H */
ksnLNullClass * ksnLNullInit(void *ke)
Initialize ksnLNull module class.
Definition: l0-server.c:96
uint16_t data_length
Packet data length.
Definition: l0-server.h:61
teoLNullEncryptionContext * ksnLNullClientGetCrypto(ksnLNullClass *kl, int fd)
Returns L0 client encryption context and return it if available.
Definition: l0-server.c:2081
int ksnLNullSendEchoToL0A(void *ke, char *addr, int port, char *cname, size_t cname_length, void *data, size_t data_len)
Definition: l0-server.c:523
const char data[]
Make it with: gcc -o post-callback post-callback.c -lcurl.
Definition: post-callback.c:23
char * name
Clients name.
Definition: l0-server.h:24
uint8_t client_name_length
Client name length (includes null terminated)
Definition: l0-server.h:60
int fd
L0 TCP Server FD.
Definition: l0-server.h:45
void ksnLNullClientDisconnect(ksnLNullClass *kl, int fd, int remove_f)
Disconnect l0 Server client.
Definition: l0-server.c:1037
struct ksnLNullSPacket ksnLNullSPacket
L0 Server resend to peer packet data structure.
size_t read_buffer_ptr
Pointer in read buffer.
Definition: l0-server.h:27
PblMap * map_n
Pointer to the L0 FDs map (by name)
Definition: l0-server.h:44
int ksnLNullClientIsConnected(ksnLNullClass *kl, char *client_name)
Check if L0 client is connected and return it FD.
Definition: l0-server.c:1347
teonet_client_data_ar * ksnLNullClientsList(ksnLNullClass *kl)
Create list of clients.
Definition: l0-server.c:1684
struct ksnLNullClass ksnLNullClass
ksnLNull Class structure definition
ksnCQue Class structure definition
Definition: cque.h:18
int ksnLNullSendEchoToL0(void *ke, char *addr, int port, char *cname, size_t cname_length, void *data, size_t data_len)
Send echo to L0 client.
Definition: l0-server.c:510
KSNet core received data structure.
Definition: net_com.h:107
struct ksnLNullData ksnLNullData
File: l0-server.h Author: Kirill Scherba kirill@scherba.ru
size_t read_buffer_size
Read buffer size.
Definition: l0-server.h:28
int t_channel
TR-UDP channel.
Definition: l0-server.h:32
double last_time
Definition: l0-server.h:33
File: l0-server.h Author: Kirill Scherba kirill@scherba.ru
Definition: l0-server.h:22
#define rd
ssize_t ksnLNullPacketSend(ksnLNullClass *kl, int fd, void *pkg, size_t pkg_length)
Send packet to L0 client.
Definition: l0-server.c:923
char payload[]
Сlient name (includes null terminated) + packet data.
Definition: l0-server.h:62
void * read_buffer
Pointer to saved buffer.
Definition: l0-server.h:26
#define ke
int t_port
TR-UDP port.
Definition: l0-server.h:31
uint8_t cmd
Command number.
Definition: l0-server.h:59
size_t ksnLNullClientsListLength(teonet_client_data_ar *clients_data)
Return size of teonet_client_data_ar data.
Definition: l0-server.c:1723
L0 Server resend to peer packet data structure.
Definition: l0-server.h:58
int fd_trudp
Last free TR-UDP L0 FD.
Definition: l0-server.h:47
ksnCQueClass * cque
CQUe to check dead clients.
Definition: l0-server.h:48
char * t_addr
TR-UDP IP address.
Definition: l0-server.h:30
void ksnLNullDestroy(ksnLNullClass *kl)
Destroy ksnLNull module class.
Definition: l0-server.c:149
int ksnLNulltrudpCheckPaket(ksnLNullClass *kl, ksnCorePacketData *rd)
Check and process L0 packet received through TR-UDP.
Definition: l0-server.c:2021
ksnLNullSStat stat
L0 server statistic.
Definition: l0-server.h:46
ksnLNull Class structure definition
Definition: l0-server.h:41
ev_io w
TCP Client watcher.
Definition: l0-server.h:23
size_t name_length
Clients name length.
Definition: l0-server.h:25
int ksnLNullSendToL0(void *ke, char *addr, int port, char *cname, size_t cname_length, uint8_t cmd, void *data, size_t data_len)
Send data to L0 client.
Definition: l0-server.c:466
void * ke
Pointer to ksnEvMgrClass.
Definition: l0-server.h:42
PblMap * map
Pointer to the L0 clients map (by fd)
Definition: l0-server.h:43
int fd
Definition: teol0cli.c:22
teoLNullEncryptionContext * server_crypt
Definition: l0-server.h:35
ksnLNullSStat * ksnLNullStat(ksnLNullClass *kl)
Get L0 server statistic.
Definition: l0-server.c:367