diff options
| author | Your Name <you@example.com> | 2026-05-19 22:26:49 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 22:26:49 +0530 |
| commit | e75c350c70c2c3233207e3182c2ba8bb9c04bde8 (patch) | |
| tree | bb2ee80b21b944c240255a13b9309d3bf9a86048 | |
| parent | 5583f4de647678321fad5f2b3df2b64ece54f0bd (diff) | |
feat(tollgate_core): add extern C guards, fix stratum_proxy function name, conditional NAPTfeature/miner-integration
- 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
| -rw-r--r-- | components/tollgate_core/include/tollgate_core.h | 10 | ||||
| -rw-r--r-- | components/tollgate_core/include/tollgate_platform.h | 8 | ||||
| -rw-r--r-- | components/tollgate_core/src/tollgate_core_firewall.c | 4 |
3 files changed, 21 insertions, 1 deletions
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 @@ | |||
| 7 | #include <stdbool.h> | 7 | #include <stdbool.h> |
| 8 | #include <stdint.h> | 8 | #include <stdint.h> |
| 9 | 9 | ||
| 10 | #ifdef __cplusplus | ||
| 11 | extern "C" { | ||
| 12 | #endif | ||
| 13 | |||
| 10 | esp_err_t tollgate_core_init(const tollgate_platform_t *platform, esp_ip4_addr_t ap_ip); | 14 | esp_err_t tollgate_core_init(const tollgate_platform_t *platform, esp_ip4_addr_t ap_ip); |
| 11 | 15 | ||
| 12 | esp_err_t tollgate_core_dns_start(esp_ip4_addr_t upstream_dns); | 16 | esp_err_t tollgate_core_dns_start(esp_ip4_addr_t upstream_dns); |
| @@ -31,10 +35,14 @@ int tollgate_core_allowed_client_count(void); | |||
| 31 | bool tollgate_core_is_owner(uint32_t client_ip); | 35 | bool tollgate_core_is_owner(uint32_t client_ip); |
| 32 | bool tollgate_core_is_owner_connected(void); | 36 | bool tollgate_core_is_owner_connected(void); |
| 33 | 37 | ||
| 34 | esp_err_t tollgate_core_stratum_proxy_start(uint16_t port); | 38 | esp_err_t tollgate_core_stratum_proxy_init(uint16_t port); |
| 35 | void tollgate_core_stratum_proxy_stop(void); | 39 | void tollgate_core_stratum_proxy_stop(void); |
| 36 | void tollgate_core_on_share_accepted(uint32_t client_ip, double difficulty); | 40 | void tollgate_core_on_share_accepted(uint32_t client_ip, double difficulty); |
| 37 | double tollgate_core_calc_hashprice(double hashrate_ghs); | 41 | double tollgate_core_calc_hashprice(double hashrate_ghs); |
| 38 | char *tollgate_core_get_mining_status_json(void); | 42 | char *tollgate_core_get_mining_status_json(void); |
| 39 | 43 | ||
| 44 | #ifdef __cplusplus | ||
| 45 | } | ||
| 46 | #endif | ||
| 47 | |||
| 40 | #endif | 48 | #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 @@ | |||
| 4 | #include <stdint.h> | 4 | #include <stdint.h> |
| 5 | #include <stdbool.h> | 5 | #include <stdbool.h> |
| 6 | 6 | ||
| 7 | #ifdef __cplusplus | ||
| 8 | extern "C" { | ||
| 9 | #endif | ||
| 10 | |||
| 7 | typedef struct { | 11 | typedef struct { |
| 8 | uint16_t (*get_price_sats)(void); | 12 | uint16_t (*get_price_sats)(void); |
| 9 | int32_t (*get_step_ms)(void); | 13 | int32_t (*get_step_ms)(void); |
| @@ -26,4 +30,8 @@ typedef struct { | |||
| 26 | double (*get_hashrate)(void); | 30 | double (*get_hashrate)(void); |
| 27 | } tollgate_platform_t; | 31 | } tollgate_platform_t; |
| 28 | 32 | ||
| 33 | #ifdef __cplusplus | ||
| 34 | } | ||
| 35 | #endif | ||
| 36 | |||
| 29 | #endif | 37 | #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 @@ | |||
| 3 | #include "esp_log.h" | 3 | #include "esp_log.h" |
| 4 | #include "esp_wifi.h" | 4 | #include "esp_wifi.h" |
| 5 | #include "esp_wifi_ap_get_sta_list.h" | 5 | #include "esp_wifi_ap_get_sta_list.h" |
| 6 | #ifdef CONFIG_LWIP_IPV4_NAPT | ||
| 6 | #include "lwip/lwip_napt.h" | 7 | #include "lwip/lwip_napt.h" |
| 8 | #endif | ||
| 7 | #include "lwip/etharp.h" | 9 | #include "lwip/etharp.h" |
| 8 | #include "lwip/netif.h" | 10 | #include "lwip/netif.h" |
| 9 | #include "lwip/prot/ip4.h" | 11 | #include "lwip/prot/ip4.h" |
| @@ -61,7 +63,9 @@ esp_err_t tollgate_core_fw_init(esp_ip4_addr_t ap_ip) | |||
| 61 | s_ap_ip = ap_ip; | 63 | s_ap_ip = ap_ip; |
| 62 | memset(s_clients, 0, sizeof(s_clients)); | 64 | memset(s_clients, 0, sizeof(s_clients)); |
| 63 | s_client_count = 0; | 65 | s_client_count = 0; |
| 66 | #ifdef CONFIG_LWIP_IPV4_NAPT | ||
| 64 | ip_napt_enable(s_ap_ip.addr, 1); | 67 | ip_napt_enable(s_ap_ip.addr, 1); |
| 68 | #endif | ||
| 65 | ESP_LOGI(TAG, "Firewall initialized with AP IP=" IPSTR " (NAT always on, per-client filter)", IP2STR(&s_ap_ip)); | 69 | ESP_LOGI(TAG, "Firewall initialized with AP IP=" IPSTR " (NAT always on, per-client filter)", IP2STR(&s_ap_ip)); |
| 66 | return ESP_OK; | 70 | return ESP_OK; |
| 67 | } | 71 | } |