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

Function HandleIncomingResponseRecords

engine/dlib/src/dlib/mdns.cpp:1403–1461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1401 }
1402
1403 static void HandleIncomingResponseRecords(MDNS* mdns, const uint8_t* data, uint32_t size, uint32_t* offset, uint32_t record_count)
1404 {
1405 for (uint32_t i = 0; i < record_count && *offset < size; ++i)
1406 {
1407 char name[256];
1408 uint16_t type = 0;
1409 uint16_t klass = 0;
1410 uint32_t ttl = 0;
1411 uint16_t rdlength = 0;
1412 if (!ReadName(data, size, offset, name, sizeof(name))
1413 || !ReadU16(data, size, offset, &type)
1414 || !ReadU16(data, size, offset, &klass)
1415 || !ReadU32(data, size, offset, &ttl)
1416 || !ReadU16(data, size, offset, &rdlength))
1417 {
1418 *offset = size;
1419 return;
1420 }
1421
1422 if (*offset + rdlength > size)
1423 {
1424 *offset = size;
1425 return;
1426 }
1427
1428 const uint32_t rdata_offset = *offset;
1429 *offset += rdlength;
1430
1431 if (ttl == 0 || (klass & ~DNS_CLASS_FLUSH) != DNS_CLASS_IN)
1432 continue;
1433
1434 for (uint32_t service_index = 0; service_index < mdns->m_Services.Size(); ++service_index)
1435 {
1436 RegisteredService& service = mdns->m_Services[service_index];
1437 if (service.m_State != SERVICE_STATE_PROBING)
1438 continue;
1439
1440 if (NameEquals(name, service.m_FullServiceName)
1441 || (service.m_ProbeHost && NameEquals(name, service.m_HostLocal)))
1442 {
1443 ProbeRecord expected;
1444 ProbeRecord actual;
1445 if (!BuildProbeRecord(service, name, type, &expected))
1446 {
1447 MarkServiceConflict(&service);
1448 continue;
1449 }
1450
1451 if (!DecodeIncomingProbeRecord(data, size, type, klass, rdata_offset, rdlength, &actual))
1452 continue;
1453
1454 if (CompareProbeRecord(actual, expected) != 0)
1455 {
1456 MarkServiceConflict(&service);
1457 }
1458 }
1459 }
1460 }

Callers 1

HandleIncomingQueriesFunction · 0.85

Calls 9

NameEqualsFunction · 0.85
BuildProbeRecordFunction · 0.85
MarkServiceConflictFunction · 0.85
CompareProbeRecordFunction · 0.85
ReadNameFunction · 0.70
ReadU16Function · 0.70
ReadU32Function · 0.70
SizeMethod · 0.45

Tested by

no test coverage detected