Skip to content

Commit

Permalink
cleaned up includes a bit using iwyu
Browse files Browse the repository at this point in the history
  • Loading branch information
g3gg0 committed Jul 31, 2024
1 parent 402afd5 commit 621a445
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 125 deletions.
2 changes: 2 additions & 0 deletions fat/source/diskio.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
extern "C" {
#endif

#include "ff.h"

/* Status of Disk Functions */
typedef BYTE DSTATUS;

Expand Down
2 changes: 2 additions & 0 deletions include/esp32.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#pragma once

#include <stdbool.h>

#include "fs_port.h"
#include "error.h"

Expand Down
5 changes: 3 additions & 2 deletions include/tls_adapter.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef __TLS_ADAPTER_H__
#define __TLS_ADAPTER_H__

#include <stdint.h> // for uint8_t
#include "error.h"
#include "tls.h"
#include "rng/yarrow.h"
#include "rng/yarrow.h" // for YarrowContext
#include "tls.h" // for TlsCache, TlsContext, _TlsContext (ptr only)

error_t tls_adapter_deinit();
error_t tls_adapter_init();
Expand Down
55 changes: 25 additions & 30 deletions src/cloud_request.c
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@

#ifdef WIN32
#else
#include <sys/random.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h>
#endif

#include <errno.h>
#include <stdlib.h>

#include "tls.h"
#include "pem_export.h"
#include "tls_cipher_suites.h"
#include "cloud_request.h"
#include "http/http_client.h"
#include "rand.h"
#include "debug.h"
#include "settings.h"

#include "tls_adapter.h"
#include "handler_api.h"
#include "settings.h"
#include "mqtt.h"
#include "platform.h"

#include "handler_cloud.h"

#include <errno.h> // for error_t
#include <stdint.h> // for uint8_t
#include <stdio.h> // for snprintf
#include <stdlib.h> // for NULL, size_t
#include <string.h> // for strlen, strcpy, strncpy, strchr, strncmp

#include "cloud_request.h" // for req_cbr_t, cloud_request, cloud_reques...
#include "compiler_port.h" // for char_t, int_t, uint_t
#include "core/net.h" // for IpAddr, (anonymous struct)::(anonymous)
#include "debug.h" // for TRACE_INFO, TRACE_ERROR, TRACE_DEBUG
#include "error.h" // for error2text, NO_ERROR, ERROR_ADDRESS_NO...
#include "handler.h" // for cbr_ctx_t
#include "handler_api.h" // for stats_update
#include "http/http_client.h" // for httpClientAddHeaderField, httpClientDi...
#include "http/http_common.h" // for HTTP_VERSION_1_1
#include "mqtt.h" // for mqtt_sendEvent
#include "net_config.h" // for client_ctx_t, TONIE_AUTH_TOKEN_LENGTH
#include "os_port.h" // for osAllocMem, osFreeMem, FALSE, TRUE
#include "platform.h" // for resolve_free, resolve_get_ip, resolve_...
#include "rand.h" // for rand_get_algo, rand_get_context
#include "settings.h" // for settings_t, get_settings, settings_cert_t
#include "stdbool.h" // for bool, true, false
#include "tls.h" // for TlsContext, _TlsContext (ptr only)
#include "tls_adapter.h" // for tls_context_key_log_init

#define MAX_REDIRECTS 5

Expand Down
35 changes: 23 additions & 12 deletions src/esp32.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@

#define TRACE_LEVEL TRACE_LEVEL_INFO

#include <stdint.h>

#include "hash/sha256.h"
#include "fs_ext.h"
#include "path.h"
#include "debug.h"

#include "esp32.h"

#include "ff.h"
#include "diskio.h"
#include "server_helpers.h"
#include "cert.h"
#include "pem_import.h"
#include <errno.h> // for error_t
#include <inttypes.h> // for PRIX32, PRIu32, PRIX8, PRIX16, PRIX64
#include <stdint.h> // for uint8_t, uint32_t, uint16_t, int16_t, int...
#include <stdbool.h> // for bool, true, false
#include <string.h> // for size_t, strcmp, memcmp, memset, NULL
#include <time.h> // for time_t

#include "cert.h" // for cert_generate_mac
#include "date_time.h" // for DateTime, convertUnixTimeToDate, getCurre...
#include "debug.h" // for TRACE_INFO, TRACE_ERROR, TRACE_LEVEL_INFO
#include "diskio.h" // for RES_OK, DRESULT, DSTATUS, RES_ERROR, disk...
#include "error.h" // for NO_ERROR, ERROR_FAILURE, ERROR_NOT_FOUND
#include "ff.h" // for FILINFO, FR_OK, BYTE, f_mount, f_close
#include "fs_ext.h" // for fsOpenFileEx
#include "fs_port.h" // for FS_SEEK_SET, FsDirEntry, FS_FILE_MODE_WRITE
#include "hash/sha256.h" // for sha256Update, sha256Final, sha256Init
#include "os_port.h" // for osFreeMem, osAllocMem, osStrcpy, osStrlen
#include "path.h" // for pathAddSlash, pathCanonicalize, pathCombine
#include "pem_import.h" // for pemImportCertificate
#include "settings.h" // for settings_get_string
#include "server_helpers.h" // for custom_asprintf

#define ESP_PARTITION_TYPE_APP 0
#define ESP_PARTITION_TYPE_DATA 1
Expand Down Expand Up @@ -501,6 +510,7 @@ static error_t process_nvs_item(FsFile *file, size_t offset, size_t part_offset,
{
case 0x00:
case 0x10:
{
char type_string[32] = {0};
osSprintf(type_string, "%sint%i_t", (item->datatype & 0xF0) ? "" : "u", (item->datatype & 0x0F) * 8);
TRACE_INFO(" Type %s (0x%08" PRIX32 ")\r\n", type_string, item->datatype);
Expand Down Expand Up @@ -534,6 +544,7 @@ static error_t process_nvs_item(FsFile *file, size_t offset, size_t part_offset,
}
break;
}
}

switch (item->datatype)
{
Expand Down
8 changes: 8 additions & 0 deletions src/fs_ext.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

#include "fs_ext.h"

#include <stdint.h> // for uint8_t
#include <stdio.h> // for fopen, FILE
#include <stdlib.h> // for NULL, free
#include <string.h> // for strdup, strlen, strrchr
#include "error.h" // for NO_ERROR, ERROR_END_OF_FILE, ERROR_FILE_...
#include "fs_port_config.h" // for PATH_SEPARATOR
#include "os_port.h" // for osStrlen

#define FILE_COPY_BUFFER_SIZE 4096 // You can adjust this buffer size as needed

void fsFixPath(char_t *path)
Expand Down
5 changes: 0 additions & 5 deletions src/handler_reverse.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@

#ifdef WIN32
#else
#include <unistd.h>
#endif

#include <sys/types.h>
#include <time.h>
#include <stdbool.h>
Expand Down
4 changes: 0 additions & 4 deletions src/handler_rtnl.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifdef WIN32
#else
#include <unistd.h>
#endif

#include <sys/types.h>
#include <time.h>
Expand Down
4 changes: 2 additions & 2 deletions src/rand.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <errno.h>
#ifdef WIN32
#else

#ifndef WIN32
#include <sys/random.h>
#include <fcntl.h>
#include <unistd.h>
Expand Down
77 changes: 37 additions & 40 deletions src/server.c
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@

#ifdef WIN32
#else
#include <sys/random.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <arpa/inet.h>
#endif

#include "core/net.h"
#include "core/ethernet.h"
#include "core/ip.h"
#include "core/tcp.h"
#include "http/http_server.h"
#include "http/http_server_misc.h"
#include "rand.h"
#include "tls_adapter.h"
#include "settings.h"
#include "returncodes.h"

#include "server_helpers.h"
#include "toniesJson.h"

#include "path.h"
#include "debug.h"
#include "os_port.h"

#include "mutex_manager.h"
#include "cloud_request.h"
#include "toniebox_state.h"
#include "handler_cloud.h"
#include "handler_reverse.h"
#include "handler_rtnl.h"
#include "handler_api.h"
#include "handler_sse.h"
#include "handler_security_mit.h"
#include "proto/toniebox.pb.rtnl.pb-c.h"
#include "pcaplog.h"

#include <errno.h> // for error_t
#include <stdint.h> // for uint8_t
#include <stdio.h> // for printf
#include <stdlib.h> // for atoi, exit, free
#include <string.h> // for NULL, strdup, strlen, strncmp, strcmp
#include <sys/types.h> // for time_t
#include <time.h> // for time

#include "compiler_port.h" // for char_t, PRIuTIME
#include "core/net.h" // for ipStringToAddr, IpAddr
#include "core/socket.h" // for _Socket
#include "debug.h" // for TRACE_DEBUG, TRACE_ERROR, TRACE_INFO
#include "error.h" // for NO_ERROR, error2text, ERROR_FAILURE
#include "fs_port_posix.h" // for fsDirExists
#include "handler_api.h" // for handleApiAssignUnknown, handleApiA...
#include "handler_cloud.h" // for handleCloudClaim, handleCloudConte...
#include "handler_reverse.h" // for handleReverse
#include "handler_rtnl.h" // for handleRtnl
#include "handler_security_mit.h" // for handleSecMitRobotsTxt, checkSecMit...
#include "handler_sse.h" // for handleApiSse, sse_init
#include "http/http_common.h" // for HTTP_AUTH_MODE_DIGEST
#include "http/http_server.h" // for _HttpConnection, HttpServerSettings
#include "mutex_manager.h" // for mutex_unlock, mutex_lock, MUTEX_CL...
#include "net_config.h" // for client_ctx_t, http_connection_priv...
#include "os_port.h" // for osFreeMem, osStrlen, osStrstr, osG...
#include "pcaplog.h" // for pcaplog_close, pcaplog_open
#include "rand.h" // for rand_get_algo, rand_get_context
#include "returncodes.h" // for RETURNCODE_INVALID_CONFIG
#include "server_helpers.h" // for httpServerUriNotFoundCallback, cus...
#include "settings.h" // for settings_t, settings_get_string
#include "stdbool.h" // for true, bool, false
#include "tls.h" // for _TlsContext, tlsLoadCertificate
#include "tls_adapter.h" // for tls_context_key_log_init, tlsCache
#include "toniebox_state.h" // for get_toniebox_state, get_toniebox_s...
#include "toniebox_state_type.h" // for toniebox_state_box_t, toniebox_sta...
#include "toniesJson.h" // for tonieboxes_update, tonies_deinit

#define APP_HTTP_MAX_CONNECTIONS 32
HttpConnection httpConnections[APP_HTTP_MAX_CONNECTIONS];
Expand Down
56 changes: 26 additions & 30 deletions src/tls_adapter.c
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
#include <errno.h>
#ifdef WIN32
#else
#include <sys/random.h>
#include <fcntl.h>
#include <unistd.h>
#endif

#include "pem_export.h"
#include "rand.h"
#include "tls_adapter.h"
#include "error.h"
#include "debug.h"
#include "settings.h"
#include "fs_port.h"
#include "fs_ext.h"

// tsl_certificate.c function Dependencies
#include <string.h>
#include <ctype.h>
#include "tls.h"
#include "tls_certificate.h"
#include "tls_misc.h"
#include "encoding/asn1.h"
#include "encoding/oid.h"
#include "pkix/pem_import.h"
#include "pkix/x509_cert_parse.h"
#include "pkix/x509_cert_validate.h"
#include "pkix/x509_key_parse.h"
#include "debug.h"
#include "cert.h"
#include "tls_adapter.h" // for load_cert, tls_adapter_deinit

#include <errno.h> // for error_t
#include <stdint.h> // for uint8_t, uint32_t
#include <stdio.h> // for sprintf
#include <stdlib.h> // for free
#include <string.h> // for NULL, size_t, memcpy, strlen

#include "compiler_port.h" // for char_t, uint_t
#include "cpu_endian.h" // for LOAD24BE
#include "debug.h" // for TRACE_ERROR, TRACE_INFO, TRACE_...
#include "encoding/asn1.h" // for asn1DumpObject
#include "error.h" // for NO_ERROR, ERROR_BAD_CERTIFICATE
#include "fs_ext.h" // for fsOpenFileEx
#include "fs_port.h" // for FS_FILE_MODE_READ
#include "fs_port_posix.h" // for fsReadFile, fsCloseFile, fsOpen...
#include "os_port.h" // for osFreeMem, osAllocMem, osMemset
#include "pem_common.h" // for pemEncodeFile
#include "pkix/x509_cert_parse.h" // for x509ParseCertificate
#include "pkix/x509_cert_validate.h" // for x509CheckNameConstraints, x509C...
#include "settings.h" // for settings_get_string_id, setting...
#include "stdbool.h" // for false, bool, true
#include "tls.h" // for _TlsContext, TLS_VERSION_1_3
#include "tls_certificate.h" // for tlsValidateCertificate, tlsChec...
#include "tls_misc.h" // for tlsGetCurveInfo
#include "x509_common.h" // for X509CertInfo, X509TbsCertificate

TlsCache *tlsCache;

Expand Down

0 comments on commit 621a445

Please sign in to comment.