Project

General

Profile

« Previous | Next » 

Revision d6a0379d

Added by Ermal LUÇI almost 15 years ago

Add a subnet option to allowed ip addresses on CP.

View differences:

etc/inc/captiveportal.inc
886 886
                $bw_up = $ruleno + 20000;
887 887
        	$rules .= "pipe {$bw_up} config bw {$ipent['bw_up']}Kbit/s queue 100\n";
888 888
        }
889
	$subnet = "";
890
	if (!empty($ipent['sn']))
891
		$subnet = "/{$ipent['sn']}";
889 892
	foreach ($tablein as $table)
890
               $rules .= "table {$table} add {$ipent['ip']} {$bw_up}\n";
893
               $rules .= "table {$table} add {$ipent['ip']}{$subnet} {$bw_up}\n";
891 894
        if ($enBwdown) {
892 895
               $bw_down = $ruleno + 20001;
893 896
               $rules .= "pipe {$bw_down} config bw {$ipent['bw_down']}Kbit/s queue 100\n";
894 897
        }
895 898
        foreach ($tableout as $table)
896
        	$rules .= "table {$table} add {$ipent['ip']} {$bw_down}\n";
899
        	$rules .= "table {$table} add {$ipent['ip']}{$subnet} {$bw_down}\n";
897 900

  
898 901
	return $rules;
899 902
}
usr/local/www/services_captiveportal_ip.php
59 59
		$ipent = $a_allowedips[$_GET['id']];
60 60
		
61 61
		if (isset($config['captiveportal']['enable'])) {
62
			if (!empty($ipent['sn']))
63
				$ipent['ip'] .= "/{$ipent['sn']}";
62 64
			mwexec("/sbin/ipfw table 3 delete " . $ipent['ip']);
63 65
			mwexec("/sbin/ipfw table 4 delete " . $ipent['ip']);
64 66
			mwexec("/sbin/ipfw table 5 delete " . $ipent['ip']);
65 67
			mwexec("/sbin/ipfw table 6 delete " . $ipent['ip']);
68
			mwexec("/sbin/ipfw table 7 delete " . $ipent['ip']);
69
			mwexec("/sbin/ipfw table 8 delete " . $ipent['ip']);
70
			mwexec("/sbin/ipfw table 9 delete " . $ipent['ip']);
71
			mwexec("/sbin/ipfw table 10 delete " . $ipent['ip']);
66 72
		}
67 73
			
68 74
		unset($a_allowedips[$_GET['id']]);
usr/local/www/services_captiveportal_ip_edit.php
70 70

  
71 71
if (isset($id) && $a_allowedips[$id]) {
72 72
	$pconfig['ip'] = $a_allowedips[$id]['ip'];
73
	$pconfig['sn'] = $a_allowedips[$id]['sn'];
73 74
	$pconfig['dir'] = $a_allowedips[$id]['dir'];
74 75
	$pconfig['bw_up'] = $a_allowedips[$id]['bw_up'];
75 76
	$pconfig['bw_down'] = $a_allowedips[$id]['bw_down'];
......
108 109
	if (!$input_errors) {
109 110
		$ip = array();
110 111
		$ip['ip'] = $_POST['ip'];
112
		$ip['sn'] = $_POST['sn'];
111 113
		$ip['dir'] = $_POST['dir'];
112 114
		$ip['descr'] = $_POST['descr'];
113 115
		if ($_POST['bw_up'])
......
116 118
                        $ip['bw_down'] = $_POST['bw_down'];
117 119
		if (isset($id) && $a_allowedips[$id]) {
118 120
			$oldip = $a_allowedips[$id]['ip'];
121
			if (!empty($a_allowedips[$id]['sn']))
122
				$oldip .= "/{$a_allowedips[$id]['sn']}";
119 123
			$a_allowedips[$id] = $ip;
120 124
		} else {
121 125
			$oldip = $ip['ip'];
126
			if (!empty($$ip['sn']))
127
				$oldip .= "/{$$ip['sn']}";
122 128
			$a_allowedips[] = $ip;
123 129
		}
124 130
		allowedips_sort();
......
168 174
                  <td width="22%" valign="top" class="vncellreq">IP address</td>
169 175
                  <td width="78%" class="vtable"> 
170 176
                    <?=$mandfldhtml;?><input name="ip" type="text" class="formfld unknown" id="ip" size="17" value="<?=htmlspecialchars($pconfig['ip']);?>">
177
		    <select name='sn' class="formselect" id='sn'>
178
			<?php for ($i = 32; $i >= 1; $i--): ?>
179
			<option value="<?=$i;?>" <?php if ($i == $pconfig['sn']) echo "selected"; ?>><?=$i;?></option>
180
			<?php endfor; ?>
181
		    </select>
171 182
                    <br> 
172 183
                    <span class="vexpl">IP address</span></td>
173 184
                </tr>

Also available in: Unified diff