Skip to content

Commit

Permalink
Pass all the LLRPProbeRequest info across in the callback and act on …
Browse files Browse the repository at this point in the history
…more of it
  • Loading branch information
peternewman committed Feb 9, 2020
1 parent dc06b8a commit f2343ce
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
12 changes: 6 additions & 6 deletions libs/acn/LLRPProbeRequestInflator.cpp
Expand Up @@ -101,15 +101,15 @@ bool LLRPProbeRequestInflator::HandlePDUData(uint32_t vector,

OLA_DEBUG << "Probe from " << UID(pdu_data.lower_uid) << " to " << UID(pdu_data.upper_uid);

// string rdm_message(reinterpret_cast<const char*>(&data[0]), pdu_len);
LLRPProbeRequest request(UID(pdu_data.lower_uid), UID(pdu_data.upper_uid));
request.client_tcp_connection_inactive = (pdu_data.filter & LLRPProbeRequestPDU::FILTER_CLIENT_TCP_CONNECTION_INACTIVE);
request.brokers_only = (pdu_data.filter & LLRPProbeRequestPDU::FILTER_BROKERS_ONLY);
unsigned int known_uids_used_size = known_uids_size;
request.known_uids = UIDSet(pdu_data.known_uids, &known_uids_used_size);

if (m_llrp_probe_request_handler.get()) {
m_llrp_probe_request_handler->Run(&headers,
UID(pdu_data.lower_uid),
UID(pdu_data.upper_uid)
//,
// UIDSet()
);
request);
} else {
OLA_WARN << "No LLRP Probe Request handler defined!";
}
Expand Down
20 changes: 15 additions & 5 deletions libs/acn/LLRPProbeRequestInflator.h
Expand Up @@ -34,13 +34,23 @@ class LLRPProbeRequestInflator: public BaseInflator {
friend class LLRPProbeRequestInflatorTest;

public:
struct LLRPProbeRequest {
LLRPProbeRequest(const ola::rdm::UID &_lower, const ola::rdm::UID &_upper)
: lower(_lower),
upper(_upper) {
}
ola::rdm::UID lower;
ola::rdm::UID upper;
bool client_tcp_connection_inactive;
bool brokers_only;
ola::rdm::UIDSet known_uids;
};


// These are pointers so the callers don't have to pull in all the headers.
typedef ola::Callback3<void,
typedef ola::Callback2<void,
const HeaderSet*, // the HeaderSet
const ola::rdm::UID&, // lower UID
const ola::rdm::UID& // upper UID
//,
// const ola::rdm::UIDSet, // known UIDs
const LLRPProbeRequest& // Probe Request Data
> LLRPProbeRequestHandler;

LLRPProbeRequestInflator();
Expand Down
24 changes: 21 additions & 3 deletions tools/e133/llrp-receive-test.cpp
Expand Up @@ -60,6 +60,7 @@ using ola::acn::CID;
using ola::acn::IncomingUDPTransport;
using ola::acn::LLRPHeader;
using ola::acn::LLRPProbeReplyPDU;
using ola::acn::LLRPProbeRequestInflator;
using ola::acn::OutgoingUDPTransport;
using ola::acn::OutgoingUDPTransportImpl;
using ola::network::Interface;
Expand Down Expand Up @@ -121,9 +122,23 @@ Interface FindLowestMAC() {

void HandleLLRPProbeRequest(
const ola::acn::HeaderSet *headers,
const ola::rdm::UID &lower_uid,
const ola::rdm::UID &upper_uid) {
OLA_DEBUG << "Handling probe from " << lower_uid << " to " << upper_uid;
const LLRPProbeRequestInflator::LLRPProbeRequest &request) {
OLA_DEBUG << "Potentially handling probe from " << request.lower << " to "
<< request.upper;

if ((*target_uid < request.lower) || (*target_uid > request.upper)) {
OLA_INFO << "Ignoring probe request as we are not in the target UID range";
return;
}

OLA_DEBUG << "Known UIDs are: " << request.known_uids;

if (request.known_uids.Contains(*target_uid)) {
OLA_INFO << "Ignoring probe request as we are already in the known UID list";
return;
}

// TODO(Peter): Check the filter bits!

const ola::acn::RootHeader root_header = headers->GetRootHeader();
const ola::acn::LLRPHeader llrp_header = headers->GetLLRPHeader();
Expand All @@ -147,6 +162,9 @@ void HandleLLRPProbeRequest(
LLRPProbeReplyPDU::LLRP_COMPONENT_TYPE_NON_RDMNET);

ola::acn::LLRPPDU pdu(ola::acn::VECTOR_LLRP_PROBE_REPLY, reply_llrp_header, &probe_reply);

// TODO(Peter): Delay sending by 0 to LLRP_MAX_BACKOFF!

m_root_sender.SendPDU(ola::acn::VECTOR_ROOT_LLRP, pdu, &transport);
OLA_DEBUG << "Sent PDU";
}
Expand Down

0 comments on commit f2343ce

Please sign in to comment.