From e75c350c70c2c3233207e3182c2ba8bb9c04bde8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 May 2026 22:26:49 +0530 Subject: feat(tollgate_core): add extern C guards, fix stratum_proxy function name, conditional NAPT - Add extern "C" guards to tollgate_core.h and tollgate_platform.h for C++ compatibility (needed for NerdQAxePlus integration) - Fix tollgate_core_stratum_proxy_start -> _init to match implementation - Make ip_napt_enable conditional on CONFIG_LWIP_IPV4_NAPT for compatibility with projects that don't enable NAPT --- components/tollgate_core/include/tollgate_core.h | 10 +++++++++- components/tollgate_core/include/tollgate_platform.h | 8 ++++++++ components/tollgate_core/src/tollgate_core_firewall.c | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/components/tollgate_core/include/tollgate_core.h b/components/tollgate_core/include/tollgate_core.h index aa5d4a1..6a17cbd 100644 --- a/components/tollgate_core/include/tollgate_core.h +++ b/components/tollgate_core/include/tollgate_core.h @@ -7,6 +7,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + esp_err_t tollgate_core_init(const tollgate_platform_t *platform, esp_ip4_addr_t ap_ip); esp_err_t tollgate_core_dns_start(esp_ip4_addr_t upstream_dns); @@ -31,10 +35,14 @@ int tollgate_core_allowed_client_count(void); bool tollgate_core_is_owner(uint32_t client_ip); bool tollgate_core_is_owner_connected(void); -esp_err_t tollgate_core_stratum_proxy_start(uint16_t port); +esp_err_t tollgate_core_stratum_proxy_init(uint16_t port); void tollgate_core_stratum_proxy_stop(void); void tollgate_core_on_share_accepted(uint32_t client_ip, double difficulty); double tollgate_core_calc_hashprice(double hashrate_ghs); char *tollgate_core_get_mining_status_json(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/components/tollgate_core/include/tollgate_platform.h b/components/tollgate_core/include/tollgate_platform.h index 6c144fa..79e25cf 100644 --- a/components/tollgate_core/include/tollgate_platform.h +++ b/components/tollgate_core/include/tollgate_platform.h @@ -4,6 +4,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { uint16_t (*get_price_sats)(void); int32_t (*get_step_ms)(void); @@ -26,4 +30,8 @@ typedef struct { double (*get_hashrate)(void); } tollgate_platform_t; +#ifdef __cplusplus +} +#endif + #endif diff --git a/components/tollgate_core/src/tollgate_core_firewall.c b/components/tollgate_core/src/tollgate_core_firewall.c index e5d61d8..ad0697e 100644 --- a/components/tollgate_core/src/tollgate_core_firewall.c +++ b/components/tollgate_core/src/tollgate_core_firewall.c @@ -3,7 +3,9 @@ #include "esp_log.h" #include "esp_wifi.h" #include "esp_wifi_ap_get_sta_list.h" +#ifdef CONFIG_LWIP_IPV4_NAPT #include "lwip/lwip_napt.h" +#endif #include "lwip/etharp.h" #include "lwip/netif.h" #include "lwip/prot/ip4.h" @@ -61,7 +63,9 @@ esp_err_t tollgate_core_fw_init(esp_ip4_addr_t ap_ip) s_ap_ip = ap_ip; memset(s_clients, 0, sizeof(s_clients)); s_client_count = 0; +#ifdef CONFIG_LWIP_IPV4_NAPT ip_napt_enable(s_ap_ip.addr, 1); +#endif ESP_LOGI(TAG, "Firewall initialized with AP IP=" IPSTR " (NAT always on, per-client filter)", IP2STR(&s_ap_ip)); return ESP_OK; } -- cgit v1.2.3