Struct Server

Source
pub struct Server {
    pub socket: Socket,
    pub ip: Ipv4Addr,
    pub config: Config,
    pub ip_pool: IpPool,
}
Expand description

Ties together a Config, Socket, and IpPool 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: Socket

A UdpSocket that understands Deliverables to communicate with the Client

§ip: Ipv4Addr

Direct access to the ipv4 address passed to the UdpSocket.

A server with multiple network addresses may use any of its addresses.

§config: Config

Configuration read from toe-beans.toml

§ip_pool: IpPool

Manages the leasing logic of a range of ip addresses

Implementations§

Source§

impl Server

Source

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.

Source

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.

Source

pub fn listen(&mut self) -> !

Calls listen_once in a loop forever.

Source

pub fn offer(&mut self, message: Message) -> Result<Message>

Sent from the server to client following a Discover message

Source

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.

Source

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.

Source

pub fn nak(&self, message: Message, error: String) -> Message

Sent from the server to client following a Request message

Auto Trait Implementations§

§

impl Freeze for Server

§

impl RefUnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl UnwindSafe for Server

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V