|
join 1.0
lightweight network framework library
|
carries NDP messages over an ICMPv6 socket. More...
#include <ndp.hpp>


Classes | |
| struct | NeighborRequest |
| neighbor solicitation waiting for the advertisement of its target. More... | |
Public Types | |
| using | Socket = typename Protocol::Socket |
| using | Endpoint = typename Protocol::Endpoint |
| using | NeighborSolicitationNotify = Function<void (const NeighborSolicitation& solicitation)> |
| neighbor solicitation notification callback. | |
| using | NeighborAdvertisementNotify = Function<void (const NeighborAdvertisement& advert)> |
| neighbor advertisement notification callback. | |
Public Member Functions | |
| BasicNdp ()=delete | |
| create the BasicNdp instance. | |
| BasicNdp (const std::string &interface, uint8_t filter, const IpAddress &group, Reactor &reactor) | |
| create the instance bound to the given interface. | |
| BasicNdp (const BasicNdp &other)=delete | |
| create instance by copy. | |
| BasicNdp & | operator= (const BasicNdp &other)=delete |
| assign instance by copy. | |
| BasicNdp (BasicNdp &&other)=delete | |
| create instance by move. | |
| BasicNdp & | operator= (BasicNdp &&other)=delete |
| assign instance by move. | |
| virtual | ~BasicNdp ()=default |
| destroy the instance. | |
| int | neighborSolicit (const IpAddress &target, NeighborAdvertisement &advert, std::chrono::milliseconds timeout=std::chrono::seconds(1)) noexcept |
| send a neighbor solicitation and wait for the advertisement of the target. | |
| int | neighborAdvertise (const NeighborAdvertisement &advert, const IpAddress &destination=IpAddress::ipv6AllNodes) noexcept |
| send a neighbor advertisement, the interface hardware address is used if it carries none. | |
| int | neighborAdvertise (const NeighborAdvertisement &advert, const NeighborSolicitation &solicitation) noexcept |
| answer a neighbor solicitation, to the solicitor or to all the nodes of the link if it has no address. | |
| int | setNeighborSolicitationListener (NeighborSolicitationNotify cb) noexcept |
| set the callback called on every neighbor solicitation received. | |
| int | unsetNeighborSolicitationListener () noexcept |
| unset the neighbor solicitation callback, it is no longer called once this returns. | |
| int | setNeighborAdvertisementListener (NeighborAdvertisementNotify cb) noexcept |
| set the callback called on every neighbor advertisement received, solicited or not. | |
| int | unsetNeighborAdvertisementListener () noexcept |
| unset the neighbor advertisement callback, it is no longer called once this returns. | |
| const std::string & | interface () const noexcept |
| get the name of the interface the instance is bound to. | |
| unsigned int | index () const noexcept |
| get the index 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 | |
| void | attach () |
| register with the reactor, to be called by the final class once fully constructed. | |
| void | detach () noexcept |
| unregister from the reactor, to be called by the final class before destruction starts. | |
| int | applyFilter (uint8_t type, bool pass) noexcept |
| pass or block a message type in the ICMPv6 filter. | |
| int | send (const char *data, size_t size, const IpAddress &destination) |
| write a message on the interface. | |
| ssize_t | receive (char *data, size_t maxSize, IpAddress &from) |
| read a message that passed the checks common to every NDP message. | |
| bool | onNeighborMessage (size_t size, const IpAddress &from) noexcept |
| hand a received neighbor message to its listener, and an advertisement to the solicitations waiting for it. | |
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 | onReadable (int fd) |
| method called when data are ready to be read 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 unsigned int | lookup (const std::string &interface) |
| get the index of the given interface. | |
Protected Attributes | |
| Socket | _socket |
| underlying socket. | |
| NdpMessage | _message |
| NDP message codec. | |
| std::unique_ptr< char[]> | _buffer |
| receive buffer. | |
| const std::string | _interface |
| interface name. | |
| const unsigned int | _index |
| interface index. | |
| const MacAddress | _hardware |
| hardware address of the interface. | |
| Reactor & | _reactor |
| event loop reactor. | |
| struct icmp6_filter | _filter |
| ICMPv6 filter applied to the socket, only accessed from the reactor thread once constructed. | |
| std::vector< NeighborRequest * > | _neighborPending |
| neighbor solicitations waiting for an advertisement, only accessed from the reactor thread. | |
| Mutex | _neighborMutex |
| neighbor solicitations protection mutex. | |
| NeighborSolicitationNotify | _neighborSolicitationListener |
| neighbor solicitation listener, only accessed from the reactor thread. | |
| bool | _neighborSolicitationCalling = false |
| NeighborAdvertisementNotify | _neighborAdvertisementListener |
| neighbor advertisement listener, only accessed from the reactor thread. | |
| bool | _neighborAdvertisementCalling = false |
carries NDP messages over an ICMPv6 socket.
| using join::BasicNdp< Protocol >::Endpoint = typename Protocol::Endpoint |
| using join::BasicNdp< Protocol >::NeighborAdvertisementNotify = Function<void (const NeighborAdvertisement& advert)> |
neighbor advertisement notification callback.
| using join::BasicNdp< Protocol >::NeighborSolicitationNotify = Function<void (const NeighborSolicitation& solicitation)> |
neighbor solicitation notification callback.
| using join::BasicNdp< Protocol >::Socket = typename Protocol::Socket |
|
delete |
create the BasicNdp instance.
|
inline |
create the instance bound to the given interface.
| interface | interface name. |
| filter | message type the instance accepts. |
| group | multicast group the instance joins, wildcard to join none. |
| reactor | reactor instance. |
| std::system_error | if the interface is unknown or the socket could not be set up. |
|
delete |
create instance by copy.
| other | other object to copy. |
|
delete |
create instance by move.
| other | other object to move. |
|
virtualdefault |
destroy the instance.
|
inlineprotectednoexcept |
pass or block a message type in the ICMPv6 filter.
| type | message type. |
| pass | true to pass the message type, false to block it. |
|
inlineprotected |
register with the reactor, to be called by the final class once fully constructed.
| std::system_error | if the registration failed. |
|
inlineprotectednoexcept |
unregister from the reactor, to be called by the final class before destruction starts.
|
inlinenoexcept |
get the hardware address of the interface the instance is bound to.
|
inlinenoexcept |
get the index of the interface the instance is bound to.
|
inlinenoexcept |
get the name of the interface the instance is bound to.
|
inlinestaticprotected |
get the index of the given interface.
| interface | interface name. |
| std::system_error | if the interface is unknown. |
|
inlinenoexcept |
send a neighbor advertisement, the interface hardware address is used if it carries none.
| advert | advertisement to send. |
| destination | destination address, all the nodes of the link by default. |
|
inlinenoexcept |
answer a neighbor solicitation, to the solicitor or to all the nodes of the link if it has no address.
| advert | advertisement to send, the interface hardware address is used if it carries none. |
| solicitation | solicitation to answer. |
|
inlinenoexcept |
send a neighbor solicitation and wait for the advertisement of the target.
| target | address of the neighbor to resolve. |
| advert | receives the advertisement. |
| timeout | maximum wait duration. |
|
inlineprotectednoexcept |
hand a received neighbor message to its listener, and an advertisement to the solicitations waiting for it.
| size | message size. |
| from | address the message came from. |
|
delete |
assign instance by move.
| other | other object to move. |
|
delete |
assign instance by copy.
| other | other object to copy. |
|
inlineprotected |
read a message that passed the checks common to every NDP message.
| data | buffer used to store the message. |
| maxSize | maximum number of bytes to read. |
| from | address the message came from. |
|
inlineprotected |
write a message on the interface.
| data | message to write. |
| size | message size. |
| destination | destination address. |
|
inlinenoexcept |
set the callback called on every neighbor advertisement received, solicited or not.
| cb | callback, called from the reactor thread, must not throw nor destroy the instance. |
|
inlinenoexcept |
set the callback called on every neighbor solicitation received.
| cb | callback, called from the reactor thread, must not throw nor destroy the instance. |
|
inlinenoexcept |
unset the neighbor advertisement callback, it is no longer called once this returns.
|
inlinenoexcept |
unset the neighbor solicitation callback, it is no longer called once this returns.
|
protected |
receive buffer.
|
protected |
ICMPv6 filter applied to the socket, only accessed from the reactor thread once constructed.
|
protected |
hardware address of the interface.
|
protected |
interface index.
|
protected |
interface name.
|
protected |
NDP message codec.
|
protected |
set while the neighbor advertisement listener is being called and still set, only accessed from the reactor thread.
|
protected |
neighbor advertisement listener, only accessed from the reactor thread.
|
protected |
neighbor solicitations protection mutex.
|
protected |
neighbor solicitations waiting for an advertisement, only accessed from the reactor thread.
|
protected |
set while the neighbor solicitation listener is being called and still set, only accessed from the reactor thread.
|
protected |
neighbor solicitation listener, only accessed from the reactor thread.
|
protected |
event loop reactor.
|
protected |
underlying socket.