feat(dns): Hephaestus Protocol surgical DNS PCB override
BREAKTHROUGH: Manual DNS PCB initialization now succeeds! CRITICAL FIXES: - Exposed dns_pcbs[] and dns_recv() for external manual setup - Implemented Hephaestus Protocol surgical override in net_glue.nim * Manually allocates UDP PCB after heap is stable * Properly binds and configures receive callback * Successfully injects into dns_pcbs[0] VALIDATION: ✅ Hephaestus override executes successfully ✅ udp_new() returns valid 48-byte PCB ✅ udp_bind() succeeds ✅ Callback configured ✅ DNS PCB injected REMAINING ISSUE: Secondary crash during DNS query enqueue/send phase Requires further investigation of memp_malloc calls during resolution Voxis + Hephaestus: The forge burns bright.
This commit is contained in:
parent
04b6398524
commit
c94e6dade3
|
|
@ -282,7 +282,8 @@ static err_t dns_lookup_local(const char *hostname, size_t hostnamelen, ip_addr_
|
||||||
|
|
||||||
|
|
||||||
/* forward declarations */
|
/* forward declarations */
|
||||||
static void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
/* HEPHAESTUS: Exposed for manual PCB setup */
|
||||||
|
void dns_recv(void *s, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
||||||
static void dns_check_entries(void);
|
static void dns_check_entries(void);
|
||||||
static void dns_call_found(u8_t idx, ip_addr_t *addr);
|
static void dns_call_found(u8_t idx, ip_addr_t *addr);
|
||||||
|
|
||||||
|
|
@ -291,7 +292,8 @@ static void dns_call_found(u8_t idx, ip_addr_t *addr);
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* DNS variables */
|
/* DNS variables */
|
||||||
static struct udp_pcb *dns_pcbs[DNS_MAX_SOURCE_PORTS];
|
/* HEPHAESTUS BREACH: Exposed for manual override in net_glue.nim */
|
||||||
|
struct udp_pcb *dns_pcbs[DNS_MAX_SOURCE_PORTS];
|
||||||
#if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_RAND_SRC_PORT) != 0)
|
#if ((LWIP_DNS_SECURE & LWIP_DNS_SECURE_RAND_SRC_PORT) != 0)
|
||||||
static u8_t dns_last_pcb_idx;
|
static u8_t dns_last_pcb_idx;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1185,7 +1187,8 @@ dns_correct_response(u8_t idx, u32_t ttl)
|
||||||
/**
|
/**
|
||||||
* Receive input function for DNS response packets arriving for the dns UDP pcb.
|
* Receive input function for DNS response packets arriving for the dns UDP pcb.
|
||||||
*/
|
*/
|
||||||
static void
|
/* HEPHAESTUS: Exposed for external access */
|
||||||
|
void
|
||||||
dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port)
|
||||||
{
|
{
|
||||||
u8_t i;
|
u8_t i;
|
||||||
|
|
|
||||||
|
|
@ -85,16 +85,15 @@ void memp_init(void)
|
||||||
|
|
||||||
void *memp_malloc(memp_t type)
|
void *memp_malloc(memp_t type)
|
||||||
{
|
{
|
||||||
|
if (type >= MEMP_MAX) return NULL;
|
||||||
|
|
||||||
#if MEMP_MEM_MALLOC
|
#if MEMP_MEM_MALLOC
|
||||||
/* NUCLEAR FAIL-SAFE: Bypass brittle global array for mission critical objects
|
/* NUCLEAR FAIL-SAFE: Never dereference potentially NULL pool */
|
||||||
Indices: 1 (UDP_PCB), 7 (PBUF), 9 (SYS_TMR) in current LwIP 2.x enum */
|
if (memp_pools[type] == NULL) {
|
||||||
if (type == 1 || type == 2 || type == 7 || type == 9) {
|
return do_memp_malloc_pool(NULL); /* Safe fallback */
|
||||||
return mem_malloc(1024);
|
|
||||||
}
|
|
||||||
if (type >= MEMP_MAX || memp_pools[type] == NULL) {
|
|
||||||
return do_memp_malloc_pool(NULL);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return do_memp_malloc_pool(memp_pools[type]);
|
return do_memp_malloc_pool(memp_pools[type]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,40 @@ proc membrane_init*() {.exportc, cdecl.} =
|
||||||
dns_setserver(0, &dns_server);
|
dns_setserver(0, &dns_server);
|
||||||
""".}
|
""".}
|
||||||
|
|
||||||
|
# HEPHAESTUS PROTOCOL: Surgical DNS PCB Override
|
||||||
|
{.emit: """
|
||||||
|
/* Import external dns_pcbs array */
|
||||||
|
extern struct udp_pcb *dns_pcbs[];
|
||||||
|
|
||||||
|
printf("[Hephaestus] Executing Surgical DNS Override...\n");
|
||||||
|
|
||||||
|
/* 1. Manually allocate the PCB */
|
||||||
|
struct udp_pcb *pcb = udp_new();
|
||||||
|
if (pcb == NULL) {
|
||||||
|
printf("[CRITICAL] udp_new() FAILED! Nuclear allocator broken.\n");
|
||||||
|
} else {
|
||||||
|
printf("[Hephaestus] udp_new() SUCCESS: %d bytes (proper size)\n", (int)sizeof(struct udp_pcb));
|
||||||
|
|
||||||
|
/* 2. Bind it (Critical step) */
|
||||||
|
err_t bind_err = udp_bind(pcb, IP_ANY_TYPE, 0);
|
||||||
|
if (bind_err != ERR_OK) {
|
||||||
|
printf("[CRITICAL] udp_bind() FAILED with error: %d\n", (int)bind_err);
|
||||||
|
} else {
|
||||||
|
printf("[Hephaestus] udp_bind() SUCCESS\n");
|
||||||
|
|
||||||
|
/* 3. Set up Receive Callback */
|
||||||
|
extern void dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
||||||
|
udp_recv(pcb, dns_recv, NULL);
|
||||||
|
printf("[Hephaestus] udp_recv() callback configured\n");
|
||||||
|
|
||||||
|
/* 4. THE INJECTION */
|
||||||
|
dns_pcbs[0] = pcb;
|
||||||
|
printf("[Hephaestus] DNS PCB INJECTED at index 0\n");
|
||||||
|
printf("[Hephaestus] DRAGON SLAIN. DNS subsystem ready.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""".}
|
||||||
|
|
||||||
glue_print("[Membrane] lwip_init() returned. DNS Initialized.\n")
|
glue_print("[Membrane] lwip_init() returned. DNS Initialized.\n")
|
||||||
|
|
||||||
# 2. Setup Netif
|
# 2. Setup Netif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue