void __fastcall UDPRequestProcess(const char *OriginalSend, const size_t SendSize, const SOCKET_DATA &LocalSocketData, const uint16_t Protocol) { //Multi requesting. if (Parameter.AlternateMultiRequest || Parameter.MultiRequestTimes > 1U) UDPRequestMulti(OriginalSend, SendSize, &LocalSocketData, Protocol); //Normal requesting else UDPRequest(OriginalSend, SendSize, &LocalSocketData, Protocol); //Fin TCP request connection. if (Protocol == IPPROTO_TCP && LocalSocketData.Socket != INVALID_SOCKET) { shutdown(LocalSocketData.Socket, SD_BOTH); closesocket(LocalSocketData.Socket); } return; }
void __fastcall UDPRequestProcess( const DNS_PACKET_DATA &Packet, const SOCKET_DATA &LocalSocketData) { //EDNS switching(Part 1) size_t EDNS_SwitchLength = Packet.Length; uint16_t EDNS_Packet_Flags = ((dns_hdr *)(Packet.Buffer))->Flags; if (Parameter.EDNS_Label && !Parameter.EDNS_Switch.EDNS_UDP) { //Reset EDNS flags, resource record counts and packet length. ((dns_hdr *)(Packet.Buffer))->Flags = htons(ntohs(((dns_hdr *)(Packet.Buffer))->Flags) & (~DNS_GET_BIT_AD)); ((dns_hdr *)(Packet.Buffer))->Flags = htons(ntohs(((dns_hdr *)(Packet.Buffer))->Flags) & (~DNS_GET_BIT_CD)); if (((dns_hdr *)(Packet.Buffer))->Additional > 0) ((dns_hdr *)(Packet.Buffer))->Additional = htons(ntohs(((dns_hdr *)(Packet.Buffer))->Additional) - 1U); EDNS_SwitchLength -= Packet.EDNS_Record; } //Multi request process if (Parameter.AlternateMultiRequest || Parameter.MultiRequestTimes > 1U) UDPRequestMulti(Packet.Buffer, EDNS_SwitchLength, &LocalSocketData, Packet.Protocol); //Normal request process else UDPRequest(Packet.Buffer, EDNS_SwitchLength, &LocalSocketData, Packet.Protocol); //Fin TCP request connection. if (Packet.Protocol == IPPROTO_TCP && SocketSetting(LocalSocketData.Socket, SOCKET_SETTING_INVALID_CHECK, false, nullptr)) { shutdown(LocalSocketData.Socket, SD_BOTH); closesocket(LocalSocketData.Socket); } //EDNS switching(Part 2) if (Parameter.EDNS_Label && !Parameter.EDNS_Switch.EDNS_UDP) { ((dns_hdr *)(Packet.Buffer))->Flags = EDNS_Packet_Flags; ((dns_hdr *)(Packet.Buffer))->Additional = htons(ntohs(((dns_hdr *)(Packet.Buffer))->Additional) + 1U); } return; }