|
join 1.0
lightweight network framework library
|
carries DHCP messages over a packet socket. More...
#include <dhcp.hpp>


Public Types | |
| using | Socket = typename Protocol::Socket |
Public Member Functions | |
| 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 | |
| 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. | |
| virtual void | onMessage (DhcpPacket::Ptr packet)=0 |
| method called when a DHCP message is received. | |
| 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. | |
Static Protected Member Functions | |
| static uint16_t | udpChecksum (const Frame &frame, const char *payload, size_t size) |
| compute the checksum of a UDP datagram, RFC 768. | |
Protected Attributes | |
| 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. | |
carries DHCP messages over a packet socket.
| using join::BasicDhcp< Protocol >::Socket = typename Protocol::Socket |
|
delete |
create the BasicDhcp 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. |
|
delete |
create instance by copy.
| other | other object to copy. |
|
delete |
create instance by move.
| other | other object to move. |
|
inlinevirtual |
destroy the instance.
|
inlineprotected |
link, internet and transport headers a DHCP message is framed with.
|
inlineprotected |
header the UDP checksum is computed over, RFC 768.
|
inlinenoexcept |
get the hardware address of the interface the instance is bound to.
|
inlinenoexcept |
get the name of the interface the instance is bound to.
|
protectedpure virtual |
method called when a DHCP message is received.
| packet | message received. |
Implemented in join::BasicDhcpClient< Protocol >, and join::BasicDhcpServer< Protocol >.
|
inlinefinaloverrideprotectedvirtual |
method called when data are ready to be read.
| fd | file descriptor. |
Reimplemented from join::EventHandler.
|
delete |
assign instance by move.
| other | other object to move. |
|
delete |
assign instance by copy.
| other | other object to copy. |
|
inlineprotected |
decode a frame received on the wire.
| data | frame received. |
| size | frame size. |
|
inlineprotected |
frame a message and write it on the wire.
| packet | message to send. |
| source | source address. |
| destination | destination address. |
|
inlinestaticprotected |
compute the checksum of a UDP datagram, RFC 768.
| frame | frame carrying the datagram, its checksum field must be zero. |
| payload | datagram payload. |
| size | payload size. |
|
protected |
receive buffer.
|
protected |
hardware address of the interface.
|
protected |
interface name.
|
protected |
DHCP message codec.
|
protected |
event loop reactor.
|
protected |
underlying socket.