### Initializing DhcpConfig Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpConfig.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Example showing how to instantiate a DhcpConfig and use it to initialize a DhcpServer. ```rust use core::net::Ipv4Addr; use leasehund::{DhcpConfig, DhcpServer}; let mut dns_servers = heapless::Vec::::new(); dns_servers.push(Ipv4Addr::new(8, 8, 8, 8)).ok(); dns_servers.push(Ipv4Addr::new(8, 8, 4, 4)).ok(); let config: DhcpConfig<4> = DhcpConfig { server_ip: Ipv4Addr::new(192, 168, 1, 1), subnet_mask: Ipv4Addr::new(255, 255, 255, 0), router: Some(Ipv4Addr::new(192, 168, 1, 1)), dns_servers, ip_pool_start: Ipv4Addr::new(192, 168, 1, 100), ip_pool_end: Ipv4Addr::new(192, 168, 1, 200), lease_time: 3600, }; let server: DhcpServer<32, 4> = DhcpServer::with_config(config); ``` -------------------------------- ### Initialize and run a basic DHCP server Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=u32+-%3E+bool Instantiate a DhcpServer with required network parameters and start the server loop. ```rust use core::net::Ipv4Addr; use leasehund::DhcpServer; use embassy_net::Stack; let mut server = DhcpServer::<32, 4>::new( Ipv4Addr::new(192, 168, 1, 1), // Server IP Ipv4Addr::new(255, 255, 255, 0), // Subnet mask Ipv4Addr::new(192, 168, 1, 1), // Router/Gateway Ipv4Addr::new(8, 8, 8, 8), // DNS server Ipv4Addr::new(192, 168, 1, 100), // IP pool start Ipv4Addr::new(192, 168, 1, 200), // IP pool end ); // Run the DHCP server (this will loop forever) server.run(stack).await; ``` -------------------------------- ### DhcpServer::run Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the DHCP server loop. ```APIDOC ## DhcpServer::run ### Description Starts the DHCP server, which listens for requests and manages leases. This method runs indefinitely and requires an Embassy network stack. ### Signature `server.run(stack).await` ``` -------------------------------- ### pub async fn run(&mut self, stack: Stack<'_>) -> ! Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=std%3A%3Avec Starts the DHCP server on the provided network stack. This method runs indefinitely and will panic if the UDP socket fails to bind to port 67. ```APIDOC ## pub async fn run(&mut self, stack: Stack<'_>) -> ! ### Description Runs the DHCP server forever on the provided network stack. ### Parameters - **stack** (Stack<'_>) - Required - The network stack to bind the DHCP server to. ### Panics Panics if the UDP socket cannot bind to port 67. ``` -------------------------------- ### pub async fn run_with_callback(&mut self, stack: Stack<'_>, callback: F) -> ! Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=u32+-%3E+bool Starts the DHCP server and invokes a provided callback function for every transaction event, such as lease assignments or releases. ```APIDOC ## pub async fn run_with_callback(&mut self, stack: Stack<'_>, callback: F) -> ! ### Description Runs the DHCP server forever, invoking `callback` for every lease event. This is identical to `run` except that `TransactionEvent`s are forwarded to the caller via `callback` instead of being discarded. ### Parameters - **stack** (Stack<'_>) - Required - The network stack instance to bind the DHCP server to. - **callback** (F) - Required - A closure that implements `FnMut(TransactionEvent)` to handle lease events. ``` -------------------------------- ### pub async fn run_with_callback(&mut self, stack: Stack<'_>, callback: F) -> ! Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=std%3A%3Avec Starts the DHCP server and invokes a provided callback function for every transaction event, such as lease assignments or releases. ```APIDOC ## pub async fn run_with_callback(&mut self, stack: Stack<'_>, callback: F) -> ! ### Description Runs the DHCP server forever, invoking `callback` for every lease event. This is identical to `run` except that `TransactionEvent`s are forwarded to the caller via `callback` instead of being discarded. ### Parameters - **stack** (Stack<'_>) - Required - The network stack to bind the DHCP server to. - **callback** (F) - Required - A closure that implements `FnMut(TransactionEvent)` to handle lease events. ``` -------------------------------- ### DhcpServer::run Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=std%3A%3Avec Starts the DHCP server loop to process incoming network requests. ```APIDOC ## DhcpServer::run ### Description Runs the DHCP server, listening for and responding to DHCP requests. This method is asynchronous and typically runs in a loop. ### Signature `server.run(stack).await` ### Parameters - **stack** (embassy_net::Stack) - Required - The Embassy network stack instance. ``` -------------------------------- ### DhcpServer::run Source: https://docs.rs/leasehund/latest/leasehund/index.html?search= Starts the DHCP server loop to process incoming network requests. ```APIDOC ## DhcpServer::run ### Description Runs the DHCP server, listening for and responding to DHCP messages. This method loops indefinitely. ### Parameters - **stack** (Stack) - Required - The Embassy network stack instance. ``` -------------------------------- ### pub async fn run(&mut self, stack: Stack<'_>) -> ! Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=u32+-%3E+bool Starts the DHCP server on the provided network stack and runs it indefinitely. This method will panic if the underlying UDP socket fails to bind to port 67. ```APIDOC ## pub async fn run(&mut self, stack: Stack<'_>) -> ! ### Description Runs the DHCP server forever on the provided network stack. ### Parameters - **stack** (Stack<'_>) - Required - The network stack instance to bind the DHCP server to. ### Panics Panics if the UDP socket cannot bind to port 67. ``` -------------------------------- ### Initialize DhcpServer Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=std%3A%3Avec Demonstrates creating a new DhcpServer instance using direct parameters or the DhcpConfigBuilder for advanced configuration. ```rust use core::net::Ipv4Addr; use leasehund::DhcpServer; let server = DhcpServer::<32, 4>::new( Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(255, 255, 255, 0), Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(8, 8, 8, 8), Ipv4Addr::new(192, 168, 1, 100), Ipv4Addr::new(192, 168, 1, 200), ); ``` ```rust use core::net::Ipv4Addr; use leasehund::{DhcpServer, DhcpConfigBuilder}; let config = DhcpConfigBuilder::<4>::new() .server_ip(Ipv4Addr::new(10, 0, 1, 1)) .subnet_mask(Ipv4Addr::new(255, 255, 0, 0)) .router(Ipv4Addr::new(10, 0, 1, 1)) .add_dns_server(Ipv4Addr::new(1, 1, 1, 1)) .add_dns_server(Ipv4Addr::new(1, 0, 0, 1)) .ip_pool(Ipv4Addr::new(10, 0, 100, 1), Ipv4Addr::new(10, 0, 199, 254)) .lease_time(7200) .build(); let server: DhcpServer<32, 4> = DhcpServer::with_config(config); ``` -------------------------------- ### DhcpServer::new Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=std%3A%3Avec Initializes a new DHCP server instance with basic configuration parameters. ```APIDOC ## DhcpServer::new ### Description Creates a new DHCP server instance using the provided network configuration parameters. ### Signature `DhcpServer::::new(server_ip, subnet_mask, router, dns_server, pool_start, pool_end)` ### Parameters - **server_ip** (Ipv4Addr) - Required - The IP address of the DHCP server. - **subnet_mask** (Ipv4Addr) - Required - The subnet mask for the network. - **router** (Ipv4Addr) - Required - The gateway/router IP address. - **dns_server** (Ipv4Addr) - Required - The primary DNS server IP. - **pool_start** (Ipv4Addr) - Required - The start of the IP address pool. - **pool_end** (Ipv4Addr) - Required - The end of the IP address pool. ``` -------------------------------- ### Initialize DhcpServer with new Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new DHCP server instance using direct parameters for network configuration. ```rust use core::net::Ipv4Addr; use leasehund::DhcpServer; let server = DhcpServer::<32, 4>::new( Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(255, 255, 255, 0), Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(8, 8, 8, 8), Ipv4Addr::new(192, 168, 1, 100), Ipv4Addr::new(192, 168, 1, 200), ); ``` -------------------------------- ### Configure DHCP server with DhcpConfigBuilder Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=u32+-%3E+bool Use the builder pattern to define advanced server settings before initializing the DhcpServer. ```rust use core::net::Ipv4Addr; use leasehund::{DhcpServer, DhcpConfigBuilder}; use embassy_net::Stack; let config = DhcpConfigBuilder::<4>::new() .server_ip(Ipv4Addr::new(10, 0, 1, 1)) .subnet_mask(Ipv4Addr::new(255, 255, 0, 0)) .router(Ipv4Addr::new(10, 0, 1, 1)) .add_dns_server(Ipv4Addr::new(1, 1, 1, 1)) .add_dns_server(Ipv4Addr::new(1, 0, 0, 1)) .add_dns_server(Ipv4Addr::new(8, 8, 8, 8)) .ip_pool( Ipv4Addr::new(10, 0, 100, 1), Ipv4Addr::new(10, 0, 199, 254) ) .lease_time(7200) .build(); let mut server: DhcpServer<32, 4> = DhcpServer::with_config(config); server.run(stack).await; ``` -------------------------------- ### pub async fn run_with_callback(&mut self, stack: Stack<'_>, callback: F) -> ! Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Runs the DHCP server indefinitely, invoking a provided callback function for every TransactionEvent that occurs. ```APIDOC ## run_with_callback ### Description Runs the DHCP server forever, invoking `callback` for every lease event. This is identical to `run` except that `TransactionEvent`s are forwarded to the caller via `callback` instead of being discarded. ### Parameters - **stack** (Stack<'_>) - Required - The network stack to run the DHCP server on. - **callback** (F) - Required - A closure that implements FnMut(TransactionEvent) to handle lease events. ``` -------------------------------- ### Initialize DHCPServerBuffers Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerBuffers.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Create a new instance of the DHCP server buffers using the new constructor. ```rust use leasehund::DHCPServerBuffers; let buffers = DHCPServerBuffers::new(); ``` -------------------------------- ### DhcpServer::new Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=std%3A%3Avec Creates a new DHCP server instance with a single DNS server configuration. ```APIDOC ## DhcpServer::new ### Description Creates a new DHCP server with a single DNS server. For multiple DNS servers or advanced options, use `DhcpConfigBuilder` with `with_config`. ### Signature `pub fn new(server_ip: Ipv4Addr, subnet_mask: Ipv4Addr, router: Ipv4Addr, dns_server: Ipv4Addr, ip_pool_start: Ipv4Addr, ip_pool_end: Ipv4Addr) -> Self` ``` -------------------------------- ### DhcpServer::new Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new DHCP server instance with a single DNS server configuration. ```APIDOC ## pub fn new(server_ip: Ipv4Addr, subnet_mask: Ipv4Addr, router: Ipv4Addr, dns_server: Ipv4Addr, ip_pool_start: Ipv4Addr, ip_pool_end: Ipv4Addr) -> Self ### Description Creates a new DHCP server with a single DNS server. For multiple DNS servers or advanced options, use `DhcpConfigBuilder` with `with_config`. ``` -------------------------------- ### pub async fn run(&mut self, stack: Stack<'_>) -> ! Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Runs the DHCP server indefinitely on the provided network stack. This method will panic if the underlying UDP socket fails to bind to port 67. ```APIDOC ## run ### Description Runs the DHCP server forever on the provided network stack. ### Parameters - **stack** (Stack<'_>) - Required - The network stack to run the DHCP server on. ### Panics Panics if the UDP socket cannot bind to port 67. ``` -------------------------------- ### DHCPServerBuffers::new Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerBuffers.html?search= Creates a new instance of DHCPServerBuffers. ```APIDOC ## pub const fn new() -> Self ### Description Creates a new set of DHCP server buffers. ### Signature `pub const fn new() -> Self` ### Example ```rust use leasehund::DHCPServerBuffers; let buffers = DHCPServerBuffers::new(); ``` ``` -------------------------------- ### DhcpServer::with_config Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=std%3A%3Avec Creates a new DHCP server instance using a pre-configured DhcpConfig object. ```APIDOC ## DhcpServer::with_config ### Description Creates a new DHCP server from a `DhcpConfig`. ### Signature `pub const fn with_config(config: DhcpConfig) -> Self` ``` -------------------------------- ### Run DHCP Server with Callback Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Executes the DHCP server while forwarding TransactionEvents to a provided callback function for monitoring lease activity. ```rust use embassy_net::Stack; use leasehund::{DhcpServer, TransactionEvent}; use core::net::Ipv4Addr; let mut server = DhcpServer::<32, 4>::new( Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(255, 255, 255, 0), Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(8, 8, 8, 8), Ipv4Addr::new(192, 168, 1, 100), Ipv4Addr::new(192, 168, 1, 200), ); server.run_with_callback(stack, |event| { match event { TransactionEvent::Leased(ip, mac) => { // log or react to new lease } TransactionEvent::Released(ip, mac) => { // log or react to release } } }).await; ``` -------------------------------- ### Find next available IP address Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to retrieve the next available IP address from the server's configured pool. ```rust use core::net::Ipv4Addr; use leasehund::{DhcpConfig, DhcpServer}; let mut dns_servers = heapless::Vec::::new(); dns_servers.push(Ipv4Addr::new(1, 1, 1, 1)).ok(); let config: DhcpConfig<4> = DhcpConfig { server_ip: Ipv4Addr::new(10, 0, 0, 1), subnet_mask: Ipv4Addr::new(255, 255, 255, 0), router: Some(Ipv4Addr::new(10, 0, 0, 1)), dns_servers, ip_pool_start: Ipv4Addr::new(10, 0, 0, 100), ip_pool_end: Ipv4Addr::new(10, 0, 0, 102), lease_time: 3600, }; let server: DhcpServer<32, 4> = DhcpServer::with_config(config); let next = server.get_next_available_ip(); assert!(matches!(next, Some(ip) if ip == Ipv4Addr::new(10, 0, 0, 100))); ``` -------------------------------- ### Initialize DHCPServerSocket Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerSocket.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new DHCP server UDP socket bound to port 67. Panics if the socket binding fails. ```rust use leasehund::{DHCPServerSocket, DHCPServerBuffers}; let mut buffers = DHCPServerBuffers::new(); let socket = DHCPServerSocket::new(stack, &mut buffers); ``` -------------------------------- ### Perform manual transaction handling Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=u32+-%3E+bool Use the lease_one method for manual control over DHCP transaction events. ```rust use core::net::Ipv4Addr; use leasehund::{DhcpServer, DHCPServerSocket, DHCPServerBuffers, TransactionEvent, DhcpConfigBuilder}; let config = DhcpConfigBuilder::<4>::new() .server_ip(Ipv4Addr::new(10, 0, 1, 1)) .subnet_mask(Ipv4Addr::new(255, 255, 0, 0)) .router(Ipv4Addr::new(10, 0, 1, 1)) .add_dns_server(Ipv4Addr::new(1, 1, 1, 1)) .add_dns_server(Ipv4Addr::new(1, 0, 0, 1)) .add_dns_server(Ipv4Addr::new(8, 8, 8, 8)) .ip_pool( Ipv4Addr::new(10, 0, 100, 1), Ipv4Addr::new(10, 0, 199, 254) ) .lease_time(7200) .build(); let mut server = DhcpServer::<32, 4>::with_config(config); let mut buffers = DHCPServerBuffers::new(); let mut socket = DHCPServerSocket::new(stack, &mut buffers); let _event: Result = server.lease_one(&mut socket).await; ``` -------------------------------- ### Initialize TransactionEvent Source: https://docs.rs/leasehund/latest/leasehund/enum.TransactionEvent.html Create a new TransactionEvent instance representing a lease event. ```rust use leasehund::TransactionEvent; use core::net::Ipv4Addr; let event = TransactionEvent::Leased(Ipv4Addr::new(192, 168, 1, 100), [0x00, 0x11, 0x22, 0x33, 0x44, 0x55]); ``` -------------------------------- ### DhcpServer Utility Methods Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html Methods for managing the server state, including lease counts, pool status, and IP allocation. ```APIDOC ## Utility Methods - `config(&self) -> &DhcpConfig`: Gets a reference to the current configuration. - `lease_count(&self) -> usize`: Gets the current number of active leases. - `purge_expired_leases(&mut self)`: Removes all expired leases from the lease table. - `is_pool_full(&self) -> bool`: Checks if the IP pool is full. - `get_next_available_ip(&self) -> Option`: Finds the next available IP address in the configured pool. ``` -------------------------------- ### DhcpConfigBuilder Source: https://docs.rs/leasehund/latest/leasehund/index.html?search= A fluent builder API for configuring the DHCP server with advanced settings. ```APIDOC ## DhcpConfigBuilder ### Description Provides a fluent interface to configure the DHCP server settings before instantiation. ### Methods - **server_ip(Ipv4Addr)** - Sets the server IP. - **subnet_mask(Ipv4Addr)** - Sets the subnet mask. - **router(Ipv4Addr)** - Sets the router/gateway IP. - **add_dns_server(Ipv4Addr)** - Adds a DNS server to the configuration. - **ip_pool(Ipv4Addr, Ipv4Addr)** - Sets the start and end range for the IP pool. - **lease_time(u32)** - Sets the lease duration in seconds. - **build()** - Returns the final configuration object. ``` -------------------------------- ### DHCPServerBuffers::new Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerBuffers.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new instance of DHCPServerBuffers, initializing the pre-allocated UDP socket buffers and metadata. ```APIDOC ## pub const fn new() -> Self ### Description Creates a new set of DHCP server buffers for use by the DHCP server. ### Signature `pub const fn new() -> Self` ### Example ```rust use leasehund::DHCPServerBuffers; let buffers = DHCPServerBuffers::new(); ``` ``` -------------------------------- ### DhcpConfigBuilder Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=std%3A%3Avec A fluent builder API for configuring the DHCP server with advanced options. ```APIDOC ## DhcpConfigBuilder ### Description Provides a builder pattern to configure the DHCP server settings before initialization. ### Methods - **server_ip(Ipv4Addr)**: Sets the server IP. - **subnet_mask(Ipv4Addr)**: Sets the subnet mask. - **router(Ipv4Addr)**: Sets the gateway IP. - **add_dns_server(Ipv4Addr)**: Adds a DNS server to the configuration. - **ip_pool(Ipv4Addr, Ipv4Addr)**: Sets the start and end of the IP address pool. - **lease_time(u32)**: Sets the lease duration in seconds. - **build()**: Consumes the builder and returns a configuration object. ``` -------------------------------- ### DhcpConfigBuilder Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Fluent API for advanced DHCP server configuration. ```APIDOC ## DhcpConfigBuilder ### Description Provides a builder pattern to construct complex DHCP configurations before initializing the server. ### Methods - `.server_ip(Ipv4Addr)`: Sets the server IP. - `.subnet_mask(Ipv4Addr)`: Sets the subnet mask. - `.router(Ipv4Addr)`: Sets the gateway IP. - `.add_dns_server(Ipv4Addr)`: Adds a DNS server to the configuration. - `.ip_pool(start, end)`: Defines the range of assignable IP addresses. - `.lease_time(u32)`: Sets the lease duration in seconds. - `.build()`: Consumes the builder and returns a configuration object. ``` -------------------------------- ### DHCPServerSocket::new Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerSocket.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new instance of DHCPServerSocket bound to port 67. ```APIDOC ## pub fn new(stack: Stack<'a>, buffers: &'a mut DHCPServerBuffers) -> Self ### Description Creates a new DHCP server UDP socket bound to port 67. This method initializes the socket using the provided network stack and buffers. ### Parameters - **stack** (Stack<'a>) - Required - The network stack to use for the socket. - **buffers** (&'a mut DHCPServerBuffers) - Required - Mutable reference to the buffers required by the DHCP server. ### Panics Panics if the socket binding to port 67 fails. ### Example ```rust use leasehund::{DHCPServerSocket, DHCPServerBuffers}; let mut buffers = DHCPServerBuffers::new(); let socket = DHCPServerSocket::new(stack, &mut buffers); ``` ``` -------------------------------- ### Run DHCP Server Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Executes the DHCP server indefinitely on the provided network stack. Panics if the UDP socket fails to bind to port 67. ```rust use embassy_net::Stack; use leasehund::DhcpServer; use core::net::Ipv4Addr; let mut server = DhcpServer::<32, 4>::new( Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(255, 255, 255, 0), Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(8, 8, 8, 8), Ipv4Addr::new(192, 168, 1, 100), Ipv4Addr::new(192, 168, 1, 200), ); server.run(stack).await; ``` -------------------------------- ### DhcpServer::lease_one Source: https://docs.rs/leasehund/latest/leasehund/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Manually handles a single DHCP transaction event. ```APIDOC ## DhcpServer::lease_one ### Description Processes a single DHCP transaction event using the provided socket and buffers. Useful for manual control over the server's event loop. ### Signature `server.lease_one(&mut socket).await` ``` -------------------------------- ### DhcpServer::lease_one Source: https://docs.rs/leasehund/latest/leasehund/index.html?search= Manually handles a single DHCP transaction event. ```APIDOC ## DhcpServer::lease_one ### Description Processes a single DHCP transaction event using the provided socket. ### Parameters - **socket** (DHCPServerSocket) - Required - The socket used for communication. ``` -------------------------------- ### DhcpConfigBuilder API Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpConfigBuilder.html Methods available for configuring and building a DHCP server configuration. ```APIDOC ## DhcpConfigBuilder ### new() Creates a new configuration builder with default settings and no DNS servers. ### server_ip(ip: Ipv4Addr) Sets the DHCP server IP address. ### subnet_mask(mask: Ipv4Addr) Sets the subnet mask. ### router(router: Ipv4Addr) Sets the default gateway/router IP address. ### no_router() Removes the router option. ### add_dns_server(dns: Ipv4Addr) Adds a DNS server to the configuration. If the maximum number of DNS servers is reached, the server is dropped. ### clear_dns_servers() Clears all configured DNS servers. ### ip_pool(start: Ipv4Addr, end: Ipv4Addr) Sets the IP address pool range. ### lease_time(seconds: u32) Sets the lease time in seconds. ### build() Builds and returns the final DhcpConfig object. ``` -------------------------------- ### Define DHCPServerBuffers struct Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerBuffers.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The internal structure definition for DHCPServerBuffers. ```rust pub struct DHCPServerBuffers { /* private fields */ } ``` -------------------------------- ### DHCPServerSocket::new Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerSocket.html Creates a new DHCP server UDP socket bound to port 67. Panics if the socket binding fails. ```APIDOC ## pub fn new(stack: Stack<'a>, buffers: &'a mut DHCPServerBuffers) -> Self ### Description Creates a new DHCP server UDP socket bound to port 67. This method initializes the socket using the provided network stack and buffers. ### Parameters - **stack** (Stack<'a>) - Required - The network stack to use for the socket. - **buffers** (&'a mut DHCPServerBuffers) - Required - The buffers required for the DHCP server socket operations. ### Panics Panics if the socket binding fails. ### Example ```rust use leasehund::{DHCPServerSocket, DHCPServerBuffers}; let mut buffers = DHCPServerBuffers::new(); let socket = DHCPServerSocket::new(stack, &mut buffers); ``` ``` -------------------------------- ### DHCPServerSocket::new Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerSocket.html?search= Creates a new DHCP server UDP socket bound to port 67. Panics if the socket binding fails. ```APIDOC ## pub fn new(stack: Stack<'a>, buffers: &'a mut DHCPServerBuffers) -> Self ### Description Creates a new DHCP server UDP socket bound to port 67. This is the primary constructor for initializing the socket. ### Parameters - **stack** (Stack<'a>) - Required - The network stack to use for the socket. - **buffers** (&'a mut DHCPServerBuffers) - Required - Mutable reference to the buffers required for DHCP server operations. ### Panics Panics if the socket binding fails. ### Example ```rust use leasehund::{DHCPServerSocket, DHCPServerBuffers}; let mut buffers = DHCPServerBuffers::new(); let socket = DHCPServerSocket::new(stack, &mut buffers); ``` ``` -------------------------------- ### DhcpServer::lease_one Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Processes DHCP packets asynchronously to handle a single lease or release transaction. ```APIDOC ## pub async fn lease_one(&mut self, socket: &mut DHCPServerSocket<'_>) -> Result ### Description Processes packets until a single lease or release transaction completes. Returns `RecvError` if there was an error receiving a packet. ``` -------------------------------- ### Define DhcpConfigBuilder struct Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpConfigBuilder.html?search= The definition of the DhcpConfigBuilder struct with a configurable maximum number of DNS servers. ```rust pub struct DhcpConfigBuilder { /* private fields */ } ``` -------------------------------- ### DhcpServer::lease_one Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=u32+-%3E+bool Processes network packets to complete a single DHCP lease or release transaction. ```APIDOC ## pub async fn lease_one(&mut self, socket: &mut DHCPServerSocket<'_>) -> Result ### Description Processes packets until a single lease or release transaction completes. ``` -------------------------------- ### Process DHCP transactions Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Uses lease_one to process network packets for a single lease or release transaction. ```rust use leasehund::{DhcpServer, DHCPServerBuffers, DHCPServerSocket, TransactionEvent}; use core::net::Ipv4Addr; let mut server = DhcpServer::<32, 4>::new( Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(255, 255, 255, 0), Ipv4Addr::new(192, 168, 1, 1), Ipv4Addr::new(8, 8, 8, 8), Ipv4Addr::new(192, 168, 1, 100), Ipv4Addr::new(192, 168, 1, 200), ); let mut buffers = DHCPServerBuffers::new(); let mut socket = DHCPServerSocket::new(stack, &mut buffers); let _event: Result = server.lease_one(&mut socket).await; ``` -------------------------------- ### DhcpServer::get_next_available_ip Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search= Retrieves the next available IP address from the configured pool. ```APIDOC ## pub fn get_next_available_ip(&self) -> Option ### Description Searches the configured IP pool and returns the next available `Ipv4Addr` if one exists. ``` -------------------------------- ### Define DHCPServerSocket Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerSocket.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The struct definition for DHCPServerSocket. ```rust pub struct DHCPServerSocket<'a> { /* private fields */ } ``` -------------------------------- ### DHCPServerSocket::new Source: https://docs.rs/leasehund/latest/leasehund/struct.DHCPServerSocket.html?search=std%3A%3Avec Creates a new DHCP server UDP socket bound to port 67. This method will panic if the socket binding fails. ```APIDOC ## pub fn new(stack: Stack<'a>, buffers: &'a mut DHCPServerBuffers) -> Self ### Description Creates a new DHCP server UDP socket bound to port 67. ### Parameters - **stack** (Stack<'a>) - Required - The network stack to use for the socket. - **buffers** (&'a mut DHCPServerBuffers) - Required - Mutable reference to the buffers required for the DHCP server socket. ### Panics Panics if the socket binding fails. ### Example ```rust use leasehund::{DHCPServerSocket, DHCPServerBuffers}; let mut buffers = DHCPServerBuffers::new(); let socket = DHCPServerSocket::new(stack, &mut buffers); ``` ``` -------------------------------- ### DhcpConfig Struct Definition Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpConfig.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The structure definition for DhcpConfig, utilizing a const generic for the maximum number of DNS servers. ```rust pub struct DhcpConfig { pub server_ip: Ipv4Addr, pub subnet_mask: Ipv4Addr, pub router: Option, pub dns_servers: Vec, pub ip_pool_start: Ipv4Addr, pub ip_pool_end: Ipv4Addr, pub lease_time: u32, } ``` -------------------------------- ### DhcpServer::is_pool_full Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=u32+-%3E+bool Checks if the configured IP address pool is currently full. ```APIDOC ## pub fn is_pool_full(&self) -> bool ### Description Checks if the IP pool is full. Call `purge_expired_leases` first to reclaim expired entries if desired. ``` -------------------------------- ### DhcpServer::lease_count Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=u32+-%3E+bool Retrieves the current number of active leases managed by the server. ```APIDOC ## pub fn lease_count(&self) -> usize ### Description Gets the current number of active leases. ``` -------------------------------- ### DhcpServer::get_next_available_ip Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Finds the next available IP address within the configured IP pool. ```APIDOC ## pub fn get_next_available_ip(&self) -> Option ### Description Finds the next available IP address in the configured pool. ``` -------------------------------- ### DhcpServer::get_next_available_ip Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=std%3A%3Avec Finds the next available IP address within the configured IP pool. ```APIDOC ## DhcpServer::get_next_available_ip ### Description Finds the next available IP address in the configured pool. ### Signature `pub fn get_next_available_ip(&self) -> Option` ``` -------------------------------- ### DhcpServer::purge_expired_leases Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Removes all expired leases from the internal lease table. ```APIDOC ## pub fn purge_expired_leases(&mut self) ### Description Removes all expired leases from the lease table. ``` -------------------------------- ### DhcpServer::purge_expired_leases Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search=std%3A%3Avec Removes all expired leases from the internal lease table. ```APIDOC ## DhcpServer::purge_expired_leases ### Description Removes all expired leases from the lease table. ### Signature `pub fn purge_expired_leases(&mut self)` ``` -------------------------------- ### DhcpServer::purge_expired_leases Source: https://docs.rs/leasehund/latest/leasehund/struct.DhcpServer.html?search= Removes all expired leases from the internal lease table. ```APIDOC ## pub fn purge_expired_leases(&mut self) ### Description Clears the lease table by removing all entries that have expired. ``` -------------------------------- ### Define RecvError Enum Source: https://docs.rs/leasehund/latest/leasehund/enum.RecvError.html?search= The structure of the RecvError enum, which currently contains a single variant for truncated packets. ```rust pub enum RecvError { Truncated, } ``` -------------------------------- ### Define TransactionEvent Enum Source: https://docs.rs/leasehund/latest/leasehund/enum.TransactionEvent.html The structure of the TransactionEvent enum, containing variants for Leased and Released events. ```rust pub enum TransactionEvent { Leased(Ipv4Addr, [u8; 6]), Released(Ipv4Addr, [u8; 6]), } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.