summaryrefslogtreecommitdiffstats
path: root/PICA_node.h
diff options
context:
space:
mode:
Diffstat (limited to 'PICA_node.h')
-rw-r--r--PICA_node.h43
1 files changed, 32 insertions, 11 deletions
diff --git a/PICA_node.h b/PICA_node.h
index 78cb997..f48ddb3 100644
--- a/PICA_node.h
+++ b/PICA_node.h
@@ -27,6 +27,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/select.h>
@@ -51,6 +52,7 @@
#include <time.h>
#include "PICA_nodeaddrlist.h"
#include "PICA_id.h"
+#include "PICA_proto.h"
#include <event2/event.h>
@@ -96,12 +98,21 @@
#define PICA_NETWORKNAME "TESTNET" // TEMP //CONF
-#define NEWCONN_BUFSIZE 58 //FIXME this is the size of CONNID packet, this packet is followed by TLS session negotiation data.
-//TLS data must not be interpreted as some PICA packet by PICA_processdatastream(),
-//so buffer size is limited by the size of CONNID.
+#define NEWCONN_BUFSIZE 58 //FIXME this is the size of the CONNID packet, which is followed by TLS session negotiation data.
+//TLS data must not be interpreted as a PICA packet by PICA_processdatastream(),
+//so the buffer size is limited by the size of CONNID.
#define DEFAULT_BUF_SIZE 4096
+//Relay buffers of a c2c link. procmsg_N2NMSG() drops the whole link when an
+//incoming N2NMSG does not fit into the free space left in these, and the
+//announced payload length of an N2NMSG is a 16 bit field less the two peer ids
+//(65535 - 2 * PICA_ID_SIZE), so anything below 64K makes that a routine event
+//instead of an exceptional one - a link carrying a call has a backlog in both
+//directions most of the time. Deliberately not DEFAULT_BUF_SIZE: that one is
+//also the r_buf/w_buf granularity paid for by every connected client.
+#define C2C_BUF_SIZE 65536
+
struct nodelink;
struct client
@@ -121,20 +132,30 @@ struct client
unsigned int r_pos;
unsigned int w_pos;
- unsigned int btw_ssl;//кол-во отправляемых байтов, передаваемое функции SSL_write
-//Если требуется повторный вызов SSL_write,то нужно передавать те же значения аргументов,а w_pos может быть увеличен
+ unsigned int btw_ssl;//number of bytes to send, passed to SSL_write
+//If SSL_write has to be retried, the same argument values must be passed, while w_pos may be increased
//
int state;
- struct client* next;//структура client может быть одновременно в составе дерева и линейного списка
+ struct client* next;//a client structure can be in a tree and a linked list at the same time
struct client* prev;
time_t tmst;
- int disconnect_ticking;//on sending message TO client this var is set to 1, on receiving some message FROM client this var is reset to 0
+ int disconnect_ticking;//on sending a message TO the client this var is set to 1, on receiving any message FROM the client it is reset to 0
struct event *ev_read;
struct event *ev_write;
+
+ //Pending "get my UDP address" request. The token is what ties a datagram
+ //arriving at the UDP socket to this connection, see process_udp_read()
+ unsigned char udpaddr_token[PICA_PROTO_MYUDPADDR_TOKENSIZE];
+ int udpaddr_token_issued;
+ time_t udpaddr_token_tmst;
+ struct client *udpaddr_token_next;//next client in the same bucket of udpaddr_tokens[]
+ //how many more MYUDPADDRREQ messages are served right now, see client_udpaddr_req_allowed()
+ unsigned int udpaddr_req_allowance;
+ time_t udpaddr_req_tmst;
};
-struct cclink //структура, описывающая соединение двух клиентов между собой через сервер
+struct cclink //describes a connection between two clients through the server
{
//unsigned int cclink_id;
unsigned int state;
@@ -177,7 +198,7 @@ enum newconn_type
NEWCONN_N2N
};
-struct newconn //структура, описывающая новое подключение (клиента)
+struct newconn //describes a new (client) connection
{
SOCKET sck;
SSL *anonssl;
@@ -201,8 +222,8 @@ struct nodelink
SOCKET sck;
SSL *anonssl;
- unsigned int addr_type;//тип адреса узла - PICA_PROTO_NEWNODE_IPV4,PICA_PROTE_NEWNODE_IPV6,...
- void *node_addr;//указатель на структуру адреса {PICA_nodeaddr_ipv4, PICA_nodeaddr_ipv6,PICA_nodeaddr_dns,..}
+ unsigned int addr_type;//node address type - PICA_PROTO_NEWNODE_IPV4,PICA_PROTO_NEWNODE_IPV6,...
+ void *node_addr;//pointer to the address structure {PICA_nodeaddr_ipv4, PICA_nodeaddr_ipv6,PICA_nodeaddr_dns,..}
unsigned char *r_buf;
unsigned char *w_buf;