From 4476ee0dba7cfece304a4358797d5eac98f2ab68 Mon Sep 17 00:00:00 2001 From: Toastman Date: Fri, 23 Sep 2011 04:59:27 +0700 Subject: [PATCH] Changed default policy about LAN/bridge access: LAN bridges are no longer accessible from each other by default. Access between LANs can be granted/managed via a new/experimental GUI. --- release/src/router/httpd/tomato.c | 3 + release/src/router/rc/firewall.c | 73 ++++++--- release/src/router/www/advanced-access.asp | 239 +++++++++++++++++++++++++++++ release/src/router/www/tomato.js | 3 +- 4 files changed, 294 insertions(+), 24 deletions(-) create mode 100644 release/src/router/www/advanced-access.asp diff --git a/release/src/router/httpd/tomato.c b/release/src/router/httpd/tomato.c index b75891da4a..5a04fdbab1 100644 --- a/release/src/router/httpd/tomato.c +++ b/release/src/router/httpd/tomato.c @@ -767,6 +767,9 @@ static const nvset_t nvset_list[] = { { "dr_wan_rx", V_LENGTH(0, 32) }, #endif +// advanced-access + { "lan_access", V_LENGTH(0, 4096) }, + // advanced-wireless { "wl_country", V_LENGTH(0, 64) }, // !!TB - Country code { "wl_country_code", V_LENGTH(0, 4) }, // !!TB - Country code diff --git a/release/src/router/rc/firewall.c b/release/src/router/rc/firewall.c index ba0aa29535..48e10f3b9d 100644 --- a/release/src/router/rc/firewall.c +++ b/release/src/router/rc/firewall.c @@ -38,13 +38,7 @@ char lan3face[IFNAMSIZ + 1]; #ifdef TCONFIG_IPV6 char wan6face[IFNAMSIZ + 1]; #endif - - char lan_cclass[sizeof("xxx.xxx.xxx.") + 1]; -//char lan1_cclass[sizeof("xxx.xxx.xxx.") + 1]; -//char lan2_cclass[sizeof("xxx.xxx.xxx.") + 1]; -//char lan3_cclass[sizeof("xxx.xxx.xxx.") + 1]; - #ifdef LINUX26 static int can_enable_fastnat; #endif @@ -973,22 +967,20 @@ static void filter_forward(void) ip46t_write( "-A FORWARD -i %s -o %s -j ACCEPT\n", // accept all lan to lan -// "-A FORWARD -m state --state INVALID -j DROP\n", // drop if INVALID state - lanface, lanface); if (strcmp(lan1face,"")!=0) - ipt_write( + ip46t_write( "-A FORWARD -i %s -o %s -j ACCEPT\n", lan1face, lan1face); if (strcmp(lan2face,"")!=0) - ipt_write( + ip46t_write( "-A FORWARD -i %s -o %s -j ACCEPT\n", lan2face, lan2face); if (strcmp(lan3face,"")!=0) - ipt_write( + ip46t_write( "-A FORWARD -i %s -o %s -j ACCEPT\n", lan3face, lan3face); - ipt_write( + ip46t_write( "-A FORWARD -m state --state INVALID -j DROP\n"); // drop if INVALID state // IPv4 only ? @@ -1043,17 +1035,52 @@ static void filter_forward(void) } } - ip46t_write("-A FORWARD -i %s -j %s\n", // from lan - lanface, chain_out_accept); - if (strcmp(lan1face,"")!=0) - ipt_write("-A FORWARD -i %s -j %s\n", // from lan - lan1face, chain_out_accept); - if (strcmp(lan2face,"")!=0) - ipt_write("-A FORWARD -i %s -j %s\n", // from lan - lan2face, chain_out_accept); - if (strcmp(lan3face,"")!=0) - ipt_write("-A FORWARD -i %s -j %s\n", // from lan - lan3face, chain_out_accept); + for (i = 0; i < wanfaces.count; ++i) { + if (*(wanfaces.iface[i].name)) { + ip46t_write("-A FORWARD -i %s -o %s -j %s\n", lanface, wanfaces.iface[i].name, chain_out_accept); + if (strcmp(lan1face,"")!=0) + ip46t_write("-A FORWARD -i %s -o %s -j %s\n", lan1face, wanfaces.iface[i].name, chain_out_accept); + if (strcmp(lan2face,"")!=0) + ip46t_write("-A FORWARD -i %s -o %s -j %s\n", lan2face, wanfaces.iface[i].name, chain_out_accept); + if (strcmp(lan3face,"")!=0) + ip46t_write("-A FORWARD -i %s -o %s -j %s\n", lan3face, wanfaces.iface[i].name, chain_out_accept); + } + } + + const char *d, *sbr, *saddr, *dbr, *daddr, *desc; + char *nv, *nvp, *b; + int n; + nvp = nv = strdup(nvram_safe_get("lan_access")); + if (nv) { + while ((b = strsep(&nvp, ">")) != NULL) { + /* + 1<0<1.2.3.4<1<5.6.7.8<30,45-50 + + + + + +[<% ident(); %>] Advanced: LAN Access + +<% css(); %> + + + + + + +
+ + + + + +
+
<% ident(); %>
+ + + + + +
LAN Access
+
+
+
+ + +
+
    +
  • Src - Source LAN bridge.
  • +
  • Src Address (optional) - Source address allowed. Ex: "1.2.3.4", "1.2.3.4 - 2.3.4.5", "1.2.3.0/24".
  • +
  • Dst - Destination LAN bridge.
  • +
  • Dst Address (optional) - Destination address inside the LAN.
  • +
+
+ +
+
+ + diff --git a/release/src/router/www/tomato.js b/release/src/router/www/tomato.js index 0f71a971e5..eaea8bd915 100644 --- a/release/src/router/www/tomato.js +++ b/release/src/router/www/tomato.js @@ -2373,6 +2373,7 @@ function navi() ['Miscellaneous', 'misc.asp'], ['Routing', 'routing.asp'], ['VLAN', 'vlan.asp'], + ['LAN Access', 'access.asp'], ['Wireless', 'wireless.asp'] ] ], ['Port Forwarding', 'forward', 0, [ ['Basic', 'basic.asp'], @@ -2426,7 +2427,7 @@ REMOVE-END */ ['Administration', 'admin', 0, [ ['Admin Access', 'access.asp'], ['Bandwidth Monitoring','bwm.asp'], - ['Buttons / LED', 'buttons.asp'], + ['Buttons/LED', 'buttons.asp'], /* CIFS-BEGIN */ ['CIFS Client', 'cifs.asp'], /* CIFS-END */ -- 2.11.4.GIT