mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-01 10:57:47 +00:00
WIFI-1629 Captive Portal Service Portal Halt
This patch will add the support to enable captive portal on multiple ssid's with same captive portal profile Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
This commit is contained in:
committed by
Rick Sommerville
parent
9598e68a2b
commit
56f51c8055
@@ -242,7 +242,7 @@ header="<!DOCTYPE html>
|
|||||||
<meta http-equiv=\"Expires\" content=\"0\">
|
<meta http-equiv=\"Expires\" content=\"0\">
|
||||||
<meta charset=\"utf-8\">
|
<meta charset=\"utf-8\">
|
||||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||||
<link rel=\"shortcut icon\" href=\"/images/$client_zone/TipLogo.png\" type=\"image/x-icon\">
|
<link rel=\"shortcut icon\" href=\"/images/TipLogo.png\" type=\"image/x-icon\">
|
||||||
<link rel=\"stylesheet\" type=\"text/css\" href=\"/splash.css\">
|
<link rel=\"stylesheet\" type=\"text/css\" href=\"/splash.css\">
|
||||||
<title>$gatewaynamehtml</title>
|
<title>$gatewaynamehtml</title>
|
||||||
</head>
|
</head>
|
||||||
@@ -257,7 +257,7 @@ header="<!DOCTYPE html>
|
|||||||
version="$(ndsctl status | grep Version)"
|
version="$(ndsctl status | grep Version)"
|
||||||
year="$(date | awk -F ' ' '{print $(6)}')"
|
year="$(date | awk -F ' ' '{print $(6)}')"
|
||||||
footer="
|
footer="
|
||||||
<img style=\"height:60px; width:100px; float:left;\" src=\"/images/$client_zone/TipLogo.png\" alt=\"Splash Page: For access to the Internet.\">
|
<img style=\"height:60px; width:100px; float:left;\" src=\"/images/TipLogo.png\" alt=\"Splash Page: For access to the Internet.\">
|
||||||
|
|
||||||
<copy-right>
|
<copy-right>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ header="<!DOCTYPE html>
|
|||||||
<meta http-equiv=\"Expires\" content=\"0\">
|
<meta http-equiv=\"Expires\" content=\"0\">
|
||||||
<meta charset=\"utf-8\">
|
<meta charset=\"utf-8\">
|
||||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||||
<link rel=\"shortcut icon\" href=\"/images/$client_zone/TipLogo.png\" type=\"image/x-icon\">
|
<link rel=\"shortcut icon\" href=\"/images/TipLogo.png\" type=\"image/x-icon\">
|
||||||
<link rel=\"stylesheet\" type=\"text/css\" href=\"/splash.css\">
|
<link rel=\"stylesheet\" type=\"text/css\" href=\"/splash.css\">
|
||||||
<title>$gatewaynamehtml</title>
|
<title>$gatewaynamehtml</title>
|
||||||
</head>
|
</head>
|
||||||
@@ -317,7 +317,7 @@ header="<!DOCTYPE html>
|
|||||||
version="$(ndsctl status | grep Version)"
|
version="$(ndsctl status | grep Version)"
|
||||||
year="$(date | awk -F ' ' '{print $(6)}')"
|
year="$(date | awk -F ' ' '{print $(6)}')"
|
||||||
footer="
|
footer="
|
||||||
<img style=\"height:60px; width:60px; float:left;\" src=\"/images/$client_zone/TipLogo.png\" alt=\"Splash Page: For access to the Internet.\">
|
<img style=\"height:60px; width:60px; float:left;\" src=\"/images/TipLogo.png\" alt=\"Splash Page: For access to the Internet.\">
|
||||||
<copy-right>
|
<copy-right>
|
||||||
<br><br>
|
<br><br>
|
||||||
openNDS $version.
|
openNDS $version.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
body{
|
body{
|
||||||
background-image:url('/images/wlan1/TipBackLogo.png');
|
background-image:url('/images/TipBackLogo.png');
|
||||||
background-attachment:fixed;
|
background-attachment:fixed;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ validate_client() {
|
|||||||
# $username, $phone, $emailaddr, $addr, $code
|
# $username, $phone, $emailaddr, $addr, $code
|
||||||
#
|
#
|
||||||
# Return either 0 if validation successful or 1 if not
|
# Return either 0 if validation successful or 1 if not
|
||||||
userlist="/etc/opennds/htdocs/images/$client_zone/userpass.dat"
|
userlist="/etc/opennds/htdocs/images/userpass.dat"
|
||||||
varlist="username password firstname lastname"
|
varlist="username password firstname lastname"
|
||||||
|
|
||||||
while read user; do
|
while read user; do
|
||||||
@@ -282,7 +282,7 @@ header="<!DOCTYPE html>
|
|||||||
<meta http-equiv=\"Expires\" content=\"0\">
|
<meta http-equiv=\"Expires\" content=\"0\">
|
||||||
<meta charset=\"utf-8\">
|
<meta charset=\"utf-8\">
|
||||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||||
<link rel=\"shortcut icon\" href=\"/images/$client_zone/TipLogo.png\" type=\"image/x-icon\">
|
<link rel=\"shortcut icon\" href=\"/images/TipLogo.png\" type=\"image/x-icon\">
|
||||||
<link rel=\"stylesheet\" type=\"text/css\" href=\"/splash.css\">
|
<link rel=\"stylesheet\" type=\"text/css\" href=\"/splash.css\">
|
||||||
<title>$gatewaynamehtml</title>
|
<title>$gatewaynamehtml</title>
|
||||||
</head>
|
</head>
|
||||||
@@ -297,7 +297,7 @@ header="<!DOCTYPE html>
|
|||||||
version="$(ndsctl status | grep Version)"
|
version="$(ndsctl status | grep Version)"
|
||||||
year="$(date | awk -F ' ' '{print $(6)}')"
|
year="$(date | awk -F ' ' '{print $(6)}')"
|
||||||
footer="
|
footer="
|
||||||
<img style=\"height:60px; width:60px; float:left;\" src=\"/images/$client_zone/TipLogo.png\" alt=\"Splash Page: For access to the Internet.\">
|
<img style=\"height:60px; width:60px; float:left;\" src=\"/images/TipLogo.png\" alt=\"Splash Page: For access to the Internet.\">
|
||||||
<copy-right>
|
<copy-right>
|
||||||
<br><br>
|
<br><br>
|
||||||
openNDS $version.
|
openNDS $version.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ extern struct blob_buf c;
|
|||||||
extern struct schema_Wifi_VIF_State vstate;
|
extern struct schema_Wifi_VIF_State vstate;
|
||||||
extern const struct schema_Wifi_VIF_Config *vconf;
|
extern const struct schema_Wifi_VIF_Config *vconf;
|
||||||
extern void vif_captive_portal_set (const struct schema_Wifi_VIF_Config *vconf, char *ifname);
|
extern void vif_captive_portal_set (const struct schema_Wifi_VIF_Config *vconf, char *ifname);
|
||||||
extern void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate, struct uci_section *s);
|
extern void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate);
|
||||||
extern void captive_portal_init();
|
extern void captive_portal_init();
|
||||||
extern void splash_page_logo(char* dest_file,char* src_url);
|
extern void splash_page_logo(char* dest_file,char* src_url);
|
||||||
extern void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf, char *ifname);
|
extern void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf, char *ifname);
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ void vif_state_dhcp_allowlist_get(struct schema_Wifi_VIF_State *vstate)
|
|||||||
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
|
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
|
||||||
continue;
|
continue;
|
||||||
sscanf(blobmsg_get_string(cur), "/%[^/]/%[^_]_%s", fqdn, set, read_ifname);
|
sscanf(blobmsg_get_string(cur), "/%[^/]/%[^_]_%s", fqdn, set, read_ifname);
|
||||||
if(!strcmp(vstate->if_name, read_ifname))
|
if(!strcmp("opennds", read_ifname))
|
||||||
{
|
{
|
||||||
strcpy(vstate->captive_allowlist[vstate->captive_allowlist_len], fqdn);
|
strcpy(vstate->captive_allowlist[vstate->captive_allowlist_len], fqdn);
|
||||||
vstate->captive_allowlist_len++;
|
vstate->captive_allowlist_len++;
|
||||||
@@ -171,10 +171,8 @@ void vif_state_dhcp_allowlist_get(struct schema_Wifi_VIF_State *vstate)
|
|||||||
|
|
||||||
void ipset_flush(char *ifname)
|
void ipset_flush(char *ifname)
|
||||||
{
|
{
|
||||||
char com[24]="ipset flush set_wlan1";
|
char com[32]="ipset flush set_opennds";
|
||||||
|
system(com);
|
||||||
if (!strcmp(ifname,"wlan1"))
|
|
||||||
system(com);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf, char *ifname)
|
void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf, char *ifname)
|
||||||
@@ -189,7 +187,7 @@ void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf,
|
|||||||
for (i = 0; i < vconf->captive_allowlist_len; i++)
|
for (i = 0; i < vconf->captive_allowlist_len; i++)
|
||||||
{
|
{
|
||||||
strcpy(buff,(char*)vconf->captive_allowlist[i]);
|
strcpy(buff,(char*)vconf->captive_allowlist[i]);
|
||||||
sprintf(ips,"/%s/set_%s", buff,ifname);
|
sprintf(ips,"/%s/set_%s", buff,"opennds");
|
||||||
blobmsg_add_string(&dnsmas, NULL,ips);
|
blobmsg_add_string(&dnsmas, NULL,ips);
|
||||||
}
|
}
|
||||||
blobmsg_close_array(&dnsmas, e);
|
blobmsg_close_array(&dnsmas, e);
|
||||||
@@ -228,134 +226,133 @@ void set_captive_portal_state(struct schema_Wifi_VIF_State *vstate,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate, struct uci_section *s)
|
void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
const char *opt;
|
const char *opt;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
struct blob_attr *tc[__NDS_ATTR_MAX] = { };
|
struct blob_attr *tc[__NDS_ATTR_MAX] = { };
|
||||||
struct uci_element *e = NULL;
|
struct uci_section *cp_section;
|
||||||
|
|
||||||
uci_load(cap_uci, "opennds", &opennds);
|
uci_load(cap_uci, "opennds", &opennds);
|
||||||
uci_foreach_element(&opennds->sections, e) {
|
cp_section = uci_lookup_section(cap_uci, opennds,"opennds");
|
||||||
struct uci_section *cp_section = uci_to_section(e);
|
if(!cp_section) {
|
||||||
if (!strcmp(s->e.name, cp_section->e.name)){
|
LOGN("Section Not Found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
blob_buf_init(&cap, 0);
|
||||||
|
uci_to_blob(&cap, cp_section, &opennds_param);
|
||||||
|
blobmsg_parse(opennds_policy, __NDS_ATTR_MAX, tc, blob_data(cap.head), blob_len(cap.head));
|
||||||
|
for (i = 0; i < SCHEMA_CAPTIVE_PORTAL_OPTS_MAX; i++) {
|
||||||
|
opt = captive_portal_options_table[i];
|
||||||
|
if (!strcmp(opt, "session_timeout"))
|
||||||
|
{
|
||||||
|
if (tc[NDS_ATTR_SESSIONTIMEOUT])
|
||||||
|
{
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_SESSIONTIMEOUT]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (!strcmp(opt, "authentication")) {
|
||||||
|
if(tc[NDS_ATTR_AUTHENTICATION]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_AUTHENTICATION]);
|
||||||
|
if (!strcmp(buf, "None")) {
|
||||||
|
|
||||||
blob_buf_init(&cap, 0);
|
set_captive_portal_state(vstate, &index,
|
||||||
uci_to_blob(&cap, cp_section, &opennds_param);
|
captive_portal_options_table[i],
|
||||||
blobmsg_parse(opennds_policy, __NDS_ATTR_MAX, tc, blob_data(cap.head), blob_len(cap.head));
|
buf);
|
||||||
for (i = 0; i < SCHEMA_CAPTIVE_PORTAL_OPTS_MAX; i++) {
|
} else if (!strcmp(buf,"username")) {
|
||||||
opt = captive_portal_options_table[i];
|
set_captive_portal_state(vstate, &index,
|
||||||
if (!strcmp(opt, "session_timeout"))
|
captive_portal_options_table[i],
|
||||||
{
|
buf);
|
||||||
if (tc[NDS_ATTR_SESSIONTIMEOUT])
|
|
||||||
{
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_SESSIONTIMEOUT]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (!strcmp(opt, "authentication")) {
|
|
||||||
if(tc[NDS_ATTR_AUTHENTICATION]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_AUTHENTICATION]);
|
|
||||||
if (!strcmp(buf, "None")) {
|
|
||||||
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
} else if (!strcmp(buf,"username")) {
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "browser_title") == 0) {
|
|
||||||
if (tc[NDS_ATTR_GATEWAYNAME]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_GATEWAYNAME]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "splash_page_logo") == 0) {
|
|
||||||
if (tc[NDS_ATTR_SPLASH_PAGE_LOGO]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_SPLASH_PAGE_LOGO]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "splash_page_background_logo") == 0) {
|
|
||||||
if (tc[NDS_ATTR_PAGE_BACKGROUND_LOGO]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_PAGE_BACKGROUND_LOGO]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "splash_page_title") == 0) {
|
|
||||||
if (tc[NDS_ATTR_SPLASH_PAGE_TITLE]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_SPLASH_PAGE_TITLE]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "redirect_url") == 0) {
|
|
||||||
if (tc[NDS_ATTR_REDIRECT_URL]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_REDIRECT_URL]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "acceptance_policy") == 0) {
|
|
||||||
if (tc[NDS_ATTR_ACCEPTANCE_POLICY]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_ACCEPTANCE_POLICY]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "login_success_text") == 0) {
|
|
||||||
if (tc[NDS_ATTR_LOGIN_SUCCESS_TEXT]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_LOGIN_SUCCESS_TEXT]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "username_password_file") == 0) {
|
|
||||||
if (tc[NDS_ATTR_USERNAMEPASS_FILE]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_USERNAMEPASS_FILE]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "radius_server_ip") == 0) {
|
|
||||||
if (tc[NDS_ATTR_RADIUS_IP]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_RADIUS_IP]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "radius_server_port") == 0) {
|
|
||||||
if (tc[NDS_ATTR_RADIUS_PORT]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_RADIUS_PORT]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "radius_server_secret") == 0) {
|
|
||||||
if (tc[NDS_ATTR_RADIUS_SECRET]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_RADIUS_SECRET]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
} else if (strcmp(opt, "radius_auth_type") == 0) {
|
|
||||||
if (tc[NDS_ATTR_RADIUS_AUTH_TYPE]) {
|
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_RADIUS_AUTH_TYPE]);
|
|
||||||
set_captive_portal_state(vstate, &index,
|
|
||||||
captive_portal_options_table[i],
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(opt, "browser_title") == 0) {
|
||||||
|
if (tc[NDS_ATTR_GATEWAYNAME]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_GATEWAYNAME]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "splash_page_logo") == 0) {
|
||||||
|
if (tc[NDS_ATTR_SPLASH_PAGE_LOGO]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_SPLASH_PAGE_LOGO]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "splash_page_background_logo") == 0) {
|
||||||
|
if (tc[NDS_ATTR_PAGE_BACKGROUND_LOGO]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_PAGE_BACKGROUND_LOGO]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "splash_page_title") == 0) {
|
||||||
|
if (tc[NDS_ATTR_SPLASH_PAGE_TITLE]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_SPLASH_PAGE_TITLE]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "redirect_url") == 0) {
|
||||||
|
if (tc[NDS_ATTR_REDIRECT_URL]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_REDIRECT_URL]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "acceptance_policy") == 0) {
|
||||||
|
if (tc[NDS_ATTR_ACCEPTANCE_POLICY]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_ACCEPTANCE_POLICY]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "login_success_text") == 0) {
|
||||||
|
if (tc[NDS_ATTR_LOGIN_SUCCESS_TEXT]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_LOGIN_SUCCESS_TEXT]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "username_password_file") == 0) {
|
||||||
|
if (tc[NDS_ATTR_USERNAMEPASS_FILE]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_USERNAMEPASS_FILE]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "radius_server_ip") == 0) {
|
||||||
|
if (tc[NDS_ATTR_RADIUS_IP]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_RADIUS_IP]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "radius_server_port") == 0) {
|
||||||
|
if (tc[NDS_ATTR_RADIUS_PORT]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_RADIUS_PORT]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "radius_server_secret") == 0) {
|
||||||
|
if (tc[NDS_ATTR_RADIUS_SECRET]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_RADIUS_SECRET]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
} else if (strcmp(opt, "radius_auth_type") == 0) {
|
||||||
|
if (tc[NDS_ATTR_RADIUS_AUTH_TYPE]) {
|
||||||
|
buf = blobmsg_get_string(tc[NDS_ATTR_RADIUS_AUTH_TYPE]);
|
||||||
|
set_captive_portal_state(vstate, &index,
|
||||||
|
captive_portal_options_table[i],
|
||||||
|
buf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uci_unload(cap_uci, opennds);
|
uci_unload(cap_uci, opennds);
|
||||||
@@ -424,10 +421,10 @@ void splash_page_logo(char* dest_file, char* src_url)
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipset_create(char *ifname)
|
int ipset_create(char *ifnds)
|
||||||
{
|
{
|
||||||
char command[64];
|
char command[64];
|
||||||
sprintf(command,"ipset create set_%s hash:ip", ifname);
|
sprintf(command,"ipset create set_%s hash:ip", ifnds);
|
||||||
return (system(command));
|
return (system(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,38 +432,38 @@ void captive_portal_get_current_urls(char *ifname, char *splash_logo, char *back
|
|||||||
{
|
{
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
struct blob_attr *tc[__NDS_ATTR_MAX] = { };
|
struct blob_attr *tc[__NDS_ATTR_MAX] = { };
|
||||||
struct uci_element *e = NULL;
|
|
||||||
struct blob_buf url_buf={ };
|
struct blob_buf url_buf={ };
|
||||||
|
struct uci_section *cp_section;
|
||||||
|
|
||||||
uci_load(cap_uci, "opennds", &opennds);
|
uci_load(cap_uci, "opennds", &opennds);
|
||||||
uci_foreach_element(&opennds->sections, e) {
|
cp_section = uci_lookup_section(cap_uci, opennds,"opennds");
|
||||||
struct uci_section *cp_section = uci_to_section(e);
|
if(!cp_section) {
|
||||||
if (!strcmp(ifname, cp_section->e.name)){
|
LOGN("Section Not Found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
blob_buf_init(&url_buf, 0);
|
blob_buf_init(&url_buf, 0);
|
||||||
uci_to_blob(&url_buf, cp_section, &opennds_param);
|
uci_to_blob(&url_buf, cp_section, &opennds_param);
|
||||||
blobmsg_parse(opennds_policy, __NDS_ATTR_MAX, tc, blob_data(url_buf.head), blob_len(url_buf.head));
|
blobmsg_parse(opennds_policy, __NDS_ATTR_MAX, tc, blob_data(url_buf.head), blob_len(url_buf.head));
|
||||||
|
|
||||||
if (tc[NDS_ATTR_SPLASH_PAGE_LOGO]) {
|
if (tc[NDS_ATTR_SPLASH_PAGE_LOGO]) {
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_SPLASH_PAGE_LOGO]);
|
buf = blobmsg_get_string(tc[NDS_ATTR_SPLASH_PAGE_LOGO]);
|
||||||
strcpy(splash_logo, buf);
|
strcpy(splash_logo, buf);
|
||||||
} else {
|
} else {
|
||||||
splash_logo[0]=0;
|
splash_logo[0]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tc[NDS_ATTR_PAGE_BACKGROUND_LOGO]) {
|
if (tc[NDS_ATTR_PAGE_BACKGROUND_LOGO]) {
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_PAGE_BACKGROUND_LOGO]);
|
buf = blobmsg_get_string(tc[NDS_ATTR_PAGE_BACKGROUND_LOGO]);
|
||||||
strcpy(back_image, buf);
|
strcpy(back_image, buf);
|
||||||
} else {
|
} else {
|
||||||
back_image[0]=0;
|
back_image[0]=0;
|
||||||
}
|
}
|
||||||
if (tc[NDS_ATTR_USERNAMEPASS_FILE]) {
|
if (tc[NDS_ATTR_USERNAMEPASS_FILE]) {
|
||||||
buf = blobmsg_get_string(tc[NDS_ATTR_USERNAMEPASS_FILE]);
|
buf = blobmsg_get_string(tc[NDS_ATTR_USERNAMEPASS_FILE]);
|
||||||
strcpy(user_file, buf);
|
strcpy(user_file, buf);
|
||||||
} else {
|
} else {
|
||||||
user_file[0]=0;
|
user_file[0]=0;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
uci_unload(cap_uci, opennds);
|
uci_unload(cap_uci, opennds);
|
||||||
return;
|
return;
|
||||||
@@ -501,7 +498,7 @@ void opennds_parameters(char *ifname)
|
|||||||
blobmsg_add_string(&cap_blob, NULL, users_router[i]);
|
blobmsg_add_string(&cap_blob, NULL, users_router[i]);
|
||||||
}
|
}
|
||||||
blobmsg_close_array(&cap_blob, d);
|
blobmsg_close_array(&cap_blob, d);
|
||||||
blob_to_uci_section(cap_uci, "opennds", ifname, "opennds", cap_blob.head, &opennds_param, NULL);
|
blob_to_uci_section(cap_uci, "opennds", "opennds", "opennds", cap_blob.head, &opennds_param, NULL);
|
||||||
uci_commit_all(cap_uci);
|
uci_commit_all(cap_uci);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -546,10 +543,10 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
|
|||||||
char back_image[84];
|
char back_image[84];
|
||||||
char user_file[84];
|
char user_file[84];
|
||||||
|
|
||||||
sprintf(path,"/etc/opennds/htdocs/images/%s/",ifname);
|
sprintf(path,"/etc/opennds/htdocs/images/");
|
||||||
sprintf(webroot,"/etc/opennds/htdocs");
|
sprintf(webroot,"/etc/opennds/htdocs");
|
||||||
sprintf(ipset_tcp80,"allow tcp port 80 ipset set_%s", ifname);
|
sprintf(ipset_tcp80,"allow tcp port 80 ipset set_opennds");
|
||||||
sprintf(ipset_tcp443,"allow tcp port 443 ipset set_%s", ifname);
|
sprintf(ipset_tcp443,"allow tcp port 443 ipset set_opennds");
|
||||||
char file_path[128];
|
char file_path[128];
|
||||||
struct stat st = {0};
|
struct stat st = {0};
|
||||||
if (stat(path, &st) == -1)
|
if (stat(path, &st) == -1)
|
||||||
@@ -574,7 +571,7 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
|
|||||||
blobmsg_add_string(&cap, "gatewayinterface","br-lan");
|
blobmsg_add_string(&cap, "gatewayinterface","br-lan");
|
||||||
blobmsg_add_string(&cap, "authentication", value);
|
blobmsg_add_string(&cap, "authentication", value);
|
||||||
blobmsg_add_string(&cap, "preauth","/usr/lib/opennds/login.sh");
|
blobmsg_add_string(&cap, "preauth","/usr/lib/opennds/login.sh");
|
||||||
ipset_create(ifname);
|
ipset_create("opennds");
|
||||||
d = blobmsg_open_array(&cap, "preauthenticated_users");
|
d = blobmsg_open_array(&cap, "preauthenticated_users");
|
||||||
blobmsg_add_string(&cap, NULL, ipset_tcp80);
|
blobmsg_add_string(&cap, NULL, ipset_tcp80);
|
||||||
blobmsg_add_string(&cap, NULL, ipset_tcp443);
|
blobmsg_add_string(&cap, NULL, ipset_tcp443);
|
||||||
@@ -583,7 +580,7 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
|
|||||||
} else if (strcmp(value,"username")==0) {
|
} else if (strcmp(value,"username")==0) {
|
||||||
blobmsg_add_string(&cap, "webroot",webroot);
|
blobmsg_add_string(&cap, "webroot",webroot);
|
||||||
opennds_parameters(ifname);
|
opennds_parameters(ifname);
|
||||||
ipset_create(ifname);
|
ipset_create("opennds");
|
||||||
blobmsg_add_string(&cap, "enabled", "1");
|
blobmsg_add_string(&cap, "enabled", "1");
|
||||||
blobmsg_add_string(&cap, "gatewayinterface","br-lan");
|
blobmsg_add_string(&cap, "gatewayinterface","br-lan");
|
||||||
blobmsg_add_string(&cap, "authentication", value);
|
blobmsg_add_string(&cap, "authentication", value);
|
||||||
@@ -595,7 +592,7 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
|
|||||||
|
|
||||||
} else if (strcmp(value,"radius")==0) {
|
} else if (strcmp(value,"radius")==0) {
|
||||||
blobmsg_add_string(&cap, "webroot",webroot);
|
blobmsg_add_string(&cap, "webroot",webroot);
|
||||||
opennds_parameters(ifname);
|
opennds_parameters("opennds");
|
||||||
blobmsg_add_string(&cap, "authentication", value);
|
blobmsg_add_string(&cap, "authentication", value);
|
||||||
blobmsg_add_string(&cap, "enabled", "1");
|
blobmsg_add_string(&cap, "enabled", "1");
|
||||||
blobmsg_add_string(&cap, "gatewayinterface","br-lan");
|
blobmsg_add_string(&cap, "gatewayinterface","br-lan");
|
||||||
@@ -607,7 +604,7 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
|
|||||||
blobmsg_close_array(&cap, d);
|
blobmsg_close_array(&cap, d);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
opennds_section_del(ifname);
|
opennds_section_del("opennds");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -665,7 +662,7 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blob_to_uci_section(cap_uci, "opennds", ifname, "opennds", cap.head, &opennds_param, NULL);
|
blob_to_uci_section(cap_uci, "opennds", "opennds", "opennds", cap.head, &opennds_param, NULL);
|
||||||
uci_commit_all(cap_uci);
|
uci_commit_all(cap_uci);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -669,6 +669,7 @@ bool vif_state_update(struct uci_section *s, struct schema_Wifi_VIF_Config *vcon
|
|||||||
char mac[ETH_ALEN * 3];
|
char mac[ETH_ALEN * 3];
|
||||||
char *ifname, radio[IF_NAMESIZE];
|
char *ifname, radio[IF_NAMESIZE];
|
||||||
bool vifIsActive = false;
|
bool vifIsActive = false;
|
||||||
|
char network_name[8];
|
||||||
|
|
||||||
LOGT("%s: get state", s->e.name);
|
LOGT("%s: get state", s->e.name);
|
||||||
|
|
||||||
@@ -736,8 +737,10 @@ bool vif_state_update(struct uci_section *s, struct schema_Wifi_VIF_Config *vcon
|
|||||||
// else
|
// else
|
||||||
// SCHEMA_SET_INT(vstate.uapsd_enable, false);
|
// SCHEMA_SET_INT(vstate.uapsd_enable, false);
|
||||||
|
|
||||||
if (tb[WIF_ATTR_NETWORK])
|
if (tb[WIF_ATTR_NETWORK]) {
|
||||||
SCHEMA_SET_STR(vstate.bridge, blobmsg_get_string(tb[WIF_ATTR_NETWORK]));
|
SCHEMA_SET_STR(vstate.bridge, blobmsg_get_string(tb[WIF_ATTR_NETWORK]));
|
||||||
|
strcpy(network_name, blobmsg_get_string(tb[WIF_ATTR_NETWORK]));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
LOGW("%s: unknown bridge/network", s->e.name);
|
LOGW("%s: unknown bridge/network", s->e.name);
|
||||||
|
|
||||||
@@ -803,9 +806,10 @@ bool vif_state_update(struct uci_section *s, struct schema_Wifi_VIF_Config *vcon
|
|||||||
}
|
}
|
||||||
vif_state_security_get(&vstate, tb);
|
vif_state_security_get(&vstate, tb);
|
||||||
vif_state_custom_options_get(&vstate, tb);
|
vif_state_custom_options_get(&vstate, tb);
|
||||||
vif_state_captive_portal_options_get(&vstate, s);
|
if(!strcmp(network_name,"lan")) {
|
||||||
vif_state_dhcp_allowlist_get(&vstate);
|
vif_state_captive_portal_options_get(&vstate);
|
||||||
|
vif_state_dhcp_allowlist_get(&vstate);
|
||||||
|
}
|
||||||
if (vconf) {
|
if (vconf) {
|
||||||
LOGN("%s: updating vif config", radio);
|
LOGN("%s: updating vif config", radio);
|
||||||
vif_state_to_conf(&vstate, vconf);
|
vif_state_to_conf(&vstate, vconf);
|
||||||
|
|||||||
Reference in New Issue
Block a user