Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
net_com.h
Go to the documentation of this file.
1 
11 #ifndef NET_COM_H
12 #define NET_COM_H
13 
14 //#include "net_recon.h"
15 
16 
17 #include "net_arp.h"
18 #include "teonet_l0_client.h"
19 #include <stdint.h>
20 enum ksnCMD {
21 
22  // Core level not TR-UDP mode: 0...63
23  CMD_NONE = 0,
32 
33  // Core level TR-UDP mode: 64...127
66 
73 
76 
77  // Application level TR-UDP mode: 128...191
81 
82  // Application level not TR-UDP mode: 192...254
87  CMD_LAST = 255
88 };
89 
90 #define CMD_TRUDP_CHECK(CMD) (!CMD || CMD == CMD_CONNECT || (CMD >= CMD_64_RESERVED && CMD < CMD_192_RESERVED))
91 
95 typedef struct ksnCommandClass {
96 
97  void *kc;
98  void *ks;
99  void *kr;
100  void *ksscr;
101 
103 
107 typedef struct ksnCorePacketData {
108 
109  char *addr;
110  int port;
111  int mtu;
112  char *from;
113  uint8_t from_len;
114 
115  uint8_t cmd;
116 
117  void *data;
118  size_t data_len;
119 
120  void *raw_data;
121  size_t raw_data_len;
122 
123  ksnet_arp_data_ext *arp;
124 
125  int l0_f;
126 
128 
129 
130 #ifdef __cplusplus
131 extern "C" {
132 #endif
133 
137 int ksnCommandSendCmdEcho(ksnCommandClass *kco, char *to, void *data,
138  size_t data_len);
139 void *ksnCommandEchoBuffer(ksnCommandClass *kco, void *data, size_t data_len,
140  size_t *data_t_len);
141 int ksnCommandSendCmdConnect(ksnCommandClass *kco, char *to, char *name,
142  char *addr, uint32_t port);
143 
145 int send_cmd_connect_cb_b(ksnetArpClass *ka, char *peer_name,
146  ksnet_arp_data_ext *arp, void *data);
147 int send_cmd_connect_cb(ksnetArpClass *ka, char *peer_name,
148  ksnet_arp_data_ext *arp, void *data);
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* NET_COM_H */
#86 Request number of peers, allow JSON in request
Definition: net_com.h:56
File: net_arp.h Author: Kirill Scherba kirill@scherba.ru
Definition: net_arp.h:24
ksnCommandClass * ksnCommandInit(void *kc)
Initialize ksnet command class.
Definition: net_com.c:63
ksnet_arp_data_ext * arp
Pointer to extended ARP Table data.
Definition: net_com.h:123
void * data
Received data.
Definition: net_com.h:117
#102 Request public IPs, which set by l0_public_ipv4, l0_public_ipv6 parameters
Definition: net_com.h:74
#68 Group of packets (Splited packets)
Definition: net_com.h:38
const char data[]
Make it with: gcc -o post-callback post-callback.c -lcurl.
Definition: post-callback.c:23
uint8_t cmd
Command ID.
Definition: net_com.h:115
#3 Reserver for future use
Definition: net_com.h:26
size_t data_len
Received data length.
Definition: net_com.h:118
int mtu
Remote mtu.
Definition: net_com.h:111
#64 Reserver for future use
Definition: net_com.h:34
#95 TR-UDP info answer
Definition: net_com.h:65
char * from
Remote peer name.
Definition: net_com.h:112
#98 LOGGING command
Definition: net_com.h:69
ksnCMD
File: net_com.c Author: Kirill Scherba kirill@scherba.ru
Definition: net_com.h:20
#6 Inform peer about disconnected peer
Definition: net_com.h:29
#72 Get peers, allow JSON in request
Definition: net_com.h:42
#101 Send data to all L0 clients
Definition: net_com.h:72
void * kr
Pointer to KSNet reconnect class.
Definition: net_com.h:99
size_t raw_data_len
Received packet length.
Definition: net_com.h:121
#193 User command
Definition: net_com.h:84
#82 UnSubscribe from event
Definition: net_com.h:52
#90 Request host info, allow JSON in request
Definition: net_com.h:60
#73 Get peers answer
Definition: net_com.h:43
#71 Command to L0 Client
Definition: net_com.h:41
#76 Reconnect answer command
Definition: net_com.h:46
#96 L0 server auth request answer command
Definition: net_com.h:67
#83 Subscribe answer
Definition: net_com.h:53
#1 Reserver for future use
Definition: net_com.h:24
#92 L0 server info request
Definition: net_com.h:62
#89 LO server statistic
Definition: net_com.h:59
uint8_t from_len
Remote peer name length.
Definition: net_com.h:113
#99 L0 client reset command
Definition: net_com.h:70
KSNet core received data structure.
Definition: net_com.h:107
#75 Reconnect command
Definition: net_com.h:45
struct ksnCommandClass ksnCommandClass
KSNet command class data.
#255 Last command Reserved for future use
Definition: net_com.h:87
#5 Inform peer about connected peer
Definition: net_com.h:28
void * ks
Pointer to KSNet split class.
Definition: net_com.h:98
#define kc
Definition: hotkeys.c:72
#87 Number of peers answer
Definition: net_com.h:57
#129 User command
Definition: net_com.h:79
void ksnCommandDestroy(ksnCommandClass *kco)
Destroy ksnet command class.
Definition: net_com.c:78
#147 Confirm auth
Definition: net_com.h:80
#0 Common command
Definition: net_com.h:23
int ksnCommandSendCmdConnect(ksnCommandClass *kco, char *to, char *name, char *addr, uint32_t port)
Send CMD_CONNECT command to peer.
Definition: net_com.c:310
#80 Clients list
Definition: net_com.h:50
#define rd
#195
Definition: net_com.h:85
#65 Echo test message: auto replay test message command
Definition: net_com.h:35
#4 A Peer want connect to r-host
Definition: net_com.h:27
struct ksnCorePacketData ksnCorePacketData
KSNet core received data structure.
#88 Get LO server statistic request, allow JSON in request
Definition: net_com.h:58
#103 Public IPs answer
Definition: net_com.h:75
void * ksnCommandEchoBuffer(ksnCommandClass *kco, void *data, size_t data_len, size_t *data_t_len)
Create ECHO command buffer.
Definition: net_com.c:260
#70 Command from L0 Client
Definition: net_com.h:40
#78 Auth answer command
Definition: net_com.h:48
#85 Clients number
Definition: net_com.h:55
KSNet command class data.
Definition: net_com.h:95
#8 Reset command, data: byte or char 0 - soft reset; 1 - hard reset
Definition: net_com.h:31
int ksnCommandCheck(ksnCommandClass *kco, ksnCorePacketData *rd)
Check and process command.
Definition: net_com.c:91
void * ksscr
Pointer to teoSScrClass.
Definition: net_com.h:100
void * raw_data
Received packet data.
Definition: net_com.h:120
#84 Request clients number, allow JSON in request
Definition: net_com.h:54
#81 Subscribe to event
Definition: net_com.h:51
#196
Definition: net_com.h:86
#192 Reserver for future use
Definition: net_com.h:83
#77 Auth command
Definition: net_com.h:47
int l0_f
L0 command flag (from set to l0 client name)
Definition: net_com.h:125
#94 TR-UDP info request
Definition: net_com.h:64
int send_cmd_connect_cb_b(ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp, void *data)
Send connect command.
Definition: net_com.c:1115
int cmd_disconnected_cb(ksnCommandClass *kco, ksnCorePacketData *rd)
Process CMD_DISCONNECTED command.
Definition: net_com.c:1303
#67 Tunnel command
Definition: net_com.h:37
#69 Stream command
Definition: net_com.h:39
#128 Reserver for future use
Definition: net_com.h:78
int send_cmd_connect_cb(ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp, void *data)
Send connect command.
Definition: net_com.c:1094
#93 L0 server info answer
Definition: net_com.h:63
int ksnCommandSendCmdEcho(ksnCommandClass *kco, char *to, void *data, size_t data_len)
Send ECHO command to peer.
Definition: net_com.c:283
#66 Answer to auto replay message command
Definition: net_com.h:36
#97 AM application command
Definition: net_com.h:68
#2 Reserver for future use
Definition: net_com.h:25
#91 Host info amswer
Definition: net_com.h:61
void * kc
Pointer to KSNet core class object.
Definition: net_com.h:97
#79 Request clients list
Definition: net_com.h:49
#74 Resend command
Definition: net_com.h:44
int port
Remote peer port.
Definition: net_com.h:110
#7 VPN command
Definition: net_com.h:30
#100 Subscribe command extension. (Send answer for one random peer by type)
Definition: net_com.h:71
char * addr
Remote peer IP address.
Definition: net_com.h:109