IPDiscovery is the main thread in IP-based neighbor discovery, configured via config file or command console to listen to a specified UDP port for unicast, broadcast, or multicast beacons from advertising neighbors. More...
#include <IPDiscovery.h>
Classes | |
struct | DiscoveryHeader |
On-the-wire (radio, whatever) representation of IP address family's advertisement beacon. More... | |
Public Types | |
enum | cl_type_t { UNDEFINED = 0, TCPCL = 1, UDPCL = 2 } |
Enumerate which type of CL is advertised. More... | |
Public Member Functions | |
void | shutdown () |
Close main socket, causing thread to exit. | |
virtual | ~IPDiscovery () |
Static Public Member Functions | |
static const char * | type_to_str (cl_type_t t) |
static cl_type_t | str_to_type (const char *cltype) |
Public Attributes | |
struct dtn::IPDiscovery::DiscoveryHeader | packed |
On-the-wire (radio, whatever) representation of IP address family's advertisement beacon. | |
Static Public Attributes | |
static const u_int32_t | DEFAULT_DST_ADDR = 0xffffffff |
If no other options are set for destination, default to sending to the IPv4 broadcast address. | |
static const u_int32_t | DEFAULT_SRC_ADDR = INADDR_ANY |
If no other options are set for source, use this as default local address. | |
static const u_int | DEFAULT_MCAST_TTL = 1 |
If no other options are set for multicast TTL, set to 1. | |
Protected Member Functions | |
IPDiscovery (const std::string &name) | |
bool | configure (int argc, const char *argv[]) |
Set internal state using parameter list; return true on success, else false. | |
void | run () |
virtual from oasys::Thread | |
bool | parse_advertisement (u_char *buf, size_t len, in_addr_t remote_addr, u_int8_t &cl_type, std::string &nexthop, EndpointID &remote_eid) |
Convenience method to pull the relevant items out of the inbound packet. | |
void | handle_announce () |
Virtual from Discovery. | |
Protected Attributes | |
volatile bool | shutdown_ |
signal to close down thread | |
in_addr_t | local_addr_ |
address for bind() to receive beacons | |
u_int16_t | port_ |
local and remote | |
in_addr_t | remote_addr_ |
whether unicast, multicast, or broadcast | |
u_int | mcast_ttl_ |
TTL hop count for multicast option. | |
oasys::UDPClient | socket_ |
the socket for beacons in- and out-bound | |
bool | persist_ |
whether to exit thread on send/recv failures | |
Friends | |
class | Discovery |
IPDiscovery is the main thread in IP-based neighbor discovery, configured via config file or command console to listen to a specified UDP port for unicast, broadcast, or multicast beacons from advertising neighbors.
Definition at line 35 of file IPDiscovery.h.
Enumerate which type of CL is advertised.
Definition at line 76 of file IPDiscovery.h.
virtual dtn::IPDiscovery::~IPDiscovery | ( | ) | [inline, virtual] |
Definition at line 112 of file IPDiscovery.h.
dtn::IPDiscovery::IPDiscovery | ( | const std::string & | name | ) | [protected] |
Definition at line 37 of file IPDiscovery.cc.
References DEFAULT_DST_ADDR, DEFAULT_MCAST_TTL, DEFAULT_SRC_ADDR, local_addr_, mcast_ttl_, persist_, port_, remote_addr_, and shutdown_.
bool dtn::IPDiscovery::configure | ( | int | argc, | |
const char * | argv[] | |||
) | [protected, virtual] |
Set internal state using parameter list; return true on success, else false.
Implements dtn::Discovery.
Definition at line 51 of file IPDiscovery.cc.
References buf, dtn::Discovery::local_, local_addr_, mcast_ttl_, persist_, port_, remote_addr_, socket_, and dtn::Discovery::to_addr_.
void dtn::IPDiscovery::handle_announce | ( | ) | [inline, protected, virtual] |
Virtual from Discovery.
Reimplemented from dtn::Discovery.
Definition at line 143 of file IPDiscovery.h.
References socket_.
bool dtn::IPDiscovery::parse_advertisement | ( | u_char * | buf, | |
size_t | len, | |||
in_addr_t | remote_addr, | |||
u_int8_t & | cl_type, | |||
std::string & | nexthop, | |||
EndpointID & | remote_eid | |||
) | [protected] |
Convenience method to pull the relevant items out of the inbound packet.
Definition at line 278 of file IPDiscovery.cc.
References dtn::EndpointID::assign(), buf, dtn::IPDiscovery::DiscoveryHeader::cl_type, dtn::IPDiscovery::DiscoveryHeader::inet_addr, dtn::IPDiscovery::DiscoveryHeader::inet_port, dtn::IPDiscovery::DiscoveryHeader::length, dtn::IPDiscovery::DiscoveryHeader::name_len, and dtn::IPDiscovery::DiscoveryHeader::sender_name.
Referenced by run().
void dtn::IPDiscovery::run | ( | ) | [protected] |
virtual from oasys::Thread
Definition at line 122 of file IPDiscovery.cc.
References dtn::Discovery::announce(), buf, dtn::IPAnnounce::cl_addr(), dtn::EndpointID::equals(), errno, dtn::IPAnnounce::format_advertisement(), dtn::Discovery::handle_neighbor_discovered(), dtn::Announce::interval(), dtn::Announce::interval_remaining(), len, dtn::Discovery::list_, local_addr_, parse_advertisement(), persist_, port_, remote_addr_, shutdown_, socket_, and type_to_str().
void dtn::IPDiscovery::shutdown | ( | ) | [inline, virtual] |
Close main socket, causing thread to exit.
Implements dtn::Discovery.
Definition at line 110 of file IPDiscovery.h.
static cl_type_t dtn::IPDiscovery::str_to_type | ( | const char * | cltype | ) | [inline, static] |
Definition at line 95 of file IPDiscovery.h.
Referenced by dtn::IPAnnounce::format_advertisement().
static const char* dtn::IPDiscovery::type_to_str | ( | cl_type_t | t | ) | [inline, static] |
friend class Discovery [friend] |
Definition at line 115 of file IPDiscovery.h.
const u_int32_t dtn::IPDiscovery::DEFAULT_DST_ADDR = 0xffffffff [static] |
If no other options are set for destination, default to sending to the IPv4 broadcast address.
Definition at line 44 of file IPDiscovery.h.
Referenced by IPDiscovery().
const u_int dtn::IPDiscovery::DEFAULT_MCAST_TTL = 1 [static] |
If no other options are set for multicast TTL, set to 1.
Definition at line 55 of file IPDiscovery.h.
Referenced by IPDiscovery().
const u_int32_t dtn::IPDiscovery::DEFAULT_SRC_ADDR = INADDR_ANY [static] |
If no other options are set for source, use this as default local address.
Definition at line 50 of file IPDiscovery.h.
Referenced by IPDiscovery().
in_addr_t dtn::IPDiscovery::local_addr_ [protected] |
address for bind() to receive beacons
Definition at line 149 of file IPDiscovery.h.
Referenced by configure(), IPDiscovery(), and run().
u_int dtn::IPDiscovery::mcast_ttl_ [protected] |
TTL hop count for multicast option.
Definition at line 152 of file IPDiscovery.h.
Referenced by configure(), and IPDiscovery().
On-the-wire (radio, whatever) representation of IP address family's advertisement beacon.
bool dtn::IPDiscovery::persist_ [protected] |
whether to exit thread on send/recv failures
Definition at line 154 of file IPDiscovery.h.
Referenced by configure(), IPDiscovery(), and run().
u_int16_t dtn::IPDiscovery::port_ [protected] |
local and remote
Definition at line 150 of file IPDiscovery.h.
Referenced by configure(), IPDiscovery(), and run().
in_addr_t dtn::IPDiscovery::remote_addr_ [protected] |
whether unicast, multicast, or broadcast
Definition at line 151 of file IPDiscovery.h.
Referenced by configure(), IPDiscovery(), and run().
volatile bool dtn::IPDiscovery::shutdown_ [protected] |
signal to close down thread
Definition at line 148 of file IPDiscovery.h.
Referenced by IPDiscovery(), run(), and shutdown().
oasys::UDPClient dtn::IPDiscovery::socket_ [protected] |
the socket for beacons in- and out-bound
Definition at line 153 of file IPDiscovery.h.
Referenced by configure(), handle_announce(), run(), and shutdown().