mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
The macros in ip6_addr.c are duplicated from ip4_addr.c, so move them to lwIPs portability layer
...didn't see that in the first place...
This commit is contained in:
parent
93f4245e89
commit
849dfb17c7
@ -112,16 +112,6 @@ ip4_addr_netmask_valid(u32_t netmask)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Here for now until needed in other places in lwIP */
|
|
||||||
#ifndef isprint
|
|
||||||
#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up)
|
|
||||||
#define isprint(c) in_range(c, 0x20, 0x7f)
|
|
||||||
#define isdigit(c) in_range(c, '0', '9')
|
|
||||||
#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'))
|
|
||||||
#define islower(c) in_range(c, 'a', 'z')
|
|
||||||
#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ascii internet address interpretation routine.
|
* Ascii internet address interpretation routine.
|
||||||
* The value returned is in network order.
|
* The value returned is in network order.
|
||||||
@ -167,7 +157,7 @@ ip4addr_aton(const char *cp, ip4_addr_t *addr)
|
|||||||
* Values are specified as for C:
|
* Values are specified as for C:
|
||||||
* 0x=hex, 0=octal, 1-9=decimal.
|
* 0x=hex, 0=octal, 1-9=decimal.
|
||||||
*/
|
*/
|
||||||
if (!isdigit(c)) {
|
if (!lwip_isdigit(c)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
val = 0;
|
val = 0;
|
||||||
@ -182,11 +172,11 @@ ip4addr_aton(const char *cp, ip4_addr_t *addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (isdigit(c)) {
|
if (lwip_isdigit(c)) {
|
||||||
val = (val * base) + (u32_t)(c - '0');
|
val = (val * base) + (u32_t)(c - '0');
|
||||||
c = *++cp;
|
c = *++cp;
|
||||||
} else if (base == 16 && isxdigit(c)) {
|
} else if (base == 16 && lwip_isxdigit(c)) {
|
||||||
val = (val << 4) | (u32_t)(c + 10 - (islower(c) ? 'a' : 'A'));
|
val = (val << 4) | (u32_t)(c + 10 - (lwip_islower(c) ? 'a' : 'A'));
|
||||||
c = *++cp;
|
c = *++cp;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -211,7 +201,7 @@ ip4addr_aton(const char *cp, ip4_addr_t *addr)
|
|||||||
/*
|
/*
|
||||||
* Check for trailing characters.
|
* Check for trailing characters.
|
||||||
*/
|
*/
|
||||||
if (c != '\0' && !isspace(c)) {
|
if (c != '\0' && !lwip_isspace(c)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -50,13 +50,6 @@
|
|||||||
/* used by IP6_ADDR_ANY(6) in ip6_addr.h */
|
/* used by IP6_ADDR_ANY(6) in ip6_addr.h */
|
||||||
const ip_addr_t ip6_addr_any = IPADDR6_INIT(0ul, 0ul, 0ul, 0ul);
|
const ip_addr_t ip6_addr_any = IPADDR6_INIT(0ul, 0ul, 0ul, 0ul);
|
||||||
|
|
||||||
#define lwip_in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up)
|
|
||||||
#define lwip_isprint(c) lwip_in_range(c, 0x20, 0x7f)
|
|
||||||
#define lwip_isdigit(c) lwip_in_range(c, '0', '9')
|
|
||||||
#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_xchar(i) ((char)((i) < 10 ? '0' + (i) : 'A' + (i) - 10))
|
#define lwip_xchar(i) ((char)((i) < 10 ? '0' + (i) : 'A' + (i) - 10))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,6 +203,29 @@ typedef int ssize_t;
|
|||||||
#define SSIZE_MAX INT_MAX
|
#define SSIZE_MAX INT_MAX
|
||||||
#endif /* SSIZE_MAX */
|
#endif /* SSIZE_MAX */
|
||||||
|
|
||||||
|
/** Define this to 1 in arch/cc.h of your port if your compiler does not provide
|
||||||
|
* the cytype.h header. If ctype.h is available, a few few character functions
|
||||||
|
* are mapped to the appropriate functions (lwip_islower, lwip_isdigit...), if
|
||||||
|
* not, a private implementation is provided.
|
||||||
|
*/
|
||||||
|
#ifndef LWIP_NO_CTYPE_H
|
||||||
|
#define LWIP_NO_CTYPE_H 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_NO_CTYPE_H
|
||||||
|
#define lwip_in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up)
|
||||||
|
#define lwip_isdigit(c) lwip_in_range(c, '0', '9')
|
||||||
|
#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')
|
||||||
|
#else
|
||||||
|
#include <ctype.h>
|
||||||
|
#define lwip_isdigit(c) isdigit(c)
|
||||||
|
#define lwip_isxdigit(c) isxdigit(c)
|
||||||
|
#define lwip_islower(c) islower(c)
|
||||||
|
#define lwip_isspace(c) isspace(c)
|
||||||
|
#endif
|
||||||
|
|
||||||
/** C++ const_cast<target_type>(val) equivalent to remove constness from a value (GCC -Wcast-qual) */
|
/** C++ const_cast<target_type>(val) equivalent to remove constness from a value (GCC -Wcast-qual) */
|
||||||
#ifndef LWIP_CONST_CAST
|
#ifndef LWIP_CONST_CAST
|
||||||
#define LWIP_CONST_CAST(target_type, val) ((target_type)((ptrdiff_t)val))
|
#define LWIP_CONST_CAST(target_type, val) ((target_type)((ptrdiff_t)val))
|
||||||
|
Loading…
Reference in New Issue
Block a user