Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
l0-server.h File Reference
#include <ev.h>
#include <pbl.h>
#include "modules/cque.h"
#include "net_com.h"
#include "subscribe.h"
#include "teonet_l0_client.h"

Go to the source code of this file.

Data Structures

struct  ksnLNullData
 File: l0-server.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
struct  ksnLNullClass
 ksnLNull Class structure definition More...
 
struct  ksnLNullSPacket
 L0 Server resend to peer packet data structure. More...
 

Typedefs

typedef struct ksnLNullData ksnLNullData
 File: l0-server.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
typedef struct ksnLNullClass ksnLNullClass
 ksnLNull Class structure definition More...
 
typedef struct ksnLNullSPacket ksnLNullSPacket
 L0 Server resend to peer packet data structure. More...
 

Functions

ksnLNullClassksnLNullInit (void *ke)
 Initialize ksnLNull module class. More...
 
void ksnLNullDestroy (ksnLNullClass *kl)
 Destroy ksnLNull module class. More...
 
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. More...
 
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. More...
 
int ksnLNullSendEchoToL0A (void *ke, char *addr, int port, char *cname, size_t cname_length, void *data, size_t data_len)
 
int ksnLNullClientIsConnected (ksnLNullClass *kl, char *client_name)
 Check if L0 client is connected and return it FD. More...
 
teonet_client_data_ar * ksnLNullClientsList (ksnLNullClass *kl)
 Create list of clients. More...
 
size_t ksnLNullClientsListLength (teonet_client_data_ar *clients_data)
 Return size of teonet_client_data_ar data. More...
 
ksnLNullSStat * ksnLNullStat (ksnLNullClass *kl)
 Get L0 server statistic. More...
 
int ksnLNulltrudpCheckPaket (ksnLNullClass *kl, ksnCorePacketData *rd)
 Check and process L0 packet received through TR-UDP. More...
 
ssize_t ksnLNullPacketSend (ksnLNullClass *kl, int fd, void *pkg, size_t pkg_length)
 Send packet to L0 client. More...
 
void ksnLNullClientDisconnect (ksnLNullClass *kl, int fd, int remove_f)
 Disconnect l0 Server client. More...
 
teoLNullEncryptionContext * ksnLNullClientGetCrypto (ksnLNullClass *kl, int fd)
 Returns L0 client encryption context and return it if available. More...
 

Typedef Documentation

typedef struct ksnLNullClass ksnLNullClass

ksnLNull Class structure definition

typedef struct ksnLNullData ksnLNullData

File: l0-server.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Created on October 8, 2015, 1:39 PM L0 Server map data structure

L0 Server resend to peer packet data structure.

Function Documentation

void ksnLNullClientDisconnect ( ksnLNullClass kl,
int  fd,
int  remove_f 
)

Disconnect l0 Server client.

Called when client disconnected or when the L0 Server closing. Close TCP connections and remove data from L0 Server clients map.

Parameters
klPointer to ksnLNullClass
fdTCP client connection file descriptor
remove_fIf true than remove disconnected record from map

References _send_subscribe_event_disconnected(), CONNECT, ksnetEvMgrClass::ev_loop, EVENT_MANAGER_OBJECT, free(), ksn_printf, malloc(), ksnLNullClass::map, ksnLNullClass::map_n, MODULE, ksnLNullData::name, ksnLNullData::name_length, pblMapRemoveFree(), ksnLNullData::read_buffer, ksnLNullData::read_buffer_ptr, ksnLNullData::read_buffer_size, ksnLNullData::server_crypt, ksnLNullClass::stat, ksnLNullData::t_addr, and ksnLNullData::w.

Referenced by _check_connected(), cmd_l0_kick_client(), ksnLNulltrudpCheckPaket(), and trudp_event_cb().

teoLNullEncryptionContext* ksnLNullClientGetCrypto ( ksnLNullClass kl,
int  fd 
)

Returns L0 client encryption context and return it if available.

Parameters
klPointer to ksnLNullClass
fdClient name connection fd
Returns
teoLNullEncryptionContext pointer or null if not available

