Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
net_com.c File Reference
#include <stdlib.h>
#include <string.h>
#include "ev_mgr.h"
#include "net_split.h"
#include "net_recon.h"
#include "utils/rlutil.h"
#include "utils/teo_memory.h"
#include "modules/subscribe.h"
#include "trudp_stat.h"
#include "commands_creator.h"

Macros

#define MODULE   _ANSI_LIGHTBLUE "net_command" _ANSI_NONE
 

Typedefs

typedef struct
cmd_connect_cque_cb_data 
cmd_connect_cque_cb_data
 

Functions

int cmd_stream_cb (ksnStreamClass *ks, ksnCorePacketData *rd)
 Process CMD_STREAM teonet command. More...
 
int cmd_l0_cb (ksnetEvMgrClass *ke, ksnCorePacketData *rd)
 Process CMD_L0 teonet command. More...
 
int cmd_l0_to_cb (ksnetEvMgrClass *ke, ksnCorePacketData *rd)
 Process CMD_L0_TO teonet command. More...
 
int cmd_l0_broadcast_cb (ksnetEvMgrClass *ke, ksnCorePacketData *rd)
 Process CMD_L0_CLIENT_BROADCAST teonet command (from peer to l0) More...
 
int cmd_reconnect_cb (ksnCommandClass *kco, ksnCorePacketData *rd)
 Process CMD_RECONNECT command. More...
 
int cmd_subscribe_cb (ksnCommandClass *kco, ksnCorePacketData *rd)
 Process CMD_SUBSCRIBE, CMD_UNSUBSCRIBE and CMD_SUBSCRIBE_ANSWER commands. More...
 
int cmd_l0_check_cb (ksnCommandClass *kco, ksnCorePacketData *rd)
 Check l0 client answer from authentication application. More...
 
int cmd_l0_kick_client (ksnCommandClass *kco, ksnCorePacketData *rd)
 Kick l0 client. More...
 
ksnCommandClassksnCommandInit (void *kc)
 Initialize ksnet command class. More...
 
void ksnCommandDestroy (ksnCommandClass *kco)
 Destroy ksnet command class. More...
 
int ksnCommandCheck (ksnCommandClass *kco, ksnCorePacketData *rd)
 Check and process command. More...
 
void * ksnCommandEchoBuffer (ksnCommandClass *kco, void *data, size_t data_len, size_t *data_t_len)
 Create ECHO command buffer. More...
 
int ksnCommandSendCmdEcho (ksnCommandClass *kco, char *to, void *data, size_t data_len)
 Send ECHO command to peer. More...
 
int ksnCommandSendCmdConnect (ksnCommandClass *kco, char *to, char *name, char *addr, uint32_t port)
 Send CMD_CONNECT command to peer. More...
 
int ksnCommandSendCmdConnectA (ksnCommandClass *kco, char *to_addr, uint32_t to_port, char *name, char *addr, uint32_t port)
 Send CONNECTED command to peer by address. More...
 
int send_cmd_connect_cb (ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp, void *data)
 Send connect command. More...
 
int send_cmd_connect_cb_b (ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp, void *data)
 Send connect command. More...
 
int cmd_disconnected_cb (ksnCommandClass *kco, ksnCorePacketData *rd)
 Process CMD_DISCONNECTED command. More...
 

Variables

const char * JSON = "JSON"
 
const char * BINARY = "BINARY"
 

Macro Definition Documentation

Typedef Documentation

typedef struct cmd_connect_cque_cb_data cmd_connect_cque_cb_data

Function Documentation

int cmd_l0_broadcast_cb ( ksnetEvMgrClass ke,
ksnCorePacketData rd 
)

Process CMD_L0_CLIENT_BROADCAST teonet command (from peer to l0)

Parameters
kePointer to ksnetEvMgrClass
rdPointer to ksnCorePacketData data
Returns
If true - than command was processed by this function

References ksnCorePacketData::cmd, ksnCorePacketData::data, ksnCorePacketData::data_len, ksnetEvMgrClass::kl, teonet_cfg::l0_allow_f, and ksnetEvMgrClass::teo_cfg.

Referenced by ksnCommandCheck().

int cmd_l0_check_cb ( ksnCommandClass kco,
ksnCorePacketData rd 
)

Check l0 client answer from authentication application.

Parameters
kcoPointer to ksnCommandClass
rdPointer to ksnCorePacketData
Returns

References DEBUG, EVENT_MANAGER_OBJECT, free(), ksnetEvMgrClass::kl, ksn_printf, ksnLNullClientIsConnected(), ksnLNullClass::map, and MODULE.

Referenced by ksnCommandCheck().

int cmd_reconnect_cb ( ksnCommandClass kco,
ksnCorePacketData rd 
)
inline

Process CMD_RECONNECT command.

