From f7b8aed2f72cb43a027aca691588efbdbe4963e2 Mon Sep 17 00:00:00 2001 From: feelfree69 Date: Sun, 1 Mar 2026 21:07:31 +0100 Subject: [PATCH] first working(?) version --- dhcp.c | 4 +++- dhcp.h | 2 +- syslog.c | 6 ++++-- syslog.h | 2 +- udp_apps.c | 14 +++----------- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/dhcp.c b/dhcp.c index 9febcca..80ad865 100644 --- a/dhcp.c +++ b/dhcp.c @@ -353,8 +353,10 @@ void dhcp_stop(void) __banked } -void dhcp_callback(void) __banked +void dhcp_callback(uint16_t lport) __banked { + if (lport != HTONS(DHCPC_CLIENT_PORT)) // Is this call for us? If not, ignore it + return; if (!dhcp_state.state) return; if (uip_closed()) { diff --git a/dhcp.h b/dhcp.h index fda167b..b9cb7c4 100644 --- a/dhcp.h +++ b/dhcp.h @@ -16,7 +16,7 @@ void dhcp_start(void) __banked; void dhcp_stop(void) __banked; // void dhcp_periodic(void) __banked; -void dhcp_callback(void) __banked; +void dhcp_callback(uint16_t lport) __banked; struct dhcp_state { diff --git a/syslog.c b/syslog.c index c3fbd17..a661840 100644 --- a/syslog.c +++ b/syslog.c @@ -38,7 +38,6 @@ void syslog_start(void) __banked print_string("Started syslog to IP "); itoa(syslog_addr[0]); write_char('.'); itoa(syslog_addr[0]>>8); write_char('.'); itoa(syslog_addr[1]); write_char('.'); itoa(syslog_addr[1]>>8); write_char('\n'); - syslog_enabled = 1; } else { @@ -58,8 +57,11 @@ void syslog_stop(void) __banked } } -void syslog_callback(void) __banked +void syslog_callback(uint16_t lport) __banked { + if (lport != syslog_conn->lport) + return; + if ((logptr_r != logptr_w) && full_line_available) { int16_t log_size = logptr_w - logptr_r; diff --git a/syslog.h b/syslog.h index ccb75c9..26e2981 100644 --- a/syslog.h +++ b/syslog.h @@ -8,6 +8,6 @@ void syslog_init(void) __banked; void syslog_start(void) __banked; void syslog_stop(void) __banked; -void syslog_callback(void) __banked; +void syslog_callback(uint16_t lport) __banked; #endif diff --git a/udp_apps.c b/udp_apps.c index 390a66f..f2c9c55 100644 --- a/udp_apps.c +++ b/udp_apps.c @@ -1,17 +1,9 @@ -#include "stdint.h" +#include "uip/uip.h" #include "udp_apps.h" -static uint8_t callbacknr; - void udp_callbacks(void) { - // Calling more than one callback from the same UIP_UDP_APPCALL does not work; we use a simple dispatcher - if (callbacknr == 0) { - dhcp_callback(); - callbacknr = 1; - } else { - syslog_callback(); - callbacknr = 0; - } + dhcp_callback(uip_udp_conn->lport); // let the application decide if this is for it or not + syslog_callback(uip_udp_conn->lport); // let the application decide if this is for it or not } \ No newline at end of file