summaryrefslogtreecommitdiffstats
path: root/PICA_node.h
diff options
context:
space:
mode:
authorAnton <anton@picapica>2018-12-14 22:41:27 +0400
committerAnton <anton@picapica>2018-12-14 22:41:27 +0400
commit0b6656e30c83a328e2b70c0802584e98b1da0a40 (patch)
tree44000a140f54a26310eb95b3ee24741f40df9955 /PICA_node.h
parent240d089596ff9727ba257e539b88584d6fa6a9f9 (diff)
downloadpica-pica-0b6656e30c83a328e2b70c0802584e98b1da0a40.tar.gz
pica-pica-0b6656e30c83a328e2b70c0802584e98b1da0a40.zip
pica-node: implemented anon DH TLS connection stage, reworked newconns
Diffstat (limited to 'PICA_node.h')
-rw-r--r--PICA_node.h58
1 files changed, 43 insertions, 15 deletions
diff --git a/PICA_node.h b/PICA_node.h
index c5fd45e..7d8d19e 100644
--- a/PICA_node.h
+++ b/PICA_node.h
@@ -58,27 +58,38 @@
//#define PICA_DATA_PORT 51915
//#define PICA_NODE_PORT 51916
-#define PICA_CLSTATE_SENDINGRESP 1
+#define PICA_NEWCONN_WAITANONTLSACCEPT 1
+#define PICA_NEWCONN_WAITREQUEST 2
+#define PICA_NEWCONN_SENDINGOK 3
+#define PICA_NEWCONN_SENDINGREJECT 4
+#define PICA_NEWCONN_WAITANONTLSSHUTDOWN 5
+
+#define PICA_CLSTATE_WAITANONTLSSHUTDOWN 1
+//#define PICA_CLSTATE_SENDINGRESP 1
#define PICA_CLSTATE_TLSNEGOTIATION 2
#define PICA_CLSTATE_CONNECTED 3
-//LOCAL - оба клиента подсоединены к одному узлу
-//N2NCLR - к узлу подключен вызывающий клиент
-//N2NCLE - к узлу подключен вызываемый клиент
+//LOCAL - both clients are connected to the same node
+//N2NCLR - caller client is connected to this node
+//N2NCLE - callee client is connected to this node
#define PICA_CCLINK_LOCAL_WAITREP 1
#define PICA_CCLINK_LOCAL_WAITCONNCLE 2
-#define PICA_CCLINK_LOCAL_WAITCONNCLR 3
-#define PICA_CCLINK_LOCAL_ACTIVE 4
+#define PICA_CCLINK_LOCAL_WAITCONNCLEANONTLSSHUTDOWN 3
+#define PICA_CCLINK_LOCAL_WAITCONNCLR 4
+#define PICA_CCLINK_LOCAL_WAITCONNCLRANONTLSSHUTDOWN 5
+#define PICA_CCLINK_LOCAL_ACTIVE 6
-#define PICA_CCLINK_N2NCLR_WAITSEARCH 5
-#define PICA_CCLINK_N2NCLR_WAITREP 6
-#define PICA_CCLINK_N2NCLR_WAITCONNCLR 7
-#define PICA_CCLINK_N2NCLR_ACTIVE 8
+#define PICA_CCLINK_N2NCLR_WAITSEARCH 7
+#define PICA_CCLINK_N2NCLR_WAITREP 8
+#define PICA_CCLINK_N2NCLR_WAITCONNCLR 9
+#define PICA_CCLINK_N2NCLR_WAITCONNCLRANONTLSSHUTDOWN 10
+#define PICA_CCLINK_N2NCLR_ACTIVE 11
-#define PICA_CCLINK_N2NCLE_WAITREP 9
-#define PICA_CCLINK_N2NCLE_WAITCONNCLE 10
-#define PICA_CCLINK_N2NCLE_ACTIVE 11
+#define PICA_CCLINK_N2NCLE_WAITREP 12
+#define PICA_CCLINK_N2NCLE_WAITCONNCLE 13
+#define PICA_CCLINK_N2NCLE_WAITCONNCLEANONTLSSHUTDOWN 14
+#define PICA_CCLINK_N2NCLE_ACTIVE 15
@@ -90,7 +101,6 @@
#define DEFAULT_BUF_SIZE 4096
-
struct nodelink;
struct client
@@ -151,20 +161,36 @@ struct cclink //структура, описывающая соединение
int disconnect_ticking;
};
+enum newconn_type
+{
+ NEWCONN_UNKNOWN,
+ NEWCONN_C2N,
+ NEWCONN_C2C,
+ NEWCONN_N2N
+};
+
struct newconn //структура, описывающая новое подключение (клиента)
{
SOCKET sck;
+ SSL *anonssl;
struct sockaddr_in addr;
time_t tmst;
int pos;
+ int state;
+ enum newconn_type type;
unsigned char buf[NEWCONN_BUFSIZE];
+ union
+ {
+ struct client *cl;
+ struct cclink *cc;
+ } iconn;
};
struct nodelink
{
struct sockaddr_in addr;
SOCKET sck;
- SSL *ssl;
+ 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,..}
@@ -175,6 +201,7 @@ struct nodelink
unsigned int buflen_w;
unsigned int r_pos;
unsigned int w_pos;
+ unsigned int btw_ssl;
struct nodelink *next;
struct nodelink *prev;
@@ -183,5 +210,6 @@ struct nodelink
int disconnect_ticking;
};
+extern SSL_CTX *anon_ctx;
#endif