extmod/modnetwork: Increase max hostname length to 32.

This changes from the previous limit of 15 characters.  Although DHCP and
mDNS allow for up to 63, ESP32 and ESP8266 only allow 32, so this seems
like a reasonable limit to enforce across all ports (and avoids wasting the
additional memory).

Also clarifies that `MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN` does not include
the null terminator (which was unclear before).

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared
2023-09-29 22:49:49 +10:00
committed by Damien George
parent d6c55a40fe
commit b329fdcb73
6 changed files with 15 additions and 8 deletions

View File

@@ -56,10 +56,12 @@
extern char mod_network_country_code[2];
#ifndef MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN
#define MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN (16)
// Doesn't include the null terminator.
#define MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN (32)
#endif
extern char mod_network_hostname[MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN];
// This is a null-terminated string.
extern char mod_network_hostname[MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN + 1];
#if MICROPY_PY_LWIP
struct netif;