References ksnLNullData::server_crypt.

int ksnLNullClientIsConnected ( ksnLNullClass kl,
char *  client_name 
)

Check if L0 client is connected and return it FD.

Parameters
klPointer to ksnLNullClass
client_nameClient name
Returns
Connection fd or NULL ifnot connected

References ksnLNullClass::map_n.

Referenced by cmd_l0_check_cb(), cmd_l0_kick_client(), cmd_l0_to_cb(), and ksnCoreSendCmdto().

teonet_client_data_ar* ksnLNullClientsList ( ksnLNullClass kl)
size_t ksnLNullClientsListLength ( teonet_client_data_ar *  clients_data)
inline

Return size of teonet_client_data_ar data.

Parameters
clients_data
Returns
Size of teonet_client_data_ar data
void ksnLNullDestroy ( ksnLNullClass kl)

Destroy ksnLNull module class.

Parameters
klPointer to ksnLNullClass

References free(), ksnLNullClass::map, and ksnLNullClass::map_n.

Referenced by modules_destroy().

ksnLNullClass* ksnLNullInit ( void *  ke)

Initialize ksnLNull module class.

Parameters
kePointer to ksnetEvMgrClass
Returns
Pointer to created ksnLNullClass or NULL if error occurred

References ksnLNullClass::fd_trudp, ksnLNullClass::ke, ke, malloc(), ksnLNullClass::map, ksnLNullClass::map_n, and ksnLNullClass::stat.

Referenced by modules_init().

ssize_t ksnLNullPacketSend ( ksnLNullClass kl,
int  fd,
void *  pkg,
size_t  pkg_length 
)

Send packet to L0 client.

Parameters
fdL0 client socket
pkgPackage to send
pkg_lengthPackage length
Returns
Length of send data or -1 at error

< Remote address

< Remote address length

References CMD_TRUDP_CHECK, dump_bytes(), EVENT_MANAGER_OBJECT, ksnLNullClass::ke, ksn_printf, ksnTRUDPsendto(), MODULE, ksnLNullData::server_crypt, ksnLNullClass::stat, ksnLNullData::t_addr, and ksnLNullData::t_port.

Referenced by _check_connected(), cmd_l0_to_cb(), and ksnCoreSendCmdto().

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.

Parameters
kePointer to ksnetEvMgrClass
addrIP address of remote peer
portPort of remote peer
cnameL0 client name (include trailing zero)
cname_lengthLength of the L0 client name
dataData
data_lenData length
Returns
Return 0 if success; -1 if data length is too lage (more than 32319)

References CMD_ECHO, free(), kc, ksnCommandEchoBuffer(), and ksnLNullSendToL0().

Referenced by teo::Teonet::sendEchoToL0().

int ksnLNullSendEchoToL0A ( void *  ke,
char *  addr,
int  port,
char *  cname,
size_t  cname_length,
void *  data,
size_t  data_len 
)
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.

Usually it is an answer to request from L0 client

Parameters
kePointer to ksnetEvMgrClass
addrIP address of remote peer
portPort of remote peer
cnameL0 client name (include trailing zero)
cname_lengthLength of the L0 client name
cmdCommand
dataData
data_lenData length
Returns
Return 0 if success; -1 if data length is too lage (more than 32319)

References ksnLNullSPacket::client_name_length, ksnLNullSPacket::cmd, CMD_L0_TO, ksnLNullSPacket::data_length, DEBUG_VV, free(), kc, ksn_printf, ksnCoreSendto(), malloc(), MODULE, and ksnLNullSPacket::payload.

Referenced by ksnLNullSendEchoToL0(), sendCmdAnswerToBinaryA(), teo::Teonet::sendToL0(), and teoSScrSend().

ksnLNullSStat* ksnLNullStat ( ksnLNullClass kl)

Get L0 server statistic.

Parameters
klPointer to ksnLNullClass
Returns
Pointer to ksnLNullSStat or NULL if L0 server has not started

References ksnLNullClass::stat.

Referenced by metric_teonet_count().