MCPcopy Create free account
hub / github.com/defold/defold / BuildSrvRData

Function BuildSrvRData

engine/dlib/src/dlib/mdns.cpp:745–758  ·  view source on GitHub ↗

Builds canonical SRV rdata once so probes, responses, and tiebreak comparisons all operate on the same byte representation.

Source from the content-addressed store, hash-verified

743 // Builds canonical SRV rdata once so probes, responses, and tiebreak
744 // comparisons all operate on the same byte representation.
745 static bool BuildSrvRData(const RegisteredService& service, uint8_t* data, uint32_t data_size, uint16_t* data_length)
746 {
747 uint32_t data_offset = 0;
748 if (!WriteU16(data, data_size, &data_offset, 0) // priority
749 || !WriteU16(data, data_size, &data_offset, 0) // weight
750 || !WriteU16(data, data_size, &data_offset, service.m_Port)
751 || !WriteName(data, data_size, &data_offset, service.m_HostLocal))
752 {
753 return false;
754 }
755
756 *data_length = (uint16_t) data_offset;
757 return true;
758 }
759
760 // Encodes the TXT payload exactly as it will appear on the wire so probe
761 // authority claims and incoming tiebreak records can be compared bytewise.

Callers 1

BuildProbeRecordFunction · 0.85

Calls 2

WriteU16Function · 0.70
WriteNameFunction · 0.70

Tested by

no test coverage detected