SatCat5
satcat5::ip::DhcpClient Class Referencefinal

Detailed Description

DHCP Client for leasing an IP address from a server.

See also
ip_dhcp.h, DhcpServer

Definition at line 71 of file ip_dhcp.h.

#include <ip_dhcp.h>

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

Public Member Functions

 DhcpClient (satcat5::udp::Dispatch *iface)
 Attach this DHCP client to a UDP-dispatch object.
 
void inform (const satcat5::ip::Addr &new_addr)
 Set a static IP and fetch other parameters from the server.
 
void release (const satcat5::ip::Addr &new_addr=satcat5::ip::ADDR_NONE)
 Relinquish the currently held lease, if one exists. More...
 
void renew ()
 Request extension of current lease if held, otherwise request a new lease. More...
 
satcat5::ip::DhcpState state () const
 Report current lease state.
 
u32 status () const
 Report remaining lease time, or zero if none is held.
 
void set_client_id (const satcat5::ip::DhcpId *id)
 Set an explicit client identifier (RFC2132 Section 9.14). More...
 
virtual void gateway_change (const satcat5::ip::Addr &dstaddr, const satcat5::ip::Addr &gateway)
 Callback for changes to gateway configuration. More...
 
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.
 

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 arp_event (const satcat5::eth::MacAddr &mac, const satcat5::ip::Addr &ip) override
 Callback for any announced MAC/IP address pair. More...
 
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.
 
void next_timer ()
 
void send_message (u8 opcode)
 
void query (unsigned elapsed_msec)
 

Private Attributes

satcat5::udp::Dispatch *const m_iface
 
const satcat5::ip::DhcpIdm_client_id
 
satcat5::udp::Address m_server
 Server IP+MAC address.
 
satcat5::ip::DhcpState m_state
 Client state.
 
satcat5::ip::Addr m_ipaddr
 Assigned IP address, if any.
 
u16 m_seconds
 Seconds since start of process.
 
u32 m_server_id
 Server-ID (may not match IP-addr)
 
u32 m_timeout
 Time to next action, in seconds.
 
u32 m_xid
 Client/server transaction-ID.
 
satcat5::eth::ArpListenerm_next
 
unsigned m_trem
 
unsigned m_tnext
 

Member Function Documentation

◆ arp_event()

void DhcpClient::arp_event ( const satcat5::eth::MacAddr mac,
const satcat5::ip::Addr ip 
)
overrideprivatevirtual

Callback for any announced MAC/IP address pair.

Child class MUST override this method.

Implements satcat5::eth::ArpListener.

Definition at line 213 of file ip_dhcp.cc.

◆ frame_rcvd()

void DhcpClient::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 227 of file ip_dhcp.cc.

◆ gateway_change()

virtual void satcat5::eth::ArpListener::gateway_change ( const satcat5::ip::Addr dstaddr,
const satcat5::ip::Addr gateway 
)
inlinevirtualinherited

Callback for changes to gateway configuration.

Child class MAY override this method.

Reimplemented in satcat5::ip::Address, and satcat5::test::CountArpResponse.

Definition at line 56 of file eth_arp.h.

◆ release()

void DhcpClient::release ( const satcat5::ip::Addr new_addr = satcat5::ip::ADDR_NONE)

Relinquish the currently held lease, if one exists.

Halts automatic requests until renew() is called. If an address is provided, set the new static IP address.

Definition at line 178 of file ip_dhcp.cc.

◆ renew()

void DhcpClient::renew ( )

Request extension of current lease if held, otherwise request a new lease.

Resumes automatic requests.

Definition at line 186 of file ip_dhcp.cc.

◆ set_client_id()

void satcat5::ip::DhcpClient::set_client_id ( const satcat5::ip::DhcpId id)
inline

Set an explicit client identifier (RFC2132 Section 9.14).

This is not normally required, but can help ensure continuity when switching between network adapters (e.g., wired/wireless).

Definition at line 103 of file ip_dhcp.h.


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