Self-registering IP-protocol and UDP-port dispatch; move picomap-specific constants out of generic net/dispatch layers
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include "prepend_buffer.h"
|
||||
#include "udp.h"
|
||||
|
||||
uint16_t dispatch_listen_port_be();
|
||||
|
||||
struct responder {
|
||||
uint32_t message_id;
|
||||
udp::address reply_to;
|
||||
@@ -22,7 +24,7 @@ struct responder {
|
||||
if (!r) return;
|
||||
buf.append(*r);
|
||||
udp::prepend(buf, reply_to.mac, ns.mac, ns.ip, reply_to.ip,
|
||||
PICOMAP_PORT_BE, reply_to.port, *r);
|
||||
dispatch_listen_port_be(), reply_to.port, *r);
|
||||
net_send_raw(buf.span());
|
||||
}
|
||||
};
|
||||
@@ -52,7 +54,7 @@ void typed_handler(const responder& resp, std::span<const uint8_t> payload) {
|
||||
resp.respond(*result);
|
||||
}
|
||||
|
||||
void dispatch_init();
|
||||
void dispatch_init(uint16_t listen_port_be);
|
||||
timer_handle dispatch_schedule_ms(uint32_t ms, void (*fn)());
|
||||
bool dispatch_cancel_timer(timer_handle h);
|
||||
[[noreturn]] void dispatch_run(std::span<const handler_entry> handlers);
|
||||
|
||||
Reference in New Issue
Block a user