]> git.ipfire.org Git - network.git/commitdiff
pppoe-server: Add option to limit sessions per MAC.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 24 Jun 2012 13:20:40 +0000 (13:20 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 24 Jun 2012 13:20:40 +0000 (13:20 +0000)
hooks/zones/bridge.configs/pppoe-server
ppp/pppoe-server

index b6ba0ea64a7f8aa151791b723a04219c3ae5f75d..0b1cd4cc27828a7c150bc89c6d291ab81c82926d 100755 (executable)
@@ -21,7 +21,7 @@
 
 . /usr/lib/network/header-config
 
-HOOK_SETTINGS="HOOK MTU SERVICE_NAME SUBNET"
+HOOK_SETTINGS="HOOK MTU SERVICE_NAME SUBNET MAX_SESSIONS"
 
 # Maximum Transmission Unit.
 MTU=1492
@@ -33,9 +33,14 @@ SERVICE_NAME=
 # The net address will be the gateway address for the PPPoE server.
 SUBNET=
 
+# Defines the max. number of sessions per MAC address.
+# 0 = unlimited.
+MAX_SESSIONS=0
+
 function _check() {
        assert isset MTU
        assert isset SUBNET
+       assert isset MAX_SESSIONS
 }
 
 function _create() {
@@ -44,6 +49,9 @@ function _create() {
 
        while [ $# -gt 0 ]; do
                case "${1}" in
+                       --max-sessions=*)
+                               MAX_SESSIONS=$(cli_get_val ${1})
+                               ;;
                        --mtu=*)
                                MTU=$(cli_get_val ${1})
                                ;;
@@ -121,5 +129,12 @@ function _status() {
                "${start_address}-${end_address}"
        cli_space
 
+       local max_sessions=${MAX_SESSIONS}
+       if [ "${max_sessions}" = "0" ]; then
+               max_sessions="unlimited"
+       fi
+       cli_print_fmt1 3 "${max_sessions} session(s) per MAC"
+       cli_space
+
        exit ${EXIT_OK}
 }
index 01538ba7b3557737c1ad66d1e7d2eba66f7a3817..33da580edab1c17f5536d7b56101d743f8ba0c67 100644 (file)
@@ -66,6 +66,11 @@ case "${action}" in
                        pppoe_cmdline="${pppoe_cmdline} -S ${SERVICE_NAME// /_}"
                fi
 
+               # Add the max. number of sessions per MAC address.
+               if [ ${MAX_SESSIONS} -gt 0 ]; then
+                       pppoe_cmdline="${pppoe_cmdline} -x ${MAX_SESSIONS}"
+               fi
+
                # Create the pppoe-server-options file.
                pppoe_server_options ${pppd_options} ${zone}
                pppoe_cmdline="${pppoe_cmdline} -O ${pppd_options}"