lixuewei / rt-n56u

Automatically exported from code.google.com/p/rt-n56u
0 stars 0 forks source link

dnsmasq setup custom netmask #1165

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It will be cool if custom mask will be suported. Now mask geted from lan 
settings.

I think that this small patch will solve this. Please review:

diff --git a/trunk/user/rc/services_ex.c b/trunk/user/rc/services_ex.c
--- a/trunk/user/rc/services_ex.c
+++ b/trunk/user/rc/services_ex.c
@@ -111,7 +111,7 @@
    FILE *fp;
    int i, i_max, i_sdhcp, i_dns, is_use_dhcp, i_verbose;
    char dhcp_mac[32], dhcp_ip[32], *smac, *sip;
-   char *start, *end, *ipaddr, *mask, *gw, *dns1, *dns2, *dns3;
+   char *start, *end, *ipaddr, *dhcp_mask, *mask, *gw, *dns1, *dns2, *dns3;
    char dhcp_start[16], dhcp_end[16], lan_ipaddr[16], lan_netmask[16];
    size_t ethers = 0;
    char *resolv_conf = "/etc/resolv.conf";
@@ -188,7 +188,8 @@

        start  = nvram_safe_get("dhcp_start");
        end    = nvram_safe_get("dhcp_end");
-       mask   = nvram_safe_get("lan_netmask");
+       dhcp_mask = nvram_safe_get("dhcp_netmask");
+       mask = *dhcp_mask?dhcp_mask:nvram_safe_get("lan_netmask");

        strcpy(lan_ipaddr, *ipaddr?ipaddr:"192.168.1.1");
        strcpy(dhcp_start, *start&&*end?start:"192.168.1.2");
@@ -200,7 +201,7 @@
            nvram_set("dhcp_start", dhcp_start);
            nvram_set("dhcp_end", dhcp_end);
        }
-       
+
        fprintf(fp, "dhcp-range=%s,%s,%s,%s\n", dhcp_start, dhcp_end, lan_netmask, nvram_safe_get("dhcp_lease"));

        /* GATEWAY */
diff --git a/trunk/user/www/n56u_ribbon_fixed/Advanced_DHCP_Content.asp 
b/trunk/user/www/n56u_ribbon_fixed/Advanced_DHCP_Content.asp
--- a/trunk/user/www/n56u_ribbon_fixed/Advanced_DHCP_Content.asp
+++ b/trunk/user/www/n56u_ribbon_fixed/Advanced_DHCP_Content.asp
@@ -121,6 +121,7 @@

    if(!validate_ipaddr_final(document.form.dhcp_start, 'dhcp_start') ||
            !validate_ipaddr_final(document.form.dhcp_end, 'dhcp_end') ||
+           !validate_ipaddr_final(document.form.dhcp_netmask, 'dhcp_netmask') ||
            !validate_ipaddr_final(document.form.dhcp_gateway_x, 'dhcp_gateway_x') ||
            !validate_ipaddr_final(document.form.dhcp_dns1_x, 'dhcp_dns1_x') ||
            !validate_ipaddr_final(document.form.dhcp_dns2_x, 'dhcp_dns1_x') ||
@@ -434,6 +435,12 @@
                                             </td>
                                         </tr>
                                         <tr>
+                                            <th><a class="help_tooltip" 
href="javascript:void(0);">DHCP netmask:</a></th>
+                                            <td>
+                                                <input type="text" 
maxlength="15" class="input" size="15" name="dhcp_netmask" value="<% 
nvram_get_x("","dhcp_netmask"); %>" onKeyPress="return is_ipaddr(this)" 
onKeyUp="change_ipaddr(this)">
+                                            </td>
+                                        </tr>
+                                        <tr>
                                             <th><a class="help_tooltip" href="javascript:void(0);" onmouseover="openTooltip(this,5,5);"><#LANHostConfig_LeaseTime_itemname#></a></th>
                                             <td>
                                                 <input type="text" maxlength="6" size="6" name="dhcp_lease" class="input" value="<% nvram_get_x("", "dhcp_lease"); %>" onKeyPress="return is_number(this)">  

Original issue reported on code.google.com by ruslan.u...@gmail.com on 17 Feb 2014 at 9:24