From a9d6ea59535b3ccabcc728c042d5d4cdb16ea876 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Wed, 13 Jun 2018 15:08:11 +0200 Subject: [PATCH] introduce 'lwip_tolower' and use it in dns.c Signed-off-by: Simon Goldschmidt --- src/core/dns.c | 3 +-- src/include/lwip/arch.h | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/dns.c b/src/core/dns.c index 11df6922..866319a9 100644 --- a/src/core/dns.c +++ b/src/core/dns.c @@ -96,7 +96,6 @@ #include "lwip/prot/dns.h" #include -#include /** Random generator function to create random TXIDs and source ports for queries */ #ifndef DNS_RAND_TXID @@ -667,7 +666,7 @@ dns_compare_name(const char *query, struct pbuf *p, u16_t start_offset) if (c < 0) { return 0xFFFF; } - if (tolower((*query)) != tolower((u8_t)c)) { + if (lwip_tolower((*query)) != lwip_tolower((u8_t)c)) { return 0xFFFF; } if (response_offset == 0xFFFF) { diff --git a/src/include/lwip/arch.h b/src/include/lwip/arch.h index 069060ff..b4181610 100644 --- a/src/include/lwip/arch.h +++ b/src/include/lwip/arch.h @@ -221,12 +221,15 @@ typedef int ssize_t; #define lwip_isxdigit(c) (lwip_isdigit(c) || lwip_in_range((c), 'a', 'f') || lwip_in_range((c), 'A', 'F')) #define lwip_islower(c) lwip_in_range((c), 'a', 'z') #define lwip_isspace(c) ((c) == ' ' || (c) == '\f' || (c) == '\n' || (c) == '\r' || (c) == '\t' || (c) == '\v') +#define lwip_isupper(c) lwip_in_range((c), 'A', 'Z') +#define lwip_tolower(c) (lwip_isupper(c) ? (c) - 'A' + 'a' : c) #else #include #define lwip_isdigit(c) isdigit((unsigned char)(c)) #define lwip_isxdigit(c) isxdigit((unsigned char)(c)) #define lwip_islower(c) islower((unsigned char)(c)) #define lwip_isspace(c) isspace((unsigned char)(c)) +#define lwip_tolower(c) tolower(c) #endif /** C++ const_cast(val) equivalent to remove constness from a value (GCC -Wcast-qual) */