From 5a4f5f96140ef0dc280dfd3be2a0853c3850f1c8 Mon Sep 17 00:00:00 2001 From: luigi__ Date: Tue, 20 Apr 2010 17:21:31 +0000 Subject: [PATCH] Wifi: fix potential endian issues on bigendian in the DNS parsing code. --- desmume/src/wifi.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index dc8a5f6f6..50d8e7226 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -2005,11 +2005,11 @@ void SoftAP_Reset() static bool SoftAP_IsDNSRequestToWFC(u16 ethertype, u8* body) { // Check the various headers... - if (htons(ethertype) != 0x0800) return false; // EtherType: IP + if (ntohs(ethertype) != 0x0800) return false; // EtherType: IP if (body[0] != 0x45) return false; // Version: 4, header len: 5 if (body[9] != 0x11) return false; // Protocol: UDP - if (htons(*(u16*)&body[22]) != 53) return false; // Dest. port: 53 (DNS) - if ((*(u16*)&body[28+2]) & 0x8000) return false; // must be a query + if (ntohs(*(u16*)&body[22]) != 53) return false; // Dest. port: 53 (DNS) + if (htons(ntohs(*(u16*)&body[28+2])) & 0x8000) return false; // must be a query // Analyze each question u16 numquestions = htons(*(u16*)&body[28+4]);