Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
net_com.h File Reference
#include "net_arp.h"
#include "teonet_l0_client.h"
#include <stdint.h>

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...
 

Enumerations

enum  ksnCMD {
  CMD_NONE = 0, CMD_1_RESERVED, CMD_2_RESERVED, CMD_3_RESERVED,
  CMD_CONNECT_R, CMD_CONNECT, CMD_DISCONNECTED, CMD_VPN,
  CMD_RESET, CMD_64_RESERVED = 64, CMD_ECHO, CMD_ECHO_ANSWER,
  CMD_TUN, CMD_SPLIT, CMD_STREAM, CMD_L0,
  CMD_L0_TO, CMD_PEERS, CMD_PEERS_ANSWER, CMD_RESEND,
  CMD_RECONNECT, CMD_RECONNECT_ANSWER, CMD_AUTH, CMD_AUTH_ANSWER,
  CMD_L0_CLIENTS, CMD_L0_CLIENTS_ANSWER, CMD_SUBSCRIBE, CMD_UNSUBSCRIBE,
  CMD_SUBSCRIBE_ANSWER, CMD_L0_CLIENTS_N, CMD_L0_CLIENTS_N_ANSWER, CMD_GET_NUM_PEERS,
  CMD_GET_NUM_PEERS_ANSWER, CMD_L0_STAT, CMD_L0_STAT_ANSWER, CMD_HOST_INFO,
  CMD_HOST_INFO_ANSWER, CMD_L0_INFO, CMD_L0_INFO_ANSWER, CMD_TRUDP_INFO,
  CMD_TRUDP_INFO_ANSWER, CMD_L0_AUTH, CMD_AM, CMD_LOGGING,
  CMD_L0_CLIENT_RESET, CMD_SUBSCRIBE_RND, CMD_L0_CLIENT_BROADCAST, CMD_GET_PUBLIC_IP,
  CMD_GET_PUBLIC_IP_ANSWER, CMD_128_RESERVED = 128, CMD_USER, CMD_CONFIRM_AUTH = 147,
  CMD_192_RESERVED = 192, CMD_USER_NR, CMD_ECHO_UNRELIABLE = 195, CMD_ECHO_UNRELIABLE_ANSWER = 196,
  CMD_LAST = 255
}
 File: net_com.c Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 

Functions

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...
 
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...
 

Macro Definition Documentation

#define CMD_TRUDP_CHECK (   CMD)    (!CMD || CMD == CMD_CONNECT || (CMD >= CMD_64_RESERVED && CMD < CMD_192_RESERVED))

Typedef Documentation

KSNet command class data.

KSNet core received data structure.

Enumeration Type Documentation

enum ksnCMD

File: net_com.c Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Created on April 29, 2015, 7:57 PM

KSNet Network command processing module

Enumerator
CMD_NONE 

#0 Common command

CMD_1_RESERVED 

#1 Reserver for future use

CMD_2_RESERVED 

#2 Reserver for future use

CMD_3_RESERVED 

#3 Reserver for future use

CMD_CONNECT_R 

#4 A Peer want connect to r-host

CMD_CONNECT 

#5 Inform peer about connected peer

CMD_DISCONNECTED 

#6 Inform peer about disconnected peer

CMD_VPN 

#7 VPN command

CMD_RESET 

#8 Reset command, data: byte or char 0 - soft reset; 1 - hard reset

CMD_64_RESERVED 

#64 Reserver for future use

CMD_ECHO 

#65 Echo test message: auto replay test message command

CMD_ECHO_ANSWER 

#66 Answer to auto replay message command

CMD_TUN 

#67 Tunnel command

CMD_SPLIT 

#68 Group of packets (Splited packets)

CMD_STREAM 

#69 Stream command

CMD_L0 

#70 Command from L0 Client

CMD_L0_TO 

#71 Command to L0 Client

CMD_PEERS 

#72 Get peers, allow JSON in request

CMD_PEERS_ANSWER 

#73 Get peers answer

CMD_RESEND 

#74 Resend command

CMD_RECONNECT 

#75 Reconnect command

CMD_RECONNECT_ANSWER 

#76 Reconnect answer command

CMD_AUTH 

#77 Auth command

CMD_AUTH_ANSWER 

#78 Auth answer command

CMD_L0_CLIENTS 

#79 Request clients list

CMD_L0_CLIENTS_ANSWER 

#80 Clients list

CMD_SUBSCRIBE 

#81 Subscribe to event

CMD_UNSUBSCRIBE 

#82 UnSubscribe from event

CMD_SUBSCRIBE_ANSWER 

#83 Subscribe answer

CMD_L0_CLIENTS_N 

#84 Request clients number, allow JSON in request

CMD_L0_CLIENTS_N_ANSWER 

#85 Clients number

CMD_GET_NUM_PEERS 

#86 Request number of peers, allow JSON in request

CMD_GET_NUM_PEERS_ANSWER 

#87 Number of peers answer

CMD_L0_STAT 

#88 Get LO server statistic request, allow JSON in request

CMD_L0_STAT_ANSWER 

#89 LO server statistic

CMD_HOST_INFO 

#90 Request host info, allow JSON in request

CMD_HOST_INFO_ANSWER 

#91 Host info amswer

CMD_L0_INFO 

#92 L0 server info request

CMD_L0_INFO_ANSWER 

#93 L0 server info answer

CMD_TRUDP_INFO 

#94 TR-UDP info request

CMD_TRUDP_INFO_ANSWER 

#95 TR-UDP info answer

CMD_L0_AUTH 

#96 L0 server auth request answer command

CMD_AM 

#97 AM application command

CMD_LOGGING 

#98 LOGGING command

CMD_L0_CLIENT_RESET 

#99 L0 client reset command

CMD_SUBSCRIBE_RND 

#100 Subscribe command extension. (Send answer for one random peer by type)

CMD_L0_CLIENT_BROADCAST 

#101 Send data to all L0 clients

CMD_GET_PUBLIC_IP 

#102 Request public IPs, which set by l0_public_ipv4, l0_public_ipv6 parameters

CMD_GET_PUBLIC_IP_ANSWER 

#103 Public IPs answer

CMD_128_RESERVED 

#128 Reserver for future use

CMD_USER 

#129 User command

CMD_CONFIRM_AUTH 

#147 Confirm auth

CMD_192_RESERVED 

#192 Reserver for future use

CMD_USER_NR 

#193 User command

CMD_ECHO_UNRELIABLE 

#195

CMD_ECHO_UNRELIABLE_ANSWER 

#196

CMD_LAST 

#255 Last command Reserved for future use

Function Documentation

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 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().