Ethertype handler registry: arp/ipv4 self-register via __attribute__((constructor)), drop threaded mac/ip/subnet params
This commit is contained in:
@@ -19,7 +19,6 @@ struct __attribute__((packed)) header {
|
||||
};
|
||||
static_assert(sizeof(header) == 28);
|
||||
|
||||
void handle(std::span<const uint8_t> frame, span_writer& tx,
|
||||
eth::mac_addr our_mac, ipv4::ip4_addr our_ip);
|
||||
void handle(std::span<const uint8_t> frame, span_writer& tx);
|
||||
|
||||
} // namespace arp
|
||||
|
||||
@@ -36,6 +36,8 @@ static_assert(sizeof(header) == 20);
|
||||
|
||||
uint16_t checksum(const void* data, size_t len);
|
||||
|
||||
static constexpr ip4_addr SUBNET_BROADCAST = {169, 254, 255, 255};
|
||||
|
||||
template <typename Buf>
|
||||
void prepend(Buf& buf, const eth::mac_addr& dst_mac, const eth::mac_addr& src_mac,
|
||||
ip4_addr src_ip, ip4_addr dst_ip, uint8_t protocol,
|
||||
@@ -55,7 +57,6 @@ void prepend(Buf& buf, const eth::mac_addr& dst_mac, const eth::mac_addr& src_ma
|
||||
eth::prepend(buf, dst_mac, src_mac, eth::ETH_IPV4);
|
||||
}
|
||||
|
||||
void handle(std::span<const uint8_t> frame, span_writer& tx,
|
||||
eth::mac_addr our_mac, ip4_addr our_ip, ip4_addr subnet_broadcast);
|
||||
void handle(std::span<const uint8_t> frame, span_writer& tx);
|
||||
|
||||
} // namespace ipv4
|
||||
|
||||
@@ -16,6 +16,8 @@ using net_frame_callback = bool (*)(std::span<const uint8_t> frame);
|
||||
using frame_cb_list = callback_list<net_frame_callback, 16>;
|
||||
using frame_cb_handle = frame_cb_list::node*;
|
||||
|
||||
using ethertype_handler = void (*)(std::span<const uint8_t> frame, span_writer& tx);
|
||||
|
||||
inline constexpr uint16_t PICOMAP_PORT_BE = __builtin_bswap16(28781);
|
||||
|
||||
bool net_init();
|
||||
@@ -24,3 +26,4 @@ frame_cb_handle net_add_frame_callback(net_frame_callback cb);
|
||||
void net_remove_frame_callback(frame_cb_handle h);
|
||||
void net_poll(std::span<uint8_t> tx);
|
||||
void net_send_raw(std::span<const uint8_t> data);
|
||||
void net_register_ethertype(uint16_t ethertype_be, ethertype_handler fn);
|
||||
|
||||
Reference in New Issue
Block a user