Teonet library
0.4.7
|
Go to the source code of this file.
Data Structures | |
struct | ksnCommandClass |
KSNet command class data. More... | |
struct | ksnCorePacketData |
KSNet core received data structure. More... | |
Macros | |
#define | CMD_TRUDP_CHECK(CMD) (!CMD || CMD == CMD_CONNECT || (CMD >= CMD_64_RESERVED && CMD < CMD_192_RESERVED)) |
Typedefs | |
typedef struct ksnCommandClass | ksnCommandClass |
KSNet command class data. More... | |
typedef struct ksnCorePacketData | ksnCorePacketData |
KSNet core received data structure. More... | |
Functions | |
ksnCommandClass * | ksnCommandInit (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... | |
int | ksnCommandSendCmdEcho (ksnCommandClass *kco, char *to, void *data, size_t data_len) |
Send ECHO command to peer. More... | |
void * | ksnCommandEchoBuffer (ksnCommandClass *kco, void *data, size_t data_len, size_t *data_t_len) |
Create ECHO command buffer. More... | |
int | ksnCommandSendCmdConnect (ksnCommandClass *kco, char *to, char *name, char *addr, uint32_t port) |
Send CMD_CONNECT command to peer. More... | |
int | cmd_disconnected_cb (ksnCommandClass *kco, ksnCorePacketData *rd) |
Process CMD_DISCONNECTED 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 | send_cmd_connect_cb (ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp, void *data) |
Send connect command. More... | |
#define CMD_TRUDP_CHECK | ( | CMD | ) | (!CMD || CMD == CMD_CONNECT || (CMD >= CMD_64_RESERVED && CMD < CMD_192_RESERVED)) |
Referenced by ksnLNullPacketSend(), and ksnTRUDPsendto().
typedef struct ksnCommandClass ksnCommandClass |
KSNet command class data.
typedef struct ksnCorePacketData ksnCorePacketData |
KSNet core received data structure.
enum ksnCMD |
File: net_com.c Author: Kirill Scherba kiril l@sc herba .ru
Created on April 29, 2015, 7:57 PM
KSNet Network command processing module
int cmd_disconnected_cb | ( | ksnCommandClass * | kco, |
ksnCorePacketData * | rd | ||
) |
Process CMD_DISCONNECTED command.
A peer send disconnect command
kco | Pointer to ksnCommandClass |
rd | Pointer to ksnCorePacketData |
References ksnCorePacketData::addr, ARP_TABLE_OBJECT, ksnCorePacketData::cmd, ksnCorePacketData::data, DEBUG_VV, EV_K_DISCONNECTED, ksnetEvMgrClass::event_cb, EVENT_MANAGER_OBJECT, free(), ksnCorePacketData::from, ksnCorePacketData::from_len, ksnCommandClass::kr, ksn_printf, ksnet_formatMessage(), ksnetArpRemove(), ksnCommandClass::ksscr, MODULE, ksnCorePacketData::port, teonet_cfg::r_host_name, ksnetEvMgrClass::teo_cfg, teoMetricGauge(), teoSScrSend(), and ksnetEvMgrClass::tm.
Referenced by ksnCommandCheck().
int ksnCommandCheck | ( | ksnCommandClass * | kco, |
ksnCorePacketData * | rd | ||
) |
Check and process command.
References ksnCorePacketData::addr, ksnCorePacketData::cmd, CMD_CONNECT, CMD_CONNECT_R, CMD_DISCONNECTED, cmd_disconnected_cb(), CMD_ECHO, CMD_ECHO_ANSWER, CMD_ECHO_UNRELIABLE, CMD_GET_NUM_PEERS, CMD_GET_PUBLIC_IP, CMD_HOST_INFO, CMD_HOST_INFO_ANSWER, CMD_L0, CMD_L0_AUTH, cmd_l0_broadcast_cb(), cmd_l0_cb(), cmd_l0_check_cb(), CMD_L0_CLIENT_BROADCAST, CMD_L0_CLIENT_RESET, CMD_L0_CLIENTS, CMD_L0_CLIENTS_N, CMD_L0_INFO, cmd_l0_kick_client(), CMD_L0_STAT, CMD_L0_TO, cmd_l0_to_cb(), CMD_NONE, CMD_PEERS, CMD_RECONNECT, CMD_RECONNECT_ANSWER, cmd_reconnect_cb(), CMD_RESEND, CMD_RESET, CMD_SPLIT, CMD_STREAM, cmd_stream_cb(), CMD_SUBSCRIBE, CMD_SUBSCRIBE_ANSWER, cmd_subscribe_cb(), CMD_SUBSCRIBE_RND, CMD_TRUDP_INFO, CMD_TUN, cmd_tun_cb(), CMD_UNSUBSCRIBE, CMD_VPN, cmd_vpn_cb(), ksnCorePacketData::data, ksnCorePacketData::data_len, DEBUG_VV, EVENT_MANAGER_OBJECT, ksnCorePacketData::from, ke, ksnetEvMgrClass::kl, ksnetEvMgrClass::ks, ksn_printf, ksnetEvMgrClass::ktun, ksnetEvMgrClass::kvpn, MODULE, and ksnCorePacketData::port.
Referenced by cmd_l0_cb(), and ksnCoreProcessPacket().
void ksnCommandDestroy | ( | ksnCommandClass * | kco | ) |
Destroy ksnet command class.
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.
kco | Pointer to ksnCommandClass |
data | Echo data |
data_len | Echo data length |
data_t_len | Pointer to hold ECHO buffer size |
References EVENT_MANAGER_OBJECT, ke, ksnetEvMgrGetTime(), and malloc().
Referenced by _check_connected(), ksnCommandSendCmdEcho(), ksnLNullSendEchoToL0(), and ksnLNullSendEchoToL0A().
ksnCommandClass* ksnCommandInit | ( | void * | kc | ) |
Initialize ksnet command class.
References kc, ksnCommandClass::kc, ke, ksnCommandClass::kr, ksnCommandClass::ks, ksnReconnectInit(), ksnSplitInit(), ksnCommandClass::ksscr, teo_malloc(), and teoSScrInit().
Referenced by ksnCoreInit().
int ksnCommandSendCmdConnect | ( | ksnCommandClass * | kco, |
char * | to, | ||
char * | name, | ||
char * | addr, | ||
uint32_t | port | ||
) |
Send CMD_CONNECT command to peer.
kco | Pointer to ksnCommandClass |
to | Send command to peer name |
name | Name of peer to connect |
addr | IP address of peer to connect |
port | Port of peer to connect |
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 ksnCommandSendCmdEcho | ( | ksnCommandClass * | kco, |
char * | to, | ||
void * | data, | ||
size_t | data_len | ||
) |
Send ECHO command to peer.
kco | Pointer to ksnCommandClass |
to | Send command to peer name |
data | Echo data |
data_len | Echo data length |
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.
ka | Pointer to ksnetArpClass |
peer_name | Peer name |
arp_data | Pointer to ARP data ksnet_arp_data |
data | Pointer 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.
ka | Pointer to ksnetArpClass |
peer_name | Peer name |
arp_data | Pointer to ARP data ksnet_arp_data |
data | Pointer to ksnCorePacketData |
References ksnCorePacketData::addr, data, ksnCorePacketData::from, ksnetArpClass::ke, ksnCommandSendCmdConnectA(), and ksnCorePacketData::port.
Referenced by ksnCoreCheckNewPeer().