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

Function BuildProbeMessage

engine/dlib/src/dlib/mdns.cpp:1120–1183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1118 }
1119
1120 static uint32_t BuildProbeMessage(const RegisteredService& service, uint8_t* buffer, uint32_t buffer_size)
1121 {
1122 uint32_t offset = 0;
1123 ProbeRecord service_records[2];
1124 ProbeRecord host_records[1];
1125 const uint32_t service_record_count = BuildServiceProbeRecordSet(service, service_records, DM_ARRAY_SIZE(service_records));
1126 const uint32_t host_record_count = BuildHostProbeRecordSet(service, host_records, DM_ARRAY_SIZE(host_records));
1127
1128 // RFC 6762 probing is done against the unique RRsets we intend to own.
1129 // For DNS-SD that means the SRV/TXT pair at the full service instance
1130 // name, not the shared PTR at the service type. Authority records carry
1131 // the tentative rdata so simultaneous probes can be tie-broken.
1132 const uint16_t question_count = host_record_count > 0 ? 2 : 1;
1133 const uint16_t authority_count = (uint16_t) (service_record_count + host_record_count);
1134 if (service_record_count != 2)
1135 return 0;
1136
1137 if (!WriteU16(buffer, buffer_size, &offset, 0)
1138 || !WriteU16(buffer, buffer_size, &offset, 0)
1139 || !WriteU16(buffer, buffer_size, &offset, question_count)
1140 || !WriteU16(buffer, buffer_size, &offset, 0)
1141 || !WriteU16(buffer, buffer_size, &offset, authority_count)
1142 || !WriteU16(buffer, buffer_size, &offset, 0)
1143 || !WriteName(buffer, buffer_size, &offset, service.m_FullServiceName)
1144 || !WriteU16(buffer, buffer_size, &offset, DNS_TYPE_ANY)
1145 || !WriteU16(buffer, buffer_size, &offset, DNS_CLASS_IN))
1146 {
1147 return 0;
1148 }
1149
1150 if (host_record_count > 0
1151 && (!WriteName(buffer, buffer_size, &offset, service.m_HostLocal)
1152 || !WriteU16(buffer, buffer_size, &offset, DNS_TYPE_ANY)
1153 || !WriteU16(buffer, buffer_size, &offset, DNS_CLASS_IN)))
1154 {
1155 return 0;
1156 }
1157
1158 for (uint32_t i = 0; i < service_record_count; ++i)
1159 {
1160 if (!WriteCanonicalRecord(buffer, buffer_size, &offset,
1161 service.m_FullServiceName,
1162 service_records[i].m_Type,
1163 service_records[i].m_Class,
1164 service.m_Ttl,
1165 service_records[i].m_RData,
1166 service_records[i].m_RDataLength))
1167 return 0;
1168 }
1169
1170 for (uint32_t i = 0; i < host_record_count; ++i)
1171 {
1172 if (!WriteCanonicalRecord(buffer, buffer_size, &offset,
1173 service.m_HostLocal,
1174 host_records[i].m_Type,
1175 host_records[i].m_Class,
1176 service.m_Ttl,
1177 host_records[i].m_RData,

Callers 1

SendProbeFunction · 0.85

Calls 5

BuildHostProbeRecordSetFunction · 0.85
WriteCanonicalRecordFunction · 0.85
WriteU16Function · 0.70
WriteNameFunction · 0.70

Tested by

no test coverage detected