Project:
IPFire
Code Location:
git://git.ipfire.org/network.gitmaster
/
functions.pppoe-server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2012 IPFire Network Development Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see <http://www.gnu.org/licenses/>. # # # ############################################################################### function pppoe_server_start() { local zone=${1} assert isset zone service_start "pppoe-server@${zone}.service" } function pppoe_server_stop() { local zone=${1} assert isset zone service_stop "pppoe-server@${zone}.service" } function pppoe_server_status() { local zone=${1} assert isset zone service_status "pppoe-server@${zone}.service" } function pppoe_server_options() { local file=${1} assert isset file local zone=${2} assert isset zone shift 2 local auth="false" local default_asyncmap="true" local dns_servers local lcp_echo_failure=5 local lcp_echo_interval=60 local proxyarp="true" local required_auths local value while [ $# -gt 0 ]; do case "${1}" in --auth=*) auth=$(cli_get_val ${1}) ;; --default-asyncmap=*) default_asyncmap=$(cli_get_val ${1}) ;; --dns-server=*) dns_servers="${dns_servers} $(cli_get_val ${1})" ;; --lcp-echo-failure=*) lcp_echo_failure=$(cli_get_val ${1}) assert isinteger ${lcp_echo_failure} ;; --lcp-echo-interval=*) lcp_echo_interval=$(cli_get_val ${1}) assert isinteger ${lcp_echo_interval} ;; --proxyarp=*) proxyarp=$(cli_get_val ${1}) ;; --require-auth=*) required_auths="${required_auths} $(cli_get_val ${1})" ;; esac shift done mkdir -p $(dirname ${file}) 2>/dev/null config_header "pppoe-server options configuration file" > ${file} # Authentication ( print "# Authentication" if enabled auth; then print "auth" else print "noauth" fi print ) >> ${file} # If there are only a number of auth algorithms allowed, we # define them here. if isset required_auths; then print "# Required authentication methods" >> ${file} local method for method in ${required_auths}; do print "require-${method}" done >> ${file} print >> ${file} fi # DNS servers if isset dns_servers; then print "# DNS servers" >> ${file} local server for server in ${dns_servers}; do print "ms-dns ${server}" done >> ${file} print >> ${file} fi # Default asyncmap if enabled default_asyncmap; then ( print "# Default asyncmap" print "default-asyncmap" print ) >> ${file} fi # LCP settings. ( print "# LCP settings" print "lcp-echo-failure ${lcp_echo_failure}" print "lcp-echo-interval ${lcp_echo_interval}" print ) >> ${file} # Proxy ARP ( print "# Proxy ARP" if enabled proxyarp; then print "proxyarp" else print "noproxyarp" fi print ) >> ${file} # Default options, we always set. ( print "debug" print "nodefaultroute" print "noipdefault" print "noipx" ) >> ${file} return ${EXIT_OK} } function pppoe_server_poolfile() { local file=${1} assert isset file local subnet=${2} assert isset subnet config_header "PPPoE server IP address pool file" > ${file} # The network address will be the gateway address. local netaddr=$(ipv4_get_network ${subnet}) local addr for addr in $(ipv4_range_explicit ${subnet}); do [ "${addr}" = "${netaddr}" ] && continue print "${addr}" done >> ${file} return ${EXIT_OK} }
