diff options
Diffstat (limited to 'core/net_crypto.h')
-rw-r--r-- | core/net_crypto.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/core/net_crypto.h b/core/net_crypto.h index 7b9e9b97..46bcf250 100644 --- a/core/net_crypto.h +++ b/core/net_crypto.h | |||
@@ -47,15 +47,16 @@ typedef struct { | |||
47 | 47 | ||
48 | } Crypto_Connection; | 48 | } Crypto_Connection; |
49 | 49 | ||
50 | typedef int (*cryptopacket_handler_callback)(void * object, IP_Port ip_port, uint8_t *source_pubkey, uint8_t *data, uint32_t len); | 50 | typedef int (*cryptopacket_handler_callback)(void *object, IP_Port ip_port, uint8_t *source_pubkey, uint8_t *data, |
51 | uint32_t len); | ||
51 | 52 | ||
52 | typedef struct { | 53 | typedef struct { |
53 | cryptopacket_handler_callback function; | 54 | cryptopacket_handler_callback function; |
54 | void * object; | 55 | void *object; |
55 | }Cryptopacket_Handles; | 56 | } Cryptopacket_Handles; |
56 | 57 | ||
57 | typedef struct { | 58 | typedef struct { |
58 | Lossless_UDP * lossless_udp; | 59 | Lossless_UDP *lossless_udp; |
59 | 60 | ||
60 | Crypto_Connection *crypto_connections; | 61 | Crypto_Connection *crypto_connections; |
61 | 62 | ||
@@ -127,11 +128,12 @@ int write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uin | |||
127 | request_id is the id of the request (32 = friend request, 254 = ping request) | 128 | request_id is the id of the request (32 = friend request, 254 = ping request) |
128 | returns -1 on failure | 129 | returns -1 on failure |
129 | returns the length of the created packet on success */ | 130 | returns the length of the created packet on success */ |
130 | int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t *packet, uint8_t *recv_public_key, uint8_t *data, uint32_t length, uint8_t request_id); | 131 | int create_request(uint8_t *send_public_key, uint8_t *send_secret_key, uint8_t *packet, uint8_t *recv_public_key, |
132 | uint8_t *data, uint32_t length, uint8_t request_id); | ||
131 | 133 | ||
132 | 134 | ||
133 | /* Function to call when request beginning with byte is received */ | 135 | /* Function to call when request beginning with byte is received */ |
134 | void cryptopacket_registerhandler(Net_Crypto *c, uint8_t byte, cryptopacket_handler_callback cb, void * object); | 136 | void cryptopacket_registerhandler(Net_Crypto *c, uint8_t byte, cryptopacket_handler_callback cb, void *object); |
135 | 137 | ||
136 | /* Start a secure connection with other peer who has public_key and ip_port | 138 | /* Start a secure connection with other peer who has public_key and ip_port |
137 | returns -1 if failure | 139 | returns -1 if failure |
@@ -155,7 +157,8 @@ int crypto_inbound(Net_Crypto *c, uint8_t *public_key, uint8_t *secret_nonce, ui | |||
155 | /* accept an incoming connection using the parameters provided by crypto_inbound | 157 | /* accept an incoming connection using the parameters provided by crypto_inbound |
156 | return -1 if not successful | 158 | return -1 if not successful |
157 | returns the crypt_connection_id if successful */ | 159 | returns the crypt_connection_id if successful */ |
158 | int accept_crypto_inbound(Net_Crypto *c, int connection_id, uint8_t *public_key, uint8_t *secret_nonce, uint8_t *session_key); | 160 | int accept_crypto_inbound(Net_Crypto *c, int connection_id, uint8_t *public_key, uint8_t *secret_nonce, |
161 | uint8_t *session_key); | ||
159 | 162 | ||
160 | /* return 0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet | 163 | /* return 0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet |
161 | (we have received a handshake but no empty data packet), 3 if the connection is established. | 164 | (we have received a handshake but no empty data packet), 3 if the connection is established. |
@@ -177,7 +180,7 @@ void load_keys(Net_Crypto *c, uint8_t *keys); | |||
177 | 180 | ||
178 | /* create new instance of Net_Crypto | 181 | /* create new instance of Net_Crypto |
179 | sets all the global connection variables to their default values. */ | 182 | sets all the global connection variables to their default values. */ |
180 | Net_Crypto * new_net_crypto(Networking_Core * net); | 183 | Net_Crypto *new_net_crypto(Networking_Core *net); |
181 | 184 | ||
182 | /* main loop */ | 185 | /* main loop */ |
183 | void do_net_crypto(Net_Crypto *c); | 186 | void do_net_crypto(Net_Crypto *c); |