Drop send_raw parameter threading: arp/icmp/igmp/ipv4 call net_send_raw directly
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "igmp.h"
|
||||
#include <vector>
|
||||
#include "ipv4.h"
|
||||
#include "net.h"
|
||||
#include "parse_buffer.h"
|
||||
#include "prepend_buffer.h"
|
||||
|
||||
@@ -34,31 +35,27 @@ bool is_member_mac(const eth::mac_addr& mac) {
|
||||
}
|
||||
|
||||
static void send_report(const ipv4::ip4_addr& group,
|
||||
eth::mac_addr our_mac, ipv4::ip4_addr our_ip,
|
||||
std::function<void(std::span<const uint8_t>)> send_raw) {
|
||||
eth::mac_addr our_mac, ipv4::ip4_addr our_ip) {
|
||||
prepend_buffer<4096> buf;
|
||||
prepend_report(buf, our_mac, our_ip, group);
|
||||
send_raw(buf.span());
|
||||
net_send_raw(buf.span());
|
||||
}
|
||||
|
||||
void join(const ipv4::ip4_addr& group,
|
||||
eth::mac_addr our_mac, ipv4::ip4_addr our_ip,
|
||||
std::function<void(std::span<const uint8_t>)> send_raw) {
|
||||
eth::mac_addr our_mac, ipv4::ip4_addr our_ip) {
|
||||
for (auto& g : groups)
|
||||
if (g.ip == group) return;
|
||||
groups.push_back({group, mac_for_ip(group)});
|
||||
send_report(group, our_mac, our_ip, send_raw);
|
||||
send_report(group, our_mac, our_ip);
|
||||
}
|
||||
|
||||
void send_all_reports(eth::mac_addr our_mac, ipv4::ip4_addr our_ip,
|
||||
std::function<void(std::span<const uint8_t>)> send_raw) {
|
||||
void send_all_reports(eth::mac_addr our_mac, ipv4::ip4_addr our_ip) {
|
||||
for (auto& g : groups)
|
||||
send_report(g.ip, our_mac, our_ip, send_raw);
|
||||
send_report(g.ip, our_mac, our_ip);
|
||||
}
|
||||
|
||||
void handle(std::span<const uint8_t> frame, span_writer& tx,
|
||||
eth::mac_addr our_mac, ipv4::ip4_addr our_ip,
|
||||
std::function<void(std::span<const uint8_t>)> send_raw) {
|
||||
eth::mac_addr our_mac, ipv4::ip4_addr our_ip) {
|
||||
parse_buffer pb(frame);
|
||||
pb.consume<eth::header>();
|
||||
auto* ip = pb.consume<ipv4::header>();
|
||||
@@ -73,11 +70,11 @@ void handle(std::span<const uint8_t> frame, span_writer& tx,
|
||||
|
||||
if (msg->group == ipv4::ip4_addr{0, 0, 0, 0}) {
|
||||
for (auto& g : groups)
|
||||
send_report(g.ip, our_mac, our_ip, send_raw);
|
||||
send_report(g.ip, our_mac, our_ip);
|
||||
} else {
|
||||
for (auto& g : groups) {
|
||||
if (g.ip == msg->group) {
|
||||
send_report(g.ip, our_mac, our_ip, send_raw);
|
||||
send_report(g.ip, our_mac, our_ip);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user