join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
Server Class Reference

a DHCP server handing out addresses from a pool. More...

Inheritance diagram for Server:
Collaboration diagram for Server:

Public Member Functions

 Server (const std::string &device, const IpAddress &first, uint32_t count, const DhcpOption &options)
 create the server instance.
 

Protected Member Functions

void onDiscover (const DhcpPacket &request) override
 offer an address to a client asking for one.
 
void onRequest (const DhcpPacket &request) override
 acknowledge the address a client asks to keep.
 
void onRelease (const DhcpPacket &request) override
 give the address of a client back to the pool.
 
void onDecline (const DhcpPacket &request) override
 drop an address a client reported as already in use.
 
void onInform (const DhcpPacket &request) override
 answer a client asking only for the parameters.
 
IpAddress allocate (const DhcpPacket &request)
 pick an address for the given client.
 

Protected Attributes

const uint32_t _first
 first address of the pool, in host order.
 
const uint32_t _count
 number of addresses in the pool.
 
const DhcpOption _options
 options advertised to the clients.
 
std::map< MacAddress, IpAddress_leases
 addresses handed out, indexed by client hardware address.
 

Detailed Description

a DHCP server handing out addresses from a pool.

Constructor & Destructor Documentation

◆ Server()

Server::Server ( const std::string & device,
const IpAddress & first,
uint32_t count,
const DhcpOption & options )
inline

create the server instance.

Parameters
deviceinterface to serve.
firstfirst address of the pool.
countnumber of addresses in the pool.
optionsoptions to advertise to the clients.

Member Function Documentation

◆ allocate()

IpAddress Server::allocate ( const DhcpPacket & request)
inlineprotected

pick an address for the given client.

Parameters
requestmessage received.
Returns
the address picked, wildcard if the pool is exhausted.

◆ onDecline()

void Server::onDecline ( const DhcpPacket & request)
inlineoverrideprotected

drop an address a client reported as already in use.

Parameters
requestmessage received.

◆ onDiscover()

void Server::onDiscover ( const DhcpPacket & request)
inlineoverrideprotected

offer an address to a client asking for one.

Parameters
requestmessage received.

◆ onInform()

void Server::onInform ( const DhcpPacket & request)
inlineoverrideprotected

answer a client asking only for the parameters.

Parameters
requestmessage received.

◆ onRelease()

void Server::onRelease ( const DhcpPacket & request)
inlineoverrideprotected

give the address of a client back to the pool.

Parameters
requestmessage received.

◆ onRequest()

void Server::onRequest ( const DhcpPacket & request)
inlineoverrideprotected

acknowledge the address a client asks to keep.

Parameters
requestmessage received.

Member Data Documentation

◆ _count

const uint32_t Server::_count
protected

number of addresses in the pool.

◆ _first

const uint32_t Server::_first
protected

first address of the pool, in host order.

◆ _leases

std::map<MacAddress, IpAddress> Server::_leases
protected

addresses handed out, indexed by client hardware address.

◆ _options

const DhcpOption Server::_options
protected

options advertised to the clients.


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