|
join 1.0
lightweight network framework library
|
DHCP server. More...
#include <dhcp.hpp>


Public Member Functions | |
| BasicDhcpServer ()=delete | |
| create the BasicDhcpServer instance. | |
| BasicDhcpServer (const std::string &interface, Reactor &reactor=ReactorThread::reactor()) | |
| create the instance bound to the given interface. | |
| virtual | ~BasicDhcpServer ()=default |
| destroy the instance. | |
| int | offer (const DhcpPacket &request, const IpAddress &address, const DhcpOption &options={}) |
| answer a DISCOVER message with an OFFER. | |
| int | ack (const DhcpPacket &request, const IpAddress &address, const DhcpOption &options={}) |
| answer a REQUEST message with an ACK. | |
| int | nak (const DhcpPacket &request, const std::string &message={}) |
| refuse a REQUEST message with a NAK. | |
Public Member Functions inherited from join::BasicDhcp< Protocol > | |
| BasicDhcp ()=delete | |
| create the BasicDhcp instance. | |
| BasicDhcp (const std::string &interface, Reactor &reactor=ReactorThread::reactor()) | |
| create the instance bound to the given interface. | |
| BasicDhcp (const BasicDhcp &other)=delete | |
| create instance by copy. | |
| BasicDhcp & | operator= (const BasicDhcp &other)=delete |
| assign instance by copy. | |
| BasicDhcp (BasicDhcp &&other)=delete | |
| create instance by move. | |
| BasicDhcp & | operator= (BasicDhcp &&other)=delete |
| assign instance by move. | |
| virtual | ~BasicDhcp () |
| destroy the instance. | |
| const std::string & | interface () const noexcept |
| get the name of the interface the instance is bound to. | |
| const MacAddress & | hardware () const noexcept |
| get the hardware address of the interface the instance is bound to. | |
Public Member Functions inherited from join::EventHandler | |
| EventHandler ()=default | |
| create instance. | |
| EventHandler (const EventHandler &other)=default | |
| copy constructor. | |
| EventHandler & | operator= (const EventHandler &other)=default |
| copy assignment operator. | |
| EventHandler (EventHandler &&other)=default | |
| move constructor. | |
| EventHandler & | operator= (EventHandler &&other)=default |
| move assignment operator. | |
| virtual | ~EventHandler ()=default |
| destroy instance. | |
Protected Member Functions | |
| virtual void | onDiscover (const DhcpPacket &request)=0 |
| method called when a DISCOVER message is received. | |
| virtual void | onRequest (const DhcpPacket &request)=0 |
| method called when a REQUEST message is received. | |
| virtual void | onRelease (const DhcpPacket &request)=0 |
| method called when a RELEASE message is received. | |
| virtual void | onDecline (const DhcpPacket &request)=0 |
| method called when a DECLINE message is received. | |
| virtual void | onInform (const DhcpPacket &request)=0 |
| method called when an INFORM message is received. | |
| void | onMessage (DhcpPacket::Ptr packet) override final |
| dispatch a received message to the handler for its type. | |
| int | reply (const DhcpPacket &request, uint8_t type, const IpAddress &address, const DhcpOption &options) |
| answer a message received from a client. | |
Protected Member Functions inherited from join::BasicDhcp< Protocol > | |
| struct | __attribute__ ((packed)) Frame |
| link, internet and transport headers a DHCP message is framed with. | |
| struct | __attribute__ ((packed)) Pseudo |
| header the UDP checksum is computed over, RFC 768. | |
| void | onReadable (int fd) override final |
| method called when data are ready to be read. | |
| int | transmit (const DhcpPacket &packet, const IpAddress &source, const IpAddress &destination) |
| frame a message and write it on the wire. | |
| DhcpPacket::Ptr | receive (const char *data, size_t size) const |
| decode a frame received on the wire. | |
Protected Member Functions inherited from join::EventHandler | |
| virtual void | onEvent (int fd, uint32_t revents) |
| method called when events are reported on handle. | |
| virtual void | onWriteable (int fd) |
| method called when data are ready to be written on handle. | |
| virtual void | onClose (int fd) |
| method called when handle was closed by the peer. | |
| virtual void | onError (int fd) |
| method called when an error occurred on handle. | |
Additional Inherited Members | |
Public Types inherited from join::BasicDhcp< Protocol > | |
| using | Socket = typename Protocol::Socket |
Static Protected Member Functions inherited from join::BasicDhcp< Protocol > | |
| static uint16_t | udpChecksum (const Frame &frame, const char *payload, size_t size) |
| compute the checksum of a UDP datagram, RFC 768. | |
Protected Attributes inherited from join::BasicDhcp< Protocol > | |
| Socket | _socket |
| underlying socket. | |
| DhcpMessage | _message |
| DHCP message codec. | |
| std::unique_ptr< char[]> | _buffer |
| receive buffer. | |
| const std::string | _interface |
| interface name. | |
| const MacAddress | _hardware |
| hardware address of the interface. | |
| Reactor & | _reactor |
| event loop reactor. | |
DHCP server.
|
delete |
create the BasicDhcpServer instance.
|
inlineexplicit |
create the instance bound to the given interface.
| interface | interface name. |
| reactor | reactor instance. |
| std::system_error | if the interface is unknown or the socket could not be bound to it. |
|
virtualdefault |
destroy the instance.
|
inline |
answer a REQUEST message with an ACK.
| request | message being answered. |
| address | address assigned to the client. |
| options | options to advertise, the message type and the server identifier are added. |
|
inline |
refuse a REQUEST message with a NAK.
| request | message being refused. |
| message | human readable reason, empty to give none. |
|
inline |
answer a DISCOVER message with an OFFER.
| request | message being answered. |
| address | address offered to the client. |
| options | options to advertise, the message type and the server identifier are added. |
|
protectedpure virtual |
method called when a DECLINE message is received.
| request | message received. |
|
protectedpure virtual |
method called when a DISCOVER message is received.
| request | message received. |
|
protectedpure virtual |
method called when an INFORM message is received.
| request | message received. |
|
inlinefinaloverrideprotectedvirtual |
dispatch a received message to the handler for its type.
| packet | message received. |
Implements join::BasicDhcp< Protocol >.
|
protectedpure virtual |
method called when a RELEASE message is received.
| request | message received. |
|
protectedpure virtual |
method called when a REQUEST message is received.
| request | message received. |
|
inlineprotected |
answer a message received from a client.
| request | message being answered. |
| type | message type of the answer. |
| address | address assigned to the client. |
| options | options to advertise. |