Browse Source

Fix header include order in test and update Makefile

v2_dev
Evgeny 2 months ago
parent
commit
cc533c500d
  1. 293
      build_errors.txt
  2. 1
      tests/test_etcp_connection_init.c

293
build_errors.txt

@ -1,293 +0,0 @@
etcp_connections.c: In function ‘etcp_encrypt_send’:
etcp_connections.c:250:24: error: incompatible types when initializing type ‘sc_context_t *’ {aka ‘struct secure_channel *’} using type ‘struct secure_channel’
250 | sc_context_t* sc = dgram->link->etcp->crypto_ctx;
| ^~~~~
etcp_connections.c:252:59: warning: ‘return’ with no value, in function returning non-void
252 | if (len<=0 || len>1480) { dgram->link->send_errors++; return; }
| ^~~~~~
etcp_connections.c:248:5: note: declared here
248 | int etcp_encrypt_send(struct ETCP_DGRAM* dgram) {
| ^~~~~~~~~~~~~~~~~
etcp_connections.c:255:38: warning: passing argument 4 of ‘sc_encrypt’ from incompatible pointer type [-Wincompatible-pointer-types]
255 | sc_encrypt(sc, dgram->data, len, &enc_buf, &enc_buf_len);
| ^~~~~~~~
| |
| uint8_t (*)[1600] {aka unsigned char (*)[1600]}
In file included from etcp_connections.h:4,
from etcp_connections.c:1:
secure_channel.h:61:102: note: expected ‘uint8_t *’ {aka ‘unsigned char *’} but argument is of type ‘uint8_t (*)[1600]’ {aka ‘unsigned char (*)[1600]’}
61 | sc_status_t sc_encrypt(sc_context_t *ctx, const uint8_t *plaintext, size_t plaintext_len, uint8_t *ciphertext, size_t *ciphertext_len);
| ~~~~~~~~~^~~~~~~~~~
etcp_connections.c:256:82: warning: ‘return’ with no value, in function returning non-void
256 | if (enc_buf_len + dgram->noencrypt_len > 1480) { dgram->link->send_errors++; return; }
| ^~~~~~
etcp_connections.c:248:5: note: declared here
248 | int etcp_encrypt_send(struct ETCP_DGRAM* dgram) {
| ^~~~~~~~~~~~~~~~~
etcp_connections.c:259:35: error: incompatible types when initializing type ‘struct sockaddr_storage *’ using type ‘struct sockaddr_storage’
259 | struct sockaddr_storage* addr=dgram->link->remote_addr;
| ^~~~~
etcp_connections.c:260:27: error: ‘to_addr’ undeclared (first use in this function); did you mean ‘in_addr’?
260 | socklen_t addr_len = (to_addr->ss_family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6);
| ^~~~~~~
| in_addr
etcp_connections.c:260:27: note: each undeclared identifier is reported only once for each function it appears in
etcp_connections.c:261:67: warning: passing argument 5 of ‘sendto’ from incompatible pointer type [-Wincompatible-pointer-types]
261 | ssize_t sent = sendto(dgram->link->conn->fd, enc_buf, len, 0, addr, addr_len);
| ^~~~
| |
| struct sockaddr_storage *
In file included from etcp_connections.h:7:
/usr/include/x86_64-linux-gnu/sys/socket.h:153:58: note: expected ‘const struct sockaddr *’ but argument is of type ‘struct sockaddr_storage *’
153 | int __flags, __CONST_SOCKADDR_ARG __addr,
| ^
etcp_connections.c: In function ‘etcp_connections_read_callback’:
etcp_connections.c:311:33: error: ‘pkt’ undeclared (first use in this function)
311 | socklen_t addr_len = sizeof(pkt->metadata.remote_addr);
| ^~~
etcp_connections.c:314:15: error: redefinition of ‘addr_len’
314 | socklen_t addr_len=sizeof(addr);
| ^~~~~~~~
etcp_connections.c:311:15: note: previous definition of ‘addr_len’ with type ‘socklen_t’ {aka ‘unsigned int’}
311 | socklen_t addr_len = sizeof(pkt->metadata.remote_addr);
| ^~~~~~~~
etcp_connections.c:322:48: warning: passing argument 1 of ‘memory_pool_alloc’ from incompatible pointer type [-Wincompatible-pointer-types]
322 | struct ETCP_DGRAM* pkt = memory_pool_alloc(&e_sock->instance->pkt_pool);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| struct memory_pool **
In file included from utun_instance.h:7,
from etcp_connections.h:5:
../lib/memory_pool.h:18:45: note: expected ‘struct memory_pool *’ but argument is of type ‘struct memory_pool **’
18 | void* memory_pool_alloc(struct memory_pool* pool);
| ~~~~~~~~~~~~~~~~~~~~^~~~
etcp_connections.c:327:51: error: expected expression before ‘struct’
327 | struct ETCP_LINK* link=etcp_link_find_by_addr(struct ETCP_SOCKET* e_sock, &addr);
| ^~~~~~
etcp_connections.c:327:28: error: too few arguments to function ‘etcp_link_find_by_addr’
327 | struct ETCP_LINK* link=etcp_link_find_by_addr(struct ETCP_SOCKET* e_sock, &addr);
| ^~~~~~~~~~~~~~~~~~~~~~
etcp_connections.c:105:26: note: declared here
105 | static struct ETCP_LINK* etcp_link_find_by_addr(struct ETCP_SOCKET* e_sock, struct sockaddr_storage* addr) {
| ^~~~~~~~~~~~~~~~~~~~~~
etcp_connections.c:360:41: error: invalid type argument of ‘->’ (have ‘struct secure_channel’)
360 | if (memcmp(&conn->crypto_ctx->peer_public_key, &sc.peer_public_key, SC_PUBKEY_SIZE)) { errorcode=5; goto ec_fr; }// коллизия - peer id совпал а ключи разные.
| ^~
etcp_connections.c:362:48: error: ‘etcp’ undeclared (first use in this function)
362 | struct ETCP_LINK* link = etcp_link_new(etcp, e_sock, addr, 1);
| ^~~~
etcp_connections.c:362:62: error: incompatible type for argument 3 of ‘etcp_link_new’
362 | struct ETCP_LINK* link = etcp_link_new(etcp, e_sock, addr, 1);
| ^~~~
| |
| struct sockaddr_storage
etcp_connections.c:209:108: note: expected ‘struct sockaddr_storage *’ but argument is of type ‘struct sockaddr_storage’
209 | struct ETCP_LINK* etcp_link_new(struct ETCP_CONN* etcp, struct ETCP_SOCKET* conn, struct sockaddr_storage* remote_addr, uint8_t is_server) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
etcp_connections.c:376:49: error: invalid type argument of ‘->’ (have ‘struct global_config’)
376 | int mtu=e_sock->instance->config->global->mtu;
| ^~
etcp_connections.c:383:9: warning: implicit declaration of function ‘packet_pool_free’ [-Wimplicit-function-declaration]
383 | packet_pool_free(&e_sock->instance->pkt_pool, pkt);
| ^~~~~~~~~~~~~~~~
etcp_connections.c:392:5: warning: implicit declaration of function ‘etcp_input’; did you mean ‘etcp_conn_input’? [-Wimplicit-function-declaration]
392 | etcp_input(pkt, conns);
| ^~~~~~~~~~
| etcp_conn_input
etcp_connections.c:392:21: error: ‘conns’ undeclared (first use in this function); did you mean ‘confstr’?
392 | etcp_input(pkt, conns);
| ^~~~~
| confstr
etcp_connections.c: In function ‘etcp_input’:
etcp_connections.c:405:18: error: ‘e_sock’ undeclared (first use in this function)
405 | if (!pkt || !e_sock) return -1;
| ^~~~~~
etcp_connections.c:408:21: error: ‘struct ETCP_DGRAM’ has no member named ‘metadata’
408 | size_t len = pkt->metadata.data_len;
| ^~
etcp_connections.c:417:75: error: ‘struct ETCP_CONN’ has no member named ‘has_peer_key’
417 | if (header != ETCP_INIT_REQUEST && header != ETCP_CHANNEL_INIT && etcp->has_peer_key) {
| ^~
etcp_connections.c:419:28: error: incompatible types when initializing type ‘sc_context_t *’ {aka ‘struct secure_channel *’} using type ‘struct secure_channel’
419 | sc_context_t* sc = etcp->crypto_ctx;
| ^~~~
etcp_connections.c:431:83: error: ‘struct ETCP_DGRAM’ has no member named ‘metadata’
431 | struct ETCP_LINK* link = etcp_link_find_by_addr(e_sock, (struct sockaddr*)&pkt->metadata.remote_addr,
| ^~
etcp_connections.c:432:63: error: ‘struct ETCP_DGRAM’ has no member named ‘metadata’
432 | sizeof(pkt->metadata.remote_addr));
| ^~
etcp_connections.c:431:30: error: too many arguments to function ‘etcp_link_find_by_addr’
431 | struct ETCP_LINK* link = etcp_link_find_by_addr(e_sock, (struct sockaddr*)&pkt->metadata.remote_addr,
| ^~~~~~~~~~~~~~~~~~~~~~
etcp_connections.c:105:26: note: declared here
105 | static struct ETCP_LINK* etcp_link_find_by_addr(struct ETCP_SOCKET* e_sock, struct sockaddr_storage* addr) {
| ^~~~~~~~~~~~~~~~~~~~~~
etcp_connections.c:437:70: error: ‘struct ETCP_DGRAM’ has no member named ‘metadata’
437 | link = etcp_link_new(etcp, e_sock, (struct sockaddr*)&pkt->metadata.remote_addr,
| ^~
etcp_connections.c:438:44: error: ‘struct ETCP_DGRAM’ has no member named ‘metadata’
438 | sizeof(pkt->metadata.remote_addr));
| ^~
etcp_connections.c:443:13: warning: implicit declaration of function ‘etcp_connections_send’; did you mean ‘etcp_connection_create’? [-Wimplicit-function-declaration]
443 | etcp_connections_send(e_sock, reset_pkt, 1, (struct sockaddr*)&pkt->metadata.remote_addr, sizeof(pkt->metadata.remote_addr));
| ^~~~~~~~~~~~~~~~~~~~~
| etcp_connection_create
etcp_connections.c:443:79: error: ‘struct ETCP_DGRAM’ has no member named ‘metadata’
443 | etcp_connections_send(e_sock, reset_pkt, 1, (struct sockaddr*)&pkt->metadata.remote_addr, sizeof(pkt->metadata.remote_addr));
| ^~
etcp_connections.c:443:113: error: ‘struct ETCP_DGRAM’ has no member named ‘metadata’
443 | etcp_connections_send(e_sock, reset_pkt, 1, (struct sockaddr*)&pkt->metadata.remote_addr, sizeof(pkt->metadata.remote_addr));
| ^~
etcp_connections.c:459:20: error: ‘struct ETCP_CONN’ has no member named ‘peer_public_key’
459 | memcpy(etcp->peer_public_key, peer_pubkey, SC_PUBKEY_SIZE);
| ^~
etcp_connections.c:460:13: error: ‘struct ETCP_CONN’ has no member named ‘has_peer_key’
460 | etcp->has_peer_key = 1;
| ^~
etcp_connections.c:461:36: error: incompatible type for argument 1 of ‘sc_set_peer_public_key’
461 | sc_set_peer_public_key(etcp->crypto_ctx, peer_pubkey);
| ~~~~^~~~~~~~~~~~
| |
| struct secure_channel
secure_channel.h:58:50: note: expected ‘sc_context_t *’ {aka ‘struct secure_channel *’} but argument is of type ‘struct secure_channel’
58 | sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const char *peer_public_key, int mode);// mode: 0-bin 1-hex key format
| ~~~~~~~~~~~~~~^~~
etcp_connections.c:461:9: error: too few arguments to function ‘sc_set_peer_public_key’
461 | sc_set_peer_public_key(etcp->crypto_ctx, peer_pubkey);
| ^~~~~~~~~~~~~~~~~~~~~~
secure_channel.h:58:13: note: declared here
58 | sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const char *peer_public_key, int mode);// mode: 0-bin 1-hex key format
| ^~~~~~~~~~~~~~~~~~~~~~
etcp_connections.c:478:12: error: ‘struct ETCP_DGRAM’ has no member named ‘metadata’
478 | pkt->metadata.channel = link; // Or etcp_channel if separate
| ^~
etcp_connections.c:483:5: warning: implicit declaration of function ‘packet_pool_put’ [-Wimplicit-function-declaration]
483 | packet_pool_put(&etcp->packet_pool, pkt);
| ^~~~~~~~~~~~~~~
etcp_connections.c:483:26: error: ‘struct ETCP_CONN’ has no member named ‘packet_pool’
483 | packet_pool_put(&etcp->packet_pool, pkt);
| ^~
etcp_connections.c: In function ‘init_connections’:
etcp_connections.c:490:29: warning: initialization of ‘struct config *’ from incompatible pointer type ‘struct utun_config *’ [-Wincompatible-pointer-types]
490 | struct config* config = instance->config;
| ^~~~~~~~
etcp_connections.c:491:42: error: invalid use of undefined type ‘struct config’
491 | instance->connections = calloc(config->server_count, sizeof(struct ETCP_CONN));
| ^~
etcp_connections.c:494:15: error: ‘struct UTUN_INSTANCE’ has no member named ‘connection_count’; did you mean ‘connections’?
494 | instance->connection_count = 0;
| ^~~~~~~~~~~~~~~~
| connections
etcp_connections.c:496:39: error: invalid use of undefined type ‘struct config’
496 | struct CFG_SERVER* server = config->servers;
| ^~
etcp_connections.c:500:34: warning: implicit declaration of function ‘etcp_connection_add’; did you mean ‘etcp_connection_create’? [-Wimplicit-function-declaration]
500 | struct ETCP_CONN* conn = etcp_connection_add(instance, server->ip, server->netif_index, server->so_mark, server->type);
| ^~~~~~~~~~~~~~~~~~~
| etcp_connection_create
etcp_connections.c:500:34: warning: initialization of ‘struct ETCP_CONN *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
etcp_connections.c:503:26: error: ‘etcp’ undeclared (first use in this function)
503 | etcp_destroy(etcp);
| ^~~~
etcp_connections.c:508:36: error: ‘struct CFG_SERVER’ has no member named ‘addr’
508 | server->name, server->addr, e_sock->num_channels);
| ^~
etcp_connections.c:508:44: error: ‘e_sock’ undeclared (first use in this function)
508 | server->name, server->addr, e_sock->num_channels);
| ^~~~~~
etcp_connections.c:513:31: error: invalid use of undefined type ‘struct config’
513 | for (int j = 0; j < config->client_count; j++) {
| ^~
etcp_connections.c:514:47: error: invalid use of undefined type ‘struct config’
514 | struct client_config* client = &config->clients[j];
| ^~
etcp_connections.c:517:26: error: invalid use of undefined type ‘struct client_config’
517 | if (strcmp(client->from, server->name) != 0) {
| ^~
etcp_connections.c:525:31: error: ‘struct ETCP_CONN’ has no member named ‘ctx’
525 | sc_init_ctx(&etcp_conn->ctx, &instance->my_keys);
| ^~
etcp_connections.c:526:26: error: invalid use of undefined type ‘struct client_config’
526 | if (strlen(client->peer_public_key_hex) > 0) {
| ^~
etcp_connections.c:528:17: warning: implicit declaration of function ‘hex_to_binary’ [-Wimplicit-function-declaration]
528 | if (hex_to_binary(client->peer_public_key_hex, peer_key_bin, SC_PUBKEY_SIZE) == 0) {
| ^~~~~~~~~~~~~
etcp_connections.c:528:37: error: invalid use of undefined type ‘struct client_config’
528 | if (hex_to_binary(client->peer_public_key_hex, peer_key_bin, SC_PUBKEY_SIZE) == 0) {
| ^~
etcp_connections.c:529:33: error: ‘struct ETCP_CONN’ has no member named ‘peer_public_key’
529 | memcpy(etcp_conn->peer_public_key, peer_key_bin, SC_PUBKEY_SIZE);
| ^~
etcp_connections.c:530:26: error: ‘struct ETCP_CONN’ has no member named ‘has_peer_key’
530 | etcp_conn->has_peer_key = 1;
| ^~
etcp_connections.c:531:49: error: incompatible type for argument 1 of ‘sc_set_peer_public_key’
531 | sc_set_peer_public_key(etcp_conn->crypto_ctx, peer_key_bin);
| ~~~~~~~~~^~~~~~~~~~~~
| |
| struct secure_channel
secure_channel.h:58:50: note: expected ‘sc_context_t *’ {aka ‘struct secure_channel *’} but argument is of type ‘struct secure_channel’
58 | sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const char *peer_public_key, int mode);// mode: 0-bin 1-hex key format
| ~~~~~~~~~~~~~~^~~
etcp_connections.c:531:17: error: too few arguments to function ‘sc_set_peer_public_key’
531 | sc_set_peer_public_key(etcp_conn->crypto_ctx, peer_key_bin);
| ^~~~~~~~~~~~~~~~~~~~~~
secure_channel.h:58:13: note: declared here
58 | sc_status_t sc_set_peer_public_key(sc_context_t *ctx, const char *peer_public_key, int mode);// mode: 0-bin 1-hex key format
| ^~~~~~~~~~~~~~~~~~~~~~
etcp_connections.c:537:16: error: variable ‘cl’ has initializer but incomplete type
537 | struct client_link cl=client->links;
| ^~~~~~~~~~~
etcp_connections.c:537:37: error: invalid use of undefined type ‘struct client_config’
537 | struct client_link cl=client->links;
| ^~
etcp_connections.c:537:28: error: storage size of ‘cl’ isn’t known
537 | struct client_link cl=client->links;
| ^~
etcp_connections.c:539:13: error: ‘conn’ undeclared (first use in this function)
539 | conn= (надо найти)
| ^~~~
etcp_connections.c:539:20: error: ‘надо’ undeclared (first use in this function)
539 | conn= (надо найти)
| ^~~~
etcp_connections.c:539:24: error: expected ‘)’ before ‘найти’
539 | conn= (надо найти)
| ~ ^~~~~~
| )
etcp_connections.c:539:31: error: expected ‘;’ before ‘struct’
539 | conn= (надо найти)
| ^
| ;
......
542 | struct ETCP_LINK* link = etcp_link_new(etcp, conn, cl->remote_sockaddr, sizeof(struct sockaddr_storage));
| ~~~~~~
In file included from etcp_connections.c:8:
etcp_connections.c:544:95: error: invalid use of undefined type ‘struct client_config’
544 | DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "Failed to create link for client %s", client->name);
| ^~
../lib/debug_config.h:114:92: note: in definition of macro ‘DEBUG_ERROR’
114 | debug_output(DEBUG_LEVEL_ERROR, category, __FUNCTION__, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
etcp_connections.c:550:51: error: invalid use of undefined type ‘struct client_config’
550 | printf(" Added client %s -> %s\n", client->name, client->to_addr);
| ^~
etcp_connections.c:550:65: error: invalid use of undefined type ‘struct client_config’
550 | printf(" Added client %s -> %s\n", client->name, client->to_addr);
| ^~
etcp_connections.c:554:19: error: ‘struct UTUN_INSTANCE’ has no member named ‘connection_count’; did you mean ‘connections’?
554 | if (instance->connection_count == 0) {
| ^~~~~~~~~~~~~~~~
| connections
etcp_connections.c:561:54: error: ‘struct UTUN_INSTANCE’ has no member named ‘connection_count’; did you mean ‘connections’?
561 | printf("Initialized %d connections\n", instance->connection_count);
| ^~~~~~~~~~~~~~~~
| connections
etcp_connections.c: At top level:
etcp_connections.c:26:12: warning: ‘etcp_link_send_init_response’ used but never defined
26 | static int etcp_link_send_init_response(struct ETCP_LINK* link, int mtu, uint16_t keepalive_interval);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:619: utun-etcp_connections.o] Ошибка 1
make[1]: *** [Makefile:433: all-recursive] Ошибка 1
make: *** [Makefile:353: all] Ошибка 2

1
tests/test_etcp_connection_init.c

@ -7,7 +7,6 @@
#include <arpa/inet.h>
#include <time.h>
#include "../lib/crc32.h"
#include "../lib/memory_pool.h"
#include "../lib/u_async.h"
#include "../lib/ll_queue.h"

Loading…
Cancel
Save