diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e8dfeb..1fa239a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,9 @@ add_subdirectory(debug_log) add_subdirectory(msgpack) add_subdirectory(eth) add_subdirectory(ipv4) +add_subdirectory(arp) add_library(limen STATIC - src/arp.cpp src/dispatch.cpp src/flash.cpp src/handlers.cpp @@ -31,6 +31,7 @@ target_link_libraries(limen PUBLIC msgpack eth ipv4 + arp pico_stdlib pico_sha256 ) diff --git a/arp/CMakeLists.txt b/arp/CMakeLists.txt new file mode 100644 index 0000000..82e7c5a --- /dev/null +++ b/arp/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(arp STATIC arp.cpp) + +target_include_directories(arp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +target_compile_options(arp PRIVATE -Wall -Wextra -Wno-unused-parameter) + +target_link_libraries(arp PUBLIC + util + eth + ipv4 +) diff --git a/src/arp.cpp b/arp/arp.cpp similarity index 98% rename from src/arp.cpp rename to arp/arp.cpp index b64733c..5ceb482 100644 --- a/src/arp.cpp +++ b/arp/arp.cpp @@ -41,6 +41,8 @@ void handle(std::span frame, span_writer& tx) { eth::send_raw(buf.span()); } +void init() {} + __attribute__((constructor)) static void register_ethertype() { eth::register_ethertype(eth::ETH_ARP, handle); diff --git a/include/arp.h b/arp/arp.h similarity index 97% rename from include/arp.h rename to arp/arp.h index 0fff18c..b51de3a 100644 --- a/include/arp.h +++ b/arp/arp.h @@ -19,6 +19,7 @@ struct __attribute__((packed)) header { }; static_assert(sizeof(header) == 28); +void init(); void handle(std::span frame, span_writer& tx); } // namespace arp diff --git a/src/dispatch.cpp b/src/dispatch.cpp index 0947e91..4b17976 100644 --- a/src/dispatch.cpp +++ b/src/dispatch.cpp @@ -5,6 +5,7 @@ #include "timer_queue.h" #include "eth.h" #include "ipv4.h" +#include "arp.h" #include "igmp.h" #include "udp.h" #include "debug_log.h" @@ -37,6 +38,7 @@ void dispatch_init(uint16_t port_be) { udp::register_port(port_be, on_udp_message); eth::init(); ipv4::init(); + arp::init(); dispatch_schedule_ms(60000, igmp_reannounce); dlog("dispatch_init complete"); }