MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Send

Method Send

pcsx2/DEV9/InternalServers/DNS_Server.cpp:124–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122 }
123
124 bool DNS_Server::Send(UDP_Packet* payload)
125 {
126 PayloadPtr* udpPayload = static_cast<PayloadPtr*>(payload->GetPayload());
127 DNS_Packet dns(udpPayload->data, udpPayload->GetLength());
128
129 if (dns.GetOpCode() == (u8)DNS_OPCode::Query && dns.questions.size() > 0 && dns.GetQR() == false)
130 {
131 std::vector<std::string> reqs;
132
133 for (size_t i = 0; i < dns.questions.size(); i++)
134 {
135 DNS_QuestionEntry q = dns.questions[i];
136 if (q.entryType == 1 && q.entryClass == 1)
137 reqs.push_back(q.name);
138 else
139 Console.Error("DEV9: Unexpected question type of class, T: %d C: %d", q.entryType, q.entryClass);
140 }
141 if (reqs.size() == 0)
142 return true;
143 if (dns.GetTC() == true)
144 {
145 Console.Error("DEV9: Truncated DNS packet Not Supported");
146 return true;
147 }
148
149 DNS_Packet* ret = new DNS_Packet();
150 ret->id = dns.id; //TODO, drop duplicate requests based on ID
151 ret->SetQR(true);
152 ret->SetOpCode(static_cast<u8>(DNS_OPCode::Query));
153 ret->SetAA(false);
154 ret->SetTC(false);
155 ret->SetRD(true);
156 ret->SetRA(true);
157 ret->SetAD(false);
158 ret->SetCD(false);
159 ret->SetRCode(static_cast<u8>(DNS_RCode::NoError));
160 //Counts
161 ret->questions = dns.questions;
162
163 DNS_State* state = new DNS_State(static_cast<int>(reqs.size()), reqs, ret, payload->sourcePort);
164 outstandingQueries++;
165
166 for (size_t i = 0; i < reqs.size(); i++)
167 {
168 if (CheckHostList(reqs[i], state))
169 continue;
170 GetHost(reqs[i], state);
171 }
172 return true;
173 }
174 else
175 {
176 Console.Error("DEV9: Unexpected DNS OPCode, Code: %s", dns.GetOpCode());
177 return true;
178 }
179 }
180
181 bool DNS_Server::CheckHostList(std::string url, DNS_State* state)

Callers 5

SendICMPMethod · 0.45
SendTCPMethod · 0.45
SendUDPMethod · 0.45
SendFromConnectionMethod · 0.45
InternalServerSendMethod · 0.45

Calls 15

GetOpCodeMethod · 0.80
GetQRMethod · 0.80
GetTCMethod · 0.80
SetQRMethod · 0.80
SetOpCodeMethod · 0.80
SetAAMethod · 0.80
SetTCMethod · 0.80
SetRDMethod · 0.80
SetRAMethod · 0.80
SetADMethod · 0.80
SetCDMethod · 0.80
SetRCodeMethod · 0.80

Tested by

no test coverage detected