Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tcp_proxy.h
Go to the documentation of this file.
1 
10 #ifndef TCP_PROXY_H
11 #define TCP_PROXY_H
12 
13 #include <stdint.h>
14 #include <stdio.h>
15 #include <pbl.h>
16 #include <ev.h>
17 
18 #include "config/conf.h"
19 
23 typedef enum {
24 
28 
30 
34 typedef enum {
35 
37 // CMD_TCPP_GET_IPS, ///< Get host IPs list
38 // CMD_TCPP_GET_PORT ///< Get host UDP proxy port
39 
41 
45 typedef struct ksnTCPProxyHeader {
46 
47  uint8_t checksum;
48  unsigned int version : 4;
49  unsigned int command : 4;
50  uint16_t port;
51  uint16_t packet_length;
52  uint8_t addr_length;
53  uint8_t packet_checksum;
54 
56 
60 typedef struct ksnTCPProxyPacketData {
61 
64  size_t length;
65  size_t ptr;
66  int stage;
67 
69 
73 typedef struct ksnTCPProxyData {
74 
78  ev_io w;
79  ev_io w_udp;
81 
83 
87 typedef struct ksnTCPProxyClass {
88 
89  void *ke;
90 
91  // Client
92  int fd_client;
93  ev_io w_client;
95 
96  // Server
97  int fd;
98  PblMap* map;
99 
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
108 
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* TCP_PROXY_H */
int stage
Packet buffer receiving stage.
Definition: tcp_proxy.h:66
uint16_t packet_length
UDP packet length.
Definition: tcp_proxy.h:51
ev_io w
TCP Client watcher.
Definition: tcp_proxy.h:78
int fd
TCP Server fd or 0 if not started.
Definition: tcp_proxy.h:97
ksnTCPProxyPacketData packet
Packet buffer.
Definition: tcp_proxy.h:80
Resend packet to UDP Proxy client/server.
Definition: tcp_proxy.h:36
ksnTCPProxyClass map data
Definition: tcp_proxy.h:73
ksnTCPProxyClass * ksnTCPProxyInit(void *ke)
Initialize TCP Proxy module.
Definition: tcp_proxy.c:76
uint8_t checksum
Whole checksum.
Definition: tcp_proxy.h:47
ksnTCPProxyHeader * header
Packet header.
Definition: tcp_proxy.h:63
size_t length
Received package length.
Definition: tcp_proxy.h:64
struct ksnTCPProxyClass ksnTCPProxyClass
TCP Proxy class data.
int ksnTCPProxyClientConnect(ksnTCPProxyClass *tp)
Connect to TCP Proxy server.
Definition: tcp_proxy.c:473
struct ksnTCPProxyPacketData ksnTCPProxyPacketData
TCP Proxy packet data structure.
size_t ptr
Pointer to data end in packet buffer.
Definition: tcp_proxy.h:65
unsigned int version
Protocol version number.
Definition: tcp_proxy.h:48
uint8_t packet_checksum
Header checksum.
Definition: tcp_proxy.h:53
struct ksnTCPProxyData ksnTCPProxyData
ksnTCPProxyClass map data
int fd_client
TCP Client fd or 0 if not started (or not connected)
Definition: tcp_proxy.h:92
unsigned int command
Protocol command.
Definition: tcp_proxy.h:49
int udp_proxy_port
UDP Proxy port number.
Definition: tcp_proxy.h:76
Wait for end of the packet.
Definition: tcp_proxy.h:26
ksnTCPProxyCommand
TCP Proxy protocol command.
Definition: tcp_proxy.h:34
uint8_t addr_length
UDP peers address string length included trailing zero.
Definition: tcp_proxy.h:52
#define ke
TCP Proxy packet data structure.
Definition: tcp_proxy.h:60
uint16_t port
UDP peers port number.
Definition: tcp_proxy.h:50
char buffer[KSN_BUFFER_DB_SIZE]
Packet buffer.
Definition: tcp_proxy.h:62
PblMap * map
Hash Map to store tcp proxy client connections.
Definition: tcp_proxy.h:98
TCP Proxy packet(message) header structure.
Definition: tcp_proxy.h:45
ksnTCPProxyBufferStage
TCP Proxy buffer stage.
Definition: tcp_proxy.h:23
#define KSN_BUFFER_DB_SIZE
File: conf.h Author: Kirill Scherba.
Definition: conf.h:14
ksnTCPProxyPacketData packet
TCP Client Packet buffer.
Definition: tcp_proxy.h:94
void * ke
Pointer to ksnetEvMgrClass.
Definition: tcp_proxy.h:89
void ksnTCPProxyDestroy(ksnTCPProxyClass *tp)
Destroy TCP Proxy module.
Definition: tcp_proxy.c:99
ev_io w_client
TCP Client watcher.
Definition: tcp_proxy.h:93
int tcp_proxy_fd
TCP Proxy file descriptor.
Definition: tcp_proxy.h:75
struct ksnTCPProxyHeader ksnTCPProxyHeader
TCP Proxy packet(message) header structure.
TCP Proxy class data.
Definition: tcp_proxy.h:87
ev_io w_udp
UDP Client watcher.
Definition: tcp_proxy.h:79
Process the packet in buffer.
Definition: tcp_proxy.h:27
Wait for begibbibg of the packet.
Definition: tcp_proxy.h:25
int udp_proxy_fd
UDP Proxy file descriptor.
Definition: tcp_proxy.h:77