Skip to content

Commit

Permalink
Add the ability to inflate an LLRP Probe Reply and build a Probe Request
Browse files Browse the repository at this point in the history
(cherry picked from commit 8db5131)
  • Loading branch information
peternewman committed Apr 21, 2024
1 parent 781cdf6 commit b151281
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions libs/acn/LLRPProbeRequestPDU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,56 @@ void LLRPProbeRequestPDU::PackData(ola::io::OutputStream *stream) const {
(m_known_uids.Size() * UID::LENGTH)));
}

unsigned int LLRPProbeRequestPDU::DataSize() const {
llrp_probe_request_pdu_data data;
return static_cast<unsigned int>(sizeof(llrp_probe_request_pdu_data) -
sizeof(data.known_uids) +
(m_known_uids.Size() * UID::LENGTH));

Check failure on line 89 in libs/acn/LLRPProbeRequestPDU.cpp

View workflow job for this annotation

GitHub Actions / cpplint

Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]
}

bool LLRPProbeRequestPDU::PackData(uint8_t *data, unsigned int *length) const {
llrp_probe_request_pdu_data pdu_data;
m_lower_uid.Pack(pdu_data.lower_uid, sizeof(pdu_data.lower_uid));
m_upper_uid.Pack(pdu_data.upper_uid, sizeof(pdu_data.upper_uid));
uint16_t filter = 0;
if (m_client_tcp_connection_inactive) {
filter |= FILTER_CLIENT_TCP_CONNECTION_INACTIVE;
}
if (m_brokers_only) {
filter |= FILTER_BROKERS_ONLY;
}
pdu_data.filter = HostToNetwork(filter);
// TODO(Peter): We need to check we've got <= 200 UIDs here
m_known_uids.Pack(pdu_data.known_uids, sizeof(pdu_data.known_uids));
*length = static_cast<unsigned int>(sizeof(llrp_probe_request_pdu_data) -
sizeof(pdu_data.known_uids) +
(m_known_uids.Size() * UID::LENGTH));

memcpy(data, &pdu_data, *length);
return true;
}

void LLRPProbeRequestPDU::PackData(ola::io::OutputStream *stream) const {
llrp_probe_request_pdu_data data;
m_lower_uid.Pack(data.lower_uid, sizeof(data.lower_uid));
m_upper_uid.Pack(data.upper_uid, sizeof(data.upper_uid));
uint16_t filter = 0;
if (m_client_tcp_connection_inactive) {
filter |= FILTER_CLIENT_TCP_CONNECTION_INACTIVE;
}
if (m_brokers_only) {
filter |= FILTER_BROKERS_ONLY;
}
data.filter = HostToNetwork(filter);
// TODO(Peter): We need to check we've got <= 200 UIDs here
m_known_uids.Pack(data.known_uids, sizeof(data.known_uids));
stream->Write(reinterpret_cast<uint8_t*>(&data),
static_cast<unsigned int>(sizeof(llrp_probe_request_pdu_data) -
sizeof(data.known_uids) +
(m_known_uids.Size() * UID::LENGTH)));
}

void LLRPProbeRequestPDU::PrependPDU(ola::io::IOStack *stack,
const UID &lower_uid,
const UID &upper_uid,
Expand Down

0 comments on commit b151281

Please sign in to comment.