pub struct Server {
pub socket: Socket,
pub ip: Ipv4Addr,
pub config: Config,
pub leases: Leases,
}Expand description
Ties together a Config, Socket, and Leases in order to handle incoming Client Messages, and construct server-specific response Messages.
Used by the server binary and integration tests.
Requires the v4_server feature, which is enabled by default.
Fields§
§socket: SocketA UdpSocket that understands Deliverables to communicate with the Client
ip: Ipv4AddrDirect access to the ipv4 address passed to the UdpSocket.
A server with multiple network addresses may use any of its addresses.
config: ConfigConfiguration read from toe-beans.toml
leases: LeasesManages the leasing logic of a range of ip addresses
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(config: Config) -> Self
pub fn new(config: Config) -> Self
Setup everything necessary for a Server to listen for incoming Messages.
This fn is relatively “slow” and may panic, but that is okay
because it is called before the listen or listen_once fns.
Sourcepub fn listen_once(&mut self)
pub fn listen_once(&mut self)
Will wait for one Message on the UdpSocket and send a response based on it.
To handle more than one Message, use listen.
Sourcepub fn offer(&mut self, message: Message) -> Result<Message>
pub fn offer(&mut self, message: Message) -> Result<Message>
Sent from the server to client following a Discover message
Sourcepub fn ack(&mut self, message: Message, yiaddr: Ipv4Addr) -> Message
pub fn ack(&mut self, message: Message, yiaddr: Ipv4Addr) -> Message
Sent from the server to client following a Request message
Acks behave differently depending on if they are sent in response to a DHCP Request or DHCP Inform. For example, a DHCP Request must send lease time and a DHCP Inform must not.
Any configuration parameters in the DHCPACK message SHOULD NOT conflict with those in the earlier DHCPOFFER message to which the client is responding.
Sourcepub fn ack_inform(&self, message: Message) -> Message
pub fn ack_inform(&self, message: Message) -> Message
Sent from server to client in response to an Inform message
Acks behave differently depending on if they are sent in response to a DHCP Request or DHCP Inform. For example, a DHCP Request must send lease time and a DHCP Inform must not.