wificfg: remove the AP WEP mode option (#514)

* wificfg: remove the AP WEP mode option

The WEP mode does not appear to be implement in the sdk for the AP mode, and
defaults to open when WEP is requested which is probably not intended. Remove
the WEP option from the wifi config interface.

* lwip: enable mdns dns queries.

* wificfg: support mDNS on the softAP interface.
This commit is contained in:
Our Air Quality 2017-12-14 03:29:49 +11:00 committed by Ruslan V. Uss
parent c1937ea754
commit f27bc0f452
5 changed files with 101 additions and 66 deletions

View file

@ -49,8 +49,6 @@
"<dd><select id=\"am\" name=\"ap_authmode\">" "<dd><select id=\"am\" name=\"ap_authmode\">"
"<option value=\"0\"", "<option value=\"0\"",
">Open</option>" ">Open</option>"
"<option value=\"1\"",
">WEP</option>"
"<option value=\"2\"", "<option value=\"2\"",
">WPA_PSK</option>" ">WPA_PSK</option>"
"<option value=\"3\"", "<option value=\"3\"",
@ -82,6 +80,9 @@
"<dt><label for=\"dns_en\">DNS enabled</label></dt>" "<dt><label for=\"dns_en\">DNS enabled</label></dt>"
"<dd><input id=\"dns_en\" type=\"checkbox\" name=\"ap_dns\" value=\"1\" ", "<dd><input id=\"dns_en\" type=\"checkbox\" name=\"ap_dns\" value=\"1\" ",
" /></dd>" " /></dd>"
"<dt><label for=\"dns_en\">mDNS enabled</label></dt>"
"<dd><input id=\"dns_en\" type=\"checkbox\" name=\"ap_mdns\" value=\"1\" ",
" /></dd>"
"</dl>" "</dl>"
"<center><input type=\"reset\">&nbsp;<input type=\"submit\" value=\"Save\"></center>" "<center><input type=\"reset\">&nbsp;<input type=\"submit\" value=\"Save\"></center>"
"</fieldset>" "</fieldset>"

View file

@ -60,7 +60,7 @@
"pattern=\"(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)_*(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)_*){3}\" " "pattern=\"(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)_*(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)_*){3}\" "
"name=\"sta_gateway\" placeholder=\"192.168.1.1\" value=\"", "name=\"sta_gateway\" placeholder=\"192.168.1.1\" value=\"",
"\"></dd>" "\"></dd>"
"<dt><label for=\"mdns\">Enable mDNS</label></dt>" "<dt><label for=\"mdns\">mDNS enabled</label></dt>"
"<dd><input id=\"mdns\" type=\"checkbox\" name=\"sta_mdns\" value=\"1\" ", "<dd><input id=\"mdns\" type=\"checkbox\" name=\"sta_mdns\" value=\"1\" ",
" /></dd>" " /></dd>"
"</dl>" "</dl>"

View file

@ -76,7 +76,7 @@ static int read_crlf_line(int s, char *buf, size_t len)
do { do {
char c; char c;
int r = read(s, &c, 1); ssize_t r = read(s, &c, 1);
/* Expecting a known terminator so fail on EOF. */ /* Expecting a known terminator so fail on EOF. */
if (r <= 0) if (r <= 0)
@ -101,7 +101,7 @@ static int read_crlf_line(int s, char *buf, size_t len)
return num; return num;
} }
int wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t len) ssize_t wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t len)
{ {
size_t num = 0; size_t num = 0;
@ -110,7 +110,7 @@ int wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t le
break; break;
char c; char c;
int r = read(s, &c, 1); ssize_t r = read(s, &c, 1);
/* Expecting a known number of characters so fail on EOF. */ /* Expecting a known number of characters so fail on EOF. */
if (r <= 0) return -1; if (r <= 0) return -1;
@ -243,7 +243,7 @@ static const struct {
static wificfg_method intern_http_method(char *str) static wificfg_method intern_http_method(char *str)
{ {
int i; size_t i;
for (i = 0; i < sizeof(method_table) / sizeof(method_table[0]); i++) { for (i = 0; i < sizeof(method_table) / sizeof(method_table[0]); i++) {
if (!strcmp(str, method_table[i].str)) if (!strcmp(str, method_table[i].str))
return method_table[i].method; return method_table[i].method;
@ -274,7 +274,7 @@ static const struct {
static http_header intern_http_header(char *str) static http_header intern_http_header(char *str)
{ {
int i; size_t i;
for (i = 0; i < sizeof(http_header_table) / sizeof(http_header_table[0]); i++) { for (i = 0; i < sizeof(http_header_table) / sizeof(http_header_table[0]); i++) {
if (!strcmp(str, http_header_table[i].str)) if (!strcmp(str, http_header_table[i].str))
return http_header_table[i].name; return http_header_table[i].name;
@ -292,7 +292,7 @@ static const struct {
static wificfg_content_type intern_http_content_type(char *str) static wificfg_content_type intern_http_content_type(char *str)
{ {
int i; size_t i;
for (i = 0; i < sizeof(content_type_table) / sizeof(content_type_table[0]); i++) { for (i = 0; i < sizeof(content_type_table) / sizeof(content_type_table[0]); i++) {
if (!strcmp(str, content_type_table[i].str)) if (!strcmp(str, content_type_table[i].str))
return content_type_table[i].type; return content_type_table[i].type;
@ -318,13 +318,13 @@ static char *skip_to_whitespace(char *string)
return string; return string;
} }
int wificfg_write_string(int s, const char *str) ssize_t wificfg_write_string(int s, const char *str)
{ {
int res = write(s, str, strlen(str)); ssize_t res = write(s, str, strlen(str));
return res; return res;
} }
int wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len) ssize_t wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len)
{ {
size_t str_len = strlen(str); size_t str_len = strlen(str);
@ -366,7 +366,7 @@ int wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len)
/* Else too big for the buffer. */ /* Else too big for the buffer. */
char size_buf[8]; char size_buf[8];
size_t size_len = snprintf(size_buf, sizeof(size_buf), "%x\r\n", str_len); size_t size_len = snprintf(size_buf, sizeof(size_buf), "%x\r\n", str_len);
int res = write(s, size_buf, size_len); ssize_t res = write(s, size_buf, size_len);
if (res != size_len) { if (res != size_len) {
return res; return res;
} }
@ -377,7 +377,7 @@ int wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len)
return write(s, size_buf + size_len - 2, 2); return write(s, size_buf + size_len - 2, 2);
} }
int wificfg_write_chunk_end(int s) ssize_t wificfg_write_chunk_end(int s)
{ {
return wificfg_write_string(s, "0\r\n\r\n"); return wificfg_write_string(s, "0\r\n\r\n");
} }
@ -409,6 +409,7 @@ typedef enum {
FORM_NAME_AP_NETMASK, FORM_NAME_AP_NETMASK,
FORM_NAME_AP_DHCP_LEASES, FORM_NAME_AP_DHCP_LEASES,
FORM_NAME_AP_DNS, FORM_NAME_AP_DNS,
FORM_NAME_AP_MDNS,
FORM_NAME_DONE, FORM_NAME_DONE,
FORM_NAME_NONE FORM_NAME_NONE
} form_name; } form_name;
@ -443,17 +444,18 @@ static const struct {
{"ap_netmask", FORM_NAME_AP_NETMASK}, {"ap_netmask", FORM_NAME_AP_NETMASK},
{"ap_dhcp_leases", FORM_NAME_AP_DHCP_LEASES}, {"ap_dhcp_leases", FORM_NAME_AP_DHCP_LEASES},
{"ap_dns", FORM_NAME_AP_DNS}, {"ap_dns", FORM_NAME_AP_DNS},
{"ap_mdns", FORM_NAME_AP_MDNS},
{"done", FORM_NAME_DONE} {"done", FORM_NAME_DONE}
}; };
static form_name intern_form_name(char *str) static form_name intern_form_name(char *str)
{ {
int i; size_t i;
for (i = 0; i < sizeof(form_name_table) / sizeof(form_name_table[0]); i++) { for (i = 0; i < sizeof(form_name_table) / sizeof(form_name_table[0]); i++) {
if (!strcmp(str, form_name_table[i].str)) if (!strcmp(str, form_name_table[i].str))
return form_name_table[i].name; return form_name_table[i].name;
} }
return FORM_NAME_NONE; return FORM_NAME_NONE;
} }
@ -838,7 +840,7 @@ static int handle_wificfg_index_post(int s, wificfg_method method,
bool valp = false; bool valp = false;
while (rem > 0) { while (rem > 0) {
int r = wificfg_form_name_value(s, &valp, &rem, buf, len); ssize_t r = wificfg_form_name_value(s, &valp, &rem, buf, len);
if (r < 0) { if (r < 0) {
break; break;
@ -849,7 +851,7 @@ static int handle_wificfg_index_post(int s, wificfg_method method,
form_name name = intern_form_name(buf); form_name name = intern_form_name(buf);
if (valp) { if (valp) {
int r = wificfg_form_name_value(s, NULL, &rem, buf, len); ssize_t r = wificfg_form_name_value(s, NULL, &rem, buf, len);
if (r < 0) { if (r < 0) {
break; break;
} }
@ -1142,33 +1144,31 @@ static int handle_wifi_ap(int s, wificfg_method method,
if (wificfg_write_string_chunk(s, http_wifi_ap_content[8], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[8], buf, len) < 0) return -1;
int8_t wifi_ap_authmode = 4; int8_t wifi_ap_authmode = AUTH_WPA_WPA2_PSK;
sysparam_get_int8("wifi_ap_authmode", &wifi_ap_authmode); sysparam_get_int8("wifi_ap_authmode", &wifi_ap_authmode);
if (wifi_ap_authmode == 0 && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1; if (wifi_ap_authmode == AUTH_OPEN && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[9], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[9], buf, len) < 0) return -1;
if (wifi_ap_authmode == 1 && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1; if (wifi_ap_authmode == AUTH_WPA_PSK && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[10], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[10], buf, len) < 0) return -1;
if (wifi_ap_authmode == 2 && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1; if (wifi_ap_authmode == AUTH_WPA2_PSK && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[11], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[11], buf, len) < 0) return -1;
if (wifi_ap_authmode == 3 && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1; if (wifi_ap_authmode == AUTH_WPA_WPA2_PSK && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[12], buf, len) < 0) return -1;
if (wifi_ap_authmode == 4 && wificfg_write_string_chunk(s, " selected", buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[13], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[12], buf, len) < 0) return -1;
int8_t wifi_ap_max_conn = 3; int8_t wifi_ap_max_conn = 3;
sysparam_get_int8("wifi_ap_max_conn", &wifi_ap_max_conn); sysparam_get_int8("wifi_ap_max_conn", &wifi_ap_max_conn);
snprintf(buf, len, "%u", wifi_ap_max_conn); snprintf(buf, len, "%u", wifi_ap_max_conn);
if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[14], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[13], buf, len) < 0) return -1;
int32_t wifi_ap_beacon_interval = 100; int32_t wifi_ap_beacon_interval = 100;
sysparam_get_int32("wifi_ap_beacon_interval", &wifi_ap_beacon_interval); sysparam_get_int32("wifi_ap_beacon_interval", &wifi_ap_beacon_interval);
snprintf(buf, len, "%u", wifi_ap_beacon_interval); snprintf(buf, len, "%u", wifi_ap_beacon_interval);
if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[15], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[14], buf, len) < 0) return -1;
char *wifi_ap_ip_addr = NULL; char *wifi_ap_ip_addr = NULL;
sysparam_get_string("wifi_ap_ip_addr", &wifi_ap_ip_addr); sysparam_get_string("wifi_ap_ip_addr", &wifi_ap_ip_addr);
@ -1178,7 +1178,7 @@ static int handle_wifi_ap(int s, wificfg_method method,
if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1;
} }
if (wificfg_write_string_chunk(s, http_wifi_ap_content[16], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[15], buf, len) < 0) return -1;
char *wifi_ap_netmask = NULL; char *wifi_ap_netmask = NULL;
sysparam_get_string("wifi_ap_netmask", &wifi_ap_netmask); sysparam_get_string("wifi_ap_netmask", &wifi_ap_netmask);
@ -1188,18 +1188,25 @@ static int handle_wifi_ap(int s, wificfg_method method,
if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1;
} }
if (wificfg_write_string_chunk(s, http_wifi_ap_content[17], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[16], buf, len) < 0) return -1;
int8_t wifi_ap_dhcp_leases = 4; int8_t wifi_ap_dhcp_leases = 4;
sysparam_get_int8("wifi_ap_dhcp_leases", &wifi_ap_dhcp_leases); sysparam_get_int8("wifi_ap_dhcp_leases", &wifi_ap_dhcp_leases);
snprintf(buf, len, "%u", wifi_ap_dhcp_leases); snprintf(buf, len, "%u", wifi_ap_dhcp_leases);
if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, buf, buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[18], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[17], buf, len) < 0) return -1;
int8_t wifi_ap_dns = 1; int8_t wifi_ap_dns = 1;
sysparam_get_int8("wifi_ap_dns", &wifi_ap_dns); sysparam_get_int8("wifi_ap_dns", &wifi_ap_dns);
if (wifi_ap_dns && wificfg_write_string_chunk(s, "checked", buf, len) < 0) return -1; if (wifi_ap_dns && wificfg_write_string_chunk(s, "checked", buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[18], buf, len) < 0) return -1;
int8_t wifi_ap_mdns = 1;
sysparam_get_int8("wifi_ap_mdns", &wifi_ap_mdns);
if (wifi_ap_mdns && wificfg_write_string_chunk(s, "checked", buf, len) < 0) return -1;
if (wificfg_write_string_chunk(s, http_wifi_ap_content[19], buf, len) < 0) return -1; if (wificfg_write_string_chunk(s, http_wifi_ap_content[19], buf, len) < 0) return -1;
if (wificfg_write_chunk_end(s) < 0) return -1; if (wificfg_write_chunk_end(s) < 0) return -1;
@ -1228,9 +1235,10 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
uint8_t ap_disable_if_sta = 0; uint8_t ap_disable_if_sta = 0;
uint8_t ssid_hidden = 0; uint8_t ssid_hidden = 0;
uint8_t dns_enable = 0; uint8_t dns_enable = 0;
uint8_t mdns_enable = 0;
while (rem > 0) { while (rem > 0) {
int r = wificfg_form_name_value(s, &valp, &rem, buf, len); ssize_t r = wificfg_form_name_value(s, &valp, &rem, buf, len);
if (r < 0) { if (r < 0) {
break; break;
@ -1241,7 +1249,7 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
form_name name = intern_form_name(buf); form_name name = intern_form_name(buf);
if (valp) { if (valp) {
int r = wificfg_form_name_value(s, NULL, &rem, buf, len); ssize_t r = wificfg_form_name_value(s, NULL, &rem, buf, len);
if (r < 0) { if (r < 0) {
break; break;
} }
@ -1281,19 +1289,21 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
} }
case FORM_NAME_AP_AUTHMODE: { case FORM_NAME_AP_AUTHMODE: {
uint32_t mode = strtoul(buf, NULL, 10); uint32_t mode = strtoul(buf, NULL, 10);
if (mode >= 0 && mode <= 5) if (mode == AUTH_OPEN || mode == AUTH_WPA_PSK ||
mode == AUTH_WPA2_PSK || mode == AUTH_WPA_WPA2_PSK) {
sysparam_set_int8("wifi_ap_authmode", mode); sysparam_set_int8("wifi_ap_authmode", mode);
}
break; break;
} }
case FORM_NAME_AP_MAX_CONN: { case FORM_NAME_AP_MAX_CONN: {
uint32_t max_conn = strtoul(buf, NULL, 10); uint32_t max_conn = strtoul(buf, NULL, 10);
if (max_conn >= 0 && max_conn <= 8) if (max_conn <= 8)
sysparam_set_int8("wifi_ap_max_conn", max_conn); sysparam_set_int8("wifi_ap_max_conn", max_conn);
break; break;
} }
case FORM_NAME_AP_BEACON_INTERVAL: { case FORM_NAME_AP_BEACON_INTERVAL: {
uint32_t interval = strtoul(buf, NULL, 10); uint32_t interval = strtoul(buf, NULL, 10);
if (interval >= 0 && interval <= 10000) if (interval <= 10000)
sysparam_set_int32("wifi_ap_beacon_interval", interval); sysparam_set_int32("wifi_ap_beacon_interval", interval);
break; break;
} }
@ -1305,7 +1315,7 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
break; break;
case FORM_NAME_AP_DHCP_LEASES: { case FORM_NAME_AP_DHCP_LEASES: {
uint32_t leases = strtoul(buf, NULL, 10); uint32_t leases = strtoul(buf, NULL, 10);
if (leases >= 0 && leases <= 16) if (leases <= 16)
sysparam_set_int8("wifi_ap_dhcp_leases", leases); sysparam_set_int8("wifi_ap_dhcp_leases", leases);
break; break;
} }
@ -1313,6 +1323,10 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
dns_enable = strtoul(buf, NULL, 10) != 0; dns_enable = strtoul(buf, NULL, 10) != 0;
break; break;
} }
case FORM_NAME_AP_MDNS: {
mdns_enable = strtoul(buf, NULL, 10) != 0;
break;
}
case FORM_NAME_DONE: case FORM_NAME_DONE:
done = true; done = true;
break; break;
@ -1327,6 +1341,7 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
sysparam_set_int8("wifi_ap_disable_if_sta", ap_disable_if_sta); sysparam_set_int8("wifi_ap_disable_if_sta", ap_disable_if_sta);
sysparam_set_int8("wifi_ap_ssid_hidden", ssid_hidden); sysparam_set_int8("wifi_ap_ssid_hidden", ssid_hidden);
sysparam_set_int8("wifi_ap_dns", dns_enable); sysparam_set_int8("wifi_ap_dns", dns_enable);
sysparam_set_int8("wifi_ap_mdns", mdns_enable);
} }
return wificfg_write_string(s, http_redirect_header); return wificfg_write_string(s, http_redirect_header);
@ -1656,10 +1671,8 @@ static void server_task(void *pvParameters)
{ {
char *hostname_local = NULL; char *hostname_local = NULL;
char *hostname = NULL; char *hostname = NULL;
int8_t wifi_sta_mdns = 1;
sysparam_get_string("hostname", &hostname); sysparam_get_string("hostname", &hostname);
sysparam_get_int8("wifi_sta_mdns", &wifi_sta_mdns);
if (hostname) { if (hostname) {
size_t len = strlen(hostname) + 6 + 1; size_t len = strlen(hostname) + 6 + 1;
hostname_local = (char *)malloc(len); hostname_local = (char *)malloc(len);
@ -1667,21 +1680,34 @@ static void server_task(void *pvParameters)
snprintf(hostname_local, len, "%s.local", hostname); snprintf(hostname_local, len, "%s.local", hostname);
} }
struct netif *netif = sdk_system_get_netif(STATION_IF); int8_t wifi_sta_mdns = 1;
if (wifi_sta_mdns && netif) { int8_t wifi_ap_mdns = 1;
sysparam_get_int8("wifi_sta_mdns", &wifi_sta_mdns);
sysparam_get_int8("wifi_ap_mdns", &wifi_ap_mdns);
struct netif *station_netif = sdk_system_get_netif(STATION_IF);
struct netif *softap_netif = sdk_system_get_netif(SOFTAP_IF);
if ((wifi_sta_mdns && station_netif) || (wifi_ap_mdns && softap_netif)) {
#if LWIP_MDNS_RESPONDER
mdns_resp_init();
#endif
#if EXTRAS_MDNS_RESPONDER #if EXTRAS_MDNS_RESPONDER
mdns_init(); mdns_init();
mdns_add_facility(hostname, "_http", NULL, mdns_TCP + mdns_Browsable, 80, 600); mdns_add_facility(hostname, "_http", NULL, mdns_TCP + mdns_Browsable, 80, 600);
#endif
#if LWIP_MDNS_RESPONDER
mdns_resp_init();
if (netif) {
mdns_resp_add_netif(netif, hostname, 120);
mdns_resp_add_service(netif, hostname, "_http",
DNSSD_PROTO_TCP, 80, 3600, NULL, NULL);
}
#endif #endif
} }
#if LWIP_MDNS_RESPONDER
if (wifi_sta_mdns && station_netif) {
mdns_resp_add_netif(station_netif, hostname, 120);
mdns_resp_add_service(station_netif, hostname, "_http",
DNSSD_PROTO_TCP, 80, 3600, NULL, NULL);
}
if (wifi_ap_mdns && softap_netif) {
mdns_resp_add_netif(softap_netif, hostname, 120);
mdns_resp_add_service(softap_netif, hostname, "_http",
DNSSD_PROTO_TCP, 80, 3600, NULL, NULL);
}
#endif
free(hostname); free(hostname);
} }
@ -1851,7 +1877,7 @@ static void server_task(void *pvParameters)
size_t len; size_t len;
for (len = 0; len < 4096; len++) { for (len = 0; len < 4096; len++) {
char c; char c;
int res = read(s, &c, 1); ssize_t res = read(s, &c, 1);
if (res != 1) break; if (res != 1) break;
} }
@ -1912,7 +1938,7 @@ static void dns_task(void *pvParameters)
char buffer[96]; char buffer[96];
struct sockaddr_storage src_addr; struct sockaddr_storage src_addr;
socklen_t src_addr_len = sizeof(src_addr); socklen_t src_addr_len = sizeof(src_addr);
size_t count = recvfrom(fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&src_addr, &src_addr_len); ssize_t count = recvfrom(fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&src_addr, &src_addr_len);
/* Drop messages that are too large to send a response in the buffer */ /* Drop messages that are too large to send a response in the buffer */
if (count > 0 && count <= sizeof(buffer) - 16) { if (count > 0 && count <= sizeof(buffer) - 16) {
@ -2097,8 +2123,9 @@ void wificfg_init(uint32_t port, const wificfg_dispatch *dispatch)
/* Read and validate paramenters. */ /* Read and validate paramenters. */
int8_t wifi_ap_ssid_hidden = 0; int8_t wifi_ap_ssid_hidden = 0;
sysparam_get_int8("wifi_ap_ssid_hidden", &wifi_ap_ssid_hidden); sysparam_get_int8("wifi_ap_ssid_hidden", &wifi_ap_ssid_hidden);
if (wifi_ap_ssid_hidden < 0 || wifi_ap_ssid_hidden > 1) if (wifi_ap_ssid_hidden < 0 || wifi_ap_ssid_hidden > 1) {
wifi_ap_ssid_hidden = 1; wifi_ap_ssid_hidden = 1;
}
int8_t wifi_ap_channel = 6; int8_t wifi_ap_channel = 6;
sysparam_get_int8("wifi_ap_channel", &wifi_ap_channel); sysparam_get_int8("wifi_ap_channel", &wifi_ap_channel);
@ -2119,18 +2146,22 @@ void wificfg_init(uint32_t port, const wificfg_dispatch *dispatch)
int8_t wifi_ap_authmode = AUTH_WPA_WPA2_PSK; int8_t wifi_ap_authmode = AUTH_WPA_WPA2_PSK;
sysparam_get_int8("wifi_ap_authmode", &wifi_ap_authmode); sysparam_get_int8("wifi_ap_authmode", &wifi_ap_authmode);
if (wifi_ap_authmode < AUTH_OPEN || wifi_ap_authmode > AUTH_MAX) if (wifi_ap_authmode != AUTH_OPEN && wifi_ap_authmode != AUTH_WPA_PSK &&
wifi_ap_authmode != AUTH_WPA2_PSK && wifi_ap_authmode != AUTH_WPA_WPA2_PSK) {
wifi_ap_authmode = AUTH_WPA_WPA2_PSK; wifi_ap_authmode = AUTH_WPA_WPA2_PSK;
}
int8_t wifi_ap_max_conn = 3; int8_t wifi_ap_max_conn = 3;
sysparam_get_int8("wifi_ap_max_conn", &wifi_ap_max_conn); sysparam_get_int8("wifi_ap_max_conn", &wifi_ap_max_conn);
if (wifi_ap_max_conn < 1 || wifi_ap_max_conn > 8) if (wifi_ap_max_conn < 1 || wifi_ap_max_conn > 8) {
wifi_ap_max_conn = 3; wifi_ap_max_conn = 3;
}
int32_t wifi_ap_beacon_interval = 100; int32_t wifi_ap_beacon_interval = 100;
sysparam_get_int32("wifi_ap_beacon_interval", &wifi_ap_beacon_interval); sysparam_get_int32("wifi_ap_beacon_interval", &wifi_ap_beacon_interval);
if (wifi_ap_beacon_interval < 0 || wifi_ap_beacon_interval > 1000) if (wifi_ap_beacon_interval < 0 || wifi_ap_beacon_interval > 1000) {
wifi_ap_beacon_interval = 100; wifi_ap_beacon_interval = 100;
}
/* Default AP IP address and netmask. */ /* Default AP IP address and netmask. */
char *wifi_ap_ip_addr = NULL; char *wifi_ap_ip_addr = NULL;

View file

@ -97,7 +97,7 @@ void wificfg_init(uint32_t port, const wificfg_dispatch *dispatch);
* is truncated to the buffer length. The number of characters read is limited * is truncated to the buffer length. The number of characters read is limited
* to the remainder which is updated. The 'valp' flag is set if a value follows. * to the remainder which is updated. The 'valp' flag is set if a value follows.
*/ */
int wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t len); ssize_t wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t len);
/* Support for form url-encoding decoder. */ /* Support for form url-encoding decoder. */
void wificfg_form_url_decode(char *string); void wificfg_form_url_decode(char *string);
@ -106,20 +106,17 @@ void wificfg_form_url_decode(char *string);
void wificfg_html_escape(char *string, char *buf, size_t len); void wificfg_html_escape(char *string, char *buf, size_t len);
/* Support for writing a string in a response. */ /* Support for writing a string in a response. */
int wificfg_write_string(int s, const char *str); ssize_t wificfg_write_string(int s, const char *str);
/* Support for writing a string in a response, with chunk transfer encoding. /* Support for writing a string in a response, with chunk transfer encoding.
* An optional buffer may be supplied to use to construct a chunk with the * An optional buffer may be supplied to use to construct a chunk with the
* header and trailer, reducing the number of write() calls, and the str may be * header and trailer, reducing the number of write() calls, and the str may be
* at the start of this buffer. * at the start of this buffer.
*/ */
int wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len); ssize_t wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len);
/* Write a chunk transfer encoding end marker. */ /* Write a chunk transfer encoding end marker. */
int wificfg_write_chunk_end(int s); ssize_t wificfg_write_chunk_end(int s);
/* Write a chunk offset 4 bytes into the buffer. */
int wificfg_write_buffer_chunk(int s, char *buf);
/* Write a html title meta data, using the hostname or AP SSI. */ /* Write a html title meta data, using the hostname or AP SSI. */
int wificfg_write_html_title(int s, char *buf, size_t len, const char *str); int wificfg_write_html_title(int s, char *buf, size_t len, const char *str);

View file

@ -297,6 +297,12 @@
#define DNS_MAX_NAME_LENGTH 128 #define DNS_MAX_NAME_LENGTH 128
#endif #endif
/** Set this to 1 to enable querying ".local" names via mDNS
* using a One-Shot Multicast DNS Query */
#ifndef LWIP_DNS_SUPPORT_MDNS_QUERIES
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1
#endif
/* /*
--------------------------------- ---------------------------------
---------- UDP options ---------- ---------- UDP options ----------