Self-registering IP-protocol and UDP-port dispatch; move picomap-specific constants out of generic net/dispatch layers
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <unordered_map>
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/time.h"
|
||||
#include "handlers.h"
|
||||
#include "net.h"
|
||||
#include "icmp.h"
|
||||
#include "igmp.h"
|
||||
@@ -119,7 +120,7 @@ static void discover_peer(discovery_data& d,
|
||||
ts.active_discovery = &d;
|
||||
|
||||
const auto& ns = net_get_state();
|
||||
eth::mac_addr mcast_mac = igmp::mac_for_ip(igmp::PICOMAP_DISCOVERY_GROUP);
|
||||
eth::mac_addr mcast_mac = igmp::mac_for_ip(PICOMAP_DISCOVERY_GROUP);
|
||||
|
||||
prepend_buffer<4096> buf;
|
||||
uint8_t* payload = buf.payload_ptr();
|
||||
@@ -133,7 +134,7 @@ static void discover_peer(discovery_data& d,
|
||||
}
|
||||
buf.append(*encoded);
|
||||
|
||||
udp::prepend(buf, mcast_mac, ns.mac, ns.ip, igmp::PICOMAP_DISCOVERY_GROUP,
|
||||
udp::prepend(buf, mcast_mac, ns.mac, ns.ip, PICOMAP_DISCOVERY_GROUP,
|
||||
PICOMAP_PORT_BE, PICOMAP_PORT_BE, *encoded, 1);
|
||||
|
||||
ts.frame_cb = net_add_frame_callback(discover_reply_cb);
|
||||
@@ -145,7 +146,7 @@ static void discover_peer(discovery_data& d,
|
||||
static bool igmp_report_cb(std::span<const uint8_t> frame) {
|
||||
ipv4::ip4_addr group;
|
||||
if (!igmp::parse_report(frame, group)) return false;
|
||||
if (group != igmp::PICOMAP_DISCOVERY_GROUP) return false;
|
||||
if (group != PICOMAP_DISCOVERY_GROUP) return false;
|
||||
ts.frame_cb = nullptr;
|
||||
test_end({true, {"got IGMP report for " + ipv4::to_string(group)}});
|
||||
return true;
|
||||
@@ -159,7 +160,7 @@ static void igmp_timeout_cb() {
|
||||
static void test_discovery_igmp() {
|
||||
const auto& ns = net_get_state();
|
||||
prepend_buffer<4096> buf;
|
||||
igmp::prepend_query(buf, ns.mac, ns.ip, igmp::PICOMAP_DISCOVERY_GROUP);
|
||||
igmp::prepend_query(buf, ns.mac, ns.ip, PICOMAP_DISCOVERY_GROUP);
|
||||
|
||||
ts.frame_cb = net_add_frame_callback(igmp_report_cb);
|
||||
ts.timer = dispatch_schedule_ms(5000, igmp_timeout_cb);
|
||||
|
||||
Reference in New Issue
Block a user