SatCat5
satcat5::ip::DhcpServer Class Referencefinal

Detailed Description

DHCP Server for managing leases to other clients.

See also
ip_dhcp.h, DhcpClient

Definition at line 194 of file ip_dhcp.h.

#include <ip_dhcp.h>

Inheritance diagram for satcat5::ip::DhcpServer:
[legend]
Collaboration diagram for satcat5::ip::DhcpServer:
[legend]

Public Member Functions

 DhcpServer (satcat5::udp::Dispatch *iface, satcat5::ip::DhcpPool *pool)
 Attach this DHCP server to a UDP-dispatch object and address pool.
 
void count_leases (unsigned &free, unsigned &taken) const
 Report the number of active or open leases.
 
satcat5::ip::Addr request (u32 lease_seconds, const satcat5::ip::Addr &addr=satcat5::ip::ADDR_NONE)
 Manually request/reserve an IP address for the next N seconds. More...
 
void max_lease (u32 seconds)
 Change the lease timeout. (Mostly used for testing.)
 
void timer_once (unsigned msec)
 Configure a one-time notification after X milliseconds.
 
void timer_every (unsigned msec)
 Configure a repeating notification every X milliseconds.
 
void timer_stop ()
 Stop all future notifications.
 
unsigned timer_interval () const
 Accessor for recurring timer interval, if one is set.
 
unsigned timer_remaining () const
 Accessor for time to next event, if one is set.
 
void set_dns (const satcat5::ip::Addr &addr)
 Set various optional client-configuration fields. More...
 
void set_domain (const char *name)
 Set various optional client-configuration fields. More...
 
void set_gateway (const satcat5::ip::Subnet &gateway)
 Set various optional client-configuration fields. More...
 

Static Public Member Functions

static unsigned count_timer ()
 Count all objects of this type, including idle timers.
 

Protected Attributes

satcat5::net::Type m_filter
 Incoming packet filter.
 

Private Member Functions

void frame_rcvd (satcat5::io::LimitedRead &src) override
 Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value. More...
 
void timer_event () override
 Child class MUST override this method.
 
satcat5::ip::Addr offer (u32 client_id, u32 req_ipaddr, u32 req_lease)
 
satcat5::ip::Addr reserve (u32 client_id, u32 req_ipaddr, u32 req_lease)
 
void query (unsigned elapsed_msec)
 

Private Attributes

satcat5::udp::Dispatch *const m_iface
 
satcat5::ip::DhcpPool *const m_pool
 
u32 m_time
 Arbitrary timescale (+1/sec)
 
u32 m_max_lease
 Maximum lease in seconds.
 
unsigned m_next_lease
 Next lease request.
 
unsigned m_next_timer
 Next timer event.
 
satcat5::ip::Addr m_dns
 DNS server, if one is available.
 
const char * m_domain
 Domain name (human-readable)
 
satcat5::ip::Subnet m_gateway
 Default gateway and subnet mask.
 
satcat5::net::Protocolm_next
 Linked list of Protocols.
 
unsigned m_trem
 
unsigned m_tnext
 

Member Function Documentation

◆ frame_rcvd()

void DhcpServer::frame_rcvd ( satcat5::io::LimitedRead src)
overrideprivatevirtual

Dispatch calls frame_rcvd(...) for each incoming frame with with a matching net::Type value.

The child class SHOULD read the frame contents from the provided "src" object, which is only valid until the function returns.

To send a reply:

  • Call m_iface->open_reply() to obtain a Writable object. (This also writes out any applicable frame headers.)
  • Write frame contents, then call write_finalize().

The child class MUST override this method.

Implements satcat5::net::Protocol.

Definition at line 587 of file ip_dhcp.cc.

◆ request()

Addr DhcpServer::request ( u32  lease_seconds,
const satcat5::ip::Addr addr = satcat5::ip::ADDR_NONE 
)

Manually request/reserve an IP address for the next N seconds.

Request a specific address or ADDR_NONE for the first available.

Definition at line 579 of file ip_dhcp.cc.

◆ set_dns()

void satcat5::ip::DhcpServer::set_dns ( const satcat5::ip::Addr addr)
inline

Set various optional client-configuration fields.

Once set, these will be included in outgoing DHCP responses.

Definition at line 216 of file ip_dhcp.h.

◆ set_domain()

void satcat5::ip::DhcpServer::set_domain ( const char *  name)
inline

Set various optional client-configuration fields.

Once set, these will be included in outgoing DHCP responses.

Definition at line 218 of file ip_dhcp.h.

◆ set_gateway()

void satcat5::ip::DhcpServer::set_gateway ( const satcat5::ip::Subnet gateway)
inline

Set various optional client-configuration fields.

Once set, these will be included in outgoing DHCP responses.

Definition at line 220 of file ip_dhcp.h.


The documentation for this class was generated from the following files: