MCPcopy Create free account
hub / github.com/SmingHub/Sming / onReceive

Method onReceive

Sming/Components/Network/src/Network/DnsServer.cpp:76–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void DnsServer::onReceive(pbuf* buf, IpAddress remoteIP, uint16_t remotePort)
77{
78 debug_d("DNS REQ from %s:%d", remoteIP.toString().c_str(), remotePort);
79
80 // Allocated buffer with additional room for answer
81 char* buffer = new char[buf->tot_len + MAX_ANSWER_LENGTH];
82 if(buffer == nullptr) {
83 return;
84 }
85
86 unsigned requestLen = pbuf_copy_partial(buf, buffer, buf->tot_len, 0);
87
88 debug_hex(DBG, "< DNS", buffer, requestLen);
89
90 auto responseLen = processQuestion(buffer, requestLen);
91 if(responseLen != 0) {
92 debug_hex(DBG, "> DNS", buffer, responseLen);
93 sendTo(remoteIP, remotePort, buffer, responseLen);
94 }
95
96 delete[] buffer;
97}
98
99size_t DnsServer::processQuestion(char* buffer, size_t requestLen)
100{

Callers

nothing calls this directly

Calls 2

c_strMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected