Skip to content

Commit

Permalink
add logs to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
abtink committed Sep 2, 2023
1 parent 3be09a6 commit 7b2e9f0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mdns/mdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,18 @@ otbrError Publisher::DecodeTxtData(Publisher::TxtList &aTxtList, const uint8_t *
{
otbrError error = OTBR_ERROR_NONE;

otbrLogWarning("ABTIN -> DecodeTxtData(aTxtLength %u)", aTxtLength);

for (uint16_t r = 0; r < aTxtLength;)
{
uint16_t entrySize = aTxtData[r];
uint16_t keyStart = r + 1;
uint16_t entryEnd = keyStart + entrySize;
uint16_t keyEnd = keyStart;

otbrLogWarning("ABTIN -> r = %u, entrySize=%u", r, entrySize);


VerifyOrExit(entryEnd <= aTxtLength, error = OTBR_ERROR_PARSE);

while (keyEnd < entryEnd && aTxtData[keyEnd] != '=')
Expand All @@ -144,20 +149,26 @@ otbrError Publisher::DecodeTxtData(Publisher::TxtList &aTxtList, const uint8_t *

if (keyEnd == entryEnd)
{
otbrLogWarning("ABTIN -> adding boolean attr", r, entrySize);

// No `=`, treat as a boolean attribute.
aTxtList.emplace_back(reinterpret_cast<const char *>(&aTxtData[keyStart]), keyEnd - keyStart);
}
else
{
uint16_t valStart = keyEnd + 1; // To skip over `=`

otbrLogWarning("ABTIN -> adding key value");

aTxtList.emplace_back(reinterpret_cast<const char *>(&aTxtData[keyStart]), keyEnd - keyStart,
&aTxtData[valStart], entryEnd - valStart);
}

r += entrySize + 1;
}

otbrLogWarning("ABTIN -> aTxtList.size() = %u", aTxtList.size());

exit:
return error;
}
Expand Down

0 comments on commit 7b2e9f0

Please sign in to comment.