Parameters
kcoPointer to ksnCommandClass
rdPointer to ksnCorePacketData
Returns
True if command is processed

References ksnCorePacketData::addr, ksnCorePacketData::cmd, DEBUG_VV, EVENT_MANAGER_OBJECT, ksnCorePacketData::from, ksnCommandClass::kr, ksn_printf, MODULE, and ksnCorePacketData::port.

Referenced by ksnCommandCheck().

int cmd_subscribe_cb ( ksnCommandClass kco,
ksnCorePacketData rd 
)
void ksnCommandDestroy ( ksnCommandClass kco)

Destroy ksnet command class.

Parameters
kco

References free(), ksnCommandClass::kr, ksnCommandClass::ks, ksnSplitDestroy(), ksnCommandClass::ksscr, and teoSScrDestroy().

Referenced by ksnCoreDestroy().

void* ksnCommandEchoBuffer ( ksnCommandClass kco,
void *  data,
size_t  data_len,
size_t *  data_t_len 
)

Create ECHO command buffer.

Parameters
kcoPointer to ksnCommandClass
dataEcho data
data_lenEcho data length
data_t_lenPointer to hold ECHO buffer size
Returns
Pointer to ECHO command buffer. SHould be free after use.

References EVENT_MANAGER_OBJECT, ke, ksnetEvMgrGetTime(), and malloc().

Referenced by _check_connected(), ksnCommandSendCmdEcho(), ksnLNullSendEchoToL0(), and ksnLNullSendEchoToL0A().

ksnCommandClass* ksnCommandInit ( void *  kc)
int ksnCommandSendCmdConnect ( ksnCommandClass kco,
char *  to,
char *  name,
char *  addr,
uint32_t  port 
)

Send CMD_CONNECT command to peer.

Parameters
kcoPointer to ksnCommandClass
toSend command to peer name
nameName of peer to connect
addrIP address of peer to connect
portPort of peer to connect
Returns

References CMD_CONNECT, createCmdConnectPacket(), DEBUG_VV, EVENT_MANAGER_OBJECT, free(), ksnCommandClass::kc, ksn_printf, ksnCoreSendCmdto(), and MODULE.

Referenced by send_cmd_connect_cb(), and send_cmd_connected_cb().

int ksnCommandSendCmdConnectA ( ksnCommandClass kco,
char *  to_addr,
uint32_t  to_port,
char *  name,
char *  addr,
uint32_t  port 
)

Send CONNECTED command to peer by address.

Parameters
kcoPointer to ksnCommandClass
to_addrSend command to IP address
to_portSend command to Port
nameName of peer to connect
addrIP address of peer to connect
portPort of peer to connect
Returns

References CMD_CONNECT, createCmdConnectPacket(), DEBUG_VV, EVENT_MANAGER_OBJECT, free(), ksnCommandClass::kc, ksn_printf, ksnCoreSendto(), and MODULE.

Referenced by send_cmd_connect_cb_b().

int ksnCommandSendCmdEcho ( ksnCommandClass kco,
char *  to,
void *  data,
size_t  data_len 
)

Send ECHO command to peer.

Parameters
kcoPointer to ksnCommandClass
toSend command to peer name
dataEcho data
data_lenEcho data length
Returns
True at success

References CMD_ECHO, EVENT_MANAGER_OBJECT, free(), ksnCommandClass::kc, ke, ksnCommandEchoBuffer(), ksnCoreSendCmdto(), and ksnetEvMgrGetTime().

Referenced by check_connected_cb(), hotkeys_cb(), monitor_timer_one_cb(), ping_timer_cb(), and teo::Teonet::sendEchoTo().

int send_cmd_connect_cb ( ksnetArpClass ka,
char *  peer_name,
ksnet_arp_data_ext *  arp,
void *  data 
)

Send connect command.

Parameters
kaPointer to ksnetArpClass
peer_namePeer name
arp_dataPointer to ARP data ksnet_arp_data
dataPointer to ksnCorePacketData

References ksnCorePacketData::addr, data, ksnCorePacketData::from, ksnetArpClass::ke, ksnCommandSendCmdConnect(), and ksnCorePacketData::port.

Referenced by ksnCoreCheckNewPeer().

int send_cmd_connect_cb_b ( ksnetArpClass ka,
char *  peer_name,
ksnet_arp_data_ext *  arp,
void *  data 
)

Send connect command.

Parameters
kaPointer to ksnetArpClass
peer_namePeer name
arp_dataPointer to ARP data ksnet_arp_data
dataPointer to ksnCorePacketData

References ksnCorePacketData::addr, data, ksnCorePacketData::from, ksnetArpClass::ke, ksnCommandSendCmdConnectA(), and ksnCorePacketData::port.

Referenced by ksnCoreCheckNewPeer().

Variable Documentation

const char* BINARY = "BINARY"
const char* JSON = "JSON"